summaryrefslogtreecommitdiff
path: root/odk
diff options
context:
space:
mode:
Diffstat (limited to 'odk')
-rw-r--r--odk/cfgWin.js981
-rwxr-xr-xodk/configure.pl808
-rw-r--r--odk/docs/common/ref/idl.css130
-rw-r--r--odk/docs/cpp/ref/cpp.css127
-rw-r--r--odk/docs/images/arrow-1.gifbin0 -> 98 bytes
-rw-r--r--odk/docs/images/arrow-2.gifbin0 -> 68 bytes
-rw-r--r--odk/docs/images/arrow-3.gifbin0 -> 98 bytes
-rw-r--r--odk/docs/images/bg_table.gifbin0 -> 42 bytes
-rw-r--r--odk/docs/images/bg_table.pngbin0 -> 128 bytes
-rwxr-xr-xodk/docs/images/bg_table2.gifbin0 -> 44 bytes
-rw-r--r--odk/docs/images/bg_table2.pngbin0 -> 128 bytes
-rwxr-xr-xodk/docs/images/bg_table3.gifbin0 -> 44 bytes
-rw-r--r--odk/docs/images/bg_table3.pngbin0 -> 128 bytes
-rw-r--r--odk/docs/images/bluball.gifbin0 -> 103 bytes
-rw-r--r--odk/docs/images/nada.gifbin0 -> 49 bytes
-rw-r--r--odk/docs/images/nav_down.pngbin0 -> 224 bytes
-rw-r--r--odk/docs/images/nav_home.pngbin0 -> 471 bytes
-rw-r--r--odk/docs/images/nav_left.pngbin0 -> 223 bytes
-rw-r--r--odk/docs/images/nav_right.pngbin0 -> 225 bytes
-rw-r--r--odk/docs/images/nav_up.pngbin0 -> 211 bytes
-rw-r--r--odk/docs/images/odk-footer-logo.gifbin0 -> 850 bytes
-rw-r--r--odk/docs/images/ooo-main-app_32.pngbin0 -> 2429 bytes
-rw-r--r--odk/docs/images/orc-main-app_32.pngbin0 -> 2496 bytes
-rw-r--r--odk/docs/images/sdk_head-1.pngbin0 -> 11767 bytes
-rw-r--r--odk/docs/images/sdk_head-2.pngbin0 -> 175 bytes
-rw-r--r--odk/docs/images/sdk_line-1.gifbin0 -> 43 bytes
-rw-r--r--odk/docs/images/sdk_line-2.gifbin0 -> 113 bytes
-rw-r--r--odk/docs/install.html420
-rw-r--r--odk/docs/notsupported.html4
-rw-r--r--odk/docs/sdk_styles.css130
-rw-r--r--odk/docs/tools.html1094
-rw-r--r--odk/examples/CLI/CSharp/Spreadsheet/GeneralTableSample.cs206
-rw-r--r--odk/examples/CLI/CSharp/Spreadsheet/Makefile79
-rw-r--r--odk/examples/CLI/CSharp/Spreadsheet/SpreadsheetDocHelper.cs344
-rw-r--r--odk/examples/CLI/CSharp/Spreadsheet/SpreadsheetSample.cs1478
-rw-r--r--odk/examples/CLI/CSharp/Spreadsheet/ViewSample.cs165
-rw-r--r--odk/examples/CLI/VB.NET/WriterDemo/Makefile61
-rw-r--r--odk/examples/CLI/VB.NET/WriterDemo/WriterDemo.vb242
-rw-r--r--odk/examples/CLI/makefile.mk72
-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.java1123
-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.java330
-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
-rw-r--r--odk/examples/OLE/activex/Makefile122
-rw-r--r--odk/examples/OLE/activex/README.txt39
-rw-r--r--odk/examples/OLE/activex/SOActiveX.cpp645
-rw-r--r--odk/examples/OLE/activex/SOActiveX.h166
-rw-r--r--odk/examples/OLE/activex/SOActiveX.rgs33
-rw-r--r--odk/examples/OLE/activex/SOComWindowPeer.cpp58
-rw-r--r--odk/examples/OLE/activex/SOComWindowPeer.h162
-rw-r--r--odk/examples/OLE/activex/SOComWindowPeer.rgs23
-rw-r--r--odk/examples/OLE/activex/StdAfx2.cpp46
-rw-r--r--odk/examples/OLE/activex/StdAfx2.h65
-rw-r--r--odk/examples/OLE/activex/example.html26
-rw-r--r--odk/examples/OLE/activex/resource.h55
-rw-r--r--odk/examples/OLE/activex/so_activex.cpp108
-rw-r--r--odk/examples/OLE/activex/so_activex.def5
-rw-r--r--odk/examples/OLE/activex/so_activex.idl138
-rw-r--r--odk/examples/OLE/activex/so_activex.rc136
-rw-r--r--odk/examples/OLE/delphi/InsertTables/Project1.dpr14
-rw-r--r--odk/examples/OLE/delphi/InsertTables/Project1.res0
-rw-r--r--odk/examples/OLE/delphi/InsertTables/SampleCode.pas393
-rw-r--r--odk/examples/OLE/delphi/InsertTables/SampleUI.dfm4
-rw-r--r--odk/examples/OLE/delphi/InsertTables/SampleUI.pas168
-rw-r--r--odk/examples/OLE/delphi/StarOffice_Delphi.sxwbin0 -> 34970 bytes
-rw-r--r--odk/examples/OLE/delphi/StarOffice_and_Delphi.pdfbin0 -> 60963 bytes
-rw-r--r--odk/examples/OLE/makefile.mk93
-rw-r--r--odk/examples/OLE/vbscript/WriterDemo.vbs172
-rw-r--r--odk/examples/OLE/vbscript/readme.txt4
-rw-r--r--odk/examples/basic/drawing/dirtree.txt20
-rw-r--r--odk/examples/basic/drawing/importexportofasciifiles.odgbin0 -> 11125 bytes
-rw-r--r--odk/examples/basic/forms_and_controls/beef.wmfbin0 -> 9856 bytes
-rw-r--r--odk/examples/basic/forms_and_controls/burger.wmfbin0 -> 84308 bytes
-rw-r--r--odk/examples/basic/forms_and_controls/burger_factory.odtbin0 -> 18934 bytes
-rw-r--r--odk/examples/basic/forms_and_controls/chicken.wmfbin0 -> 14272 bytes
-rw-r--r--odk/examples/basic/forms_and_controls/fish.wmfbin0 -> 13716 bytes
-rw-r--r--odk/examples/basic/forms_and_controls/vegetable.wmfbin0 -> 17862 bytes
-rw-r--r--odk/examples/basic/makefile.mk91
-rw-r--r--odk/examples/basic/sheet/adapting_to_euroland.odsbin0 -> 9964 bytes
-rw-r--r--odk/examples/basic/stock_quotes_updater/stock.odsbin0 -> 21540 bytes
-rw-r--r--odk/examples/basic/text/creating_an_index/index.odtbin0 -> 13160 bytes
-rw-r--r--odk/examples/basic/text/creating_an_index/indexlist.txt9
-rw-r--r--odk/examples/basic/text/modifying_text_automatically/changing_appearance.odtbin0 -> 9883 bytes
-rw-r--r--odk/examples/basic/text/modifying_text_automatically/inserting_bookmarks.odtbin0 -> 10207 bytes
-rw-r--r--odk/examples/basic/text/modifying_text_automatically/replacing_text.odtbin0 -> 10021 bytes
-rw-r--r--odk/examples/basic/text/modifying_text_automatically/using_regular_expressions.odtbin0 -> 10072 bytes
-rw-r--r--odk/examples/cpp/DocumentLoader/DocumentLoader.cxx167
-rw-r--r--odk/examples/cpp/DocumentLoader/Makefile127
-rw-r--r--odk/examples/cpp/DocumentLoader/test.odtbin0 -> 6737 bytes
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/Addons.xcu170
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/CalcListener.cxx39
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/CalcWindowState.xcu21
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/Jobs.xcu23
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/ListenerHelper.cxx144
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/ListenerHelper.h82
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/Makefile166
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/MyJob.cxx109
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/MyJob.h150
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/MyListener.cxx167
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/MyListener.h96
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx539
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h141
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/ProtocolHandler.xcu10
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/WriterListener.cxx47
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/WriterWindowState.xcu21
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/exports.cxx120
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/logo_big.pngbin0 -> 616 bytes
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/logo_small.pngbin0 -> 585 bytes
-rw-r--r--odk/examples/cpp/counter/Makefile161
-rw-r--r--odk/examples/cpp/counter/XCountable.idl55
-rw-r--r--odk/examples/cpp/counter/counter.cxx238
-rw-r--r--odk/examples/cpp/counter/countermain.cxx122
-rw-r--r--odk/examples/cpp/makefile.mk80
-rw-r--r--odk/examples/cpp/remoteclient/Makefile160
-rw-r--r--odk/examples/cpp/remoteclient/remoteclient.cxx283
-rw-r--r--odk/examples/examples.html750
-rw-r--r--odk/examples/java/ConverterServlet/ConverterServlet.html46
-rw-r--r--odk/examples/java/ConverterServlet/ConverterServlet.java336
-rw-r--r--odk/examples/java/ConverterServlet/Makefile94
-rw-r--r--odk/examples/java/ConverterServlet/README38
-rw-r--r--odk/examples/java/ConverterServlet/web.xml23
-rw-r--r--odk/examples/java/DocumentHandling/DocumentConverter.java225
-rw-r--r--odk/examples/java/DocumentHandling/DocumentLoader.java92
-rw-r--r--odk/examples/java/DocumentHandling/DocumentPrinter.java109
-rw-r--r--odk/examples/java/DocumentHandling/DocumentSaver.java131
-rw-r--r--odk/examples/java/DocumentHandling/Makefile145
-rw-r--r--odk/examples/java/DocumentHandling/test/test1.odtbin0 -> 7999 bytes
-rw-r--r--odk/examples/java/Drawing/Makefile92
-rw-r--r--odk/examples/java/Drawing/SDraw.java272
-rw-r--r--odk/examples/java/EmbedDocument/Container1/EmbedContApp.java1024
-rw-r--r--odk/examples/java/EmbedDocument/Container1/EmbedContFrame.java108
-rw-r--r--odk/examples/java/EmbedDocument/Container1/Makefile48
-rwxr-xr-xodk/examples/java/EmbedDocument/EmbeddedObject/EditorFrame.java121
-rw-r--r--odk/examples/java/EmbedDocument/EmbeddedObject/EmbeddedObject.odtbin0 -> 9975 bytes
-rwxr-xr-xodk/examples/java/EmbedDocument/EmbeddedObject/EmbeddedObject.xcu28
-rw-r--r--odk/examples/java/EmbedDocument/EmbeddedObject/Makefile147
-rwxr-xr-xodk/examples/java/EmbedDocument/EmbeddedObject/OwnEmbeddedObject.java1124
-rwxr-xr-xodk/examples/java/EmbedDocument/EmbeddedObject/OwnEmbeddedObjectFactory.java101
-rwxr-xr-xodk/examples/java/Inspector/Addon.xcu28
-rwxr-xr-xodk/examples/java/Inspector/Addons.xcu23
-rw-r--r--odk/examples/java/Inspector/HideableMutableTreeNode.java88
-rw-r--r--odk/examples/java/Inspector/HideableTreeModel.java298
-rw-r--r--odk/examples/java/Inspector/Inspector.java461
-rw-r--r--odk/examples/java/Inspector/InspectorAddon.java228
-rw-r--r--odk/examples/java/Inspector/InspectorPane.java629
-rw-r--r--odk/examples/java/Inspector/InstanceInspector.idl52
-rw-r--r--odk/examples/java/Inspector/InstanceInspectorTest.odtbin0 -> 12272 bytes
-rw-r--r--odk/examples/java/Inspector/Introspector.java667
-rw-r--r--odk/examples/java/Inspector/Makefile195
-rw-r--r--odk/examples/java/Inspector/MethodParametersDialog.java353
-rwxr-xr-xodk/examples/java/Inspector/ObjectInspector.xcs18
-rwxr-xr-xodk/examples/java/Inspector/ObjectInspector.xcu18
-rwxr-xr-xodk/examples/java/Inspector/ProtocolHandler.xcu11
-rw-r--r--odk/examples/java/Inspector/ProtocolHandlerAddon.java283
-rw-r--r--odk/examples/java/Inspector/SourceCodeGenerator.java1766
-rw-r--r--odk/examples/java/Inspector/SwingDialogProvider.java442
-rw-r--r--odk/examples/java/Inspector/SwingTreeControlProvider.java427
-rw-r--r--odk/examples/java/Inspector/SwingTreePathProvider.java40
-rw-r--r--odk/examples/java/Inspector/SwingUnoFacetteNode.java84
-rw-r--r--odk/examples/java/Inspector/SwingUnoMethodNode.java138
-rw-r--r--odk/examples/java/Inspector/SwingUnoNode.java156
-rw-r--r--odk/examples/java/Inspector/SwingUnoPropertyNode.java96
-rw-r--r--odk/examples/java/Inspector/TDocSupplier.java168
-rw-r--r--odk/examples/java/Inspector/TestInspector.java88
-rw-r--r--odk/examples/java/Inspector/UnoFacetteNode.java85
-rw-r--r--odk/examples/java/Inspector/UnoMethodNode.java228
-rw-r--r--odk/examples/java/Inspector/UnoNode.java437
-rw-r--r--odk/examples/java/Inspector/UnoPropertyNode.java225
-rw-r--r--odk/examples/java/Inspector/UnoTreeRenderer.java135
-rw-r--r--odk/examples/java/Inspector/XDialogProvider.java65
-rw-r--r--odk/examples/java/Inspector/XInstanceInspector.idl56
-rw-r--r--odk/examples/java/Inspector/XLanguageSourceCodeGenerator.java106
-rw-r--r--odk/examples/java/Inspector/XMethodParametersDialog.java37
-rw-r--r--odk/examples/java/Inspector/XTreeControlProvider.java93
-rw-r--r--odk/examples/java/Inspector/XTreePathProvider.java25
-rw-r--r--odk/examples/java/Inspector/XUnoFacetteNode.java63
-rw-r--r--odk/examples/java/Inspector/XUnoMethodNode.java68
-rw-r--r--odk/examples/java/Inspector/XUnoNode.java84
-rw-r--r--odk/examples/java/Inspector/XUnoPropertyNode.java51
-rwxr-xr-xodk/examples/java/Inspector/images/containers_16.pngbin0 -> 233 bytes
-rwxr-xr-xodk/examples/java/Inspector/images/content_16.pngbin0 -> 370 bytes
-rwxr-xr-xodk/examples/java/Inspector/images/interfaces_16.pngbin0 -> 433 bytes
-rwxr-xr-xodk/examples/java/Inspector/images/methods_16.pngbin0 -> 380 bytes
-rwxr-xr-xodk/examples/java/Inspector/images/properties_16.pngbin0 -> 242 bytes
-rwxr-xr-xodk/examples/java/Inspector/images/services_16.pngbin0 -> 258 bytes
-rwxr-xr-xodk/examples/java/Inspector/manifest.mf3
-rw-r--r--odk/examples/java/MinimalComponent/BuildMinimalComponent.xml64
-rw-r--r--odk/examples/java/MinimalComponent/Makefile203
-rw-r--r--odk/examples/java/MinimalComponent/MinimalComponent.idl52
-rw-r--r--odk/examples/java/MinimalComponent/MinimalComponent.java171
-rw-r--r--odk/examples/java/MinimalComponent/TestMinimalComponent.java69
-rw-r--r--odk/examples/java/NotesAccess/Makefile113
-rw-r--r--odk/examples/java/NotesAccess/NotesAccess.java288
-rw-r--r--odk/examples/java/NotesAccess/Stocks.nsfbin0 -> 262144 bytes
-rw-r--r--odk/examples/java/PropertySet/Makefile134
-rw-r--r--odk/examples/java/PropertySet/PropTest.java265
-rw-r--r--odk/examples/java/PropertySet/PropertySet.odtbin0 -> 8391 bytes
-rw-r--r--odk/examples/java/Spreadsheet/CalcAddins.java304
-rw-r--r--odk/examples/java/Spreadsheet/CalcAddins.odsbin0 -> 8653 bytes
-rw-r--r--odk/examples/java/Spreadsheet/ChartTypeChange.java355
-rw-r--r--odk/examples/java/Spreadsheet/EuroAdaption.java389
-rw-r--r--odk/examples/java/Spreadsheet/Makefile213
-rw-r--r--odk/examples/java/Spreadsheet/SCalc.java412
-rw-r--r--odk/examples/java/Spreadsheet/XCalcAddins.idl100
-rw-r--r--odk/examples/java/Storage/Makefile58
-rw-r--r--odk/examples/java/Storage/StorageFunctionality.java147
-rw-r--r--odk/examples/java/Storage/StorageTest.java7
-rw-r--r--odk/examples/java/Storage/Test01.java158
-rw-r--r--odk/examples/java/Storage/Test02.java152
-rw-r--r--odk/examples/java/Storage/Test03.java209
-rw-r--r--odk/examples/java/Storage/Test04.java273
-rw-r--r--odk/examples/java/Storage/Test05.java268
-rw-r--r--odk/examples/java/Storage/Test06.java278
-rw-r--r--odk/examples/java/Storage/Test07.java137
-rw-r--r--odk/examples/java/Storage/Test08.java213
-rw-r--r--odk/examples/java/Storage/Test09.java123
-rw-r--r--odk/examples/java/Storage/TestHelper.java864
-rw-r--r--odk/examples/java/Text/BookmarkInsertion.java284
-rw-r--r--odk/examples/java/Text/GraphicsInserter.java179
-rw-r--r--odk/examples/java/Text/HardFormatting.java286
-rw-r--r--odk/examples/java/Text/Makefile136
-rw-r--r--odk/examples/java/Text/SWriter.java397
-rw-r--r--odk/examples/java/Text/StyleCreation.java226
-rw-r--r--odk/examples/java/Text/StyleInitialization.java320
-rw-r--r--odk/examples/java/Text/TextDocumentStructure.java205
-rw-r--r--odk/examples/java/Text/TextReplace.java231
-rw-r--r--odk/examples/java/Text/WriterSelector.java162
-rw-r--r--odk/examples/java/Text/oo_smiley.gifbin0 -> 46109 bytes
-rw-r--r--odk/examples/java/ToDo/Makefile166
-rw-r--r--odk/examples/java/ToDo/ToDo.idl50
-rw-r--r--odk/examples/java/ToDo/ToDo.java965
-rw-r--r--odk/examples/java/ToDo/ToDo.odsbin0 -> 13276 bytes
-rw-r--r--odk/examples/java/ToDo/XToDo.idl50
-rw-r--r--odk/examples/java/makefile.mk155
-rw-r--r--odk/inc/makefile.mk47
-rw-r--r--odk/inc/pch/precompiled_odk.cxx29
-rw-r--r--odk/inc/pch/precompiled_odk.hxx32
-rw-r--r--odk/index.html203
-rw-r--r--odk/no_localization1
-rw-r--r--odk/pack/checkbin/makefile.mk51
-rw-r--r--odk/pack/checkidl/makefile.mk51
-rw-r--r--odk/pack/checkinc/makefile.mk54
-rw-r--r--odk/pack/checkinc2/makefile.mk54
-rwxr-xr-xodk/pack/copying/addsym-macosx.sh11
-rw-r--r--odk/pack/copying/dk.mk3
-rw-r--r--odk/pack/copying/idl_chapter_refs.txt7555
-rw-r--r--odk/pack/copying/makefile.mk262
-rw-r--r--odk/pack/gendocu/java/package-list135
-rw-r--r--odk/pack/gendocu/makefile.mk122
-rw-r--r--odk/pack/gendocu/uno/package-list53
-rw-r--r--odk/pack/unzip_udk/deltree.txt0
-rw-r--r--odk/pack/unzip_udk/makefile.mk46
-rw-r--r--odk/prj/build.lst15
-rw-r--r--odk/prj/d.lst5
-rw-r--r--odk/setsdkenv_unix67
-rw-r--r--odk/setsdkenv_unix.csh.in313
-rw-r--r--odk/setsdkenv_unix.sh.in343
-rwxr-xr-xodk/setsdkenv_windows.bat64
-rwxr-xr-xodk/setsdkenv_windows.template183
-rwxr-xr-xodk/setsdkname.bat3
-rw-r--r--odk/settings/component.uno.def4
-rw-r--r--odk/settings/settings.mk607
-rw-r--r--odk/settings/std.mk63
-rw-r--r--odk/settings/stdtarget.mk16
-rw-r--r--odk/source/com/sun/star/lib/loader/InstallationFinder.java584
-rw-r--r--odk/source/com/sun/star/lib/loader/Loader.java385
-rw-r--r--odk/source/com/sun/star/lib/loader/WinRegKey.java200
-rw-r--r--odk/source/com/sun/star/lib/loader/WinRegKeyException.java51
-rw-r--r--odk/source/com/sun/star/lib/loader/makefile.mk56
-rw-r--r--odk/source/unoapploader/unx/makefile.mk60
-rw-r--r--odk/source/unoapploader/unx/unoapploader.c301
-rw-r--r--odk/source/unoapploader/win/makefile.mk57
-rw-r--r--odk/source/unoapploader/win/unoapploader.c423
-rw-r--r--odk/source/unowinreg/win/makefile.mk114
-rw-r--r--odk/source/unowinreg/win/unowinreg.cxx185
-rw-r--r--odk/source/unowinreg/win/unowinreg.dxp9
-rw-r--r--odk/util/check.pl485
-rw-r--r--odk/util/checkdiff.pl62
-rw-r--r--odk/util/delzip1
-rw-r--r--odk/util/makefile.mk58
-rw-r--r--odk/util/makefile.pmk223
-rw-r--r--odk/util/odk_rules.pmk193
634 files changed, 113912 insertions, 0 deletions
diff --git a/odk/cfgWin.js b/odk/cfgWin.js
new file mode 100644
index 000000000000..0dc23d22aa25
--- /dev/null
+++ b/odk/cfgWin.js
@@ -0,0 +1,981 @@
+// This script asks for variables, which are necessary for building the
+// examples of the Office Development Kit. The script duplicates the template
+// script and inserts the variables into the copied script.
+// The Script was developed for the operating systems Microsoft Windows.
+var regKeyOfficeCurrentUser = "HKEY_CURRENT_USER\\Software\\OpenOffice.org\\UNO\\InstallPath\\";
+var regKeyOfficeLocaleMachine = "HKEY_LOCAL_MACHINE\\Software\\OpenOffice.org\\UNO\\InstallPath\\";
+var regKeyDotNetInstallRoot = "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\.NETFramework\\InstallRoot";
+var regKeyDotNet1_1 = "HKLM\\Software\\Microsoft\\.NETFramework\\policy\\v1.1\\4322";
+var sDirDotNet1_1 = "v1.1.4322";
+var regKeyDotNet2_0 = "HKLM\\Software\\Microsoft\\.NETFramework\\Policy\\v2.0\\50727";
+var sDirDotNet2_0 = "v2.0.50727";
+
+var regKeyJDK = "HKLM\\Software\\JavaSoft\\Java Development Kit\\";
+//var regKeyVC70 = "HKLM\\SOFTWARE\\Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir";
+//var regKeyVC71 = "HKLM\\SOFTWARE\\Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir";
+var regKeyVC90 = "HKLM\\SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VC\\ProductDir";
+
+//var regKeyVCExpress80 = "HKLM\\SOFTWARE\\Microsoft\\VCExpress\\8.0\\Setup\\VC\\ProductDir";
+var regKeyVCExpress90 = "HKLM\\SOFTWARE\\Microsoft\\VCExpress\\9.0\\Setup\\VC\\ProductDir";
+
+var regKeyWindowsSDK = "HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\CurrentInstallFolder";
+
+var WshShell = WScript.CreateObject("WScript.Shell");
+var WshSysEnv = WshShell.Environment("process");
+var aFileSystemObject = new ActiveXObject("Scripting.FileSystemObject");
+var stdin = WScript.StdIn;
+var stdout = WScript.StdOut;
+
+stdout.WriteLine("\n" +
+" *** Configure your SDK environment ***\n\n" +
+" NOTE: This script is working only for Windows 2000, Windows XP or newer versions!\n");
+
+var oo_sdk_name=WshSysEnv("OO_SDK_NAME");
+var stldebug="";
+var oo_sdk_home=getSdkHome();
+var oo_user_sdk_dir=WshSysEnv("APPDATA") + "\\" + oo_sdk_name;
+var oo_user_sdk_env_script=oo_user_sdk_dir + "\\setsdkenv_windows.bat";
+
+var office_home=getOfficeHome();
+var office_base_home=getOfficeBaseHome();
+var oo_sdk_ure_home=getUreHome();
+
+var oo_sdk_make_home=getMakeHome();
+var oo_sdk_zip_home=getZipHome();
+var oo_sdk_manifest_used="";
+var oo_sdk_windowssdk="";
+var oo_sdk_cpp_home=getCppHome();
+var oo_sdk_cli_home=getCliHome();
+var oo_sdk_java_home=getJavaHome();
+var oo_sdk_out=getOutputDir();
+var sdk_auto_deployment=getAutoDeployment();
+
+writeBatFile(oo_user_sdk_dir, oo_user_sdk_env_script);
+
+stdout.Write(
+ "\n ******************************************************************\n" +
+ " * ... \"" + oo_user_sdk_env_script + "\"\n" +
+ " * batch file has been prepared.\n" +
+ " * This batch file will be used in the future to prepare your\n" +
+ " * personal configured SDK environment.\n" +
+ " ******************************************************************\n\n");
+// " * For each time you want to use this configured SDK environment,\n" +
+// " * you have to run the \"setsdkenv_windows.bat\" file in a new shell!\n" +
+
+// done -------------------------------------------------------------------------
+
+
+function skipChoice(msg)
+{
+ stdout.Write("\n Do you want to skip the choice of " + msg + " (YES/NO) [YES]:");
+ var sChoice = stdin.ReadLine();
+ if (sChoice == "" || sChoice.toLowerCase() == "yes")
+ return true;
+
+ return false;
+}
+
+function getSdkHome()
+{
+ var sSuggestedHome = WshSysEnv("OO_SDK_HOME");
+ if (sSuggestedHome.length == 0) {
+ var scriptname = WScript.ScriptFullName;
+ sSuggestedHome = scriptname.substr(0,scriptname.length-10);
+ }
+
+ while(true)
+ {
+ stdout.Write("\n Enter the Office Software Development Kit directory [" +
+ sSuggestedHome + "]:");
+ var sHome = stdin.ReadLine();
+ if (sHome.length == 0)
+ {
+ //No user input, use default.
+ if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
+ {
+ stdout.WriteLine("\n Error: Could not find directory \"" +
+ sSuggestedHome + "\". An SDK is required, please" +
+ " specify the path to a valid installation.");
+ continue;
+ }
+ sHome = sSuggestedHome;
+ }
+ else
+ {
+ //validate the user input
+ if ( ! aFileSystemObject.FolderExists(sHome))
+ {
+ stdout.WriteLine("\n Error: The directory \"" + sHome +
+ "\" does not exist. Please enter the path to a" +
+ "valid SDK installation.");
+ continue;
+ }
+ }
+ //Check if this is an sdk folder by looking for the idl sub - dir
+ var idlDir = sHome + "\\idl";
+ if (! aFileSystemObject.FolderExists(idlDir))
+ {
+ stdout.WriteLine("\n Error: Could not find directory \"" +
+ idlDir + "\". An SDK is required, please specify " +
+ "the path to a valid SDK installation.");
+ continue;
+ }
+
+ if (aFileSystemObject.FileExists(sHome + "\\lib\\stlport_vc71_stldebug.lib")) {
+ stldebug="_stldebug";
+ }
+
+ return sHome;
+ }
+}
+
+function getOfficeOrUre()
+{
+ var suggestion = "Office";
+ var choice;
+ while (choice != "office" && choice != "ure") {
+ stdout.Write(
+ "\n Use an installed Office or an installed UNO Runtime"
+ + " Environment (Office/URE) [" + suggestion + "]:");
+ choice = stdin.ReadLine();
+ if (choice == "") {
+ choice = suggestion;
+ }
+ choice = choice.toLowerCase();
+ }
+ return choice;
+}
+
+function getOfficeHome()
+{
+ var sSuggestedHome = WshSysEnv("OFFICE_HOME");
+ if (sSuggestedHome.length == 0)
+ {
+ try {
+ sSuggestedHome = WshShell.RegRead(regKeyOfficeCurrentUser);
+ //The registry entry points to the program folder but we need the
+ //installation folder
+ } catch(exc) {}
+ if (sSuggestedHome.length == 0)
+ {
+ try {
+ sSuggestedHome = WshShell.RegRead(regKeyOfficeLocaleMachine);
+ //The registry entry points to the program folder but we need
+ //the installation folder
+ } catch (exc) {}
+ }
+
+ var index=0;
+ if ((index = sSuggestedHome.lastIndexOf("\\")) != -1)
+ sSuggestedHome = sSuggestedHome.substr(0, index);
+
+ if (sSuggestedHome.length == 0)
+ sSuggestedHome = searchOffice();
+ }
+
+ while(true)
+ {
+ stdout.Write("\n Enter the Office base installation directory [" +
+ sSuggestedHome + "]:");
+ var sHome = stdin.ReadLine();
+ if (sHome.length == 0)
+ {
+ //No user input, use default.
+ if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
+ {
+ stdout.WriteLine("\n Error: Could not find directory \"" +
+ sSuggestedHome + "\" An office installation is " +
+ "required, please specify the path to a valid " +
+ "office installation.");
+ sSuggestedHome = "";
+ continue;
+ }
+ sHome = sSuggestedHome;
+ } else
+ {
+ //validate the user input
+ if ( ! aFileSystemObject.FolderExists(sHome))
+ {
+ stdout.WriteLine("\n Error: The directory \"" + sHome +
+ "\" does not exist. Please specify the path to " +
+ "a valid office installation.");
+ continue;
+ }
+ }
+ //Check if this is a valid office installtion folder by looking for the
+ //program sub-directory
+ var progDir = sHome + "\\program";
+ if (! aFileSystemObject.FolderExists(progDir))
+ {
+ stdout.WriteLine("\n Error: Could not find directory \"" +
+ progDir + "\". An office installation is required, " +
+ "please specify the path to a valid office " +
+ "installation.");
+ continue;
+ }
+ return sHome;
+ }
+}
+
+function searchOffice()
+{
+ var tmp = oo_sdk_home;
+ var officepath ="";
+ var index=-1;
+
+ if ((index = tmp.lastIndexOf("\\Basis")) != -1) {
+ tmp = tmp.substr(0, index);
+ }
+
+ if (aFileSystemObject.FileExists(tmp + "\\program\\soffice.exe")) {
+ return tmp;
+ }
+
+ return "";
+}
+
+
+function getOfficeBaseHome()
+{
+ var officebase = oo_sdk_home;
+ var index=officebase.lastIndexOf("\\");
+
+ officebase = officebase.substr(0, index);
+
+ return officebase;
+}
+
+function getUreHome()
+{
+ var tmpure = oo_sdk_home;
+ var ure = "";
+ var index=0;
+ if ((index = tmpure.lastIndexOf("Basis")) != -1)
+ tmpure = tmpure.substr(0, index);
+
+ if (aFileSystemObject.FileExists(tmpure + "\\URE\\bin\\uno.exe")) {
+ ure = tmpure + "\URE";
+ }
+
+ return ure;
+
+/*
+ var suggestion = WshSysEnv("OO_SDK_URE_HOME");
+ var choice;
+ for (;;) {
+ stdout.Write(
+ "\n Enter the URE installation directory [" + suggestion + "]:");
+ choice = stdin.ReadLine();
+ if (choice == "") {
+ choice = suggestion;
+ }
+ if (aFileSystemObject.FileExists(choice + "\\bin\\uno.exe")) {
+ break;
+ }
+ stdout.WriteLine("\n Error: A valid URE installation is required.");
+ }
+ return choice;
+*/
+}
+
+function getMakeHome()
+{
+ var sSuggestedHome = WshSysEnv("OO_SDK_MAKE_HOME");
+
+ while(true)
+ {
+ stdout.Write("\n Enter GNU make (3.79.1 or higher) tools directory [" +
+ sSuggestedHome + "]:");
+ var sHome = stdin.ReadLine();
+ if (sHome.length == 0)
+ {
+ //No user input, use default.
+ if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
+ {
+ stdout.WriteLine("\n Error: Could not find directory \"" +
+ sSuggestedHome + "\". GNU make is required, " +
+ "please specify a GNU make tools directory.");
+ sSuggestedHome = "";
+ continue;
+ }
+ sHome = sSuggestedHome;
+ } else
+ {
+ //validate the user input
+ if ( ! aFileSystemObject.FolderExists(sHome))
+ {
+ stdout.WriteLine("\n Error: The directory \"" + sHome +
+ "\" does not exist. GNU make is required, " +
+ "please specify a GNU make tools directory.");
+ continue;
+ }
+ }
+ //Check for the make executable
+ var sMakePath = sHome + "\\make.exe";
+ if (! aFileSystemObject.FileExists(sMakePath))
+ {
+ sMakePath = sHome + "\\mingw32-make.exe";
+ }
+ if (! aFileSystemObject.FileExists(sMakePath))
+ {
+ stdout.WriteLine("\n Error: Could not find \"" + sMakePath +
+ "\". GNU make is required, please specify a GNU " +
+ "make tools directory.");
+ continue;
+ }
+ return sHome;
+ }
+}
+
+function getZipHome()
+{
+ var sSuggestedHome = WshSysEnv("OO_SDK_ZIP_HOME");
+
+ while(true)
+ {
+ stdout.Write("\n Enter a zip (2.3 or higher) tools directory [" +
+ sSuggestedHome + "]:");
+ var sHome = stdin.ReadLine();
+ if (sHome.length == 0)
+ {
+ //No user input, use default.
+ if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
+ {
+ stdout.WriteLine("\n Error: Could not find directory \"" +
+ sSuggestedHome + "\". zip is required, please " +
+ "specify a zip tools directory.");
+ sSuggestedHome = "";
+ continue;
+ }
+ sHome = sSuggestedHome;
+ }
+ else
+ {
+ //validate the user input
+ if ( ! aFileSystemObject.FolderExists(sHome))
+ {
+ stdout.WriteLine("\n Error: The directory \"" + sHome +
+ "\" does not exist. zip is required, please " +
+ "specify a zip tools directory.");
+ continue;
+ }
+ }
+ //Check for the make executable
+ var sZipPath = sHome + "\\zip.exe";
+ if (! aFileSystemObject.FileExists(sZipPath))
+ {
+ stdout.WriteLine("\n Error: Could not find \"" + sZipPath +
+ "\". zip is required, please specify a zip tools " +
+ "directory.");
+ continue;
+ }
+ return sHome;
+ }
+}
+
+function getCppHome()
+{
+ var sSuggestedHome = WshSysEnv("OO_SDK_CPP_HOME");
+ if (sSuggestedHome.length == 0)
+ {
+ var sVC="";
+ try {
+ sVC = WshShell.RegRead(regKeyVCExpress90);
+ }catch (exc) {}
+ if (sVC.length == 0)
+ {
+ try {
+ sVC = WshShell.RegRead(regKeyVC90);
+ }catch (exc) {}
+ }
+ // check Windows SDK if VC 9
+ if (sVC.length > 0)
+ {
+ oo_sdk_manifest_used="true";
+ try {
+ oo_sdk_windowssdk = WshShell.RegRead(regKeyWindowsSDK);
+ }catch (exc) {}
+ }
+ if (sVC.length == 0)
+ {
+ try {
+ sVC = WshShell.RegRead(regKeyVCExpress80);
+ }catch (exc) {}
+ if (sVC.length > 0)
+ oo_sdk_manifest_used="true";
+ }
+ if (sVC.length == 0)
+ {
+ try {
+ sVC = WshShell.RegRead(regKeyVC80);
+ }catch (exc) {}
+ if (sVC.length > 0)
+ oo_sdk_manifest_used="true";
+ }
+ if (sVC.length == 0)
+ {
+ try {
+ sVC = WshShell.RegRead(regKeyVC71);
+ }catch (exc) {}
+ }
+ if (sVC.length > 0)
+ {
+ sVC += "bin";
+ if (aFileSystemObject.FileExists(sVC + "\\cl.exe"))
+ sSuggestedHome = sVC;
+ }
+ }
+
+ var bSkip = false;
+ while(true)
+ {
+ stdout.Write("\n Enter the directory of the C++ compiler (optional) [" +
+ sSuggestedHome + "]:");
+ var sHome = stdin.ReadLine();
+ if (sHome.length == 0)
+ {
+ //No user input, check OO_SDK_CPP_HOME or suggested value
+ if ( sSuggestedHome.length == 0 ) {
+ bSkip = true;
+ } else {
+ if ( !aFileSystemObject.FolderExists(sSuggestedHome) )
+ {
+ stdout.WriteLine("\n Error: Could not find directory \"" +
+ sSuggestedHome + "\".");
+ sSuggestedHome = "";
+ bSkip = true;
+ }
+ }
+
+ sHome = sSuggestedHome;
+ } else
+ {
+ //validate the user input
+ if ( ! aFileSystemObject.FolderExists(sHome))
+ {
+ stdout.WriteLine("\n Error: Could not find directory \"" +
+ sHome + "\".");
+ bSkip = true;
+ }
+ }
+
+ if ( !bSkip) {
+ //Check if the C++ compiler exist
+ var cl = sHome + "\\cl.exe";
+ var mt = sHome + "\\mt.exe";
+
+ if (! aFileSystemObject.FileExists(cl))
+ {
+ stdout.WriteLine("\n Error: Could not find the C++ compiler \""
+ + cl + "\".");
+ sHome = "";
+ bSkip = true;
+ } else {
+ if (aFileSystemObject.FileExists(mt)) {
+ oo_sdk_vc8_used="true";
+ }
+ }
+ }
+
+ if ( bSkip ) {
+ if ( skipChoice("the C++ compiler") ) {
+ return "";
+ } else {
+ bSkip = false;
+ continue;
+ }
+ }
+
+ return sHome;
+ }
+}
+
+function getCliHome()
+{
+ var sSuggestedHome = WshSysEnv("OO_SDK_CLI_HOME");
+
+ if (sSuggestedHome.length == 0)
+ {
+ try {
+ var _ver = WshShell.RegRead(regKeyDotNet2_0);
+ if (_ver.length > 0)
+ {
+ sSuggestedHome = WshShell.RegRead(regKeyDotNetInstallRoot);
+ sSuggestedHome += sDirDotNet2_0;
+ if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
+ sSuggestedHome = "";
+ }
+
+ if (sSuggestedHome.length == 0)
+ {
+ _ver = WshShell.RegRead(regKeyDotNet1_1);
+ if (_ver.length > 0)
+ {
+ sSuggestedHome = WshShell.RegRead(regKeyDotNetInstallRoot);
+ sSuggestedHome += sDirDotNet1_1;
+ if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
+ sSuggestedHome = "";
+ }
+ }
+ } catch (exc) {}
+ }
+
+ var bSkip = false;
+ while(true)
+ {
+ stdout.Write("\n Enter the directory of the C# and VB.NET compilers (optional) [" + sSuggestedHome + "]:");
+ var sHome = stdin.ReadLine();
+ if (sHome.length == 0)
+ {
+ //No user input, check OO_SDK_CLI_HOME or suggested value
+ if ( sSuggestedHome.length == 0 ) {
+ bSkip = true;
+ } else {
+ if ( !aFileSystemObject.FolderExists(sSuggestedHome) )
+ {
+ stdout.WriteLine("\n Error: Could not find directory \"" +
+ sSuggestedHome + "\".");
+ sSuggestedHome = "";
+ bSkip = true;
+ }
+ }
+
+ sHome = sSuggestedHome;
+ }
+ else
+ {
+ //validate the user input
+ if ( ! aFileSystemObject.FolderExists(sHome))
+ {
+ stdout.WriteLine("\n Error: The directory \"" + sHome +
+ "\" does not exist.");
+ bSkip = true;
+ }
+ }
+
+ if ( !bSkip ) {
+ //Check if the C# and VB.NET compiler exist
+ var csc = sHome + "\\csc.exe";
+ var vbc = sHome + "\\vbc.exe";
+
+ if (! aFileSystemObject.FileExists(csc))
+ {
+ stdout.WriteLine("\n Error: Could not find the C# compiler \"" +
+ csc + "\".");
+ bSkip = true;
+ }
+ if (! aFileSystemObject.FileExists(vbc))
+ {
+ stdout.WriteLine("\n Error: Could not find the VB.NET compiler \"" +
+ vbc + "\".");
+ bSkip = true;
+ }
+ }
+
+ if ( bSkip ) {
+ if ( skipChoice("the C# and VB.NET compilers") ) {
+ return "";
+ } else {
+ bSkip = false;
+ continue;
+ }
+ }
+
+ return sHome;
+ }
+}
+
+function getJavaHome()
+{
+ var sSuggestedHome = WshSysEnv("OO_SDK_JAVA_HOME");
+ if (sSuggestedHome.length == 0)
+ {
+ try {
+ var currentVersion = WshShell.RegRead(regKeyJDK + "CurrentVersion");
+ if (currentVersion.length > 0)
+ {
+ sSuggestedHome = WshShell.RegRead(regKeyJDK + currentVersion +
+ "\\JavaHome");
+ if ( ! aFileSystemObject.FolderExists(sSuggestedHome) )
+ sSuggestedHome = "";
+ }
+ } catch (exc) {}
+ }
+
+ var bSkip = false;
+ while(true)
+ {
+ stdout.Write("\n Enter JAVA SDK (1.4.1_01 or higher) installation directory (optional) [" + sSuggestedHome + "]:");
+ var sHome = stdin.ReadLine();
+ if (sHome.length == 0)
+ {
+ //No user input, check OO_SDK_JAVA_HOME or suggested value
+ if ( sSuggestedHome.length == 0 ) {
+ bSkip = true;
+ } else {
+ if ( !aFileSystemObject.FolderExists(sSuggestedHome) )
+ {
+ stdout.WriteLine("\n Error: Could not find directory \"" +
+ sSuggestedHome + "\".");
+ sSuggestedHome = "";
+ bSkip=true;
+ }
+ }
+
+ sHome = sSuggestedHome;
+ } else
+ {
+ //validate the user input
+ if ( ! aFileSystemObject.FolderExists(sHome))
+ {
+ stdout.WriteLine("\n Error: The directory \"" + sHome +
+ "\" does not exist.");
+ bSkip = true;
+ }
+ }
+
+ if ( !bSkip) {
+ //Check if this is an sdk folder by looking for the javac compiler
+ var javacompiler = sHome + "\\bin\\javac.exe";
+ if (! aFileSystemObject.FileExists(javacompiler))
+ {
+ stdout.WriteLine("\n Error: Could not find \"" +
+ javacompiler + "\".");
+ bSkip = true;
+ }
+ }
+
+ if ( bSkip ) {
+ if ( skipChoice("the Java SDK") ) {
+ return "";
+ } else {
+ bSkip = false;
+ continue;
+ }
+ }
+
+ return sHome;
+ }
+}
+
+function getOutputDir()
+{
+ var defaultdir = "c:\\" + oo_sdk_name;
+ var sSuggestedDir = WshSysEnv("OO_SDK_OUT");
+ if (sSuggestedDir.length == 0)
+ sSuggestedDir = defaultdir;
+
+ var bSkip = false;
+ while(true)
+ {
+ stdout.Write(
+ "\n Default output directory is the \"c:\\" + oo_sdk_name + "\".\n" +
+ " Enter an existent directory if you prefer a different one. But note" +
+ " that only\n a path without spaces is allowed because of a" +
+ " limitation of gnu make. (optional) [" + sSuggestedDir + "]:");
+ var sDir = stdin.ReadLine();
+ if (sDir.length == 0)
+ {
+ //No user input, check OO_SDK_OUT or suggested value
+ if ( sSuggestedDir.length == 0 ) {
+ bSkip = true;
+ } else {
+ if (sSuggestedDir == oo_user_sdk_dir || sSuggestedDir == defaultdir) {
+ var fso = new ActiveXObject("Scripting.FileSystemObject");
+ if ( !fso.FolderExists(sSuggestedDir) )
+ fso.CreateFolder(sSuggestedDir);
+ }
+ if ( !aFileSystemObject.FolderExists(sSuggestedDir) )
+ {
+ stdout.WriteLine("\n Error: Could not find directory \"" +
+ sSuggestedDir + "\".");
+ sSuggestedDir = "";
+ bSkip = true;
+ }
+ }
+
+ sDir = sSuggestedDir;
+ }
+ else
+ {
+ if (sDir.indexOf(' ') != -1) {
+ stdout.WriteLine("\n Error: your specified output directory " +
+ "\"" + sDir + "\" " +
+ "contains one or more spaces.\n That " +
+ "causes problems with gnu make. Please specifiy" +
+ " a directory without spaces.");
+ bSkip = true;
+ }
+ //validate the user input
+ if ( ! aFileSystemObject.FolderExists(sDir))
+ {
+ stdout.WriteLine("\n Error: Could not find directory \"" +
+ sDir + "\".");
+ bSkip = true;
+ }
+ }
+
+ if ( bSkip ) {
+ if ( skipChoice("a special output directory") ) {
+ return "";
+ } else {
+ bSkip = false;
+ continue;
+ }
+ }
+
+ return sDir;
+ }
+}
+
+function getAutoDeployment()
+{
+ var sSuggestedAuto = WshSysEnv("SDK_AUTO_DEPLOYMENT");
+ if (sSuggestedAuto.length == 0)
+ sSuggestedAuto = "YES";
+
+ while(true)
+ {
+ stdout.Write("\n Automatic deployment of UNO components (YES/NO) ["+
+ sSuggestedAuto + "]:");
+ var sAuto = stdin.ReadLine();
+ if (sAuto.length == 0)
+ sAuto = sSuggestedAuto;
+ else
+ {
+ sAutoU = sAuto.toUpperCase();
+ if (sAutoU != "YES" && sAutoU != "NO")
+ {
+ stdout.WriteLine("\n Error: The value \"" + sAuto + "\" is " +
+ "invalid. Please answer YES or NO.")
+ continue;
+ }
+ sAuto = sAutoU;
+ }
+ return sAuto;
+ }
+}
+
+//The function uses sp2bv.exe to obtain a file URL from a
+//system path. The URL is already escaped for use as bootstrap variable.
+//($ -> \$). Then the resulting string is escaped for use in a bat file.
+//That is % signs are made to double % (% -> %%);
+function makeBootstrapFileUrl(systemPath)
+{
+ var oExec = WshShell.Exec("sp2bv.exe \"" + systemPath + "\"");
+ var output="";
+ while (true)
+ {
+ if (!oExec.StdOut.AtEndOfStream)
+ {
+ var next = oExec.StdOut.Read(1);
+ if (next == '%')
+ output += "%%";
+ else
+ output += next;
+ }
+ else
+ break;
+ }
+ return output;
+}
+
+function writeBatFile(fdir, file)
+{
+ var fso = new ActiveXObject("Scripting.FileSystemObject");
+ if ( !fso.FolderExists(fdir) )
+ fso.CreateFolder(fdir);
+ var newFile = fso.CreateTextFile(file, true);
+
+ newFile.Write(
+ "@echo off\n" +
+ "REM This script sets all enviroment variables, which\n" +
+ "REM are necessary for building the examples of the Office Development Kit.\n" +
+ "REM The Script was developed for the operating systems Windows.\n" +
+ "REM The SDK name\n" +
+ "REM Example: set OO_SDK_NAME=openoffice3.0_sdk\n" +
+ "set OO_SDK_NAME=" + oo_sdk_name +
+ "\n\n" +
+ "REM Installation directory of the Software Development Kit.\n" +
+ "REM Example: set OO_SDK_HOME=C:\\Program Files\\OpenOffice.org\\Basic 3.0\\sdk\n" +
+ "set OO_SDK_HOME=" + oo_sdk_home +
+ "\n\n" +
+ "REM Office installation directory.\n" +
+ "REM Example: set OFFICE_HOME=C:\\Program Files\\OpenOffice.org 3\n" +
+ "set OFFICE_HOME=" + office_home +
+ "\n\n" +
+ "REM Example: set OFFICE_HOME=C:\\Program Files\\OpenOffice.org\\Basis 3.0\n" +
+ "set OFFICE_BASE_HOME=" + office_base_home +
+ "\n\n" +
+ "REM URE installation directory.\n" +
+ "REM Example: set OO_SDK_URE_HOME=C:\\Program Files\\OpenOffice.org\\URE\n" +
+ "set OO_SDK_URE_HOME=" + oo_sdk_ure_home +
+ "\n\n" +
+ "REM Directory of the make command.\n" +
+ "REM Example: set OO_SDK_MAKE_HOME=D:\\NextGenerationMake\\make\n" +
+ "set OO_SDK_MAKE_HOME=" + oo_sdk_make_home +
+ "\n\n" +
+ "REM Directory of the zip tool.\n" +
+ "REM Example: set OO_SDK_ZIP_HOME=D:\\infozip\\bin\n" +
+ "set OO_SDK_ZIP_HOME=" + oo_sdk_zip_home +
+ "\n\n" +
+ "REM Directory of the C++ compiler.\n" +
+ "REM Example:set OO_SDK_CPP_HOME=C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\bin\n" +
+ "set OO_SDK_CPP_HOME=" + oo_sdk_cpp_home +
+ "\nset CPP_MANIFEST=" + oo_sdk_manifest_used +
+ "\nset CPP_WINDOWS_SDK=" + oo_sdk_windowssdk +
+ "\n\n" +
+ "REM Directory of the C# and VB.NET compilers.\n" +
+ "REM Example:set OO_SDK_CLI_HOME=C:\\WINXP\\Microsoft.NET\\Framework\\v1.0.3705\n" +
+ "set OO_SDK_CLI_HOME=" + oo_sdk_cli_home +
+ "\n\n" +
+ "REM Java SDK installation directory.\n" +
+ "REM Example: set OO_SDK_JAVA_HOME=C:\\Program Files\\Java\\jdk1.6.0_05\n" +
+ "set OO_SDK_JAVA_HOME=" + oo_sdk_java_home +
+ "\n\n" +
+ "REM Special output directory\n" +
+ "REM Example: set OO_SDK_OUT=C:\\" + oo_sdk_name + "\n" +
+ "set OO_SDK_OUT=" + oo_sdk_out +
+ "\n\n" +
+ "REM Automatic deployment\n" +
+ "REM Example: set SDK_AUTO_DEPLOYMENT=YES\n" +
+ "set SDK_AUTO_DEPLOYMENT=" + sdk_auto_deployment +
+ "\n\n" +
+ "set STLDEBUG=" + stldebug + "\n" +
+ "REM check stlport lib in 4NT shell\n" +
+ "REM if exist \"%OO_SDK_HOME%\\windows\\lib\\stlport_vc71_stldebug.lib\". (\n" +
+ "REM set STLDEBUG=_stldebug\n" +
+ "REM )\n\n" +
+ "REM Check installation path for the Office Development Kit.\n" +
+ "if not defined OO_SDK_HOME (\n" +
+ " echo Error: the variable OO_SDK_HOME is missing!\n" +
+ " goto :error\n" +
+ " )\n" +
+ "\n" +
+ "REM Check installation path for the office.\n" +
+ "REM if not defined OFFICE_HOME (\n" +
+ "REM if not defined OO_SDK_URE_HOME (\n" +
+ "REM echo Error: either of the variables OFFICE_HOME and\n" +
+ "REM echo OO_SDK_URE_HOME is missing!\n" +
+ "REM goto :error\n" +
+ "REM )\n" +
+ "REM )\n" +
+ "\n" +
+ "REM Check installation path for GNU make.\n" +
+ "if not defined OO_SDK_MAKE_HOME (\n" +
+ " echo Error: the variable OO_SDK_MAKE_HOME is missing!\n" +
+ " goto :error\n" +
+ " )\n" +
+ "\n" +
+ "REM Check installation path for the zip tool.\n" +
+ "if not defined OO_SDK_ZIP_HOME (\n" +
+ " echo Error: the variable OO_SDK_ZIP_HOME is missing!\n" +
+ " goto :error\n" +
+ " )\n" +
+ "\n" +
+ "REM Set library path. \n" +
+ "set LIB=%OO_SDK_HOME%\\lib;%LIB%\n" +
+ "if defined CPP_WINDOWS_SDK (\n" +
+ " set LIB=%LIB%;%CPP_WINDOWS_SDK%\\lib\n" +
+ " )\n" +
+ "\n" +
+ "REM Set office program path.\n" +
+ "if defined OFFICE_HOME (\n" +
+ " set OFFICE_PROGRAM_PATH=%OFFICE_HOME%\\program\n" +
+ " )\n" +
+ "\n" +
+ "REM Set office program path.\n" +
+ "if defined OFFICE_BASE_HOME (\n" +
+ " set OFFICE_BASE_PROGRAM_PATH=%OFFICE_BASE_HOME%\\program\n" +
+ " )\n" +
+ "\n" +
+ "REM Set UNO path, necessary to ensure that the cpp examples using the\n" +
+ "REM new UNO bootstrap mechanism use the configured office installation\n" +
+ "REM (only set when using an Office).\n" +
+ "if defined OFFICE_HOME (\n" +
+ " set UNO_PATH=%OFFICE_PROGRAM_PATH%\n" +
+ " )\n" +
+ "\n" +
+ "REM if defined OO_SDK_URE_HOME (\n" +
+ "set OO_SDK_URE_BIN_DIR=%OO_SDK_URE_HOME%\\bin\n" +
+ "set OO_SDK_URE_LIB_DIR=%OO_SDK_URE_HOME%\\bin\n" +
+ "set OO_SDK_URE_JAVA_DIR=%OO_SDK_URE_HOME%\\java\n" +
+ "REM ) else (\n" +
+ "set OO_SDK_OFFICE_BIN_DIR=%OFFICE_PROGRAM_PATH%\n" +
+ "set OO_SDK_OFFICE_LIB_DIR=%OFFICE_BASE_PROGRAM_PATH%\n" +
+ "set OO_SDK_OFFICE_JAVA_DIR=%OFFICE_BASE_PROGRAM_PATH%\\classes\n" +
+ "REM )\n" +
+ "\n" +
+ "REM Set classpath\n" +
+ "set CLASSPATH=%OO_SDK_URE_JAVA_DIR%\\juh.jar;%OO_SDK_URE_JAVA_DIR%\\jurt.jar;%OO_SDK_URE_JAVA_DIR%\\ridl.jar;%OO_SDK_URE_JAVA_DIR%\\unoloader.jar;%OO_SDK_OFFICE_JAVA_DIR%\\unoil.jar\n" +
+ "REM if defined OFFICE_HOME (\n" +
+ "REM set CLASSPATH=%CLASSPATH%;%OO_SDK_OFFICE_JAVA_DIR%\\unoil.jar\n" +
+ "REM )\n" +
+ "\n" +
+ "REM Add directory of the SDK tools to the path.\n" +
+ "set PATH=%OO_SDK_HOME%\\bin;%OO_SDK_URE_BIN_DIR%;%OO_SDK_OFFICE_BIN_DIR%;%OO_SDK_HOME%\\WINexample.out\\bin;%PATH%\n" +
+ "\n" +
+ "REM Set PATH appropriate to the output directory\n" +
+ "if defined OO_SDK_OUT (\n" +
+ " set PATH=%OO_SDK_OUT%\\WINexample.out\\bin;%PATH%\n" +
+ " ) else (\n" +
+ " set PATH=%OO_SDK_HOME%\\WINexample.out\\bin;%PATH%\n" +
+ " )\n" +
+ "\n" +
+ "REM Add directory of the command make to the path, if necessary.\n" +
+ "if defined OO_SDK_MAKE_HOME set PATH=%OO_SDK_MAKE_HOME%;%PATH%\n" +
+ "\n" +
+ "REM Add directory of the zip tool to the path, if necessary.\n" +
+ "if defined OO_SDK_ZIP_HOME set PATH=%OO_SDK_ZIP_HOME%;%PATH%\n" +
+ "\n" +
+ "REM Add directory of the C++ compiler to the path, if necessary.\n" +
+ "if defined OO_SDK_CPP_HOME set PATH=%OO_SDK_CPP_HOME%;%PATH%\n" +
+ "\n" +
+ "REM Add directory of the Win SDK to the path, if necessary.\n" +
+ "if defined CPP_WINDOWS_SDK (\n" +
+ " set PATH=%CPP_WINDOWS_SDK\\bin%;%PATH%\n" +
+ " set INCLUDE=%CPP_WINDOWS_SDK\\Include%;%INCLUDE%\n" +
+ ")\n" +
+ "REM Add directory of the C# and VB.NET compilers to the path, if necessary.\n" +
+ "if defined OO_SDK_CLI_HOME set PATH=%OO_SDK_CLI_HOME%;%PATH%\n" +
+ "\n" +
+ "REM Add directory of the Java tools to the path, if necessary.\n" +
+ "if defined OO_SDK_JAVA_HOME set PATH=%OO_SDK_JAVA_HOME%\\bin;%OO_SDK_JAVA_HOME%\\jre\\bin;%PATH%\n" +
+ "\n" +
+ "REM Set environment for C++ compiler tools, if necessary.\n" +
+ "if defined OO_SDK_CPP_HOME call \"%OO_SDK_CPP_HOME%\\VCVARS32.bat\"\n" +
+ "\n" +
+ "REM Set tilte to identify the prepared shell.\n" +
+ "title Shell prepared for SDK\n" +
+ "\nREM Prepare shell with all necessary environment variables.\n" +
+ "echo.\n" +
+ "echo ******************************************************************\n" +
+ "echo *\n" +
+ "echo * SDK environment is prepared for Windows\n" +
+ "echo *\n" +
+ "echo * SDK = %OO_SDK_HOME%\n" +
+ "echo * Office = %OFFICE_HOME%\n" +
+ "echo * Office Base = %OFFICE_BASE_HOME%\n" +
+ "echo * URE = %OO_SDK_URE_HOME%\n" +
+ "echo * Make = %OO_SDK_MAKE_HOME%\n" +
+ "echo * Zip = %OO_SDK_ZIP_HOME%\n" +
+ "echo * C++ Compiler = %OO_SDK_CPP_HOME%\n" +
+ "echo * C# and VB.NET compilers = %OO_SDK_CLI_HOME%\n" +
+ "echo * Java = %OO_SDK_JAVA_HOME%\n" +
+ "echo * Special Output directory = %OO_SDK_OUT%\n" +
+ "echo * Auto deployment = %SDK_AUTO_DEPLOYMENT%\n" +
+ "echo *\n" +
+ "echo ******************************************************************\n" +
+ "echo.\n" +
+ "goto end\n" +
+ "\n" +
+ " :error\n" +
+ "Error: Please insert the necessary environment variables into the batch file.\n" +
+ "\n" +
+ " :end\n"
+ );
+ newFile.Close();
+}
+
+
+
diff --git a/odk/configure.pl b/odk/configure.pl
new file mode 100755
index 000000000000..e1a1cfb99924
--- /dev/null
+++ b/odk/configure.pl
@@ -0,0 +1,808 @@
+#
+# configure.pl - a perl script to set a minimal environment for the SDK.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+
+use IO::File;
+use File::Basename;
+
+$main::hostname= $ARGV[0];
+$main::sdkpath= $ARGV[1];
+$main::OO_SDK_NAME= $ARGV[2];
+
+$main::OO_MAJORVERSION=$main::OO_SDK_NAME;
+$main::OO_MINORVERSION=$main::OO_SDK_NAME;
+$main::OO_MAJORVERSION =~ s#[^\d]+(\d).(\d).+#$1#go;
+$main::OO_MINORVERSION =~ s#[^\d]+(\d).(\d).+#$2#go;
+
+$main::OO_SDK_CONFIG_HOME= "$ENV{HOME}/$main::OO_SDK_NAME";
+
+$main::operatingSystem = `$main::sdkpath/config.guess | cut -d"-" -f3,4`;
+chomp ($main::operatingSystem);
+
+$main::OO_SDK_HOME = $main::sdkpath;
+#$main::OO_SDK_HOME = "";
+$main::OO_SDK_HOME_SUGGESTION = $main::sdkpath;
+
+$main::OFFICE_OR_URE = "Office";
+$main::OFFICE_OR_URE_SUGGESTION = "Office";
+
+$main::OFFICE_HOME = "";
+
+$main::OFFICE_BASE_HOME = substr($main::sdkpath, 0, rindex($main::sdkpath, "/sdk"));
+
+if ( $main::operatingSystem =~ m/darwin/ )
+{
+# $main::OO_SDK_URE_HOME = `cd $main::sdkpath/../ure-link && pwd`;
+} else {
+ $main::OO_SDK_URE_HOME = `cd $main::sdkpath/../ure-link && pwd`;
+}
+chomp($main::OO_SDK_URE_HOME);
+
+$main::OO_SDK_MAKE_HOME = "";
+$main::makeName = "make";
+if ( $main::operatingSystem =~ m/solaris/ ||
+ $main::operatingSystem =~ m/freebsd/ )
+{
+ $main::makeName = "gmake";
+}
+$main::OO_SDK_MAKE_HOME_SUGGESTION = searchprog($main::makeName);
+$main::makeVersion = "3.79.1";
+$main::correctVersion = 0;
+
+$main::OO_SDK_ZIP_HOME = "";
+$main::OO_SDK_ZIP_HOME_SUGGESTION = searchprog("zip");
+$main::zipVersion = "2.3";
+
+$main::OO_SDK_CPP_HOME = "";
+$main::cppName = "gcc";
+$main::cppVersion = "4.0.1";
+if ( $main::operatingSystem =~ m/solaris/ )
+{
+ $main::cppName = "CC";
+ $main::cppVersion = "5.2";
+}
+$main::OO_SDK_CC_55_OR_HIGHER = "";
+$main::OO_SDK_CPP_HOME_SUGGESTION = searchprog($main::cppName);
+
+$main::OO_SDK_JAVA_HOME = "";
+$main::OO_SDK_JAVA_BIN_DIR = "bin";
+if ( $main::operatingSystem =~ m/darwin/ )
+{
+ $main::OO_SDK_JAVA_BIN_DIR="Commands";
+}
+$main::OO_SDK_JAVA_HOME_SUGGESTION = searchprog("javac");
+$main::javaVersion = "1.5.0_01";
+
+$main::SDK_AUTO_DEPLOYMENT = "";
+$main::SDK_AUTO_DEPLOYMENT_SUGGESTION = "YES";
+
+$main::OO_SDK_OUTPUT_DIR_SUGGESTION = "$ENV{HOME}";
+$main::OO_SDK_OUTPUT_DIR = "";
+$main::skipOutputDir = 0;
+
+$main::return = 0;
+
+if ( $main::OFFICE_OR_URE eq "Office" )
+{
+ if ( $main::operatingSystem =~ m/darwin/ )
+ {
+# used for a SDK as part of the office installation
+# $main::OFFICE_HOME = `cd $main::sdkpath/../../.. && pwd`;
+# chomp($main::OFFICE_HOME);
+# print " Used Office = $main::OFFICE_HOME\n";
+ print " Used SDK = $main::OO_SDK_HOME\n\n";
+
+ $main::OFFICE_HOME_SUGGESTION = searchMacOffice();
+ while ( (! -d "$main::OFFICE_HOME" ) ||
+ ((-d "$main::OFFICE_HOME") && (! -d "$main::OFFICE_HOME/Contents/MacOS")) )
+ {
+ print " Enter the Office installation directory [$main::OFFICE_HOME_SUGGESTION]: ";
+ $main::OFFICE_HOME = readStdIn();
+ chop($main::OFFICE_HOME);
+ if ( $main::OFFICE_HOME eq "" )
+ {
+ $main::OFFICE_HOME = $main::OFFICE_HOME_SUGGESTION;
+ }
+
+ if ( ! -d "$main::OFFICE_HOME" )
+ {
+ $main::OFFICE_HOME = "";
+ print " Error: An office installation is required, please specify the path to a valid installation.\n";
+ }
+
+ # check more details
+ if ( -d "$main::OFFICE_HOME/Contents/basis-link" ) {
+ $main::OFFICE_BASE_HOME = "$main::OFFICE_HOME/Contents/basis-link";
+ if ( -d "$main::OFFICE_BASE_HOME/ure-link" ) {
+ $main::OO_SDK_URE_HOME = "$main::OFFICE_BASE_HOME/ure-link";
+ } else {
+ $main::OFFICE_HOME = "";
+ $main::OFFICE_BASE_HOME = "";
+ $main::OO_SDK_URE_HOME = "";
+ print " Error: no URE found in office installation, please specify the path to a valid installation.\n";
+ }
+ } else {
+ $main::OFFICE_HOME = "";
+ $main::OFFICE_BASE_HOME = "";
+ $main::OO_SDK_URE_HOME = "";
+ print " Error: no base layer found in office installation, please specify the path to a valid installation.\n";
+ }
+ }
+ } else
+ {
+ $main::OFFICE_HOME_SUGGESTION = searchoffice();
+
+ if ( $main::OFFICE_HOME_SUGGESTION eq "" ) {
+ # prepare Office path
+ $main::OFFICE_HOME_SUGGESTION = searchprog("soffice");
+ }
+
+ if ( ! $main::OFFICE_HOME_SUGGESTION eq "" )
+ {
+ my $tmpOffice = readlink "$main::OFFICE_HOME_SUGGESTION/soffice";
+
+ if ( $tmpOffice eq "" )
+ {
+ $tmpOffice = "$main::OFFICE_HOME_SUGGESTION/soffice";
+ }
+
+ my $offset = rindex($tmpOffice, "/program/soffice");
+ if ( $offset != -1 )
+ {
+ $main::OFFICE_HOME_SUGGESTION = substr($tmpOffice, 0, $offset);
+ } else
+ {
+ $offset = rindex($tmpOffice, "/soffice");
+ if ( $offset != -1 )
+ {
+ $main::OFFICE_HOME_SUGGESTION = substr($tmpOffice, 0, $offset);
+ } else
+ {
+ $main::OFFICE_HOME_SUGGESTION = "";
+ }
+ }
+ }
+
+ while ( (! -d "$main::OFFICE_HOME" ) ||
+ ((-d "$main::OFFICE_HOME") && (! -d "$main::OFFICE_HOME/program")) )
+ {
+ print " Enter the Office installation directory [$main::OFFICE_HOME_SUGGESTION]: ";
+ $main::OFFICE_HOME = readStdIn();
+ chop($main::OFFICE_HOME);
+ if ( $main::OFFICE_HOME eq "" )
+ {
+ $main::OFFICE_HOME = $main::OFFICE_HOME_SUGGESTION;
+ }
+
+ if ( ! -d "$main::OFFICE_HOME" )
+ {
+ $main::OFFICE_HOME = "";
+ print " Error: An office installation is required, please specify the path to a valid installation.\n";
+ } else
+ {
+ # special work for a network installation, no prgram directory but a link to the soffice binary
+ if ( (! -d "$main::OFFICE_HOME/program") && (-e "$main::OFFICE_HOME/soffice") )
+ {
+ my $soserver = `ls -l $OFFICE_HOME_SUGGESTION/soffice | sed -n 's/.* -> //p'`;
+ $soserver= substr($soserver, 0, rindex($soserver, "program") - 1);
+
+ if ( ! -d $soserver )
+ {
+ $main::OFFICE_HOME = "";
+ print " Error: An office installation is required, please specify the path to a valid installation.\n";
+ } else
+ {
+ $main::OFFICE_HOME = $soserver;
+ }
+ }
+ }
+ }
+ }
+}
+else
+{
+ # prepare URE path
+ $main::OO_SDK_URE_HOME_SUGGESTION = "/opt/openoffice.org/ure";
+ $main::OO_SDK_URE_HOME_SUGGESTION = "" unless
+ -e "$main::OO_SDK_URE_HOME_SUGGESTION/bin/uno";
+ for (;;)
+ {
+ print " Enter the URE installation directory",
+ " [$main::OO_SDK_URE_HOME_SUGGESTION]: ";
+ $main::OO_SDK_URE_HOME = readStdIn();
+ chop $main::OO_SDK_URE_HOME;
+ $main::OO_SDK_URE_HOME = $main::OO_SDK_URE_HOME_SUGGESTION if
+ $main::OO_SDK_URE_HOME eq "" &&
+ $main::OO_SDK_URE_HOME_SUGGESTION ne "";
+ last if -e "$main::OO_SDK_URE_HOME/bin/uno";
+ print " Error: A valid URE installation is required.\n";
+ }
+}
+
+# prepare GNU make path
+while ( (!$main::correctVersion) &&
+ ((! -d "$main::OO_SDK_MAKE_HOME" ) ||
+ ((-d "$main::OO_SDK_MAKE_HOME") && (! -e "$main::OO_SDK_MAKE_HOME/$main::makeName"))) )
+{
+ print " Enter GNU make ($main::makeVersion or higher) tools directory [$main::OO_SDK_MAKE_HOME_SUGGESTION]: ";
+ $main::OO_SDK_MAKE_HOME = readStdIn();
+ chop($main::OO_SDK_MAKE_HOME);
+ if ( $main::OO_SDK_MAKE_HOME eq "" )
+ {
+ $main::OO_SDK_MAKE_HOME = $main::OO_SDK_MAKE_HOME_SUGGESTION;
+ }
+ if ( (! -d "$main::OO_SDK_MAKE_HOME") ||
+ ((-d "$main::OO_SDK_MAKE_HOME") && (! -e "$main::OO_SDK_MAKE_HOME/$main::makeName")) )
+ {
+ $main::OO_SDK_MAKE_HOME = "";
+ print " Error: GNU make is required, please specify a GNU make tools directory.\n";
+ } else
+ {
+ #check version
+ my $testVersion = `$OO_SDK_MAKE_HOME/$main::makeName --version`;
+ if ( $testVersion eq "")
+ {
+ print " Set the environment variable OO_SDK_MAKE_HOME to your GNU build tools directory.\n";
+ print " GNU make version $main::makeVersion can be obtained at ftp://ftp.gnu.org/gnu/make/\n";
+ } else
+ {
+ if ($testVersion =~ m#((\d+\.)+\d+)# )
+ {
+ $testVersion = $1;
+ }
+ $main::correctVersion = testVersion($main::makeVersion, $testVersion, "$main::OO_SDK_MAKE_HOME/$main::makeName", 1);
+ if ( !$main::correctVersion )
+ {
+ print " The '$main::makeName' command found at '$main::OO_SDK_MAKE_HOME' has a wrong version\n";
+ $main::OO_SDK_MAKE_HOME = "";
+ }
+ }
+ }
+}
+
+# prepare zip path
+$main::correctVersion = 0;
+while ( (!$main::correctVersion) &&
+ ((! -d "$main::OO_SDK_ZIP_HOME" ) ||
+ ((-d "$main::OO_SDK_ZIP_HOME") && (! -e "$main::OO_SDK_ZIP_HOME/zip"))) )
+{
+ print " Enter zip ($main::zipVersion or higher) tool directory [$main::OO_SDK_ZIP_HOME_SUGGESTION]: ";
+ $main::OO_SDK_ZIP_HOME = readStdIn();
+ chop($main::OO_SDK_ZIP_HOME);
+ if ( $main::OO_SDK_ZIP_HOME eq "" )
+ {
+ $main::OO_SDK_ZIP_HOME = $main::OO_SDK_ZIP_HOME_SUGGESTION;
+ }
+ if ( (! -d "$main::OO_SDK_ZIP_HOME") ||
+ ((-d "$main::OO_SDK_ZIP_HOME") && (! -e "$main::OO_SDK_ZIP_HOME/zip")) )
+ {
+ $main::OO_SDK_ZIP_HOME = "";
+ print " Error: zip tool is required, please specify a zip tool directory.\n";
+ } else
+ {
+ #check version
+ my $testVersion = `$OO_SDK_ZIP_HOME/zip -h 2>&1 | egrep Zip | head -n 1`;
+ $testVersion =~ s#Zip ([\d.]+) .*#$1#go;
+ if ( $testVersion eq "")
+ {
+ print " Set the environment variable OO_SDK_ZIP_HOME to your zip tool directory.\n";
+ print " zip version $main::zipVersion can be obtained at ftp://www.info-zip.org/\n";
+ } else
+ {
+ if ($testVersion =~ m#((\d+\.)+\d+)# )
+ {
+ $testVersion = $1;
+ }
+ $main::correctVersion = testVersion($main::zipVersion, $testVersion, "$main::OO_SDK_MAKE_HOME/zip", 1);
+ if ( !$main::correctVersion )
+ {
+ print " The 'zip' command found at '$main::OO_SDK_ZIP_HOME' has a wrong version\n";
+ $main::OO_SDK_ZIP_HOME = "";
+ }
+ }
+ }
+}
+
+# prepare C++ compiler path
+$main::correctVersion = 0;
+while ( (!$main::correctVersion) &&
+ ((! -d "$main::OO_SDK_CPP_HOME" ) ||
+ ((-d "$main::OO_SDK_CPP_HOME") && (! -e "$main::OO_SDK_CPP_HOME/$main::cpp"))) )
+{
+ print " C++ compilers where for example a language binding exist:\n";
+ print " - Solaris, Sun WorkShop 6 update 1 C++ 5.2 2000/09/11 or higher\n";
+ print " - Linux, GNU C++ compiler, gcc version 4.0.1 or higher\n";
+ print " - MacOS, GNU C++ compiler, gcc version 4.0.1 or higher\n";
+ print " Enter the directory of the C++ compiler, the directory\n";
+ print " where the compiler is located (optional) [$main::OO_SDK_CPP_HOME_SUGGESTION]: ";
+
+ $main::OO_SDK_CPP_HOME = readStdIn();
+ chop($main::OO_SDK_CPP_HOME);
+ if ( $main::OO_SDK_CPP_HOME eq "" )
+ {
+ $main::OO_SDK_CPP_HOME = $main::OO_SDK_CPP_HOME_SUGGESTION;
+ }
+
+ if ( ! $main::OO_SDK_CPP_HOME eq "" )
+ {
+ if ( (! -d "$main::OO_SDK_CPP_HOME") ||
+ ((-d "$main::OO_SDK_CPP_HOME") && (! -e "$main::OO_SDK_CPP_HOME/$main::cppName")) )
+ {
+ print " Error: Could not find directory '$main::OO_SDK_CPP_HOME'.\n";
+ if ( skipChoice("C++ compiler") == 1 )
+ {
+ $main::correctVersion = 1;
+ }
+ $main::OO_SDK_CPP_HOME = "";
+ } else
+ {
+ #check version
+ if ( $main::cppName eq "gcc" )
+ {
+ my $testVersion = `$OO_SDK_CPP_HOME/$main::cppName -dumpversion`;
+ if ( $testVersion eq "")
+ {
+ print " The '$main::cppName' command found at $main::OO_SDK_CPP_HOME/$main::cppName is not a ";
+ print " GNU compiler.\nSet the environment variable OO_SDK_CPP_HOME to your GNU build tools ";
+ print " directory.\nA GNU compiler version $main::cppVersion can be obtained at ";
+ print " ftp://ftp.gnu.org/gnu/gcc/\n";
+ } else
+ {
+ $main::correctVersion = testVersion($main::cppVersion, $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 1);
+ if ( !$main::correctVersion )
+ {
+ print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n";
+ if ( skipChoice("C++ compiler") == 1 )
+ {
+ $main::correctVersion = 1;
+ }
+
+ $main::OO_SDK_CPP_HOME = "";
+ }
+ }
+ } else
+ {
+ # for Solaris we have to check the version too
+ open(FILE, "$OO_SDK_CPP_HOME/$main::cppName -V 2>&1 |");
+ my @lines = <FILE>;
+ my $testVersion = $lines[0];
+ if ( $testVersion eq "")
+ {
+ print " The '$main::cppName' command found at $main::OO_SDK_CPP_HOME/$main::cppName is not a ";
+ print " Solaris C++ compiler.\nSet the environment variable OO_SDK_CPP_HOME to your Solaris C++ compiler directory.\n";
+ } else
+ {
+ if ($testVersion =~ m#((\d+\.)+\d+)# )
+ {
+ $testVersion = $1;
+ }
+ $main::correctVersion = testVersion($main::cppVersion, $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 1);
+ if ( !$main::correctVersion )
+ {
+ print " The '$main::cppName' command found at '$main::OO_SDK_CPP_HOME' has a wrong version\n";
+ if ( skipChoice("C++ compiler") == 1 )
+ {
+ $main::correctVersion = 1;
+ }
+
+ $main::OO_SDK_CPP_HOME = "";
+ } else {
+ $main::correctVersion = testVersion("5.5", $testVersion, "$main::OO_SDK_CPP_HOME/$main::cppName", 2);
+ if ( $main::correctVersion ) {
+ $main::OO_SDK_CC_55_OR_HIGHER = $testVersion;
+ }
+ }
+ }
+ }
+ }
+ } else
+ {
+ # the C++ compiler is optional
+ $main::correctVersion = 1;
+ }
+}
+
+
+# prepare Java path
+$main::correctVersion = 0;
+
+# prepare Java suggestion (cut bin or Commands directory to be in the root of the Java SDK)
+$main::offset = rindex($main::OO_SDK_JAVA_HOME_SUGGESTION, "/$main::OO_SDK_JAVA_BIN_DIR");
+if ( $main::offset != -1 )
+{
+ $main::OO_SDK_JAVA_HOME_SUGGESTION = substr($main::OO_SDK_JAVA_HOME_SUGGESTION, 0, $main::offset);
+}
+
+while ( (!$main::correctVersion) &&
+ ((! -d "$main::OO_SDK_JAVA_HOME" ) ||
+ ((-d "$main::OO_SDK_JAVA_HOME") && (! -e "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/javac"))) )
+{
+ print " Enter Java SDK (1.5, recommendation is 1.6 or higher) installation directory (optional) [$main::OO_SDK_JAVA_HOME_SUGGESTION]: ";
+ $main::OO_SDK_JAVA_HOME = readStdIn();
+ chop($main::OO_SDK_JAVA_HOME);
+ if ( $main::OO_SDK_JAVA_HOME eq "" )
+ {
+ $main::OO_SDK_JAVA_HOME = $main::OO_SDK_JAVA_HOME_SUGGESTION;
+ }
+ if ( ! $main::OO_SDK_JAVA_HOME eq "" )
+ {
+ if ( (! -d "$main::OO_SDK_JAVA_HOME") ||
+ ((-d "$main::OO_SDK_JAVA_HOME") && (! -e "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/javac")) )
+ {
+ print " Error: Could not find directory '$main::OO_SDK_JAVA_HOME' or '$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/javac'.\n";
+ if ( skipChoice("JAVA SDK") == 1 )
+ {
+ $main::correctVersion = 1;
+ }
+ $main::OO_SDK_JAVA_HOME = "";
+ } else
+ {
+ #check version
+ my $testVersion = `$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/java -version 2>&1 | egrep "java version" | head -n 1 | sed -e 's#.*version "##' | sed -e 's#".*##'`;
+ $testVersion =~ s#([^\n]+)\n#$1#go;
+
+ $main::correctVersion = testVersion($main::javaVersion, $testVersion, "$main::OO_SDK_JAVA_HOME/$main::OO_SDK_JAVA_BIN_DIR/java", 1);
+ if ( !$main::correctVersion )
+ {
+ if ( skipChoice("JAVA SDK") == 1 )
+ {
+ $main::correctVersion = 1;
+ }
+ $main::OO_SDK_JAVA_HOME = "";
+ }
+ }
+ }else
+ {
+ # the Java SDK is optional
+ $main::correctVersion = 1;
+ }
+}
+
+
+# prepare output directory (optional)
+while ( (!$main::skipOutputDir) &&
+ (! -d "$main::OO_SDK_OUTPUT_DIR") )
+{
+ print " Default output directory is in your HOME directory.\n";
+ print " Enter an existent directory if you prefer a different output directory (optional) [$main::OO_SDK_OUTPUT_DIR_SUGGESTION]: ";
+
+ $main::OO_SDK_OUTPUT_DIR = readStdIn();
+
+ chop($main::OO_SDK_OUTPUT_DIR);
+ if ( $main::OO_SDK_OUTPUT_DIR eq "" )
+ {
+ $main::OO_SDK_OUTPUT_DIR = $main::OO_SDK_OUTPUT_DIR_SUGGESTION;
+ }
+ if ( ! $main::OO_SDK_OUTPUT_DIR eq "" )
+ {
+ if ( ! -d "$main::OO_SDK_OUTPUT_DIR" )
+ {
+ print " Error: Could not find directory '$main::OO_SDK_OUTPUT_DIR'.\n";
+ if ( skipChoice("optional output directory") == 1 )
+ {
+ $main::skipOutputDir = 1;
+ }
+ $main::OO_SDK_OUTPUT_DIR = "";
+ }
+ } else
+ {
+ # the output directory is optional
+ $main::skipOutputDir = 1;
+ }
+}
+
+# prepare auto deployment
+if ( $main::OFFICE_OR_URE eq "Office" )
+{
+ while ( $main::SDK_AUTO_DEPLOYMENT eq "" ||
+ ((! $main::SDK_AUTO_DEPLOYMENT eq "YES") &&
+ (! $main::SDK_AUTO_DEPLOYMENT eq "NO")) )
+ {
+ print " Automatic deployment of UNO components (YES/NO) [$main::SDK_AUTO_DEPLOYMENT_SUGGESTION]: ";
+ $main::SDK_AUTO_DEPLOYMENT = uc <STDIN>;
+ chop($main::SDK_AUTO_DEPLOYMENT);
+ if ( $main::SDK_AUTO_DEPLOYMENT eq "" )
+ {
+ $main::SDK_AUTO_DEPLOYMENT = "YES";
+ }
+ }
+}
+else
+{
+ $main::SDK_AUTO_DEPLOYMENT = "NO";
+}
+
+prepareScriptFile("setsdkenv_unix.sh.in", "setsdkenv_unix.sh", 1);
+chmod 0644, "$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh";
+
+prepareScriptFile("setsdkenv_unix.csh.in", "setsdkenv_unix.csh", 2);
+chmod 0644, "$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.csh";
+
+print "\n";
+print " ************************************************************************\n";
+print " * ... your SDK environment has been prepared.\n";
+print " * For each time you want to use this configured SDK environment, you\n";
+print " * have to run the \"setsdkenv_unix\" script file!\n";
+print " * Alternatively can you source one of the scripts\n";
+print " * \"$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.sh\"\n";
+print " * \"$main::OO_SDK_CONFIG_HOME/$main::hostname/setsdkenv_unix.csh\"\n";
+print " * to get an environment without starting a new shell.\n";
+print " ************************************************************************\n\n";
+
+exit $return;
+
+sub skipChoice
+{
+ my $msg = shift;
+ my $skip = "";
+ while ( !( $skip eq "yes" || $skip eq "no") )
+ {
+ print " Do you want to skip the choice of the '$msg' (YES/NO): [YES] ";
+ $skip = lc <STDIN>;
+ chop($skip);
+ if ( $skip eq "" ) { $skip = "yes"; } # default
+ if ( $skip eq "yes" )
+ {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+sub resolveLink
+{
+ my $base= shift;
+ my $link= shift;
+
+ my $resolvedpath = "$base/$link";
+ my $linktarget = readlink "$resolvedpath";
+ my $resolvedlink = "";
+
+ while ( $linktarget ne "") {
+
+ if ( $linktarget =~ m/^\/.*/ )
+ {
+ $resolvedpath = "$linktarget";
+ } else {
+ $resolvedpath = `cd $base/$linktarget; pwd`;
+ chop $resolvedpath;
+ }
+ $base = dirname("$resolvedpath");
+
+ $linktarget = readlink "$resolvedpath";
+ }
+
+ $resolvedlink = `cd $resolvedpath; pwd`;
+ chop $resolvedlink;
+ return $resolvedlink;
+}
+
+sub searchprog
+{
+ my $_search= shift;
+ my $tmpPath = `echo "\$PATH"`;
+ my @pathList = split(":" , $tmpPath);
+ my $progDir = "";
+
+ if ( $_search eq "javac" )
+ {
+ if ( $main::operatingSystem =~ m/darwin/ ) {
+ $progDir = resolveLink("/System/Library/Frameworks/JavaVM.Framework/Versions", "CurrentJDK");
+
+ if ( -e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" )
+ {
+ return "$progDir/$main::OO_SDK_JAVA_BIN_DIR";
+ }
+ }
+
+ if ( $main::operatingSystem =~ m/solaris/ ) {
+ $progDir = resolveLink("/usr/jdk", "latest");
+ if ( -e "$progDir/$main::OO_SDK_JAVA_BIN_DIR/javac" )
+ {
+ return "$progDir/$main::OO_SDK_JAVA_BIN_DIR";
+ }
+ }
+ }
+
+ if ( $_search eq "gmake" && $main::operatingSystem =~ m/solaris/ ) {
+ if ( -e "/usr/sfw/bin/gmake" )
+ {
+ return "/usr/sfw/bin";
+ }
+ }
+
+ foreach $i (@pathList)
+ {
+ chomp ($i);
+
+ if ( -e "$i/$_search" )
+ {
+
+ if ( index($i, "/") == 0 )
+ {
+ # # absolute path; leave unchanged
+ $progDir = $i;
+ } else
+ {
+ $progDir = `cd "$i"; pwd`;
+ }
+ return $progDir
+ }
+ }
+ return $progDir
+}
+
+sub searchMacOffice
+{
+ if (-d "/Applications/OpenOffice.org.app" ) {
+ return "/Applications/OpenOffice.org.app"
+ }
+ if (-d "/Applications/Oracle Open Office.app" ) {
+ return "/Applications/Oracle Open Office.app";
+ }
+ if (-d "/Applications/StarOffice.app" ) {
+ return "/Applications/StarOffice.app";
+ }
+ if (-d "/Applications/StarSuite.app" ) {
+ return "/Applications/StarSuite.app";
+ }
+
+ return "";
+}
+
+sub searchoffice
+{
+ my $offset = rindex($main::sdkpath, "/openoffice.org");
+ my $tmpOffice = substr($main::sdkpath, 0, $offset);
+ my $officepath = "$tmpOffice/openoffice.org$main::OO_MAJORVERSION";
+
+# if ( $main::OO_MINORVERSION > 0) {
+# $officepath = "$officepath$main::OO_MINORVERSION";
+# }
+
+ # search corresponding office for this SDK
+ if (-d $officepath && -e "$officepath/program/soffice") {
+ return $officepath;
+ }
+ # fallback
+ my $tmpversion = $main::OO_MAJORVERSION;
+# if ( $main::OO_MINORVERSION > 0) {
+# $tmpversion = "$tmpversion.$main::OO_MINORVERSION";
+# }
+
+ $officepath = "$tmpOffice/oracle_open_office$tmpversion";
+ if (-d $officepath && -e "$officepath/program/soffice") {
+ return $officepath;
+ }
+
+ my $tmpversion = $main::OO_MAJORVERSION + 6;
+ if ( $main::OO_MINORVERSION > 0) {
+ $tmpversion = "$tmpversion.$main::OO_MINORVERSION";
+ }
+
+ $officepath = "$tmpOffice/staroffice$tmpversion";
+ if (-d $officepath && -e "$officepath/program/soffice") {
+ return $officepath;
+ }
+ $officepath = "$tmpOffice/StarOffice$tmpversion";
+ if (-d $officepath && -e "$officepath/program/soffice") {
+ return $officepath;
+ }
+ $officepath = "$tmpOffice/starsuite$tmpversion";
+ if (-d $officepath && -e "$officepath/program/soffice") {
+ return $officepath;
+ }
+ $officepath = "$tmpOffice/StarSuite$tmpversion";
+ if (-d $officepath && -e "$officepath/program/soffice") {
+ return $officepath;
+ }
+ $officepath = "";
+
+ # search other potential matching office versions
+ my $path = "/opt/";
+ my $entry = "";
+ my $version = "0";
+ for $entry (glob($path.'*')) {
+ ## if the file is a directory
+ if( -d $entry) {
+
+ if ($entry =~ m#(.+(o|O)ffice(\.org){0,1}(\d([\d\.]){0,2}))# ||
+ $entry =~ m#(.+(s|S)uite(.*)(\d([\d\.]){0,2}))# )
+ {
+ if ($4 > $version) {
+ $version = $4;
+ $officepath = $entry;
+ }
+ }
+ }
+ }
+ return $officepath;
+}
+
+
+
+sub testVersion
+{
+ my $tmpMustBeVersion = shift;
+ my $tmpTestVersion = shift;
+ my $toolName = shift;
+ # 1=check + message 2=check only
+ my $checkOnly = shift;
+ my @mustBeVersion = split(/\.|_|-/,$tmpMustBeVersion);
+ my @testVersion = split(/\.|_|-/,$tmpTestVersion);
+ my $length = $#mustBeVersion;
+
+ if ($#testVersion < $#mustBeVersion) {
+ $length = $#testVersion;
+ }
+
+ for ($i=0; $i <= $length; $i++ )
+ {
+ if ( @testVersion->[$i] > @mustBeVersion->[$i] )
+ {
+ return 1; # 1 indicates a correct version
+ }
+
+ if ( @testVersion->[$i] < @mustBeVersion->[$i] )
+ {
+ if ( $#checkOnly == 1 ) {
+ print " The command '$toolName' has the version $tmpTestVersion.\n";
+ print " The SDK requires at least the version $tmpMustBeVersion.\n";
+ }
+ return 0;
+ }
+ }
+
+ return 1; # 1 indicates a correct version
+}
+
+sub readStdIn
+{
+ my $tmpstdin = <STDIN>;
+ if ( index($tmpstdin, "\$") != -1)
+ {
+ return `echo $tmpstdin`;
+ }
+
+ return $tmpstdin;
+}
+
+sub prepareScriptFile()
+{
+ my $inputFile = shift;
+ my $outputFile = shift;
+ # shell mode 1 = sh
+ # 2 = csh
+ my $shellMode = shift;
+
+ if ( ! -d "$main::OO_SDK_CONFIG_HOME/$main::hostname" )
+ {
+ system("mkdir -p $main::OO_SDK_CONFIG_HOME/$main::hostname");
+ }
+
+ open ( FILEIN, "$main::sdkpath/$inputFile" ) || die "\nERROR: could not open '$main::sdkpath/$inputFile' for reading";
+ open ( FILEOUT, ">$main::OO_SDK_CONFIG_HOME/$main::hostname/$outputFile" ) || die "\nERROR: could not open '$main::OO_SDK_CONFIG_HOME/$main::hostname/$outputFile' for writing";
+
+ while ( <FILEIN> )
+ {
+ $_ =~ s#\@OO_SDK_NAME\@#$main::OO_SDK_NAME#go;
+ $_ =~ s#\@OO_SDK_HOME\@#$main::OO_SDK_HOME#go;
+ $_ =~ s#\@OFFICE_HOME\@#$main::OFFICE_HOME#go;
+ $_ =~ s#\@OFFICE_BASE_HOME\@#$main::OFFICE_BASE_HOME#go;
+ $_ =~ s#\@OO_SDK_URE_HOME\@#$main::OO_SDK_URE_HOME#go;
+ $_ =~ s#\@OO_SDK_MAKE_HOME\@#$main::OO_SDK_MAKE_HOME#go;
+ $_ =~ s#\@OO_SDK_ZIP_HOME\@#$main::OO_SDK_ZIP_HOME#go;
+ $_ =~ s#\@OO_SDK_CPP_HOME\@#$main::OO_SDK_CPP_HOME#go;
+ $_ =~ s#\@OO_SDK_CC_55_OR_HIGHER\@#$main::OO_SDK_CC_55_OR_HIGHER#go;
+ $_ =~ s#\@OO_SDK_JAVA_HOME\@#$main::OO_SDK_JAVA_HOME#go;
+ $_ =~ s#\@SDK_AUTO_DEPLOYMENT\@#$main::SDK_AUTO_DEPLOYMENT#go;
+ $_ =~ s#\@OO_SDK_OUTPUT_DIR\@#$main::OO_SDK_OUTPUT_DIR#go;
+
+ print FILEOUT $_;
+ }
+
+ close FILEIN;
+ close FILEOUT;
+}
diff --git a/odk/docs/common/ref/idl.css b/odk/docs/common/ref/idl.css
new file mode 100644
index 000000000000..6327b9243f80
--- /dev/null
+++ b/odk/docs/common/ref/idl.css
@@ -0,0 +1,130 @@
+/* Autodoc css file for IDL documentation */
+
+
+/*See bottom of file for explanations.*/
+
+body { background-color:#ffffff; }
+
+#adc-idlref a { text-decoration: none; }
+#adc-idlref a:link { color: #0e85cd; }
+#adc-idlref a:visited { color: #638093; }
+#adc-idlref a:active { color: #4dadea; }
+
+#adc-idlref h3
+ { font-size:13pt; font-weight:bold;
+ margin-top:3pt; margin-bottom:1pt; }
+
+#adc-idlref p, #adc-idlref dt, #adc-idlref dd, #adc-idlref pre
+ { font-size:11pt;
+ margin-top:3pt; margin-bottom:1pt; }
+
+#adc-idlref pre { font-family:monospace; }
+
+#adc-idlref table.subtitle { margin-top:6pt; margin-bottom:6pt; }
+
+#adc-idlref td { font-size:11pt; }
+#adc-idlref td.title
+ { font-family: Arial; font-size:19pt; font-weight:bold;
+ line-height:30pt;
+ background-image:url(../../images/bg_table.png);
+ text-align:center; }
+
+#adc-idlref td.subtitle
+ { font-family: Arial; font-size:13pt;
+ line-height:20pt;
+ background-image:url(../../images/bg_table.png); }
+
+#adc-idlref td.crosstitle
+ { font-size:12pt; font-weight:bold;
+ line-height:15pt; background-color:#eeeeff; }
+
+#adc-idlref td.imdetail
+ { width:100%;
+ background-image:url(../../images/bg_table3.png); }
+
+#adc-idlref td.imsum_left { width:30%; }
+#adc-idlref td.imsum_right { width:70%; }
+
+#adc-idlref table.navimain { background-image:url(../../images/bg_table2.png); }
+
+#adc-idlref td.navimain
+ { background-image:url(../../images/bg_table2.png);
+ text-align:center;
+ font-family: Arial; font-size:12pt; font-weight:bold;
+ padding-left:7pt; padding-right:7pt; }
+
+#adc-idlref td.navimainself
+ { text-align:center;
+ font-family: Arial; font-size:12pt; font-weight:bold;
+ color:#ffffff; }
+
+#adc-idlref td.navimainnone
+ { text-align:center;
+ font-family: Arial; font-size:12pt; }
+
+#adc-idlref td.navisub
+ { text-align:center;
+ font-family: Arial; font-size:9pt; font-variant:small-caps;
+ padding-left:7pt; padding-right:7pt; }
+
+#adc-idlref a.navimain
+ { text-align:center;
+ font-family: Arial; font-size:12pt; font-weight:bold;
+ color:#C44B01; }
+
+#adc-idlref a.navisub
+ { text-align:center;
+ font-family: Arial; font-size:9pt; font-variant:small-caps;
+ color:#C44B01; }
+
+#adc-idlref a.membertitle { font-size:12pt; font-weight:bold; line-height:18pt; }
+
+#adc-idlref a:link.navimain, #adc-idlref a:link.navisub { color:#0e85cd; }
+#adc-idlref a:visited.navimain, #adc-idlref a:visited.navisub { color: #638093; }
+#adc-idlref a:active.navimain, #adc-idlref a:active.navisub { color: #4dadea; }
+
+#adc-idlref .dt { font-weight:bold; }
+#adc-idlref .namechain { font-size:13pt; font-weight:bold; margin-top:3pt; margin-bottom:6pt; }
+#adc-idlref .title2 { font-size:13pt; font-style:italic; font-weight:bold; text-align:left; }
+
+#adc-idlref table { empty-cells:show; }
+
+#adc-idlref .childlist td,
+#adc-idlref .commentedlinks td,
+#adc-idlref .memberlist td,
+#adc-idlref .subtitle td,
+#adc-idlref .crosstitle td { border: .1pt solid grey; }
+
+#adc-idlref .flag-table td { border: .1pt solid #cccccc; }
+
+#adc-idlref .title-table td,
+#adc-idlref .table-in-method td,
+#adc-idlref .table-in-data td,
+#adc-idlref .navimain td,
+#adc-idlref .navisub td,
+#adc-idlref .expl-table td,
+#adc-idlref .param-table td { border: none; }
+
+
+/* Explanation of CSS classes:
+
+table.lightbg Background of navigation bar.
+.navimain Text in main navigation bar.
+.navisub Text in lower navigation bar.
+td.navimainself Cell in main navigation bar with "selected" shadow: You are here.
+td.navimainnone Cell in main navigation bar with no link.
+
+.namechain Line with current module path.
+
+td.crosstitle Comment box for bases (base interfaces etc.)
+td.imsum_left Left part of such boxes.
+td.imsum_right Right part of such boxes.
+
+td.title Main title of the page like "interface XYz"
+.subtitle Tables, and head cells of those, which list members
+ like "method summary" and "method details".
+
+td.imdetail Background table of method's detail description.
+a.membertitle Method name (as jump label) in method's detail
+ description.
+*/
diff --git a/odk/docs/cpp/ref/cpp.css b/odk/docs/cpp/ref/cpp.css
new file mode 100644
index 000000000000..b8286999bf19
--- /dev/null
+++ b/odk/docs/cpp/ref/cpp.css
@@ -0,0 +1,127 @@
+/* Autodoc css file for C++ documentation */
+
+
+body { background-color:#ffffff; }
+
+#adc-cppref a { text-decoration: none; }
+#adc-cppref a:link { color: #0e85cd; }
+#adc-cppref a:visited { color: #638093; }
+#adc-cppref a:active { color: #4dadea; }
+
+#adc-cppref h1 { font-size:20pt; margin-top:3pt; margin-bottom:7pt; }
+#adc-cppref h2 { font-family:Arial; font-size:16pt; margin-top:3pt; margin-bottom:5pt; }
+#adc-cppref h3 { font-size:13pt; margin-top:2pt; margin-bottom:3pt; }
+#adc-cppref h4 { font-size:10pt; font-weight:bold; margin-top:2pt; margin-bottom:1pt; }
+#adc-cppref dl { margin-top:1pt; margin-bottom:1pt; }
+#adc-cppref dl.member { margin-top:1pt; margin-bottom:1pt;
+ background-image:url(../../images/bg_table3.png); }
+#adc-cppref dt { font-size:10pt; font-weight:bold; margin-top:2pt; margin-bottom:1pt; }
+#adc-cppref dt.member { font-size:13pt; font-weight:bold; margin-top:2pt; margin-bottom:1pt; }
+#adc-cppref dt.simple { font-size:10pt; font-weight:normal; margin-top:2pt; margin-bottom:1pt; }
+#adc-cppref dd { font-size:10pt; margin-top:1pt; margin-bottom:1pt; }
+#adc-cppref dd.member { font-size:10pt; margin-top:1pt; margin-bottom:1pt; background-color:#ffffff; }
+#adc-cppref p { font-size:10pt; margin-top:3pt; margin-bottom:1pt; }
+#adc-cppref pre { font-family:monospace; font-size:10pt; margin-top:1pt; margin-bottom:1pt; }
+#adc-cppref tr { font-size:10pt; }
+#adc-cppref td { font-size:10pt; }
+
+#adc-cppref dt.attention { color:#ff0000; }
+
+#adc-cppref div.title { text-align:center; line-height:26pt;
+ background-image:url(../../images/bg_table.png); }
+#adc-cppref .subtitle { background-image:url(../../images/bg_table.png); }
+
+#adc-cppref td.flagname { background-image:url(../../images/bg_table2.png);
+ font-family:Arial; font-size:8pt; font-weight:bold; }
+#adc-cppref td.flagyes { font-family:Arial; font-size:8pt; font-weight:bold; }
+#adc-cppref td.flagno { font-family:Arial; font-size:8pt; }
+#adc-cppref td.flagtext { font-family:Arial; font-size:8pt; font-weight:bold; }
+
+#adc-cppref td.navimain, td.navimain a
+ { background-image:url(../../images/bg_table2.png);
+ font-family:Arial; font-size:12pt; font-weight:bold; }
+
+/* background-color:#eeeeff; color:#000000; */
+
+#adc-cppref td.navimainself
+ { background-color:#226bb0; color:#ffffff;
+ font-family:Arial; font-size:12pt; font-weight:bold; }
+#adc-cppref td.navimainnone
+ { background-image:url(../../images/bg_table2.png);
+ font-family:Arial; font-size:12pt; }
+
+#adc-cppref div.define { font-family:Arial; background-color:#87c2e6; }
+
+#adc-cppref .nqclass { color:#008800; }
+
+#adc-cppref h3.help { background-color:#cfe7f5; margin-top:12pt; }
+
+#adc-cppref .btpubl { color:#87c2e6; }
+#adc-cppref .btprot { color:#226bb0; }
+#adc-cppref .btpriv { color:#06348c; }
+#adc-cppref .btvpubl { color:#87c2e6; font-style:italic; }
+#adc-cppref .btvprot { color:#226bb0; font-style:italic; }
+#adc-cppref .btvpriv { color:#06348c; font-style:italic; }
+#adc-cppref .btself { font-weight:bold; }
+
+#adc-cppref table { empty-cells:show; }
+
+#adc-cppref .childlist td,
+#adc-cppref .commentedlinks td,
+#adc-cppref .memberlist td,
+#adc-cppref .title-table td,
+#adc-cppref .subtitle td,
+#adc-cppref .crosstitle td { border: .1pt solid grey }
+
+#adc-cppref .flag-table td { border: .1pt solid #cccccc; }
+
+#adc-cppref .table-in-method td,
+#adc-cppref .table-in-data td,
+#adc-cppref .navimain td,
+#adc-cppref .navisub td,
+#adc-cppref .expl-table td,
+#adc-cppref .param-table td { border: none; }
+
+
+/* Explanation of CSS classes:
+
+dl.member provides coloured frame for function descriptions.
+dd.member makes the content of this frame white
+
+dt.attention special colour for @attention remarks
+
+div.title HTML page headline
+.subtitle headline of lists of members and similar
+
+ These are for the flagtables in classes:
+td.flagname Flag name.
+td.flagyes flag value "yes"
+td.flagno flag value "no"
+td.flagtext other flag value
+
+
+ These are for the main navigationbar:
+td.navimain, td.navimain a
+ Links in navibar.
+td.navimainself Text in navibar which refers to current page.
+td.navimainnone Text which links to nothing.
+
+
+div.define Subtitles on the #define/macro descriptions page
+
+.nqclass special color for classes in the qualification
+ on top of type pages like in:
+ ::nsp1::nsp2::_ClassXY_::
+
+h3.help Subtitles on the help page
+
+ These are for the base class tree on class pages:
+.btpubl public base class
+.btprot protected
+.btpriv private
+.btvpubl virtual public
+.btvprot virtual protected
+.btvpriv virtual private
+.btself placeholder for currently displayed class
+
+*/
diff --git a/odk/docs/images/arrow-1.gif b/odk/docs/images/arrow-1.gif
new file mode 100644
index 000000000000..99da8a7d5b0f
--- /dev/null
+++ b/odk/docs/images/arrow-1.gif
Binary files differ
diff --git a/odk/docs/images/arrow-2.gif b/odk/docs/images/arrow-2.gif
new file mode 100644
index 000000000000..2e2b20d7d325
--- /dev/null
+++ b/odk/docs/images/arrow-2.gif
Binary files differ
diff --git a/odk/docs/images/arrow-3.gif b/odk/docs/images/arrow-3.gif
new file mode 100644
index 000000000000..99da8a7d5b0f
--- /dev/null
+++ b/odk/docs/images/arrow-3.gif
Binary files differ
diff --git a/odk/docs/images/bg_table.gif b/odk/docs/images/bg_table.gif
new file mode 100644
index 000000000000..8c961993cf31
--- /dev/null
+++ b/odk/docs/images/bg_table.gif
Binary files differ
diff --git a/odk/docs/images/bg_table.png b/odk/docs/images/bg_table.png
new file mode 100644
index 000000000000..eb5d4f2f7381
--- /dev/null
+++ b/odk/docs/images/bg_table.png
Binary files differ
diff --git a/odk/docs/images/bg_table2.gif b/odk/docs/images/bg_table2.gif
new file mode 100755
index 000000000000..8f8ad2f1d442
--- /dev/null
+++ b/odk/docs/images/bg_table2.gif
Binary files differ
diff --git a/odk/docs/images/bg_table2.png b/odk/docs/images/bg_table2.png
new file mode 100644
index 000000000000..d0cafddfecaa
--- /dev/null
+++ b/odk/docs/images/bg_table2.png
Binary files differ
diff --git a/odk/docs/images/bg_table3.gif b/odk/docs/images/bg_table3.gif
new file mode 100755
index 000000000000..d0c6469c9525
--- /dev/null
+++ b/odk/docs/images/bg_table3.gif
Binary files differ
diff --git a/odk/docs/images/bg_table3.png b/odk/docs/images/bg_table3.png
new file mode 100644
index 000000000000..2759066df928
--- /dev/null
+++ b/odk/docs/images/bg_table3.png
Binary files differ
diff --git a/odk/docs/images/bluball.gif b/odk/docs/images/bluball.gif
new file mode 100644
index 000000000000..dc7c020045d3
--- /dev/null
+++ b/odk/docs/images/bluball.gif
Binary files differ
diff --git a/odk/docs/images/nada.gif b/odk/docs/images/nada.gif
new file mode 100644
index 000000000000..75b945d25538
--- /dev/null
+++ b/odk/docs/images/nada.gif
Binary files differ
diff --git a/odk/docs/images/nav_down.png b/odk/docs/images/nav_down.png
new file mode 100644
index 000000000000..fee3fbf30bea
--- /dev/null
+++ b/odk/docs/images/nav_down.png
Binary files differ
diff --git a/odk/docs/images/nav_home.png b/odk/docs/images/nav_home.png
new file mode 100644
index 000000000000..36c4cf76cdde
--- /dev/null
+++ b/odk/docs/images/nav_home.png
Binary files differ
diff --git a/odk/docs/images/nav_left.png b/odk/docs/images/nav_left.png
new file mode 100644
index 000000000000..b2f5da725fb0
--- /dev/null
+++ b/odk/docs/images/nav_left.png
Binary files differ
diff --git a/odk/docs/images/nav_right.png b/odk/docs/images/nav_right.png
new file mode 100644
index 000000000000..87310372a2f6
--- /dev/null
+++ b/odk/docs/images/nav_right.png
Binary files differ
diff --git a/odk/docs/images/nav_up.png b/odk/docs/images/nav_up.png
new file mode 100644
index 000000000000..8267ada19789
--- /dev/null
+++ b/odk/docs/images/nav_up.png
Binary files differ
diff --git a/odk/docs/images/odk-footer-logo.gif b/odk/docs/images/odk-footer-logo.gif
new file mode 100644
index 000000000000..e79cd7143ac3
--- /dev/null
+++ b/odk/docs/images/odk-footer-logo.gif
Binary files differ
diff --git a/odk/docs/images/ooo-main-app_32.png b/odk/docs/images/ooo-main-app_32.png
new file mode 100644
index 000000000000..296c6f4c58b1
--- /dev/null
+++ b/odk/docs/images/ooo-main-app_32.png
Binary files differ
diff --git a/odk/docs/images/orc-main-app_32.png b/odk/docs/images/orc-main-app_32.png
new file mode 100644
index 000000000000..b596295abba1
--- /dev/null
+++ b/odk/docs/images/orc-main-app_32.png
Binary files differ
diff --git a/odk/docs/images/sdk_head-1.png b/odk/docs/images/sdk_head-1.png
new file mode 100644
index 000000000000..56094aabab52
--- /dev/null
+++ b/odk/docs/images/sdk_head-1.png
Binary files differ
diff --git a/odk/docs/images/sdk_head-2.png b/odk/docs/images/sdk_head-2.png
new file mode 100644
index 000000000000..61adc6f7c974
--- /dev/null
+++ b/odk/docs/images/sdk_head-2.png
Binary files differ
diff --git a/odk/docs/images/sdk_line-1.gif b/odk/docs/images/sdk_line-1.gif
new file mode 100644
index 000000000000..199d3a80bc88
--- /dev/null
+++ b/odk/docs/images/sdk_line-1.gif
Binary files differ
diff --git a/odk/docs/images/sdk_line-2.gif b/odk/docs/images/sdk_line-2.gif
new file mode 100644
index 000000000000..44ef0146a5ad
--- /dev/null
+++ b/odk/docs/images/sdk_line-2.gif
Binary files differ
diff --git a/odk/docs/install.html b/odk/docs/install.html
new file mode 100644
index 000000000000..baf9b5f1259f
--- /dev/null
+++ b/odk/docs/install.html
@@ -0,0 +1,420 @@
+<html>
+<head>
+ <title>OpenOffice.org %PRODUCT_RELEASE% SDK - Installation Guide</title>
+ <link rel="stylesheet" type="text/css" href="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="install"/>
+<table class="table1" cellpadding=0>
+ <tr style="background-image:url(images/sdk_head-2.png)">
+ <td colspan="3" align="left"><img src="images/sdk_head-1.png" width="800" height="120" usemap="#Map" border="0"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="nothing10" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td colspan="3"><img class="nothing1" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table3">
+ <tr>
+ <td colspan="2" class="head1">Installation Guide</td>
+ <td align="right"><a href="../index.html" title="link to the SDK start page"><img class="navigate" src="images/nav_home.png"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table3">
+ <tr>
+ <td colspan="2">
+ <p>The OpenOffice.org %PRODUCT_RELEASE% SDK comes with a set of development tools, base
+ libraries, header files and helper class files that can be used to
+ develop Java/C++ components, to embed the OpenOffice.org %PRODUCT_RELEASE% application in
+ your own programs, or to use the API (scripting or remote control the
+ office). For a complete working environment, we have some additional
+ requirements:</p>
+ </td>
+ </tr>
+ <tr valign="top">
+ <td><b>OpenOffice.org %PRODUCT_RELEASE% installation</td>
+ <td class="content80">The SDK works on top of an existing office
+ installation and uses the same libraries as the office installation.</td>
+ </tr>
+ </tr>
+ <tr valign="middle">
+ <td colspan="2"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr valign="top">
+ <td><b>JDK (1.5 or higher)<b></td>
+ <td class="content80">
+ <p>A JDK is necessary for developing Java components or applications. An appropriate Java SDK can be found on <a target="_blank" href="http://java.sun.com/products" title="link to the Java SDK download page (online)">http://java.sun.com/products</a>.</p>
+ <p>Recommendation is to use Java 6 excepting for Mac OS because initially Mac OS supported a 64bit version of Java 6 only.</p>
+ <p><b>Note</b>: The Java compiler is <b><u>optional</u></b>!</p></td>
+ </tr>
+ <tr valign="middle">
+ <td colspan="2"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr valign="top">
+ <td><b>C++ compiler<b></td>
+ <td class="content80">A C++ compiler is necessary for developing C++
+ components or applications. UNO depends on a compiler dependent language
+ binding, so that we use the appropriate compiler where a language binding
+ exists:
+ <table class="table4">
+ <tr>
+ <td class="cell15">Solaris</td>
+ <td class="cell85">Sun Studion 8 (20070730)</td>
+ </tr>
+ <tr>
+ <td class="cell15">Linux</td>
+ <td class="cell80">GNU C++ compiler, gcc version 4.0.1</td>
+ </tr>
+ <tr>
+ <td class="cell15">Windows</td>
+ <td class="cell80">Microsoft C++ Compiler, Microsoft Visual Studio 2008 or the Express version (cl, version 15.00.21022)</td>
+ </tr>
+ </table>
+ <p><b>Note</b>: The C++ compiler is <b><u>optional</u></b>! If you use the Express edition you have to ensure that the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF&displaylang=en">Microsoft Visual Studio 2008 Redistributable Package</a> is also installed. You can download this package from Microsoft directly.</a></p></td>
+ </tr>
+ <tr valign="middle">
+ <td colspan="2"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr valign="top">
+ <td><b>Microsoft .NET Framework SDK version 1.0 or higher<b></td>
+ <td class="content80">The SDK is required for building CLI applications.
+ That is, programs written in languages, such as C# or VB.NET.<br>
+ <p><b>Note</b>: The .NET Framework is <b><u>optional</u></b>!</p></td>
+ </tr>
+ <tr valign="middle">
+ <td colspan="2"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr valign="top">
+ <td><b>GNU make (3.79.1 or higher)<b></td>
+ <td class="content80">
+ <p>GNU make is used to build the examples of the SDK. GNU make is available from <a target="_blank" href="http://www.gnu.org" title="link to www.gnu.org (online)">http://www.gnu.org</a>. It can be ftped via <a target="_blank" href="ftp://ftp.gnu.org/gnu/make" title="link to gnumake on www.gnu.org (online)">ftp://ftp.gnu.org/gnu/make</a></p>
+ <p><b>Note</b>: Windows user can find an executable of gnu make under <a target="_blank" href="http://www.mingw.org/wiki/Getting_Started" title="link to the MinGW Getting Started wiki (online)">http://www.mingw.org/wiki/Getting_Started</a> (see the mingw32-make link under &quot;Manual Installation&quot;). Do not use the Cygwin make, because it does not
+ work well. On Solaris gnu make can be found often under <b><i>/usr/sfw/bin/gmake</i></b>, but keep in mind that you have to use <b>'gmake'</b> then. Or you can find gnu make also under <a target="_blank" href="http://www.sunfreeware.com/" title="link to www.sunfreeware.com (online)">http://www.sunfreeware.com/</a>.</td>
+ </tr>
+ <tr valign="middle">
+ <td colspan="2"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr valign="top">
+ <td><b>zip tool (2.3 or higher)<b></td>
+ <td class="content80">The zip tool is used to create UNO packages. zip is
+ a new requirement to make the SDK independent of a Java SDK.<br>
+ If you do not have these already, you can download them from <a target="_blank" href="http://www.info-zip.org" title="link to www.ubfi-zip.org (online)">http://www.info-zip.org</a>. Note: The cygwin zip.exe does not work for the build under
+ the 4NT shell. You have to use the native w32 version.</td>
+ </tr>
+ <tr valign="middle">
+ <td colspan="2"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td><img class="nothing10" src="images/nada.gif"></td>
+ <td align="right">
+ <a href="#install" title="link to the top of this page"><img class="navigate" src="images/nav_up.png"></a>
+ <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="images/nav_home.png"></a></td>
+ </tr>
+ <tr valign="middle">
+ <td colspan="2">
+ <p>The SDK provides an implicit configuration mechanism, which
+ configures the SDK build environment to your personal needs the first
+ time you use the SDK environment. This configuration step creates one or
+ two new setsdkenv_XXX scripts in the user's home directory:</P>
+ <ul>
+ <li><b>$HOME/$OO_SDK_NAME/setsdkenv_unix.sh</b> and <b>$HOME/$OO_SDK_NAME/setsdkenv_unix.csh</b>&nbsp;&nbsp;-> for Unix
+ <li><b>C:\Documents and Settings\&lt;username&gt;\Application Data\%OO_SDK_NAME%\setsdkenv_windows.bat</b></a>&nbsp;&nbsp;-> for Windows2000/XP or later
+ </ul>
+ <p>The automatically started configure script (Unix and Windows2000/XP)
+ requests relevant information and directories (SDK, StarOffice, GNU make,
+ Java, C++), in order to prepare a working SDK environment. After completing the
+ configure script once, the newly created script is always used to set the
+ necessary environment variables for using the SDK and the required
+ tools.</P>
+ <p>On UNIX operating systems, the configure script uses Perl. LINUX systems should have
+ installed a working Perl version, and on Solaris you can find a working
+ Perl version under <a target="_blank" href="http://www.sunfreeware.com/" title="link to www.sunfreeware.com (online)">http://www.sunfreeware.com/</a> if
+ necessary. On Windows, the configure script uses Windows Script and
+ a JScipt. If you have problems with Windows Script, you can download a
+ newer version of <a href ="http://www.microsoft.com/downloads/details.aspx?FamilyId=C717D943-7E4B-4622-86EB-95A22B832CAA&displaylang=en" link"link to the download page for the Windows Script">Windows Script</a>.
+ </p>
+ <p>On other versions of Windows, use the batch
+ file template <b>&lt;OO_SDK_HOME&gt;\setsdkenv_windows.template</b>,
+ rename it to *.bat, and adapt it to your local environment.</p>
+ <p>If you use the template batch file, edit and set
+ the following variables:</p>
+ <table class="table4">
+ <tr valign="top">
+ <td class="cell20"><b>OFFICE_HOME</b></td>
+ <td class="cell80">Path to an existing StarOffice&#153 or OpenOffice.org
+ base installation, e.g. &quot;/opt/staroffice8&quot;. Be sure
+ that it is not a user installation only. Exactly one of OFFICE_HOME
+ and OO_SDK_URE_HOME must be set. The other should be either unset or
+ set to an empty value.</td>
+ </tr>
+ <tr><a name="oosdkname"/>
+ <td class="cell20"><b>OO_SDK_NAME</b></td>
+ <td class="cell80">The configuration uses the
+ directory name of the SDK, but you can use another name as well.
+ It is important that the name does not contain spaces, because of a limitation
+ of gnu make which cannot handle spaces correctly. This name is, for
+ example, used to create an output directory in the users home directory
+ for any generated output when you use the SDK build environment.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><b>OO_SDK_URE_HOME</b></td>
+ <td class="cell80">Path to an existing UNO Runtime Environment
+ installation, e.g. &quot;/opt/openoffice.org/ure&quot;. Exactly one of
+ OFFICE_HOME and OO_SDK_URE_HOME must be set. The other should be
+ either unset or set to an empty value.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><b>OO_SDK_HOME</b></td>
+ <td class="cell80">Path to the SDK root directory, e.g.
+ &quot;/usr/local/StarOffice8_SDK&quot;</td>
+ </tr>
+ <tr>
+ <td class="cell20"><b>OO_SDK_JAVA_HOME</b></td>
+ <td class="cell80">Path to a JDK root directory. The JDK is
+ <b>optional</b> and only necessary if you like to run the Java examples
+ or if you like to use the SDK environment to develop your own Java
+ solution.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><b>OO_SDK_CPP_HOME</b></td>
+ <td class="cell80">Path to the C++ compiler (on Windows, the directory
+ where the &quot;<i>vcvar32.bat</i>&quot; file can be found). The C++
+ compiler is <b>optional</b> and only necessary for building the C++
+ examples.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><b>OO_SDK_CLI_HOME</b></td>
+ <td class="cell80">Path to the C# compiler and VB.NET compiler (on
+ Windows, this directory can be found under the system directory (e.g.
+ c:\WINXP\Microsoft.NET\Framework\v1.0.3705). The compilers are
+ <b>optional</b> and only necessary for building the CLI examples.<br>
+ <b>Note: Windows only!</b></td>
+ </tr>
+ <tr>
+ <td class="cell20"><b>OO_SDK_MAKE_HOME</b></td>
+ <td class="cell80">Path to GNU make.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><b>OO_SDK_ZIP_HOME</b></td>
+ <td class="cell80">Path to the 'zip' tool.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><b>OO_SDK_OUTPUT_DIR</b></td>
+ <td class="cell80">Path to an existing directory where the example output
+ is generated. The output directory is <b>optional</b>, by default
+ the output is generated in the SDK directory itself. If an output
+ directory is specified, the output is generated in a SDK dependent
+ subdirectory in this directory (e.g. &lt;OO_SDK_OUTPUT_DIR&gt;
+ /OpenOffice.org %PRODUCT_RELEASE%/LINUXExample.out)</td>
+ </tr>
+ <tr>
+ <td class="cell20"><b>SDK_AUTO_DEPLOYMENT</b></td>
+ <td class="cell80">If this variable is set, the component examples are automatically deployed into the Office installation referenced by
+ OFFICE_HOME. See also chapter <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Extensions/unopkg" title="link to the &quot;Extension Manager - unopkg&quot; chapter in the Developer's Guide">&quot;Extension Manager - unopkg&quot;</a> from the Developer's Guide.
+ This variable is only relevant when OFFICE_HOME is set.</td>
+ </tr>
+ </table>
+ <p>You must run the <b>setsdkenv_XXX</b> script every time you want to
+ use the configured SDK environment. The settings are local for the current
+ shell on Windows or the new started shell on UNIX. On UNIX you
+ can now source one of the prepared environment
+ script files (&quot;setsdkenv_unix.sh&quot; or
+ &quot;setsdkenv_unix.csh&quot; dependending on the shell you use) to prepare
+ your current shell instead of starting a new shell.</p>
+ </td>
+ </tr>
+ <tr valign="middle">
+ <td colspan="2"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td><img class="nothing10" src="images/nada.gif"></td>
+ <td align="right">
+ <a href="#install" title="link to the top of this page"><img class="navigate" src="images/nav_up.png"></a>
+ <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="images/nav_home.png"></a></td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <p class="head2">Manual Setting</p>
+ <p>If you do not want to use the script to set your working
+ environment, you must set the appropriate environment variables
+ yourself. The script sets the following environment variables:</p>
+ <p class="head3">Common Environment Variables</p>
+ <table class="table4">
+ <tr valign="top">
+ <td class="cell20">OO_SDK_NAME</td>
+ <td class="cell80">See description <a href="#oosdkname" title="link to the description of the environment variable OO_SDK_NAME">above</a>.</td>
+ </tr>
+ <tr valign="top">
+ <td class="cell20">OO_SDK_URE_BIN_DIR</td>
+ <td class="cell80">The path within the chosen office or URE
+ installation where binary executables are located (e.g.,
+ <i>$OFFICE_HOME/program</i> for an office installation, or
+ <i>$OO_SDK_URE_HOME/bin</i> for a Unix URE installation).</td>
+ </tr>
+ <tr valign="top">
+ <td class="cell20">OO_SDK_URE_LIB_DIR</td>
+ <td class="cell80">The path within the chosen office or URE
+ installation where dynamic libraries are located (e.g.,
+ <i>$OFFICE_HOME/program</i> for an office installation, or
+ <i>$OO_SDK_URE_HOME/lib</i> for a Unix URE installation).</td>
+ </tr>
+ <tr valign="top">
+ <td class="cell20">OO_SDK_URE_JAVA_DIR</td>
+ <td class="cell80">The path within the chosen office or URE
+ installation where Java JARs are located (e.g.,
+ <i>$OFFICE_HOME/program/classes</i> for an office installation, or
+ <i>$OO_SDK_URE_HOME/share/java</i> for a Unix URE installation).</td>
+ </tr>
+ <tr valign="top">
+ <td class="cell20">CLASSPATH</td>
+ <td class="cell80">
+ =<i>$OO_SDK_URE_JAVA_DIR/juh.jar;
+ $OO_SDK_URE_JAVA_DIR/jurt.jar;
+ $OO_SDK_URE_JAVA_DIR/ridl.jar;
+ $OO_SDK_URE_JAVA_DIR/unoloader.jar;
+ [$OO_SDK_URE_JAVA_DIR/unoil.jar;]
+ $CLASSPATH</i><br>
+ <p>The classpath will be set or extended to the necessary jar files of
+ the specified office installation. (<i>unoil.jar</i> is only included
+ when OFFICE_HOME is set.)</p>
+ </td>
+ </tr>
+ <tr valign="top">
+ <td class="cell20">OFFICE_PROGRAM_PATH</td>
+ <td class="cell80">=<i>$OFFICE_HOME/program</i><br>
+ <p>This variable is used to find, for example, the office type library and
+ the UNO package deployment tool. This variable is only relevant when
+ OFFICE_HOME is set.</p>
+ </td>
+ </tr>
+ <tr valign="top">
+ <td class="cell20">UNO_PATH</td>
+ <td class="cell80">=<i>$OFFICE_PROGRAM_PATH</i><br>
+ <p>This variable is used to ensure that the new C++ UNO bootstrap
+ mechanism uses the configured office installation of the SDK. Normally
+ the bootstrap mechanism finds the default office installation for the
+ user on the system. This variable is optional but is set from the scripts
+ to ensure a homogeneous environment. Especially useful during development
+ where you might have more than one office installation installed. This
+ variable is only relevant when OFFICE_HOME is set.</p>
+ </td>
+ </tr>
+ </table>
+ <p class="head3">Environment Variables for UNIX</p>
+ <p class="head4">Solaris</p>
+ <table class="table4">
+ <tr valign="top">
+ <td class="cell20">LD_LIBRARY_PATH</td>
+ <td class="cell80">=<i>$OO_SDK_URE_LIB_DIR: $OO_SDK_HOME/(solsparc|solintel)/lib: $LD_LIBRARY_PATH</i><br>
+ <p>The LD_LIBRARY_PATH will be set or will be extended by the office/URE
+ library path, the platform dependent lib directory for several additional
+ libraries.</p>
+ </td>
+ </tr>
+ <tr valign="top">
+ <td class="cell20">PATH</td>
+ <td class="cell80">=<i>$OO_SDK_HOME/(solsparc|solintel)/bin:$OO_SDK_MAKE_HOME: $OO_SDK_ZIP_HOME: [$OO_SDK_CPP_HOME:] [$OO_SDK_JAVA_HOME/bin:] $OO_SDK_URE_BIN_DIR: $PATH</i></b><br>
+ <p>The PATH variable will be extended by the paths for the SDK development
+ tools, the compiler, the JDK, GNU make, the zip tool and the
+ OO_SDK_URE_BIN_DIR, where the compiler or the JDK are
+ optional.</p>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" class="cell80">When OO_SDK_URE_HOME is set, the script
+ additionally creates symbolic links to the public dynamic libraries of
+ the URE in <i>$OO_SDK_HOME/(solsparc|solintel)/lib</i>, which are
+ needed for linking.</td>
+ </tr>
+ </table>
+ <p class="head4">Linux</p>
+ <table class="table4">
+ <tr valign="top">
+ <td class="cell20">LD_LIBRARY_PATH</td>
+ <td class="cell80">=<i>$OO_SDK_URE_LIB_DIR: $SDK_HOME/linux/lib: $LD_LIBRARY_PATH</i><br>
+ <p>The LD_LIBRARY_PATH will be set or will be extended by the office/URE
+ library path, the platform dependent lib directory for some additional
+ libraries.</p>
+ </td>
+ </tr>
+ <tr valign="top">
+ <td class="cell20">PATH</td>
+ <td class="cell80">=<i>$OO_SDK_HOME/linux/bin:$OO_SDK_MAKE_HOME: $OO_SDK_ZIP_HOME: [$OO_SDK_CPP_HOME:] [$OO_SDK_JAVA_HOME/bin:] $OO_SDK_URE_BIN_DIR: $PATH</i><br>
+ <p>The PATH variable will be extended by the paths for the SDK development
+ tools, the compiler, the JDK, GNU make, the zip tool and the
+ OO_SDK_URE_BIN_DIR, where the compiler and the JDK are
+ optional.</p>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" class="cell80">When OO_SDK_URE_HOME is set, the script
+ additionally creates symbolic links to the public dynamic libraries of
+ the URE in <i>$OO_SDK_HOME/linux/lib</i>, which are needed for
+ linking.</td>
+ </tr>
+ </table>
+ <p class="head3">Environment Variables for Windows</p>
+ <table class="table4">
+ <tr valign="top">
+ <td class="cell20">PATH</td>
+ <td class="cell80">=<i>%OO_SDK_HOME%\windows\bin; %OO_SDK_MAKE_HOME%; %OO_SDK_ZIP_HOME%; [%OO_SDK_CLI_HOME%;] [%OO_SDK_CPP_HOME%;] [%OO_SDK_JAVA_HOME%\bin;] %OO_SDK_URE_BIN_DIR%; %PATH%</i><br>
+ <p>The PATH variable will be extended by the paths for the SDK development
+ tools, the compiler, the JDK, GNU make, the zip tool and the
+ OO_SDK_URE_BIN_DIR.</p>
+ </td>
+ </tr>
+ <tr valign="top">
+ <td class="cell20">LIB</td>
+ <td class="cell80">=<i>%OO_SDK_HOME%\windows\lib; %LIB%</i><br>
+ <p>The LIB variable will be extended by the path to the import libraries
+ that are necessary for Windows.</p>
+ </td>
+ </tr>
+ <tr valign="top">
+ <td colspan="2" class="cell80">In addition to setting these environment
+ variables, the script calls the &quot;<i>vcvar32.bat</i>&quot; batch file
+ which is provided by the Microsoft Developer Studio to set the necessary
+ environment variables for the compiler.</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="nothing30" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <div class="centertext">
+ <p><img class="oraclelogo" src="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>
+</table>
+<map name="Map">
+ <area shape="rect" coords="10,68,93,105" href="http://www.oracle.com">
+</map>
+</body>
+</html>
diff --git a/odk/docs/notsupported.html b/odk/docs/notsupported.html
new file mode 100644
index 000000000000..02a497c59a3d
--- /dev/null
+++ b/odk/docs/notsupported.html
@@ -0,0 +1,4 @@
+<html><head> <title>OpenOffice.org %PRODUCT_RELEASE% SDK - Not supported page</title> <link rel="stylesheet" type="text/css" href="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"><table class="table1" cellpadding=0> <tr style="background-image:url(images/sdk_head-2.gif); backgorund-position: bottom; "> <td colspan="2" align="left"><img src="images/sdk_head-1.gif" width="335" height="109" usemap="#Map" border="0"></td> <td align=right><img src="images/sdk_head-3.gif" width="32" height="109"></td> </tr> <tr> <td colspan="3"><img class="nothing10" src="images/nada.gif"></td> </tr> <tr> <td colspan="3"> <table class="table2"> <tr> <td> <p align="center"><a href="../index.html" title="link to the SDK start page"><img class="navigate" src="images/nav_home.png"></a></p> </td> </tr> <tr> <td><img class="nothing8" src="images/nada.gif"></td> </tr> <tr> <td> <p class="note">This page is currently not supported!</p> </td> </tr> </table> </td> </tr> <tr> <td colspan="3"><img class="nothing30" src="images/nada.gif"></td> </tr> <tr> <td colspan="3"><img class="line" src="images/sdk_line-1.gif"></td> </tr> <tr> <td colspan="3"> <div class="centertext">
+ <p><img class="oraclelogo" src="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></table><map name="Map"> <area shape="rect" coords="10,68,93,105" href="http://www.sun.com"></map></body></html>
diff --git a/odk/docs/sdk_styles.css b/odk/docs/sdk_styles.css
new file mode 100644
index 000000000000..9a02576bc130
--- /dev/null
+++ b/odk/docs/sdk_styles.css
@@ -0,0 +1,130 @@
+a { text-decoration: none; }
+a:link { color: #0e85cd; }
+a:visited { color: #638093; }
+a:active { color: #4dadea; }
+
+.sdkbody { background-color: #FFFFFF;
+ color: #000000;
+ margin-top: 0;
+ margin-bottom: 0;
+ margin-left: 0;
+ margin-right: 0;
+ font-family: Arial, Helvetica, sans-serif; }
+
+.note { font-size: 20;
+ font-weight: bold;
+ font-style: italic;
+ text-align: center; }
+
+.table1 { width: 100%;
+ border-style: none;
+ border-spacing: 0;
+ padding: 0; }
+
+.table2 { width: 100%;
+ border-style: none;
+ border-spacing: 8;
+ padding: 5; }
+
+.table3 { width: 100%;
+ border-style: none;
+ border-spacing: 6;
+ padding: 0; }
+
+.table4 { width: 100%;
+ border-width: 2px;
+ border-style: groove;
+ border-color: #CCCCCC;
+ border-spacing: 0;
+ border-collapse: collapse; }
+
+.cell15 { width: 15%;
+ border-width: 2px;
+ border-style: groove;
+ border-color: #CCCCCC;
+ border-spacing: 0;
+ border-collapse: collapse;
+ padding: 4; }
+
+.cell20 { width: 20%;
+ border-width: 2px;
+ border-style: groove;
+ border-color: #CCCCCC;
+ border-spacing: 0;
+ border-collapse: collapse;
+ padding: 4; }
+
+.cell80 { width: 80%;
+ border-width: 2px;
+ border-style: groove;
+ border-color: #CCCCCC;
+ border-spacing: 0;
+ border-collapse: collapse;
+ padding: 4; }
+
+.cell85 { width: 85%;
+ border-width: 2px;
+ border-style: groove;
+ border-color: #CCCCCC;
+ border-spacing: 0;
+ border-collapse: collapse;
+ padding: 4; }
+
+.nothing1 { width: 20;
+ height: 1; }
+
+.nothing8 { width: 20;
+ height: 8; }
+
+.nothing10 { width: 20;
+ height: 10; }
+
+.nothing30 { width: 20;
+ height: 30; }
+
+
+.appicon { width: 32;
+ height: 32;
+ border: 0; }
+
+.line { width: 100%;
+ height: 5;
+ border: 0;
+ vertical-align: middle; }
+
+
+.arrow { width: 16;
+ height: 13; }
+
+.head1 { font-size: 20;
+ font-weight: bold; }
+
+.head2 { font-size: 18;
+ font-weight: bold; }
+
+.head3 { font-size: 17;
+ font-weight: bold; }
+
+.head4 { font-size: 16;
+ font-weight: bold; }
+
+.thead { font-weight: bold;
+ background-image:url(../docs/images/bg_table.png);
+ backgorund-position: middle; }
+
+.navigate { border: 0; }
+
+.content1 { width: 1%; }
+.content3 { width: 3%; }
+.content4 { width: 4%; }
+.content10 { width: 10%; }
+.content20 { width: 20%; }
+.content70 { width: 70%; }
+.content75 { width: 75%; }
+.content80 { width: 80%; }
+.content87 { width: 87%; }
+
+.centertext {align:center; text-align:center; font-size: 12;}
+.oraclelogo {vertical-align:middle;}
+
+
diff --git a/odk/docs/tools.html b/odk/docs/tools.html
new file mode 100644
index 000000000000..6ff9060f26f1
--- /dev/null
+++ b/odk/docs/tools.html
@@ -0,0 +1,1094 @@
+<html>
+<head>
+ <title>OpenOffice.org %PRODUCT_RELEASE% SDK - Development Tools</title>
+ <link rel="stylesheet" type="text/css" href="sdk_styles.css">
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <meta name="author" content="J&uuml;rgen Schmidt">
+</head>
+
+<body class="sdkbody"><a name="tools"/>
+<table class="table1" cellpadding=0>
+ <tr style="background-image:url(images/sdk_head-2.png)">
+ <td colspan="3" align="left"><img src="images/sdk_head-1.png" width="800" height="120" usemap="#Map" border="0"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="nothing10" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td colspan="3"><img class="nothing1" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table3">
+ <tr>
+ <td colspan="2" class="head1">Development Tools</td>
+ <td align="right"><a href="../index.html" title="link to the SDK start page"><img class="navigate" src="images/nav_home.png"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table3">
+ <tr valign="top">
+ <td class="content3"><img src="images/arrow-1.gif"></td>
+ <td><a href="#unopkg" title="link to the unopkg tool description">unopkg</a></td>
+ <td class="content87">The new UNO package deployment tool. It comes
+ with the office installation and can be found in the program
+ directory of the office installation.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="images/arrow-1.gif"></td>
+ <td><a href="#unoexe" title="link to the uno tool description">uno</a></td>
+ <td class="content87">Tool to provide a UNO runtime environment and
+ provide configured (deployed) or single components. This tool
+ comes with the office installation and can be found in the program
+ directory of the office installation.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="images/arrow-1.gif"></td>
+ <td><a href="#regmerge" title="link to the regmerge tool description">regmerge</a></td>
+ <td class="content87">Tool to merge several registry (e.g. type
+ libraries) files into one file. <b>Note:</b> Since OpenOffice.org 3 it is not longer part of the SDK but it comes directly with the office as part of the <b>ure</b>.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="images/arrow-1.gif"></td>
+ <td><a href="#regview" title="link to the regview tool description">regview</a></td>
+ <td class="content87">Tool to view the content of a registry file
+ in a human readable manner. Special support for type library
+ nodes. <b>Note:</b> Since OpenOffice.org 3 it is not longer part of the SDK but it comes directly with the office as part of the <b>ure</b>.</td>
+ </tr>
+ <tr valign="middle">
+ <td colspan="3"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="images/arrow-1.gif"></td>
+ <td><a href="#idlc" title="link to the idlc tool description">idlc</a></td>
+ <td class="content87">The UNOIDL compiler, generates a common
+ binary type library format as base for all codemaker tools and
+ the UNO runtime type library.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="images/arrow-1.gif"></td>
+ <td><a href="#cppumaker" title="link to the cppumaker tool description">cppumaker</a></td>
+ <td class="content87">Tool for generating C++ code for the UNOIDL
+ types stored in a type library.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="images/arrow-1.gif"></td>
+ <td><a href="#javamaker" title="link to the javamaker tool description">javamaker</a></td>
+ <td class="content87">Tool for generating Java class files for the
+ UNOIDL types stored in a type library.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="images/arrow-1.gif"></td>
+ <td><a href="#climaker" title="link to the climaker tool description">climaker</a></td>
+ <td class="content87">Tool for generating CLI assemblies for the
+ UNOIDL types stored in a type library (windows only).</td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="images/arrow-1.gif"></td>
+ <td><a href="#uno-skeletonmaker" title="link to the uno-skeletonmaker tool description">uno-skeletonmaker</a></td>
+ <td class="content87">Tool for dumping type definitions on stdout or generating complete code skeletons for Java/C++.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="images/arrow-1.gif"></td>
+ <td><a href="#regcomp" title="link to the regcomp tool description">regcomp</a></td>
+ <td class="content87">A simple UNO component registration tool.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="images/arrow-1.gif"></td>
+ <td><a href="#regmerge" title="link to the regmerge tool description">regmerge</a></td>
+ <td class="content87">Tool to merge several registry (e.g. type
+ libraries) files into one file.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="images/arrow-1.gif"></td>
+ <td><a href="#regview" title="link to the regview tool description">regview</a></td>
+ <td class="content87">Tool to view the content of a registry file
+ in a human readable manner. Special support for type library
+ nodes.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="images/arrow-1.gif"></td>
+ <td><a href="#autodoc" title="link to the autodoc tool description">autodoc</a></td>
+ <td class="content87">Tool to generate javadoc-like documentation
+ for C/C++ and UNOIDL files.</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td colspan="2" class="head1"><a name="unopkg"/>unopkg</td>
+ <td align="right">
+ <a style="a:link:visited #FFFFFF;" href="#tools" title="link to the tools overview"><img class="navigate" src="images/nav_up.png"></a>
+ <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="images/nav_home.png"></a></td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <p>'unopkg' is a tool for easy deployment of UNO packages in an existing
+ office installation. UNO packages are UNO components (single libraries or
+ Jar files or more complex zip files that contains one or more libraries|
+ Jar files, type libraries and configuration items), scripts and
+ OpenOffice.org %PRODUCT_RELEASE% Basic libraries as zip package. 'unopkg' is not part of the
+ SDK but comes with the office directly and is a development tool as well
+ as an end user tool to deploy extension into an office installation.</p>
+ <p>More details concerning deployment and this tool can be find in the
+ Developer's Guide: <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Extensions/unopkg" title="link to the &quot;Extension Manager - unopkg&quot; chapter in the Developer's Guide">Extension Manager - <i>unopkg</i></a>.</p>
+ <p><b>Note:</b> This tool works only in the <i>&lt;office&gt;/program</i>
+ directory!</p>
+ <p class="head2">Usage:</p>
+ <blockquote>
+ <b><code>
+ unopkg add &lt;options&gt; package-path...<br>
+ unopkg remove &lt;options&gt; package-name...<br>
+ unopkg list &lt;options&gt; package-name...<br>
+ unopkg reinstall &lt;options&gt;<br>
+ unopkg gui<br>
+ unopkg -V<br>
+ unopkg -h<br>
+ </code></b>
+ </blockquote>
+ <p class="head2">Sub-commands:</p>
+ <p>
+ <table class="table4">
+ <tr>
+ <td class="cell15"><code>add</code></td>
+ <td class="cell85">add packages</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>remove</code></td>
+ <td class="cell85">remove packages by name</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>reinstall</code></td>
+ <td class="cell85">export feature: reinstall all deployed
+ packages</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>list</code></td>
+ <td class="cell85">list information about deployed packages</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>gui</code></td>
+ <td class="cell15">raise Package Manager Graphical User Interface
+ (GUI)</td>
+ </tr>
+ </table>
+ </p>
+ <p class="head2">Options:</p>
+ <p>
+ <table class="table4">
+ <tr>
+ <td class="cell15"><code>-h, --help</code></td>
+ <td class="cell85">show this help on the command line</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-V, --version</code></td>
+ <td class="cell85">shows version information
+ </td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-v, --verbose</code></td>
+ <td class="cell85">dump verbose output to stdout</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-f, --force</code></td>
+ <td class="cell85">force overwriting existing packages</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>--log-file &lt;file&gt;</code></td>
+ <td class="cell85">custom log file; default:
+ <i>&lt;cache-dir&gt/log.txt</i>.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>--shared</code></td>
+ <td class="cell85">expert feature: operate on shared installation
+ deployment context; run only when no concurrent Office process(es) are
+ running!</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>--deployment-context &lt;context&gt</code>
+ </td>
+ <td class="cell85">expert feature: explicit deployment context</td>
+ </tr>
+ </table>
+ </p>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td colspan="2" class="head1"><a name="unoexe"/>uno</td>
+ <td align="right">
+ <a href="#tools" title="link to the tools overview"><img class="navigate" src="images/nav_up.png"></a>
+ <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="images/nav_home.png"></a>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <p>The UNO-starter is for running a component or service process, and
+ providing a runtime environment. Raising a component might look like
+ this </p>
+ <p><code>[c:\] uno.exe -c MyComponent -l mycomp.dll -r myregistry.rdb
+ -- foo bar</code></p>
+ <p>or</p>
+ <p><code>[c:\] uno.exe -s foo.bar.FooBarService -r myregistry.rdb
+ -- foo bar</code></p>
+ <p>The starter loads the component and instantiates it. The component
+ must export the interface <a href="common/ref/com/sun/star/lang/XMain.html" title="link into the IDL reference to the interface com.sun.star.lang.XMain">com.sun.star.lang.XMain</a>:</p>
+ <p>
+ <code>interface XMain : com::sun::star::uno::XInterface <br>
+ { <br>
+ &nbsp;&nbsp;&nbsp; /** This method is called to run the component.<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @param aArguments command line arguments <br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @return process error code to be returned to system <br>
+ &nbsp;&nbsp;&nbsp; */ <br>
+ &nbsp;&nbsp;&nbsp; long run( [in] sequence&lt; string &gt; arguments ); <br>
+ };
+ </code>
+ </p>
+ <p>Method run() will be called and returns the error code given, back
+ to the system. If the uno starter is executed with the -u (URL) option,
+ then XInitialization is used instead of XMain. The -u option is described
+ later.</p>
+ <p class="head2">Usage:</p>
+ <blockquote>
+ <b><code>uno (-c&lt;ComponentImplementationName&gt; -l &lt;LocationUrl&gt;
+ | -s &lt;ServiceName&gt;) <br>
+ [-ro &lt;ReadOnlyRegistry1&gt;] [-ro &lt;ReadOnlyRegistry2&gt;] ... [-rw &lt;ReadWriteRegistry&gt;]<br>
+ [-u uno:(socket[,host=&lt;HostName&gt;][,port=&lt;nnn&gt;]|pipe[,name=&lt;PipeName&gt;]);iiop|urp;&lt;Name&gt;<br>
+ [--singleaccept] [--singleinstance]] <br>
+ [-- &lt;Argument1 Argument2 ...&gt;]
+ </code></b>
+ </blockquote>
+ <p class="head2">Options:</p>
+ <p>
+ <table class="table4">
+ <tr>
+ <td class="cell15"><code>&lt;HostName&gt;</code></td>
+ <td class="cell85">Specifying a host name might be necessary to
+ distinguish the network interface to be used,if a machine is part of
+ two networks.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>&lt;PipeName&gt;</code></td>
+ <td class="cell85">Name of a named pipe.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>&lt;Name&gt;</code></td>
+ <td class="cell85">Identifier for demanded called component
+ instances.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>&lt;Registries&gt;</code></td>
+ <td class="cell85">The optional <code>&lt;Registries&gt;</code>
+ (e.g., c:\myreg.rdb) are used by the ServiceManager. The <i>ro</i>
+ ones are opened for reading only; whereas, a single <i>rw</i> one
+ will be opened for reading and writing. If the <i>rw</i> one does
+ not exist, then it may be created. Components may read and write to
+ store their persistent state.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>--singleaccept</code></td>
+ <td class="cell85">The uno starter will accept one connection,
+ provide the component instance and die.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>--singleinstance</code></td>
+ <td class="cell85">The uno starter will accept any number of
+ connections, but will provide the same single component instance any
+ time instead of creating a new instance for each connection.</td>
+ </tr>
+ </table>
+ <p><b>Service <a href="common/ref/com/sun/star/bridge/UnoUrlResolver.html" title="link into the IDL reference to the service com.sun.star.bridge.UnoUrlResolver">com.sun.star.bridge.UnoUrlResolver</a></b></p>
+ <p>You can easily connect to a server started with the
+ <code>-u (url)</code> option by using this service, giving the same url
+ to resolve. The service provides you an instance from remote.</p>
+ </p>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td colspan="2" class="head1"><a name="idlc"/>idlc</td>
+ <td align="right">
+ <a href="#tools" title="link to the tools overview"><img class="navigate" src="images/nav_up.png"></a>
+ <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="images/nav_home.png"></a>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <p>'idlc' is the UNOIDL compiler. It is a full featured compiler used
+ to check UNODL type definitions and transform valid type definitions
+ into a binary type library format, which is later used by all codemaker
+ tools. It is also used as a dynamic type library for UNO at runtime.<br>
+ You can find a syntax description for UNOIDL <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/AppendixD/UNOIDL_Syntax_Specification" title="link to the &quot;UNOIDL Syntax Specification&quot; chapter in the Developer's Guide">here</a>.</p>
+ <p class="head2">Usage:</p>
+ <blockquote>
+ <b><code>idlc [-options] file_1 ... file_n | @&lt;filename&gt;</code></b>
+ </blockquote>
+ <p>
+ <table class="table4">
+ <tr>
+ <td class="cell15"><code>file_1 ... file_n</code></td>
+ <td class="cell85">specifies one or more idl files. Only files with
+ the extension '.idl' are valid.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>@&lt;filename&gt;</code></td>
+ <td class="cell85">filename specifies the name of a command
+ file.</td>
+ </tr>
+ </table>
+ </p>
+ <p class="head2">Options:</p>
+ <p>
+ <table class="table4">
+ <tr>
+ <td class="cell15"><code>-O&lt;path&gt;</code></td>
+ <td class="cell85">path describes the output directory. The
+ generated output is a registry file with the same name as the idl
+ input file.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-I&lt;path&gt;</code></td>
+ <td class="cell85">path specifies a directory where included files
+ that will be searched by the preprocessor are located. Multiple
+ directories can be combined with ';'.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-D&lt;name&gt;</code></td>
+ <td class="cell85">name defines a macro for the preprocessor.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-C</code></td>
+ <td class="cell85">generates complete type information, including
+ additional service information and documentation.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-h|?</code></td>
+ <td class="cell85">print this help message and exit.</td>
+ </tr>
+ </table>
+ </p>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td colspan="2" class="head1"><a name="cppumaker"/>cppumaker</td>
+ <td align="right">
+ <a href="#tools" title="link to the tools overview"><img class="navigate" src="images/nav_up.png"></a>
+ <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="images/nav_home.png"></a>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <p>The 'cppumaker' generates a C++ representation for idl types. The
+ cppumaker works on a typelibrary, which is generated by the UNOIDL
+ compiler (<a href="#idlc" link="link to the idlc tool description">
+ idlc</a>). It generates the output for all specified types and for all
+ types the specified types depend on.</p>
+ <p class="head2">Usage:</p>
+ <blockquote>
+ <b><code>cppumaker [-options] file_1 ... file_n</code></b>
+ </blockquote>
+ <p class="head2">Options:</p>
+ <p>
+ <table class="table4">
+ <tr>
+ <td class="cell15"><code>-O&lt;path&gt;</code></td>
+ <td class="cell85">path describes the root directory for the
+ generated output. The output directory tree is generated under this
+ directory.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-T&lt;name&gt;<br>
+ |-T&lt;t1&gt;;&lt;t2&gt;...</code></td>
+ <td class="cell85">name specifies a type or a list of types. The
+ output for this type and all dependent types are generated. If no '-T'
+ option is specified, then output for all types is generated. It is also
+ possible to use a wildcard 'xy.*' to generate a complete module
+ inclusive all subdirectories. The use of '-T*' is equivalent to no '-T'
+ option. Example: 'com.sun.star.uno.XInterface' or
+ 'com.sun.star.uno.*' are valid types.
+ </td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-B&lt;name&gt;</code></td>
+ <td class="cell85">name specifies the base node. All types are
+ searched under this node. Default is the root '/' of the registry
+ files.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-L</code></td>
+ <td class="cell85">UNO type functions are generated lightweight, that
+ means only the name and typeclass are given and everything else is
+ retrieved from the type library dynamically. The default is that UNO
+ type functions provides enough type information for boostrapping C++.
+ '-L' should be the default for external components.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-C</code></td>
+ <td class="cell85">UNO type functions are generated comprehensive
+ that means all necessary information is available for bridging the
+ type in UNO.
+ </td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-G</code></td>
+ <td class="cell85">generate only target files which do not
+ exist.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-Gc</code></td>
+ <td class="cell85">generate only target files whose content will
+ be changed.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-X&lt;name&gt;</code></td>
+ <td class="cell85">extra types, which are not be taken into account
+ for generation.</td>
+ </tr>
+ </table>
+ </p>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td colspan="2" class="head1"><a name="javamaker"/>javamaker</td>
+ <td align="right">
+ <a href="#tools" title="link to the tools overview"><img class="navigate" src="images/nav_up.png"></a>
+ <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="images/nav_home.png"></a>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <p>The 'javamaker' generates the appropriate Java class file for each idl
+ type. The javamaker works on a typelibrary which is generated by the
+ UNOIDL compiler (<a href="#idlc" link="link to the idlc tool description">
+ idlc</a>). It generates the output for all specified types and for all
+types the specified types depend on.</p>
+ <p class="head2">Usage:</p>
+ <blockquote>
+ <b><code>javamaker [-options] file_1 ... file_n -Xfile_n+1 -Xfile_n+2</code></b>
+ </blockquote>
+ <p class="head2">Options:</p>
+ <p>
+ <table class="table4">
+ <tr>
+ <td class="cell15"><code>-O&lt;path&gt;</code></td>
+ <td class="cell85">path describes the root directory for the
+ generated output. The output directory tree is generated under this
+ directory.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-T&lt;name&gt;|-T&lt;t1&gt;;&lt;t2&gt;...</code></td>
+ <td class="cell85">name specifies a type or a list of types. The
+ output for this type and all dependent types are generated. If no '-T'
+ option is specified, then output for all types is generated. It is also
+ possible to use a wildcard 'xy.*' to generate a complete module
+ inclusive all subdirectories. The use of '-T*' is equivalent to no '-T'
+ option. Example: 'com.sun.star.uno.XInterface'
+ or 'com.sun.star.uno.*' are valid types.
+ </td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-B&lt;name&gt;</code></td>
+ <td class="cell85">name specifies the base node. All types are
+ searched under this node. Default is the root '/' of the registry
+ files.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-nD</code></td>
+ <td class="cell85">no dependent types are generated.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-G</code></td>
+ <td class="cell85">generate only target files which do not
+ exist.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-Gc</code></td>
+ <td class="cell85">generate only target files whose content will
+ be changed.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-X&lt;name&gt;</code></td>
+ <td class="cell85">extra types, which will not be taken into account
+ for generation.</td>
+ </tr>
+ </table>
+ </p>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td colspan="2" class="head1"><a name="climaker"/>climaker</td>
+ <td align="right">
+ <a href="#tools" title="link to the tools overview"><img class="navigate" src="images/nav_up.png"></a>
+ <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="images/nav_home.png"></a>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <p>The 'climaker' (windows only) generates the appropriate CLI assemblies file for each idl
+ type. The climaker works on a typelibrary which is generated by the
+ UNOIDL compiler (<a href="#idlc" link="link to the idlc tool description">
+ idlc</a>). It generates the output for all specified types and for all
+ types the specified types depend on.</p>
+ <p class="head2">Usage:</p>
+ <blockquote>
+ <b><code>climaker &lt;switches&gt; [registry-file-1 registry-file-2 ...]</code></b>
+ </blockquote>
+ <p class="head2">Options:</p>
+ <p>
+ <table class="table4">
+ <tr>
+ <td class="cell15"><code>-O, --out &lt;output_file&gt;</code></td>
+ <td class="cell85">output assembly file;<br>
+ defaults to cli_unotypes.dll if more than one registry-file is given, else &lt;registry-file&gt;.dll</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-T, --types &lt;type1[;type2;...]&gt;</code></td>
+ <td class="cell85">types to be generated (if none is given,
+ then all types of given registries are emitted</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-X, --extra &lt;rdb-file&gt;></code></td>
+ <td class="cell85">additional rdb to saturate referenced types in
+ given registry file(s); these types will not be
+ emitted into the output assembly file</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-r, --reference &lt;assembly-file&gt;</code></td>
+ <td class="cell85">reference metadata from assembly file</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-k, --keyfile</code></td>
+ <td class="cell85">keyfile needed for strong name</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>--assembly-version &lt;version&gt;</code></td>
+ <td class="cell85">sets assembly version</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>--assembly-description &lt;text&gt;</code></td>
+ <td class="cell85">sets assembly description text</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>--assembly-product &lt;text&gt;</code></td>
+ <td class="cell85">sets assembly product name</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>--assembly-company &lt;text&gt;</code></td>
+ <td class="cell85">sets assembly company</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>--assembly-copyright &lt;text&gt;</code></td>
+ <td class="cell85">sets assembly copyright</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>--assembly-trademark &lt;text&gt;</code></td>
+ <td class="cell85">sets assembly trademark</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-v, --verbose</code></td>
+ <td class="cell85">verbose output to stdout</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-h, --help</code></td>
+ <td class="cell85">this message</td>
+ </tr>
+
+ </table>
+ </p>
+ <p><b>Example:</b> <code>climaker --out cli_mytypes.dll --reference cli_uretypes.dll --extra types.rdb mytypes.rdb</code></p>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td colspan="2" class="head1"><a name="uno-skeletonmaker"/>uno-skeletonmaker</td>
+ <td align="right">
+ <a href="#tools" title="link to the tools overview"><img class="navigate" src="images/nav_up.png"></a>
+ <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="images/nav_home.png"></a>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <p>The 'uno-skeletonmaker' is a tool to simplify the UNO component development. It has different modes, from simply dumping code definitions for different languages on stdout up to generating complete code skeletons. The generation of code skeletons support common component skeletons as well as specialized skeletons for special service provider interfaces.</p>
+ <p class="head2">Usage:</p>
+ <blockquote>
+ <b><code>
+ uno-skeletonmaker (-env:INIFILENAME=&lt;url&gt; | -env:UNO_TYPES=&lt;url>) dump [&lt;options>] -t &lt;type&gt; ...<br>
+ uno-skeletonmaker (-env:INIFILENAME=&lt;url&gt; | -env:UNO_TYPES=&lt;url&gt;) component [&lt;options&gt;] -n &lt;name&gt; -t &lt;type&gt; ...<br>
+ uno-skeletonmaker (-env:INIFILENAME=&lt;url&gt; | -env:UNO_TYPES=&lt;url&gt;) calc-add-in [&lt;options&gt;] -n &lt;name&gt; -t &lt;add-in_service&gt;<br>
+ uno-skeletonmaker (-env:INIFILENAME=&lt;url&gt; | -env:UNO_TYPES=&lt;url&gt;) add-on [&lt;options&gt;] -n &lt;name&gt; -p &lt;protocol_name:command,...&gt;
+ uno-skeletonmaker -V, --version<br>
+ uno-skeletonmaker -h, --help<br>
+ </code></b>
+ </blockquote>
+ <p class="head2">Sub-commands:</p>
+ <p>
+ <table class="table4">
+ <tr>
+ <td class="cell15"><code>dump</code></td>
+ <td class="cell85">dump declarations on stdout (e.g. constructors, methods, type mapping for properties) or complete method bodies with method forwarding.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>component</code></td>
+ <td class="cell85">generates language specific code skeleton files using the implementation name as the file and class name</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>calc-add-in</code></td>
+ <td class="cell85">generates a language specific code skeleton for a Calc Add-Ins using the implementation name as the file and class name. A service type is necessary, referencing an interface which defines the new add-in functions.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>add-on</code></td>
+ <td class="cell85">generates a language specific code skeleton for an add-on compnent using the implementation name as the file and class name. The protocol name(s) and the corresponding command(s) have to be specified with the '-p' option.</td>
+ </tr>
+ </table>
+ </p>
+ <p class="head2">Options:</p>
+ <p>
+ <table class="table4">
+ <tr>
+ <td class="cell15"><code>-env:INIFILENAME=&lt;url&gt;</code></td>
+ <td class="cell85">url specifies a URL to an UNO ini|rc file of an existing UNO environment (URE, office installation).</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-env:UNO_TYPES=&lt;url&gt;</code></td>
+ <td class="cell85">url specifies a binary type library file. It can be a space separated list of urls.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-a, --all</code></td>
+ <td class="cell85">list all interface methods, not only the direct ones</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>--(java4|java5|cpp)</code></td>
+ <td class="cell85">select the target language<br>
+ --java4 generate output for Java 1.4 or earlier<br>
+ --java5 generate output for Java 1.5 or later (is currently the default)<br>
+ --cpp generate output for C++</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-sn, --shortnames</code></td>
+ <td class="cell85">using namespace abbreviation 'css:': for '::com::sun::star::', only valid for sub-command 'dump' and target language 'cpp'. It is default for the sub-command 'component'.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>--propertysetmixin</code></td>
+ <td class="cell85">the generated skeleton implements the cppu::PropertySetMixin helper if a referenced new style service specifies an interface which provides attributes (directly or inherited).</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-lh --licenseheader</code></td>
+ <td class="cell85">generates a default OpenOffice.org LGPL license header at the beginning of a component source file. This option is taken into account in 'component' mode only and if -o is unequal 'stdout'.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-bc<br>--backward-compatible</code></td>
+ <td class="cell85">specifies that the generated calc add-in is backward compatible to older office versions and implement the former required add-in interfaces where the implementation is mapped on the new add-in configuration. In this case the config schema needs to be bundled with the extension add-in as well. Default is a minimal add-in component skeleton based on the add-in configuration coming with the office since OO.org 2.0.4.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-o &lt;path&gt;</code></td>
+ <td class="cell85">path specifies an existing directory where the output files are generated to, only valid for sub-command 'component'. If path=stdout the generated code is generated on standard out instead of a file.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-l &lt;file&gt;</code></td>
+ <td class="cell85">specifies a binary type library (can be used more than once). The type library is integrated as an additional type provider in the bootstrapped type system.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-n &lt;name&gt;</code></td>
+ <td class="cell85">specifies an implementation name for the component (used as classname, filename and package|namespace name). In 'dump' mode it is used as classname (e.g. &quot;MyBase::&quot;, C++ only) to generate method bodies not inline.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-d &lt;name&gt;</code></td>
+ <td class="cell85">specifies a base classname or a delegator. In 'dump' mode it is used as a delegator to forward methods. It can be used as '&lt;name&gt;::' for base forwarding, or '&lt;name&gt;-&gt;|.' for composition. Using &quot;_&quot; means that a default bodies with default return values are dumped.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-t &lt;name&gt;</code></td>
+ <td class="cell85">specifies an UNOIDL type name, e.g. com.sun.star.text.XText (can be used more than once).</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-p &lt;protocol:cmd(s)&gt;</code></td>
+ <td class="cell85">specifies an add-on protocol name and the corresponding command names, where the commands are a ',' separated list of unique commands. This option is only valid for add-ons.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-V, --version</code></td>
+ <td class="cell85">print version number and exit.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-h, --help</code></td>
+ <td class="cell85">print this help and exit.</td>
+ </tr>
+ </table>
+ </p>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td colspan="2" class="head1"><a name="regcomp"/>regcomp</td>
+ <td align="right">
+ <a href="#tools" title="link to the tools overview"><img class="navigate" src="images/nav_up.png"></a>
+ <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="images/nav_home.png"></a>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <p>'regcomp' is a tool to register|revoke external UNO components
+ into|from a registry which is used in a UNO environment.</p>
+ <p class="head2">Usage:</p>
+ <blockquote>
+ <b><code>regcomp -revoke [-br&lt;registryfile&gt;] -r &lt;registryfile&gt; -c &lt;locationUrl&gt;[-l&lt;componentLoaderName&gt;]</code></b>
+ </blockquote>
+ <p class="head2">Options:</p>
+ <p>
+ <table class="table4">
+ <tr>
+ <td class="cell15"><code>-register|revoke</code></td>
+ <td class="cell85">register means that the components will be
+ installed and revoke means that they will be removed.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-br&lt;registryfile&gt;</code></td>
+ <td class="cell85">the name of the registry used for bootstrapping
+ the program. If the bootstrap registry is specified and has the same
+ name as the registration registry, '-r' is optional.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-r&lt;registryfile&gt;</code></td>
+ <td class="cell85">the name of the registry (will be created if
+ it does not exist) where the component should be registered.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-c&lt;locationUrls&gt;</code></td>
+ <td class="cell85">the location of a component (DLL, Class name,
+ or an url of a jar file) or a list of urls separated by ';'s. Note
+ that, if a list of urls is specified, the components must all need
+ the same loader.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-l&lt;componentLoaderName&gt;</code></td>
+ <td class="cell85">the name of the needed loader, if no loader is
+ specified the 'com.sun.star.loader.SharedLibrary' is used. Supported
+ loaders: 'com.sun.star.loader.SharedLibrary' |
+ 'com.sun.star.loader.Java'.</td>
+ </tr>
+ </table>
+ </p>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td colspan="2" class="head1"><a name="regmerge"/>regmerge</td>
+ <td align="right">
+ <a href="#tools" title="link to the tools overview"><img class="navigate" src="images/nav_up.png"></a>
+ <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="images/nav_home.png"></a>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <p>'regmerge' is a small tool to merge different registry files under a
+ specified key into another registry file. If a value already exists in
+ the target file the value is overwritten by the value of the source
+ file.</p>
+ <p class="head2">Usage:</p>
+ <blockquote>
+ <b><code>regmerge [-v|--verbose] &lt;mergefile&gt; &lt;mergeKeyName&gt; &lt;regfile_1&gt; ... &lt;regfile_n&gt;</code></b>
+ </blockquote>
+ <p class="head2">Options:</p>
+ <p>
+ <table class="table4">
+ <tr>
+ <td class="cell15"><code>-v|--verbose</code></td>
+ <td class="cell85">verbose output on stdout.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>&lt;mergefile&gt;</code></td>
+ <td class="cell85">specifies the merged registry file. If this file
+ doesn't exist, it is created.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>&lt;mergeKeyName&gt;</code></td>
+ <td class="cell85">specifies the merge key, everything is merged
+ under this key. If this key doesn't exist, it is created.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>&lt;regfile_1&gt; ... &lt;regfile_n&gt;</code></td>
+ <td class="cell85">specifies one or more registry files that are
+ merged.</td>
+ </tr>
+ </table>
+ </p>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td colspan="2" class="head1"><a name="regview"/>regview</td>
+ <td align="right">
+ <a href="#tools" title="link to the tools overview"><img class="navigate" src="images/nav_up.png"></a>
+ <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="images/nav_home.png"></a>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <p>'regview' is a tool to show the contents of a registry file. The tool
+ dumps the hierarchical structure and the values of the nodes in a human
+ readable manner to stdout.</p>
+ <p class="head2">Usage:</p>
+ <blockquote>
+ <b><code>regview &lt;registryfile&gt; [&lt;keyName&gt;]</code></b>
+ </blockquote>
+ <p class="head2">Options:</p>
+ <p>
+ <table class="table4">
+ <tr>
+ <td class="cell15">-br&lt;registryfile&gt;</code></td>
+ <td class="cell85">the name of the registry whose contents should
+ be viewed.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>&lt;keyName&gt;</code></td>
+ <td class="cell85">the name of a registry key. The name must be
+ fully qualified; for example, '/' means the root key and
+ '/UCR/com/sun/star/uno/XInterface' shows the type specification of the
+ XInterface type. If no key is specified, the tool dumps the whole
+ content of the registry file.</td>
+ </tr>
+ </table>
+ </p>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td colspan="2" class="head1"><a name="autodoc"/>autodoc</td>
+ <td align="right">
+ <a href="#tools" title="link to the tools overview"><img class="navigate" src="images/nav_up.png"></a>
+ <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="images/nav_home.png"></a>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <p>The 'autodoc' tool is used for creating javadoc-like documentation
+ from C++ and UNOIDL source code.</p>
+ <p>There are some conventions to follow when documenting C++- or
+ UNOIDL-sourcecode. See also the <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/AppendixB/IDL_Documentation_Guidelines" title="link to the UNOIDL Documentation Guidelines">UNOIDL Documentation Guidelines</a>.<br>
+ If you are not familiar with these, but do know javadoc: For simple C++
+ sourcecode documentation, using javadoc-style comments will work.</p>
+ <p class="head2">Usage:</p>
+ <blockquote>
+ <b><code>autodoc [ -v &lt;VerboseNr&gt; ] [ -name "&lt;TitleForTheDocu&gt;" ] -html &lt;OutputDirectory&gt; -lg &lt;SourcecodeLanguage&gt;<br>
+ { [ -p &lt;ProjectName&gt; &lt;ProjectRootDirectory&gt; ] &nbsp;-t &lt;SourceTree&gt;* | -d &lt;SourceDirectory&gt;* | -f &lt;SourceFile&gt;* }*</code></b>
+ </blockquote>
+ <p class="head2">Options:</p>
+ <p>
+ <table width="100%" border="1" cellpadding="4" cellspacing="0">
+ <tr>
+ <td class="cell15"><code>-v &lt;VerboseNr&gt;</code></td>
+ <td class="cell85">&lt;VerboseNr&gt; == 5 displays the parsed source
+ code tokens, so you can locate which piece caused an parsing error.<br>
+ &lt;VerboseNr&gt; == 2 displays not only the parsed source code,
+ but also the comments.<br><br>
+ This option must be the first one, if it is used.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-name "&lt;Title&gt;"</code></td>
+ <td class="cell85">&lt;Title&gt; occurs as the title of the start
+ page of the HTML output. If this option is omitted, a default title is
+ created.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-html &lt;OutputDirectory&gt;</code></td>
+ <td class="cell85">specifies the root directory where the HTML output
+ is created.<br>
+ Autodoc does not remove old files there, though it overwrites them.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-lg &lt;SourcecodeLanguage&gt;</code></td>
+ <td class="cell85">Possible values are: c++ | idl.<br><br>
+ This also specifies which files will be parsed: &quot;c++&quot; parses
+ all files with the endings .hxx and .h, &quot;idl&quot; parses all
+ files with the ending '.idl' .<br>
+ To change this behaviour, see at option <code>-f</code>.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-p &lt;ProjectName&gt; &lt;ProjectDirectory&gt;</code></td>
+ <td class="cell85">this option can be used to divide large code
+ bases into different projects.<br>
+ &lt;ProjectName&gt; gives a user-defined name for the project.<br>
+ &lt;ProjectDirectory&gt; is the root to which all paths, given with the
+ following options <code>-t,-d</code> and <code>-f</code>, are
+ relative.<br>
+ This option can be omitted when there are no projects and all paths in
+ the following options are relative to the working directory.<br><br>
+ The &quot;{ ... }*&quot; around the options <code>-p,-t,-d,-f</code>
+ indicates, that this whole block of options can be repeated, each block
+ starting with a new <code>-p</code>.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-t &lt;SourceTree&gt;</code></td>
+ <td class="cell85">specifies that all files in the directory
+ &lt;SourceTree&gt; and it's subdirectories are parsed, where the file
+ ending matches the option <code>-lg</code>.<br>
+ There can be given multiple directories after one <code>-t</code>
+ option.<br>
+ All relative paths &nbsp;are relative to the project-rootdirectory,
+ given with the <code>-p</code> option.<br>
+ </td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-d &lt;SourceDirectory&gt;</code></td>
+ <td class="cell85">Specifies that all files in th directory
+ &lt;SourceDirectory&gt;, but NOT it's subdirectories, are parsed, where
+ the file ending matches the option <code>-lg</code>.<br>
+ There can be multiple directories given after one <code>-d</code>
+ option.<br>
+ All relative paths &nbsp;are relative to the project-rootdirectory,
+ given with the <code>-p</code> option.</td>
+ </tr>
+ <tr>
+ <td class="cell15"><code>-f &lt;SourceFile&gt;</code></td>
+ <td class="cell85">parses the given file. The ending does not have
+ to match the <code>-lg</code> option.<br>
+ There can be multiple files given after one <code>-f</code> option.<br>
+ All relative paths &nbsp;are relative to the project-rootdirectory,
+ given with the <code>-p</code> option.</td>
+ </tr>
+ </table>
+ </p><b>Remark:</b> The sequence of options matters! Use them in the order given
+ in the &quot;Usage&quot;-paragraph.</p>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <div class="centertext">
+ <p><img class="oraclelogo" src="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>
+</table>
+<map name="Map">
+ <area shape="rect" coords="10,68,93,105" href="http://www.oracle.com">
+</map>
+</body>
+</html>
diff --git a/odk/examples/CLI/CSharp/Spreadsheet/GeneralTableSample.cs b/odk/examples/CLI/CSharp/Spreadsheet/GeneralTableSample.cs
new file mode 100644
index 000000000000..ced0edf935d3
--- /dev/null
+++ b/odk/examples/CLI/CSharp/Spreadsheet/GeneralTableSample.cs
@@ -0,0 +1,206 @@
+
+using System;
+
+
+// __________ implementation ____________________________________
+
+/** Create a spreadsheet document and provide access to table contents.
+ */
+public class GeneralTableSample : SpreadsheetDocHelper
+{
+
+ public static void Main( String [] args )
+ {
+ try
+ {
+ using ( GeneralTableSample aSample =
+ new GeneralTableSample( args ) )
+ {
+ aSample.doSampleFunction();
+ }
+ Console.WriteLine( "Sample done." );
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine( "Sample caught exception! " + ex );
+ }
+ }
+
+// ________________________________________________________________
+
+ public GeneralTableSample( String[] args ) : base( args )
+ {
+ }
+
+// ________________________________________________________________
+
+ /// This sample function modifies cells and cell ranges.
+ public void doSampleFunction()
+ {
+ // for common usage
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet = getSpreadsheet( 0 );
+ unoidl.com.sun.star.beans.XPropertySet xPropSet = null;
+ unoidl.com.sun.star.table.XCell xCell = null;
+ unoidl.com.sun.star.table.XCellRange xCellRange = null;
+
+ // *** Access and modify a VALUE CELL ***
+ Console.WriteLine( "*** 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.
+ bool 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 );
+ unoidl.com.sun.star.text.XText xCellText =
+ (unoidl.com.sun.star.text.XText) xCell;
+ unoidl.com.sun.star.text.XTextCursor xTextCursor =
+ xCellText.createTextCursor();
+ xCellText.insertString( xTextCursor, aText, false );
+
+ // *** Change cell properties ***
+ int nValue = bValid ? 0x00FF00 : 0xFF4040;
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCell;
+ xPropSet.setPropertyValue(
+ "CellBackColor", new uno.Any( (Int32) nValue ) );
+
+
+ // *** Accessing a CELL RANGE ***
+ Console.WriteLine( "*** 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 = (unoidl.com.sun.star.beans.XPropertySet) xCellRange;
+ xPropSet.setPropertyValue(
+ "CellBackColor", new uno.Any( (Int32) 0x8080FF ) );
+
+ // Accessing a cell range over its name.
+ xCellRange = xSheet.getCellRangeByName( "C4:D5" );
+
+ // Change properties of the range.
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCellRange;
+ xPropSet.setPropertyValue(
+ "CellBackColor", new uno.Any( (Int32) 0xFFFF80 ) );
+
+
+ // *** Using the CELL CURSOR to add some data below of
+ // the filled area ***
+ Console.WriteLine( "*** Sample for service table.CellCursor ***" );
+
+ // Create a cursor using the XSpreadsheet method createCursorByRange()
+ xCellRange = xSheet.getCellRangeByName( "A1" );
+ unoidl.com.sun.star.sheet.XSheetCellRange xSheetCellRange =
+ (unoidl.com.sun.star.sheet.XSheetCellRange) xCellRange;
+
+ unoidl.com.sun.star.sheet.XSheetCellCursor xSheetCellCursor =
+ xSheet.createCursorByRange( xSheetCellRange );
+ unoidl.com.sun.star.table.XCellCursor xCursor =
+ (unoidl.com.sun.star.table.XCellCursor) 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 ***
+ Console.WriteLine( "*** Sample for services table.TableRows and " +
+ "table.TableColumns ***" );
+
+ unoidl.com.sun.star.table.XColumnRowRange xCRRange =
+ (unoidl.com.sun.star.table.XColumnRowRange) xSheet;
+ unoidl.com.sun.star.table.XTableColumns xColumns =
+ xCRRange.getColumns();
+ unoidl.com.sun.star.table.XTableRows xRows = xCRRange.getRows();
+
+ // Get column C by index (interface XIndexAccess).
+ uno.Any aColumnObj = xColumns.getByIndex( 2 );
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) aColumnObj.Value;
+ xPropSet.setPropertyValue( "Width", new uno.Any( (Int32) 5000 ) );
+
+ // Get the name of the column.
+ unoidl.com.sun.star.container.XNamed xNamed =
+ (unoidl.com.sun.star.container.XNamed) aColumnObj.Value;
+ aText = "The name of this column is " + xNamed.getName() + ".";
+ xSheet.getCellByPosition( 2, 2 ).setFormula( aText );
+
+ // Get column D by name (interface XNameAccess).
+ unoidl.com.sun.star.container.XNameAccess xColumnsName =
+ (unoidl.com.sun.star.container.XNameAccess) xColumns;
+
+ aColumnObj = xColumnsName.getByName( "D" );
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) aColumnObj.Value;
+ xPropSet.setPropertyValue(
+ "IsVisible", new uno.Any( (Boolean) false ) );
+
+ // Get row 7 by index (interface XIndexAccess)
+ uno.Any aRowObj = xRows.getByIndex( 6 );
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) aRowObj.Value;
+ xPropSet.setPropertyValue( "Height", new uno.Any( (Int32) 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 ***
+ Console.WriteLine( "*** Sample for service table.TableCharts ***" );
+
+ unoidl.com.sun.star.table.XTableChartsSupplier xChartsSupp =
+ (unoidl.com.sun.star.table.XTableChartsSupplier) xSheet;
+ unoidl.com.sun.star.table.XTableCharts xCharts =
+ xChartsSupp.getCharts();
+
+ // The chart will base on the last cell series, initializing all values.
+ String aName = "newChart";
+ unoidl.com.sun.star.awt.Rectangle aRect =
+ new unoidl.com.sun.star.awt.Rectangle();
+ aRect.X = 10000;
+ aRect.Y = 3000;
+ aRect.Width = aRect.Height = 5000;
+ unoidl.com.sun.star.table.CellRangeAddress[] aRanges =
+ new unoidl.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.
+ uno.Any aChartObj = xCharts.getByName( aName );
+ unoidl.com.sun.star.table.XTableChart xChart =
+ (unoidl.com.sun.star.table.XTableChart) aChartObj.Value;
+
+ // 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 );
+ }
+
+}
diff --git a/odk/examples/CLI/CSharp/Spreadsheet/Makefile b/odk/examples/CLI/CSharp/Spreadsheet/Makefile
new file mode 100644
index 000000000000..cbe43167905d
--- /dev/null
+++ b/odk/examples/CLI/CSharp/Spreadsheet/Makefile
@@ -0,0 +1,79 @@
+# Builds the SpreadSheet examples of the Developers Guide.
+
+PRJ = ../../../..
+SETTINGS = $(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.mk
+
+CSC_FLAGS = -warnaserror+ -noconfig
+VBC_FLAGS = -warnaserror+
+ifeq "$(DEBUG)" "yes"
+CC_FLAGS+=-Zi -MT
+CSC_FLAGS += -debug+ -checked+ -define:DEBUG -define:TRACE
+VBC_FLAGS += -debug+ -define:DEBUG=1 -define:TRACE=1
+else
+CSC_FLAGS += -o
+VBC_FLAGS += -o
+endif
+
+THIS_OUT_MISC = $(OUT_MISC)/csharp_SpreadsheetExamples
+
+SPREADSHEET_OUT:= $(OUT_BIN)/CSharp_SpreadsheetExamples
+CLI_LIB_LOCATION = $(PRJ)\cli
+
+# Targets
+.PHONY : ALL
+ALL : SpreadsheetSample \
+ GeneralTableSample \
+ ViewSample \
+ Info
+
+include $(SETTINGS)/stdtarget.mk
+
+
+# build executables
+#csc -lib:"d:\StarOffice 8" does not work. csc does not understand the quotes.
+#but they are needed if the path contains a space. Therefore we use full path
+#with the -reference switch
+$(SPREADSHEET_OUT)/%.exe : %.cs SpreadsheetDocHelper.cs
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ csc $(CSC_FLAGS) \
+ -target:exe \
+ -out:$@ \
+ -reference:"$(CLI_LIB_LOCATION)"\cli_basetypes.dll \
+ -reference:"$(CLI_LIB_LOCATION)"\cli_uretypes.dll \
+ -reference:"$(CLI_LIB_LOCATION)"\cli_oootypes.dll \
+ -reference:"$(CLI_LIB_LOCATION)"\cli_ure.dll \
+ -reference:"$(CLI_LIB_LOCATION)"\cli_cppuhelper.dll \
+ $^
+
+SpreadsheetSample : $(SPREADSHEET_OUT)/SpreadsheetSample.exe
+
+GeneralTableSample : $(SPREADSHEET_OUT)/GeneralTableSample.exe
+
+ViewSample : $(SPREADSHEET_OUT)/ViewSample.exe
+
+.PHONY : Info
+Info :
+ @echo -------------------------------------------------------------------------------
+ @echo Please use one of the following commands to execute the examples!
+ @echo -
+ @echo $(MAKE) GeneralTableSample.run
+ @echo $(MAKE) SpreadsheetSample.run
+ @echo $(MAKE) ViewSample.run
+ @echo -------------------------------------------------------------------------------
+
+
+%.run : $(SPREADSHEET_OUT)/%.exe
+ @echo -------------------------------------------------------------------------------
+ @echo Executing sample $@ $(UNORC) $(CONNECT_STRING)...
+ @echo -------------------------------------------------------------------------------
+ cd $(subst /,\\,$(SPREADSHEET_OUT)) && $(basename $@).exe
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_BIN)/CSharp_SpreadsheetExamples)
+
+
diff --git a/odk/examples/CLI/CSharp/Spreadsheet/SpreadsheetDocHelper.cs b/odk/examples/CLI/CSharp/Spreadsheet/SpreadsheetDocHelper.cs
new file mode 100644
index 000000000000..e2f49d08b3fe
--- /dev/null
+++ b/odk/examples/CLI/CSharp/Spreadsheet/SpreadsheetDocHelper.cs
@@ -0,0 +1,344 @@
+
+using System;
+using unoidl.com.sun.star.lang;
+using unoidl.com.sun.star.uno;
+using unoidl.com.sun.star.bridge;
+using unoidl.com.sun.star.frame;
+
+// __________ 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 : System.IDisposable
+{
+
+// __ private members ___________________________________________
+
+ private const String msDataSheetName = "Data";
+
+ private unoidl.com.sun.star.uno.XComponentContext m_xContext;
+ private unoidl.com.sun.star.lang.XMultiServiceFactory mxMSFactory;
+ private unoidl.com.sun.star.sheet.XSpreadsheetDocument mxDocument;
+
+// ________________________________________________________________
+
+ public SpreadsheetDocHelper( String[] args )
+ {
+ // Connect to a running office and get the service manager
+ mxMSFactory = connect( args );
+ // Create a new spreadsheet document
+ mxDocument = initDocument();
+ }
+
+// __ helper methods ____________________________________________
+
+ /** Returns the service manager.
+ @return XMultiServiceFactory interface of the service manager. */
+ public unoidl.com.sun.star.lang.XMultiServiceFactory getServiceManager()
+ {
+ return mxMSFactory;
+ }
+
+ /** Returns the whole spreadsheet document.
+ @return XSpreadsheetDocument interface of the document. */
+ public unoidl.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 unoidl.com.sun.star.sheet.XSpreadsheet getSpreadsheet( int nIndex )
+ {
+ // Collection of sheets
+ unoidl.com.sun.star.sheet.XSpreadsheets xSheets =
+ mxDocument.getSheets();
+
+ unoidl.com.sun.star.container.XIndexAccess xSheetsIA =
+ (unoidl.com.sun.star.container.XIndexAccess) xSheets;
+
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet =
+ (unoidl.com.sun.star.sheet.XSpreadsheet)
+ xSheetsIA.getByIndex( nIndex ).Value;
+
+ 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 unoidl.com.sun.star.sheet.XSpreadsheet insertSpreadsheet(
+ String aName, short nIndex )
+ {
+ // Collection of sheets
+ unoidl.com.sun.star.sheet.XSpreadsheets xSheets =
+ mxDocument.getSheets();
+
+ xSheets.insertNewByName( aName, nIndex );
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet =
+ (unoidl.com.sun.star.sheet.XSpreadsheet)
+ xSheets.getByName( aName ).Value;
+
+ 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(
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet,
+ String aCellName,
+ double fValue )
+ {
+ 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(
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet,
+ String aCellName,
+ String aFormula )
+ {
+ 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(
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet,
+ String aCellName,
+ int nDay, int nMonth, int nYear )
+ {
+ // Set the date value.
+ unoidl.com.sun.star.table.XCell xCell =
+ xSheet.getCellRangeByName( aCellName ).getCellByPosition( 0, 0 );
+ String aDateStr = nMonth + "/" + nDay + "/" + nYear;
+ xCell.setFormula( aDateStr );
+
+ // Set standard date format.
+ unoidl.com.sun.star.util.XNumberFormatsSupplier xFormatsSupplier =
+ (unoidl.com.sun.star.util.XNumberFormatsSupplier) getDocument();
+ unoidl.com.sun.star.util.XNumberFormatTypes xFormatTypes =
+ (unoidl.com.sun.star.util.XNumberFormatTypes)
+ xFormatsSupplier.getNumberFormats();
+ int nFormat = xFormatTypes.getStandardFormat(
+ unoidl.com.sun.star.util.NumberFormat.DATE,
+ new unoidl.com.sun.star.lang.Locale() );
+
+ unoidl.com.sun.star.beans.XPropertySet xPropSet =
+ (unoidl.com.sun.star.beans.XPropertySet) xCell;
+ xPropSet.setPropertyValue(
+ "NumberFormat",
+ new uno.Any( (Int32) 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(
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet,
+ String aRange, String aHeadline )
+ {
+ unoidl.com.sun.star.beans.XPropertySet xPropSet = null;
+ unoidl.com.sun.star.table.XCellRange xCellRange = null;
+
+ // draw border
+ xCellRange = xSheet.getCellRangeByName( aRange );
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCellRange;
+ unoidl.com.sun.star.table.BorderLine aLine =
+ new unoidl.com.sun.star.table.BorderLine();
+ aLine.Color = 0x99CCFF;
+ aLine.InnerLineWidth = aLine.LineDistance = 0;
+ aLine.OuterLineWidth = 100;
+ unoidl.com.sun.star.table.TableBorder aBorder =
+ new unoidl.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",
+ new uno.Any(
+ typeof (unoidl.com.sun.star.table.TableBorder), aBorder ) );
+
+ // draw headline
+ unoidl.com.sun.star.sheet.XCellRangeAddressable xAddr =
+ (unoidl.com.sun.star.sheet.XCellRangeAddressable) xCellRange;
+ unoidl.com.sun.star.table.CellRangeAddress aAddr =
+ xAddr.getRangeAddress();
+
+ xCellRange = xSheet.getCellRangeByPosition(
+ aAddr.StartColumn,
+ aAddr.StartRow, aAddr.EndColumn, aAddr.StartRow );
+
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCellRange;
+ xPropSet.setPropertyValue(
+ "CellBackColor", new uno.Any( (Int32) 0x99CCFF ) );
+ // write headline
+ unoidl.com.sun.star.table.XCell xCell =
+ xCellRange.getCellByPosition( 0, 0 );
+ xCell.setFormula( aHeadline );
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCell;
+ xPropSet.setPropertyValue(
+ "CharColor", new uno.Any( (Int32) 0x003399 ) );
+ xPropSet.setPropertyValue(
+ "CharWeight",
+ new uno.Any( (Single) unoidl.com.sun.star.awt.FontWeight.BOLD ) );
+ }
+
+// ________________________________________________________________
+// Methods to create cell addresses and range addresses.
+
+ /** Creates a unoidl.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 unoidl.com.sun.star.table.CellAddress createCellAddress(
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet,
+ String aCell )
+ {
+ unoidl.com.sun.star.sheet.XCellAddressable xAddr =
+ (unoidl.com.sun.star.sheet.XCellAddressable)
+ xSheet.getCellRangeByName( aCell ).getCellByPosition( 0, 0 );
+ return xAddr.getCellAddress();
+ }
+
+ /** Creates a unoidl.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 unoidl.com.sun.star.table.CellRangeAddress createCellRangeAddress(
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet, String aRange )
+ {
+ unoidl.com.sun.star.sheet.XCellRangeAddressable xAddr =
+ (unoidl.com.sun.star.sheet.XCellRangeAddressable)
+ 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(
+ unoidl.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(
+ unoidl.com.sun.star.sheet.XSheetCellRange xCellRange, bool bWithSheet )
+ {
+ String aStr = "";
+ if (bWithSheet)
+ {
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet =
+ xCellRange.getSpreadsheet();
+ unoidl.com.sun.star.container.XNamed xNamed =
+ (unoidl.com.sun.star.container.XNamed) xSheet;
+ aStr += xNamed.getName() + ".";
+ }
+ unoidl.com.sun.star.sheet.XCellRangeAddressable xAddr =
+ (unoidl.com.sun.star.sheet.XCellRangeAddressable) 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(
+ unoidl.com.sun.star.container.XIndexAccess xRangesIA )
+ {
+ String aStr = "";
+ int nCount = xRangesIA.getCount();
+ for (int nIndex = 0; nIndex < nCount; ++nIndex)
+ {
+ if (nIndex > 0)
+ aStr += " ";
+ uno.Any aRangeObj = xRangesIA.getByIndex( nIndex );
+ unoidl.com.sun.star.sheet.XSheetCellRange xCellRange =
+ (unoidl.com.sun.star.sheet.XSheetCellRange) aRangeObj.Value;
+ aStr += getCellRangeAddressString( xCellRange, false );
+ }
+ return aStr;
+ }
+
+// ________________________________________________________________
+
+ /** Connect to a running office that is accepting connections.
+ @return The ServiceManager to instantiate office components. */
+ private XMultiServiceFactory connect( String [] args )
+ {
+
+ m_xContext = uno.util.Bootstrap.bootstrap();
+
+ return (XMultiServiceFactory) m_xContext.getServiceManager();
+ }
+
+ public void Dispose()
+ {
+
+ }
+
+ /** Creates an empty spreadsheet document.
+ @return The XSpreadsheetDocument interface of the document. */
+ private unoidl.com.sun.star.sheet.XSpreadsheetDocument initDocument()
+ {
+ XComponentLoader aLoader = (XComponentLoader)
+ mxMSFactory.createInstance( "com.sun.star.frame.Desktop" );
+
+ XComponent xComponent = aLoader.loadComponentFromURL(
+ "private:factory/scalc", "_blank", 0,
+ new unoidl.com.sun.star.beans.PropertyValue[0] );
+
+ return (unoidl.com.sun.star.sheet.XSpreadsheetDocument) xComponent;
+ }
+
+// ________________________________________________________________
+}
diff --git a/odk/examples/CLI/CSharp/Spreadsheet/SpreadsheetSample.cs b/odk/examples/CLI/CSharp/Spreadsheet/SpreadsheetSample.cs
new file mode 100644
index 000000000000..9b78a289fb21
--- /dev/null
+++ b/odk/examples/CLI/CSharp/Spreadsheet/SpreadsheetSample.cs
@@ -0,0 +1,1478 @@
+
+using System;
+
+// __________ implementation ____________________________________
+
+/** Create and modify a spreadsheet document.
+ */
+public class SpreadsheetSample : SpreadsheetDocHelper
+{
+
+ public static void Main( String [] args )
+ {
+ try
+ {
+ using ( SpreadsheetSample aSample = new SpreadsheetSample( args ) )
+ {
+ aSample.doSampleFunctions();
+ }
+ Console.WriteLine( "\nSamples done." );
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine( "Sample caught exception! " + ex );
+ }
+ }
+
+ public SpreadsheetSample( String[] args )
+ : base( args )
+ {
+ }
+
+ /** This sample function performs all changes on the document. */
+ public void doSampleFunctions()
+ {
+ doCellSamples();
+ doCellRangeSamples();
+ doCellRangesSamples();
+ doCellCursorSamples();
+ doFormattingSamples();
+ doDocumentSamples();
+ doDatabaseSamples();
+ doDataPilotSamples();
+ doNamedRangesSamples();
+ doFunctionAccessSamples();
+ doApplicationSettingsSamples();
+ }
+
+// ________________________________________________________________
+
+ /** All samples regarding the service com.sun.star.sheet.SheetCell. */
+ private void doCellSamples()
+ {
+ Console.WriteLine( "\n*** Samples for service sheet.SheetCell ***\n" );
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet = getSpreadsheet( 0 );
+ unoidl.com.sun.star.table.XCell xCell = null;
+ unoidl.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. ---
+ unoidl.com.sun.star.text.XText xText =
+ (unoidl.com.sun.star.text.XText) xCell;
+ unoidl.com.sun.star.text.XTextCursor xTextCursor =
+ xText.createTextCursor();
+
+ xText.insertString( xTextCursor, "Text in first line.", false );
+ xText.insertControlCharacter( xTextCursor,
+ unoidl.com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false );
+ xText.insertString( xTextCursor, "And a ", false );
+
+ // create a hyperlink
+ unoidl.com.sun.star.lang.XMultiServiceFactory xServiceMan =
+ (unoidl.com.sun.star.lang.XMultiServiceFactory) getDocument();
+ Object aHyperlinkObj =
+ xServiceMan.createInstance( "com.sun.star.text.TextField.URL" );
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) aHyperlinkObj;
+ xPropSet.setPropertyValue(
+ "URL", new uno.Any( "http://www.example.org" ) );
+ xPropSet.setPropertyValue(
+ "Representation", new uno.Any( "hyperlink" ) );
+ // ... and insert
+ unoidl.com.sun.star.text.XTextContent xContent =
+ (unoidl.com.sun.star.text.XTextContent) aHyperlinkObj;
+ xText.insertTextContent( xTextCursor, xContent, false );
+
+ // --- Query the separate paragraphs. ---
+ unoidl.com.sun.star.container.XEnumerationAccess xParaEA =
+ (unoidl.com.sun.star.container.XEnumerationAccess) xCell;
+ unoidl.com.sun.star.container.XEnumeration xParaEnum =
+ xParaEA.createEnumeration();
+ // Go through the paragraphs
+ while( xParaEnum.hasMoreElements() )
+ {
+ uno.Any aPortionObj = xParaEnum.nextElement();
+ unoidl.com.sun.star.container.XEnumerationAccess xPortionEA =
+ (unoidl.com.sun.star.container.XEnumerationAccess)
+ aPortionObj.Value;
+ unoidl.com.sun.star.container.XEnumeration xPortionEnum =
+ xPortionEA.createEnumeration();
+ aText = "";
+ // Go through all text portions of a paragraph and construct string.
+ while( xPortionEnum.hasMoreElements() )
+ {
+ unoidl.com.sun.star.text.XTextRange xRange =
+ (unoidl.com.sun.star.text.XTextRange)
+ xPortionEnum.nextElement().Value;
+ aText += xRange.getString();
+ }
+ Console.WriteLine( "Paragraph text: " + aText );
+ }
+
+
+ // --- Change cell properties. ---
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCell;
+ // from styles.CharacterProperties
+ xPropSet.setPropertyValue(
+ "CharColor", new uno.Any( (Int32) 0x003399 ) );
+ xPropSet.setPropertyValue(
+ "CharHeight", new uno.Any( (Single) 20.0 ) );
+ // from styles.ParagraphProperties
+ xPropSet.setPropertyValue(
+ "ParaLeftMargin", new uno.Any( (Int32) 500 ) );
+ // from table.CellProperties
+ xPropSet.setPropertyValue(
+ "IsCellBackgroundTransparent", new uno.Any( false ) );
+ xPropSet.setPropertyValue(
+ "CellBackColor", new uno.Any( (Int32) 0x99CCFF ) );
+
+
+ // --- Get cell address. ---
+ unoidl.com.sun.star.sheet.XCellAddressable xCellAddr =
+ (unoidl.com.sun.star.sheet.XCellAddressable) xCell;
+ unoidl.com.sun.star.table.CellAddress aAddress =
+ xCellAddr.getCellAddress();
+ aText = "Address of this cell: Column=" + aAddress.Column;
+ aText += "; Row=" + aAddress.Row;
+ aText += "; Sheet=" + aAddress.Sheet;
+ Console.WriteLine( aText );
+
+
+ // --- Insert an annotation ---
+ unoidl.com.sun.star.sheet.XSheetAnnotationsSupplier xAnnotationsSupp =
+ (unoidl.com.sun.star.sheet.XSheetAnnotationsSupplier) xSheet;
+ unoidl.com.sun.star.sheet.XSheetAnnotations xAnnotations =
+ xAnnotationsSupp.getAnnotations();
+ xAnnotations.insertNew( aAddress, "This is an annotation" );
+
+ unoidl.com.sun.star.sheet.XSheetAnnotationAnchor xAnnotAnchor =
+ (unoidl.com.sun.star.sheet.XSheetAnnotationAnchor) xCell;
+ unoidl.com.sun.star.sheet.XSheetAnnotation xAnnotation =
+ xAnnotAnchor.getAnnotation();
+ xAnnotation.setIsVisible( true );
+ }
+
+// ________________________________________________________________
+
+ /** All samples regarding the service com.sun.star.sheet.SheetCellRange. */
+ private void doCellRangeSamples()
+ {
+ Console.WriteLine(
+ "\n*** Samples for service sheet.SheetCellRange ***\n" );
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet = getSpreadsheet( 0 );
+ unoidl.com.sun.star.table.XCellRange xCellRange = null;
+ unoidl.com.sun.star.beans.XPropertySet xPropSet = null;
+ unoidl.com.sun.star.table.CellRangeAddress aRangeAddress = null;
+
+ // Preparation
+ setFormula( xSheet, "B5", "First cell" );
+ setFormula( xSheet, "B6", "Second cell" );
+ // Get cell range B5:B6 by position - (column, row, column, row)
+ xCellRange = xSheet.getCellRangeByPosition( 1, 4, 1, 5 );
+
+
+ // --- Change cell range properties. ---
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCellRange;
+ // from com.sun.star.styles.CharacterProperties
+ xPropSet.setPropertyValue(
+ "CharColor", new uno.Any( (Int32) 0x003399 ) );
+ xPropSet.setPropertyValue(
+ "CharHeight", new uno.Any( (Single) 20.0 ) );
+ // from com.sun.star.styles.ParagraphProperties
+ xPropSet.setPropertyValue(
+ "ParaLeftMargin", new uno.Any( (Int32) 500 ) );
+ // from com.sun.star.table.CellProperties
+ xPropSet.setPropertyValue(
+ "IsCellBackgroundTransparent", new uno.Any( false ) );
+ xPropSet.setPropertyValue(
+ "CellBackColor", new uno.Any( (Int32) 0x99CCFF ) );
+
+
+ // --- Replace text in all cells. ---
+ unoidl.com.sun.star.util.XReplaceable xReplace =
+ (unoidl.com.sun.star.util.XReplaceable) xCellRange;
+ unoidl.com.sun.star.util.XReplaceDescriptor xReplaceDesc =
+ xReplace.createReplaceDescriptor();
+ xReplaceDesc.setSearchString( "cell" );
+ xReplaceDesc.setReplaceString( "text" );
+ // property SearchWords searches for whole cells!
+ xReplaceDesc.setPropertyValue( "SearchWords", new uno.Any( false ) );
+ int nCount = xReplace.replaceAll( xReplaceDesc );
+ Console.WriteLine( "Search text replaced " + nCount + " times." );
+
+
+ // --- Merge cells. ---
+ xCellRange = xSheet.getCellRangeByName( "F3:G6" );
+ prepareRange( xSheet, "E1:H7", "XMergeable" );
+ unoidl.com.sun.star.util.XMergeable xMerge =
+ (unoidl.com.sun.star.util.XMergeable) 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" );
+ unoidl.com.sun.star.util.XIndent xIndent =
+ (unoidl.com.sun.star.util.XIndent) xCellRange;
+ xIndent.incrementIndent();
+
+ xCellRange = xSheet.getCellRangeByName( "I22:I23" );
+ xIndent = (unoidl.com.sun.star.util.XIndent) xCellRange;
+ xIndent.incrementIndent();
+*/
+
+
+ // --- Column properties. ---
+ xCellRange = xSheet.getCellRangeByName( "B1" );
+ unoidl.com.sun.star.table.XColumnRowRange xColRowRange =
+ (unoidl.com.sun.star.table.XColumnRowRange) xCellRange;
+ unoidl.com.sun.star.table.XTableColumns xColumns =
+ xColRowRange.getColumns();
+
+ uno.Any aColumnObj = xColumns.getByIndex( 0 );
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) aColumnObj.Value;
+ xPropSet.setPropertyValue( "Width", new uno.Any( (Int32) 6000 ) );
+
+ unoidl.com.sun.star.container.XNamed xNamed =
+ (unoidl.com.sun.star.container.XNamed) aColumnObj.Value;
+ Console.WriteLine(
+ "The name of the wide column is " + xNamed.getName() + "." );
+
+
+ // --- Cell range data ---
+ prepareRange( xSheet, "A9:C30", "XCellRangeData" );
+
+ xCellRange = xSheet.getCellRangeByName( "A10:C30" );
+ unoidl.com.sun.star.sheet.XCellRangeData xData =
+ (unoidl.com.sun.star.sheet.XCellRangeData) xCellRange;
+ uno.Any [][] aValues =
+ {
+ new uno.Any [] { new uno.Any( "Name" ),
+ new uno.Any( "Fruit" ),
+ new uno.Any( "Quantity" ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 3.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 7.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 3.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 9.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 5.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 6.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 3.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 8.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 1.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 2.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 7.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 1.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 8.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 8.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 7.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 1.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 9.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 3.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 4.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 9.0 ) }
+ };
+ xData.setDataArray( aValues );
+
+
+ // --- Get cell range address. ---
+ unoidl.com.sun.star.sheet.XCellRangeAddressable xRangeAddr =
+ (unoidl.com.sun.star.sheet.XCellRangeAddressable) xCellRange;
+ aRangeAddress = xRangeAddr.getRangeAddress();
+ Console.WriteLine(
+ "Address of this range: Sheet=" + aRangeAddress.Sheet );
+ Console.WriteLine(
+ "Start column=" + aRangeAddress.StartColumn + "; Start row=" +
+ aRangeAddress.StartRow );
+ Console.WriteLine(
+ "End column =" + aRangeAddress.EndColumn + "; End row =" +
+ aRangeAddress.EndRow );
+
+
+ // --- Sheet operation. ---
+ // uses the range filled with XCellRangeData
+ unoidl.com.sun.star.sheet.XSheetOperation xSheetOp =
+ (unoidl.com.sun.star.sheet.XSheetOperation) xData;
+ double fResult = xSheetOp.computeFunction(
+ unoidl.com.sun.star.sheet.GeneralFunction.AVERAGE );
+ Console.WriteLine(
+ "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 );
+
+ unoidl.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(
+ unoidl.com.sun.star.sheet.FillDirection.TO_RIGHT,
+ unoidl.com.sun.star.sheet.FillMode.LINEAR,
+ unoidl.com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 9 );
+ // Add months to a date
+ xSeries = getCellSeries( xSheet, "E12:I12" );
+ xSeries.fillSeries(
+ unoidl.com.sun.star.sheet.FillDirection.TO_RIGHT,
+ unoidl.com.sun.star.sheet.FillMode.DATE,
+ unoidl.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(
+ unoidl.com.sun.star.sheet.FillDirection.TO_LEFT,
+ unoidl.com.sun.star.sheet.FillMode.LINEAR,
+ unoidl.com.sun.star.sheet.FillDateMode.FILL_DATE_DAY,
+ 10, 0x7FFFFFFF );
+ // Fill with an user defined list
+ xSeries = getCellSeries( xSheet, "E14:I14" );
+ xSeries.fillSeries(
+ unoidl.com.sun.star.sheet.FillDirection.TO_RIGHT,
+ unoidl.com.sun.star.sheet.FillMode.AUTO,
+ unoidl.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(
+ unoidl.com.sun.star.sheet.FillDirection.TO_TOP,
+ unoidl.com.sun.star.sheet.FillMode.GROWTH,
+ unoidl.com.sun.star.sheet.FillDateMode.FILL_DATE_DAY,
+ 2, 0x7FFFFFFF );
+ // Auto fill
+ xSeries = getCellSeries( xSheet, "E16:K18" );
+ xSeries.fillAuto(
+ unoidl.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" );
+ unoidl.com.sun.star.sheet.XArrayFormulaRange xArrayFormula =
+ (unoidl.com.sun.star.sheet.XArrayFormulaRange) xCellRange;
+ // Insert a 3x3 unit matrix.
+ xArrayFormula.setArrayFormula( "=A10:C12" );
+ Console.WriteLine(
+ "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(
+ unoidl.com.sun.star.sheet.FillDirection.TO_BOTTOM, 1 );
+ getCellSeries( xSheet, "F26:J26" ).fillAuto(
+ unoidl.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(
+ unoidl.com.sun.star.sheet.FillDirection.TO_BOTTOM, 2 );
+ prepareRange( xSheet, "E25:J38", "XMultipleOperation" );
+
+ unoidl.com.sun.star.table.CellRangeAddress aFormulaRange =
+ createCellRangeAddress( xSheet, "E26" );
+ unoidl.com.sun.star.table.CellAddress aColCell =
+ createCellAddress( xSheet, "E27" );
+ unoidl.com.sun.star.table.CellAddress aRowCell =
+ createCellAddress( xSheet, "F26" );
+
+ xCellRange = xSheet.getCellRangeByName( "E26:J31" );
+ unoidl.com.sun.star.sheet.XMultipleOperation xMultOp =
+ (unoidl.com.sun.star.sheet.XMultipleOperation) xCellRange;
+ xMultOp.setTableOperation(
+ aFormulaRange, unoidl.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 = (unoidl.com.sun.star.sheet.XMultipleOperation) xCellRange;
+ xMultOp.setTableOperation(
+ aFormulaRange, unoidl.com.sun.star.sheet.TableOperationMode.COLUMN,
+ aColCell, aRowCell );
+
+
+ // --- Cell Ranges Query ---
+ xCellRange = xSheet.getCellRangeByName( "A10:C30" );
+ unoidl.com.sun.star.sheet.XCellRangesQuery xRangesQuery =
+ (unoidl.com.sun.star.sheet.XCellRangesQuery) xCellRange;
+ unoidl.com.sun.star.sheet.XSheetCellRanges xCellRanges =
+ xRangesQuery.queryContentCells(
+ (short) unoidl.com.sun.star.sheet.CellFlags.STRING );
+ Console.WriteLine(
+ "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 unoidl.com.sun.star.sheet.XCellSeries getCellSeries(
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet, String aRange )
+ {
+ return (unoidl.com.sun.star.sheet.XCellSeries)
+ xSheet.getCellRangeByName( aRange );
+ }
+
+// ________________________________________________________________
+
+ /** All samples regarding cell range collections. */
+ private void doCellRangesSamples()
+ {
+ Console.WriteLine( "\n*** Samples for cell range collections ***\n" );
+
+ // Create a new cell range container
+ unoidl.com.sun.star.lang.XMultiServiceFactory xDocFactory =
+ (unoidl.com.sun.star.lang.XMultiServiceFactory) getDocument();
+ unoidl.com.sun.star.sheet.XSheetCellRangeContainer xRangeCont =
+ (unoidl.com.sun.star.sheet.XSheetCellRangeContainer)
+ 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 ---
+ Console.WriteLine( "All filled cells: " );
+ unoidl.com.sun.star.container.XEnumerationAccess xCellsEA =
+ xRangeCont.getCells();
+ unoidl.com.sun.star.container.XEnumeration xEnum =
+ xCellsEA.createEnumeration();
+ while( xEnum.hasMoreElements() )
+ {
+ uno.Any aCellObj = xEnum.nextElement();
+ unoidl.com.sun.star.sheet.XCellAddressable xAddr =
+ (unoidl.com.sun.star.sheet.XCellAddressable) aCellObj.Value;
+ unoidl.com.sun.star.table.CellAddress aAddr =
+ xAddr.getCellAddress();
+ Console.WriteLine(
+ getCellAddressString( aAddr.Column, aAddr.Row ) + " " );
+ }
+ Console.WriteLine();
+ }
+
+ /** Inserts a cell range address into a cell range container and prints
+ a message.
+ @param xContainer unoidl.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(
+ unoidl.com.sun.star.sheet.XSheetCellRangeContainer xContainer,
+ int nSheet, int nStartCol, int nStartRow, int nEndCol, int nEndRow,
+ bool bMerge )
+ {
+ unoidl.com.sun.star.table.CellRangeAddress aAddress =
+ new unoidl.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 );
+ Console.WriteLine(
+ "Inserting " + getCellRangeAddressString( aAddress )
+ + " " + (bMerge ? " with" : "without") + " merge,"
+ + " resulting list: " + xContainer.getRangeAddressesAsString() );
+ }
+
+// ________________________________________________________________
+
+ /** All samples regarding cell cursors. */
+ private void doCellCursorSamples()
+ {
+ Console.WriteLine( "\n*** Samples for cell cursor ***\n" );
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet = getSpreadsheet( 0 );
+
+
+ // --- Find the array formula using a cell cursor ---
+ unoidl.com.sun.star.table.XCellRange xRange =
+ xSheet.getCellRangeByName( "F22" );
+ unoidl.com.sun.star.sheet.XSheetCellRange xCellRange =
+ (unoidl.com.sun.star.sheet.XSheetCellRange) xRange;
+ unoidl.com.sun.star.sheet.XSheetCellCursor xCursor =
+ xSheet.createCursorByRange( xCellRange );
+
+ xCursor.collapseToCurrentArray();
+ unoidl.com.sun.star.sheet.XArrayFormulaRange xArray =
+ (unoidl.com.sun.star.sheet.XArrayFormulaRange) xCursor;
+ Console.WriteLine(
+ "Array formula in " + getCellRangeAddressString( xCursor, false )
+ + " contains formula " + xArray.getArrayFormula() );
+
+
+ // --- Find the used area ---
+ unoidl.com.sun.star.sheet.XUsedAreaCursor xUsedCursor =
+ (unoidl.com.sun.star.sheet.XUsedAreaCursor) xCursor;
+ xUsedCursor.gotoStartOfUsedArea( false );
+ xUsedCursor.gotoEndOfUsedArea( true );
+ // xUsedCursor and xCursor are interfaces of the same object -
+ // so modifying xUsedCursor takes effect on xCursor:
+ Console.WriteLine(
+ "The used area is: " + getCellRangeAddressString( xCursor, true ) );
+ }
+
+// ________________________________________________________________
+
+ /** All samples regarding the formatting of cells and ranges. */
+ private void doFormattingSamples()
+ {
+ Console.WriteLine( "\n*** Formatting samples ***\n" );
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet = getSpreadsheet( 1 );
+ unoidl.com.sun.star.table.XCellRange xCellRange;
+ unoidl.com.sun.star.beans.XPropertySet xPropSet = null;
+ unoidl.com.sun.star.container.XIndexAccess xRangeIA = null;
+ unoidl.com.sun.star.lang.XMultiServiceFactory xServiceManager;
+
+
+ // --- Cell styles ---
+ // get the cell style container
+ unoidl.com.sun.star.style.XStyleFamiliesSupplier xFamiliesSupplier =
+ (unoidl.com.sun.star.style.XStyleFamiliesSupplier) getDocument();
+ unoidl.com.sun.star.container.XNameAccess xFamiliesNA =
+ xFamiliesSupplier.getStyleFamilies();
+ uno.Any aCellStylesObj = xFamiliesNA.getByName( "CellStyles" );
+ unoidl.com.sun.star.container.XNameContainer xCellStylesNA =
+ (unoidl.com.sun.star.container.XNameContainer) aCellStylesObj.Value;
+
+ // create a new cell style
+ xServiceManager =
+ (unoidl.com.sun.star.lang.XMultiServiceFactory) getDocument();
+ Object aCellStyle = xServiceManager.createInstance(
+ "com.sun.star.style.CellStyle" );
+ String aStyleName = "MyNewCellStyle";
+ xCellStylesNA.insertByName(
+ aStyleName, new uno.Any( typeof (Object), aCellStyle ) );
+
+ // modify properties of the new style
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) aCellStyle;
+ xPropSet.setPropertyValue(
+ "CellBackColor", new uno.Any( (Int32) 0x888888 ) );
+ xPropSet.setPropertyValue(
+ "IsCellBackgroundTransparent", new uno.Any( false ) );
+
+
+
+ // --- Query equal-formatted cell ranges ---
+ // prepare example, use the new cell style
+ xCellRange = xSheet.getCellRangeByName( "D2:F2" );
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCellRange;
+ xPropSet.setPropertyValue( "CellStyle", new uno.Any( aStyleName ) );
+
+ xCellRange = xSheet.getCellRangeByName( "A3:G3" );
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCellRange;
+ xPropSet.setPropertyValue( "CellStyle", new uno.Any( aStyleName ) );
+
+ // All ranges in one container
+ xCellRange = xSheet.getCellRangeByName( "A1:G3" );
+ Console.WriteLine( "Service CellFormatRanges:" );
+ unoidl.com.sun.star.sheet.XCellFormatRangesSupplier xFormatSupp =
+ (unoidl.com.sun.star.sheet.XCellFormatRangesSupplier) xCellRange;
+ xRangeIA = xFormatSupp.getCellFormatRanges();
+ Console.WriteLine( getCellRangeListString( xRangeIA ) );
+
+ // Ranges sorted in SheetCellRanges containers
+ Console.WriteLine( "\nService UniqueCellFormatRanges:" );
+ unoidl.com.sun.star.sheet.XUniqueCellFormatRangesSupplier
+ xUniqueFormatSupp =
+ (unoidl.com.sun.star.sheet.XUniqueCellFormatRangesSupplier)
+ xCellRange;
+ unoidl.com.sun.star.container.XIndexAccess xRangesIA =
+ xUniqueFormatSupp.getUniqueCellFormatRanges();
+ int nCount = xRangesIA.getCount();
+ for (int nIndex = 0; nIndex < nCount; ++nIndex)
+ {
+ uno.Any aRangesObj = xRangesIA.getByIndex( nIndex );
+ xRangeIA =
+ (unoidl.com.sun.star.container.XIndexAccess) aRangesObj.Value;
+ Console.WriteLine(
+ "Container " + (nIndex + 1) + ": " +
+ getCellRangeListString( xRangeIA ) );
+ }
+
+
+ // --- Table auto formats ---
+ // get the global collection of table auto formats,
+ // use global service manager
+ xServiceManager = getServiceManager();
+ Object aAutoFormatsObj = xServiceManager.createInstance(
+ "com.sun.star.sheet.TableAutoFormats" );
+ unoidl.com.sun.star.container.XNameContainer xAutoFormatsNA =
+ (unoidl.com.sun.star.container.XNameContainer) aAutoFormatsObj;
+
+ // create a new table auto format and insert into the container
+ String aAutoFormatName = "Temp_Example";
+ bool bExistsAlready = xAutoFormatsNA.hasByName( aAutoFormatName );
+ uno.Any aAutoFormatObj;
+ if (bExistsAlready)
+ // auto format already exists -> use it
+ aAutoFormatObj = xAutoFormatsNA.getByName( aAutoFormatName );
+ else
+ {
+ // create a new auto format (with document service manager!)
+ xServiceManager =
+ (unoidl.com.sun.star.lang.XMultiServiceFactory) getDocument();
+ aAutoFormatObj = new uno.Any(
+ typeof (Object),
+ xServiceManager.createInstance(
+ "com.sun.star.sheet.TableAutoFormat" ) );
+ xAutoFormatsNA.insertByName( aAutoFormatName, aAutoFormatObj );
+ }
+ // index access to the auto format fields
+ unoidl.com.sun.star.container.XIndexAccess xAutoFormatIA =
+ (unoidl.com.sun.star.container.XIndexAccess) aAutoFormatObj.Value;
+
+ // 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
+ uno.Any aFieldObj = xAutoFormatIA.getByIndex(
+ 4 * nRow + nColumn );
+ xPropSet =
+ (unoidl.com.sun.star.beans.XPropertySet) aFieldObj.Value;
+ xPropSet.setPropertyValue(
+ "CellBackColor", new uno.Any( (Int32) nColor ) );
+ }
+ }
+
+ // set the auto format to the spreadsheet
+ xCellRange = xSheet.getCellRangeByName( "A5:H25" );
+ unoidl.com.sun.star.table.XAutoFormattable xAutoForm =
+ (unoidl.com.sun.star.table.XAutoFormattable) 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 = (unoidl.com.sun.star.beans.XPropertySet) xCellRange;
+ unoidl.com.sun.star.sheet.XSheetConditionalEntries xEntries =
+ (unoidl.com.sun.star.sheet.XSheetConditionalEntries)
+ xPropSet.getPropertyValue( "ConditionalFormat" ).Value;
+
+ // create a condition and apply it to the range
+ unoidl.com.sun.star.beans.PropertyValue[] aCondition =
+ new unoidl.com.sun.star.beans.PropertyValue[3];
+ aCondition[0] = new unoidl.com.sun.star.beans.PropertyValue();
+ aCondition[0].Name = "Operator";
+ aCondition[0].Value =
+ new uno.Any(
+ typeof (unoidl.com.sun.star.sheet.ConditionOperator),
+ unoidl.com.sun.star.sheet.ConditionOperator.GREATER );
+ aCondition[1] = new unoidl.com.sun.star.beans.PropertyValue();
+ aCondition[1].Name = "Formula1";
+ aCondition[1].Value = new uno.Any( "1" );
+ aCondition[2] = new unoidl.com.sun.star.beans.PropertyValue();
+ aCondition[2].Name = "StyleName";
+ aCondition[2].Value = new uno.Any( aStyleName );
+ xEntries.addNew( aCondition );
+ xPropSet.setPropertyValue(
+ "ConditionalFormat",
+ new uno.Any(
+ typeof (unoidl.com.sun.star.sheet.XSheetConditionalEntries),
+ xEntries ) );
+ }
+
+// ________________________________________________________________
+
+ /** All samples regarding the spreadsheet document. */
+ private void doDocumentSamples()
+ {
+ Console.WriteLine( "\n*** Samples for spreadsheet document ***\n" );
+
+
+ // --- Insert a new spreadsheet ---
+ unoidl.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)" );
+
+ unoidl.com.sun.star.sheet.XCellRangeMovement xMovement =
+ (unoidl.com.sun.star.sheet.XCellRangeMovement) xSheet;
+ unoidl.com.sun.star.table.CellRangeAddress aSourceRange =
+ createCellRangeAddress( xSheet, "A2:B3" );
+ unoidl.com.sun.star.table.CellAddress aDestCell =
+ createCellAddress( xSheet, "D2" );
+ xMovement.copyRange( aDestCell, aSourceRange );
+
+
+ // --- Print automatic column page breaks ---
+ unoidl.com.sun.star.sheet.XSheetPageBreak xPageBreak =
+ (unoidl.com.sun.star.sheet.XSheetPageBreak) xSheet;
+ unoidl.com.sun.star.sheet.TablePageBreakData[] aPageBreakArray =
+ xPageBreak.getColumnPageBreaks();
+
+ Console.Write( "Automatic column page breaks:" );
+ for (int nIndex = 0; nIndex < aPageBreakArray.Length; ++nIndex)
+ if (!aPageBreakArray[nIndex].ManualBreak)
+ Console.Write( " " + aPageBreakArray[nIndex].Position );
+ Console.WriteLine();
+
+
+ // --- Document properties ---
+ unoidl.com.sun.star.beans.XPropertySet xPropSet =
+ (unoidl.com.sun.star.beans.XPropertySet) getDocument();
+
+ String aText = "Value of property IsIterationEnabled: ";
+ aText +=
+ (Boolean) xPropSet.getPropertyValue( "IsIterationEnabled" ).Value;
+ Console.WriteLine( aText );
+ aText = "Value of property IterationCount: ";
+ aText += (Int32) xPropSet.getPropertyValue( "IterationCount" ).Value;
+ Console.WriteLine( aText );
+ aText = "Value of property NullDate: ";
+ unoidl.com.sun.star.util.Date aDate = (unoidl.com.sun.star.util.Date)
+ xPropSet.getPropertyValue( "NullDate" ).Value;
+ aText += aDate.Year + "-" + aDate.Month + "-" + aDate.Day;
+ Console.WriteLine( aText );
+
+
+ // --- Data validation ---
+ prepareRange( xSheet, "A5:C7", "Validation" );
+ setFormula( xSheet, "A6", "Insert values between 0.0 and 5.0 below:" );
+
+ unoidl.com.sun.star.table.XCellRange xCellRange =
+ xSheet.getCellRangeByName( "A7:C7" );
+ unoidl.com.sun.star.beans.XPropertySet xCellPropSet =
+ (unoidl.com.sun.star.beans.XPropertySet) xCellRange;
+ // validation properties
+ unoidl.com.sun.star.beans.XPropertySet xValidPropSet =
+ (unoidl.com.sun.star.beans.XPropertySet)
+ xCellPropSet.getPropertyValue( "Validation" ).Value;
+ xValidPropSet.setPropertyValue(
+ "Type",
+ new uno.Any(
+ typeof (unoidl.com.sun.star.sheet.ValidationType),
+ unoidl.com.sun.star.sheet.ValidationType.DECIMAL ) );
+ xValidPropSet.setPropertyValue(
+ "ShowErrorMessage", new uno.Any( true ) );
+ xValidPropSet.setPropertyValue(
+ "ErrorMessage", new uno.Any( "This is an invalid value!" ) );
+ xValidPropSet.setPropertyValue(
+ "ErrorAlertStyle",
+ new uno.Any(
+ typeof (unoidl.com.sun.star.sheet.ValidationAlertStyle),
+ unoidl.com.sun.star.sheet.ValidationAlertStyle.STOP ) );
+ // condition
+ unoidl.com.sun.star.sheet.XSheetCondition xCondition =
+ (unoidl.com.sun.star.sheet.XSheetCondition) xValidPropSet;
+ xCondition.setOperator(
+ unoidl.com.sun.star.sheet.ConditionOperator.BETWEEN );
+ xCondition.setFormula1( "0.0" );
+ xCondition.setFormula2( "5.0" );
+ // apply on cell range
+ xCellPropSet.setPropertyValue(
+ "Validation",
+ new uno.Any(
+ typeof (unoidl.com.sun.star.beans.XPropertySet),
+ xValidPropSet ) );
+
+
+ // --- Scenarios ---
+ uno.Any [][] aValues = {
+ new uno.Any [] { uno.Any.VOID, uno.Any.VOID },
+ new uno.Any [] { uno.Any.VOID, uno.Any.VOID }
+ };
+
+ aValues[ 0 ][ 0 ] = new uno.Any( (Double) 11 );
+ aValues[ 0 ][ 1 ] = new uno.Any( (Double) 12 );
+ aValues[ 1 ][ 0 ] = new uno.Any( "Test13" );
+ aValues[ 1 ][ 1 ] = new uno.Any( "Test14" );
+ insertScenario(
+ xSheet, "B10:C11", aValues,
+ "First Scenario", "The first scenario." );
+
+ aValues[ 0 ][ 0 ] = new uno.Any( "Test21" );
+ aValues[ 0 ][ 1 ] = new uno.Any( "Test22" );
+ aValues[ 1 ][ 0 ] = new uno.Any( (Double) 23 );
+ aValues[ 1 ][ 1 ] = new uno.Any( (Double) 24 );
+ insertScenario(
+ xSheet, "B10:C11", aValues,
+ "Second Scenario", "The visible scenario." );
+
+ aValues[ 0 ][ 0 ] = new uno.Any( (Double) 31 );
+ aValues[ 0 ][ 1 ] = new uno.Any( (Double) 32 );
+ aValues[ 1 ][ 0 ] = new uno.Any( "Test33" );
+ aValues[ 1 ][ 1 ] = new uno.Any( "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(
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet,
+ String aRange,
+ uno.Any [][] aValueArray,
+ String aScenarioName,
+ String aScenarioComment )
+ {
+ // get the cell range with the given address
+ unoidl.com.sun.star.table.XCellRange xCellRange =
+ xSheet.getCellRangeByName( aRange );
+
+ // create the range address sequence
+ unoidl.com.sun.star.sheet.XCellRangeAddressable xAddr =
+ (unoidl.com.sun.star.sheet.XCellRangeAddressable) xCellRange;
+ unoidl.com.sun.star.table.CellRangeAddress[] aRangesSeq =
+ new unoidl.com.sun.star.table.CellRangeAddress[1];
+ aRangesSeq[0] = xAddr.getRangeAddress();
+
+ // create the scenario
+ unoidl.com.sun.star.sheet.XScenariosSupplier xScenSupp =
+ (unoidl.com.sun.star.sheet.XScenariosSupplier) xSheet;
+ unoidl.com.sun.star.sheet.XScenarios xScenarios =
+ xScenSupp.getScenarios();
+ xScenarios.addNewByName( aScenarioName, aRangesSeq, aScenarioComment );
+
+ // insert the values into the range
+ unoidl.com.sun.star.sheet.XCellRangeData xData =
+ (unoidl.com.sun.star.sheet.XCellRangeData) 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(
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet,
+ String aScenarioName )
+ {
+ // get the scenario set
+ unoidl.com.sun.star.sheet.XScenariosSupplier xScenSupp =
+ (unoidl.com.sun.star.sheet.XScenariosSupplier) xSheet;
+ unoidl.com.sun.star.sheet.XScenarios xScenarios =
+ xScenSupp.getScenarios();
+
+ // get the scenario and activate it
+ uno.Any aScenarioObj = xScenarios.getByName( aScenarioName );
+ unoidl.com.sun.star.sheet.XScenario xScenario =
+ (unoidl.com.sun.star.sheet.XScenario) aScenarioObj.Value;
+ xScenario.apply();
+ }
+
+// ________________________________________________________________
+
+ private void doNamedRangesSamples()
+ {
+ Console.WriteLine( "\n*** Samples for named ranges ***\n" );
+ unoidl.com.sun.star.sheet.XSpreadsheetDocument xDocument =
+ getDocument();
+ unoidl.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
+ unoidl.com.sun.star.beans.XPropertySet xDocProp =
+ (unoidl.com.sun.star.beans.XPropertySet) xDocument;
+ uno.Any aRangesObj = xDocProp.getPropertyValue( "NamedRanges" );
+ unoidl.com.sun.star.sheet.XNamedRanges xNamedRanges =
+ (unoidl.com.sun.star.sheet.XNamedRanges) aRangesObj.Value;
+ unoidl.com.sun.star.table.CellAddress aRefPos =
+ new unoidl.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" );
+ unoidl.com.sun.star.table.XCellRange xRange =
+ xSheet.getCellRangeByPosition( 6, 47, 7, 49 );
+ unoidl.com.sun.star.sheet.XCellRangeData xData =
+ ( unoidl.com.sun.star.sheet.XCellRangeData ) xRange;
+ uno.Any [][] aValues =
+ {
+ new uno.Any [] { new uno.Any( "Apples" ),
+ new uno.Any( "Oranges" ) },
+ new uno.Any [] { new uno.Any( (Double) 5 ),
+ new uno.Any( (Double) 7 ) },
+ new uno.Any [] { new uno.Any( (Double) 6 ),
+ new uno.Any( (Double) 8 ) }
+ };
+ xData.setDataArray( aValues );
+
+ // insert a column label range
+ uno.Any aLabelsObj = xDocProp.getPropertyValue( "ColumnLabelRanges" );
+ unoidl.com.sun.star.sheet.XLabelRanges xLabelRanges =
+ (unoidl.com.sun.star.sheet.XLabelRanges) aLabelsObj.Value;
+ unoidl.com.sun.star.table.CellRangeAddress aLabelArea =
+ new unoidl.com.sun.star.table.CellRangeAddress();
+ aLabelArea.Sheet = 0;
+ aLabelArea.StartColumn = 6;
+ aLabelArea.StartRow = 47;
+ aLabelArea.EndColumn = 7;
+ aLabelArea.EndRow = 47;
+ unoidl.com.sun.star.table.CellRangeAddress aDataArea =
+ new unoidl.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;
+ unoidl.com.sun.star.lang.XMultiServiceFactory xServiceManager =
+ getServiceManager();
+ unoidl.com.sun.star.container.XNameAccess xContext =
+ (unoidl.com.sun.star.container.XNameAccess)
+ xServiceManager.createInstance(
+ "com.sun.star.sdb.DatabaseContext" );
+ String[] aNames = xContext.getElementNames();
+ if ( aNames.Length > 0 )
+ aDatabase = aNames[0];
+ 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;
+ unoidl.com.sun.star.lang.XMultiServiceFactory xServiceManager =
+ getServiceManager();
+ unoidl.com.sun.star.container.XNameAccess xContext =
+ (unoidl.com.sun.star.container.XNameAccess)
+ xServiceManager.createInstance(
+ "com.sun.star.sdb.DatabaseContext" );
+ unoidl.com.sun.star.sdb.XCompletedConnection xSource =
+ (unoidl.com.sun.star.sdb.XCompletedConnection)
+ xContext.getByName( aDatabase ).Value;
+ unoidl.com.sun.star.task.XInteractionHandler xHandler =
+ (unoidl.com.sun.star.task.XInteractionHandler)
+ xServiceManager.createInstance(
+ "com.sun.star.task.InteractionHandler" );
+ unoidl.com.sun.star.sdbcx.XTablesSupplier xSupplier =
+ (unoidl.com.sun.star.sdbcx.XTablesSupplier)
+ xSource.connectWithCompletion( xHandler );
+ unoidl.com.sun.star.container.XNameAccess xTables =
+ xSupplier.getTables();
+ String[] aNames = xTables.getElementNames();
+ if ( aNames.Length > 0 )
+ aTable = aNames[0];
+ return aTable;
+ }
+
+ private void doDatabaseSamples()
+ {
+ Console.WriteLine( "\n*** Samples for database operations ***\n" );
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet = getSpreadsheet( 2 );
+
+
+ // --- put some example data into the sheet ---
+ unoidl.com.sun.star.table.XCellRange xRange =
+ xSheet.getCellRangeByName( "B3:D24" );
+ unoidl.com.sun.star.sheet.XCellRangeData xData =
+ (unoidl.com.sun.star.sheet.XCellRangeData) xRange;
+ uno.Any [][] aValues =
+ {
+ new uno.Any [] { new uno.Any( "Name" ),
+ new uno.Any( "Year" ),
+ new uno.Any( "Sales" ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( (Double) 2001 ),
+ new uno.Any( (Double) 4.0 ) },
+ new uno.Any [] { new uno.Any( "Carol" ),
+ new uno.Any( (Double) 1997 ),
+ new uno.Any( (Double) 3.0 ) },
+ new uno.Any [] { new uno.Any( "Carol" ),
+ new uno.Any( (Double) 1998 ),
+ new uno.Any( (Double) 8.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( (Double) 1997 ),
+ new uno.Any( (Double) 8.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( (Double) 2002 ),
+ new uno.Any( (Double) 9.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( (Double) 1999 ),
+ new uno.Any( (Double) 7.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( (Double) 1996 ),
+ new uno.Any( (Double) 3.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( (Double) 2000 ),
+ new uno.Any( (Double) 1.0 ) },
+ new uno.Any [] { new uno.Any( "Carol" ),
+ new uno.Any( (Double) 1999 ),
+ new uno.Any( (Double) 5.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( (Double) 2002 ),
+ new uno.Any( (Double) 1.0 ) },
+ new uno.Any [] { new uno.Any( "Carol" ),
+ new uno.Any( (Double) 2001 ),
+ new uno.Any( (Double) 5.0 ) },
+ new uno.Any [] { new uno.Any( "Carol" ),
+ new uno.Any( (Double) 2000 ),
+ new uno.Any( (Double) 1.0 ) },
+ new uno.Any [] { new uno.Any( "Carol" ),
+ new uno.Any( (Double) 1996 ),
+ new uno.Any( (Double) 8.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( (Double) 1996 ),
+ new uno.Any( (Double) 7.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( (Double) 1997 ),
+ new uno.Any( (Double) 3.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( (Double) 2000 ),
+ new uno.Any( (Double) 9.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( (Double) 1998 ),
+ new uno.Any( (Double) 1.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( (Double) 1999 ),
+ new uno.Any( (Double) 6.0 ) },
+ new uno.Any [] { new uno.Any( "Carol" ),
+ new uno.Any( (Double) 2002 ),
+ new uno.Any( (Double) 8.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( (Double) 1998 ),
+ new uno.Any( (Double) 5.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( (Double) 2001 ),
+ new uno.Any( (Double) 6.0 ) }
+ };
+ xData.setDataArray( aValues );
+
+
+ // --- filter for second column >= 1998 ---
+ unoidl.com.sun.star.sheet.XSheetFilterable xFilter =
+ (unoidl.com.sun.star.sheet.XSheetFilterable) xRange;
+ unoidl.com.sun.star.sheet.XSheetFilterDescriptor xFilterDesc =
+ xFilter.createFilterDescriptor( true );
+ unoidl.com.sun.star.sheet.TableFilterField[] aFilterFields =
+ new unoidl.com.sun.star.sheet.TableFilterField[1];
+ aFilterFields[0] = new unoidl.com.sun.star.sheet.TableFilterField();
+ aFilterFields[0].Field = 1;
+ aFilterFields[0].IsNumeric = true;
+ aFilterFields[0].Operator =
+ unoidl.com.sun.star.sheet.FilterOperator.GREATER_EQUAL;
+ aFilterFields[0].NumericValue = 1998;
+ xFilterDesc.setFilterFields( aFilterFields );
+ unoidl.com.sun.star.beans.XPropertySet xFilterProp =
+ (unoidl.com.sun.star.beans.XPropertySet) xFilterDesc;
+ xFilterProp.setPropertyValue(
+ "ContainsHeader", new uno.Any( true ) );
+ xFilter.filter( xFilterDesc );
+
+
+ // --- do the same filter as above, using criteria from a cell range ---
+ unoidl.com.sun.star.table.XCellRange xCritRange =
+ xSheet.getCellRangeByName( "B27:B28" );
+ unoidl.com.sun.star.sheet.XCellRangeData xCritData =
+ (unoidl.com.sun.star.sheet.XCellRangeData) xCritRange;
+ uno.Any [][] aCritValues =
+ {
+ new uno.Any [] { new uno.Any( "Year" ) },
+ new uno.Any [] { new uno.Any( ">= 1998" ) }
+ };
+ xCritData.setDataArray( aCritValues );
+ unoidl.com.sun.star.sheet.XSheetFilterableEx xCriteria =
+ (unoidl.com.sun.star.sheet.XSheetFilterableEx) xCritRange;
+ xFilterDesc = xCriteria.createFilterDescriptorByObject( xFilter );
+ if ( xFilterDesc != null )
+ xFilter.filter( xFilterDesc );
+
+
+ // --- sort by second column, ascending ---
+ unoidl.com.sun.star.util.SortField[] aSortFields =
+ new unoidl.com.sun.star.util.SortField[1];
+ aSortFields[0] = new unoidl.com.sun.star.util.SortField();
+ aSortFields[0].Field = 1;
+ aSortFields[0].SortAscending = true;
+
+ unoidl.com.sun.star.beans.PropertyValue[] aSortDesc =
+ new unoidl.com.sun.star.beans.PropertyValue[2];
+ aSortDesc[0] = new unoidl.com.sun.star.beans.PropertyValue();
+ aSortDesc[0].Name = "SortFields";
+ aSortDesc[0].Value =
+ new uno.Any(
+ typeof (unoidl.com.sun.star.util.SortField []),
+ aSortFields );
+ aSortDesc[1] = new unoidl.com.sun.star.beans.PropertyValue();
+ aSortDesc[1].Name = "ContainsHeader";
+ aSortDesc[1].Value = new uno.Any( true );
+
+ unoidl.com.sun.star.util.XSortable xSort =
+ (unoidl.com.sun.star.util.XSortable) xRange;
+ xSort.sort( aSortDesc );
+
+
+ // --- insert subtotals ---
+ unoidl.com.sun.star.sheet.XSubTotalCalculatable xSub =
+ (unoidl.com.sun.star.sheet.XSubTotalCalculatable) xRange;
+ unoidl.com.sun.star.sheet.XSubTotalDescriptor xSubDesc =
+ xSub.createSubTotalDescriptor( true );
+ unoidl.com.sun.star.sheet.SubTotalColumn[] aColumns =
+ new unoidl.com.sun.star.sheet.SubTotalColumn[1];
+ // calculate sum of third column
+ aColumns[0] = new unoidl.com.sun.star.sheet.SubTotalColumn();
+ aColumns[0].Column = 2;
+ aColumns[0].Function = unoidl.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 ---
+ unoidl.com.sun.star.beans.PropertyValue[] aImportDesc =
+ new unoidl.com.sun.star.beans.PropertyValue[3];
+ aImportDesc[0] = new unoidl.com.sun.star.beans.PropertyValue();
+ aImportDesc[0].Name = "DatabaseName";
+ aImportDesc[0].Value = new uno.Any( aDatabase );
+ aImportDesc[1] = new unoidl.com.sun.star.beans.PropertyValue();
+ aImportDesc[1].Name = "SourceType";
+ aImportDesc[1].Value =
+ new uno.Any(
+ typeof (unoidl.com.sun.star.sheet.DataImportMode),
+ unoidl.com.sun.star.sheet.DataImportMode.TABLE );
+ aImportDesc[2] = new unoidl.com.sun.star.beans.PropertyValue();
+ aImportDesc[2].Name = "SourceObject";
+ aImportDesc[2].Value = new uno.Any( aTableName );
+
+ unoidl.com.sun.star.table.XCellRange xImportRange =
+ xSheet.getCellRangeByName( "B35:B35" );
+ unoidl.com.sun.star.util.XImportable xImport =
+ (unoidl.com.sun.star.util.XImportable) xImportRange;
+ xImport.doImport( aImportDesc );
+
+
+ // --- use the temporary database range to find the
+ // imported data's size ---
+ unoidl.com.sun.star.beans.XPropertySet xDocProp =
+ (unoidl.com.sun.star.beans.XPropertySet) getDocument();
+ uno.Any aRangesObj = xDocProp.getPropertyValue( "DatabaseRanges" );
+ unoidl.com.sun.star.container.XNameAccess xRanges =
+ (unoidl.com.sun.star.container.XNameAccess) aRangesObj.Value;
+ String[] aNames = xRanges.getElementNames();
+ for ( int i=0; i<aNames.Length; i++ )
+ {
+ uno.Any aRangeObj = xRanges.getByName( aNames[i] );
+ unoidl.com.sun.star.beans.XPropertySet xRangeProp =
+ (unoidl.com.sun.star.beans.XPropertySet) aRangeObj.Value;
+ bool bUser = (Boolean)
+ xRangeProp.getPropertyValue( "IsUserDefined" ).Value;
+ if ( !bUser )
+ {
+ // this is the temporary database range -
+ // get the cell range and format it
+ unoidl.com.sun.star.sheet.XCellRangeReferrer xRef =
+ (unoidl.com.sun.star.sheet.XCellRangeReferrer)
+ aRangeObj.Value;
+ unoidl.com.sun.star.table.XCellRange xResultRange =
+ xRef.getReferredCells();
+ unoidl.com.sun.star.beans.XPropertySet xResultProp =
+ (unoidl.com.sun.star.beans.XPropertySet) xResultRange;
+ xResultProp.setPropertyValue(
+ "IsCellBackgroundTransparent", new uno.Any( false ) );
+ xResultProp.setPropertyValue(
+ "CellBackColor", new uno.Any( (Int32) 0xFFFFCC ) );
+ }
+ }
+ }
+ else
+ Console.WriteLine("can't get database");
+ }
+
+// ________________________________________________________________
+
+ private void doDataPilotSamples()
+ {
+ Console.WriteLine( "\n*** Samples for Data Pilot ***\n" );
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet = getSpreadsheet( 0 );
+
+
+ // --- Create a new DataPilot table ---
+ prepareRange( xSheet, "A38:C38", "Data Pilot" );
+ unoidl.com.sun.star.sheet.XDataPilotTablesSupplier xDPSupp =
+ (unoidl.com.sun.star.sheet.XDataPilotTablesSupplier) xSheet;
+ unoidl.com.sun.star.sheet.XDataPilotTables xDPTables =
+ xDPSupp.getDataPilotTables();
+ unoidl.com.sun.star.sheet.XDataPilotDescriptor xDPDesc =
+ xDPTables.createDataPilotDescriptor();
+ // set source range (use data range from CellRange test)
+ unoidl.com.sun.star.table.CellRangeAddress aSourceAddress =
+ createCellRangeAddress( xSheet, "A10:C30" );
+ xDPDesc.setSourceRange( aSourceAddress );
+ // settings for fields
+ unoidl.com.sun.star.container.XIndexAccess xFields =
+ xDPDesc.getDataPilotFields();
+ uno.Any aFieldObj;
+ unoidl.com.sun.star.beans.XPropertySet xFieldProp;
+ // use first column as column field
+ aFieldObj = xFields.getByIndex(0);
+ xFieldProp = (unoidl.com.sun.star.beans.XPropertySet) aFieldObj.Value;
+ xFieldProp.setPropertyValue(
+ "Orientation",
+ new uno.Any(
+ typeof (unoidl.com.sun.star.sheet.DataPilotFieldOrientation),
+ unoidl.com.sun.star.sheet.DataPilotFieldOrientation.COLUMN ) );
+ // use second column as row field
+ aFieldObj = xFields.getByIndex(1);
+ xFieldProp = (unoidl.com.sun.star.beans.XPropertySet) aFieldObj.Value;
+ xFieldProp.setPropertyValue(
+ "Orientation",
+ new uno.Any(
+ typeof (unoidl.com.sun.star.sheet.DataPilotFieldOrientation),
+ unoidl.com.sun.star.sheet.DataPilotFieldOrientation.ROW ) );
+ // use third column as data field, calculating the sum
+ aFieldObj = xFields.getByIndex(2);
+ xFieldProp = (unoidl.com.sun.star.beans.XPropertySet) aFieldObj.Value;
+ xFieldProp.setPropertyValue(
+ "Orientation",
+ new uno.Any(
+ typeof (unoidl.com.sun.star.sheet.DataPilotFieldOrientation),
+ unoidl.com.sun.star.sheet.DataPilotFieldOrientation.DATA ) );
+ xFieldProp.setPropertyValue(
+ "Function",
+ new uno.Any(
+ typeof (unoidl.com.sun.star.sheet.GeneralFunction),
+ unoidl.com.sun.star.sheet.GeneralFunction.SUM ) );
+ // select output position
+ unoidl.com.sun.star.table.CellAddress aDestAddress =
+ createCellAddress( xSheet, "A40" );
+ xDPTables.insertNewByName( "DataPilotExample", aDestAddress, xDPDesc );
+
+
+ // --- Modify the DataPilot table ---
+ uno.Any aDPTableObj = xDPTables.getByName( "DataPilotExample" );
+ xDPDesc =
+ (unoidl.com.sun.star.sheet.XDataPilotDescriptor) aDPTableObj.Value;
+ xFields = xDPDesc.getDataPilotFields();
+ // add a second data field from the third column,
+ // calculating the average
+ aFieldObj = xFields.getByIndex(2);
+ xFieldProp = (unoidl.com.sun.star.beans.XPropertySet) aFieldObj.Value;
+ xFieldProp.setPropertyValue(
+ "Orientation",
+ new uno.Any(
+ typeof (unoidl.com.sun.star.sheet.DataPilotFieldOrientation),
+ unoidl.com.sun.star.sheet.DataPilotFieldOrientation.DATA ) );
+ xFieldProp.setPropertyValue(
+ "Function",
+ new uno.Any(
+ typeof (unoidl.com.sun.star.sheet.GeneralFunction),
+ unoidl.com.sun.star.sheet.GeneralFunction.AVERAGE ) );
+ }
+
+// ________________________________________________________________
+
+ private void doFunctionAccessSamples()
+ {
+ Console.WriteLine( "\n*** Samples for function handling ***\n" );
+ unoidl.com.sun.star.lang.XMultiServiceFactory xServiceManager =
+ getServiceManager();
+
+
+ // --- Calculate a function ---
+ Object aFuncInst = xServiceManager.createInstance(
+ "com.sun.star.sheet.FunctionAccess" );
+ unoidl.com.sun.star.sheet.XFunctionAccess xFuncAcc =
+ (unoidl.com.sun.star.sheet.XFunctionAccess) aFuncInst;
+ // put the data in a two-dimensional array
+ Double [][] aData = { new Double [] { 1.0, 2.0, 3.0 } };
+ // construct the array of function arguments
+ uno.Any [] aArgs = new uno.Any [2];
+ aArgs[0] = new uno.Any( typeof (Double [][]), aData );
+ aArgs[1] = new uno.Any( (Double) 2.0 );
+ uno.Any aResult = xFuncAcc.callFunction( "ZTEST", aArgs );
+ Console.WriteLine(
+ "ZTEST result for data {1,2,3} and value 2 is " + aResult.Value );
+
+
+ // --- Get the list of recently used functions ---
+ Object aRecInst = xServiceManager.createInstance(
+ "com.sun.star.sheet.RecentFunctions" );
+ unoidl.com.sun.star.sheet.XRecentFunctions xRecFunc =
+ (unoidl.com.sun.star.sheet.XRecentFunctions) aRecInst;
+ int[] nRecentIds = xRecFunc.getRecentFunctionIds();
+
+
+ // --- Get the names for these functions ---
+ Object aDescInst = xServiceManager.createInstance(
+ "com.sun.star.sheet.FunctionDescriptions" );
+ unoidl.com.sun.star.sheet.XFunctionDescriptions xFuncDesc =
+ (unoidl.com.sun.star.sheet.XFunctionDescriptions) aDescInst;
+ Console.Write("Recently used functions: ");
+ for (int nFunction=0; nFunction<nRecentIds.Length; nFunction++)
+ {
+ unoidl.com.sun.star.beans.PropertyValue[] aProperties =
+ xFuncDesc.getById( nRecentIds[nFunction] );
+ for (int nProp=0; nProp<aProperties.Length; nProp++)
+ if ( aProperties[nProp].Name.Equals( "Name" ) )
+ Console.Write( aProperties[nProp].Value + " " );
+ }
+ Console.WriteLine();
+ }
+
+// ________________________________________________________________
+
+ private void doApplicationSettingsSamples()
+ {
+ Console.WriteLine( "\n*** Samples for application settings ***\n" );
+ unoidl.com.sun.star.lang.XMultiServiceFactory xServiceManager =
+ getServiceManager();
+
+
+ // --- Get the user defined sort lists ---
+ Object aSettings = xServiceManager.createInstance(
+ "com.sun.star.sheet.GlobalSheetSettings" );
+ unoidl.com.sun.star.beans.XPropertySet xPropSet =
+ (unoidl.com.sun.star.beans.XPropertySet) aSettings;
+ String[] aEntries = (String [])
+ xPropSet.getPropertyValue( "UserLists" ).Value;
+ Console.WriteLine("User defined sort lists:");
+ for ( int i=0; i<aEntries.Length; i++ )
+ Console.WriteLine( aEntries[i] );
+ }
+
+// ________________________________________________________________
+
+}
diff --git a/odk/examples/CLI/CSharp/Spreadsheet/ViewSample.cs b/odk/examples/CLI/CSharp/Spreadsheet/ViewSample.cs
new file mode 100644
index 000000000000..7b73d178ff1d
--- /dev/null
+++ b/odk/examples/CLI/CSharp/Spreadsheet/ViewSample.cs
@@ -0,0 +1,165 @@
+
+using System;
+using System.Threading;
+
+// __________ implementation ____________________________________
+
+/** Create and modify a spreadsheet view.
+ */
+public class ViewSample : SpreadsheetDocHelper
+{
+
+ public static void Main( String [] args )
+ {
+ try
+ {
+ using ( ViewSample aSample = new ViewSample( args ) )
+ {
+ aSample.doSampleFunction();
+ }
+ Console.WriteLine( "\nSamples done." );
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine( "Sample caught exception! " + ex );
+ }
+ }
+
+// ________________________________________________________________
+
+ public ViewSample( String[] args )
+ : base( args )
+ {
+ }
+
+// ________________________________________________________________
+
+ /** This sample function performs all changes on the view. */
+ public void doSampleFunction()
+ {
+ unoidl.com.sun.star.sheet.XSpreadsheetDocument xDoc = getDocument();
+ unoidl.com.sun.star.frame.XModel xModel =
+ (unoidl.com.sun.star.frame.XModel) xDoc;
+ unoidl.com.sun.star.frame.XController xController =
+ xModel.getCurrentController();
+
+ // --- Spreadsheet view ---
+ // freeze the first column and first two rows
+ unoidl.com.sun.star.sheet.XViewFreezable xFreeze =
+ (unoidl.com.sun.star.sheet.XViewFreezable) xController;
+ if ( null != xFreeze )
+ Console.WriteLine( "got xFreeze" );
+ xFreeze.freezeAtPosition( 1, 2 );
+
+ // --- View pane ---
+ // get the cell range shown in the second pane and assign
+ // a cell background to them
+ unoidl.com.sun.star.container.XIndexAccess xIndex =
+ (unoidl.com.sun.star.container.XIndexAccess) xController;
+ uno.Any aPane = xIndex.getByIndex(1);
+ unoidl.com.sun.star.sheet.XCellRangeReferrer xRefer =
+ (unoidl.com.sun.star.sheet.XCellRangeReferrer) aPane.Value;
+ unoidl.com.sun.star.table.XCellRange xRange = xRefer.getReferredCells();
+ unoidl.com.sun.star.beans.XPropertySet xRangeProp =
+ (unoidl.com.sun.star.beans.XPropertySet) xRange;
+ xRangeProp.setPropertyValue(
+ "IsCellBackgroundTransparent", new uno.Any( false ) );
+ xRangeProp.setPropertyValue(
+ "CellBackColor", new uno.Any( (Int32) 0xFFFFCC ) );
+
+ // --- View settings ---
+ // change the view to display green grid lines
+ unoidl.com.sun.star.beans.XPropertySet xProp =
+ (unoidl.com.sun.star.beans.XPropertySet) xController;
+ xProp.setPropertyValue(
+ "ShowGrid", new uno.Any( true ) );
+ xProp.setPropertyValue(
+ "GridColor", new uno.Any( (Int32) 0x00CC00 ) );
+
+ // --- Range selection ---
+ // let the user select a range and use it as the view's selection
+ unoidl.com.sun.star.sheet.XRangeSelection xRngSel =
+ (unoidl.com.sun.star.sheet.XRangeSelection) xController;
+ ExampleRangeListener aListener = new ExampleRangeListener();
+ xRngSel.addRangeSelectionListener( aListener );
+ unoidl.com.sun.star.beans.PropertyValue[] aArguments =
+ new unoidl.com.sun.star.beans.PropertyValue[2];
+ aArguments[0] = new unoidl.com.sun.star.beans.PropertyValue();
+ aArguments[0].Name = "Title";
+ aArguments[0].Value = new uno.Any( "Please select a range" );
+ aArguments[1] = new unoidl.com.sun.star.beans.PropertyValue();
+ aArguments[1].Name = "CloseOnMouseRelease";
+ aArguments[1].Value = new uno.Any( true );
+ xRngSel.startRangeSelection( aArguments );
+ Monitor.Enter( aListener );
+ try
+ {
+ Monitor.Wait( aListener ); // wait until the selection is done
+ }
+ finally
+ {
+ Monitor.Exit( aListener );
+ }
+ xRngSel.removeRangeSelectionListener( aListener );
+ if ( aListener.aResult != null && aListener.aResult.Length != 0 )
+ {
+ unoidl.com.sun.star.view.XSelectionSupplier xSel =
+ (unoidl.com.sun.star.view.XSelectionSupplier) xController;
+ unoidl.com.sun.star.sheet.XSpreadsheetView xView =
+ (unoidl.com.sun.star.sheet.XSpreadsheetView) xController;
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet =
+ xView.getActiveSheet();
+ unoidl.com.sun.star.table.XCellRange xResultRange =
+ xSheet.getCellRangeByName( aListener.aResult );
+ xSel.select(
+ new uno.Any(
+ typeof (unoidl.com.sun.star.table.XCellRange),
+ xResultRange ) );
+ }
+ }
+
+// ________________________________________________________________
+
+ // listener to react on finished selection
+
+ private class ExampleRangeListener
+ : unoidl.com.sun.star.sheet.XRangeSelectionListener
+ {
+ public String aResult;
+
+ public void done( unoidl.com.sun.star.sheet.RangeSelectionEvent aEvent )
+ {
+ aResult = aEvent.RangeDescriptor;
+ Monitor.Enter( this );
+ try
+ {
+ Monitor.Pulse( this );
+ }
+ finally
+ {
+ Monitor.Exit( this );
+ }
+ }
+
+ public void aborted(
+ unoidl.com.sun.star.sheet.RangeSelectionEvent aEvent )
+ {
+ Monitor.Enter( this );
+ try
+ {
+ Monitor.Pulse( this );
+ }
+ finally
+ {
+ Monitor.Exit( this );
+ }
+ }
+
+ public void disposing( unoidl.com.sun.star.lang.EventObject aObj )
+ {
+ }
+ }
+
+// ________________________________________________________________
+
+}
diff --git a/odk/examples/CLI/VB.NET/WriterDemo/Makefile b/odk/examples/CLI/VB.NET/WriterDemo/Makefile
new file mode 100644
index 000000000000..ac60d7ef4536
--- /dev/null
+++ b/odk/examples/CLI/VB.NET/WriterDemo/Makefile
@@ -0,0 +1,61 @@
+# Builds the WriterDemo examples of the Developers Guide.
+
+PRJ = ../../../..
+SETTINGS = $(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.mk
+
+CSC_FLAGS = -warnaserror+ -incremental- -noconfig
+VBC_FLAGS = -warnaserror+
+ifeq "$(DEBUG)" "yes"
+CC_FLAGS+=-Zi -MT
+CSC_FLAGS += -debug+ -checked+ -define:DEBUG -define:TRACE
+VBC_FLAGS += -debug+ -define:DEBUG=1 -define:TRACE=1
+else
+CSC_FLAGS += -o
+endif
+
+WRITERDEMO_OUT:= $(OUT_BIN)/VB_dotNET_WriterDemo
+
+# Targets
+.PHONY : ALL
+ALL : WriterDemo
+
+include $(SETTINGS)/stdtarget.mk
+
+# build executables
+$(WRITERDEMO_OUT)/%.exe: %.vb
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ vbc $(VBC_FLAGS) \
+ -target:exe \
+ -out:$@ \
+ -libpath:"$(PRJ)\cli" \
+ -reference:cli_basetypes.dll \
+ -reference:cli_uretypes.dll \
+ -reference:cli_oootypes.dll \
+ -reference:cli_ure.dll \
+ -reference:cli_cppuhelper.dll \
+ -reference:System.dll \
+ -reference:System.Drawing.dll \
+ -reference:System.Windows.Forms.dll \
+ $^
+
+WriterDemo : $(WRITERDEMO_OUT)/WriterDemo.exe
+ @echo -------------------------------------------------------------------------------
+ @echo Please use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) WriterDemo.run
+ @echo -------------------------------------------------------------------------------
+
+%.run : $(WRITERDEMO_OUT)/%.exe
+ @echo -------------------------------------------------------------------------------
+ @echo Executing sample $@ $(UNORC) $(CONNECT_STRING)...
+ @echo -------------------------------------------------------------------------------
+ cd $(subst /,\\,$(WRITERDEMO_OUT)) && $(basename $@).exe
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_BIN)/VB_dotNET_WriterDemo)
+
diff --git a/odk/examples/CLI/VB.NET/WriterDemo/WriterDemo.vb b/odk/examples/CLI/VB.NET/WriterDemo/WriterDemo.vb
new file mode 100644
index 000000000000..48eea4e44ea5
--- /dev/null
+++ b/odk/examples/CLI/VB.NET/WriterDemo/WriterDemo.vb
@@ -0,0 +1,242 @@
+'*************************************************************************
+'
+' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+'
+' Copyright 2000, 2010 Oracle and/or its affiliates.
+'
+' OpenOffice.org - a multi-platform office productivity suite
+'
+' This file is part of OpenOffice.org.
+'
+' OpenOffice.org is free software: you can redistribute it and/or modify
+' it under the terms of the GNU Lesser General Public License version 3
+' only, as published by the Free Software Foundation.
+'
+' OpenOffice.org is distributed in the hope that it will be useful,
+' but WITHOUT ANY WARRANTY; without even the implied warranty of
+' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+' GNU Lesser General Public License version 3 for more details
+' (a copy is included in the LICENSE file that accompanied this code).
+'
+' You should have received a copy of the GNU Lesser General Public License
+' version 3 along with OpenOffice.org. If not, see
+' <http://www.openoffice.org/license.html>
+' for a copy of the LGPLv3 License.
+'
+'*************************************************************************
+
+Option Explicit On
+Option Strict On
+
+imports System
+imports System.Collections
+imports Microsoft.VisualBasic
+imports unoidl.com.sun.star.lang
+imports unoidl.com.sun.star.uno
+imports unoidl.com.sun.star.bridge
+imports uno.util
+
+Module WriterDemo
+
+Sub Main( ByVal args() As String)
+' If args.Length <> 2 Then
+' Console.WriteLine("WriterDemo takes two arguments. A file url to the office" & _
+' "program directory and a connection string.")
+' End If
+'Connect to a running office
+'--------------------------------------------------
+
+'Create a service manager of the remote office
+'Dim ht As Hashtable = New Hashtable()
+'ht.Add("SYSBINDIR", args(0))
+Dim xContext As XComponentContext
+'xLocalContext = Bootstrap.defaultBootstrap_InitialComponentContext( _
+' args(0) & "/uno.ini", ht.GetEnumerator())
+
+xContext = Bootstrap.bootstrap()
+
+'Dim xURLResolver As XUnoUrlResolver
+'xURLResolver = DirectCast(xLocalContext.getServiceManager(). _
+' createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", _
+' xLocalContext), XUnoUrlResolver)
+
+'Dim xRemoteContext As XComponentContext
+'xRemoteContext = DirectCast(xURLResolver.resolve( _
+' "uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext"), _
+' XComponentContext)
+
+Dim xFactory As XMultiServiceFactory
+xFactory = DirectCast(xContext.getServiceManager(), _
+ XMultiServiceFactory)
+
+'Create the Desktop
+Dim xDesktop As unoidl.com.sun.star.frame.XDesktop
+xDesktop = DirectCast(xFactory.createInstance("com.sun.star.frame.Desktop"), _
+ unoidl.com.sun.star.frame.XDesktop)
+
+'Open a new empty writer document
+Dim xComponentLoader As unoidl.com.sun.star.frame.XComponentLoader
+xComponentLoader = DirectCast(xDesktop, unoidl.com.sun.star.frame.XComponentLoader)
+Dim arProps() As unoidl.com.sun.star.beans.PropertyValue = _
+ New unoidl.com.sun.star.beans.PropertyValue(){}
+Dim xComponent As unoidl.com.sun.star.lang.XComponent
+ xComponent = xComponentLoader.loadComponentFromURL( _
+ "private:factory/swriter", "_blank", 0, arProps)
+Dim xTextDocument As unoidl.com.sun.star.text.XTextDocument
+xTextDocument = DirectCast(xComponent, unoidl.com.sun.star.text.XTextDocument)
+
+'Create a text object
+Dim xText As unoidl.com.sun.star.text.XText
+xText = xTextDocument.getText()
+
+Dim xSimpleText As unoidl.com.sun.star.text.XSimpleText
+xSimpleText = DirectCast(xText, unoidl.com.sun.star.text.XSimpleText)
+
+'Create a cursor object
+Dim xCursor As unoidl.com.sun.star.text.XTextCursor
+xCursor = xSimpleText.createTextCursor()
+
+'Inserting some Text
+xText.insertString(xCursor, "The first line in the newly created text document." _
+ & vbLf, false)
+
+'Create instance of a text table with 4 columns and 4 rows
+Dim objTextTable As Object
+objTextTable= DirectCast(xTextDocument, unoidl.com.sun.star.lang.XMultiServiceFactory). _
+ createInstance("com.sun.star.text.TextTable")
+Dim xTextTable As unoidl.com.sun.star.text.XTextTable
+xTextTable = DirectCast(objTextTable, unoidl.com.sun.star.text.XTextTable)
+xTextTable.initialize(4, 4)
+xText.insertTextContent(xCursor, xTextTable, false)
+
+'Set the table background color
+Dim xPropertySetTable As unoidl.com.sun.star.beans.XPropertySet
+xPropertySetTable = DirectCast(objTextTable, unoidl.com.sun.star.beans.XPropertySet)
+xPropertySetTable.setPropertyValue("BackTransparent", New uno.Any(False))
+xPropertySetTable.setPropertyValue("BackColor", New uno.Any(&Hccccff))
+
+'Get first row
+Dim xTableRows As unoidl.com.sun.star.table.XTableRows
+xTableRows = xTextTable.getRows()
+Dim anyRow As uno.Any
+anyRow = DirectCast(xTableRows, unoidl.com.sun.star.container.XIndexAccess).getByIndex( 0)
+
+'Set a different background color for the first row
+Dim xPropertySetFirstRow As unoidl.com.sun.star.beans.XPropertySet
+xPropertySetFirstRow = DirectCast(anyRow.Value, unoidl.com.sun.star.beans.XPropertySet)
+xPropertySetFirstRow.setPropertyValue("BackTransparent", New uno.Any(False))
+xPropertySetFirstRow.setPropertyValue("BackColor", New uno.Any(&H6666AA))
+
+'Fill the first table row
+insertIntoCell("A1","FirstColumn", xTextTable)
+insertIntoCell("B1","SecondColumn", xTextTable)
+insertIntoCell("C1","ThirdColumn", xTextTable)
+insertIntoCell("D1","SUM", xTextTable)
+
+'Fill the remaining rows
+xTextTable.getCellByName("A2").setValue(22.5)
+xTextTable.getCellByName("B2").setValue(5615.3)
+xTextTable.getCellByName("C2").setValue(-2315.7)
+xTextTable.getCellByName("D2").setFormula("sum <A2:C2>")
+
+xTextTable.getCellByName("A3").setValue(21.5)
+xTextTable.getCellByName("B3").setValue (615.3)
+xTextTable.getCellByName("C3").setValue( -315.7)
+xTextTable.getCellByName("D3").setFormula( "sum <A3:C3>")
+
+xTextTable.getCellByName("A4").setValue( 121.5)
+xTextTable.getCellByName("B4").setValue( -615.3)
+xTextTable.getCellByName("C4").setValue( 415.7)
+xTextTable.getCellByName("D4").setFormula( "sum <A4:C4>")
+
+'Change the CharColor and add a Shadow
+Dim xPropertySetCursor As unoidl.com.sun.star.beans.XPropertySet
+xPropertySetCursor = DirectCast(xCursor, unoidl.com.sun.star.beans.XPropertySet)
+xPropertySetCursor.setPropertyValue("CharColor", New uno.Any(255))
+xPropertySetCursor.setPropertyValue("CharShadowed", New uno.Any(true))
+
+'Create a paragraph break
+xSimpleText.insertControlCharacter(xCursor, _
+ unoidl.com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
+
+'Inserting colored Text.
+xSimpleText.insertString(xCursor," This is a colored Text - blue with shadow" & vbLf, _
+ False)
+
+'Create a paragraph break
+xSimpleText.insertControlCharacter(xCursor, _
+ unoidl.com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
+
+'Create a TextFrame.
+Dim objTextFrame As Object
+objTextFrame = DirectCast(xTextDocument, unoidl.com.sun.star.lang.XMultiServiceFactory). _
+ createInstance("com.sun.star.text.TextFrame")
+
+Dim xTextFrame As unoidl.com.sun.star.text.XTextFrame = _
+ DirectCast(objTextFrame, unoidl.com.sun.star.text.XTextFrame)
+
+'Set the size of the frame
+Dim aSize As unoidl.com.sun.star.awt.Size = _
+ New unoidl.com.sun.star.awt.Size(15000, 400)
+DirectCast(xTextFrame, unoidl.com.sun.star.drawing.XShape).setSize(aSize)
+
+'Set anchortype
+Dim xPropertySetFrame As unoidl.com.sun.star.beans.XPropertySet
+xPropertySetFrame = DirectCast(xTextFrame, unoidl.com.sun.star.beans.XPropertySet)
+xPropertySetFrame.setPropertyValue("AnchorType", New uno.Any( _
+ GetType(unoidl.com.sun.star.text.TextContentAnchorType), _
+ unoidl.com.sun.star.text.TextContentAnchorType.AS_CHARACTER))
+
+'insert the frame
+xText.insertTextContent(xCursor, xTextFrame, False)
+
+'Get the text object of the frame
+
+Dim xFrameText As unoidl.com.sun.star.text.XText
+xFrameText = xTextFrame.getText()
+
+Dim xFrameSimpleText As unoidl.com.sun.star.text.XSimpleText
+xFrameSimpleText = DirectCast(xFrameText, unoidl.com.sun.star.text.XSimpleText)
+
+'Create a cursor object
+Dim xFrameCursor As unoidl.com.sun.star.text.XTextCursor
+xFrameCursor = xFrameSimpleText.createTextCursor()
+
+'Inserting some Text
+xFrameSimpleText.insertString(xFrameCursor, _
+ "The first line in the newly created text frame.", False)
+xFrameSimpleText.insertString(xFrameCursor, _
+ vbLf & "With this second line the height of the frame raises.", False)
+
+'Create a paragraph break
+xSimpleText.insertControlCharacter(xFrameCursor, _
+ unoidl.com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
+
+'Change the CharColor and add a Shadow
+xPropertySetCursor.setPropertyValue("CharColor", New uno.Any(65536))
+xPropertySetCursor.setPropertyValue("CharShadowed", New uno.Any(False))
+
+'Insert another string
+xText.insertString(xCursor, vbLf + " That's all for now !!", False)
+
+End Sub
+
+Sub insertIntoCell(sCellName As String,sText As String, _
+ xTable As unoidl.com.sun.star.text.XTextTable)
+ Dim xCell As unoidl.com.sun.star.table.XCell
+ xCell = xTable.getCellByName(sCellName)
+
+ Dim xSimpleTextCell As unoidl.com.sun.star.text.XSimpleText
+ xSimpleTextCell = DirectCast(xCell, unoidl.com.sun.star.text.XSimpleText)
+
+ Dim xCursor As unoidl.com.sun.star.text.XTextCursor
+ xCursor = xSimpleTextCell.createTextCursor()
+
+ Dim xPropertySetCursor As unoidl.com.sun.star.beans.XPropertySet
+ xPropertySetCursor = DirectCast(xCursor, unoidl.com.sun.star.beans.XPropertySet)
+
+ xPropertySetCursor.setPropertyValue("CharColor", New uno.Any(&Hffffff))
+ xSimpleTextCell.insertString(xCursor, sText, False)
+End Sub
+
+End Module
diff --git a/odk/examples/CLI/makefile.mk b/odk/examples/CLI/makefile.mk
new file mode 100644
index 000000000000..fb5344f98087
--- /dev/null
+++ b/odk/examples/CLI/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=cli
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+CSHARP=\
+ $(DESTDIRCLIEXAMPLES)$/CSharp$/Spreadsheet$/GeneralTableSample.cs \
+ $(DESTDIRCLIEXAMPLES)$/CSharp$/Spreadsheet$/SpreadsheetDocHelper.cs \
+ $(DESTDIRCLIEXAMPLES)$/CSharp$/Spreadsheet$/SpreadsheetSample.cs \
+ $(DESTDIRCLIEXAMPLES)$/CSharp$/Spreadsheet$/ViewSample.cs \
+ $(DESTDIRCLIEXAMPLES)$/CSharp$/Spreadsheet$/Makefile
+
+VBDOTNET=\
+ $(DESTDIRCLIEXAMPLES)$/VB.NET$/WriterDemo$/WriterDemo.vb \
+ $(DESTDIRCLIEXAMPLES)$/VB.NET$/WriterDemo$/Makefile
+
+
+DIR_FILE_LIST= \
+ $(CSHARP) \
+ $(VBDOTNET)
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/ex_$(TARGET)_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/ex_$(TARGET)_files.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
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..2e4f3d06504b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Config/ConfigExamples.java
@@ -0,0 +1,1123 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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
+ 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 a given ConfigurationProvider
+ */
+ public void runExamples( )
+ {
+ if (checkProvider(mxProvider))
+ {
+ System.out.println("\nStarting examples.");
+
+ readDataExample();
+
+ browseDataExample();
+
+ updateGroupExample();
+
+ resetGroupExample();
+
+ updateSetExample();
+
+ System.out.println("\nAll Examples completed.");
+ }
+ else
+ System.out.println("ERROR: Cannot run examples without ConfigurationProvider.");
+
+ }
+
+ /** Do some simple checks, if 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 a specified read-only configuration view
+ */
+ public Object createConfigurationView( String sPath )
+ throws com.sun.star.uno.Exception
+ {
+ XMultiServiceFactory xProvider = getProvider();
+
+ // The service name: Need only read access:
+ final String sReadOnlyView = "com.sun.star.configuration.ConfigurationAccess";
+
+ // creation arguments: nodepath
+ com.sun.star.beans.PropertyValue aPathArgument = new com.sun.star.beans.PropertyValue();
+ aPathArgument.Name = "nodepath";
+ aPathArgument.Value = sPath;
+
+ Object[] aArguments = new Object[1];
+ aArguments[0] = aPathArgument;
+
+ // create the view
+ Object xViewRoot = xProvider.createInstanceWithArguments(sReadOnlyView, aArguments);
+
+ return xViewRoot;
+ }
+
+ /** Create a specified updatable configuration view
+ */
+ Object createUpdatableView( String sPath )
+ throws com.sun.star.uno.Exception
+ {
+ XMultiServiceFactory xProvider = getProvider();
+
+ // The service name: Need update access:
+ final String cUpdatableView = "com.sun.star.configuration.ConfigurationUpdateAccess";
+
+ // creation arguments: nodepath
+ com.sun.star.beans.PropertyValue aPathArgument = new com.sun.star.beans.PropertyValue();
+ aPathArgument.Name = "nodepath";
+ aPathArgument.Value = sPath;
+
+ Object[] aArguments = new Object[1];
+ aArguments[0] = aPathArgument;
+
+ // create the view
+ Object xViewRoot = xProvider.createInstanceWithArguments(cUpdatableView, aArguments);
+
+ return xViewRoot;
+ }
+
+ /** This method demonstrates read access to data
+ */
+ protected void readDataExample ()
+ {
+ try
+ {
+ System.out.println("\n--- starting example: read grid option settings --------------------");
+ Object aData = readGridConfiguration( );
+ System.out.println("Read grid options: " + aData);
+
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates browsing access to data
+ */
+ protected void browseDataExample ()
+ {
+ try
+ {
+ System.out.println("\n--- starting example: browse filter configuration ------------------");
+ printRegisteredFilters( );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates update access to group data
+ */
+ protected void updateGroupExample ()
+ {
+ try
+ {
+ System.out.println("\n--- starting example: update group data --------------");
+ editGridOptions( );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates resetting data to its default state
+ */
+ protected void resetGroupExample ()
+ {
+ try
+ {
+ System.out.println("\n--- starting example: reset group data -----------------------------");
+ Object aOldData = readGridConfiguration( );
+ resetGridConfiguration( );
+ Object aNewData = readGridConfiguration( );
+ System.out.println("Before reset: user grid options: " + aOldData);
+ System.out.println("After reset: default grid options: " + aNewData);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates update access to set data
+ */
+ protected void updateSetExample ()
+ {
+ try
+ {
+ System.out.println("\n--- starting example: update set data ---------------");
+ storeSampleDataSource( );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+// READ example
+ /// class to hold information about grid settings
+ 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 view
+ Object xViewRoot = createUpdatableView( cGridOptionsPath );
+
+ // the 'editor'
+ GridOptionsEditor dialog = new GridOptionsEditor();
+
+ // set up the initial values and register listeners
+ // get a data access interface, to supply the view with a model
+ XMultiHierarchicalPropertySet xProperties =
+ (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);
+
+ 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.
+ */
+ Object createDataSourceDescription(XMultiServiceFactory xProvider, String sDataSourceName )
+ throws com.sun.star.uno.Exception
+ {
+ // The service name: Need an update access:
+ final String cUpdatableView = "com.sun.star.configuration.ConfigurationUpdateAccess";
+
+ // The path to the DataSources set node
+ final String cDataSourcesPath = "/org.openoffice.Office.DataAccess/DataSources";
+
+ // creation arguments: nodepath
+ com.sun.star.beans.PropertyValue aPathArgument = new com.sun.star.beans.PropertyValue();
+ aPathArgument.Name = "nodepath";
+ aPathArgument.Value = cDataSourcesPath ;
+
+ Object[] aArguments = new Object[1];
+ aArguments[0] = aPathArgument;
+
+ // create the view
+ Object xViewRoot =
+ xProvider.createInstanceWithArguments(cUpdatableView, aArguments);
+
+ XNameAccess xSetOfDataSources =
+ (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class,xViewRoot);
+
+ Object xDataSourceDescriptor = null; // the result
+ if ( xSetOfDataSources .hasByName( sDataSourceName ))
+ {
+ // the element is there
+ try
+ {
+ // the view should point to the element directly, so we need to extend the path
+ XHierarchicalName xComposePath = (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
+ Object[] aDeepArguments = new Object[1];
+ aDeepArguments[0] = aPathArgument;
+
+ // create the view
+ xDataSourceDescriptor =
+ xProvider.createInstanceWithArguments(cUpdatableView, aDeepArguments);
+
+ if ( xDataSourceDescriptor != null) // all went fine
+ {
+ // dispose the other view
+ ((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..994e6e4f9b3d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/CodeSamples.java
@@ -0,0 +1,330 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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 url = "jdbc:mysql://localhost:3306/TestTables";
+ // second create the necessary properties
+ com.sun.star.beans.PropertyValue [] props = new com.sun.star.beans.PropertyValue[]
+ {
+ new com.sun.star.beans.PropertyValue("user",0,"test1",com.sun.star.beans.PropertyState.DIRECT_VALUE),
+ new com.sun.star.beans.PropertyValue("password",0,"test1",com.sun.star.beans.PropertyState.DIRECT_VALUE),
+ new com.sun.star.beans.PropertyValue("JavaDriverClass",0,"org.gjt.mm.mysql.Driver",com.sun.star.beans.PropertyState.DIRECT_VALUE)
+ };
+ // now create a connection to mysql
+ con = xDriverManager.getConnectionWithInfo(url,props);
+ }
+ return con;
+ }
+
+ // uses the driver directly to create a new connection and dispose it.
+ public static XConnection openConnectionWithDriver() throws com.sun.star.uno.Exception
+ {
+ XConnection con = null;
+ // create the Driver with the implementation name
+ Object aDriver =
+ xMCF.createInstanceWithContext("org.openoffice.comp.drivers.MySQL.Driver",
+ xContext);
+ // query for the interface
+ com.sun.star.sdbc.XDriver xDriver;
+ xDriver = (XDriver)UnoRuntime.queryInterface(XDriver.class,aDriver);
+ if(xDriver != null)
+ {
+ // first create the needed url
+ String url = "jdbc:mysql://localhost:3306/TestTables";
+ // second create the necessary properties
+ com.sun.star.beans.PropertyValue [] props = new com.sun.star.beans.PropertyValue[]
+ {
+ new com.sun.star.beans.PropertyValue("user",0,"test1",com.sun.star.beans.PropertyState.DIRECT_VALUE),
+ new com.sun.star.beans.PropertyValue("password",0,"test1",com.sun.star.beans.PropertyState.DIRECT_VALUE),
+ new com.sun.star.beans.PropertyValue("JavaDriverClass",0,"org.gjt.mm.mysql.Driver",com.sun.star.beans.PropertyState.DIRECT_VALUE)
+ };
+ // now create a connection to mysql
+ con = xDriver.connect(url,props);
+ }
+ return con;
+ }
+
+ // print all available datasources
+ public static void printDataSources() throws com.sun.star.uno.Exception
+ {
+ // create a DatabaseContext and print all DataSource names
+ XNameAccess xNameAccess = (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..4beca94f9828
--- /dev/null
+++ b/odk/examples/DevelopersGuide/examples.html
@@ -0,0 +1,3032 @@
+<html>
+<head>
+ <title>OpenOffice.org %PRODUCT_RELEASE% SDK - Developer's Guide Examples</title>
+ <link rel="stylesheet" type="text/css"
+ href="../../docs/sdk_styles.css">
+ <meta http-equiv="Content-Type"
+ content="text/html; charset=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 %PRODUCT_RELEASE% Basic and
+Dialogs</a></td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"></td>
+ <td><a href="#Database"
+ title="link to the Database examples">Database Access</a></td>
+ <td class="content4"></td>
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"></td>
+ <td><a href="#Forms"
+ title="link to the Forms examples">Forms</a></td>
+ <td class="content10"></td>
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"></td>
+ <td><a href="#UniversalContentBroker%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 %PRODUCT_RELEASE% in a
+different process space.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./FirstSteps/FirstLoadComponent.java"
+ title="link to FirstSteps/FirstLoadComponent.java">FirstLoadComponent</a></td>
+ <td class="cell80">Demonstrates how to load a
+component into OpenOffice.org %PRODUCT_RELEASE% by a Java application.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./FirstSteps/HelloTextTableShape.java"
+ title="link to FirstSteps/HelloTextTableShape.java">HelloTextTableShape</a></td>
+ <td class="cell80">Performs some generic text and
+shape operations on a text document, a spreadsheet document and a
+drawing document.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a
+ name="ProfessionalUNO">Professional UNO examples1</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Lifetime Examples</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./ProfUNO/Lifetime/MyUnoObject.java"
+ title="link to ProfUNO/Lifetime/MyUnoObject.java">MyUnoObject</a></td>
+ <td class="cell80">Shows that it depends on the
+implementation of the Java VM whether finalize() will be called or not.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./ProfUNO/Lifetime/object_lifetime.cxx"
+ title="link to ProfUNO/Lifetime/object_lifetime.java">object_lifetime.cxx
+(ProfUnoLifetime)</a></td>
+ <td class="cell80">Shows the UNO reference counting
+mechanism in C++.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Interprocess Connection Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./ProfUNO/InterprocessConn/ConnectionAwareClient.java"
+ title="link to ProfUNO/InterprocessConn/ConnectionAwareClient/.java">ConnectionAwareClient</a></td>
+ <td class="cell80">Implements a client which is aware
+of losing connection to OpenOffice.org %PRODUCT_RELEASE%.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./ProfUNO/InterprocessConn/UrlResolver.java"
+ title="link to ProfUNO/InterProcessConn/UrlResolver.java">UrlResolver</a></td>
+ <td class="cell80">Builds a connection to
+OpenOffice.org %PRODUCT_RELEASE% 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 %PRODUCT_RELEASE% using C++.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./ProfUNO/CppBinding/string_samples.cxx"
+ title="link to ProfUNO/Cppbinding/string_samples.java">string_samples.cxx</a></td>
+ <td class="cell80">Demonstrates usage of RTL string
+classes <a href="../../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 %PRODUCT_RELEASE% Basic IDE. The component provides methods that
+ can be bound to dialog respectively control events .</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/DialogComponent/XTestDialogHandler.idl"
+ title="link to Components/DialogComponent/XTestDialogHandler.idl">XTestDialogHandler.idl</a></td>
+ <td class="cell80">Interface implementing a createDialog method showing the
+ dialog and some methods to be used as event handler for the dialog.
+ </td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/DialogComponent/TestDialogHandler.idl"
+ title="link to Components/DialogComponent/TestDialogHandler.idl">TestDialogHandler.idl</a></td>
+ <td class="cell80">
+ Service definition for the component implementing
+ its own interface <code>XTestDialogHandler</code>.
+ </td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/DialogComponent/DialogComponent.odt"
+ title="link to Components/DialogComponent/DialogComponent.odt">DialogComponent.odt</a></td>
+ <td class="cell80">Document containing Basic code to
+ instantiate the Dialog Components and a Dialog containing
+ controls with events bound to methods supported by the
+ Dialog Component.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a
+ name="OfficeDevelopment">Office Development examples</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Ascii Filter Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java"
+ title="link to OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java">AsciiReplaceFilter</a></td>
+ <td class="cell80">Implements an example for an
+import/export filter service.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java"
+ title="link to OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java">FilterOptions</a></td>
+ <td class="cell80">Offers some helper methods to
+analyze and prepare the arguments of the filter method.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/AsciiFilter/TypeDetection.xcu"
+ title="link to OfficeDev/FilterDevelopment/AsciiFilter/TypeDetection.xcu">TypeDetection.xcu</a></td>
+ <td class="cell80">Contains the necessary
+configuration items for the AsciiReplaceFilter.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">FlatXmlFilter C++ Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXml.cxx"
+ title="link to OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXml.cxx">FlatXml.cxx</a></td>
+ <td class="cell80">Implements an import/export filter
+storing the data in one xml stream instead of the normal three streams
+in for example an .odt file. The example is implemented in C++.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.xcu"
+ title="link to OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.xcu">FlatXmlFilter_cpp.xcu</a></td>
+ <td class="cell80">Contains the necessary
+configuration items for the C++ flat xml filter.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">FlatXmlFilter Java Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java"
+ title="link to OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java">FlatXml</a></td>
+ <td class="cell80">Implements an import/export filter
+storing the data in one xml stream instead of the normal three streams
+in for example an .odt file. The example is implemented in Java.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXmlFilter_java.xcu"
+ title="link to OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXmlFilter_java.xcu">FlatXmlFilter_java.xcu</a></td>
+ <td class="cell80">Contains the necessary
+configuration items for the Java flat xml filter.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">FlatXml FilterDetection Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx"
+ title="link to OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx">filterdetect.cxx</a></td>
+ <td class="cell80">Implements an example filter
+detection for the flat xml filter. The example is implemented in C++.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx"
+ title="link to OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx">filterdetect.hxx</a></td>
+ <td class="cell80">Contains the class definition of
+the filter detection example.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx"
+ title="link to OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx">fdcomp.cxx</a></td>
+ <td class="cell80">Implements the administrative
+component functions (component_writeInfo, component_getFactory).</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 %PRODUCT_RELEASE% via system
+window handle. This is the same mechanism as used by the OOoBean, but
+the OOoBean itself is not used here, just the JNI window handle access.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/DocumentView.java"
+ title="link to OfficeDev/DesktopEnvironment/DocumentView.java">DocumentView</a></td>
+ <td class="cell80">Deals with the application window
+and it's actions.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/FunctionHelper.java"
+ title="link to OfficeDev/DesktopEnvironment/FunctionHelper.java">FunctionHelper</a></td>
+ <td class="cell80">This helper comprises all
+OpenOffice.org %PRODUCT_RELEASE% API calls. Thus it is possible to learn about these
+aspects separately from the rest of the application example.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/IOnewayLink.java"
+ title="link to OfficeDev/DesktopEnvironment/IOnewayLink.java">IOnewayLink</a></td>
+ <td class="cell80">This is an interface to receive
+asynchronous events from UNO oneway calls.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/IShutdownListener.java"
+ title="link to OfficeDev/DesktopEnvironment/IShutdownListener.java">IShutdownListener</a></td>
+ <td class="cell80">This is a listener interface to
+clean up on shutdown of OpenOffice.org %PRODUCT_RELEASE%.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/Interceptor.java"
+ title="link to OfficeDev/DesktopEnvironment/Interceptor.java">Interceptor</a></td>
+ <td class="cell80">This implements a dispatch
+interceptor for a specific URL.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/JavaWindowPeerFake.java"
+ title="link to OfficeDev/DesktopEnvironment/JavaWindowPeerFake.java">JavaWindowPeerFake</a></td>
+ <td class="cell80">Fakes an <a
+ href="../../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 %PRODUCT_RELEASE% and exports its UNO service manager for the Java side of
+the application.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/OnewayExecutor.java"
+ title="link to OfficeDev/DesktopEnvironment/OnewayExecutor.java">OnewayExecutor</a></td>
+ <td class="cell80">Implements <code>IOnewayLink</code>
+to decouple asynchronous oneway calls in the Java process.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/StatusListener.java"
+ title="link to OfficeDev/DesktopEnvironment/StatusListener.java">StatusListener</a></td>
+ <td class="cell80">Implements a listener for a <a
+ href="../../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 %PRODUCT_RELEASE% shutdown.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Office Development Examples</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/OfficeConnect.java"
+ title="link to OfficeDev/OfficeConnect.java">OfficeConnect</a></td>
+ <td class="cell80">Builds the remote bridge to
+OpenOffice.org %PRODUCT_RELEASE% and exports its UNO service manager to the Java side.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./OfficeDev/ContextMenuInterceptor.java"
+ title="link to OfficeDev/ContextMenuInterceptor.java">ContextMenuInterceptor</a></td>
+ <td class="cell80">This example shows a context menu
+interceptor that creates a new menu entry that has a sub menu. This sub
+menu is in inserted into the context menu on the topmost position. It
+provides some helper functions to the user that are reachable through
+the menu Help.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/MenuElement.java"
+ title="link to OfficeDev/MenuElement.java">MenuElement</a></td>
+ <td class="cell80">A helper class for the context
+menu interceptor example. It determines the menu element type.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./OfficeDev/Number_Formats.java"
+ title="link to OfficeDev/Number_Formats.java">Number_Formats</a></td>
+ <td class="cell80">Demonstrates the use of number
+formats in a spreadsheet document.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Termination Test Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./OfficeDev/TerminationTest/TerminationTest.java"
+ title="link to OfficeDev/TerminationTest/TerminationTest.java">TerminationTest</a></td>
+ <td class="cell80">This example uses the
+TerminateListener and shows the use of them in a running program.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/TerminationTest/TerminateListener.java"
+ title="link to OfficeDev/TerminationTest/TerminateListener.java">TerminateListener</a></td>
+ <td class="cell80">An example implementation of <a
+ href="../../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 %PRODUCT_RELEASE% terminates.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Clipboard Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./OfficeDev/Clipboard/Clipboard.java"
+ title="link to OfficeDev/Clipboard/Clipboard.java">Clipboard</a></td>
+ <td class="cell80">Demonstrates the usage of the
+clipboard service by registering a clipboard listener, getting a list
+of formats from the current clipboard content and copying some data to
+the clipboard.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Clipboard/ClipboardListener.java"
+ title="link to OfficeDev/Clipboard/ClipboardListener.java">ClipboardListener</a></td>
+ <td class="cell80">Implements a clipboard listener
+for the Clipboard example. In such a class, actions can be implemented
+which happen whenever the clipboard content changes.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Clipboard/ClipboardOwner.java"
+ title="link to OfficeDev/Clipboard/ClipboardOwner.java">ClipboardOwner</a></td>
+ <td class="cell80">Implements a clipboard owner for
+the Clipboard example. This class is notified when it loses ownership
+of the clipboard.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Clipboard/TextTransferable.java"
+ title="link to OfficeDev/Clipboard/TextTransferable.java">TextTransferable</a></td>
+ <td class="cell80">Implements a data object for the
+Clipboard example. Such classes supply clients with data in a variety
+of formats.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Linguistic Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./OfficeDev/Linguistic/LinguisticExamples.java"
+ title="link to OfficeDev/Linguistic/LinguisticExamples.java">LinguisticExamples</a></td>
+ <td class="cell80">A short example that uses most of
+the functionality from the OpenOffice.org %PRODUCT_RELEASE% linguistic API.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Linguistic/OneInstanceFactory.java"
+ title="link to OfficeDev/Linguistic/OneInstanceFactory.java">OneInstanceFactory</a></td>
+ <td class="cell80">This class is used to provide a
+service factory for the linguistic services. It enforces that the
+actual implementations are only instantiated once.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Linguistic/PropChgHelper.java"
+ title="link to OfficeDev/Linguistic/PropChgHelper.java">PropChgHelper</a></td>
+ <td class="cell80">The base class for several
+property change helpers which are used to keep track of the changes of
+the service relevant linguistic properties. It is also used by the
+thesaurus directly.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Linguistic/PropChgHelper_Hyph.java"
+ title="link to OfficeDev/Linguistic/PropChgHelper_Hyph.java">PropChgHelper_Hyph</a></td>
+ <td class="cell80">The property change helper that is
+tracking the hyphenation relevant properties.</td>
+ </tr>
+ <tr>
+ </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 %PRODUCT_RELEASE% and open or create a drawing
+document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./Drawing/LayerDemo.java" title="link to Drawing/LayerDemo.java">LayerDemo</a></td>
+ <td class="cell80">Creates shapes in different layers
+to show how to protect shapes from modifications.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./Drawing/ObjectTransformationDemo.java"
+ title="link to Drawing/ObjectTransformationDemo.java">ObjectTransformationDemo</a></td>
+ <td class="cell80">Shows geometric transformations on
+a shape using a 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 %PRODUCT_RELEASE% and create text, drawing or spreadsheet document. This
+class is used as a helper class for the other examples.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Charts/JavaSampleChartAddIn.java"
+ title="link to Charts/JavaSampleChartAddIn.java">JavaSampleChartAddIn</a></td>
+ <td class="cell80">Gives an example of how to
+implement chart add-ins to create new or specialized diagram types. The
+resulting component has to be deployed before it can be used.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./Charts/ListenAtCalcRangeInDraw.java"
+ title="link to Charts/ListenAtCalcRangeInDraw.java">ListenAtCalcRangeInDraw</a></td>
+ <td class="cell80">This helper class is used to build
+connection between an embedded chart object in a drawing document and a
+data range in a spreadsheet document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./Charts/SelectionChangeListener.java"
+ title="link to Charts/SelectionChangeListener.java">SelectionChangeListener</a></td>
+ <td class="cell80">Shows how to register a handler
+which is called when the selection within an embedded chart object
+changes.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a
+ name="BasicandDialogs">OpenOffice.org %PRODUCT_RELEASE% Basic and Dialogs examples</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./BasicAndDialogs/FirstStepsBasic.odt"
+ title="link to BasicAndDialogs/FirstStepsBasic.odt">FirstStepsBasic.odt</a></td>
+ <td class="cell80">This 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 %PRODUCT_RELEASE% and executes the code SalesMan samples for database API.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./Database/OpenQuery.java"
+ title="link to Database/OpenQuery.java">OpenQuery</a></td>
+ <td class="cell80">Demonstrates the use of <a
+ href="../../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 %PRODUCT_RELEASE%, gets the configuration manager and accesses the
+configuration in various ways.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a name="OfficeBean">Office
+Bean example</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20"> Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./OfficeBean/OOoBeanViewer.java"
+ title="link to OfficeBean/OOoBeanViewer.java">OOoBeanViewer</a></td>
+ <td class="cell80">Shows how to use the <code>OOoBean</code>
+embedded in a Java AWT component. It shows how to load and store
+documents as well as how to control toolbar visibility.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a name="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>
diff --git a/odk/examples/OLE/activex/Makefile b/odk/examples/OLE/activex/Makefile
new file mode 100644
index 000000000000..815fa86b9783
--- /dev/null
+++ b/odk/examples/OLE/activex/Makefile
@@ -0,0 +1,122 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (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 OLE activex 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
+COMPONENT_NAME=so_activex
+COMPONENT_IMPL_NAME=$(SHAREDLIB_PRE)$(COMPONENT_NAME).$(SHAREDLIB_EXT)
+COMPONENT_IMPL=$(SHAREDLIB_OUT)/$(SHAREDLIB_PRE)$(COMPONENT_NAME).$(SHAREDLIB_EXT)
+OUT_COMP_INC = $(OUT_INC)/$(COMPONENT_NAME)
+OUT_COMP_GEN = $(OUT_MISC)/$(COMPONENT_NAME)
+OUT_COMP_SLO=$(OUT_SLO)/$(COMPONENT_NAME)
+
+MIDLFILES = so_activex.idl
+
+CXXFILES = SOActiveX.cpp \
+ SOComWindowPeer.cpp \
+ so_activex.cpp \
+ StdAfx2.cpp
+
+SLOFILES = $(patsubst %.cpp,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
+
+# Targets
+.PHONY: ALL
+ALL : \
+ OleActvieXComponentExample
+
+include $(SETTINGS)/stdtarget.mk
+
+# Attention: so_activex.idl is no UNOIDL file!
+$(OUT_COMP_INC)/so_activex.h : so_activex.idl
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
+ midl.exe /tlb $(OUT_COMP_GEN)/so_activex.tlb /h $(OUT_COMP_INC)/so_activex.h \
+ /iid $(OUT_COMP_INC)/so_activex_i.c /proxy $(OUT_COMP_INC)/so_activex_p.c \
+ /dlldata $(OUT_COMP_INC)/dlldata.c /Oicf $<
+
+$(OUT_COMP_GEN)/so_activex.res : so_activex.rc $(OUT_COMP_INC)/so_activex.h
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ rc $(CC_INCLUDES) /R /FO$@ so_activex.rc
+
+$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cpp
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+
+
+# Note: If you don't use the MS Visual Studio .Net, please comment out the next line.
+CL_NEW_LIB=atls.lib
+
+$(SHAREDLIB_OUT)/$(SHAREDLIB_PRE)%.$(SHAREDLIB_EXT) : $(SLOFILES) $(OUT_COMP_GEN)/so_activex.res so_activex.def
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(OUT_LIB))
+ @echo .
+ @echo -----------------------------------------------------------------------------------
+ @echo ATTENTION: If you have problems with linking the library and if you do not use the
+ @echo MS .Net compiler please check the makefile and comment out the variable CL_NEW_LIB.
+ @echo -----------------------------------------------------------------------------------
+ @echo .
+ $(LINK) $(LIBRARY_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) \
+ /DEF:so_activex.def /IMPLIB:$(OUT_LIB)/iso_activex.lib $(SLOFILES) \
+ msvcrt.lib kernel32.lib user32.lib uuid.lib advapi32.lib ole32.lib oleaut32.lib gdi32.lib \
+ urlmon.lib Shlwapi.lib oldnames.lib $(CL_NEW_LIB) $(OUT_COMP_GEN)/so_activex.res
+ $(LINK_MANIFEST)
+
+ifeq "$(OS)" "WIN"
+OleActvieXComponentExample : $(COMPONENT_IMPL)
+ @echo --------------------------------------------------------------------------------
+ @echo The activex control was created, please load the "$(QM)example.html$(QM)" file
+ @echo in your InternetExplorer to use the activex control.
+ @echo --------------------------------------------------------------------------------
+else
+OleActvieXComponentExample :
+ @echo --------------------------------------------------------------------------------
+ @echo This example works only under Windows!
+ @echo --------------------------------------------------------------------------------
+endif
+
+.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),$(OUT_LIB)/*$(COMPONENT_NAME).*))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(SHAREDLIB_PRE)$(COMPONENT_NAME).*))
diff --git a/odk/examples/OLE/activex/README.txt b/odk/examples/OLE/activex/README.txt
new file mode 100644
index 000000000000..b8be6fcbc9cb
--- /dev/null
+++ b/odk/examples/OLE/activex/README.txt
@@ -0,0 +1,39 @@
+ Compile.
+Warning: Before the control can be built user has to add path to MS ATL headers
+ into Makefile.
+
+If you use the build environment of the SDK you have to check which MS compiler
+do you use. It you use the MS Visual Studio .NET compiler everything should work
+fine with the SDK. If you use an older MS compiler please edit the Makefile and
+uncomment or remove the line 'CL_NEW_LIB=atls.lib'.
+
+ Description.
+
+The StarOffice ActiveX control shows an example of access to UNO through COM technology.
+It requires a properly installed StarOffice version 6.0/6.1 or OpenOffice 1.0.
+This is a Lite ActiveX control so it can be used only in containers that
+allows to use such controls. It can be activated with an <OBJECT> tag from
+a html-page to embed a document. Without any parameters a new writer document will be
+opened for editing. Possible parameters are
+ src - full URL to the file that should be edited/viewed;
+ it can contain "private:factory/..." URLs to open new documents
+ for edit, for example "private:factory/swriter"
+ readonly - if it is set to "true" the document will be opened readonly,
+ otherwise the document will be opened for editing.
+
+The control can be extended easily, for example it can be changed
+to allow scripting to load different documents.
+
+As any ActiveX control this one should be registered.
+To let MSIE register it itself the "CODEBASE" parameter
+for the "OBJECT" tag should be specified
+with an URL to the library "so_activex.dll".
+
+Also it can be done using regsvr32 application.
+To do it please write
+<Path to Windows installation>\System32\regsvr32 so_activex.dll
+
+To unregister the control please use /u option:
+<Path to Windows installation>\system32\regsvr32 so_activex.dll /u
+
+
diff --git a/odk/examples/OLE/activex/SOActiveX.cpp b/odk/examples/OLE/activex/SOActiveX.cpp
new file mode 100644
index 000000000000..bdef49740ea1
--- /dev/null
+++ b/odk/examples/OLE/activex/SOActiveX.cpp
@@ -0,0 +1,645 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// SOActiveX.cpp : Implementation of CSOActiveX
+
+#include "stdafx2.h"
+#include "so_activex.h"
+#include "SOActiveX.h"
+#include "SOComWindowPeer.h"
+
+#define STAROFFICE_WINDOWCLASS "SOParentWindow"
+
+#define BARS_NUMBER 3
+#define BARS_TO_SHOW 2
+
+OLECHAR* pSlotUrl[BARS_NUMBER] =
+ {L"slot:5910" // SID_TOGGLEFUNCTIONBAR
+ ,L"slot:5920" // SID_TOGGLESTATUSBAR
+ ,L"slot:6661" // SID_TOGGLE_MENUBAR
+// ,L"slot:10603" // SID_HYPERLINK_INSERT
+ };
+
+OLECHAR* pSlotName[BARS_NUMBER] =
+ {L"FunctionBarVisible" // SID_TOGGLEFUNCTIONBAR
+ ,L"StatusBarVisible" // SID_TOGGLESTATUSBAR
+ ,L"MenuBarVisible" // SID_TOGGLE_MENUBAR
+// ,L"InsertHyperlink" // SID_HYPERLINK_INSERT
+ };
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+HRESULT ExecuteFunc( IDispatch* idispUnoObject,
+ OLECHAR* sFuncName,
+ CComVariant* params,
+ unsigned int count,
+ CComVariant* pResult )
+{
+ if( !idispUnoObject )
+ return E_FAIL;
+
+ DISPID id;
+ HRESULT hr = idispUnoObject->GetIDsOfNames( IID_NULL, &sFuncName, 1, LOCALE_USER_DEFAULT, &id);
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ DISPPARAMS dispparams= { params, 0, count, 0};
+
+ // DEBUG
+ EXCEPINFO myInfo;
+ return idispUnoObject->Invoke( id, IID_NULL,LOCALE_USER_DEFAULT, DISPATCH_METHOD,
+ &dispparams, pResult, &myInfo, 0);
+}
+
+HRESULT GetIDispByFunc( IDispatch* idispUnoObject,
+ OLECHAR* sFuncName,
+ CComVariant* params,
+ unsigned int count,
+ CComPtr<IDispatch>& pdispResult )
+{
+ if( !idispUnoObject )
+ return E_FAIL;
+
+ CComVariant result;
+ HRESULT hr = ExecuteFunc( idispUnoObject, sFuncName, params, count, &result );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ if( result.vt != VT_DISPATCH || result.pdispVal == NULL )
+ return hr;
+
+ pdispResult = CComPtr<IDispatch>( result.pdispVal );
+
+ return S_OK;
+}
+
+HRESULT PutPropertiesToIDisp( IDispatch* pdispObject,
+ OLECHAR** sMemberNames,
+ CComVariant* pVariant,
+ unsigned int count )
+{
+ for( unsigned int ind = 0; ind < count; ind++ )
+ {
+ DISPID id;
+ HRESULT hr = pdispObject->GetIDsOfNames( IID_NULL, &sMemberNames[ind], 1, LOCALE_USER_DEFAULT, &id );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ hr = CComDispatchDriver::PutProperty( pdispObject, id, &pVariant[ind] );
+ if( !SUCCEEDED( hr ) ) return hr;
+ }
+
+ return S_OK;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// CSOActiveX
+
+CSOActiveX::CSOActiveX()
+: mCookie(0)
+, mCurFileUrl( L"private:factory/swriter" )
+, mbLoad( FALSE )
+, mParentWin( NULL )
+, mOffWin( NULL )
+, mbViewOnly( FALSE )
+{
+ CLSID clsFactory = {0x82154420,0x0FBF,0x11d4,{0x83, 0x13,0x00,0x50,0x04,0x52,0x6A,0xB4}};
+ HRESULT hr = CoCreateInstance( clsFactory, NULL, CLSCTX_ALL, __uuidof(IDispatch), (void**)&mpDispFactory);
+
+ mPWinClass.style = CS_HREDRAW|CS_VREDRAW;
+ mPWinClass.lpfnWndProc = ::DefWindowProc;
+ mPWinClass.cbClsExtra = 0;
+ mPWinClass.cbWndExtra = 0;
+ mPWinClass.hInstance = (HINSTANCE) GetModuleHandle(NULL); //myInstance;
+ mPWinClass.hIcon = NULL;
+ mPWinClass.hCursor = NULL;
+ mPWinClass.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
+ mPWinClass.lpszMenuName = NULL;
+ mPWinClass.lpszClassName = STAROFFICE_WINDOWCLASS;
+
+ RegisterClass(&mPWinClass);
+}
+
+CSOActiveX::~CSOActiveX()
+{
+ Cleanup();
+
+}
+
+HRESULT CSOActiveX::Cleanup()
+{
+ if( mpDispFrame && mbViewOnly )
+ {
+ ShowSomeBars();
+ mbViewOnly = FALSE;
+ }
+
+ if( mpDispFrame )
+ {
+ // mpDispFrame->dispose();
+ CComVariant dummyResult;
+ ExecuteFunc( mpDispFrame, L"dispose", NULL, 0, &dummyResult );
+ mpDispFrame = CComPtr< IDispatch >();
+ }
+
+ if( ::IsWindow( mOffWin ) )
+ ::DestroyWindow( mOffWin );
+
+ return S_OK;
+}
+
+
+STDMETHODIMP CSOActiveX::InitNew ()
+{
+ mbLoad = TRUE;
+ return S_OK;
+}
+
+STDMETHODIMP CSOActiveX::Load ( LPSTREAM pStm )
+{
+ mbLoad = TRUE;
+
+ // may be later?
+ // for now just ignore
+
+ return S_OK;
+}
+
+STDMETHODIMP CSOActiveX::Load( LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog )
+{
+ IPropertyBag2* pPropBag2;
+ HRESULT hr = pPropBag->QueryInterface( IID_IPropertyBag2, (void**)&pPropBag2 );
+ ATLASSERT( hr >= 0 );
+
+ if( !SUCCEEDED( hr ) )
+ return hr;
+
+ unsigned long aNum;
+ hr = pPropBag2->CountProperties( &aNum );
+ ATLASSERT( hr >= 0 );
+ if( !SUCCEEDED( hr ) )
+ return hr;
+
+ PROPBAG2* aPropNames = new PROPBAG2[aNum];
+ unsigned long aReaded;
+
+ hr = pPropBag2->GetPropertyInfo( 0,
+ aNum,
+ aPropNames,
+ &aReaded );
+ ATLASSERT( hr >= 0 );
+ if( !SUCCEEDED( hr ) )
+ {
+ delete[] aPropNames;
+ return hr;
+ }
+
+ CComVariant* aVal = new CComVariant[aNum];
+ HRESULT* hvs = new HRESULT[aNum];
+ hr = pPropBag2->Read( aNum,
+ aPropNames,
+ NULL,
+ aVal,
+ hvs );
+ ATLASSERT( hr >= 0 );
+ if( !SUCCEEDED( hr ) )
+ {
+ delete[] hvs;
+ delete[] aVal;
+ delete[] aPropNames;
+ return hr;
+ }
+
+ USES_CONVERSION;
+ for( unsigned long ind = 0; ind < aNum; ind++ )
+ {
+ // all information from the 'object' tag is in strings
+ if( aVal[ind].vt == VT_BSTR && !strcmp( OLE2T( aPropNames[ind].pstrName ), "src" ) )
+ {
+ mCurFileUrl = wcsdup( aVal[ind].bstrVal );
+ }
+ else if( aVal[ind].vt == VT_BSTR
+ && !strcmp( OLE2T( aPropNames[ind].pstrName ), "readonly" ) )
+ {
+ if( !strcmp( OLE2T( aVal[ind].bstrVal ), "true" ) )
+ {
+ mbViewOnly = TRUE;
+ }
+ else
+ {
+ // the default value
+ mbViewOnly = FALSE;
+ }
+ }
+ }
+
+ delete[] hvs;
+ delete[] aVal;
+ delete[] aPropNames;
+
+ if( !mpDispFactory )
+ return hr;
+
+ mbLoad = TRUE;
+
+ Invalidate();
+ UpdateWindow();
+
+ return hr;
+}
+
+HRESULT CSOActiveX::GetUnoStruct( OLECHAR* sStructName, CComPtr<IDispatch>& pdispResult )
+{
+ return GetIDispByFunc( mpDispFactory, L"Bridge_GetStruct", &CComVariant( sStructName ), 1, pdispResult );
+}
+
+HRESULT CSOActiveX::GetUrlStruct( OLECHAR* sUrl, CComPtr<IDispatch>& pdispUrl )
+{
+ HRESULT hr = GetUnoStruct( L"com.sun.star.util.URL", pdispUrl );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ OLECHAR* sURLMemberName = L"Complete";
+ DISPID nURLID;
+ hr = pdispUrl->GetIDsOfNames( IID_NULL, &sURLMemberName, 1, LOCALE_USER_DEFAULT, &nURLID );
+ if( !SUCCEEDED( hr ) ) return hr;
+ hr = CComDispatchDriver::PutProperty( pdispUrl, nURLID, &CComVariant( sUrl ) );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ CComPtr<IDispatch> pdispTransformer;
+ hr = GetIDispByFunc( mpDispFactory,
+ L"createInstance",
+ &CComVariant( L"com.sun.star.util.URLTransformer" ),
+ 1,
+ pdispTransformer );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ CComVariant dummyResult;
+ CComVariant aInOutParam;
+ aInOutParam.ppdispVal = &pdispUrl;
+ aInOutParam.vt = VT_DISPATCH | VT_BYREF;
+ hr = ExecuteFunc( pdispTransformer, L"parseStrict", &aInOutParam, 1, &dummyResult );
+ if( !SUCCEEDED( hr ) || dummyResult.vt != VT_BOOL || !dummyResult.boolVal ) return hr;
+
+ return S_OK;
+}
+
+
+HRESULT CSOActiveX::CreateFrameOldWay( HWND hwnd, int width, int height )
+{
+ if( !mpDispFactory )
+ return E_FAIL;
+
+ // create window handle holder
+ CComPtr< CComObject< SOComWindowPeer > > pPeerToSend = new CComObject<SOComWindowPeer>( hwnd );
+ pPeerToSend->SetHWNDInternally( hwnd );
+ CComQIPtr< IDispatch, &IID_IDispatch > pIDispToSend( pPeerToSend );
+
+ // create rectangle structure
+ CComPtr<IDispatch> pdispRectangle;
+ HRESULT hr = GetUnoStruct( L"com.sun.star.awt.Rectangle", pdispRectangle );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ OLECHAR* sRectMemberNames[4] = { L"X",
+ L"Y",
+ L"Width",
+ L"Height" };
+ CComVariant pRectVariant[4];
+ pRectVariant[0] = pRectVariant[1] = pRectVariant[2] = pRectVariant[3] = CComVariant( 0 );
+
+ hr = PutPropertiesToIDisp( pdispRectangle, sRectMemberNames, pRectVariant, 4 );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create WindowDescriptor structure
+ CComPtr<IDispatch> pdispWinDescr;
+ hr = GetUnoStruct( L"com.sun.star.awt.WindowDescriptor", pdispWinDescr );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // fill in descriptor with info
+ OLECHAR* sDescriptorMemberNames[6] = { L"Type",
+ L"WindowServiceName",
+ L"ParentIndex",
+ L"Parent",
+ L"Bounds",
+ L"WindowAttributes" };
+ CComVariant pDescriptorVar[6];
+ pDescriptorVar[0] = CComVariant( 0 );
+ pDescriptorVar[1] = CComVariant( L"workwindow" );
+ pDescriptorVar[2] = CComVariant( 1 );
+ pDescriptorVar[3] = CComVariant( pIDispToSend );
+ pDescriptorVar[4] = CComVariant( pdispRectangle );
+ pDescriptorVar[5] = CComVariant( 33 );
+ hr = PutPropertiesToIDisp( pdispWinDescr, sDescriptorMemberNames, pDescriptorVar, 6 );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create XToolkit instance
+ CComPtr<IDispatch> pdispToolkit;
+ hr = GetIDispByFunc( mpDispFactory, L"createInstance", &CComVariant( L"com.sun.star.awt.Toolkit" ), 1, pdispToolkit );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create window with toolkit
+ hr = GetIDispByFunc( pdispToolkit, L"createWindow", &CComVariant( pdispWinDescr ), 1, mpDispWin );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create frame
+ hr = GetIDispByFunc( mpDispFactory, L"createInstance", &CComVariant( L"com.sun.star.frame.Task" ), 1, mpDispFrame );
+ if( !SUCCEEDED( hr ) || !mpDispFrame )
+ {
+ // the interface com.sun.star.frame.Task is removed in 6.1
+ // but the interface com.sun.star.frame.Frame has some bugs in 6.0
+ hr = GetIDispByFunc( mpDispFactory, L"createInstance", &CComVariant( L"com.sun.star.frame.Frame" ), 1, mpDispFrame );
+ if( !SUCCEEDED( hr ) ) return hr;
+ }
+
+ // initialize frame
+ CComVariant dummyResult;
+ hr = ExecuteFunc( mpDispFrame, L"initialize", &CComVariant( mpDispWin ), 1, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create desktop
+ CComPtr<IDispatch> pdispDesktop;
+ hr = GetIDispByFunc( mpDispFactory, L"createInstance", &CComVariant( L"com.sun.star.frame.Desktop" ), 1, pdispDesktop );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create tree of frames
+ CComPtr<IDispatch> pdispChildren;
+ hr = GetIDispByFunc( pdispDesktop, L"getFrames", NULL, 0, pdispChildren );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // insert new frame into desctop hierarchy
+ hr = ExecuteFunc( pdispChildren, L"append", &CComVariant( mpDispFrame ), 1, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // initialize window
+ hr = ExecuteFunc( mpDispWin, L"setBackground", &CComVariant( (long)0xFFFFFFFF ), 1, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ hr = ExecuteFunc( mpDispWin, L"setVisible", &CComVariant( TRUE ), 1, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ CComVariant aPosArgs[5];
+ aPosArgs[4] = CComVariant( 0 );
+ aPosArgs[3] = CComVariant( 0 );
+ aPosArgs[2] = CComVariant( width );
+ aPosArgs[1] = CComVariant( height );
+ aPosArgs[0] = CComVariant( 12 );
+ hr = ExecuteFunc( mpDispWin, L"setPosSize", aPosArgs, 5, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+
+ return S_OK;
+}
+
+HRESULT CSOActiveX::CallDispatch1PBool( OLECHAR* sUrl, OLECHAR* sArgName, BOOL sArgVal )
+{
+ CComPtr<IDispatch> pdispURL;
+ HRESULT hr = GetUrlStruct( sUrl, pdispURL );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ CComPtr<IDispatch> pdispXDispatch;
+ CComVariant aArgs[3];
+ aArgs[2] = CComVariant( pdispURL );
+ aArgs[1] = CComVariant( L"" );
+ aArgs[0] = CComVariant( (int)0 );
+ hr = GetIDispByFunc( mpDispFrame,
+ L"queryDispatch",
+ aArgs,
+ 3,
+ pdispXDispatch );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ SAFEARRAY FAR* pPropVals = SafeArrayCreateVector( VT_DISPATCH, 0, 1 );
+ long ix = 0;
+ CComPtr<IDispatch> pdispPropVal;
+ hr = GetUnoStruct( L"com.sun.star.beans.PropertyValue", pdispPropVal );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ OLECHAR* sPropMemberNames[2] = { L"Name", L"Value" };
+ CComVariant pPropVar[2];
+ pPropVar[0] = CComVariant( sArgName );
+ pPropVar[1] = CComVariant(); pPropVar[1].vt = VT_BOOL; pPropVar[1].boolVal = sArgVal ? VARIANT_TRUE : VARIANT_FALSE ;
+ hr = PutPropertiesToIDisp( pdispPropVal, sPropMemberNames, pPropVar, 2 );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ SafeArrayPutElement( pPropVals, &ix, pdispPropVal );
+
+ CComVariant aDispArgs[2];
+ aDispArgs[1] = CComVariant( pdispURL );
+ // aDispArgs[0] = CComVariant( pPropVals ); such constructor is not defined ??!
+ aDispArgs[0] = CComVariant(); aDispArgs[0].vt = VT_ARRAY | VT_DISPATCH; aDispArgs[0].parray = pPropVals;
+
+ CComVariant dummyResult;
+ hr = ExecuteFunc( pdispXDispatch, L"dispatch", aDispArgs, 2, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ return S_OK;
+}
+
+HRESULT CSOActiveX::ShowSomeBars()
+{
+ // show FunctionBar and StatusBar
+ for( int ind = 0; ind < BARS_TO_SHOW; ind ++ )
+ {
+ HRESULT hr = CallDispatch1PBool( pSlotUrl[ind], pSlotName[ind], TRUE );
+ if( !SUCCEEDED( hr ) ) return hr;
+ }
+
+ return S_OK;
+}
+
+HRESULT CSOActiveX::HideAllBars()
+{
+ for( int ind = 0; ind < BARS_NUMBER; ind ++ )
+ {
+ HRESULT hr = CallDispatch1PBool( pSlotUrl[ind], pSlotName[ind], FALSE );
+ if( !SUCCEEDED( hr ) ) return hr;
+ }
+
+ return S_OK;
+}
+
+HRESULT CSOActiveX::LoadURLToFrame( )
+{
+ HRESULT hr = CallDispatch1PBool( mCurFileUrl, L"ReadOnly", mbViewOnly );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ if( mbViewOnly )
+ HideAllBars();
+
+ return S_OK;
+}
+
+HRESULT CSOActiveX::OnDrawAdvanced( ATL_DRAWINFO& di )
+{
+ if( m_spInPlaceSite && mCurFileUrl )
+ {
+ HWND hwnd;
+ HRESULT hr = m_spInPlaceSite->GetWindow( &hwnd );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ if( mParentWin != hwnd || !mOffWin )
+ {
+ if( mpDispFrame )
+ {
+ CComVariant dummyResult;
+ ExecuteFunc( mpDispFrame, L"dispose", NULL, 0, &dummyResult );
+ mpDispFrame = CComPtr<IDispatch>();
+ }
+
+ mParentWin = hwnd;
+ mOffWin = CreateWindow(
+ STAROFFICE_WINDOWCLASS,
+ "OfficeContainer",
+ WS_CHILD | WS_CLIPCHILDREN | WS_BORDER,
+ di.prcBounds->left,
+ di.prcBounds->top,
+ di.prcBounds->right - di.prcBounds->left,
+ di.prcBounds->bottom - di.prcBounds->top,
+ mParentWin,
+ NULL,
+ NULL,
+ NULL );
+
+ ::ShowWindow( mOffWin, SW_SHOW );
+ }
+ else
+ {
+ RECT aRect;
+ ::GetWindowRect( mOffWin, &aRect );
+
+ if( aRect.left != di.prcBounds->left || aRect.top != di.prcBounds->top
+ || aRect.right != di.prcBounds->right || aRect.bottom != di.prcBounds->bottom )
+ {
+ // on this state the office window should exist already
+ ::SetWindowPos( mOffWin,
+ HWND_TOP,
+ di.prcBounds->left,
+ di.prcBounds->top,
+ di.prcBounds->right - di.prcBounds->left,
+ di.prcBounds->bottom - di.prcBounds->top,
+ SWP_NOZORDER );
+
+ CComVariant aPosArgs[5];
+ aPosArgs[4] = CComVariant( 0 );
+ aPosArgs[3] = CComVariant( 0 );
+ aPosArgs[2] = CComVariant( int(di.prcBounds->right - di.prcBounds->left) );
+ aPosArgs[1] = CComVariant( int(di.prcBounds->bottom - di.prcBounds->top) );
+ aPosArgs[0] = CComVariant( 12 );
+ CComVariant dummyResult;
+ hr = ExecuteFunc( mpDispWin, L"setPosSize", aPosArgs, 5, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+ }
+ }
+
+ if( ! mpDispFrame )
+ {
+ hr = CreateFrameOldWay( mOffWin,
+ di.prcBounds->right - di.prcBounds->left,
+ di.prcBounds->bottom - di.prcBounds->top );
+ if( !SUCCEEDED( hr ) ) return hr;
+ }
+
+ if( mbLoad )
+ {
+ hr = LoadURLToFrame();
+ if( !SUCCEEDED( hr ) ) return hr;
+ mbLoad = FALSE;
+ }
+ }
+
+ return S_OK;
+}
+
+
+STDMETHODIMP CSOActiveX::SetClientSite( IOleClientSite* aClientSite )
+{
+ HRESULT hr = IOleObjectImpl<CSOActiveX>::SetClientSite( aClientSite );
+
+ if( !aClientSite )
+ {
+ ATLASSERT( mWebBrowser2 );
+ if( mWebBrowser2 )
+ AtlUnadvise( mWebBrowser2, DIID_DWebBrowserEvents2, mCookie );
+ return hr;
+ }
+
+ CComPtr<IOleContainer> aContainer;
+ m_spClientSite->GetContainer( &aContainer );
+ ATLASSERT( aContainer );
+
+ if( SUCCEEDED( hr ) && aContainer )
+ {
+ CComQIPtr<IServiceProvider, &IID_IServiceProvider> aServiceProvider( aContainer );
+ ATLASSERT( aServiceProvider );
+
+ if( aServiceProvider )
+ {
+ aServiceProvider->QueryService( SID_SInternetExplorer,
+ IID_IWebBrowser,
+ (void**)&mWebBrowser2 );
+ ATLASSERT( mWebBrowser2 );
+ if( mWebBrowser2 )
+ AtlAdvise( mWebBrowser2, GetUnknown(), DIID_DWebBrowserEvents2, &mCookie );
+ }
+ }
+
+ return hr;
+}
+
+STDMETHODIMP CSOActiveX::Invoke(DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ DISPPARAMS* pDispParams,
+ VARIANT* pvarResult,
+ EXCEPINFO* pExcepInfo,
+ UINT* puArgErr)
+{
+ if (riid != IID_NULL)
+ return DISP_E_UNKNOWNINTERFACE;
+
+ if (!pDispParams)
+ return DISP_E_PARAMNOTOPTIONAL;
+
+ if ( dispidMember == DISPID_ONQUIT )
+ Cleanup();
+
+ IDispatchImpl<ISOActiveX, &IID_ISOActiveX,
+ &LIBID_SO_ACTIVEXLib>::Invoke(
+ dispidMember, riid, lcid, wFlags, pDispParams,
+ pvarResult, pExcepInfo, puArgErr);
+
+ return S_OK;
+}
+
+// ---------------------------------------------------------------------------
+
diff --git a/odk/examples/OLE/activex/SOActiveX.h b/odk/examples/OLE/activex/SOActiveX.h
new file mode 100644
index 000000000000..8b587217cf03
--- /dev/null
+++ b/odk/examples/OLE/activex/SOActiveX.h
@@ -0,0 +1,166 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// SOActiveX.h : Declaration of the CSOActiveX
+
+#ifndef __SOACTIVEX_H_
+#define __SOACTIVEX_H_
+
+#include "resource.h" // main symbols
+#include <ExDispID.h>
+#include <ExDisp.h>
+#include <shlguid.h>
+#include <atlctl.h>
+
+#include "so_activex.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// CSOActiveX
+class ATL_NO_VTABLE CSOActiveX :
+ public CComObjectRootEx<CComSingleThreadModel>,
+ public IDispatchImpl<ISOActiveX, &IID_ISOActiveX, &LIBID_SO_ACTIVEXLib>,
+ public CComControl<CSOActiveX>,
+ public IPersistStreamInitImpl<CSOActiveX>,
+ public IOleControlImpl<CSOActiveX>,
+ public IOleObjectImpl<CSOActiveX>,
+ public IOleInPlaceActiveObjectImpl<CSOActiveX>,
+ public IViewObjectExImpl<CSOActiveX>,
+ public IOleInPlaceObjectWindowlessImpl<CSOActiveX>,
+// public IConnectionPointContainerImpl<CSOActiveX>,
+ public CComCoClass<CSOActiveX, &CLSID_SOActiveX>,
+// public CProxy_ItryPluginEvents< CSOActiveX >,
+ public IPersistPropertyBagImpl< CSOActiveX >,
+ public IProvideClassInfo2Impl< &CLSID_SOActiveX,
+ &DIID__ISOActiveXEvents,
+ &LIBID_SO_ACTIVEXLib >,
+ public IObjectSafetyImpl< CSOActiveX,
+ INTERFACESAFE_FOR_UNTRUSTED_DATA >
+{
+protected:
+ CComPtr<IWebBrowser2> mWebBrowser2;
+ DWORD mCookie;
+
+ CComPtr<IDispatch> mpDispFactory;
+ CComPtr<IDispatch> mpDispFrame;
+ CComPtr<IDispatch> mpDispWin;
+ OLECHAR* mCurFileUrl;
+ BOOL mbLoad;
+ BOOL mbViewOnly;
+ WNDCLASS mPWinClass;
+ HWND mParentWin;
+ HWND mOffWin;
+public:
+ CSOActiveX();
+ ~CSOActiveX();
+
+DECLARE_REGISTRY_RESOURCEID(IDR_SOACTIVEX)
+
+DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+BEGIN_COM_MAP(CSOActiveX)
+ COM_INTERFACE_ENTRY(ISOActiveX)
+ COM_INTERFACE_ENTRY(IDispatch)
+ COM_INTERFACE_ENTRY(IViewObjectEx)
+ COM_INTERFACE_ENTRY(IViewObject2)
+ COM_INTERFACE_ENTRY(IViewObject)
+ COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
+ COM_INTERFACE_ENTRY(IOleInPlaceObject)
+ COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
+ COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
+ COM_INTERFACE_ENTRY(IOleControl)
+ COM_INTERFACE_ENTRY(IOleObject)
+ COM_INTERFACE_ENTRY(IPersistStreamInit)
+ COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
+// COM_INTERFACE_ENTRY(IConnectionPointContainer)
+ COM_INTERFACE_ENTRY(IProvideClassInfo)
+ COM_INTERFACE_ENTRY(IProvideClassInfo2)
+ COM_INTERFACE_ENTRY(IPersistPropertyBag)
+ COM_INTERFACE_ENTRY(IObjectSafety)
+END_COM_MAP()
+
+BEGIN_PROP_MAP(CSOActiveX)
+ PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
+ PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
+ // Example entries
+ // PROP_ENTRY("Property Description", dispid, clsid)
+ // PROP_PAGE(CLSID_StockColorPage)
+END_PROP_MAP()
+
+BEGIN_CONNECTION_POINT_MAP(CSOActiveX)
+END_CONNECTION_POINT_MAP()
+
+BEGIN_MSG_MAP(CSOActiveX)
+ CHAIN_MSG_MAP(CComControl<CSOActiveX>)
+ DEFAULT_REFLECTION_HANDLER()
+END_MSG_MAP()
+// Handler prototypes:
+// LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+// LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
+// LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
+
+
+
+// IViewObjectEx
+ DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
+
+// ISOActiveX
+public:
+
+ STDMETHOD(SetClientSite)( IOleClientSite* aClientSite );
+ STDMETHOD(Invoke)( DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ DISPPARAMS* pDispParams,
+ VARIANT* pvarResult,
+ EXCEPINFO* pExcepInfo,
+ UINT* puArgErr);
+ STDMETHOD(Load) ( LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog );
+ STDMETHOD(Load) ( LPSTREAM pStm );
+ STDMETHOD(InitNew) ();
+ HRESULT OnDrawAdvanced(ATL_DRAWINFO& di);
+ HRESULT OnDraw(ATL_DRAWINFO& di) { return S_OK; }
+
+ HRESULT CreateFrameOldWay( HWND hwnd, int width, int height );
+ HRESULT GetUnoStruct( OLECHAR* sStructName, CComPtr<IDispatch>& pdispResult );
+ HRESULT LoadURLToFrame();
+ HRESULT ShowSomeBars();
+ HRESULT HideAllBars();
+ HRESULT CallDispatch1PBool( OLECHAR* sUrl, OLECHAR* sArgName, BOOL sArgVal );
+ HRESULT GetUrlStruct( OLECHAR* sUrl, CComPtr<IDispatch>& pdispUrl );
+ HRESULT Cleanup();
+};
+
+#endif //__SOACTIVEX_H_
+
diff --git a/odk/examples/OLE/activex/SOActiveX.rgs b/odk/examples/OLE/activex/SOActiveX.rgs
new file mode 100644
index 000000000000..d3814df3b241
--- /dev/null
+++ b/odk/examples/OLE/activex/SOActiveX.rgs
@@ -0,0 +1,33 @@
+HKCR
+{
+ so_activex.SOActiveX.1 = s 'SOActiveX Class'
+ {
+ CLSID = s '{67F2A879-82D5-4A6D-8CC5-FFB3C114B69D}'
+ }
+ so_activex.SOActiveX = s 'SOActiveX Class'
+ {
+ CLSID = s '{67F2A879-82D5-4A6D-8CC5-FFB3C114B69D}'
+ CurVer = s 'so_activex.SOActiveX.1'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {67F2A879-82D5-4A6D-8CC5-FFB3C114B69D} = s 'SOActiveX Class'
+ {
+ ProgID = s 'so_activex.SOActiveX.1'
+ VersionIndependentProgID = s 'so_activex.SOActiveX'
+ ForceRemove 'Programmable'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'Apartment'
+ }
+ ForceRemove 'Control'
+ ForceRemove 'ToolboxBitmap32' = s '%MODULE%, 101'
+ 'MiscStatus' = s '0'
+ {
+ '1' = s '131473'
+ }
+ 'TypeLib' = s '{61FA3F13-8061-4796-B055-3697ED28CB38}'
+ 'Version' = s '1.0'
+ }
+ }
+}
diff --git a/odk/examples/OLE/activex/SOComWindowPeer.cpp b/odk/examples/OLE/activex/SOComWindowPeer.cpp
new file mode 100644
index 000000000000..dbefc0dd6689
--- /dev/null
+++ b/odk/examples/OLE/activex/SOComWindowPeer.cpp
@@ -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.
+ *
+ *************************************************************************/
+
+// SOComWindowPeer.cpp : Implementation of CHelpApp and DLL registration.
+
+#include "stdafx2.h"
+#include "so_activex.h"
+#include "SOComWindowPeer.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+
+STDMETHODIMP SOComWindowPeer::InterfaceSupportsErrorInfo(REFIID riid)
+{
+ static const IID* arr[] =
+ {
+ &IID_ISOComWindowPeer,
+ };
+
+ for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
+ {
+ if (InlineIsEqualGUID(*arr[i],riid))
+ return S_OK;
+ }
+ return S_FALSE;
+}
+
diff --git a/odk/examples/OLE/activex/SOComWindowPeer.h b/odk/examples/OLE/activex/SOComWindowPeer.h
new file mode 100644
index 000000000000..31a94999601d
--- /dev/null
+++ b/odk/examples/OLE/activex/SOComWindowPeer.h
@@ -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.
+ *
+ *************************************************************************/
+
+// SOComWindowPeer.h: Definition of the SOComWindowPeer class
+//
+//////////////////////////////////////////////////////////////////////
+
+#if !defined __SOCOMWINDOWPEER_H_
+#define __SOCOMWINDOWPEER_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "resource.h" // main symbols
+#include <ExDispID.h>
+#include <ExDisp.h>
+#include <shlguid.h>
+#include <atlctl.h>
+
+#include "so_activex.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// SOComWindowPeer
+
+class SOComWindowPeer :
+ public IDispatchImpl<ISOComWindowPeer, &IID_ISOComWindowPeer, &LIBID_SO_ACTIVEXLib>,
+ public ISupportErrorInfo,
+ public CComObjectRoot,
+ public CComCoClass<SOComWindowPeer,&CLSID_SOComWindowPeer>
+{
+ HWND m_hwnd;
+public:
+ SOComWindowPeer() : m_hwnd( NULL ) {}
+
+BEGIN_COM_MAP(SOComWindowPeer)
+ COM_INTERFACE_ENTRY(IDispatch)
+ COM_INTERFACE_ENTRY(ISOComWindowPeer)
+ COM_INTERFACE_ENTRY(ISupportErrorInfo)
+END_COM_MAP()
+DECLARE_NOT_AGGREGATABLE(SOComWindowPeer)
+// Remove the comment from the line above if you don't want your object to
+// support aggregation.
+
+DECLARE_REGISTRY_RESOURCEID(IDR_SOCOMWINDOWPEER)
+
+// ISupportsErrorInfo
+ STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
+
+// ISOComWindowPeer
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getWindowHandle(
+ /* [in] */ SAFEARRAY __RPC_FAR * procId,
+ /* [in] */ short s,
+ /* [retval][out] */ long __RPC_FAR *ret)
+ {
+ *ret = (long) m_hwnd;
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getToolkit(
+ /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal)
+ {
+ *retVal = NULL;
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setPointer(
+ /* [in] */ IDispatch __RPC_FAR *xPointer)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setBackground(
+ /* [in] */ int nColor)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE invalidate(
+ /* [in] */ short __MIDL_0015)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE invalidateRect(
+ /* [in] */ IDispatch __RPC_FAR *aRect,
+ /* [in] */ short nFlags)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE dispose( void)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE addEventListener(
+ /* [in] */ IDispatch __RPC_FAR *xListener)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE removeEventListener(
+ /* [in] */ IDispatch __RPC_FAR *xListener)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bridge_implementedInterfaces(
+ /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal)
+ {
+ *pVal = SafeArrayCreateVector( VT_BSTR, 0, 2 );
+
+ if( !*pVal )
+ return E_FAIL;
+
+ long ix = 0;
+ CComBSTR aInterface( OLESTR( "com.sun.star.awt.XSystemDependentWindowPeer" ) );
+ SafeArrayPutElement( *pVal, &ix, aInterface );
+
+ ix = 1;
+ aInterface = CComBSTR( OLESTR( "com.sun.star.awt.XWindowPeer" ) );
+ SafeArrayPutElement( *pVal, &ix, aInterface );
+
+ return S_OK;
+ }
+
+ void SetHWNDInternally( HWND hwnd ) { m_hwnd = hwnd; }
+};
+
+#endif // __SOCOMWINDOWPEER_H_
diff --git a/odk/examples/OLE/activex/SOComWindowPeer.rgs b/odk/examples/OLE/activex/SOComWindowPeer.rgs
new file mode 100644
index 000000000000..42e985a31a1b
--- /dev/null
+++ b/odk/examples/OLE/activex/SOComWindowPeer.rgs
@@ -0,0 +1,23 @@
+HKCR
+{
+ so_activex.SOComWindowPeer.1 = s 'SOComWindowPeer Class'
+ {
+ CLSID = s '{EE51BD3E-8BB6-4FB8-B319-F65B1BE3B21D}'
+ }
+ so_activex.SOComWindowPeer = s 'SOComWindowPeer Class'
+ {
+ CLSID = s '{EE51BD3E-8BB6-4FB8-B319-F65B1BE3B21D}'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {EE51BD3E-8BB6-4FB8-B319-F65B1BE3B21D} = s 'SOComWindowPeer Class'
+ {
+ ProgID = s 'so_activex.SOComWindowPeer.1'
+ VersionIndependentProgID = s 'so_activex.SOComWindowPeer'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'both'
+ }
+ }
+ }
+}
diff --git a/odk/examples/OLE/activex/StdAfx2.cpp b/odk/examples/OLE/activex/StdAfx2.cpp
new file mode 100644
index 000000000000..9d223866fcbc
--- /dev/null
+++ b/odk/examples/OLE/activex/StdAfx2.cpp
@@ -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.
+ *
+ *************************************************************************/
+
+// stdafx1.cpp : source file that includes just the standard includes
+// stdafx1.pch will be the pre-compiled header
+// stdafx1.obj will contain the pre-compiled type information
+
+#include "stdafx2.h"
+
+#ifdef _ATL_STATIC_REGISTRY
+#include <statreg.h>
+#include <statreg.cpp>
+#endif
+
+#include <atlimpl.cpp>
diff --git a/odk/examples/OLE/activex/StdAfx2.h b/odk/examples/OLE/activex/StdAfx2.h
new file mode 100644
index 000000000000..61174de0d2fd
--- /dev/null
+++ b/odk/examples/OLE/activex/StdAfx2.h
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// stdafx1.h : include file for standard system include files,
+// or project specific include files that are used frequently,
+// but are changed infrequently
+
+#if !defined(AFX_STDAFX_H__C1799EA0_62CC_44DE_A2DD_C9F0410FF7F1__INCLUDED_)
+#define AFX_STDAFX_H__C1799EA0_62CC_44DE_A2DD_C9F0410FF7F1__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define STRICT
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0400
+#endif
+#define _ATL_APARTMENT_THREADED
+#define _ATL_STATIC_REGISTRY
+
+#define min(a, b) (((a) < (b)) ? (a) : (b))
+
+#include <atlbase.h>
+//You may derive a class from CComModule and use it if you want to override
+//something, but do not change the name of _Module
+extern CComModule _Module;
+#include <atlcom.h>
+#include <atlctl.h>
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__C1799EA0_62CC_44DE_A2DD_C9F0410FF7F1__INCLUDED)
diff --git a/odk/examples/OLE/activex/example.html b/odk/examples/OLE/activex/example.html
new file mode 100644
index 000000000000..fd5876a6f212
--- /dev/null
+++ b/odk/examples/OLE/activex/example.html
@@ -0,0 +1,26 @@
+<HTML>
+<HEAD>
+<TITLE>Document Title</TITLE>
+</HEAD>
+<BODY>
+
+<center>
+First you should edit the example.html file!!!
+</center>
+<center>
+<!-- Please edit CODEBASE parameter -->
+<!-- In case ActiveX control is already registered the parameter can be removed -->
+<OBJECT CLASSID="clsid:67F2A879-82D5-4A6D-8CC5-FFB3C114B69D" width="500" height="500"
+ CODEBASE="<path_to_the_sdk_sample_output_dir>\bin\so_activex.dll">
+<!-- Full URL to a document
+ <PARAM NAME="src" VALUE="file:///d:/tmp/test.odt">
+-->
+<!-- Just view the document, do not edit
+ <PARAM NAME="readonly" VALUE="true">
+-->
+</OBJECT>
+
+</center>
+
+</BODY>
+</HTML>
diff --git a/odk/examples/OLE/activex/resource.h b/odk/examples/OLE/activex/resource.h
new file mode 100644
index 000000000000..7cea26317723
--- /dev/null
+++ b/odk/examples/OLE/activex/resource.h
@@ -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.
+ *
+ *************************************************************************/
+
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by so_activex.rc
+//
+#define IDS_PROJNAME 100
+#define IDB_SOACTIVEX 101
+#define IDR_SOACTIVEX 102
+#define IDB_SOCOMWINDOWPEER 103
+#define IDR_SOCOMWINDOWPEER 104
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 201
+#define _APS_NEXT_COMMAND_VALUE 32768
+#define _APS_NEXT_CONTROL_VALUE 201
+#define _APS_NEXT_SYMED_VALUE 105
+#endif
+#endif
+
diff --git a/odk/examples/OLE/activex/so_activex.cpp b/odk/examples/OLE/activex/so_activex.cpp
new file mode 100644
index 000000000000..13def3bf307b
--- /dev/null
+++ b/odk/examples/OLE/activex/so_activex.cpp
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// so_activex.cpp : Implementation of DLL Exports.
+
+
+// Note: Proxy/Stub Information
+// To build a separate proxy/stub DLL,
+// run nmake -f so_activexps.mk in the project directory.
+
+#include "stdafx2.h"
+#include "resource.h"
+#include <initguid.h>
+#include "so_activex.h"
+
+#include "so_activex_i.c"
+#include "SOActiveX.h"
+
+
+CComModule _Module;
+
+BEGIN_OBJECT_MAP(ObjectMap)
+OBJECT_ENTRY(CLSID_SOActiveX, CSOActiveX)
+END_OBJECT_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// DLL Entry Point
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
+{
+ if (dwReason == DLL_PROCESS_ATTACH)
+ {
+ _Module.Init(ObjectMap, hInstance, &LIBID_SO_ACTIVEXLib);
+ DisableThreadLibraryCalls(hInstance);
+ }
+ else if (dwReason == DLL_PROCESS_DETACH)
+ _Module.Term();
+ return TRUE; // ok
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Used to determine whether the DLL can be unloaded by OLE
+
+STDAPI DllCanUnloadNow(void)
+{
+ return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Returns a class factory to create an object of the requested type
+
+STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
+{
+ return _Module.GetClassObject(rclsid, riid, ppv);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DllRegisterServer - Adds entries to the system registry
+
+STDAPI DllRegisterServer(void)
+{
+ HRESULT aResult = _Module.RegisterServer(TRUE);
+
+ return aResult;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DllUnregisterServer - Removes entries from the system registry
+
+STDAPI DllUnregisterServer(void)
+{
+ HRESULT aResult = _Module.UnregisterServer(TRUE);
+
+ return aResult;
+}
+
diff --git a/odk/examples/OLE/activex/so_activex.def b/odk/examples/OLE/activex/so_activex.def
new file mode 100644
index 000000000000..68939efa1fe2
--- /dev/null
+++ b/odk/examples/OLE/activex/so_activex.def
@@ -0,0 +1,5 @@
+EXPORTS
+ DllCanUnloadNow PRIVATE
+ DllGetClassObject PRIVATE
+ DllRegisterServer PRIVATE
+ DllUnregisterServer PRIVATE
diff --git a/odk/examples/OLE/activex/so_activex.idl b/odk/examples/OLE/activex/so_activex.idl
new file mode 100644
index 000000000000..545d5643569d
--- /dev/null
+++ b/odk/examples/OLE/activex/so_activex.idl
@@ -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.
+ *
+ *************************************************************************/
+
+// so_activex.idl : IDL source for so_activex.dll
+//
+
+// This file will be processed by the MIDL tool to
+// produce the type library (so_activex.tlb) and marshalling code.
+
+import "oaidl.idl";
+import "ocidl.idl";
+#include "olectl.h"
+
+
+ [
+ object,
+ uuid(DACF7E3F-626B-4BF9-964B-F4910C843711),
+ dual,
+ helpstring("ISOActiveX Interface"),
+ pointer_default(unique)
+ ]
+ interface ISOActiveX : IDispatch
+ {
+ };
+
+[
+ object,
+ uuid(BF5D10F3-8A10-4A0B-B150-2B6AA2D7E118),
+ dual,
+ helpstring("ISOComWindowPeer Interface"),
+ pointer_default(unique)
+]
+interface ISOComWindowPeer : IDispatch
+{
+ [id(1), helpstring("method getWindowHandle")]
+ HRESULT getWindowHandle( [in] SAFEARRAY(VARIANT) procId,
+ [in] short s,
+ [out,retval] long* ret);
+
+ [id(2), helpstring("method getToolkit")]
+ HRESULT getToolkit( [out,retval] IDispatch** retVal );
+
+ [id(3), helpstring("method setPointer")]
+ HRESULT setPointer( [in] IDispatch* xPointer );
+
+ [id(4), helpstring("method setBackground")]
+ HRESULT setBackground( [in] int nColor );
+
+ [id(5), helpstring("method invalidate")]
+ HRESULT invalidate( [in] short );
+
+ [id(6), helpstring("method invalidateRect")]
+ HRESULT invalidateRect( [in] IDispatch* aRect, [in] short nFlags );
+
+ [id(7), helpstring("method dispose")]
+ HRESULT dispose();
+
+ [id(8), helpstring("method addEventListener")]
+ HRESULT addEventListener( [in] IDispatch* xListener );
+
+ [id(9), helpstring("method removeEventListener")]
+ HRESULT removeEventListener( [in] IDispatch* xListener );
+
+ [propget, id(10), helpstring("property_implementedInterfaces")]
+ HRESULT Bridge_implementedInterfaces([out, retval] SAFEARRAY(BSTR) *pVal);
+};
+
+[
+ uuid(61FA3F13-8061-4796-B055-3697ED28CB38),
+ version(1.0),
+ helpstring("so_activex 1.0 Type Library")
+]
+library SO_ACTIVEXLib
+{
+ importlib("stdole32.tlb");
+ importlib("stdole2.tlb");
+
+ [
+ uuid(7F760565-5719-4F04-BA86-112C474B10EA),
+ helpstring("_ISOActiveXEvents Interface")
+ ]
+ dispinterface _ISOActiveXEvents
+ {
+ properties:
+ methods:
+ };
+
+ [
+ uuid(67F2A879-82D5-4A6D-8CC5-FFB3C114B69D),
+ helpstring("SOActiveX Class")
+ ]
+ coclass SOActiveX
+ {
+ [default] interface ISOActiveX;
+ [default, source] dispinterface _ISOActiveXEvents;
+ };
+
+ [
+ uuid(EE51BD3E-8BB6-4FB8-B319-F65B1BE3B21D),
+ helpstring("SOComWindowPeer Class")
+ ]
+ coclass SOComWindowPeer
+ {
+ [default] interface ISOComWindowPeer;
+ };
+};
+
diff --git a/odk/examples/OLE/activex/so_activex.rc b/odk/examples/OLE/activex/so_activex.rc
new file mode 100644
index 000000000000..72ca32e1a72c
--- /dev/null
+++ b/odk/examples/OLE/activex/so_activex.rc
@@ -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.
+ *
+ *************************************************************************/
+
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "winres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Russian resources
+
+//#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
+//#ifdef _WIN32
+//LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
+//#pragma code_page(1251)
+//#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+//IDB_SOACTIVEX BITMAP DISCARDABLE "soacti.bmp"
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// REGISTRY
+//
+
+IDR_SOACTIVEX REGISTRY DISCARDABLE "SOActiveX.rgs"
+IDR_SOCOMWINDOWPEER REGISTRY DISCARDABLE "SOComWindowPeer.rgs"
+//#endif // Russian resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""winres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "1 TYPELIB ""so_activex.tlb""\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_PROJNAME "so_activex"
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+1 TYPELIB .\..\..\..\WINexample.out\misc\so_activex\so_activex.tlb
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/odk/examples/OLE/delphi/InsertTables/Project1.dpr b/odk/examples/OLE/delphi/InsertTables/Project1.dpr
new file mode 100644
index 000000000000..9f2bd2fd5667
--- /dev/null
+++ b/odk/examples/OLE/delphi/InsertTables/Project1.dpr
@@ -0,0 +1,14 @@
+program Project1;
+
+uses
+ Forms,
+ SampleUI in 'SampleUI.pas' {OKBottomDlg},
+ SampleCode in 'SampleCode.pas';
+
+{$R *.RES}
+
+begin
+ Application.Initialize;
+ Application.CreateForm(TOKBottomDlg, OKBottomDlg);
+ Application.Run;
+end.
diff --git a/odk/examples/OLE/delphi/InsertTables/Project1.res b/odk/examples/OLE/delphi/InsertTables/Project1.res
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/odk/examples/OLE/delphi/InsertTables/Project1.res
diff --git a/odk/examples/OLE/delphi/InsertTables/SampleCode.pas b/odk/examples/OLE/delphi/InsertTables/SampleCode.pas
new file mode 100644
index 000000000000..f314f7ea6d29
--- /dev/null
+++ b/odk/examples/OLE/delphi/InsertTables/SampleCode.pas
@@ -0,0 +1,393 @@
+{***********************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************}
+unit SampleCode;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
+ StdCtrls, ComObj, Variants;
+
+ type
+ TSampleCode = class
+
+ function Connect() : boolean;
+ procedure Disconnect();
+
+ function CreateDocument(bReadOnly : boolean) : boolean;
+
+ procedure InsertTable(sTableName : String; dbPointer : String);
+
+ procedure InsertDatabaseTable(
+ oDoc : Variant;
+ sTableName : String;
+ oCursor : Variant;
+ iRows : Integer;
+ iColumns : Integer;
+ dbPointer : String );
+ function CreateTextTable(
+ oDoc : Variant;
+ oCursor : Variant;
+ sName : String;
+ iRow : Integer;
+ iColumn : Integer) : Variant;
+ function getCellContent(
+ sBookmarkName : String ) : Variant;
+ function getDatabasePointer(
+ sTableName : String;
+ sCellname : String ) : String;
+ procedure InsertBookmark(
+ oDoc : Variant;
+ oTextCursor : Variant;
+ sBookmarkName : String );
+ function CreateBookmarkName(
+ sTableName : String;
+ sCellName : String;
+ sDatabasepointer : String ) : String;
+ procedure ChangeCellContent(
+ oDoc : Variant;
+ sTableName : String;
+ sCellName : String;
+ dValue : Double );
+ function GetBookmarkFromDBPointer(
+ oDoc : Variant;
+ sBookmarkName : String) : Variant;
+ function GetBookmarkFromAdress(
+ oDoc : Variant;
+ sTableName : String;
+ sCellAdress : String) : Variant;
+ function JumpToBookmark(
+ oBookmark : Variant) : Variant;
+ function CreateUniqueTablename(oDoc : Variant) : String;
+
+ private
+ StarOffice : Variant;
+ Document : Variant;
+
+ { Private-Deklarationen }
+ public
+ { Public-Deklarationen }
+ end;
+
+implementation
+
+{ Insert a table texttable and insert in each cell a Bookmark with the address
+ of the cell and database pointer
+}
+
+function TSampleCode.Connect() : boolean;
+begin
+ if VarIsEmpty(StarOffice) then
+ StarOffice := CreateOleObject('com.sun.star.ServiceManager');
+
+ Connect := not (VarIsEmpty(StarOffice) or VarIsNull(StarOffice));
+end;
+
+procedure TSampleCode.Disconnect();
+begin
+ StarOffice := Unassigned;
+end;
+
+function TSampleCode.CreateDocument(bReadOnly : boolean) : boolean;
+var
+ StarDesktop : Variant;
+ LoadParams : Variant;
+ CoreReflection : Variant;
+ PropertyValue : Variant;
+begin
+ StarDesktop := StarOffice.createInstance('com.sun.star.frame.Desktop');
+
+ if (bReadOnly) then begin
+ LoadParams := VarArrayCreate([0, 0], varVariant);
+ CoreReflection := StarOffice.createInstance('com.sun.star.reflection.CoreReflection');
+
+ CoreReflection
+ .forName('com.sun.star.beans.PropertyValue')
+ .createObject(PropertyValue);
+
+ PropertyValue.Name := 'ReadOnly';
+ PropertyValue.Value := true;
+
+ LoadParams[0] := PropertyValue;
+ end
+ else
+ LoadParams := VarArrayCreate([0, -1], varVariant);
+
+ Document := StarDesktop.LoadComponentFromURL( 'private:factory/swriter', '_blank', 0, LoadParams);
+
+ CreateDocument := not (VarIsEmpty(Document) or VarIsNull(Document));
+end;
+
+
+function TSampleCode.getCellContent(
+ sBookmarkName : String ) : Variant;
+var
+ oBookmark : Variant;
+ oTextCursor : Variant;
+begin
+ oBookmark := GetBookmarkFromDBPointer( Document, sBookmarkName );
+ oTextCursor := JumpToBookmark( oBookmark );
+
+ getCellContent := oTextCursor.Cell.Value;
+
+end;
+
+
+function TSampleCode.getDatabasePointer(
+ sTableName : String;
+ sCellname : String ) : String;
+var
+ oBookmark : Variant;
+ sBookmarkName : String;
+ iPos : Integer;
+begin
+ oBookmark := GetBookmarkFromAdress( Document, sTableName, sCellName );
+
+ sBookmarkName := oBookmark.getName();
+
+ iPos := Pos('/%', sBookmarkName);
+ while Pos('/%', sBookmarkName) > 0 do
+ begin
+ iPos := Pos('/%', sBookmarkName);
+ sBookmarkName[iPos] := '%';
+ end;
+
+ Delete( sBookmarkName, 1, iPos+1);
+ getDatabasePointer := sBookmarkName;
+end;
+
+
+procedure TSampleCode.InsertTable(sTableName : String; dbPointer : String);
+var
+ oCursor : Variant;
+begin
+ { create a cursor object on the current position in the document }
+ oCursor := Document.Text.CreateTextCursor();
+
+ { Create for each table a unique database name }
+ if (sTableName = '') then
+ sTableName := createUniqueTablename(Document);
+
+ InsertDatabaseTable( Document, sTableName, oCursor, 4, 2, dbPointer );
+
+ ChangeCellContent( Document, sTableName, 'B2', 1.12 );
+end;
+
+procedure TSampleCode.InsertDatabaseTable(
+ oDoc : Variant;
+ sTableName : String;
+ oCursor : Variant;
+ iRows : Integer;
+ iColumns : Integer;
+ dbPointer : String);
+var
+ oTable : Variant;
+ sCellnames : Variant;
+ iCellcounter : Integer;
+ oCellCursor : Variant;
+ oTextCursor : Variant;
+ sCellName : String;
+begin
+ oTable := CreateTextTable( oDoc, oCursor, sTableName, iRows, iColumns );
+ sCellnames := oTable.getCellNames();
+
+ For iCellcounter := VarArrayLowBound( sCellnames, 1) to VarArrayHighBound(sCellnames, 1) do
+ begin
+ sCellName := sCellnames[iCellcounter];
+
+ oCellCursor := oTable.getCellByName(sCellName);
+ oCellCursor.Value := iCellcounter;
+ oTextCursor := oCellCursor.getEnd();
+ InsertBookmark(
+ oDoc,
+ oTextCursor,
+ createBookmarkName(sTableName, sCellName, dbPointer));
+ end;
+end;
+
+{
+
+' Change the content of a cell
+}
+
+procedure TSampleCode.ChangeCellContent(
+ oDoc : Variant;
+ sTableName : String;
+ sCellName : String;
+ dValue : Double );
+var
+ oBookmark : Variant;
+ oTextCursor : Variant;
+ sBookmarkName : String;
+begin
+ oBookmark := GetBookmarkFromAdress( oDoc, sTableName, sCellName );
+ oTextCursor := JumpToBookmark( oBookmark );
+ oTextCursor.Cell.Value := dValue;
+
+ { create a new bookmark for the new number }
+ sBookmarkName := oBookmark.getName();
+ oBookmark.dispose();
+ InsertBookmark( oDoc, oTextCursor, sBookmarkName );
+end;
+
+
+{ ' Jump to Bookmark and return for this position the cursor }
+
+function TSampleCode.JumpToBookmark(
+ oBookmark : Variant) : Variant;
+
+begin
+ JumpToBookmark := oBookmark.Anchor.Text.createTextCursorByRange(
+ oBookmark.Anchor );
+end;
+
+
+{ ' Create a Texttable on a Textdocument }
+function TSampleCode.CreateTextTable(
+ oDoc : Variant;
+ oCursor : Variant;
+ sName : String;
+ iRow : Integer;
+ iColumn : Integer) : Variant;
+var
+ ret : Variant;
+begin
+ ret := oDoc.createInstance( 'com.sun.star.text.TextTable' );
+
+ ret.setName( sName );
+ ret.initialize( iRow, iColumn );
+ oDoc.Text.InsertTextContent( oCursor, ret, False );
+
+ CreateTextTable := ret;
+end;
+
+
+{ 'create a unique name for the Texttables }
+function TSampleCode.CreateUniqueTablename(oDoc : Variant) : String;
+var
+ iHighestNumber : Integer;
+ sTableNames : Variant;
+ iTableCounter : Integer;
+ sTableName : String;
+ iTableNumber : Integer;
+ i : Integer;
+begin
+ sTableNames := oDoc.getTextTables.getElementNames();
+ iHighestNumber := 0;
+ For iTableCounter := VarArrayLowBound(sTableNames, 1) to VarArrayHighBound(sTableNames, 1) do
+ begin
+ sTableName := sTableNames[iTableCounter];
+ i := Pos( '$$', sTableName );
+ iTableNumber := strtoint( Copy(sTableName, i + 2, Length( sTableName ) - i - 1 ) );
+
+ If iTableNumber > iHighestNumber then
+ iHighestNumber := iTableNumber;
+ end;
+ createUniqueTablename := 'DBTable$$' + inttostr(iHighestNumber + 1);
+end;
+
+
+{' Insert a Bookmark on the cursor }
+procedure TSampleCode.InsertBookmark(
+ oDoc : Variant;
+ oTextCursor : Variant;
+ sBookmarkName : String);
+var
+ oBookmarkInst : Variant;
+begin
+ oBookmarkInst := oDoc.createInstance('com.sun.star.text.Bookmark');
+
+ oBookmarkInst.Name := sBookmarkName;
+ oTextCursor.gotoStart( true );
+ oTextCursor.text.InsertTextContent( oTextCursor, oBookmarkInst, true );
+end;
+
+
+function TSampleCode.CreateBookmarkName(
+ sTableName : String;
+ sCellName : String;
+ sDatabasepointer : String ) : String;
+begin
+ createBookmarkName := '//' + sTableName + '/%' + sCellName + '/%' + sDatabasePointer + ':' + sCellName;
+end;
+
+{ ' Returns the Bookmark the Tablename and Cellname }
+function TSampleCode.GetBookmarkFromAdress(
+ oDoc : Variant;
+ sTableName : String;
+ sCellAdress : String) : Variant;
+var
+ sTableAddress : String;
+ iTableNameLength : Integer;
+ sBookNames : Variant;
+ iBookCounter : Integer;
+begin
+ sTableAddress := '//' + sTableName + '/%' + sCellAdress;
+ iTableNameLength := Length( sTableAddress );
+
+ sBookNames := oDoc.Bookmarks.getElementNames;
+
+ for iBookCounter := VarArrayLowBound(sBookNames, 1) to VarArrayHighBound(sBookNames, 1) do
+ begin
+ If sTableAddress = Copy( sBookNames[iBookCounter], 1, iTableNameLength) then
+ begin
+ GetBookmarkFromAdress := oDoc.Bookmarks.getByName(sBookNames[iBookCounter]);
+ exit;
+ end;
+ end;
+end;
+
+{ ' Returns the Bookmark the Tablename and Cellname }
+function TSampleCode.GetBookmarkFromDBPointer(
+ oDoc : Variant;
+ sBookmarkName : String) : Variant;
+var
+ sBookNames : Variant;
+ iBookCounter : Integer;
+begin
+ sBookNames := oDoc.Bookmarks.getElementNames;
+
+ for iBookCounter := VarArrayLowBound(sBookNames, 1) to VarArrayHighBound(sBookNames, 1) do
+ begin
+ If Pos(sBookmarkName, sBookNames[iBookCounter]) = (1 + Length(sBookNames[iBookCounter]) - Length(sBookmarkName)) then
+ begin
+ GetBookmarkFromDBPointer := oDoc.Bookmarks.getByName(sBookNames[iBookCounter]);
+ exit;
+ end;
+ end;
+end;
+
+end.
+
+
diff --git a/odk/examples/OLE/delphi/InsertTables/SampleUI.dfm b/odk/examples/OLE/delphi/InsertTables/SampleUI.dfm
new file mode 100644
index 000000000000..082fce7b7ef8
--- /dev/null
+++ b/odk/examples/OLE/delphi/InsertTables/SampleUI.dfm
@@ -0,0 +1,4 @@
+ÿ
+ParentFont OldCreateOrder PositionpoScreenCenter PixelsPerInch`
+TextHeight Table NameTable namedisconnectEnabledTabOrderOnClick OnDisconnectTStatusBar
+StatusBar1LeftSimpleTextReady \ No newline at end of file
diff --git a/odk/examples/OLE/delphi/InsertTables/SampleUI.pas b/odk/examples/OLE/delphi/InsertTables/SampleUI.pas
new file mode 100644
index 000000000000..fcd4f4301011
--- /dev/null
+++ b/odk/examples/OLE/delphi/InsertTables/SampleUI.pas
@@ -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.
+ *
+ *************************************************************************}
+unit SampleUI;
+
+interface
+
+uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
+ Buttons, ExtCtrls, SampleCode, ComCtrls;
+
+type
+ TOKBottomDlg = class(TForm)
+ Bevel1: TBevel;
+ Button1: TButton;
+ Button2: TButton;
+ Button3: TButton;
+ Button4: TButton;
+ Edit1: TEdit;
+ Label1: TLabel;
+ Edit2: TEdit;
+ Label2: TLabel;
+ Button5: TButton;
+ Button6: TButton;
+ Edit3: TEdit;
+ Label3: TLabel;
+ Label4: TLabel;
+ Label6: TLabel;
+ Edit6: TEdit;
+ Bevel2: TBevel;
+ Bevel3: TBevel;
+ Bevel4: TBevel;
+ StatusBar1: TStatusBar;
+ Edit4: TEdit;
+ Label7: TLabel;
+ procedure OnConnect(Sender: TObject);
+ procedure OnDisconnect(Sender: TObject);
+ procedure OnCreateDocument(Sender: TObject);
+ procedure OnInsertTable(Sender: TObject);
+ procedure OnGetDatabasePointer(Sender: TObject);
+ procedure OnGetCellContent(Sender: TObject);
+ private
+ { Private declarations }
+ public
+ { Public declarations }
+ end;
+
+var
+ OKBottomDlg: TOKBottomDlg;
+ Sample : TSampleCode;
+implementation
+
+{$R *.DFM}
+
+procedure TOKBottomDlg.OnConnect(Sender: TObject);
+begin
+ StatusBar1.SimpleText := 'Connection to StarOffice ...';
+ Sample := TSampleCode.Create();
+ if Sample.Connect() then
+ begin
+ Button1.Enabled := false;
+ Button2.Enabled := true;
+ Button3.Enabled := true;
+ Button4.Enabled := false;
+ Button5.Enabled := false;
+ Button6.Enabled := false;
+ end;
+ StatusBar1.SimpleText := 'Ready';
+end;
+
+procedure TOKBottomDlg.OnDisconnect(Sender: TObject);
+begin
+ StatusBar1.SimpleText := 'Disconnection from StarOffice ...';
+ Sample.Disconnect();
+ Button1.Enabled := true;
+ Button2.Enabled := false;
+ Button3.Enabled := false;
+ Button4.Enabled := false;
+ Button5.Enabled := false;
+ Button6.Enabled := false;
+ StatusBar1.SimpleText := 'Ready';
+end;
+
+procedure TOKBottomDlg.OnCreateDocument(Sender: TObject);
+begin
+ StatusBar1.SimpleText := 'Creating new text document ...';
+ try
+ if Sample.CreateDocument(false) then
+ begin
+ Button4.Enabled := true;
+ Button5.Enabled := true;
+ Button6.Enabled := true;
+ end;
+ StatusBar1.SimpleText := 'Ready';
+ except
+ StatusBar1.SimpleText := 'Error';
+ end;
+end;
+
+procedure TOKBottomDlg.OnInsertTable(Sender: TObject);
+begin
+ try
+ StatusBar1.SimpleText := 'Inserting Table ...';
+ Sample.InsertTable(Edit2.Text, Edit1.Text);
+ StatusBar1.SimpleText := 'Ready';
+ except
+ StatusBar1.SimpleText := 'Error';
+ end;
+end;
+
+procedure TOKBottomDlg.OnGetDatabasePointer(Sender: TObject);
+var
+ res : String;
+begin
+ try
+ StatusBar1.SimpleText := 'Getting database pointer ...';
+ res := Sample.getDatabasePointer(Edit4.Text, Edit3.Text);
+ Application.MessageBox(PChar('the pointer: ' + res), PChar('Result'), ID_OK);
+ StatusBar1.SimpleText := 'Ready';
+ except
+ StatusBar1.SimpleText := 'Error';
+ end;
+end;
+
+procedure TOKBottomDlg.OnGetCellContent(Sender: TObject);
+var
+ res : String;
+begin
+ try
+ StatusBar1.SimpleText := 'Getting cell content ...';
+ res := Sample.getCellContent(Edit6.Text);
+ Application.MessageBox(PChar('the content: ' + res), PChar('Result'), ID_OK);
+ StatusBar1.SimpleText := 'Ready';
+ except
+ StatusBar1.SimpleText := 'Error';
+ end;
+end;
+
+end.
diff --git a/odk/examples/OLE/delphi/StarOffice_Delphi.sxw b/odk/examples/OLE/delphi/StarOffice_Delphi.sxw
new file mode 100644
index 000000000000..77ccc4b77ca7
--- /dev/null
+++ b/odk/examples/OLE/delphi/StarOffice_Delphi.sxw
Binary files differ
diff --git a/odk/examples/OLE/delphi/StarOffice_and_Delphi.pdf b/odk/examples/OLE/delphi/StarOffice_and_Delphi.pdf
new file mode 100644
index 000000000000..92eee437f4a3
--- /dev/null
+++ b/odk/examples/OLE/delphi/StarOffice_and_Delphi.pdf
Binary files differ
diff --git a/odk/examples/OLE/makefile.mk b/odk/examples/OLE/makefile.mk
new file mode 100644
index 000000000000..49c7a822e54b
--- /dev/null
+++ b/odk/examples/OLE/makefile.mk
@@ -0,0 +1,93 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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
+#----------------------------------------------------
+
+ACTIVEX_FILES=\
+ $(DESTDIROLEEXAMPLES)$/activex$/example.html \
+ $(DESTDIROLEEXAMPLES)$/activex$/Makefile \
+ $(DESTDIROLEEXAMPLES)$/activex$/README.txt \
+ $(DESTDIROLEEXAMPLES)$/activex$/resource.h \
+ $(DESTDIROLEEXAMPLES)$/activex$/SOActiveX.cpp \
+ $(DESTDIROLEEXAMPLES)$/activex$/SOActiveX.h \
+ $(DESTDIROLEEXAMPLES)$/activex$/SOActiveX.rgs \
+ $(DESTDIROLEEXAMPLES)$/activex$/SOComWindowPeer.cpp \
+ $(DESTDIROLEEXAMPLES)$/activex$/SOComWindowPeer.h \
+ $(DESTDIROLEEXAMPLES)$/activex$/SOComWindowPeer.rgs \
+ $(DESTDIROLEEXAMPLES)$/activex$/so_activex.cpp \
+ $(DESTDIROLEEXAMPLES)$/activex$/so_activex.def \
+ $(DESTDIROLEEXAMPLES)$/activex$/so_activex.idl \
+ $(DESTDIROLEEXAMPLES)$/activex$/so_activex.rc \
+ $(DESTDIROLEEXAMPLES)$/activex$/StdAfx2.cpp \
+ $(DESTDIROLEEXAMPLES)$/activex$/StdAfx2.h
+
+DELPHI_FILES=\
+ $(DESTDIROLEEXAMPLES)$/delphi$/InsertTables$/Project1.dpr \
+ $(DESTDIROLEEXAMPLES)$/delphi$/InsertTables$/Project1.res \
+ $(DESTDIROLEEXAMPLES)$/delphi$/InsertTables$/SampleCode.pas \
+ $(DESTDIROLEEXAMPLES)$/delphi$/InsertTables$/SampleUI.dfm \
+ $(DESTDIROLEEXAMPLES)$/delphi$/InsertTables$/SampleUI.pas \
+ $(DESTDIROLEEXAMPLES)$/delphi$/StarOffice_and_Delphi.pdf \
+ $(DESTDIROLEEXAMPLES)$/delphi$/StarOffice_Delphi.sxw
+
+VBSCRIPT_FILES=\
+ $(DESTDIROLEEXAMPLES)$/vbscript$/readme.txt \
+ $(DESTDIROLEEXAMPLES)$/vbscript$/WriterDemo.vbs
+
+DIR_FILE_LIST= \
+ $(ACTIVEX_FILES) \
+ $(DELPHI_FILES) \
+ $(VBSCRIPT_FILES)
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/ex_ole_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/ex_ole_files.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
diff --git a/odk/examples/OLE/vbscript/WriterDemo.vbs b/odk/examples/OLE/vbscript/WriterDemo.vbs
new file mode 100644
index 000000000000..71d011e4f13a
--- /dev/null
+++ b/odk/examples/OLE/vbscript/WriterDemo.vbs
@@ -0,0 +1,172 @@
+'***********************************************************************
+'*
+'* The Contents of this file are made available subject to the terms of
+'* the BSD license.
+'*
+'* Copyright 2000, 2010 Oracle and/or its affiliates.
+'* All rights reserved.
+'*
+'* Redistribution and use in source and binary forms, with or without
+'* modification, are permitted provided that the following conditions
+'* are met:
+'* 1. Redistributions of source code must retain the above copyright
+'* notice, this list of conditions and the following disclaimer.
+'* 2. Redistributions in binary form must reproduce the above copyright
+'* notice, this list of conditions and the following disclaimer in the
+'* documentation and/or other materials provided with the distribution.
+'* 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+'* contributors may be used to endorse or promote products derived
+'* from this software without specific prior written permission.
+'*
+'* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+'* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+'* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+'* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+'* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+'* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+'* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+'* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+'* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+'* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+'* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+'*
+'*************************************************************************
+
+'The service manager is always the starting point
+'If there is no office running then an office is started up
+Set objServiceManager= WScript.CreateObject("com.sun.star.ServiceManager")
+
+'Create the CoreReflection service that is later used to create structs
+Set objCoreReflection= objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")
+
+'Create the Desktop
+Set objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop")
+
+'Open a new empty writer document
+Dim args()
+Set objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args)
+
+'Create a text object
+Set objText= objDocument.getText
+
+'Create a cursor object
+Set objCursor= objText.createTextCursor
+
+'Inserting some Text
+objText.insertString objCursor, "The first line in the newly created text document." & vbLf, false
+
+'Inserting a second line
+objText.insertString objCursor, "Now we're in the second line", false
+
+'Create instance of a text table with 4 columns and 4 rows
+Set objTable= objDocument.createInstance( "com.sun.star.text.TextTable")
+objTable.initialize 4, 4
+
+'Insert the table
+objText.insertTextContent objCursor, objTable, false
+
+'Get first row
+Set objRows= objTable.getRows
+Set objRow= objRows.getByIndex( 0)
+
+'Set the table background color
+objTable.setPropertyValue "BackTransparent", false
+objTable.setPropertyValue "BackColor", 13421823
+
+'Set a different background color for the first row
+objRow.setPropertyValue "BackTransparent", false
+objRow.setPropertyValue "BackColor", 6710932
+
+'Fill the first table row
+insertIntoCell "A1","FirstColumn", objTable
+insertIntoCell "B1","SecondColumn", objTable
+insertIntoCell "C1","ThirdColumn", objTable
+insertIntoCell "D1","SUM", objTable
+
+objTable.getCellByName("A2").setValue 22.5
+objTable.getCellByName("B2").setValue 5615.3
+objTable.getCellByName("C2").setValue -2315.7
+objTable.getCellByName("D2").setFormula"sum <A2:C2>"
+
+objTable.getCellByName("A3").setValue 21.5
+objTable.getCellByName("B3").setValue 615.3
+objTable.getCellByName("C3").setValue -315.7
+objTable.getCellByName("D3").setFormula "sum <A3:C3>"
+
+objTable.getCellByName("A4").setValue 121.5
+objTable.getCellByName("B4").setValue -615.3
+objTable.getCellByName("C4").setValue 415.7
+objTable.getCellByName("D4").setFormula "sum <A4:C4>"
+
+'Change the CharColor and add a Shadow
+objCursor.setPropertyValue "CharColor", 255
+objCursor.setPropertyValue "CharShadowed", true
+
+'Create a paragraph break
+'The second argument is a com::sun::star::text::ControlCharacter::PARAGRAPH_BREAK constant
+objText.insertControlCharacter objCursor, 0 , false
+
+'Inserting colored Text.
+objText.insertString objCursor, " This is a colored Text - blue with shadow" & vbLf, false
+
+'Create a paragraph break ( ControlCharacter::PARAGRAPH_BREAK).
+objText.insertControlCharacter objCursor, 0, false
+
+'Create a TextFrame.
+Set objTextFrame= objDocument.createInstance("com.sun.star.text.TextFrame")
+
+'Create a Size struct.
+Set objSize= createStruct("com.sun.star.awt.Size")
+objSize.Width= 15000
+objSize.Height= 400
+objTextFrame.setSize( objSize)
+
+' TextContentAnchorType.AS_CHARACTER = 1
+objTextFrame.setPropertyValue "AnchorType", 1
+
+'insert the frame
+objText.insertTextContent objCursor, objTextFrame, false
+
+'Get the text object of the frame
+Set objFrameText= objTextFrame.getText
+
+
+'Create a cursor object
+Set objFrameTextCursor= objFrameText.createTextCursor
+
+'Inserting some Text
+objFrameText.insertString objFrameTextCursor, "The first line in the newly created text frame.", _
+ false
+objFrameText.insertString objFrameTextCursor, _
+ vbLf & "With this second line the height of the frame raises.", false
+
+'Create a paragraph break
+'The second argument is a com::sun::star::text::ControlCharacter::PARAGRAPH_BREAK constant
+objFrameText.insertControlCharacter objCursor, 0 , false
+
+'Change the CharColor and add a Shadow
+objCursor.setPropertyValue "CharColor", 65536
+objCursor.setPropertyValue "CharShadowed", false
+
+'Insert another string
+objText.insertString objCursor, " That's all for now !!", false
+
+On Error Resume Next
+If Err Then
+ MsgBox "An error occurred"
+End If
+
+
+Sub insertIntoCell( strCellName, strText, objTable)
+ Set objCellText= objTable.getCellByName( strCellName)
+ Set objCellCursor= objCellText.createTextCursor
+ objCellCursor.setPropertyValue "CharColor",16777215
+ objCellText.insertString objCellCursor, strText, false
+End Sub
+
+Function createStruct( strTypeName)
+ Set classSize= objCoreReflection.forName( strTypeName)
+ Dim aStruct
+ classSize.createObject aStruct
+ Set createStruct= aStruct
+End Function
diff --git a/odk/examples/OLE/vbscript/readme.txt b/odk/examples/OLE/vbscript/readme.txt
new file mode 100644
index 000000000000..082a4dff340b
--- /dev/null
+++ b/odk/examples/OLE/vbscript/readme.txt
@@ -0,0 +1,4 @@
+Run the script in WriterDemo.vbs with Windows Script Host.
+Commmand line:
+
+cscript WriterDemo.vbs
diff --git a/odk/examples/basic/drawing/dirtree.txt b/odk/examples/basic/drawing/dirtree.txt
new file mode 100644
index 000000000000..9cb9afe6d729
--- /dev/null
+++ b/odk/examples/basic/drawing/dirtree.txt
@@ -0,0 +1,20 @@
+Explorer
+ Workspace
+ Bookmarks
+ Database
+ Macros
+ StarOffice Math
+ StarOffice API
+ ToDo
+ Translations
+ Chinese
+ German
+ English
+ French
+ Italian
+ Dutch
+ Portuguese
+ Swedish
+ Spanish
+ Examples
+ Databases \ No newline at end of file
diff --git a/odk/examples/basic/drawing/importexportofasciifiles.odg b/odk/examples/basic/drawing/importexportofasciifiles.odg
new file mode 100644
index 000000000000..721f9e7b3931
--- /dev/null
+++ b/odk/examples/basic/drawing/importexportofasciifiles.odg
Binary files differ
diff --git a/odk/examples/basic/forms_and_controls/beef.wmf b/odk/examples/basic/forms_and_controls/beef.wmf
new file mode 100644
index 000000000000..0947521c0e19
--- /dev/null
+++ b/odk/examples/basic/forms_and_controls/beef.wmf
Binary files differ
diff --git a/odk/examples/basic/forms_and_controls/burger.wmf b/odk/examples/basic/forms_and_controls/burger.wmf
new file mode 100644
index 000000000000..35b30c394ba9
--- /dev/null
+++ b/odk/examples/basic/forms_and_controls/burger.wmf
Binary files differ
diff --git a/odk/examples/basic/forms_and_controls/burger_factory.odt b/odk/examples/basic/forms_and_controls/burger_factory.odt
new file mode 100644
index 000000000000..8203ea0f0916
--- /dev/null
+++ b/odk/examples/basic/forms_and_controls/burger_factory.odt
Binary files differ
diff --git a/odk/examples/basic/forms_and_controls/chicken.wmf b/odk/examples/basic/forms_and_controls/chicken.wmf
new file mode 100644
index 000000000000..6be326d027ca
--- /dev/null
+++ b/odk/examples/basic/forms_and_controls/chicken.wmf
Binary files differ
diff --git a/odk/examples/basic/forms_and_controls/fish.wmf b/odk/examples/basic/forms_and_controls/fish.wmf
new file mode 100644
index 000000000000..d7060f2881b9
--- /dev/null
+++ b/odk/examples/basic/forms_and_controls/fish.wmf
Binary files differ
diff --git a/odk/examples/basic/forms_and_controls/vegetable.wmf b/odk/examples/basic/forms_and_controls/vegetable.wmf
new file mode 100644
index 000000000000..364d122cf291
--- /dev/null
+++ b/odk/examples/basic/forms_and_controls/vegetable.wmf
Binary files differ
diff --git a/odk/examples/basic/makefile.mk b/odk/examples/basic/makefile.mk
new file mode 100644
index 000000000000..594b93fb5447
--- /dev/null
+++ b/odk/examples/basic/makefile.mk
@@ -0,0 +1,91 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=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=\
+ $(DESTDIRBASICEXAMPLES)$/drawing$/dirtree.txt \
+ $(DESTDIRBASICEXAMPLES)$/drawing$/importexportofasciifiles.odg
+
+FORMSANDCONTROLS_FILES=\
+ $(DESTDIRBASICEXAMPLES)$/forms_and_controls$/beef.wmf \
+ $(DESTDIRBASICEXAMPLES)$/forms_and_controls$/burger.wmf \
+ $(DESTDIRBASICEXAMPLES)$/forms_and_controls$/burger_factory.odt \
+ $(DESTDIRBASICEXAMPLES)$/forms_and_controls$/chicken.wmf \
+ $(DESTDIRBASICEXAMPLES)$/forms_and_controls$/fish.wmf \
+ $(DESTDIRBASICEXAMPLES)$/forms_and_controls$/vegetable.wmf
+
+SHEET_FILES=\
+ $(DESTDIRBASICEXAMPLES)$/sheet$/adapting_to_euroland.ods
+
+STOCKQUOTEUPDATER_FILES=\
+ $(DESTDIRBASICEXAMPLES)$/stock_quotes_updater$/stock.ods
+
+TEXT_FILES=\
+ $(DESTDIRBASICEXAMPLES)$/text$/creating_an_index$/index.odt \
+ $(DESTDIRBASICEXAMPLES)$/text$/creating_an_index$/indexlist.txt \
+ $(DESTDIRBASICEXAMPLES)$/text$/modifying_text_automatically$/changing_appearance.odt \
+ $(DESTDIRBASICEXAMPLES)$/text$/modifying_text_automatically$/inserting_bookmarks.odt \
+ $(DESTDIRBASICEXAMPLES)$/text$/modifying_text_automatically$/replacing_text.odt \
+ $(DESTDIRBASICEXAMPLES)$/text$/modifying_text_automatically$/using_regular_expressions.odt
+
+DIR_FILE_LIST= \
+ $(DRAWING_FILES) \
+ $(FORMSANDCONTROLS_FILES) \
+ $(SHEET_FILES) \
+ $(STOCKQUOTEUPDATER_FILES) \
+ $(TEXT_FILES) \
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/ex_basic_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/ex_basic_files.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
+
diff --git a/odk/examples/basic/sheet/adapting_to_euroland.ods b/odk/examples/basic/sheet/adapting_to_euroland.ods
new file mode 100644
index 000000000000..6c1ced5afae7
--- /dev/null
+++ b/odk/examples/basic/sheet/adapting_to_euroland.ods
Binary files differ
diff --git a/odk/examples/basic/stock_quotes_updater/stock.ods b/odk/examples/basic/stock_quotes_updater/stock.ods
new file mode 100644
index 000000000000..5b530b5cd9b0
--- /dev/null
+++ b/odk/examples/basic/stock_quotes_updater/stock.ods
Binary files differ
diff --git a/odk/examples/basic/text/creating_an_index/index.odt b/odk/examples/basic/text/creating_an_index/index.odt
new file mode 100644
index 000000000000..7af60ff29ce0
--- /dev/null
+++ b/odk/examples/basic/text/creating_an_index/index.odt
Binary files differ
diff --git a/odk/examples/basic/text/creating_an_index/indexlist.txt b/odk/examples/basic/text/creating_an_index/indexlist.txt
new file mode 100644
index 000000000000..43c548a7e9d4
--- /dev/null
+++ b/odk/examples/basic/text/creating_an_index/indexlist.txt
@@ -0,0 +1,9 @@
+Sun
+StarOffice
+Solaris
+Java
+Developer
+technology
+Administration
+countries
+
diff --git a/odk/examples/basic/text/modifying_text_automatically/changing_appearance.odt b/odk/examples/basic/text/modifying_text_automatically/changing_appearance.odt
new file mode 100644
index 000000000000..ac718501c5ce
--- /dev/null
+++ b/odk/examples/basic/text/modifying_text_automatically/changing_appearance.odt
Binary files differ
diff --git a/odk/examples/basic/text/modifying_text_automatically/inserting_bookmarks.odt b/odk/examples/basic/text/modifying_text_automatically/inserting_bookmarks.odt
new file mode 100644
index 000000000000..aea712f177d7
--- /dev/null
+++ b/odk/examples/basic/text/modifying_text_automatically/inserting_bookmarks.odt
Binary files differ
diff --git a/odk/examples/basic/text/modifying_text_automatically/replacing_text.odt b/odk/examples/basic/text/modifying_text_automatically/replacing_text.odt
new file mode 100644
index 000000000000..14a3882cc5c5
--- /dev/null
+++ b/odk/examples/basic/text/modifying_text_automatically/replacing_text.odt
Binary files differ
diff --git a/odk/examples/basic/text/modifying_text_automatically/using_regular_expressions.odt b/odk/examples/basic/text/modifying_text_automatically/using_regular_expressions.odt
new file mode 100644
index 000000000000..9374b6cb0183
--- /dev/null
+++ b/odk/examples/basic/text/modifying_text_automatically/using_regular_expressions.odt
Binary files differ
diff --git a/odk/examples/cpp/DocumentLoader/DocumentLoader.cxx b/odk/examples/cpp/DocumentLoader/DocumentLoader.cxx
new file mode 100644
index 000000000000..a2ea5b4f9107
--- /dev/null
+++ b/odk/examples/cpp/DocumentLoader/DocumentLoader.cxx
@@ -0,0 +1,167 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+/*****************************************************************************
+ *****************************************************************************
+ *
+ * Simple client application using the UnoUrlResolver service.
+ *
+ *****************************************************************************
+ *****************************************************************************/
+#include <stdio.h>
+#include <wchar.h>
+
+#include <sal/main.h>
+
+#include <cppuhelper/bootstrap.hxx>
+
+#include <osl/file.hxx>
+#include <osl/process.h>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+
+#include <string.h>
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::bridge;
+using namespace com::sun::star::frame;
+using namespace com::sun::star::registry;
+
+
+
+//============================================================================
+SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
+{
+ OUString sConnectionString(RTL_CONSTASCII_USTRINGPARAM("uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager"));
+ if (argc < 2)
+ {
+ printf("using: DocumentLoader <file_url> [<uno_connection_url>]\n\n"
+ "example: DocumentLoader \"file:///e:/temp/test.odt\" \"uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager\"\n");
+ exit(1);
+ }
+ if (argc == 3)
+ {
+ sConnectionString = OUString::createFromAscii(argv[2]);
+ }
+
+ // Creates a simple registry service instance.
+ Reference< XSimpleRegistry > xSimpleRegistry(
+ ::cppu::createSimpleRegistry() );
+
+ // Connects the registry to a persistent data source represented by an URL.
+ xSimpleRegistry->open( OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "DocumentLoader.rdb") ), sal_True, sal_False );
+
+ /* Bootstraps an initial component context with service manager upon a given
+ registry. This includes insertion of initial services:
+ - (registry) service manager, shared lib loader,
+ - simple registry, nested registry,
+ - implementation registration
+ - registry typedescription provider, typedescription manager (also
+ installs it into cppu core)
+ */
+ Reference< XComponentContext > xComponentContext(
+ ::cppu::bootstrap_InitialComponentContext( xSimpleRegistry ) );
+
+ /* Gets the service manager instance to be used (or null). This method has
+ been added for convenience, because the service manager is a often used
+ object.
+ */
+ Reference< XMultiComponentFactory > xMultiComponentFactoryClient(
+ xComponentContext->getServiceManager() );
+
+ /* Creates an instance of a component which supports the services specified
+ by the factory.
+ */
+ Reference< XInterface > xInterface =
+ xMultiComponentFactoryClient->createInstanceWithContext(
+ OUString::createFromAscii( "com.sun.star.bridge.UnoUrlResolver" ),
+ xComponentContext );
+
+ Reference< XUnoUrlResolver > resolver( xInterface, UNO_QUERY );
+
+ // Resolves the component context from the office, on the uno URL given by argv[1].
+ try
+ {
+ xInterface = Reference< XInterface >(
+ resolver->resolve( sConnectionString ), UNO_QUERY );
+ }
+ catch ( Exception& e )
+ {
+ printf("Error: cannot establish a connection using '%s':\n %s\n",
+ OUStringToOString(sConnectionString, RTL_TEXTENCODING_ASCII_US).getStr(),
+ OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US).getStr());
+ exit(1);
+ }
+
+ // gets the server component context as property of the office component factory
+ Reference< XPropertySet > xPropSet( xInterface, UNO_QUERY );
+ xPropSet->getPropertyValue( OUString::createFromAscii("DefaultContext") ) >>= xComponentContext;
+
+ // gets the service manager from the office
+ Reference< XMultiComponentFactory > xMultiComponentFactoryServer(
+ xComponentContext->getServiceManager() );
+
+ /* Creates an instance of a component which supports the services specified
+ by the factory. Important: using the office component context.
+ */
+ Reference < XComponentLoader > xComponentLoader(
+ xMultiComponentFactoryServer->createInstanceWithContext(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop" ) ),
+ xComponentContext ), UNO_QUERY );
+
+ /* Loads a component specified by an URL into the specified new or existing
+ frame.
+ */
+ OUString sAbsoluteDocUrl, sWorkingDir, sDocPathUrl;
+ osl_getProcessWorkingDir(&sWorkingDir.pData);
+ osl::FileBase::getFileURLFromSystemPath( OUString::createFromAscii(argv[1]), sDocPathUrl);
+ osl::FileBase::getAbsoluteFileURL( sWorkingDir, sDocPathUrl, sAbsoluteDocUrl);
+
+ Reference< XComponent > xComponent = xComponentLoader->loadComponentFromURL(
+ sAbsoluteDocUrl, OUString( RTL_CONSTASCII_USTRINGPARAM("_blank") ), 0,
+ Sequence < ::com::sun::star::beans::PropertyValue >() );
+
+ // dispose the local service manager
+ Reference< XComponent >::query( xMultiComponentFactoryClient )->dispose();
+
+ return 0;
+}
diff --git a/odk/examples/cpp/DocumentLoader/Makefile b/odk/examples/cpp/DocumentLoader/Makefile
new file mode 100644
index 000000000000..91e6f49ce41e
--- /dev/null
+++ b/odk/examples/cpp/DocumentLoader/Makefile
@@ -0,0 +1,127 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (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++ DocumentLoader 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=DocumentLoader
+COMPONENT_RDB_NAME = $(COMPONENT_NAME).rdb
+COMPONENT_RDB = $(OUT_BIN)/$(COMPONENT_RDB_NAME)
+
+OUT_COMP_INC = $(OUT_INC)/$(COMPONENT_NAME)
+OUT_COMP_GEN = $(OUT_MISC)/$(COMPONENT_NAME)
+OUT_COMP_OBJ=$(OUT_OBJ)/$(COMPONENT_NAME)
+
+COMPOENNT_ENV_FLAG = $(OUT_MISC)/cpp_$(COMPONENT_NAME)_prepare_env.flag
+
+CXXFILES = DocumentLoader.cxx
+
+OBJFILES = $(patsubst %.cxx,$(OUT_SLO_COMP)/%.$(OBJ_EXT),$(CXXFILES))
+
+# Targets
+.PHONY: ALL
+ALL : \
+ CppDocumentLoaderExample
+
+include $(SETTINGS)/stdtarget.mk
+
+# This example type library will be extended by the URE and office types
+$(OUT_BIN)/%.rdb :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ $(REGMERGE) $@ / $(URE_TYPES) $(OFFICE_TYPES)
+
+$(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)/DocumentLoader$(EXE_EXT) : $(OUT_COMP_OBJ)/DocumentLoader.$(OBJ_EXT)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
+ifeq "$(OS)" "WIN"
+ $(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_COMP_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
+
+$(COMPOENNT_ENV_FLAG) : $(COMPONENT_RDB)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ @echo --------------------------------------------------------------------------------
+ @echo Register necessary runtime components in the DocumentLoader.rdb
+ @echo --------------------------------------------------------------------------------
+ $(REGCOMP) -register -r $(COMPONENT_RDB) -c connector.uno.$(SHAREDLIB_EXT)
+ $(REGCOMP) -register -r $(COMPONENT_RDB) -c remotebridge.uno.$(SHAREDLIB_EXT)
+ $(REGCOMP) -register -r $(COMPONENT_RDB) -c bridgefac.uno.$(SHAREDLIB_EXT)
+ $(REGCOMP) -register -r $(COMPONENT_RDB) -c uuresolver.uno.$(SHAREDLIB_EXT)
+ @echo bla > $@
+
+CppDocumentLoaderExample : $(OUT_BIN)/DocumentLoader$(EXE_EXT) $(COMPOENNT_ENV_FLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The example loads the "$(QM)test.odt$(QM)" document in the DocumentLoader example directory.
+ @echo I you want to load your own document, please use: DocumentLoader "$(QM)filename$(QM)" [connection_url]
+ @echo -
+ @echo Use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) DocumentLoader.run
+ @echo -
+ @echo NOTE: This example does not use the new UNO bootstrap mechanism, it uses still a socket
+ @echo $(SQM) $(SQM)connection. Before you can run this example you have to start your office in listening mode.
+ @echo -
+ @echo $(SQM) $(SQM)soffice "$(QM)-accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager$(QM)"
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_BIN)/DocumentLoader$(EXE_EXT)
+ cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@) $(subst \\,/,$(subst /,$(PS),"$(OO_SDK_HOME)/examples/cpp/DocumentLoader/test.odt"))
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_OBJ))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMPOENNT_ENV_FLAG)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMPONENT_RDB)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/DocumentLoader*))
diff --git a/odk/examples/cpp/DocumentLoader/test.odt b/odk/examples/cpp/DocumentLoader/test.odt
new file mode 100644
index 000000000000..82edb8ef595a
--- /dev/null
+++ b/odk/examples/cpp/DocumentLoader/test.odt
Binary files differ
diff --git a/odk/examples/cpp/complextoolbarcontrols/Addons.xcu b/odk/examples/cpp/complextoolbarcontrols/Addons.xcu
new file mode 100644
index 000000000000..52ef0d376ca4
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/Addons.xcu
@@ -0,0 +1,170 @@
+<?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="OfficeToolBar">
+ <node oor:name="com.sun.star.comp.framework.addon.complextoolbarcontrols" oor:op="replace">
+ <node oor:name="m1" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:Command1</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Image Button</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,com.sun.star.sheet.SpreadsheetDocument</value>
+ </prop>
+ <prop oor:name="ControlType" oor:type="xs:string">
+ <value>ImageButton</value>
+ </prop>
+ </node>
+ <node oor:name="m2" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:Command2</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">ComboBox</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,com.sun.star.sheet.SpreadsheetDocument</value>
+ </prop>
+ <prop oor:name="ControlType" oor:type="xs:string">
+ <value>Combobox</value>
+ </prop>
+ <prop oor:name="Width" oor:type="xs:long">
+ <value>200</value>
+ </prop>
+ </node>
+ <node oor:name="m3" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>private:separator</value>
+ </prop>
+ </node>
+ <node oor:name="m4" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:Command5</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Spinfield</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,com.sun.star.sheet.SpreadsheetDocument</value>
+ </prop>
+ <prop oor:name="ControlType" oor:type="xs:string">
+ <value>Spinfield</value>
+ </prop>
+ <prop oor:name="Width" oor:type="xs:long">
+ <value>70</value>
+ </prop>
+ </node>
+ <node oor:name="m5" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>private:separator</value>
+ </prop>
+ </node>
+ <node oor:name="m6" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:Command6</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Editfield</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,com.sun.star.sheet.SpreadsheetDocument</value>
+ </prop>
+ <prop oor:name="ControlType" oor:type="xs:string">
+ <value>Editfield</value>
+ </prop>
+ <prop oor:name="Width" oor:type="xs:long">
+ <value>130</value>
+ </prop>
+ </node>
+ <node oor:name="m7" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>private:separator</value>
+ </prop>
+ </node>
+ <node oor:name="m8" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:Command7</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Dropdownbox</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,com.sun.star.sheet.SpreadsheetDocument</value>
+ </prop>
+ <prop oor:name="ControlType" oor:type="xs:string">
+ <value>Dropdownbox</value>
+ </prop>
+ <prop oor:name="Width" oor:type="xs:long">
+ <value>80</value>
+ </prop>
+ </node>
+ <node oor:name="m9" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:Command3</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Toggle Dropdown Button</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,com.sun.star.sheet.SpreadsheetDocument</value>
+ </prop>
+ <prop oor:name="ControlType" oor:type="xs:string">
+ <value>ToggleDropdownButton</value>
+ </prop>
+ </node>
+ <node oor:name="m10" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:Command4</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Dropdown Button</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,com.sun.star.sheet.SpreadsheetDocument</value>
+ </prop>
+ <prop oor:name="ControlType" oor:type="xs:string">
+ <value>DropdownButton</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="Images">
+ <node oor:name="vnd.demo.complextoolbarcontrols.image1" oor:op="replace">
+ <prop oor:name="URL">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:Command1</value>
+ </prop>
+ <node oor:name="UserDefinedImages">
+ <prop oor:name="ImageSmallURL" oor:type="xs:string">
+ <value>%origin%/logo_small.png</value>
+ </prop>
+ <prop oor:name="ImageBigURL" oor:type="xs:string">
+ <value>%origin%/logo_big.png</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/cpp/complextoolbarcontrols/CalcListener.cxx b/odk/examples/cpp/complextoolbarcontrols/CalcListener.cxx
new file mode 100644
index 000000000000..c0972003b7c4
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/CalcListener.cxx
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "MyListener.h"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+void SAL_CALL CalcListener::notifyEvent( const ::com::sun::star::document::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException)
+{
+}
+
+void SAL_CALL CalcListener::disposing( const com::sun::star::lang::EventObject& aSource ) throw( com::sun::star::uno::RuntimeException )
+{
+}
+
diff --git a/odk/examples/cpp/complextoolbarcontrols/CalcWindowState.xcu b/odk/examples/cpp/complextoolbarcontrols/CalcWindowState.xcu
new file mode 100644
index 000000000000..dbb79464f8a0
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/CalcWindowState.xcu
@@ -0,0 +1,21 @@
+<?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="CalcWindowState" oor:package="org.openoffice.Office.UI">
+ <node oor:name="UIElements">
+ <node oor:name="States">
+ <node oor:name="private:resource/toolbar/addon_com.sun.star.comp.framework.addon.complextoolbarcontrols" oor:op="replace">
+ <prop oor:name="ContextSensitive" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ <prop oor:name="UIName" oor:type="xs:string">
+ <value xml:lang="en-US">Complex Toolbar Controls</value>
+ </prop>
+ <prop oor:name="Visible" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ <prop oor:name="Docked" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+</oor:component-data> \ No newline at end of file
diff --git a/odk/examples/cpp/complextoolbarcontrols/Jobs.xcu b/odk/examples/cpp/complextoolbarcontrols/Jobs.xcu
new file mode 100644
index 000000000000..342b6fe3120e
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/Jobs.xcu
@@ -0,0 +1,23 @@
+<?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="DemoAddOn" oor:op="replace">
+ <prop oor:name="Service">
+ <value>vnd.demo.NewDocListener</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Events">
+ <node oor:name="OnNew" oor:op="replace">
+ <node oor:name="JobList">
+ <node oor:name="DemoAddOn" oor:op="replace"/>
+ </node>
+ </node>
+ <node oor:name="OnLoad" oor:op="replace">
+ <node oor:name="JobList">
+ <node oor:name="DemoAddOn" oor:op="replace"/>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/cpp/complextoolbarcontrols/ListenerHelper.cxx b/odk/examples/cpp/complextoolbarcontrols/ListenerHelper.cxx
new file mode 100644
index 000000000000..db97302d6b8d
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/ListenerHelper.cxx
@@ -0,0 +1,144 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "ListenerHelper.h"
+
+using com::sun::star::frame::XFrame;
+using com::sun::star::frame::XDispatch;
+using com::sun::star::frame::XStatusListener;
+using com::sun::star::lang::XEventListener;
+using com::sun::star::lang::EventObject;
+using com::sun::star::uno::Reference;
+using com::sun::star::uno::RuntimeException;
+using com::sun::star::frame::FeatureStateEvent;
+
+static AllListeners aListeners;
+
+void ListenerHelper::AddListener(
+ const Reference < XFrame >& xFrame,
+ const Reference < XStatusListener > xControl,
+ const ::rtl::OUString& aCommand )
+{
+ sal_uInt32 i=0;
+ sal_uInt32 nSize = aListeners.size();
+ for ( i=0; i<nSize; i++ )
+ if ( aListeners[i].xFrame == xFrame )
+ break;
+
+ OSL_ENSURE( i<nSize, "No dispatch found for this listener!" );
+ aListeners[i].aContainer[aCommand].push_back( xControl );
+}
+
+void ListenerHelper::RemoveListener(
+ const Reference < XFrame >& xFrame,
+ const Reference < XStatusListener > xControl,
+ const ::rtl::OUString& aCommand )
+{
+ sal_uInt32 nSize = aListeners.size();
+ for ( sal_uInt32 i=0; i<nSize; i++ )
+ {
+ if ( aListeners[i].xFrame == xFrame )
+ {
+ StatusListeners& aL = aListeners[i].aContainer[aCommand];
+ StatusListeners::iterator aIter = aL.begin();
+ while ( aIter != aL.end() )
+ {
+ if ( (*aIter) == xControl )
+ {
+ aL.erase( aIter );
+ break;
+ }
+
+ aIter++;
+ }
+ }
+ }
+}
+
+void ListenerHelper::Notify(
+ const Reference < XFrame >& xFrame,
+ const ::rtl::OUString& aCommand,
+ FeatureStateEvent& rEvent )
+{
+ sal_uInt32 nSize = aListeners.size();
+ for ( sal_uInt32 i=0; i<nSize; i++ )
+ {
+ if ( aListeners[i].xFrame == xFrame )
+ {
+ rEvent.Source = aListeners[i].xDispatch;
+ StatusListeners& aL = aListeners[i].aContainer[aCommand];
+ StatusListeners::iterator aIter = aL.begin();
+ while ( aIter != aL.end() )
+ {
+ (*aIter)->statusChanged( rEvent );
+ aIter++;
+ }
+ }
+ }
+}
+
+com::sun::star::uno::Reference < XDispatch > ListenerHelper::GetDispatch(
+ const Reference < XFrame >& xFrame,
+ const ::rtl::OUString& aCommand )
+{
+ sal_uInt32 nSize = aListeners.size();
+ for ( sal_uInt32 i=0; i<nSize; i++ )
+ {
+ if ( aListeners[i].xFrame == xFrame )
+ return aListeners[i].xDispatch;
+ }
+
+ return Reference < XDispatch >();
+}
+
+void ListenerHelper::AddDispatch(
+ const Reference < XDispatch > xDispatch,
+ const Reference < XFrame >& xFrame,
+ const ::rtl::OUString& aCommand )
+{
+ ListenerItem aItem;
+ aItem.xFrame = xFrame;
+ aItem.xDispatch = xDispatch;
+ aListeners.push_back( aItem );
+ xFrame->addEventListener( new ListenerItemEventListener( xFrame ) );
+}
+
+void SAL_CALL ListenerItemEventListener::disposing( const EventObject& aEvent) throw (RuntimeException)
+{
+ AllListeners::iterator aIter = aListeners.begin();
+ while ( aIter != aListeners.end() )
+ {
+ if ( (*aIter).xFrame == mxFrame )
+ {
+ aListeners.erase( aIter );
+ break;
+ }
+
+ aIter++;
+ }
+}
diff --git a/odk/examples/cpp/complextoolbarcontrols/ListenerHelper.h b/odk/examples/cpp/complextoolbarcontrols/ListenerHelper.h
new file mode 100644
index 000000000000..6a60ab1d5a46
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/ListenerHelper.h
@@ -0,0 +1,82 @@
+#include <vector>
+#include <hash_map>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XStatusListener.hpp>
+#include <com/sun/star/frame/FeatureStateEvent.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+
+#include <rtl/ustring.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+struct hashObjectName_Impl
+{
+ size_t operator()(const ::rtl::OUString Str) const
+ {
+ return (size_t)Str.hashCode();
+ }
+};
+
+struct eqObjectName_Impl
+{
+ sal_Bool operator()(const ::rtl::OUString Str1, const ::rtl::OUString Str2) const
+ {
+ return ( Str1 == Str2 );
+ }
+};
+
+typedef std::vector < com::sun::star::uno::Reference < com::sun::star::frame::XStatusListener > > StatusListeners;
+
+typedef std::hash_map
+<
+ ::rtl::OUString,
+ StatusListeners,
+ hashObjectName_Impl,
+ eqObjectName_Impl
+>
+ListenerMap;
+
+// For every frame there is *one* Dispatch object for all possible commands
+// this struct contains an array of listeners for every supported command
+// these arrays are accessed by a hash_map (with the command string as index)
+struct ListenerItem
+{
+ ListenerMap aContainer;
+ ::com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > xDispatch;
+ ::com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame;
+};
+
+typedef std::vector < ListenerItem > AllListeners;
+
+class ListenerHelper
+{
+public:
+ void AddListener(
+ const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
+ const com::sun::star::uno::Reference < com::sun::star::frame::XStatusListener > xControl,
+ const ::rtl::OUString& aCommand );
+ void RemoveListener(
+ const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
+ const com::sun::star::uno::Reference < com::sun::star::frame::XStatusListener > xControl,
+ const ::rtl::OUString& aCommand );
+ void Notify(
+ const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
+ const ::rtl::OUString& aCommand,
+ com::sun::star::frame::FeatureStateEvent& rEvent );
+ com::sun::star::uno::Reference < com::sun::star::frame::XDispatch > GetDispatch(
+ const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
+ const ::rtl::OUString& aCommand );
+ void AddDispatch(
+ const com::sun::star::uno::Reference < com::sun::star::frame::XDispatch > xDispatch,
+ const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
+ const ::rtl::OUString& aCommand );
+};
+
+class ListenerItemEventListener : public cppu::WeakImplHelper1 < ::com::sun::star::lang::XEventListener >
+{
+ ::com::sun::star::uno::Reference< com::sun::star::frame::XFrame > mxFrame;
+public:
+ ListenerItemEventListener( const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame)
+ : mxFrame(xFrame)
+ {}
+ virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException);
+};
diff --git a/odk/examples/cpp/complextoolbarcontrols/Makefile b/odk/examples/cpp/complextoolbarcontrols/Makefile
new file mode 100644
index 000000000000..a21590d03d67
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/Makefile
@@ -0,0 +1,166 @@
+ #*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the complextoolbarcontrols 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=complextoolbarcontrols
+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
+COMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
+
+CXXFILES = \
+ MyProtocolHandler.cxx \
+ MyJob.cxx \
+ MyListener.cxx \
+ WriterListener.cxx \
+ CalcListener.cxx \
+ ListenerHelper.cxx \
+ exports.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) $(STL_INCLUDES) $(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)WriterWindowState.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)CalcWindowState.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 WriterWindowState.xcu CalcWindowState.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 WriterWindowState.xcu CalcWindowState.xcu logo_small.png logo_big.png
+ 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 --------------------------------------------------------------------------------
+
+run: $(COMP1_REGISTERFLAG)
+ "$(OFFICE_PROGRAM_PATH)$(PS)soffice" -writer
+
+
+.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/cpp/complextoolbarcontrols/MyJob.cxx b/odk/examples/cpp/complextoolbarcontrols/MyJob.cxx
new file mode 100644
index 000000000000..fa2725c721ce
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/MyJob.cxx
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _MyJob_HXX
+#include "MyJob.h"
+#endif
+#include <osl/diagnose.h>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/document/XEventBroadcaster.hpp>
+
+using rtl::OUString;
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::Reference;
+using com::sun::star::uno::Any;
+using com::sun::star::uno::UNO_QUERY;
+using com::sun::star::uno::XInterface;
+using com::sun::star::uno::Exception;
+using com::sun::star::uno::RuntimeException;
+using com::sun::star::lang::IllegalArgumentException;
+using com::sun::star::lang::XMultiServiceFactory;
+using com::sun::star::beans::NamedValue;
+using com::sun::star::document::XEventBroadcaster;
+
+Any SAL_CALL MyJob::execute( const Sequence< NamedValue >& aArguments )
+ throw ( IllegalArgumentException, Exception, RuntimeException )
+{
+ Reference < XEventBroadcaster > xBrd( mxMSF->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.GlobalEventBroadcaster") ), UNO_QUERY );
+ Reference < com::sun::star::document::XEventListener > xLstner( mxMSF->createInstance(
+ ::rtl::OUString::createFromAscii("com.sun.star.comp.Office.MyListener" ) ), UNO_QUERY );
+ if ( xBrd.is() )
+ xBrd->addEventListener( xLstner );
+ return Any();
+}
+
+OUString MyJob_getImplementationName ()
+ throw (RuntimeException)
+{
+ return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Office.MyJob" ) );
+}
+
+#define SERVICE_NAME "com.sun.star.task.Job"
+
+sal_Bool SAL_CALL MyJob_supportsService( const OUString& ServiceName )
+ throw (RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
+}
+
+Sequence< OUString > SAL_CALL MyJob_getSupportedServiceNames( )
+ throw (RuntimeException)
+{
+ Sequence < OUString > aRet(1);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
+ return aRet;
+}
+
+#undef SERVICE_NAME
+
+Reference< XInterface > SAL_CALL MyJob_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
+ throw( Exception )
+{
+ return (cppu::OWeakObject*) new MyJob( rSMgr );
+}
+
+// XServiceInfo
+OUString SAL_CALL MyJob::getImplementationName( )
+ throw (RuntimeException)
+{
+ return MyJob_getImplementationName();
+}
+
+sal_Bool SAL_CALL MyJob::supportsService( const OUString& rServiceName )
+ throw (RuntimeException)
+{
+ return MyJob_supportsService( rServiceName );
+}
+
+Sequence< OUString > SAL_CALL MyJob::getSupportedServiceNames( )
+ throw (RuntimeException)
+{
+ return MyJob_getSupportedServiceNames();
+}
diff --git a/odk/examples/cpp/complextoolbarcontrols/MyJob.h b/odk/examples/cpp/complextoolbarcontrols/MyJob.h
new file mode 100644
index 000000000000..3832b13ac738
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/MyJob.h
@@ -0,0 +1,150 @@
+#ifndef _MyJob_HXX
+
+#define _MyJob_HXX
+
+
+
+#ifndef _COM_SUN_STAR_TASK_XJOB_HPP_
+
+#include <com/sun/star/task/XJob.hpp>
+
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#endif
+
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+
+#include <cppuhelper/implbase2.hxx>
+
+#endif
+
+
+
+namespace com
+
+{
+
+ namespace sun
+
+ {
+
+ namespace star
+
+ {
+
+ namespace frame
+
+ {
+
+ class XModel;
+
+ class XFrame;
+
+ }
+
+
+
+ namespace beans
+
+ {
+
+ struct NamedValue;
+
+ }
+
+ }
+
+ }
+
+}
+
+
+
+class MyJob : public cppu::WeakImplHelper2
+
+<
+
+ com::sun::star::task::XJob,
+
+ com::sun::star::lang::XServiceInfo
+
+>
+
+{
+
+private:
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
+
+
+
+public:
+
+ MyJob( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
+
+ : mxMSF( rxMSF ) {}
+
+ virtual ~MyJob() {}
+
+
+
+ // XJob
+
+ virtual ::com::sun::star::uno::Any SAL_CALL execute(
+
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments )
+
+ throw (::com::sun::star::lang::IllegalArgumentException, ::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 MyJob_getImplementationName()
+
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+
+
+sal_Bool SAL_CALL MyJob_supportsService( const ::rtl::OUString& ServiceName )
+
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+
+
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL MyJob_getSupportedServiceNames( )
+
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+
+SAL_CALL MyJob_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/cpp/complextoolbarcontrols/MyListener.cxx b/odk/examples/cpp/complextoolbarcontrols/MyListener.cxx
new file mode 100644
index 000000000000..53ecd458c2d5
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/MyListener.cxx
@@ -0,0 +1,167 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "MyListener.h"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/document/XEventBroadcaster.hpp>
+
+namespace css = ::com::sun::star;
+
+/*-----------------------------------------------------
+ 20.11.2003 11:31
+-----------------------------------------------------*/
+MyListener::MyListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
+ : m_xSMGR(xSMGR)
+{}
+
+/*-----------------------------------------------------
+ 20.11.2003 11:32
+-----------------------------------------------------*/
+MyListener::~MyListener()
+{}
+
+/*-----------------------------------------------------
+ 20.11.2003 12:04
+-----------------------------------------------------*/
+css::uno::Any SAL_CALL MyListener::execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
+ throw (css::lang::IllegalArgumentException,
+ css::uno::Exception,
+ css::uno::RuntimeException)
+{
+ css::uno::Sequence< css::beans::NamedValue > lEnv;
+
+ sal_Int32 i = 0;
+ sal_Int32 c = lArguments.getLength();
+ const css::beans::NamedValue* p = lArguments.getConstArray();
+ for (i=0; i<c; ++i)
+ {
+ if (p[i].Name.equalsAscii("Environment"))
+ {
+ p[i].Value >>= lEnv;
+ break;
+ }
+ }
+
+ css::uno::Reference< css::frame::XModel > xModel;
+
+ c = lEnv.getLength();
+ p = lEnv.getConstArray();
+ for (i=0; i<c; ++i)
+ {
+ if (p[i].Name.equalsAscii("Model"))
+ {
+ p[i].Value >>= xModel;
+ break;
+ }
+ if (p[i].Name.equalsAscii("Frame"))
+ {
+ css::uno::Reference< css::frame::XController > xController;
+ css::uno::Reference< css::frame::XFrame > xFrame;
+ p[i].Value >>= xFrame;
+ if (xFrame.is())
+ xController = xFrame->getController();
+ if (xController.is())
+ xModel = xController->getModel();
+ break;
+ }
+ }
+
+ if (!xModel.is())
+ return css::uno::Any();
+
+ css::uno::Reference< css::lang::XServiceInfo > xInfo(xModel, css::uno::UNO_QUERY);
+ sal_Bool bCalc = xInfo->supportsService(::rtl::OUString::createFromAscii("com.sun.star.sheet.SpreadsheetDocument"));
+ sal_Bool bWriter = (
+ xInfo->supportsService(::rtl::OUString::createFromAscii("com.sun.star.text.TextDocument" )) &&
+ !xInfo->supportsService(::rtl::OUString::createFromAscii("com.sun.star.text.WebDocument" )) &&
+ !xInfo->supportsService(::rtl::OUString::createFromAscii("com.sun.star.text.GlobalDocument"))
+ );
+
+ // Wir interessieren uns nur für Writer und Calc. Werden hier aber für
+ // alle neu geöffneten Dokumente benachrichtigt ...
+ if (!bCalc && !bWriter)
+ return css::uno::Any();
+
+ void* pListener = 0;
+ if (bCalc)
+ pListener = (void*)(new CalcListener(m_xSMGR));
+ else
+ if (bWriter)
+ pListener = (void*)(new WriterListener(m_xSMGR));
+
+ css::uno::Reference< css::document::XEventListener > xDocListener (static_cast< css::document::XEventListener* >(pListener), css::uno::UNO_QUERY);
+ css::uno::Reference< css::document::XEventBroadcaster > xDocBroadcaster (xModel , css::uno::UNO_QUERY);
+
+ xDocBroadcaster->addEventListener(xDocListener);
+
+ return css::uno::Any();
+}
+
+/*-----------------------------------------------------
+ 20.11.2003 12:13
+-----------------------------------------------------*/
+::rtl::OUString SAL_CALL MyListener::getImplementationName()
+ throw (css::uno::RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii(MYLISTENER_IMPLEMENTATIONNAME);
+}
+
+/*-----------------------------------------------------
+ 20.11.2003 12:13
+-----------------------------------------------------*/
+css::uno::Sequence< ::rtl::OUString > SAL_CALL MyListener::getSupportedServiceNames()
+ throw (css::uno::RuntimeException)
+{
+ css::uno::Sequence< ::rtl::OUString > lNames(1);
+ lNames[0] = ::rtl::OUString::createFromAscii(MYLISTENER_SERVICENAME);
+ return lNames;
+}
+
+/*-----------------------------------------------------
+ 20.11.2003 12:14
+-----------------------------------------------------*/
+sal_Bool SAL_CALL MyListener::supportsService(const ::rtl::OUString& sServiceName)
+ throw (css::uno::RuntimeException)
+{
+ return (
+ sServiceName.equalsAscii(MYLISTENER_SERVICENAME) ||
+ sServiceName.equalsAscii("com.sun.star.task.Job" )
+ );
+}
+
+/*-----------------------------------------------------
+ 20.11.2003 11:31
+-----------------------------------------------------*/
+css::uno::Reference< css::uno::XInterface > MyListener::st_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
+{
+ MyListener* pListener = new MyListener(xSMGR);
+ css::uno::Reference< css::uno::XInterface > xListener(static_cast< css::task::XJob* >(pListener), css::uno::UNO_QUERY);
+ return xListener;
+}
diff --git a/odk/examples/cpp/complextoolbarcontrols/MyListener.h b/odk/examples/cpp/complextoolbarcontrols/MyListener.h
new file mode 100644
index 000000000000..d1a9c22cb6ce
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/MyListener.h
@@ -0,0 +1,96 @@
+#ifndef _MyListener_HXX
+#define _MyListener_HXX
+
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/task/XJob.hpp>
+#include <com/sun/star/document/XEventListener.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+
+#define MYLISTENER_IMPLEMENTATIONNAME "vnd.My.impl.NewDocListener"
+#define MYLISTENER_SERVICENAME "vnd.My.NewDocListener"
+
+namespace css = ::com::sun::star;
+
+/*---------------------------------------------------
+ * Registriert sich in der Office Konfiguration als Job.
+ * Dieser wird dann für alle neu geöffneten Dokumente automatisch
+ * gerufen. Man bekommt eine Reference auf das geöffnete Dokument
+ * überreicht und kann dann prüfen, ob es ein unterstütztes Format
+ * hat. (Wir interessieren uns ja schließlich nur für Writer/Calc Dokumente.)
+ *
+ * @see CalcListener
+ * @see WriterListener
+ */
+class MyListener : public cppu::WeakImplHelper2< css::task::XJob ,
+ css::lang::XServiceInfo >
+{
+ private:
+ css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
+
+ public:
+ MyListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
+ virtual ~MyListener();
+
+ // XJob
+ virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
+ throw (css::lang::IllegalArgumentException,
+ css::uno::Exception,
+ css::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& sServiceName)
+ throw (css::uno::RuntimeException);
+
+ virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw (css::uno::RuntimeException);
+
+ public:
+
+ static css::uno::Reference< css::uno::XInterface > st_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
+};
+
+class CalcListener : public cppu::WeakImplHelper1< css::document::XEventListener >
+{
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
+
+
+ public:
+ CalcListener(const css::uno::Reference< css::lang::XMultiServiceFactory > &rxMSF)
+ : mxMSF( rxMSF )
+ {}
+
+ virtual ~CalcListener()
+ {}
+
+ // document.XEventListener
+ virtual void SAL_CALL notifyEvent(const css::document::EventObject& aEvent)
+ throw (css::uno::RuntimeException);
+ virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
+ throw (css::uno::RuntimeException);
+};
+
+class WriterListener : public cppu::WeakImplHelper1< css::document::XEventListener >
+{
+ private:
+ css::uno::Reference< css::lang::XMultiServiceFactory > mxMSF;
+
+ public:
+ WriterListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& rxMSF);
+
+ virtual ~WriterListener()
+ {}
+
+ // document.XEventListener
+ virtual void SAL_CALL notifyEvent(const css::document::EventObject& aEvent)
+ throw (css::uno::RuntimeException);
+ virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
+ throw (css::uno::RuntimeException);
+};
+
+#endif // _MyListener_HXX
diff --git a/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx b/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx
new file mode 100644
index 000000000000..b9a966729200
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx
@@ -0,0 +1,539 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "ListenerHelper.h"
+#include "MyProtocolHandler.h"
+#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/frame/DispatchDescriptor.hpp>
+#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include <com/sun/star/text/XTextViewCursor.hpp>
+#include <com/sun/star/text/XTextCursor.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheetView.hpp>
+#include <com/sun/star/frame/ControlCommand.hpp>
+#include <com/sun/star/frame/ControlEvent.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XControlNotificationListener.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/awt/XWindowPeer.hpp>
+#include <com/sun/star/awt/WindowAttribute.hpp>
+#include <com/sun/star/awt/XMessageBox.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/system/XSystemShellExecute.hpp>
+#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/container/XContainerQuery.hpp>
+
+#include <osl/file.hxx>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::frame;
+using com::sun::star::lang::XMultiServiceFactory;
+using com::sun::star::beans::PropertyValue;
+using com::sun::star::util::URL;
+using com::sun::star::text::XTextViewCursorSupplier;
+using com::sun::star::text::XTextViewCursor;
+using com::sun::star::text::XTextCursor;
+using com::sun::star::sheet::XSpreadsheetView;
+using com::sun::star::frame::XModel;
+using com::sun::star::text::XTextRange;
+using com::sun::star::text::XTextDocument;
+using com::sun::star::beans::NamedValue;
+using namespace com::sun::star::awt;
+using com::sun::star::view::XSelectionSupplier;
+using namespace com::sun::star::system;
+
+ListenerHelper aListenerHelper;
+
+void BaseDispatch::ShowMessageBox( const Reference< XFrame >& rFrame, const ::rtl::OUString& aTitle, const ::rtl::OUString& aMsgText )
+{
+ if ( !mxToolkit.is() )
+ mxToolkit = Reference< XToolkit > ( mxMSF->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.awt.Toolkit" ))), UNO_QUERY );
+ if ( rFrame.is() && mxToolkit.is() )
+ {
+ // describe window properties.
+ WindowDescriptor aDescriptor;
+ aDescriptor.Type = WindowClass_MODALTOP;
+ aDescriptor.WindowServiceName = ::rtl::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 = mxToolkit->createWindow( aDescriptor );
+ if ( xPeer.is() )
+ {
+ Reference< XMessageBox > xMsgBox( xPeer, UNO_QUERY );
+ if ( xMsgBox.is() )
+ {
+ xMsgBox->setCaptionText( aTitle );
+ xMsgBox->setMessageText( aMsgText );
+ xMsgBox->execute();
+ }
+ }
+ }
+}
+
+void BaseDispatch::SendCommand( const com::sun::star::util::URL& aURL, const ::rtl::OUString& rCommand, const Sequence< NamedValue >& rArgs, sal_Bool bEnabled )
+{
+ Reference < XDispatch > xDispatch =
+ aListenerHelper.GetDispatch( mxFrame, aURL.Path );
+
+ FeatureStateEvent aEvent;
+
+ aEvent.FeatureURL = aURL;
+ aEvent.Source = xDispatch;
+ aEvent.IsEnabled = bEnabled;
+ aEvent.Requery = sal_False;
+
+ ControlCommand aCtrlCmd;
+ aCtrlCmd.Command = rCommand;
+ aCtrlCmd.Arguments = rArgs;
+
+ aEvent.State <<= aCtrlCmd;
+ aListenerHelper.Notify( mxFrame, aEvent.FeatureURL.Path, aEvent );
+}
+
+void BaseDispatch::SendCommandTo( const Reference< XStatusListener >& xControl, const URL& aURL, const ::rtl::OUString& rCommand, const Sequence< NamedValue >& rArgs, sal_Bool bEnabled )
+{
+ FeatureStateEvent aEvent;
+
+ aEvent.FeatureURL = aURL;
+ aEvent.Source = (::com::sun::star::frame::XDispatch*) this;
+ aEvent.IsEnabled = bEnabled;
+ aEvent.Requery = sal_False;
+
+ ControlCommand aCtrlCmd;
+ aCtrlCmd.Command = rCommand;
+ aCtrlCmd.Arguments = rArgs;
+
+ aEvent.State <<= aCtrlCmd;
+ xControl->statusChanged( aEvent );
+}
+
+void SAL_CALL MyProtocolHandler::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException)
+{
+ Reference < XFrame > xFrame;
+ if ( aArguments.getLength() )
+ {
+ // das erste Argument ist immer der Frame, da ein ProtocolHandler den braucht um Zugriff
+ // auf den Context zu haben, in dem er aufgerufen wird
+ aArguments[0] >>= xFrame;
+ mxFrame = xFrame;
+ }
+}
+
+Reference< XDispatch > SAL_CALL MyProtocolHandler::queryDispatch( const URL& aURL, const ::rtl::OUString& sTargetFrameName, sal_Int32 nSearchFlags )
+ throw( RuntimeException )
+{
+ Reference < XDispatch > xRet;
+ if ( !mxFrame.is() )
+ return 0;
+
+ Reference < XController > xCtrl = mxFrame->getController();
+ if ( xCtrl.is() && !aURL.Protocol.compareToAscii("vnd.demo.complextoolbarcontrols.demoaddon:") )
+ {
+ Reference < XTextViewCursorSupplier > xCursor( xCtrl, UNO_QUERY );
+ Reference < XSpreadsheetView > xView( xCtrl, UNO_QUERY );
+ if ( !xCursor.is() && !xView.is() )
+ // ohne ein entsprechendes Dokument funktioniert der Handler nicht
+ return xRet;
+
+ if ( aURL.Path.equalsAscii("Command1" ) ||
+ aURL.Path.equalsAscii("Command2" ) ||
+ aURL.Path.equalsAscii("Command3" ) ||
+ aURL.Path.equalsAscii("Command4" ) ||
+ aURL.Path.equalsAscii("Command5" ) ||
+ aURL.Path.equalsAscii("Command6" ) ||
+ aURL.Path.equalsAscii("Command7" ) )
+ {
+ xRet = aListenerHelper.GetDispatch( mxFrame, aURL.Path );
+ if ( !xRet.is() )
+ {
+ xRet = xCursor.is() ? (BaseDispatch*) new WriterDispatch( mxMSF, mxFrame ) :
+ (BaseDispatch*) new CalcDispatch( mxMSF, mxFrame );
+ aListenerHelper.AddDispatch( xRet, mxFrame, aURL.Path );
+ }
+ }
+ }
+
+ return xRet;
+}
+
+Sequence < Reference< XDispatch > > SAL_CALL MyProtocolHandler::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;
+}
+
+::rtl::OUString MyProtocolHandler_getImplementationName ()
+ throw (RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii(MYPROTOCOLHANDLER_IMPLEMENTATIONNAME);
+}
+
+sal_Bool SAL_CALL MyProtocolHandler_supportsService( const ::rtl::OUString& ServiceName )
+ throw (RuntimeException)
+{
+ return (
+ ServiceName.equalsAscii(MYPROTOCOLHANDLER_SERVICENAME ) ||
+ ServiceName.equalsAscii("com.sun.star.frame.ProtocolHandler")
+ );
+}
+
+Sequence< ::rtl::OUString > SAL_CALL MyProtocolHandler_getSupportedServiceNames( )
+ throw (RuntimeException)
+{
+ Sequence < ::rtl::OUString > aRet(1);
+ aRet[0] = ::rtl::OUString::createFromAscii(MYPROTOCOLHANDLER_SERVICENAME);
+ return aRet;
+}
+
+#undef SERVICE_NAME
+
+Reference< XInterface > SAL_CALL MyProtocolHandler_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
+ throw( Exception )
+{
+ return (cppu::OWeakObject*) new MyProtocolHandler( rSMgr );
+}
+
+// XServiceInfo
+::rtl::OUString SAL_CALL MyProtocolHandler::getImplementationName( )
+ throw (RuntimeException)
+{
+ return MyProtocolHandler_getImplementationName();
+}
+
+sal_Bool SAL_CALL MyProtocolHandler::supportsService( const ::rtl::OUString& rServiceName )
+ throw (RuntimeException)
+{
+ return MyProtocolHandler_supportsService( rServiceName );
+}
+
+Sequence< ::rtl::OUString > SAL_CALL MyProtocolHandler::getSupportedServiceNames( )
+ throw (RuntimeException)
+{
+ return MyProtocolHandler_getSupportedServiceNames();
+}
+
+void SAL_CALL BaseDispatch::dispatch( const URL& aURL, const Sequence < PropertyValue >& lArgs ) throw (RuntimeException)
+{
+ /* Its neccessary to hold this object alive, till this method finish.
+ May the outside dispatch cache (implemented by the menu/toolbar!)
+ forget this instance during de-/activation of frames (focus!).
+
+ E.g. An open db beamer in combination with the My-Dialog
+ can force such strange situation :-(
+ */
+ Reference< XInterface > xSelfHold(static_cast< XDispatch* >(this), UNO_QUERY);
+
+ if ( !aURL.Protocol.compareToAscii("vnd.demo.complextoolbarcontrols.demoaddon:") )
+ {
+ if ( !aURL.Path.compareToAscii("Command1" ) )
+ {
+ // open the OpenOffice.org web page
+ ::rtl::OUString sURL(::rtl::OUString::createFromAscii("http://www.openoffice.org"));
+ Reference< XSystemShellExecute > xSystemShellExecute( mxMSF->createInstance(
+ ::rtl::OUString::createFromAscii( "com.sun.star.system.SystemShellExecute" )), UNO_QUERY );
+ if ( xSystemShellExecute.is() )
+ {
+ try
+
+ {
+ xSystemShellExecute->execute( sURL, ::rtl::OUString(), SystemShellExecuteFlags::DEFAULTS );
+ }
+ catch( Exception& rEx )
+ {
+ (void)rEx;
+ }
+ }
+ }
+ else if ( !aURL.Path.compareToAscii("Command2" ) )
+ {
+ // remove the text if it's in our list
+ Sequence< NamedValue > aRemoveArgs( 1 );
+ aRemoveArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ));
+ aRemoveArgs[0].Value <<= maComboBoxText;
+ SendCommand( aURL, ::rtl::OUString::createFromAscii( "RemoveEntryText" ), aRemoveArgs, sal_True );
+
+ // add the new text to the start of the list
+ Sequence< NamedValue > aInsertArgs( 2 );
+ aInsertArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pos" ));
+ aInsertArgs[0].Value <<= sal_Int32( 0 );
+ aInsertArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ));
+ aInsertArgs[1].Value <<= maComboBoxText;
+ SendCommand( aURL, ::rtl::OUString::createFromAscii( "InsertEntry" ), aInsertArgs, sal_True );
+ }
+ else if ( !aURL.Path.compareToAscii("Command3" ) )
+ {
+ // Retrieve the text argument from the sequence property value
+ rtl::OUString aText;
+ for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ )
+ {
+ if ( lArgs[i].Name.equalsAsciiL( "Text", 4 ))
+ {
+ lArgs[i].Value >>= aText;
+ break;
+ }
+ }
+
+ // create new URL to address the combox box
+ URL aCmdURL;
+ aCmdURL.Path = rtl::OUString::createFromAscii( "Command2" );
+ aCmdURL.Protocol = rtl::OUString::createFromAscii( "vnd.demo.complextoolbarcontrols.demoaddon:" );
+ aCmdURL.Complete = aCmdURL.Path + aCmdURL.Protocol;
+
+ // set the selected item as text into the combobox
+ Sequence< NamedValue > aArgs( 1 );
+ aArgs[0].Name = rtl::OUString::createFromAscii( "Text" );
+ aArgs[0].Value <<= aText;
+ SendCommand( aCmdURL, ::rtl::OUString::createFromAscii( "SetText" ), aArgs, sal_True );
+ }
+ else if ( !aURL.Path.compareToAscii("Command4" ) )
+ {
+ // Retrieve the text argument from the sequence property value
+ rtl::OUString aText;
+ for ( sal_Int32 i = 0; i < lArgs.getLength(); i++ )
+ {
+ if ( lArgs[i].Name.equalsAsciiL( "Text", 4 ))
+ {
+ lArgs[i].Value >>= aText;
+ break;
+ }
+ }
+
+ // just enable this command
+
+ // set enable flag according to selection
+ if ( aText.equalsAscii( "Button Disabled" ))
+ mbButtonEnabled = sal_False;
+ else
+ mbButtonEnabled = sal_True;
+
+ // create new URL to address the image button
+ URL aCmdURL;
+ aCmdURL.Path = rtl::OUString::createFromAscii( "Command1" );
+ aCmdURL.Protocol = rtl::OUString::createFromAscii( "vnd.demo.complextoolbarcontrols.demoaddon:" );
+ aCmdURL.Complete = aCmdURL.Path + aCmdURL.Protocol;
+
+ // create and initialize FeatureStateEvent with IsEnabled
+ ::com::sun::star::frame::FeatureStateEvent aEvent;
+ aEvent.FeatureURL = aCmdURL;
+ aEvent.Source = (::com::sun::star::frame::XDispatch*) this;
+ aEvent.IsEnabled = mbButtonEnabled;
+ aEvent.Requery = sal_False;
+ aEvent.State <<= Any();
+
+ // Notify listener about new state
+ Reference < XDispatch > xDispatch = aListenerHelper.GetDispatch( mxFrame, aURL.Path );
+ aListenerHelper.Notify( mxFrame, aEvent.FeatureURL.Path, aEvent );
+ }
+ else if ( !aURL.Path.compareToAscii("Command5" ) )
+ {
+ }
+ }
+}
+
+void SAL_CALL BaseDispatch::addStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL ) throw (RuntimeException)
+{
+ if ( aURL.Protocol.equalsAscii("vnd.demo.complextoolbarcontrols.demoaddon:") )
+ {
+ if ( aURL.Path.equalsAscii("Command1" ) )
+ {
+ // just enable this command
+ ::com::sun::star::frame::FeatureStateEvent aEvent;
+ aEvent.FeatureURL = aURL;
+ aEvent.Source = (::com::sun::star::frame::XDispatch*) this;
+ aEvent.IsEnabled = mbButtonEnabled;
+ aEvent.Requery = sal_False;
+ aEvent.State <<= Any();
+ xControl->statusChanged( aEvent );
+ }
+ else if ( aURL.Path.equalsAscii("Command2" ) )
+ {
+ // just enable this command
+ ::com::sun::star::frame::FeatureStateEvent aEvent;
+ aEvent.FeatureURL = aURL;
+ aEvent.Source = (::com::sun::star::frame::XDispatch*) this;
+ aEvent.IsEnabled = sal_True;
+ aEvent.Requery = sal_False;
+ aEvent.State <<= Any();
+ xControl->statusChanged( aEvent );
+ }
+ else if ( aURL.Path.equalsAscii("Command3" ) )
+ {
+ // A toggle dropdown box is normally used for a group of commands
+ // where the user can select the last issued command easily.
+ // E.g. a typical command group would be "Insert shape"
+ Sequence< NamedValue > aArgs( 1 );
+
+ // send command to set context menu content
+ Sequence< rtl::OUString > aContextMenu( 3 );
+ aContextMenu[0] = rtl::OUString::createFromAscii( "Command 1" );
+ aContextMenu[1] = rtl::OUString::createFromAscii( "Command 2" );
+ aContextMenu[2] = rtl::OUString::createFromAscii( "Command 3" );
+
+ aArgs[0].Name = rtl::OUString::createFromAscii( "List" );
+ aArgs[0].Value <<= aContextMenu;
+ SendCommandTo( xControl, aURL, rtl::OUString::createFromAscii( "SetList" ), aArgs, sal_True );
+
+ // send command to check item on pos=0
+ aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pos" ));
+ aArgs[0].Value <<= sal_Int32( 0 );
+ SendCommandTo( xControl, aURL, ::rtl::OUString::createFromAscii( "CheckItemPos" ), aArgs, sal_True );
+ }
+ else if ( aURL.Path.equalsAscii("Command4" ) )
+ {
+ // A dropdown box is normally used for a group of dependent modes, where
+ // the user can only select one. The modes cannot be combined.
+ // E.g. a typical group would be left,right,center,block.
+ Sequence< NamedValue > aArgs( 1 );
+
+ // send command to set context menu content
+ Sequence< rtl::OUString > aContextMenu( 2 );
+ aContextMenu[0] = rtl::OUString::createFromAscii( "Button Enabled" );
+ aContextMenu[1] = rtl::OUString::createFromAscii( "Button Disabled" );
+
+ aArgs[0].Name = rtl::OUString::createFromAscii( "List" );
+ aArgs[0].Value <<= aContextMenu;
+ SendCommandTo( xControl, aURL, rtl::OUString::createFromAscii( "SetList" ), aArgs, sal_True );
+
+ // set position according to enable/disable state of button
+ sal_Int32 nPos( mbButtonEnabled ? 0 : 1 );
+
+ // send command to check item on pos=0
+ aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pos" ));
+ aArgs[0].Value <<= nPos;
+ SendCommandTo( xControl, aURL, ::rtl::OUString::createFromAscii( "CheckItemPos" ), aArgs, sal_True );
+ }
+ else if ( aURL.Path.equalsAscii("Command5" ) )
+ {
+ // A spin button
+ Sequence< NamedValue > aArgs( 5 );
+
+ // send command to initialize spin button
+ aArgs[0].Name = rtl::OUString::createFromAscii( "Value" );
+ aArgs[0].Value <<= double( 0.0 );
+ aArgs[1].Name = rtl::OUString::createFromAscii( "UpperLimit" );
+ aArgs[1].Value <<= double( 10.0 );
+ aArgs[2].Name = rtl::OUString::createFromAscii( "LowerLimit" );
+ aArgs[2].Value <<= double( 0.0 );
+ aArgs[3].Name = rtl::OUString::createFromAscii( "Step" );
+ aArgs[3].Value <<= double( 0.1 );
+ aArgs[4].Name = rtl::OUString::createFromAscii( "OutputFormat" );
+ aArgs[4].Value <<= rtl::OUString::createFromAscii( "%.2f cm" );
+
+ SendCommandTo( xControl, aURL, rtl::OUString::createFromAscii( "SetValues" ), aArgs, sal_True );
+ }
+ else if ( aURL.Path.equalsAscii("Command7" ) )
+ {
+ // A dropdown box is normally used for a group of commands
+ // where the user can select one of a defined set.
+ Sequence< NamedValue > aArgs( 1 );
+
+ // send command to set context menu content
+ Sequence< rtl::OUString > aList( 10 );
+ aList[0] = rtl::OUString::createFromAscii( "White" );
+ aList[1] = rtl::OUString::createFromAscii( "Black" );
+ aList[2] = rtl::OUString::createFromAscii( "Red" );
+ aList[3] = rtl::OUString::createFromAscii( "Blue" );
+ aList[4] = rtl::OUString::createFromAscii( "Green" );
+ aList[5] = rtl::OUString::createFromAscii( "Grey" );
+ aList[6] = rtl::OUString::createFromAscii( "Yellow" );
+ aList[7] = rtl::OUString::createFromAscii( "Orange" );
+ aList[8] = rtl::OUString::createFromAscii( "Brown" );
+ aList[9] = rtl::OUString::createFromAscii( "Pink" );
+
+ aArgs[0].Name = rtl::OUString::createFromAscii( "List" );
+ aArgs[0].Value <<= aList;
+ SendCommandTo( xControl, aURL, rtl::OUString::createFromAscii( "SetList" ), aArgs, sal_True );
+ }
+
+ aListenerHelper.AddListener( mxFrame, xControl, aURL.Path );
+ }
+}
+
+void SAL_CALL BaseDispatch::removeStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL ) throw (RuntimeException)
+{
+ aListenerHelper.RemoveListener( mxFrame, xControl, aURL.Path );
+}
+
+void SAL_CALL BaseDispatch::controlEvent( const ControlEvent& Event ) throw (RuntimeException)
+{
+ if ( Event.aURL.Protocol.equalsAscii("vnd.demo.complextoolbarcontrols.demoaddon:" ))
+ {
+ if ( Event.aURL.Path.equalsAscii( "Command2" ))
+ {
+ // We get notifications whenever the text inside the combobox has been changed.
+ // We store the new text into a member.
+ if ( Event.Event.equalsAscii( "TextChanged" ))
+ {
+ rtl::OUString aNewText;
+ sal_Bool bHasText( sal_False );
+ for ( sal_Int32 i = 0; i < Event.aInformation.getLength(); i++ )
+ {
+ if ( Event.aInformation[i].Name.equalsAsciiL( "Text", 4 ))
+ {
+ bHasText = Event.aInformation[i].Value >>= aNewText;
+ break;
+ }
+ }
+
+ if ( bHasText )
+ maComboBoxText = aNewText;
+ }
+ }
+ }
+}
+
+BaseDispatch::BaseDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, const ::rtl::OUString& rServiceName )
+ : mxMSF( rxMSF )
+ , mxFrame( xFrame )
+ , msDocService( rServiceName )
+ , mbButtonEnabled( sal_True )
+{
+}
+
+
+BaseDispatch::~BaseDispatch()
+{
+ mxFrame.clear();
+ mxMSF.clear();
+}
diff --git a/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h b/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h
new file mode 100644
index 000000000000..8b819ce62694
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h
@@ -0,0 +1,141 @@
+#ifndef _MyProtocolHandler_HXX
+#define _MyProtocolHandler_HXX
+
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XControlNotificationListener.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <cppuhelper/implbase3.hxx>
+#ifndef _CPPUHELPER_IMPLBASE2_HXX
+#include <cppuhelper/implbase2.hxx>
+#endif
+#include <com/sun/star/awt/XToolkit.hpp>
+
+#define MYPROTOCOLHANDLER_IMPLEMENTATIONNAME "vnd.demo.Impl.ProtocolHandler"
+#define MYPROTOCOLHANDLER_SERVICENAME "vnd.demo.ProtocolHandler"
+
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace frame
+ {
+ class XModel;
+ class XFrame;
+ }
+ }
+ }
+}
+
+
+class MyProtocolHandler : public cppu::WeakImplHelper3
+<
+ com::sun::star::frame::XDispatchProvider,
+ 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;
+
+public:
+ MyProtocolHandler( 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 );
+
+ // 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 MyProtocolHandler_getImplementationName()
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+sal_Bool SAL_CALL MyProtocolHandler_supportsService( const ::rtl::OUString& ServiceName )
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL MyProtocolHandler_getSupportedServiceNames( )
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+SAL_CALL MyProtocolHandler_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
+ throw ( ::com::sun::star::uno::Exception );
+
+class BaseDispatch : public cppu::WeakImplHelper2
+<
+ ::com::sun::star::frame::XDispatch,
+ ::com::sun::star::frame::XControlNotificationListener
+>
+{
+protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > mxToolkit;
+ ::rtl::OUString msDocService;
+ ::rtl::OUString maComboBoxText;
+ sal_Bool mbButtonEnabled;
+
+public:
+ BaseDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, const ::rtl::OUString& rServiceName );
+
+ virtual ~BaseDispatch();
+
+ void ShowMessageBox( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aTitle, const ::rtl::OUString& aMsgText );
+ void SendCommand( const com::sun::star::util::URL& aURL, const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rArgs, sal_Bool bEnabled );
+ void SendCommandTo( const com::sun::star::uno::Reference< com::sun::star::frame::XStatusListener >& xControl, const com::sun::star::util::URL& aURL, const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rArgs, sal_Bool bEnabled );
+
+ // 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);
+
+ // XControlNotificationListener
+ virtual void SAL_CALL controlEvent( const ::com::sun::star::frame::ControlEvent& Event )
+ throw (::com::sun::star::uno::RuntimeException);
+};
+
+class WriterDispatch : public BaseDispatch
+{
+public:
+ WriterDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame )
+ : BaseDispatch( rxMSF, xFrame, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument" ) ) )
+ {}
+};
+
+class CalcDispatch : public BaseDispatch
+{
+public:
+ CalcDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame )
+ : BaseDispatch( rxMSF, xFrame, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadSheetDocument" ) ) )
+ {}
+};
+
+#endif
diff --git a/odk/examples/cpp/complextoolbarcontrols/ProtocolHandler.xcu b/odk/examples/cpp/complextoolbarcontrols/ProtocolHandler.xcu
new file mode 100644
index 000000000000..3bab74410a24
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/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="vnd.demo.ProtocolHandler" oor:op="replace">
+ <prop oor:name="Protocols" oor:type="oor:string-list">
+ <value>vnd.demo.complextoolbarcontrols.demoaddon:*</value>
+ </prop>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/cpp/complextoolbarcontrols/WriterListener.cxx b/odk/examples/cpp/complextoolbarcontrols/WriterListener.cxx
new file mode 100644
index 000000000000..ef2558101eb3
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/WriterListener.cxx
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "MyListener.h"
+
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+void SAL_CALL WriterListener::notifyEvent( const ::com::sun::star::document::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException)
+{
+}
+
+void SAL_CALL WriterListener::disposing( const com::sun::star::lang::EventObject& aSource ) throw( com::sun::star::uno::RuntimeException )
+{
+}
+
+WriterListener::WriterListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
+ : mxMSF( rxMSF )
+{
+}
+
+
diff --git a/odk/examples/cpp/complextoolbarcontrols/WriterWindowState.xcu b/odk/examples/cpp/complextoolbarcontrols/WriterWindowState.xcu
new file mode 100644
index 000000000000..fd5453eba348
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/WriterWindowState.xcu
@@ -0,0 +1,21 @@
+<?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="WriterWindowState" oor:package="org.openoffice.Office.UI">
+ <node oor:name="UIElements">
+ <node oor:name="States">
+ <node oor:name="private:resource/toolbar/addon_com.sun.star.comp.framework.addon.complextoolbarcontrols" oor:op="replace">
+ <prop oor:name="ContextSensitive" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ <prop oor:name="UIName" oor:type="xs:string">
+ <value xml:lang="en-US">Complex Toolbar Controls</value>
+ </prop>
+ <prop oor:name="Visible" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ <prop oor:name="Docked" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+</oor:component-data> \ No newline at end of file
diff --git a/odk/examples/cpp/complextoolbarcontrols/exports.cxx b/odk/examples/cpp/complextoolbarcontrols/exports.cxx
new file mode 100644
index 000000000000..5f79bda6b080
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/exports.cxx
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include <stdio.h>
+
+#include <osl/mutex.hxx>
+#include <osl/thread.h>
+#include <cppuhelper/factory.hxx>
+#include <rtl/ustring.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <sal/types.h>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+
+#include "MyProtocolHandler.h"
+#include "MyListener.h"
+
+namespace css = ::com::sun::star;
+
+static void writeInfo(const css::uno::Reference< css::registry::XRegistryKey >& xRegistryKey ,
+ const char* pImplementationName,
+ const char* pServiceName )
+{
+ ::rtl::OUStringBuffer sKey(256);
+ sKey.append (::rtl::OUString::createFromAscii(pImplementationName));
+ sKey.appendAscii("/UNO/SERVICES/");
+ sKey.append (::rtl::OUString::createFromAscii(pServiceName));
+
+ xRegistryKey->createKey(sKey.makeStringAndClear());
+}
+
+extern "C"
+{
+//==================================================================================================
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(const sal_Char** ppEnvTypeName,
+ uno_Environment** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//==================================================================================================
+SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(void* pServiceManager,
+ void* pRegistryKey )
+{
+ if (!pRegistryKey)
+ return sal_False;
+
+ try
+ {
+ css::uno::Reference< css::registry::XRegistryKey > xKey(reinterpret_cast< css::registry::XRegistryKey* >(pRegistryKey), css::uno::UNO_QUERY);
+
+ writeInfo( xKey, MYLISTENER_IMPLEMENTATIONNAME , MYLISTENER_SERVICENAME );
+ writeInfo( xKey, MYPROTOCOLHANDLER_IMPLEMENTATIONNAME, MYPROTOCOLHANDLER_SERVICENAME );
+
+ return sal_True;
+ }
+ catch(const css::registry::InvalidRegistryException&)
+ { OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); }
+
+ return sal_False;
+}
+
+//==================================================================================================
+SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(const sal_Char* pImplName ,
+ void* pServiceManager,
+ void* pRegistryKey )
+{
+ if ( !pServiceManager || !pImplName )
+ return 0;
+
+ css::uno::Reference< css::lang::XSingleServiceFactory > xFactory ;
+ css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR (reinterpret_cast< css::lang::XMultiServiceFactory* >(pServiceManager), css::uno::UNO_QUERY);
+ ::rtl::OUString sImplName = ::rtl::OUString::createFromAscii(pImplName);
+
+ if (sImplName.equalsAscii(MYLISTENER_IMPLEMENTATIONNAME))
+ {
+ css::uno::Sequence< ::rtl::OUString > lNames(1);
+ lNames[0] = ::rtl::OUString::createFromAscii(MYLISTENER_IMPLEMENTATIONNAME);
+ xFactory = ::cppu::createSingleFactory(xSMGR, sImplName, MyListener::st_createInstance, lNames);
+ }
+ else
+ if (sImplName.equalsAscii(MYPROTOCOLHANDLER_IMPLEMENTATIONNAME))
+ {
+ css::uno::Sequence< ::rtl::OUString > lNames(1);
+ lNames[0] = ::rtl::OUString::createFromAscii(MYPROTOCOLHANDLER_SERVICENAME);
+ xFactory = ::cppu::createSingleFactory(xSMGR, sImplName, MyProtocolHandler_createInstance, lNames);
+ }
+
+ if (!xFactory.is())
+ return 0;
+
+ xFactory->acquire();
+ return xFactory.get();
+}
+
+} // extern C
diff --git a/odk/examples/cpp/complextoolbarcontrols/logo_big.png b/odk/examples/cpp/complextoolbarcontrols/logo_big.png
new file mode 100644
index 000000000000..23dd24109dc6
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/logo_big.png
Binary files differ
diff --git a/odk/examples/cpp/complextoolbarcontrols/logo_small.png b/odk/examples/cpp/complextoolbarcontrols/logo_small.png
new file mode 100644
index 000000000000..c24b4e27554b
--- /dev/null
+++ b/odk/examples/cpp/complextoolbarcontrols/logo_small.png
Binary files differ
diff --git a/odk/examples/cpp/counter/Makefile b/odk/examples/cpp/counter/Makefile
new file mode 100644
index 000000000000..5e7f620a645c
--- /dev/null
+++ b/odk/examples/cpp/counter/Makefile
@@ -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.
+#
+#**************************************************************************
+
+# Builds the C++ counter 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=counter
+COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
+COMP_IMPL=$(SHAREDLIB_OUT)/$(COMP_IMPL_NAME)
+COMP_RDB_NAME = $(COMP_NAME).uno.rdb
+COMP_RDB = $(OUT_BIN)/$(COMP_RDB_NAME)
+COMP_MAPFILE = $(OUT_COMP_GEN)/$(COMP_NAME).uno.map
+OUT_COMP_INC = $(OUT_INC)/$(COMP_NAME)
+OUT_COMP_GEN = $(OUT_MISC)/$(COMP_NAME)
+OUT_COMP_OBJ = $(OUT_OBJ)/$(COMP_NAME)
+OUT_COMP_SLO = $(OUT_SLO)/$(COMP_NAME)
+
+COMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
+
+IDLFILES = XCountable.idl
+
+COMPCXXFILES = counter.cxx
+
+CXXFILES = countermain.cxx
+
+SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(COMPCXXFILES))
+OBJFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
+
+GENURDFILES = $(patsubst %.idl,$(OUT_COMP_GEN)/%.urd,$(IDLFILES))
+
+TYPESLIST = -Tfoo.XCountable
+
+# Targets
+.PHONY: ALL
+ALL : \
+ CppCounterExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_COMP_GEN)/%.urd : %.idl
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(IDLC) -I. -I$(IDL_DIR) -O$(OUT_COMP_GEN) $<
+
+# This example type library will be extended by the URE types
+$(OUT_BIN)/%.rdb : $(GENURDFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ $(REGMERGE) $@ /UCR $(GENURDFILES)
+ $(REGMERGE) $@ / $(URE_TYPES)
+
+$(COMP_TYPEFLAG) : $(COMP_RDB) $(SDKTYPEFLAG)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
+ $(CPPUMAKER) -Gc -BUCR -O$(OUT_COMP_INC) $(TYPESLIST) $(COMP_RDB)
+ echo flagged > $@
+
+$(OUT_COMP_OBJ)/%.$(OBJ_EXT) : %.cxx $(COMP_TYPEFLAG)
+ -$(MKDIR) $(subst /,$(PS),$(OUT_OBJ))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+
+$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(COMP_TYPEFLAG)
+ -$(MKDIR) $(subst /,$(PS),$(OUT_SLO))
+ -$(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
+
+$(OUT_BIN)/countermain$(EXE_EXT) : $(OUT_COMP_OBJ)/countermain.$(OBJ_EXT) $(SHAREDLIB_OUT)/counter.uno.$(SHAREDLIB_EXT)
+ifeq "$(OS)" "WIN"
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_COMP_GEN)/$(basename $(@F)).map \
+ $< $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB)
+else
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) $(STDC++LIB)
+endif
+
+
+CppCounterExample : $(OUT_BIN)/countermain$(EXE_EXT) $(COMP_IMPL)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) countermain.run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_BIN)/countermain$(EXE_EXT) $(COMP_IMPL)
+ cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_OBJ))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_RDB)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/countermain*))
diff --git a/odk/examples/cpp/counter/XCountable.idl b/odk/examples/cpp/counter/XCountable.idl
new file mode 100644
index 000000000000..290a134b2c0a
--- /dev/null
+++ b/odk/examples/cpp/counter/XCountable.idl
@@ -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.
+ *
+ *************************************************************************/
+
+#include <com/sun/star/uno/XInterface.idl>
+
+module foo
+{
+ /**
+ * Interface to count things.
+ */
+ interface XCountable : com::sun::star::uno::XInterface
+ {
+ long getCount();
+ void setCount( [in] long nCount );
+ long increment();
+ long decrement();
+ };
+
+ service Counter
+ {
+ // exported interfaces:
+ interface XCountable;
+ };
+};
diff --git a/odk/examples/cpp/counter/counter.cxx b/odk/examples/cpp/counter/counter.cxx
new file mode 100644
index 000000000000..0e6dbd0c5eb2
--- /dev/null
+++ b/odk/examples/cpp/counter/counter.cxx
@@ -0,0 +1,238 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+/*************************************************************************
+ *************************************************************************
+ *
+ * service implementation: foo.Counter
+ * exported interfaces: foo.XCounter
+ *
+ * simple example component implementing a counter
+ *
+ *************************************************************************
+ *************************************************************************/
+
+#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 <foo/XCountable.hpp>
+
+#define SERVICENAME "foo.Counter"
+#define IMPLNAME "com.sun.star.comp.example.cpp.Counter"
+
+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;
+using namespace ::foo;
+
+
+//========================================================================
+class MyCounterImpl
+ : public XCountable
+ , public XServiceInfo
+{
+ // to obtain other services if needed
+ Reference< XMultiServiceFactory > m_xServiceManager;
+
+ sal_Int32 m_nRefCount;
+ sal_Int32 m_nCount;
+
+public:
+ MyCounterImpl( const Reference< XMultiServiceFactory > & xServiceManager )
+ : m_xServiceManager( xServiceManager ), m_nRefCount( 0 )
+ { printf( "< MyCounterImpl ctor called >\n" ); }
+ ~MyCounterImpl()
+ { printf( "< MyCounterImpl dtor called >\n" ); }
+
+ // XInterface implementation
+ virtual void SAL_CALL acquire() throw ()
+ { ++m_nRefCount; }
+ virtual void SAL_CALL release() throw ()
+ { if (! --m_nRefCount) delete this; }
+ virtual Any SAL_CALL queryInterface( const Type & rType ) throw (RuntimeException)
+ { return cppu::queryInterface(rType,
+ static_cast< XInterface* >( static_cast< XServiceInfo* >( this ) ),
+ static_cast< XCountable* >( this ),
+ static_cast< XServiceInfo* >( this ) ); }
+
+ // XServiceInfo implementation
+ virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException);
+ static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static( );
+
+ // XCountable implementation
+ virtual sal_Int32 SAL_CALL getCount() throw (RuntimeException)
+ { return m_nCount; }
+ virtual void SAL_CALL setCount( sal_Int32 nCount ) throw (RuntimeException)
+ { m_nCount = nCount; }
+ virtual sal_Int32 SAL_CALL increment() throw (RuntimeException)
+ { return (++m_nCount); }
+ virtual sal_Int32 SAL_CALL decrement() throw (RuntimeException)
+ { return (--m_nCount); }
+};
+
+//*************************************************************************
+OUString SAL_CALL MyCounterImpl::getImplementationName( )
+ throw(RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) );
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL MyCounterImpl::supportsService( const OUString& ServiceName )
+ throw(RuntimeException)
+{
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL MyCounterImpl::getSupportedServiceNames( )
+ throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL MyCounterImpl::getSupportedServiceNames_Static( )
+{
+ OUString aName( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) );
+ return Sequence< OUString >( &aName, 1 );
+}
+
+
+
+
+/**
+ * Function to create a new component instance; is needed by factory helper implementation.
+ * @param xMgr service manager to if the components needs other component instances
+ */
+Reference< XInterface > SAL_CALL MyCounterImpl_create(
+ const Reference< XMultiServiceFactory > & xMgr )
+{
+ return Reference<XInterface>(static_cast<XCountable*>(new MyCounterImpl(xMgr)));
+}
+
+
+//#########################################################################
+//#### 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("/" IMPLNAME "/UNO/SERVICES") ) ) );
+
+ const Sequence< OUString > & rSNL =
+ MyCounterImpl::getSupportedServiceNames_Static();
+ 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, IMPLNAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) ),
+ MyCounterImpl_create,
+ MyCounterImpl::getSupportedServiceNames_Static() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
diff --git a/odk/examples/cpp/counter/countermain.cxx b/odk/examples/cpp/counter/countermain.cxx
new file mode 100644
index 000000000000..0fb4bb1f0ddb
--- /dev/null
+++ b/odk/examples/cpp/counter/countermain.cxx
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+/*************************************************************************
+ *************************************************************************
+ *
+ * simple client application registering and using the counter component.
+ *
+ *************************************************************************
+ *************************************************************************/
+
+#include <stdio.h>
+
+#include <sal/main.h>
+#include <rtl/ustring.hxx>
+
+#include <osl/diagnose.h>
+
+#include <cppuhelper/bootstrap.hxx>
+
+// generated c++ interfaces
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <foo/XCountable.hpp>
+
+
+using namespace foo;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+
+using namespace ::rtl;
+
+
+//=======================================================================
+SAL_IMPLEMENT_MAIN()
+{
+ Reference< XSimpleRegistry > xReg = createSimpleRegistry();
+ OSL_ENSURE( xReg.is(), "### cannot get service instance of \"com.sun.star.regiystry.SimpleRegistry\"!" );
+
+ xReg->open(OUString::createFromAscii("counter.uno.rdb"), sal_False, sal_False);
+ OSL_ENSURE( xReg->isValid(), "### cannot open test registry \"counter.uno.rdb\"!" );
+
+ Reference< XComponentContext > xContext = bootstrap_InitialComponentContext(xReg);
+ OSL_ENSURE( xContext.is(), "### cannot creage intial component context!" );
+
+ Reference< XMultiComponentFactory > xMgr = xContext->getServiceManager();
+ OSL_ENSURE( xMgr.is(), "### cannot get initial service manager!" );
+
+ // register my counter component
+ Reference< XImplementationRegistration > xImplReg(
+ xMgr->createInstanceWithContext(OUString::createFromAscii("com.sun.star.registry.ImplementationRegistration"), xContext), UNO_QUERY);
+ OSL_ENSURE( xImplReg.is(), "### cannot get service instance of \"com.sun.star.registry.ImplementationRegistration\"!" );
+
+ if (xImplReg.is())
+ {
+ xImplReg->registerImplementation(
+ OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), // loader for component
+#ifdef UNX
+#ifdef MACOSX
+ OUString::createFromAscii("counter.uno.dylib"), // component location
+#else
+ OUString::createFromAscii("counter.uno.so"), // component location
+#endif
+#else
+ OUString::createFromAscii("counter.uno.dll"), // component location
+#endif
+ Reference< XSimpleRegistry >() // registry omitted,
+ // defaulting to service manager registry used
+ );
+
+ // get a counter instance
+ Reference< XInterface > xx ;
+ xx = xMgr->createInstanceWithContext(OUString::createFromAscii("foo.Counter"), xContext);
+ Reference< XCountable > xCount( xx, UNO_QUERY );
+ OSL_ENSURE( xCount.is(), "### cannot get service instance of \"foo.Counter\"!" );
+
+ if (xCount.is())
+ {
+ xCount->setCount( 42 );
+ fprintf( stdout , "%d," , xCount->getCount() );
+ fprintf( stdout , "%d," , xCount->increment() );
+ fprintf( stdout , "%d\n" , xCount->decrement() );
+ }
+ }
+
+ Reference< XComponent >::query( xContext )->dispose();
+ return 0;
+}
diff --git a/odk/examples/cpp/makefile.mk b/odk/examples/cpp/makefile.mk
new file mode 100644
index 000000000000..462dba06ca4f
--- /dev/null
+++ b/odk/examples/cpp/makefile.mk
@@ -0,0 +1,80 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+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
+#----------------------------------------------------
+
+COUNTER_FILES=\
+ $(DESTDIRCPPEXAMPLES)$/counter$/counter.cxx \
+ $(DESTDIRCPPEXAMPLES)$/counter$/counter.uno.xml \
+ $(DESTDIRCPPEXAMPLES)$/counter$/countermain.cxx \
+ $(DESTDIRCPPEXAMPLES)$/counter$/Makefile \
+ $(DESTDIRCPPEXAMPLES)$/counter$/XCountable.idl
+
+DOUCMENTLOADER_FILES=\
+ $(DESTDIRCPPEXAMPLES)$/DocumentLoader$/DocumentLoader.cxx \
+ $(DESTDIRCPPEXAMPLES)$/DocumentLoader$/Makefile \
+ $(DESTDIRCPPEXAMPLES)$/DocumentLoader$/test.odt
+
+REMOTECLIENT_FILES=\
+ $(DESTDIRCPPEXAMPLES)$/remoteclient$/Makefile \
+ $(DESTDIRCPPEXAMPLES)$/remoteclient$/remoteclient.cxx \
+ $(DESTDIRCPPEXAMPLES)$/remoteclient$/remoteclientsample.uno.xml
+
+DIR_FILE_LIST= \
+ $(COUNTER_FILES) \
+ $(DOUCMENTLOADER_FILES) \
+ $(REMOTECLIENT_FILES)
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/ex_cpp_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/ex_cpp_files.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
+
diff --git a/odk/examples/cpp/remoteclient/Makefile b/odk/examples/cpp/remoteclient/Makefile
new file mode 100644
index 000000000000..40d51deb7cf1
--- /dev/null
+++ b/odk/examples/cpp/remoteclient/Makefile
@@ -0,0 +1,160 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (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++ remoteclient 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=remoteclientsample
+COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
+COMP_IMPL=$(SHAREDLIB_OUT)/$(COMP_IMPL_NAME)
+COMP_RDB_NAME = $(COMP_NAME).uno.rdb
+COMP_RDB = $(OUT_BIN)/$(COMP_RDB_NAME)
+COMP_MAPFILE = $(OUT_COMP_GEN)/$(COMP_NAME).uno.map
+
+OUT_COMP_INC=$(OUT_INC)/$(COMP_NAME)
+OUT_COMP_GEN=$(OUT_MISC)/$(COMP_NAME)
+OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
+
+COMP_ENV_FLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_prepare_env.flag
+COMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
+
+CXXFILES = remoteclient.cxx
+
+SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
+
+# Targets
+.PHONY: ALL
+ALL : \
+ CppClientExample
+
+include $(SETTINGS)/stdtarget.mk
+
+# This example type library will be extended by the URE types
+$(OUT_BIN)/%.rdb :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ $(REGMERGE) $@ / $(URE_TYPES)
+
+$(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
+
+$(COMP_ENV_FLAG) : $(COMP_RDB) $(OUT_BIN)/remoteserver.rdb
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ @echo --------------------------------------------------------------------------------
+ @echo Register necessary runtime components in remoteserver/remoteclientsample rdb
+ @echo --------------------------------------------------------------------------------
+ $(REGCOMP) -register -r $(OUT_BIN)/remoteserver.rdb -c connector.uno.$(SHAREDLIB_EXT)
+ $(REGCOMP) -register -r $(OUT_BIN)/remoteserver.rdb -c remotebridge.uno.$(SHAREDLIB_EXT)
+ $(REGCOMP) -register -r $(OUT_BIN)/remoteserver.rdb -c bridgefac.uno.$(SHAREDLIB_EXT)
+ $(REGCOMP) -register -r $(OUT_BIN)/remoteserver.rdb -c uuresolver.uno.$(SHAREDLIB_EXT)
+ $(REGCOMP) -register -r $(OUT_BIN)/remoteserver.rdb -c streams.uno.$(SHAREDLIB_EXT)
+ $(REGCOMP) -register -r $(COMP_RDB) -c connector.uno.$(SHAREDLIB_EXT)
+ $(REGCOMP) -register -r $(COMP_RDB) -c remotebridge.uno.$(SHAREDLIB_EXT)
+ $(REGCOMP) -register -r $(COMP_RDB) -c bridgefac.uno.$(SHAREDLIB_EXT)
+ $(REGCOMP) -register -r $(COMP_RDB) -c uuresolver.uno.$(SHAREDLIB_EXT)
+ @echo bla > $@
+
+CppClientExample : $(COMP_IMPL) $(COMP_ENV_FLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The remoteclient C++ component can be used by using the uno binary. Use the
+ @echo the follwong command to start the example. The run target starts a remote
+ @echo server and connect with the client to this server.
+ @echo -
+ @echo $(MAKE) remoteclient.run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(COMP_IMPL) $(COMP_ENV_FLAG)
+ @echo Start the remote server process ...
+ @echo -
+ifeq "$(OS)" "WIN"
+ start uno -rw $(OUT_BIN)/remoteserver.rdb --singleaccept -s com.sun.star.io.Pipe \
+ -u "uno:socket,host=localhost,port=2083;urp;MyPipe"
+else
+ uno -rw $(OUT_BIN)/remoteserver.rdb --singleaccept -s com.sun.star.io.Pipe \
+ -u "uno:socket,host=localhost,port=2083;urp;MyPipe" &
+ @echo waiting on the server process ...
+ sleep 5
+endif
+ @echo -
+ @echo ... remote server process runs ...
+ @echo -
+ @echo Start remote client process ...
+ @echo -
+ uno -l $(COMP_IMPL) -c com.sun.star.comp.product.example.RemoteClientSample \
+ -rw $(COMP_RDB) -- "uno:socket,host=localhost,port=2083;urp;MyPipe"
+ @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_ENV_FLAG)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/remoteserver.rdb))
diff --git a/odk/examples/cpp/remoteclient/remoteclient.cxx b/odk/examples/cpp/remoteclient/remoteclient.cxx
new file mode 100644
index 000000000000..cbec4d4bf84c
--- /dev/null
+++ b/odk/examples/cpp/remoteclient/remoteclient.cxx
@@ -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.
+ *
+ *************************************************************************/
+
+#include <stdio.h>
+#include <osl/mutex.hxx>
+#include <cppuhelper/factory.hxx>
+
+#include <com/sun/star/uno/XNamingService.hpp>
+
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+
+#include <com/sun/star/connection/XConnector.hpp>
+
+#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
+
+#include <com/sun/star/lang/XMain.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+
+#include <cppuhelper/implbase1.hxx>
+
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::osl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::connection;
+using namespace ::com::sun::star::bridge;
+using namespace ::com::sun::star::io;
+
+
+namespace remotebridges_officeclient {
+
+class PipeClientMain : public WeakImplHelper1< XMain >
+{
+public:
+ PipeClientMain( const Reference< XMultiServiceFactory > &r ) :
+ m_xSMgr( r )
+ {}
+public: // Methods
+
+
+ virtual sal_Int32 SAL_CALL run( const Sequence< OUString >& aArguments )
+ throw(RuntimeException);
+
+
+private: // helper methods
+ void testPipe( const Reference < XInterface > & rComponent );
+ Reference< XMultiServiceFactory > m_xSMgr;
+};
+
+void PipeClientMain::testPipe( const Reference< XInterface > & rxInterface )
+{
+ // ask for the input stream
+ Reference< XInputStream > rInputStream( rxInterface, UNO_QUERY );
+
+ // ask for the output stream
+ Reference< XOutputStream > rOutputStream( rxInterface, UNO_QUERY );
+
+ if( rInputStream.is() && rOutputStream.is() )
+ {
+ printf( "got inputstream and outputstream from remote process\n" );
+
+ sal_Int8 a[] = { 5,4,3,2,1,0 };
+ Sequence< sal_Int8 > seq( a , 6 );
+ rOutputStream->writeBytes( seq );
+ rOutputStream->closeOutput();
+
+ Sequence< sal_Int8> seqRead;
+ if( rInputStream->readBytes( seqRead ,3 ) != 3 )
+ {
+ printf( "error : Couldn't read the expected number of bytes\n" );
+ return;
+ }
+
+ if( seqRead.getConstArray()[0] != 5 ||
+ seqRead.getConstArray()[1] != 4 ||
+ seqRead.getConstArray()[2] != 3 )
+ {
+ printf( "error : The array doesn't contain the expected values\n" );
+ return;
+ }
+
+ // try to read more bytes than written
+ if( rInputStream->readBytes( seqRead , 4 ) != 3 )
+ {
+ printf( "error : Got an unexpected number of bytes\n" );
+ return;
+ }
+
+ if( seqRead.getConstArray()[0] != 2 ||
+ seqRead.getConstArray()[1] != 1 ||
+ seqRead.getConstArray()[2] != 0 )
+ {
+ printf( "error : The array doesn't contain the expected values\n" );
+ return;
+ }
+
+ printf( "pipe test worked perfect\n" );
+ }
+ else
+ {
+ printf( "Couldn't get inputstream and outputstream\n" );
+ }
+}
+
+
+sal_Int32 PipeClientMain::run( const Sequence< OUString > & aArguments ) throw ( RuntimeException )
+{
+ printf( "Connecting ....\n" );
+
+ if( aArguments.getLength() == 1 )
+ {
+ try {
+ Reference < XInterface > r =
+ m_xSMgr->createInstance( OUString::createFromAscii( "com.sun.star.bridge.UnoUrlResolver" ) );
+ Reference < XUnoUrlResolver > rResolver( r , UNO_QUERY );
+
+ // connect to the remote process and retrieve the initial object
+ r = rResolver->resolve( aArguments.getConstArray()[0] );
+
+ if( r.is() )
+ {
+ printf( "got the remote initial object\n" );
+ testPipe( r );
+ }
+ else
+ {
+ printf( "error : didn't get the initial object\n" );
+ }
+ }
+ catch( ConnectionSetupException &e )
+ {
+ OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US );
+ printf( "%s\n", o.pData->buffer );
+ printf( "couldn't access local resource ( possible security resons )\n" );
+ }
+ catch( NoConnectException &e )
+ {
+ OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US );
+ printf( "%s\n", o.pData->buffer );
+ printf( "no server listening on the resource\n" );
+ }
+ catch( IllegalArgumentException &e )
+ {
+ OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US );
+ printf( "%s\n", o.pData->buffer );
+ printf( "uno url invalid\n" );
+ }
+ catch( RuntimeException & e )
+ {
+ OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US );
+ printf( "%s\n", o.pData->buffer );
+ printf( "a remote call was aborted\n" );
+ }
+ }
+ else
+ {
+ printf( "usage: (uno remoteclient-component --) uno-url\n"
+ "e.g.: uno:socket,host=localhost,port=2083;urp;MyPipe\n" );
+ return 1;
+ }
+ return 0;
+}
+
+Reference< XInterface > SAL_CALL CreateInstance( const Reference< XMultiServiceFactory > &r)
+{
+ return Reference< XInterface > ( ( OWeakObject * ) new PipeClientMain(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( "com.sun.star.bridge.example.RemoteClientSample" );
+ pNames = &seqNames;
+ }
+ }
+ return *pNames;
+}
+
+}
+
+using namespace remotebridges_officeclient;
+#define IMPLEMENTATION_NAME "com.sun.star.comp.product.example.RemoteClientSample"
+
+
+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;
+}
+}
diff --git a/odk/examples/examples.html b/odk/examples/examples.html
new file mode 100644
index 000000000000..ed6669582cb6
--- /dev/null
+++ b/odk/examples/examples.html
@@ -0,0 +1,750 @@
+<html>
+<head>
+ <title>OpenOffice.org %PRODUCT_RELEASE% SDK - 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"/>
+<table class="table1" cellpadding=0>
+ <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">
+ <tr>
+ <td colspan="3"><img class="nothing1" src="../docs/images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table3">
+ <tr>
+ <td colspan="2" class="head1">Examples</td>
+ <td align="right"><a href="../index.html" title="link to the SDK start page"><img class="navigate" src="../docs/images/nav_home.png"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table3">
+ <tr>
+ <td colspan="3">
+ <p>The SDK provides a rich set of examples in different programming
+ languages (Java, C++, OpenOffice.org %PRODUCT_RELEASE% Basic, OLE) to illustrate the use
+ of the API and demonstrate how to benefit from the included word
+ processor, spreadsheet, presentation software, graphics program and
+ database of OpenOffice.org %PRODUCT_RELEASE%.<br>
+ 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>Every makefile contains at least one run target to execute an
+ running example, please see the makefile output in the different
+ example directories. 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.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><img class="line" src="../docs/images/sdk_line-1.gif"></td>
+ </tr>
+ </table>
+ </tr>
+ <tr>
+ <td>
+ <table class="table3">
+ <tr valign="top">
+ <td class="content3"><img src="../docs/images/arrow-1.gif"></td>
+ <td><a href="DevelopersGuide/examples.html" title="link to the Developer's Guide examples overview page">Developer's Guide examples</a></td>
+ <td class="content75">The <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/OpenOffice.org_Developers_Guide" title="link to the Developer's Guide in the Wiki">Developer's Guide</a> comes
+ with a rich set of examples which demonstrate the use of the API in
+ the different application areas.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="../docs/images/arrow-1.gif"></td>
+ <td><a href="#Java_examples" title="link to the Java examples section">Java examples</a></td>
+ <td class="content75">Set of simple and more complex examples which
+ shows the use of the API from Java.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="../docs/images/arrow-1.gif"></td>
+ <td><a href="#Cpp_examples" title="link to the C++ examples section">C++ examples</a></td>
+ <td class="content75">Small set of examples which shows the use of
+ the API from C++.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="../docs/images/arrow-1.gif"></td>
+ <td><a href="#Basic_examples" title="link to the OpenOffice.org %PRODUCT_RELEASE% Basic examples section">OpenOffice.org %PRODUCT_RELEASE% Basic examples</a></td>
+ <td class="content75">Small set of examples which shows the use of
+ the API from OpenOffice.org %PRODUCT_RELEASE% Basic.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="../docs/images/arrow-1.gif"></td>
+ <td><a href="#OLE_examples" title="link to the OLE examples section">Object Linking and Embedding (OLE) examples</a></td>
+ <td class="content75">Examples which show the use of the API from
+ OLE.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img src="../docs/images/arrow-1.gif"></td>
+ <td><a href="#CLI_examples" title="link to the CLI examples section">Common Language Infrastructure (CLI) examples</a></td>
+ <td class="content75">Examples which show the use of the API from
+ the CLI.</td>
+ </tr>
+ </table>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="../docs/images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td>
+ <table class="table3">
+ <tr>
+ <td colspan="2" class="head1"><a name="Java_examples">Java examples</td>
+ <td align="right">
+ <a href="#examples" title="link to the 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>
+ </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"><a href="java/Text/" title="link to the source directory of the Java Text examples">BookmarkInsertion</a></td>
+ <td class="cell80">This application connects to the office server and
+ gets the <a href="../docs/common/ref/com/sun/star/lang/XMultiComponentFactory.html" title="link into the IDL reference to the interface com.sun.star.lang.XMultiComponentFactory"> multi component factory</a>. An empty text document will be opened
+ and an example text will be entered. Afterwards, some bookmarks will be
+ inserted.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">HardFormatting</a></td>
+ <td class="cell80">This program connects to the office server and gets
+ the <a href="../docs/common/ref/com/sun/star/lang/XMultiComponentFactory.html" title="link into the IDL reference to the interface com.sun.star.lang.XMultiComponentFactory"> multi component factory</a>. Furthermore, an empty text document will be
+ opened, an example text will be entered, some text attributes will be
+ inspected, and the <a href="../docs/common/ref/com/sun/star/beans/PropertyState.html" title="link into the IDL reference to the enum com.sun.star.beans.PropertyState"> PropertyState</a> will be checked from the selection.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">SWriter</a></td>
+ <td class="cell80">The program connects to the office server and gets the
+ <a href="../docs/common/ref/com/sun/star/lang/XMultiComponentFactory.html" title="link into the IDL reference to the interface com.sun.star.lang.XMultiComponentFactory"> multi component factory</a>. An empty text document will be created, some
+ text will be entered, and a text table, a colored text, and text frame
+ will be inserted.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">StyleCreation</a></td>
+ <td class="cell80">The example connects to the office server and gets the
+ <a href="../docs/common/ref/com/sun/star/lang/XMultiComponentFactory.html" title="link into the IDL reference to the interface com.sun.star.lang.XMultiComponentFactory"> multi component factory</a>. An empty text document will be opened, a new
+ paragraph style will be created, and applied.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">StyleInitialization</a></td>
+ <td class="cell80">The program connects to the office server and gets the
+ <a href="../docs/common/ref/com/sun/star/lang/XMultiComponentFactory.html" title="link into the IDL reference to the interface com.sun.star.lang.XMultiComponentFactory"> multi component factory</a>. Thereafter, an empty text document will be
+ opened and an example text will be entered. The paragraph collection will
+ be used, in order to apply a different paragraph style on the
+ paragraphs.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">TextDocumentStructure</a></td>
+ <td class="cell80">The application connects to the office server and gets
+ the <a href="../docs/common/ref/com/sun/star/lang/XMultiComponentFactory.html" title="link into the IDL reference to the interface com.sun.star.lang.XMultiComponentFactory"> multi component factory</a>. An empty text document will be opened, an
+ enumeration of all paragraphs and an enumeration of all text portions
+ will be created.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">TextReplace</a></td>
+ <td class="cell80">The example connects to the office server and gets the
+ <a href="../docs/common/ref/com/sun/star/lang/XMultiComponentFactory.html" title="link into the IDL reference to the interface com.sun.star.lang.XMultiComponentFactory"> multi component factory</a>. An empty text document will be created, an
+ example text will be inserted, and some English spelled words will be
+ replaced with US spelled words.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">GraphicsInserter</a></td>
+ <td class="cell80">The GraphicsInserter creates a graphics object on an
+ empty text document by setting its position, width, height, and URL.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">WriterSelector</a></td>
+ <td class="cell80">This class gives you information on the selected
+ objects (text range, text frame, or graphics) at an OpenOffice.org
+ Server.</td>
+ </tr>
+ <tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Spreadsheet Document Examples</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/Spreadsheet/" title="link to the source directory of the Java Spreadsheet examples">CalcAddins</a></td>
+ <td class="cell80">This component adds new functions to the spreadsheet
+ application. After registering the component, the inserted functions can
+ be found with help of the functions autopilot. The new functions are
+ assigned to the category <i>Add-in</i>.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/Spreadsheet/" title="link to the source directory of the Java Spreadsheet examples">ChartTypeChange</a></td>
+ <td class="cell80">This class loads an OpenOffice.org %PRODUCT_RELEASE% Calc document and
+ changes the type of the embedded chart.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/Spreadsheet/" title="link to the source directory of the Java Spreadsheet examples">EuroAdaption</a></td>
+ <td class="cell80">The application connects to the office server and gets
+ the <a href="../docs/common/ref/com/sun/star/lang/XMultiComponentFactory.html" title="link into the IDL reference to the interface com.sun.star.lang.XMultiComponentFactory"> multi component factory</a>, opens an empty Calc document, enters an
+ example text, sets the number format to DM, changes the number format to
+ EUR (Euro), and uses the DM/EUR factor on each cell with content.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/Spreadsheet/" title="link to the source directory of the Java Spreadsheet examples">SCalc</a></td>
+ <td class="cell80">The program connects to the office server and gets the
+ <a href="../docs/common/ref/com/sun/star/lang/XMultiComponentFactory.html" title="link into the IDL reference to the interface com.sun.star.lang.XMultiComponentFactory"> multi component factory</a>. Then an empty calc document will be opened,
+ cell styles will be created, some data will be inserted into the sheets,
+ and the created cell styles will be applied. Finally, a 3D chart will be
+ inserted.</td>
+ </tr>
+ <tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Drawing Document Examples</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/Drawing/" title="link to the source directory of the Java Drawing examples">SDraw</a></td>
+ <td class="cell80">This program connects to the office server and gets
+ the <a href="../docs/common/ref/com/sun/star/lang/XMultiComponentFactory.html" title="link into the IDL reference to the interface com.sun.star.lang.XMultiComponentFactory"> multi component factory</a>. Afterwards, an empty text document will
+ be created and some shapes will be inserted on the draw page.</td>
+ </tr>
+ <tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Document Handling Examples</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/DocumentHandling/" title="link to the source directory of the Java DocumentHandling examples">DocumentConverter</a></td>
+ <td class="cell80">The program offers a service that converts arbitrary
+ documents to a favored document type.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/DocumentHandling/" title="link to the source directory of the Java DocumentHandling examples">DocumentLoader</a></td>
+ <td class="cell80">The <i>DocumentLoader</i> can open a new or an
+ existing document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/DocumentHandling/"title="link to the source directory of the Java DocumentHandling examples">DocumentPrinter</a></td>
+ <td class="cell80">The <i>DocumentPrinter</i> allows you to print the
+ favored pages of a specified document on your favored printer.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/DocumentHandling/" title="link to the source directory of the Java DocumentHandling examples">DocumentSaver</a></td>
+ <td class="cell80">The DocumentSaver shows how to save a document and
+ how you can change the type of your document.</td>
+ </tr>
+ <tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">UNO Component Examples</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="http://wiki.services.openoffice.org/wiki/Object_Inspector" title="link to the Object Inspector project page in the wiki">Object Inspector</a></td>
+ <td class="cell80">The Object Inspector is primarily an auxiliary tool
+ for the developer, which can present information about an object of the
+ OpenOffice.org %PRODUCT_RELEASE% API at run-time. Depending on the object to be inspected,
+ appropriate methods, interfaces, services, and attributes can be displayed
+ to the developer. The methods, interfaces, services and attributes are
+ represented in a predictable tree. If the attributes contained in an
+ object are to be examined, the appropriate nodes in the tree can be
+ expanded with the help of the mouse. For each non primitive object, five
+ categories are offered to the user, as long as those are available with
+ that object. The Object Inspector is currently available as a NetBeans project
+ only because of major code changes. Please see the <a href="http://wiki.services.openoffice.org/wiki/Object_Inspector" title="link to the Object Inspector project page in the wiki">project page</a> for further details.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/MinimalComponent/" title="link to the source directory of the Java MinimalComponent example">MinimalComponent</a></td>
+ <td class="cell80">This class provides a minimal UNO component. You can
+ take this class as a base for your own components. By extensions of this
+ class it is possible to also extend the function range of the Office.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/PropertySet/" title="link to the source directory of the Java PropertySet example">PropTest</a></td>
+ <td class="cell80">Contains a component that provides property set
+ interfaces by means of inheriting <a href="../docs/java/ref/com/sun/star/lib/uno/helper/PropertySet.html" title="link into the Java UNO reference to the PropertySet helper class">com.sun.star.lib.uno.helper.ProperterSet</a>.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/ToDo/" title="link to the source directory of the Java ToDo example">ToDo</a></td>
+ <td class="cell80">For every to-do listed in a spreadsheet document, this
+ component calculates the start date, day of week of the start date, the
+ end date, and the day of week of the end date. All calculations are
+ dependent upon the values of &quot;Needed Days&quot;, &quot;Due Date&quot;
+ and &quot;Status&quot;. The columns &quot;Needed Days&quot; and
+ &quot;Status&quot; are mandatory. The first to-do should be placed in
+ row nine. The date to start the calculation should be placed in cell C6.
+ The private holidays should be placed in cell K4/K5 and below.<br>
+ All rows will be calculated up to the first empty cell in the first
+ column. If a cell in the column &quot;Due Date&quot; is colored red,
+ you should take a look at your entries.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="java/EmbedDocument/EmbeddedObject" title="link to the source directory of the Java EmbeddedObject example">EmbeddedObject</a></td>
+ <td class="cell80">Contains a component that provides an example of embedded object implementation.</td>
+ </tr>
+ <tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table3">
+ <tr>
+ <td colspan="3">
+ <p>Additional information:</p>
+ <p>
+ <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/Simple_Component_in_Java" title="link to the &quot;Simple component in Java&quot; chapter in the Developer's Guide">How to write a UNO component in Java</a><br>
+ <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Java/Java_Language_Binding" title="link to the &quot;Java UNO Language Bnding&quot; chapter in the Developer's Guide">Java UNO Language Binding</a><br>
+ <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/Debugging" title="link to the &quot;Debugging Java components&quot; chapter in the Developer's Guide">Debugging Java components</a><br>
+ </p>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="../docs/images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td>
+ <table class="table3">
+ <tr>
+ <td colspan="2" class="head1"><a name="Cpp_examples">C++ examples</td>
+ <td align="right">
+ <a href="#examples" title="link to the 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 DocumentLoader example needs a running office server, before
+ running this program you should invoke the office with the following
+ command:
+ <blockquote>
+ <code>soffice &quot;-accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager&quot;</code>
+ </blockquote>
+ You can also customize the mentioned host and port to your needs.
+ </td>
+ </tr>
+ </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="cpp/DocumentLoader/"title="link to the source directory of the C++ DocumentLoader example">DocumentLoader</a></td>
+ <td class="cell80">This component works the same as the appropriate Java
+ example, but is implemented in C++.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="cpp/counter/" title="link to the source directory of the C++ counter example">Counter</a></td>
+ <td class="cell80">This demo shows how to implement a very simple UNO
+ component and how to access the UNO component from an executable.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="cpp/remoteclient/" title="link to the source directory of the C++ remoteclient example">Remote client</a></td>
+ <td class="cell80">The 'uno' program is used to export an arbitrary
+ service to other processes. In this example the com.sun.star.uno.Pipe
+ service (which is built in io-module) is exported. The client component
+ implements the <a href="../docs/common/ref/com/sun/star/lang/XMain.html" title="link into the IDL reference to the interface com.sun.star.lang.XMain">
+ com.sun.star.lang.XMain</a> interface. In the run method, it connects to
+ the servers process and retrieves an instance and does some calls on the
+ instance.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="cpp/complextoolbarcontrols/" title="link to the source directory of the C++ complextoolbarcontrols example">complextoolbarcontrols</a></td>
+ <td class="cell80">This example shows how to create a toolbar add-on with complex toolbar controls.
+ It shows how to use an Image Button, a Combo Box, a Spin Field, an Edit Field, a Dropdown Box, a Toggle Dropdown Button and a normal Dropdown Button</td>
+ </tr>
+ <tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table3">
+ <tr>
+ <td colspan="3">
+ <p>Additional information:</p>
+ <p>
+ <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/C%2B%2B_Component" title="link to the &quot;How to write a UNO component in C++&quot; chapter in the Developer's Guide">How to write a UNO component in C++</a><br>
+ <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/C%2B%2B/C%2B%2B_Language_Binding" title="link to the &quot;C++ UNO Language Binding&quot; chapter in the Developer's Guide">C++ UNO Language Binding</a><br>
+ <a href="../docs/cpp/ref/index.html" title="link to the C++ API reference">C++ reference</a>
+ </p>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="../docs/images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td>
+ <table class="table3">
+ <tr>
+ <td colspan="2" class="head1"><a name="Basic_examples">OpenOffice.org %PRODUCT_RELEASE% Basic examples</td>
+ <td align="right">
+ <a href="#examples" title="link to the 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">
+ <p>The example programs are embedded in OpenOffice.org %PRODUCT_RELEASE% documents in the
+ samples directory. To view or edit the OpenOffice.org %PRODUCT_RELEASE% Basic source,
+ select the appropriate document and then select Tools-&gt;Macro.</p>
+ <p>Most of the examples are stand-alone, but two of them (Creating an
+ Index and Import/Export of ASCII Files) have an associated data file
+ identified by a .txt file name suffix).</p>
+ <p>Some of the examples are also available in Java, you can find them in
+ the <a href="#Java_examples" title="link to the Java examples section">
+ Java section</a>.</p>
+ </td>
+ </tr>
+ </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="basic/text/modifying_text_automatically/" title="link to the source directory of the OpenOffice.org %PRODUCT_RELEASE% Basic text/modifying_text_automatically examples">Changing Appearance</a></td>
+ <td class="cell80"> To change the style used for certain words, you can
+ start with the following example. This code searches for the regular
+ expression <code>the[a-z]</code>, which stands for the text portion the
+ followed by exactly one lowercase letter. All occurrences of these four
+ letters are then changed to bold characters. The same happens in the next
+ part of the program, this time changing the appearance of
+ <code>all[a-z]</code> to italic. In order for this example to work, you
+ must execute it from an open text document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="basic/text/modifying_text_automatically/" title="link to the source directory of the OpenOffice.org %PRODUCT_RELEASE% Basic text/modifying_text_automatically examples">Replacing Text</a></td>
+ <td class="cell80">If you regularly receive documents from other people
+ for editing, you might want to make sure that certain words are always
+ written the same. The next example illustrates this by forcing certain
+ words to be spelled in American English.<br>
+ In order for this example to work, you must execute it from an open text
+ document. For a real world application, it is a good idea to read the
+ words from an external file.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="basic/text/modifying_text_automatically/" title="link to the source directory of the OpenOffice.org %PRODUCT_RELEASE% Basic text/modifying_text_automatically examples">Using Regular Expressions</a></td>
+ <td class="cell80">Another application of automatic text modification is
+ related to stylistic questions. Suppose your company&#146;s policy is to
+ avoid the use of certain words. You want to replace these words, but you
+ cannot do that automatically because you have to find the appropriate
+ replacement, which depends on the context. So instead of deleting or
+ replacing the offending words automatically, you change their color to
+ make them stand out during a subsequent manual review process.<br>
+ The following example handles two kinds of unwanted wordings: those
+ which are absolutely forbidden and must be replaced by something else,
+ and those which are considered bad style. A subroutine is responsible
+ for the changes. It can be used to make all words in a list appear in a
+ certain color in the text document. To keep the lists short, we use
+ regular expressions which provide for the variants of the words
+ (plural, adjective etc.).</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="basic/text/modifying_text_automatically/" title="link to the source directory of the OpenOffice.org %PRODUCT_RELEASE% Basic text/modifying_text_automatically examples">Inserting Bookmarks</a></td>
+ <td class="cell80">
+ <p>The next example does something very similar. This time, however, we
+ do not change the color of the words but insert a bookmark at each of
+ them. You can thus use the StarOffice navigator to jump directly from
+ word to word. Bookmarks must first be created using
+ <code>createInstance()</code>. They are then inserted with
+ <code>insertTextContent()</code> at the current text range.</p>
+ <p>The main difference to the preceding example is the For loop in
+ <code>markList()</code>. Instead of changing the color of the current
+ word, it creates a new bookmark, oBookmark, whose name is the current
+ word with an integer appended. It then inserts this bookmark at the
+ word.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="basic/text/creating_an_index/" title="link to the source directory of the OpenOffice.org %PRODUCT_RELEASE% Basic text/create_index example">Creating an Index</a></td>
+ <td class="cell80">Indices for text documents can be created manually in
+ OpenOffice.org %PRODUCT_RELEASE% Writer by clicking on the words that should appear in the
+ index. If the document is large, or if you have to generate indices for
+ several documents, this task should be automated.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="basic/sheet/" title="link to the source directory of the OpenOffice.org %PRODUCT_RELEASE% Basic sheet example">Adapting to Euroland</a></td>
+ <td class="cell80">Most of the members of the European Union will abandon
+ their old currency in favor of the new Euro in 2001. This requires
+ modifications to all programs using the old currencies. Since the exchange
+ rates for the old currencies have been fixed at the end of 1999, one can
+ already convert old data. The following program does this for all values
+ in a table that are formatted with the currency string DM.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="basic/drawing/" title="link to the source directory of the OpenOffice.org %PRODUCT_RELEASE% Basic drawing example">Import/Export of ASCII Files</a></td>
+ <td class="cell80">You can use the drawing facilities of StarOffice API
+ to generate a picture from ASCII input. One application would be a
+ hierarchical representation of a directory listing, based on textual
+ data.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="basic/stock_quotes_updater/" title="link to the source directory of the OpenOffice.org %PRODUCT_RELEASE% Basic stock_quotes_updater example">Stock Quotes Updater</a></td>
+ <td class="cell80">If you want to display stock charts for certain
+ companies, you can open up your browser every day, go to a search engine,
+ look up the quote and copy it by hand into a table. Or you can use a
+ program that does all this automatically. The following example relies on
+ the sheet module. It uses URLs to obtain the current stock quotes. The
+ quotes are displayed in sheets, one for each company. We show a line
+ diagram and the numerical values for this company on every sheet. The
+ functionality is hidden in the three subroutines <code>GetValue()</code>,
+ <code>UpdateValue()</code>, and <code>UpdateChart()</code>.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="basic/forms_and_controls/" title="link to the source directory of the OpenOffice.org %PRODUCT_RELEASE% Basic forms_and_controls example">Forms and Controls</a></td>
+ <td class="cell80">The example document Burger Factory offers some forms
+ and controls, which you can use to order your desired burger type,
+ beverage, topping, and sauce. By hitting the button
+ &quot;Order now!&quot;, your order will be placed.</td>
+ </tr>
+ <tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table3">
+ <tr>
+ <td colspan="3">
+ Additional information: <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Basic/OpenOffice.org_Basic" title="link to the &quot;OpenOffice.org %PRODUCT_RELEASE% Basic language binding&quot; chapter in the Developer's Guide">OpenOffice.org %PRODUCT_RELEASE% Basic language binding</a>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="../docs/images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td>
+ <table class="table3">
+ <tr>
+ <td colspan="2" class="head1"><a name="OLE_examples">Object Linking and Embedding (OLE) examples</td>
+ <td align="right">
+ <a href="#examples" title="link to the 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>
+ </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="OLE/activex/" title="link to the source directory of the activex plugin example using the OLE bridge">ActiveX Control</a></td>
+ <td class="cell80">The ActiveX control shows an example of access to UNO
+ through COM technology. It requires a properly installed StarOffice
+ version 6.0 or OpenOffice 1.0 or newer. This is a Lite ActiveX control
+ so it can be used only in containers that allow the use of such controls.
+ It can be activated with an &lt;OBJECT&gt; tag from a html-page to embed
+ a document. Without any parameters a new writer document will be opened
+ for editing. For more details please see the <a href="OLE/activex/README.txt" title="link to the README file of the activex example">README</a>.<br>
+ Note: This example works only under windows and if you don't use the MS
+ .Net C++ compiler please check the makefile and take notice of the
+ comments.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="OLE/vbscript/" title="link to the source directory of the VBScript example using the OLE bridge">WriterDemo</a></td>
+ <td class="cell80">This Visual Basic Script creates an empty text
+ document and inserts text, a table, and a text frame.</td>
+ </tr>
+ <tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table3">
+ <tr>
+ <td colspan="3">
+ Additional information: <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Bridge/Automation_Bridge" title="link to the &quot;Automation Language Binding&quot; chapter in the Developer's Guide">Automation Language Binding</a>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line" src="../docs/images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td>
+ <td>
+ <table class="table2">
+ <tr>
+ <td>
+ <table class="table3">
+ <tr>
+ <td colspan="2" class="head1"><a name="CLI_examples">Common Language Infrastructure (CLI) examples</td>
+ <td align="right">
+ <a href="#examples" title="link to the 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>
+ </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="CLI/CSharp/Spreadsheet/" title="link to the source directory of the Spreadsheet example using the CLI-UNO bridge">Spreadsheet Example</a></td>
+ <td class="cell80">This example is written in C# and shows how Spreadsheet
+ documents are created and filled with content. This example actually
+ consists of three separate executables, SpreadsheetSample.exe,
+ GeneralTableSample.exe, ViewSample.exe.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="CLI/VB.NET/WriterDemo/" title="link to the source directory of the WriterDeom example using the CLI-UNO bridge">WriterDemo</a></td>
+ <td class="cell80">This example is written in VB.NET. It creates a text
+ document and inserts text, a table, and a text frame.</td>
+ </tr>
+ <tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table3">
+ <tr>
+ <td colspan="3">
+ Additional information: <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/CLI/CLI_Language_Binding" title="link to the &quot;CLI-UNO Language Binding&quot; chapter in the Developer's Guide">CLI-UNO Language Binding</a>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></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>
+</table>
+<map name="Map">
+ <area shape="rect" coords="10,68,93,105" href="http://www.oracle.com">
+</map>
+</body>
+</html>
diff --git a/odk/examples/java/ConverterServlet/ConverterServlet.html b/odk/examples/java/ConverterServlet/ConverterServlet.html
new file mode 100644
index 000000000000..7c68ce8ba15e
--- /dev/null
+++ b/odk/examples/java/ConverterServlet/ConverterServlet.html
@@ -0,0 +1,46 @@
+<html><head><title>Document Converter
+</title></head><body>
+<h1>Document Converter</h1>
+<p>Converting documents with a remote running OpenOffice.org.</p>
+<form action="http://localhost:8080/conversion/servlet/ConverterServlet" method=post enctype="multipart/form-data">
+ <table width="510" border="0">
+ <tr>
+ <td>Local document</td>
+ <td>
+ <input type=file size=50 maxlength=100000 name="DocumentToBeConverted">
+ </td>
+ </tr>
+ <tr>
+ <td>Target document type</td>
+ <td>
+ <select name="converttype">
+ <option selected>swriter: StarOffice XML (Writer)</option>
+ <option>swriter: HTML (StarWriter)</option>
+ <option>swriter: MS Word 97</option>
+ <option>swriter: Text</option>
+ <option>scalc: StarOffice XML (Calc)</option>
+ <option>scalc: HTML (StarCalc)</option>
+ <option>scalc: MS Excel 97</option>
+ <option>sdraw: StarOffice XML (Draw)</option>
+ <option>simpress: StarOffice XML (Impress)</option>
+ <option>simpress: MS PowerPoint 97</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>Extension</td>
+ <td>
+ <input type=text name="extension">
+ </td>
+ </tr>
+ </table>
+ <p>The converted document will be returned by the server. If you selected the
+ target document type &quot;swriter: HTML (StarWriter)&quot; or &quot;scalc:
+ HTML (StarCalc)&quot;, the document will be shown in the browser. If have an application
+ registered in your browser for the selected document type (mime type) the application will be started.
+ Otherwise, a dialog will be opened, which allows you to open or save the converted document.</p>
+ <p>
+ <input type=submit value="Convert">
+ </p>
+</form>
+</body></html>
diff --git a/odk/examples/java/ConverterServlet/ConverterServlet.java b/odk/examples/java/ConverterServlet/ConverterServlet.java
new file mode 100644
index 000000000000..84279fab1016
--- /dev/null
+++ b/odk/examples/java/ConverterServlet/ConverterServlet.java
@@ -0,0 +1,336 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// JDK API
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.BufferedInputStream;
+import java.util.Enumeration;
+
+// Servlet API
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletOutputStream;
+
+// Helper API
+import com.oreilly.servlet.MultipartRequest;
+import com.oreilly.servlet.MultipartResponse;
+import com.oreilly.servlet.ServletUtils;
+
+// UNO API
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XStorable;
+import com.sun.star.util.XCloseable;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiComponentFactory;
+
+
+/** This class implements a http servlet in order to convert an incoming document
+ * with help of a running OpenOffice.org and to push the converted file back
+ * to the client.
+ */
+public class ConverterServlet extends HttpServlet {
+ /** Specifies the temporary directory on the web server.
+ */
+ private String stringWorkingDirectory =
+ System.getProperty( "java.io.tmpdir" ).replace( '\\', '/' );
+
+ /** Specifies the host for the office server.
+ */
+ private String stringHost = "localhost";
+
+ /** Specifies the port for the office server.
+ */
+ private String stringPort = "2083";
+
+ /** Called by the server (via the service method) to allow a servlet to handle
+ * a POST request. The file from the client will be uploaded to the web server
+ * and converted on the web server and after all pushed to the client.
+ * @param request Object that contains the request the client has made of the servlet.
+ * @param response Object that contains the response the servlet sends to the client.
+ * @throws ServletException If the request for the POST could not be handled.
+ * @throws IOException If an input or output error is detected when the servlet handles the request.
+ */
+ protected void doPost( HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, java.io.IOException {
+ try {
+ // If necessary, add a slash to the end of the string.
+ if ( !stringWorkingDirectory.endsWith( "/" ) ) {
+ stringWorkingDirectory += "/";
+ }
+
+ // Construct a MultipartRequest to help read the information.
+ // Pass in the request, a directory to save files to, and the
+ // maximum POST size we should attempt to handle.
+ MultipartRequest multipartrequest =
+ new MultipartRequest( request, stringWorkingDirectory, 5 * 1024 * 1024 );
+
+ // Getting all file names from the request
+ Enumeration files = multipartrequest.getFileNames();
+
+ // Every received file will be converted to the specified type
+ while (files.hasMoreElements()) {
+ // Getting the name from the element
+ String stringName = (String)files.nextElement();
+
+ // Getting the filename from the request
+ String stringFilename =
+ multipartrequest.getFilesystemName( stringName );
+
+ // Converting the given file on the server to the specified type and
+ // append a special extension
+ File cleanupFile = null;
+ String stringSourceFile = stringWorkingDirectory + stringFilename;
+
+ try {
+ String stringConvertedFile = convertDocument(stringSourceFile,
+ multipartrequest.getParameter( "converttype" ),
+ multipartrequest.getParameter( "extension" ));
+
+ String shortFileName = stringConvertedFile.substring(
+ stringConvertedFile.lastIndexOf('/') + 1);
+
+ // Set the response header
+ // Set the filename, is used when the file will be saved (problem with mozilla)
+ response.addHeader( "Content-Disposition",
+ "attachment; filename=" + shortFileName);
+
+ // Constructing the multi part response to the client
+ MultipartResponse multipartresponse = new MultipartResponse(response);
+
+ // Is the convert type HTML?
+ if ( ( multipartrequest.getParameter( "converttype" ).equals(
+ "swriter: HTML (StarWriter)" ) )
+ || ( multipartrequest.getParameter( "converttype" ).equals(
+ "scalc: HTML (StarCalc)" ) ) ) {
+ // Setting the content type of the response being sent to the client
+ // to text
+ multipartresponse.startResponse( "text/html" );
+ } else {
+ // Setting the content type of the response being sent to the client
+ // to application/octet-stream so that file will open a dialog box
+ // at the client in order to save the converted file
+ multipartresponse.startResponse( "application/octet-stream" );
+ }
+
+ // Pushing the converted file to the client
+ ServletUtils.returnFile( stringConvertedFile,
+ response.getOutputStream() );
+
+ // Finishing the multi part response
+ multipartresponse.finish();
+
+ // clean up the working directory
+ cleanupFile = new File(stringConvertedFile);
+ if ( cleanupFile.exists() )
+ cleanupFile.delete();
+
+ } catch (Exception exc) {
+ response.setContentType( "text/html;charset=8859-1" );
+ PrintWriter out = response.getWriter();
+
+ exc.printStackTrace();
+
+ out.println( "<html><head>" );
+ out.println( " <title>" + "SDK Converter Servlet" + "</title>" );
+ out.println( "</head>" );
+ out.println( "<body><br><p>");
+ out.println( "<b>Sorry, the conversion failed!</b></p>");
+ out.println( "<p><b>Error Mesage:</b><br>" + exc.getMessage() + "<br>");
+ exc.printStackTrace(out);
+ out.println( "</p></body><html>");
+ }
+
+ // clean up the working directory
+ cleanupFile = new File(stringSourceFile);
+ if ( cleanupFile.exists() )
+ cleanupFile.delete();
+ }
+ }
+ catch (Exception exception) {
+ System.err.println( exception.toString() );
+ }
+ }
+
+ /** This method converts a document to a given type by using a running
+ * OpenOffice.org and saves the converted document to the specified
+ * working directory.
+ * @param stringDocumentName The full path name of the file on the server to be converted.
+ * @param stringConvertType Type to convert to.
+ * @param stringExtension This string will be appended to the file name of the converted file.
+ * @return The full path name of the converted file will be returned.
+ * @see stringWorkingDirectory
+ */
+ private String convertDocument( String stringDocumentName,
+ String stringConvertType,
+ String stringExtension)
+ throws Exception
+ {
+ String stringConvertedFile = "";
+
+ // Converting the document to the favoured type
+// try {
+ // Composing the URL
+ String stringUrl = "file:///" + stringDocumentName;
+
+ /* Bootstraps a component context with the jurt base components
+ registered. Component context to be granted to a component for running.
+ Arbitrary values can be retrieved from the context. */
+ XComponentContext xcomponentcontext =
+ com.sun.star.comp.helper.Bootstrap.createInitialComponentContext( null );
+
+ /* Gets the service manager instance to be used (or null). This method has
+ been added for convenience, because the service manager is a often used
+ object. */
+ XMultiComponentFactory xmulticomponentfactory =
+ xcomponentcontext.getServiceManager();
+
+ /* Creates an instance of the component UnoUrlResolver which
+ supports the services specified by the factory. */
+ Object objectUrlResolver =
+ xmulticomponentfactory.createInstanceWithContext(
+ "com.sun.star.bridge.UnoUrlResolver", xcomponentcontext );
+
+ // Create a new url resolver
+ XUnoUrlResolver xurlresolver = ( XUnoUrlResolver )
+ UnoRuntime.queryInterface( XUnoUrlResolver.class,
+ objectUrlResolver );
+
+ // Resolves an object that is specified as follow:
+ // uno:<connection description>;<protocol description>;<initial object name>
+ Object objectInitial = xurlresolver.resolve(
+ "uno:socket,host=" + stringHost + ",port=" + stringPort +
+ ";urp;StarOffice.ServiceManager" );
+
+ // Create a service manager from the initial object
+ xmulticomponentfactory = ( XMultiComponentFactory )
+ UnoRuntime.queryInterface( XMultiComponentFactory.class, objectInitial );
+
+ // Query for the XPropertySet interface.
+ XPropertySet xpropertysetMultiComponentFactory = ( XPropertySet )
+ UnoRuntime.queryInterface( XPropertySet.class, xmulticomponentfactory );
+
+ // Get the default context from the office server.
+ Object objectDefaultContext =
+ xpropertysetMultiComponentFactory.getPropertyValue( "DefaultContext" );
+
+ // Query for the interface XComponentContext.
+ xcomponentcontext = ( XComponentContext ) UnoRuntime.queryInterface(
+ XComponentContext.class, objectDefaultContext );
+
+ /* A desktop environment contains tasks with one or more
+ frames in which components can be loaded. Desktop is the
+ environment for components which can instanciate within
+ frames. */
+ XComponentLoader xcomponentloader = ( XComponentLoader )
+ UnoRuntime.queryInterface( XComponentLoader.class,
+ xmulticomponentfactory.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xcomponentcontext ) );
+
+ // Preparing properties for loading the document
+ PropertyValue propertyvalue[] = new PropertyValue[ 1 ];
+ // Setting the flag for hidding the open document
+ propertyvalue[ 0 ] = new PropertyValue();
+ propertyvalue[ 0 ].Name = "Hidden";
+ propertyvalue[ 0 ].Value = new Boolean(true);
+
+ // Loading the wanted document
+ Object objectDocumentToStore =
+ xcomponentloader.loadComponentFromURL(
+ stringUrl, "_blank", 0, propertyvalue );
+
+ // Getting an object that will offer a simple way to store a document to a URL.
+ XStorable xstorable =
+ ( XStorable ) UnoRuntime.queryInterface( XStorable.class,
+ objectDocumentToStore );
+
+ // Preparing properties for converting the document
+ propertyvalue = new PropertyValue[ 2 ];
+ // Setting the flag for overwriting
+ propertyvalue[ 0 ] = new PropertyValue();
+ propertyvalue[ 0 ].Name = "Overwrite";
+ propertyvalue[ 0 ].Value = new Boolean(true);
+ // Setting the filter name
+ propertyvalue[ 1 ] = new PropertyValue();
+ propertyvalue[ 1 ].Name = "FilterName";
+ propertyvalue[ 1 ].Value = stringConvertType;
+
+ // Appending the favoured extension to the origin document name
+ int index = stringUrl.lastIndexOf('.');
+ if ( index >= 0 ) {
+ stringConvertedFile = stringUrl.substring(0, index) + "." + stringExtension;
+ } else {
+ stringConvertedFile = stringUrl + "." + stringExtension;
+ }
+
+ // Storing and converting the document
+ xstorable.storeAsURL( stringConvertedFile, propertyvalue );
+
+ XCloseable xcloseable = (XCloseable)UnoRuntime.queryInterface( XCloseable.class,xstorable );
+
+ // Closing the converted document
+ if ( xcloseable != null )
+ xcloseable.close(false);
+ else {
+ // If Xcloseable is not supported (older versions,
+ // use dispose() for closing the document
+ XComponent xComponent = ( XComponent ) UnoRuntime.queryInterface(
+ XComponent.class, xstorable );
+ xComponent.dispose();
+ }
+
+// }
+// catch( Exception exception ) {
+// exception.printStackTrace();
+// return( "" );
+// }
+
+ if ( stringConvertedFile.startsWith( "file:///" ) ) {
+ // Truncating the beginning of the file name
+ stringConvertedFile = stringConvertedFile.substring( 8 );
+ }
+
+ // Returning the name of the converted file
+ return stringConvertedFile;
+ }
+}
diff --git a/odk/examples/java/ConverterServlet/Makefile b/odk/examples/java/ConverterServlet/Makefile
new file mode 100644
index 000000000000..8c1828cea7b2
--- /dev/null
+++ b/odk/examples/java/ConverterServlet/Makefile
@@ -0,0 +1,94 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (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 ConverterServlet 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=ConverterServletExample
+OUT_COMP_CLASS=$(OUT_CLASS)/$(COMPONENT_NAME)
+
+JAVAFILES = \
+ ConverterServlet.java
+
+CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(JAVAFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OFFICE_CLASSES_DIR)/cos.jar\
+ $(PATH_SEPARATOR)$(OFFICE_CLASSES_DIR)/servlet.jar\
+ $(PATH_SEPARATOR)$(OUT_COMP_CLASS))
+
+# Targets
+.PHONY: ALL
+ALL : \
+ ConverterServletExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OFFICE_CLASSES_DIR)/cos.jar :
+ @echo --------------------------------------------------------------------------------
+ @echo You need the servlet support Java archive "$(QM)cos.jar$(QM)" for this example.
+ @echo You can download it from "$(QM)http://www.servlets.com/cos/index.html$(QM)"
+ @echo and then please copy it into your "$(QM)$(OFFICE_CLASSES_DIR)$(QM)" directory.
+ @echo --------------------------------------------------------------------------------
+
+$(OFFICE_CLASSES_DIR)/servlet.jar :
+ @echo --------------------------------------------------------------------------------
+ @echo You need the servlet API "$(QM)servlet.jar$(QM)" for this example.
+ @echo You can download it from "$(QM)http://java.sun.com/products/servlet/index.html$(QM)"
+ @echo and then please copy it into your "$(QM)$(OFFICE_CLASSES_DIR)$(QM)" directory.
+ @echo --------------------------------------------------------------------------------
+
+$(CLASSFILES) : $(JAVAFILES) $(OFFICE_CLASSES_DIR)/cos.jar $(OFFICE_CLASSES_DIR)/servlet.jar
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(JAVAFILES)
+
+ConverterServletExample : $(CLASSFILES)
+ @echo --------------------------------------------------------------------------------
+ @echo Please see the README file for more information how to use the converter
+ @echo servlet.
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_COMP_CLASS)/%.class
+ $(JAVA) -classpath "$(SDK_CLASSPATH)" $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
diff --git a/odk/examples/java/ConverterServlet/README b/odk/examples/java/ConverterServlet/README
new file mode 100644
index 000000000000..ea59b80b43c0
--- /dev/null
+++ b/odk/examples/java/ConverterServlet/README
@@ -0,0 +1,38 @@
+Servlet for converting documents
+================================
+
+Build preparation:
+==================
+In the file "ConverterServlet.html", search for the following line:
+<form action="http://localhost:8080/conversion/servlet/ConverterServlet" method=post enctype="multipart/form-data">
+Replace the existing IP address (localhost) with your intended IP address.
+
+Installation instructions:
+==========================
+1. If no web server is available you should install your favourite web server.
+ The example was tested with a Tomcat 4.1 server (http://jakarta.apache.org/tomcat/)
+2. Download the servlet support Java archive (cos.jar) from
+ http://www.servlets.com/cos/index.html and copy the file to the directory
+ <OFFICE_HOME>/program/classes. If you don't use the created WAR (WAR = simple web archive file, it
+ is similar to a normal Jar file) file, please make these classes also known to your web server.
+3. You need also the Servlet API (servlet.jar). The Tomcat server comes with this Servlet API. Please
+ copy the file "servlet.jar" to the directory <OFFICE_HOME>/program/classes.
+ If you don't use the Tomcat server, make sure that the Servlet API is in the classpath of your web
+ server. You can download the Servlet API from http://java.sun.com/products/servlet/index.html .
+4. Use your GNU make (http://www.gnu.org) to build the servlet class.
+5. Make the servlet class known to your web server.
+ The example creates also a WAR file which can be easy deployed in a Tomcat server.
+ 5.1 Browse the 'Tomcat Web Application Manager'
+ 5.2 Navigate into the section 'Upload a WAR file to install'
+ 5.3 Browse to your generated WAR file and select it
+ 5.4 install it
+
+
+Converting documents with the servlet:
+======================================
+1. Browse your web server "http://<your_ip>/conversion/ConverterServlet.html" or
+ open the file "ConverterServlet.html" in your web browser and select a file.
+2. Select a type to convert the file to, and the extension for the converted file.
+3. Press the button. The document will be uploaded to the server, converted and
+ pushed back to the client. Your browser will open a dialog for saving the
+ converted document.
diff --git a/odk/examples/java/ConverterServlet/web.xml b/odk/examples/java/ConverterServlet/web.xml
new file mode 100644
index 000000000000..9bef5ff964b9
--- /dev/null
+++ b/odk/examples/java/ConverterServlet/web.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!DOCTYPE web-app
+ PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+ <display-name>Conversion</display-name>
+ <description>
+ Converter servlet demo of the SDK.
+ </description>
+
+ <servlet>
+ <servlet-name>ConverterServlet</servlet-name>
+ <servlet-class>ConverterServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>ConverterServlet</servlet-name>
+ <url-pattern>/servlet/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
diff --git a/odk/examples/java/DocumentHandling/DocumentConverter.java b/odk/examples/java/DocumentHandling/DocumentConverter.java
new file mode 100644
index 000000000000..69ded5e24f45
--- /dev/null
+++ b/odk/examples/java/DocumentHandling/DocumentConverter.java
@@ -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.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+
+import java.io.File;
+import java.io.FileFilter;
+
+
+/** The class <CODE>DocumentConverter</CODE> allows you to convert all documents
+ * in a given directory and in its subdirectories to a given type. A converted
+ * document will be created in the same directory as the origin document.
+ *
+ */
+public class DocumentConverter {
+ /** Containing the loaded documents
+ */
+ static com.sun.star.frame.XComponentLoader xCompLoader = null;
+ /** Containing the given type to convert to
+ */
+ static String sConvertType = "";
+ /** Containing the given extension
+ */
+ static String sExtension = "";
+ /** Containing the current file or directory
+ */
+ static String sIndent = "";
+ /** Containing the directory where the converted files are saved
+ */
+ static String sOutputDir = "";
+
+ /** Traversing the given directory recursively and converting their files to
+ * the favoured type if possible
+ * @param fileDirectory Containing the directory
+ */
+ static void traverse( File fileDirectory ) {
+ // Testing, if the file is a directory, and if so, it throws an exception
+ if ( !fileDirectory.isDirectory() ) {
+ throw new IllegalArgumentException(
+ "not a directory: " + fileDirectory.getName()
+ );
+ }
+
+ // Prepare Url for the output directory
+ File outdir = new File(DocumentConverter.sOutputDir);
+ String sOutUrl = "file:///" + outdir.getAbsolutePath().replace( '\\', '/' );
+
+ System.out.println("\nThe converted documents will stored in \""
+ + outdir.getPath() + "!");
+
+ System.out.println(sIndent + "[" + fileDirectory.getName() + "]");
+ sIndent += " ";
+
+ // Getting all files and directories in the current directory
+ File[] entries = fileDirectory.listFiles();
+
+
+ // Iterating for each file and directory
+ for ( int i = 0; i < entries.length; ++i ) {
+ // Testing, if the entry in the list is a directory
+ if ( entries[ i ].isDirectory() ) {
+ // Recursive call for the new directory
+ traverse( entries[ i ] );
+ } else {
+ // Converting the document to the favoured type
+ try {
+ // Composing the URL by replacing all backslashs
+ String sUrl = "file:///"
+ + entries[ i ].getAbsolutePath().replace( '\\', '/' );
+
+ // Loading the wanted document
+ com.sun.star.beans.PropertyValue propertyValues[] =
+ new com.sun.star.beans.PropertyValue[1];
+ propertyValues[0] = new com.sun.star.beans.PropertyValue();
+ propertyValues[0].Name = "Hidden";
+ propertyValues[0].Value = new Boolean(true);
+
+ Object oDocToStore =
+ DocumentConverter.xCompLoader.loadComponentFromURL(
+ sUrl, "_blank", 0, propertyValues);
+
+ // Getting an object that will offer a simple way to store
+ // a document to a URL.
+ com.sun.star.frame.XStorable xStorable =
+ (com.sun.star.frame.XStorable)UnoRuntime.queryInterface(
+ com.sun.star.frame.XStorable.class, oDocToStore );
+
+ // Preparing properties for converting the document
+ propertyValues = new com.sun.star.beans.PropertyValue[2];
+ // Setting the flag for overwriting
+ propertyValues[0] = new com.sun.star.beans.PropertyValue();
+ propertyValues[0].Name = "Overwrite";
+ propertyValues[0].Value = new Boolean(true);
+ // Setting the filter name
+ propertyValues[1] = new com.sun.star.beans.PropertyValue();
+ propertyValues[1].Name = "FilterName";
+ propertyValues[1].Value = DocumentConverter.sConvertType;
+
+ // Appending the favoured extension to the origin document name
+ int index1 = sUrl.lastIndexOf('/');
+ int index2 = sUrl.lastIndexOf('.');
+ String sStoreUrl = sOutUrl + sUrl.substring(index1, index2 + 1)
+ + DocumentConverter.sExtension;
+
+ // Storing and converting the document
+ xStorable.storeAsURL(sStoreUrl, propertyValues);
+
+ // Closing the converted document. Use XCloseable.clsoe if the
+ // interface is supported, otherwise use XComponent.dispose
+ com.sun.star.util.XCloseable xCloseable =
+ (com.sun.star.util.XCloseable)UnoRuntime.queryInterface(
+ com.sun.star.util.XCloseable.class, xStorable);
+
+ if ( xCloseable != null ) {
+ xCloseable.close(false);
+ } else {
+ com.sun.star.lang.XComponent xComp =
+ (com.sun.star.lang.XComponent)UnoRuntime.queryInterface(
+ com.sun.star.lang.XComponent.class, xStorable);
+
+ xComp.dispose();
+ }
+ }
+ catch( Exception e ) {
+ e.printStackTrace(System.err);
+ }
+
+ System.out.println(sIndent + entries[ i ].getName());
+ }
+ }
+
+ sIndent = sIndent.substring(2);
+ }
+
+ /** Bootstrap UNO, getting the remote component context, getting a new instance
+ * of the desktop (used interface XComponentLoader) and calling the
+ * static method traverse
+ * @param args The array of the type String contains the directory, in which
+ * all files should be converted, the favoured converting type
+ * and the wanted extension
+ */
+ public static void main( String args[] ) {
+ if ( args.length < 3 ) {
+ System.out.println("usage: java -jar DocumentConverter.jar " +
+ "\"<directory to convert>\" \"<type to convert to>\" " +
+ "\"<extension>\" \"<output_directory>\"");
+ System.out.println("\ne.g.:");
+ System.out.println("usage: java -jar DocumentConverter.jar " +
+ "\"c:/myoffice\" \"swriter: MS Word 97\" \"doc\"");
+ System.exit(1);
+ }
+
+ com.sun.star.uno.XComponentContext xContext = null;
+
+ try {
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+
+ // get the remote office service manager
+ com.sun.star.lang.XMultiComponentFactory xMCF =
+ xContext.getServiceManager();
+
+ Object oDesktop = xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xContext);
+
+ xCompLoader = (com.sun.star.frame.XComponentLoader)
+ UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class,
+ oDesktop);
+
+ // Getting the given starting directory
+ File file = new File(args[0]);
+
+ // Getting the given type to convert to
+ sConvertType = args[1];
+
+ // Getting the given extension that should be appended to the
+ // origin document
+ sExtension = args[2];
+
+ // Getting the given type to convert to
+ sOutputDir = args[3];
+
+ // Starting the conversion of documents in the given directory
+ // and subdirectories
+ traverse(file);
+
+ System.exit(0);
+ } catch( Exception e ) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+}
diff --git a/odk/examples/java/DocumentHandling/DocumentLoader.java b/odk/examples/java/DocumentHandling/DocumentLoader.java
new file mode 100644
index 000000000000..8185cbf6da5f
--- /dev/null
+++ b/odk/examples/java/DocumentHandling/DocumentLoader.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.uno.UnoRuntime;
+
+
+/** This class opens a new or an existing office document.
+ */
+public class DocumentLoader {
+ public static void main(String args[]) {
+ if ( args.length < 1 ) {
+ System.out.println(
+ "usage: java -jar DocumentLoader.jar \"<URL|path>\"" );
+ System.out.println( "\ne.g.:" );
+ System.out.println(
+ "java -jar DocumentLoader.jar \"private:factory/swriter\"" );
+ System.exit(1);
+ }
+
+ com.sun.star.uno.XComponentContext xContext = null;
+
+ try {
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+
+ // get the remote office service manager
+ com.sun.star.lang.XMultiComponentFactory xMCF =
+ xContext.getServiceManager();
+
+ Object oDesktop = xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xContext);
+
+ com.sun.star.frame.XComponentLoader xCompLoader =
+ (com.sun.star.frame.XComponentLoader)
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, oDesktop);
+
+ String sUrl = args[0];
+ if ( sUrl.indexOf("private:") != 0) {
+ java.io.File sourceFile = new java.io.File(args[0]);
+ StringBuffer sbTmp = new StringBuffer("file:///");
+ sbTmp.append(sourceFile.getCanonicalPath().replace('\\', '/'));
+ sUrl = sbTmp.toString();
+ }
+
+ // Load a Writer document, which will be automaticly displayed
+ com.sun.star.lang.XComponent xComp = xCompLoader.loadComponentFromURL(
+ sUrl, "_blank", 0, new com.sun.star.beans.PropertyValue[0]);
+
+ if ( xComp != null )
+ System.exit(0);
+ else
+ System.exit(1);
+ }
+ catch( Exception e ) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+}
diff --git a/odk/examples/java/DocumentHandling/DocumentPrinter.java b/odk/examples/java/DocumentHandling/DocumentPrinter.java
new file mode 100644
index 000000000000..e6a7a1430d4e
--- /dev/null
+++ b/odk/examples/java/DocumentHandling/DocumentPrinter.java
@@ -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.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+
+
+public class DocumentPrinter {
+ public static void main(String args[]) {
+ if ( args.length < 3 ) {
+ System.out.println("usage: java -jar DocumentLoader.jar " +
+ "\"<Favoured printer>\" \"<URL|path>\" \"<Pages>\"");
+ System.out.println( "\ne.g.:" );
+ System.out.println("java -jar DocumentLoader.jar \"amadeus\" " +
+ "\"file:///f:/TestPrint.odt\" \"1-3;7;9\"");
+ System.exit(1);
+ }
+
+ com.sun.star.uno.XComponentContext xContext = null;
+
+ try {
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+
+ // get the remote office service manager
+ com.sun.star.lang.XMultiComponentFactory xMCF =
+ xContext.getServiceManager();
+
+ Object oDesktop = xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xContext);
+
+ com.sun.star.frame.XComponentLoader xCompLoader =
+ (com.sun.star.frame.XComponentLoader)
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, oDesktop);
+
+ java.io.File sourceFile = new java.io.File(args[1]);
+ StringBuffer sUrl = new StringBuffer("file:///");
+ sUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
+
+ // Load a Writer document, which will be automaticly displayed
+ com.sun.star.lang.XComponent xComp = xCompLoader.loadComponentFromURL(
+ sUrl.toString(), "_blank", 0,
+ new com.sun.star.beans.PropertyValue[0] );
+
+ // Querying for the interface XPrintable on the loaded document
+ com.sun.star.view.XPrintable xPrintable =
+ (com.sun.star.view.XPrintable)UnoRuntime.queryInterface(
+ com.sun.star.view.XPrintable.class, xComp);
+
+ // Setting the property "Name" for the favoured printer (name of
+ // IP address)
+ com.sun.star.beans.PropertyValue propertyValue[] =
+ new com.sun.star.beans.PropertyValue[1];
+ propertyValue[0] = new com.sun.star.beans.PropertyValue();
+ propertyValue[0].Name = "Name";
+ propertyValue[0].Value = args[ 0 ];
+
+ // Setting the name of the printer
+ xPrintable.setPrinter( propertyValue );
+
+ // Setting the property "Pages" so that only the desired pages
+ // will be printed.
+ propertyValue[0] = new com.sun.star.beans.PropertyValue();
+ propertyValue[0].Name = "Pages";
+ propertyValue[0].Value = args[ 2 ];
+
+ // Printing the loaded document
+ xPrintable.print( propertyValue );
+
+ System.exit(0);
+ }
+ catch( Exception e ) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+}
diff --git a/odk/examples/java/DocumentHandling/DocumentSaver.java b/odk/examples/java/DocumentHandling/DocumentSaver.java
new file mode 100644
index 000000000000..f6f21ea48228
--- /dev/null
+++ b/odk/examples/java/DocumentHandling/DocumentSaver.java
@@ -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.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+
+
+/** The purpose of this class is to open a specified text document and save this
+ * file to a specified URL. The type of the saved file is
+ * "swriter: StarOffice XML (Writer)".
+ */
+public class DocumentSaver {
+ /** The main method of the application.
+ * @param args The program needs two arguments:
+ * - full file name to open,
+ * - full file name to save.
+ */
+ public static void main(String args[]) {
+ if ( args.length < 2 ) {
+ System.out.println("usage: java -jar DocumentSaver.jar" +
+ "\"<URL|path to load>\" \"<URL|path to save>\"");
+ System.out.println("\ne.g.:");
+ System.out.println("java -jar DocumentSaver " +
+ "\"file:///f:/TestPrint.doc\"" +
+ "\"file:///f:/TestPrint.odt\"");
+ System.exit(1);
+ }
+
+ com.sun.star.uno.XComponentContext xContext = null;
+
+ try {
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+
+ // get the remote office service manager
+ com.sun.star.lang.XMultiComponentFactory xMCF =
+ xContext.getServiceManager();
+
+ Object oDesktop = xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xContext);
+
+ com.sun.star.frame.XComponentLoader xCompLoader =
+ (com.sun.star.frame.XComponentLoader)
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, oDesktop);
+
+ java.io.File sourceFile = new java.io.File(args[0]);
+ StringBuffer sLoadUrl = new StringBuffer("file:///");
+ sLoadUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
+
+ sourceFile = new java.io.File(args[1]);
+ StringBuffer sSaveUrl = new StringBuffer("file:///");
+ sSaveUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
+
+ com.sun.star.beans.PropertyValue[] propertyValue =
+ new com.sun.star.beans.PropertyValue[1];
+ propertyValue[0] = new com.sun.star.beans.PropertyValue();
+ propertyValue[0].Name = "Hidden";
+ propertyValue[0].Value = new Boolean(true);
+
+ Object oDocToStore = xCompLoader.loadComponentFromURL(
+ sLoadUrl.toString(), "_blank", 0, propertyValue );
+ com.sun.star.frame.XStorable xStorable =
+ (com.sun.star.frame.XStorable)UnoRuntime.queryInterface(
+ com.sun.star.frame.XStorable.class, oDocToStore );
+
+ propertyValue = new com.sun.star.beans.PropertyValue[ 2 ];
+ propertyValue[0] = new com.sun.star.beans.PropertyValue();
+ propertyValue[0].Name = "Overwrite";
+ propertyValue[0].Value = new Boolean(true);
+ propertyValue[1] = new com.sun.star.beans.PropertyValue();
+ propertyValue[1].Name = "FilterName";
+ propertyValue[1].Value = "StarOffice XML (Writer)";
+ xStorable.storeAsURL( sSaveUrl.toString(), propertyValue );
+
+ System.out.println("\nDocument \"" + sLoadUrl + "\" saved under \"" +
+ sSaveUrl + "\"\n");
+
+ com.sun.star.util.XCloseable xCloseable = (com.sun.star.util.XCloseable)
+ UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class,
+ oDocToStore );
+
+ if (xCloseable != null ) {
+ xCloseable.close(false);
+ } else
+ {
+ com.sun.star.lang.XComponent xComp = (com.sun.star.lang.XComponent)
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XComponent.class, oDocToStore );
+ xComp.dispose();
+ }
+ System.out.println("document closed!");
+ System.exit(0);
+ }
+ catch( Exception e ) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+}
diff --git a/odk/examples/java/DocumentHandling/Makefile b/odk/examples/java/DocumentHandling/Makefile
new file mode 100644
index 000000000000..0cf208330bfd
--- /dev/null
+++ b/odk/examples/java/DocumentHandling/Makefile
@@ -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.
+#
+#**************************************************************************
+
+# Builds the Java DocumentHandling examples 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
+SAMPLE_NAME=JavaDocumentHandlingExamples
+SAMPLE_CLASS_OUT = $(OUT_CLASS)/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT = $(OUT_MISC)/$(SAMPLE_NAME)
+
+DIRFLAG=$(OUT_MISC)/$(SAMPLE_NAME)_directory.flag
+
+APP1_NAME=DocumentConverter
+APP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar
+APP2_NAME=DocumentLoader
+APP2_JAR=$(SAMPLE_CLASS_OUT)/$(APP2_NAME).jar
+APP3_NAME=DocumentPrinter
+APP3_JAR=$(SAMPLE_CLASS_OUT)/$(APP3_NAME).jar
+APP4_NAME=DocumentSaver
+APP4_JAR=$(SAMPLE_CLASS_OUT)/$(APP4_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
+ -$(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
+$(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
+
+$(SAMPLE_NAME) : $(APP1_JAR) $(APP2_JAR) $(APP3_JAR) $(APP4_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo The $(APP1_NAME) search the "$(QM)./test$(QM)" directory for documents, convert
+ @echo them using using the "$(QM)MS Word 97$(QM)" filter and the extension "$(QM).doc$(QM)".
+ @echo The converted files are store in "$(QM)$(SAMPLE_GEN_OUT)/converted_files$(QM)".
+ @echo The list of possible filter names can change. Normally an updated list can be found
+ @echo on "$(QM)http://www.openoffice.org/files/documents/25/111/filter_description.html$(QM)".
+ @echo -
+ @echo The $(APP2_NAME) loads the document "$(QM)./test/test1.odt$(QM)".
+ @echo -
+ @echo The $(APP3_NAME) prints the document "$(QM)./test/test1.odt$(QM)" using the
+ @echo the specified printer. If the printer is unknown, the default printer is used.
+ @echo -
+ @echo The $(APP5_NAME) loads the document "$(QM)./test/test1.odt$(QM)" and saves it
+ @echo under "$(QM)$(SAMPLE_GEN_OUT)/savetest/testsave.odt$(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 $(MAKE) $(APP3_NAME).run
+ @echo $(MAKE) $(APP4_NAME).run
+ @echo --------
+ @echo The examples need parameters. Please use one the following commands to
+ @echo start the demo if you do not want the default parameters specified in the
+ @echo this makefile. Starting without parameters print a command line help:
+ @echo --- $(APP1_NAME) ---
+ @echo java -jar $(APP1_NAME).jar "$(QM)directory$(QM)" "$(QM)filter name$(QM)" "$(QM)extension$(QM)" "$(QM)output_directory$(QM)"
+ @echo --- $(APP2_NAME) ---
+ @echo java -jar $(APP2_NAME).jar "$(QM)Url|path$(QM)"
+ @echo --- $(APP3_NAME) ---
+ @echo java -jar $(APP3_NAME).jar "$(QM)printername$(QM)" "$(QM)filename$(QM)" "$(QM)pages$(QM)"
+ @echo --- $(APP4_NAME) ---
+ @echo java -jar $(APP4_NAME).jar "$(QM)load Url|path$(QM)" "$(QM)save Url|path$(QM)"
+ @echo --------------------------------------------------------------------------------
+
+$(APP1_NAME).run: $(APP1_JAR)
+ -$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/converted_files)
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "./test" "MS Word 97" "doc" "$(SAMPLE_GEN_OUT)/converted_files"
+
+$(APP2_NAME).run: $(APP2_JAR)
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "./test/test1.odt"
+
+$(APP3_NAME).run: $(APP3_JAR)
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "my_printer" "./test/test1.odt" 1
+
+$(APP4_NAME).run: $(APP4_JAR)
+ -$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/savetest)
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "./test/test1.odt" "$(SAMPLE_GEN_OUT)/savetest/testsave.odt"
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
diff --git a/odk/examples/java/DocumentHandling/test/test1.odt b/odk/examples/java/DocumentHandling/test/test1.odt
new file mode 100644
index 000000000000..66db1c56df6f
--- /dev/null
+++ b/odk/examples/java/DocumentHandling/test/test1.odt
Binary files differ
diff --git a/odk/examples/java/Drawing/Makefile b/odk/examples/java/Drawing/Makefile
new file mode 100644
index 000000000000..6281c2462a16
--- /dev/null
+++ b/odk/examples/java/Drawing/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 Java Drawing 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
+EXAMPLE_NAME=JavaDrawingExample
+OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+APP1_NAME=SDraw
+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
+ -$(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) SDraw.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/java/Drawing/SDraw.java b/odk/examples/java/Drawing/SDraw.java
new file mode 100644
index 000000000000..dfb544e3db02
--- /dev/null
+++ b/odk/examples/java/Drawing/SDraw.java
@@ -0,0 +1,272 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+//***************************************************************************
+// comment: Step 1: bootstrap UNO and get the remote component context
+// Step 2: open an empty text document
+// Step 3: get the drawpage an insert some shapes
+//***************************************************************************
+
+
+import java.lang.Math;
+
+import com.sun.star.uno.UnoRuntime;
+
+public class SDraw {
+
+
+ public static void main(String args[]) {
+
+ //oooooooooooooooooooooooooooStep 1oooooooooooooooooooooooooooooooooooooooo
+ // bootstrap UNO and get the remote component context. The context can
+ // be used to get the service manager
+ //*************************************************************************
+ com.sun.star.uno.XComponentContext xContext = null;
+
+ try {
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+
+ com.sun.star.lang.XComponent xDrawDoc = null;
+ com.sun.star.drawing.XDrawPage xDrawPage = null;
+
+ //oooooooooooooooooooooooooooStep 2oooooooooooooooooooooooooooooooooooooooo
+ // open an empty document. In this case it's a draw document.
+ // For this purpose an instance of com.sun.star.frame.Desktop
+ // is created. It's interface XDesktop provides the XComponentLoader,
+ // which is used to open the document via loadComponentFromURL
+ //*************************************************************************
+
+ //Open document
+ //Draw
+ System.out.println("Opening an empty Draw document ...");
+ xDrawDoc = openDraw(xContext);
+
+ //oooooooooooooooooooooooooooStep 3oooooooooooooooooooooooooooooooooooooooo
+ // get the drawpage an insert some shapes.
+ // the documents DrawPageSupplier supplies the DrawPage vi IndexAccess
+ // To add a shape get the MultiServiceFaktory of the document, create an
+ // instance of the ShapeType and add it to the Shapes-container
+ // provided by the drawpage
+ //*************************************************************************
+
+
+ // get the drawpage of drawing here
+ try {
+ System.out.println( "getting Drawpage" );
+ com.sun.star.drawing.XDrawPagesSupplier xDPS =
+ (com.sun.star.drawing.XDrawPagesSupplier)UnoRuntime.queryInterface(
+ com.sun.star.drawing.XDrawPagesSupplier.class, xDrawDoc);
+ com.sun.star.drawing.XDrawPages xDPn = xDPS.getDrawPages();
+ com.sun.star.container.XIndexAccess xDPi =
+ (com.sun.star.container.XIndexAccess)UnoRuntime.queryInterface(
+ com.sun.star.container.XIndexAccess.class, xDPn);
+ xDrawPage = (com.sun.star.drawing.XDrawPage)UnoRuntime.queryInterface(
+ com.sun.star.drawing.XDrawPage.class, xDPi.getByIndex(0));
+ } catch ( Exception e ) {
+ System.err.println( "Couldn't create document"+ e );
+ e.printStackTrace(System.err);
+ }
+
+ createSequence(xDrawDoc, xDrawPage);
+
+ //put something on the drawpage
+ System.out.println( "inserting some Shapes" );
+ com.sun.star.drawing.XShapes xShapes = (com.sun.star.drawing.XShapes)
+ UnoRuntime.queryInterface(
+ com.sun.star.drawing.XShapes.class, xDrawPage);
+ xShapes.add(createShape(xDrawDoc,2000,1500,1000,1000,"Line",0));
+ xShapes.add(createShape(xDrawDoc,3000,4500,15000,1000,"Ellipse",16711680));
+ xShapes.add(createShape(xDrawDoc,5000,3500,7500,5000,"Rectangle",6710932));
+
+ //*************************************************************************
+ System.out.println("done");
+ System.exit(0);
+ }
+
+ public static com.sun.star.lang.XComponent openDraw(
+ com.sun.star.uno.XComponentContext xContext)
+ {
+ com.sun.star.frame.XComponentLoader xCLoader;
+ com.sun.star.text.XTextDocument xDoc = null;
+ com.sun.star.lang.XComponent xComp = null;
+
+ try {
+ // get the remote office service manager
+ com.sun.star.lang.XMultiComponentFactory xMCF =
+ xContext.getServiceManager();
+
+ Object oDesktop = xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xContext);
+
+ xCLoader = (com.sun.star.frame.XComponentLoader)
+ UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class,
+ oDesktop);
+ com.sun.star.beans.PropertyValue szEmptyArgs[] =
+ new com.sun.star.beans.PropertyValue[0];
+ String strDoc = "private:factory/sdraw";
+ xComp = xCLoader.loadComponentFromURL(strDoc, "_blank", 0, szEmptyArgs);
+
+ } catch(Exception e){
+ System.err.println(" Exception " + e);
+ e.printStackTrace(System.err);
+ }
+
+ return xComp;
+ }
+
+ public static com.sun.star.drawing.XShape createShape(
+ com.sun.star.lang.XComponent xDocComp, int height, int width, int x,
+ int y, String kind, int col)
+ {
+ //possible values for kind are 'Ellipse', 'Line' and 'Rectangle'
+ com.sun.star.awt.Size size = new com.sun.star.awt.Size();
+ com.sun.star.awt.Point position = new com.sun.star.awt.Point();
+ com.sun.star.drawing.XShape xShape = null;
+
+ //get MSF
+ com.sun.star.lang.XMultiServiceFactory xDocMSF =
+ (com.sun.star.lang.XMultiServiceFactory) UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, xDocComp );
+
+ try {
+ Object oInt = xDocMSF.createInstance("com.sun.star.drawing."
+ +kind + "Shape");
+ xShape = (com.sun.star.drawing.XShape)UnoRuntime.queryInterface(
+ com.sun.star.drawing.XShape.class, oInt);
+ size.Height = height;
+ size.Width = width;
+ position.X = x;
+ position.Y = y;
+ xShape.setSize(size);
+ xShape.setPosition(position);
+
+ } catch ( Exception e ) {
+ System.err.println( "Couldn't create instance "+ e );
+ e.printStackTrace(System.err);
+ }
+
+ com.sun.star.beans.XPropertySet xSPS = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xShape);
+
+ try {
+ xSPS.setPropertyValue("FillColor", new Integer(col));
+ } catch (Exception e) {
+ System.err.println("Can't change colors " + e);
+ e.printStackTrace(System.err);
+ }
+
+ return xShape;
+ }
+
+ public static com.sun.star.drawing.XShape createSequence(
+ com.sun.star.lang.XComponent xDocComp, com.sun.star.drawing.XDrawPage xDP)
+ {
+ com.sun.star.awt.Size size = new com.sun.star.awt.Size();
+ com.sun.star.awt.Point position = new com.sun.star.awt.Point();
+ com.sun.star.drawing.XShape xShape = null;
+ com.sun.star.drawing.XShapes xShapes = (com.sun.star.drawing.XShapes)
+ UnoRuntime.queryInterface(com.sun.star.drawing.XShapes.class, xDP);
+ int height = 3000;
+ int width = 3500;
+ int x = 1900;
+ int y = 20000;
+ Object oInt = null;
+ int r = 40;
+ int g = 0;
+ int b = 80;
+
+ //get MSF
+ com.sun.star.lang.XMultiServiceFactory xDocMSF =
+ (com.sun.star.lang.XMultiServiceFactory)UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, xDocComp );
+
+ for (int i=0; i<370; i=i+25) {
+ try{
+ oInt = xDocMSF.createInstance("com.sun.star.drawing.EllipseShape");
+ xShape = (com.sun.star.drawing.XShape)UnoRuntime.queryInterface(
+ com.sun.star.drawing.XShape.class, oInt);
+ size.Height = height;
+ size.Width = width;
+ position.X = (x+(i*40));
+ position.Y =
+ (new Float(y+(Math.sin((i*Math.PI)/180))*5000)).intValue();
+ xShape.setSize(size);
+ xShape.setPosition(position);
+
+ } catch ( Exception e ) {
+ // Some exception occures.FAILED
+ System.err.println( "Couldn't get Shape "+ e );
+ e.printStackTrace(System.err);
+ }
+
+ b=b+8;
+
+ com.sun.star.beans.XPropertySet xSPS = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class,
+ xShape);
+
+ try {
+ xSPS.setPropertyValue("FillColor", new Integer(getCol(r,g,b)));
+ xSPS.setPropertyValue("Shadow", new Boolean(true));
+ } catch (Exception e) {
+ System.err.println("Can't change colors " + e);
+ e.printStackTrace(System.err);
+ }
+ xShapes.add(xShape);
+ }
+
+ com.sun.star.drawing.XShapeGrouper xSGrouper =
+ (com.sun.star.drawing.XShapeGrouper)UnoRuntime.queryInterface(
+ com.sun.star.drawing.XShapeGrouper.class, xDP);
+
+ xShape = xSGrouper.group(xShapes);
+
+ return xShape;
+ }
+
+ public static int getCol(int r, int g, int b) {
+ return r*65536+g*256+b;
+ }
+}
+
+
+
diff --git a/odk/examples/java/EmbedDocument/Container1/EmbedContApp.java b/odk/examples/java/EmbedDocument/Container1/EmbedContApp.java
new file mode 100644
index 000000000000..d6fd81c2e55c
--- /dev/null
+++ b/odk/examples/java/EmbedDocument/Container1/EmbedContApp.java
@@ -0,0 +1,1024 @@
+import java.awt.*;
+import java.applet.*;
+import java.awt.event.*;
+import java.net.*;
+import java.io.*;
+
+import javax.swing.JOptionPane;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+
+import com.sun.star.lang.XComponent;
+
+import com.sun.star.beans.PropertyValue;
+
+import com.sun.star.datatransfer.DataFlavor;
+import com.sun.star.datatransfer.XTransferable;
+
+import com.sun.star.container.XNameAccess;
+
+import com.sun.star.io.XStream;
+import com.sun.star.io.XInputStream;
+import com.sun.star.io.XOutputStream;
+import com.sun.star.io.XTruncate;
+
+import com.sun.star.embed.*;
+
+public class EmbedContApp extends Applet implements MouseListener, XEmbeddedClient
+{
+ private XMultiServiceFactory m_xServiceFactory;
+
+ private XEmbeddedObject m_xEmbedObj;
+ private XStorage m_xStorage;
+
+ private Frame m_aFrame;
+ private Menu m_aFileMenu;
+ private Menu m_aObjectMenu;
+ private Toolkit m_aToolkit;
+ private Image m_aImage;
+
+ private boolean m_bOwnFile = false;
+
+ private boolean m_bLinkObj = false;
+ private String m_aLinkURI;
+
+ public EmbedContApp( Frame aFrame, XMultiServiceFactory xServiceFactory )
+ {
+ m_aFrame = aFrame;
+ m_xServiceFactory = xServiceFactory;
+ }
+
+ public void init()
+ {
+ resize( 640, 480 );
+ setBackground( Color.gray );
+
+ m_aToolkit = Toolkit.getDefaultToolkit();
+
+ // Get a menu bar.
+ MenuBar aMenuBar = m_aFrame.getMenuBar();
+ if( aMenuBar == null )
+ {
+ aMenuBar = new MenuBar();
+ m_aFrame.setMenuBar( aMenuBar );
+ }
+
+ // Create menus for the menu bar.
+
+ // File menu
+ m_aFileMenu = new Menu( "File", true );
+ aMenuBar.add( m_aFileMenu );
+
+ MenuItem aItem = new NewMenuItem();
+ m_aFileMenu.add( aItem );
+
+ aItem = new OpenFileMenuItem();
+ m_aFileMenu.add( aItem );
+
+ aItem = new SaveMenuItem();
+ m_aFileMenu.add( aItem );
+
+ aItem = new SaveAsMenuItem();
+ m_aFileMenu.add( aItem );
+
+ // Object menu
+ m_aObjectMenu = new Menu( "Object", true );
+ aMenuBar.add( m_aObjectMenu );
+
+ aItem = new NewObjectMenuItem();
+ m_aObjectMenu.add( aItem );
+
+ aItem = new LoadObjectMenuItem();
+ m_aObjectMenu.add( aItem );
+
+ aItem = new LinkObjectMenuItem();
+ m_aObjectMenu.add( aItem );
+
+ aItem = new ConvertLinkToEmbedMenuItem();
+ m_aObjectMenu.add( aItem );
+
+ // Handle mouse clicks in our window.
+// addMouseListener( new MouseWatcher() );
+ addMouseListener( this );
+ }
+
+ public void update( Graphics g )
+ {
+ paint( g );
+ }
+
+ public void paint( Graphics g )
+ {
+ super.paint( g );
+
+ if ( m_xEmbedObj != null )
+ {
+ synchronized( this )
+ {
+ if ( m_aImage != null )
+ g.drawImage( m_aImage, 0, 0, EmbedContApp.this );
+ }
+ }
+ }
+
+ public void generateNewImage()
+ {
+ if ( m_xEmbedObj != null )
+ {
+ try {
+ int nOldState = m_xEmbedObj.getCurrentState();
+ int nState = nOldState;
+ if ( nOldState == EmbedStates.EMBED_LOADED )
+ {
+ m_xEmbedObj.changeState( EmbedStates.EMBED_RUNNING );
+ nState = EmbedStates.EMBED_RUNNING;
+ }
+
+ if ( nState == EmbedStates.EMBED_ACTIVE || nState == EmbedStates.EMBED_RUNNING )
+ {
+ XComponentSupplier xCompProv = (XComponentSupplier)UnoRuntime.queryInterface(
+ XComponentSupplier.class,
+ m_xEmbedObj );
+ if ( xCompProv != null )
+ {
+ XComponent xComp = xCompProv.getComponent();
+ XTransferable xTransfer = (XTransferable)UnoRuntime.queryInterface(
+ XTransferable.class,
+ xComp );
+ if ( xTransfer != null )
+ {
+ DataFlavor aFlavor = new DataFlavor();
+ aFlavor.MimeType = "image/png";
+ aFlavor.HumanPresentableName = "Portable Network Graphics";
+ aFlavor.DataType = new Type( byte[].class );
+
+ byte[] aPNGData = (byte[])AnyConverter.toArray( xTransfer.getTransferData( aFlavor ) );
+ if ( aPNGData != null && aPNGData.length != 0 )
+ {
+ synchronized( this )
+ {
+ m_aImage = m_aToolkit.createImage( aPNGData );
+ }
+ }
+ }
+ else
+ System.out.println( "paint() : can not get XTransferable for the component!\n" );
+ }
+ else
+ System.out.println( "paint() : XComponentSupplier is not implemented!\n" );
+ }
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ // dialogs should not be used in paint()
+ System.out.println( "Exception in paint(): " + e );
+ }
+ }
+ }
+
+ public void mouseClicked( MouseEvent e )
+ {
+ if( e.getModifiers() == InputEvent.BUTTON1_MASK )
+ {
+ // activate object if exists and not active
+ if ( m_xEmbedObj != null )
+ {
+ try {
+ m_xEmbedObj.changeState( EmbedStates.EMBED_ACTIVE );
+ }
+ catch( Exception ex )
+ {
+ JOptionPane.showMessageDialog( m_aFrame, ex, "Exception on mouse click", JOptionPane.ERROR_MESSAGE );
+ }
+ }
+ }
+ }
+
+ public void mousePressed( MouseEvent e ){};
+ public void mouseEntered( MouseEvent e ){};
+ public void mouseExited( MouseEvent e ){};
+ public void mouseReleased( MouseEvent e ){};
+
+ // XEmbeddedClient
+ public void saveObject()
+ throws com.sun.star.uno.Exception
+ {
+ if ( m_xEmbedObj != null )
+ {
+ try {
+ XEmbedPersist xPersist = (XEmbedPersist)UnoRuntime.queryInterface( XEmbedPersist.class, m_xEmbedObj );
+ if ( xPersist != null )
+ {
+ xPersist.storeOwn();
+ generateNewImage();
+ }
+ else
+ JOptionPane.showMessageDialog( m_aFrame, "No XEmbedPersist!", "Error:", JOptionPane.ERROR_MESSAGE );
+ }
+ catch( Exception e )
+ {
+ JOptionPane.showMessageDialog( m_aFrame, e, "Exception in saveObject:", JOptionPane.ERROR_MESSAGE );
+ }
+ }
+
+ generateNewImage();
+ repaint();
+ }
+
+ public void onShowWindow( boolean bVisible )
+ {
+ // for now nothing to do
+ }
+
+ // classes
+ class NewMenuItem extends MenuItem implements ActionListener // Menu New
+ {
+ public NewMenuItem()
+ {
+ super( "New", new MenuShortcut( KeyEvent.VK_A ));
+ addActionListener( this );
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ // clear everything
+ clearObjectAndStorage();
+
+ repaint();
+ }
+ }
+
+ class SaveAsMenuItem extends MenuItem implements ActionListener // Menu SaveAs...
+ {
+ public SaveAsMenuItem()
+ {
+ super( "SaveAs..." );
+ addActionListener( this );
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ // open SaveAs dialog and store
+
+ if ( m_xStorage != null && m_xEmbedObj != null )
+ {
+ FileDialog aFileDialog = new FileDialog( m_aFrame, "SaveAs", FileDialog.SAVE );
+ aFileDialog.show();
+ if ( aFileDialog.getFile() != null )
+ {
+ String aFileName = aFileDialog.getDirectory() + aFileDialog.getFile();
+ File aFile = new File( aFileName );
+ if ( aFile != null )
+ {
+ // create object from specified file
+ String aFileURI = aFile.toURI().toASCIIString();
+ try {
+ saveObject();
+
+ if ( m_bLinkObj )
+ storeLinkToStorage();
+
+ saveStorageAsFileURI( aFileURI );
+ }
+ catch( Exception ex )
+ {
+ JOptionPane.showMessageDialog( m_aFrame,
+ ex,
+ "Exception in SaveAsMenuItem:",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ }
+ }
+ }
+ else
+ JOptionPane.showMessageDialog( m_aFrame, "No document is embedded!", "Error:", JOptionPane.ERROR_MESSAGE );
+ }
+ }
+
+ class OpenFileMenuItem extends MenuItem implements ActionListener // Menu Open
+ {
+ public OpenFileMenuItem()
+ {
+ super( "Open", new MenuShortcut( KeyEvent.VK_C ));
+ addActionListener( this );
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ // clear everything
+ clearObjectAndStorage();
+
+ // open OpenFile dialog and load doc
+ FileDialog aFileDialog = new FileDialog( m_aFrame, "Open" );
+ aFileDialog.show();
+ if ( aFileDialog.getFile() != null )
+ {
+ String aFileName = aFileDialog.getDirectory() + aFileDialog.getFile();
+ File aFile = new File( aFileName );
+ if ( aFile != null )
+ {
+ // create object from specified file
+ String aFileURI = aFile.toURI().toASCIIString();
+
+ // load from specified file
+ loadFileURI( aFileURI );
+
+ if ( m_xEmbedObj != null )
+ {
+ try {
+ m_xEmbedObj.setClientSite( EmbedContApp.this );
+ }
+ catch( Exception ex )
+ {
+ JOptionPane.showMessageDialog( m_aFrame,
+ ex,
+ "Exception in OpenFileMenuItem:",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ }
+ }
+ }
+
+ generateNewImage();
+ repaint();
+ }
+ }
+
+ class SaveMenuItem extends MenuItem implements ActionListener // Menu Save
+ {
+ public SaveMenuItem()
+ {
+ super( "Save", new MenuShortcut( KeyEvent.VK_D ));
+ addActionListener( this );
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ // if has persistance store there
+ // if not open SaveAs dialog and store
+ if ( m_xStorage != null && m_xEmbedObj != null )
+ {
+ if ( m_bOwnFile )
+ {
+ if ( m_xStorage == null )
+ {
+ JOptionPane.showMessageDialog( m_aFrame,
+ "No storage for oned file!",
+ "Error:",
+ JOptionPane.ERROR_MESSAGE );
+ return;
+ }
+
+ try {
+ saveObject();
+
+ if ( m_bLinkObj )
+ storeLinkToStorage();
+
+ XTransactedObject xTransact = (XTransactedObject)UnoRuntime.queryInterface( XTransactedObject.class,
+ m_xStorage );
+ if ( xTransact != null )
+ xTransact.commit();
+ }
+ catch( Exception ex )
+ {
+ JOptionPane.showMessageDialog( m_aFrame,
+ ex,
+ "Exception during save operation in SaveMenuItem:",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ }
+ else
+ {
+ FileDialog aFileDialog = new FileDialog( m_aFrame, "SaveAs", FileDialog.SAVE );
+ aFileDialog.show();
+ if ( aFileDialog.getFile() != null )
+ {
+ String aFileName = aFileDialog.getDirectory() + aFileDialog.getFile();
+ File aFile = new File( aFileName );
+ if ( aFile != null )
+ {
+ // create object from specified file
+ String aFileURI = aFile.toURI().toASCIIString();
+ try {
+ saveObject();
+
+ if ( m_bLinkObj )
+ storeLinkToStorage();
+
+ saveStorageAsFileURI( aFileURI );
+ }
+ catch( Exception ex )
+ {
+ JOptionPane.showMessageDialog( m_aFrame,
+ ex,
+ "Exception during 'save as' operation in SaveMenuItem:",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ }
+ }
+ }
+ }
+ else
+ JOptionPane.showMessageDialog( m_aFrame, "No document is embedded!", "Error:", JOptionPane.ERROR_MESSAGE );
+ }
+ }
+
+ class NewObjectMenuItem extends MenuItem implements ActionListener // Menu NewObject
+ {
+ public NewObjectMenuItem()
+ {
+ super( "Create", new MenuShortcut( KeyEvent.VK_N ));
+ addActionListener( this );
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ // remove current object an init a new one
+ clearObjectAndStorage();
+
+ Object[] possibleValues = { "com.sun.star.comp.Writer.TextDocument",
+ "com.sun.star.comp.Writer.GlobalDocument",
+ "com.sun.star.comp.Writer.WebDocument",
+ "com.sun.star.comp.Calc.SpreadsheetDocument",
+ "com.sun.star.comp.Draw.PresentationDocument",
+ "com.sun.star.comp.Draw.DrawingDocument",
+ "com.sun.star.comp.Math.FormulaDocument" };
+
+ String selectedValue = (String)JOptionPane.showInputDialog( null, "DocumentType", "Select",
+ JOptionPane.INFORMATION_MESSAGE, null,
+ possibleValues, possibleValues[0] );
+
+ if ( selectedValue != null )
+ {
+ m_xStorage = createTempStorage();
+
+ if ( m_xStorage != null )
+ m_xEmbedObj = createEmbedObject( selectedValue );
+ else
+ JOptionPane.showMessageDialog( m_aFrame,
+ "Can't create temporary storage!",
+ "Error:",
+ JOptionPane.ERROR_MESSAGE );
+
+
+ if ( m_xEmbedObj != null )
+ {
+ try {
+ m_xEmbedObj.setClientSite( EmbedContApp.this );
+ }
+ catch( Exception ex )
+ {
+ JOptionPane.showMessageDialog( m_aFrame,
+ ex,
+ "Exception in NewObjectMenuItem:",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ }
+ }
+
+ generateNewImage();
+ repaint();
+ }
+ }
+
+ class LoadObjectMenuItem extends MenuItem implements ActionListener // Menu LoadObject
+ {
+ public LoadObjectMenuItem()
+ {
+ super( "Load from file", new MenuShortcut( KeyEvent.VK_L ));
+ addActionListener( this );
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ // first remove current object
+ clearObjectAndStorage();
+
+ // open OpenFile dialog and load doc
+ FileDialog aFileDialog = new FileDialog( m_aFrame, "Select sources to use for object init" );
+ aFileDialog.show();
+ if ( aFileDialog.getFile() != null )
+ {
+ String aFileName = aFileDialog.getDirectory() + aFileDialog.getFile();
+ File aFile = new File( aFileName );
+ if ( aFile != null )
+ {
+ // create object from specified file
+ String aFileURI = aFile.toURI().toASCIIString();
+ m_xStorage = createTempStorage();
+
+ if ( m_xStorage != null )
+ m_xEmbedObj = loadEmbedObject( aFileURI );
+
+ if ( m_xEmbedObj != null )
+ {
+ try {
+ m_xEmbedObj.setClientSite( EmbedContApp.this );
+ }
+ catch( Exception ex )
+ {
+ JOptionPane.showMessageDialog( m_aFrame,
+ ex,
+ "Exception in LoadObjectMenuItem:",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ }
+ }
+ }
+
+ generateNewImage();
+ repaint();
+ }
+ }
+
+ class LinkObjectMenuItem extends MenuItem implements ActionListener // Menu LinkObject
+ {
+ public LinkObjectMenuItem()
+ {
+ super( "Create link", new MenuShortcut( KeyEvent.VK_M ));
+ addActionListener( this );
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ // first remove current object
+ clearObjectAndStorage();
+
+ // open OpenFile dialog and load doc
+ FileDialog aFileDialog = new FileDialog( m_aFrame, "Select sources to use for object init" );
+ aFileDialog.show();
+ if ( aFileDialog.getFile() != null )
+ {
+ m_xStorage = createTempStorage();
+
+ String aFileName = aFileDialog.getDirectory() + aFileDialog.getFile();
+ File aFile = new File( aFileName );
+ if ( aFile != null )
+ {
+ // create object from specified file
+ String aFileURI = aFile.toURI().toASCIIString();
+
+ m_xEmbedObj = createLinkObject( aFileURI );
+
+ if ( m_xEmbedObj != null )
+ {
+ m_aLinkURI = aFileURI;
+ m_bLinkObj = true;
+
+ try {
+ m_xEmbedObj.setClientSite( EmbedContApp.this );
+ }
+ catch( Exception ex )
+ {
+ JOptionPane.showMessageDialog( m_aFrame,
+ ex,
+ "Exception in LinkObjectMenuItem:",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ }
+ }
+ }
+
+ generateNewImage();
+ repaint();
+ }
+ }
+
+ class ConvertLinkToEmbedMenuItem extends MenuItem implements ActionListener // Menu LinkObject
+ {
+ public ConvertLinkToEmbedMenuItem()
+ {
+ super( "Convert link to embed", new MenuShortcut( KeyEvent.VK_M ));
+ addActionListener( this );
+ }
+
+ public void actionPerformed( ActionEvent e )
+ {
+ if ( !m_bLinkObj )
+ {
+ JOptionPane.showMessageDialog( m_aFrame, "The object is not a link!", "Error:", JOptionPane.ERROR_MESSAGE );
+ return;
+ }
+
+ if ( m_xEmbedObj != null )
+ {
+ if ( m_xStorage != null )
+ {
+ try {
+ XNameAccess xNameAccess = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class,
+ m_xStorage );
+ if ( xNameAccess != null && xNameAccess.hasByName( "LinkName" ) )
+ m_xStorage.removeElement( "LinkName" );
+
+ XEmbedPersist xPersist = (XEmbedPersist)UnoRuntime.queryInterface( XEmbedPersist.class,
+ m_xEmbedObj );
+ if ( xPersist != null )
+ {
+ PropertyValue[] pEmp = new PropertyValue[0];
+ xPersist.setPersistentEntry( m_xStorage, "EmbedSub", EntryInitModes.ENTRY_NO_INIT, pEmp );
+ m_bLinkObj = false;
+ m_aLinkURI = null;
+ }
+ else
+ JOptionPane.showMessageDialog( m_aFrame,
+ "No XEmbedPersist in ConvertLink... !",
+ "Error:",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ catch( Exception e1 )
+ {
+ JOptionPane.showMessageDialog( m_aFrame,
+ e1,
+ "Exception in ConvertLinkToEmbed:try 1 :",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ }
+ }
+ }
+ }
+
+ // Helper methods
+ public XEmbeddedObject createEmbedObject( String aServiceName )
+ {
+ XEmbeddedObject xEmbObj = null;
+ byte[] pClassID = new byte[16];
+
+ if ( aServiceName.equals( "com.sun.star.comp.Writer.TextDocument" ) )
+ {
+ int[] pTempClassID = { 0x8B, 0xC6, 0xB1, 0x65, 0xB1, 0xB2, 0x4E, 0xDD,
+ 0xAA, 0x47, 0xDA, 0xE2, 0xEE, 0x68, 0x9D, 0xD6 };
+ for ( int ind = 0; ind < 16; ind++ )
+ pClassID[ind] = (byte)pTempClassID[ind];
+ }
+ else if ( aServiceName.equals( "com.sun.star.comp.Writer.GlobalDocument" ) )
+ {
+ int[] pTempClassID = { 0xB2, 0x1A, 0x0A, 0x7C, 0xE4, 0x03, 0x41, 0xFE,
+ 0x95, 0x62, 0xBD, 0x13, 0xEA, 0x6F, 0x15, 0xA0 };
+ for ( int ind = 0; ind < 16; ind++ )
+ pClassID[ind] = (byte)pTempClassID[ind];
+ }
+ else if ( aServiceName.equals( "com.sun.star.comp.Writer.WebDocument" ) )
+ {
+ int[] pTempClassID = { 0xA8, 0xBB, 0xA6, 0x0C, 0x7C, 0x60, 0x45, 0x50,
+ 0x91, 0xCE, 0x39, 0xC3, 0x90, 0x3F, 0xAC, 0x5E };
+ for ( int ind = 0; ind < 16; ind++ )
+ pClassID[ind] = (byte)pTempClassID[ind];
+ }
+ else if ( aServiceName.equals( "com.sun.star.comp.Calc.SpreadsheetDocument" ) )
+ {
+ int[] pTempClassID = { 0x47, 0xBB, 0xB4, 0xCB, 0xCE, 0x4C, 0x4E, 0x80,
+ 0xA5, 0x91, 0x42, 0xD9, 0xAE, 0x74, 0x95, 0x0F };
+ for ( int ind = 0; ind < 16; ind++ )
+ pClassID[ind] = (byte)pTempClassID[ind];
+ }
+ else if ( aServiceName.equals( "com.sun.star.comp.Draw.PresentationDocument" ) )
+ {
+ int[] pTempClassID = { 0x91, 0x76, 0xE4, 0x8A, 0x63, 0x7A, 0x4D, 0x1F,
+ 0x80, 0x3B, 0x99, 0xD9, 0xBF, 0xAC, 0x10, 0x47 };
+ for ( int ind = 0; ind < 16; ind++ )
+ pClassID[ind] = (byte)pTempClassID[ind];
+ }
+ else if ( aServiceName.equals( "com.sun.star.comp.Draw.DrawingDocument" ) )
+ {
+ int[] pTempClassID = { 0x4B, 0xAB, 0x89, 0x70, 0x8A, 0x3B, 0x45, 0xB3,
+ 0x99, 0x1C, 0xCB, 0xEE, 0xAC, 0x6B, 0xD5, 0xE3 };
+ for ( int ind = 0; ind < 16; ind++ )
+ pClassID[ind] = (byte)pTempClassID[ind];
+ }
+ else if ( aServiceName.equals( "com.sun.star.comp.Math.FormulaDocument" ) )
+ {
+ int[] pTempClassID = { 0x07, 0x8B, 0x7A, 0xBA, 0x54, 0xFC, 0x45, 0x7F,
+ 0x85, 0x51, 0x61, 0x47, 0xE7, 0x76, 0xA9, 0x97 };
+ for ( int ind = 0; ind < 16; ind++ )
+ pClassID[ind] = (byte)pTempClassID[ind];
+ }
+
+ if ( pClassID != null )
+ {
+ // create embedded object based on the class ID
+ try {
+ Object oEmbedFactory = m_xServiceFactory.createInstance( "com.sun.star.embed.EmbeddedObjectFactory" );
+ XEmbedObjectFactory xEmbedFactory = (XEmbedObjectFactory)UnoRuntime.queryInterface(
+ XEmbedObjectFactory.class,
+ oEmbedFactory );
+ if ( xEmbedFactory != null )
+ {
+ Object oEmbObj = xEmbedFactory.createInstanceInitNew( pClassID,
+ "Dummy name",
+ m_xStorage,
+ "EmbedSub" );
+ xEmbObj = (XEmbeddedObject)UnoRuntime.queryInterface( XEmbeddedObject.class, oEmbObj );
+ }
+ else
+ JOptionPane.showMessageDialog( m_aFrame,
+ "Can't create EmbedFactory!",
+ "Error:",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ catch( Exception e )
+ {
+ JOptionPane.showMessageDialog( m_aFrame, e, "Exception in createInstanceInitNew():", JOptionPane.ERROR_MESSAGE );
+ }
+ }
+ else
+ JOptionPane.showMessageDialog( m_aFrame, "Can't retrieve class ID!", "Error:", JOptionPane.ERROR_MESSAGE );
+
+ return xEmbObj;
+ }
+
+ public XEmbeddedObject createLinkObject( String aLinkURL )
+ {
+ XEmbeddedObject xEmbObj = null;
+
+ try {
+ Object oEmbedFactory = m_xServiceFactory.createInstance( "com.sun.star.embed.EmbeddedObjectFactory" );
+ XEmbedObjectFactory xEmbedFactory = (XEmbedObjectFactory)UnoRuntime.queryInterface(
+ XEmbedObjectFactory.class,
+ oEmbedFactory );
+ if ( xEmbedFactory != null )
+ {
+ Object oEmbObj = xEmbedFactory.createInstanceLink( aLinkURL );
+ xEmbObj = (XEmbeddedObject)UnoRuntime.queryInterface( XEmbeddedObject.class, oEmbObj );
+ }
+ else
+ JOptionPane.showMessageDialog( m_aFrame,
+ "Can't create EmbedFactory!",
+ "Error:",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ catch( Exception e )
+ {
+ JOptionPane.showMessageDialog( m_aFrame, e, "Exception in createLinkObject():", JOptionPane.ERROR_MESSAGE );
+ }
+
+
+ return xEmbObj;
+ }
+
+
+ public XEmbeddedObject loadEmbedObject( String aFileURI )
+ {
+ XEmbeddedObject xEmbObj = null;
+ try {
+ Object oEmbedFactory = m_xServiceFactory.createInstance( "com.sun.star.embed.EmbeddedObjectFactory" );
+ XEmbedObjectFactory xEmbedFactory = (XEmbedObjectFactory)UnoRuntime.queryInterface(
+ XEmbedObjectFactory.class,
+ oEmbedFactory );
+ if ( xEmbedFactory != null )
+ {
+ PropertyValue[] aMedDescr = { new PropertyValue(), new PropertyValue() };
+ aMedDescr[0].Name = "URL";
+ aMedDescr[0].Value = (Object) aFileURI;
+ aMedDescr[1].Name = "ReadOnly";
+ aMedDescr[1].Value = (Object) new Boolean( false );
+ Object oEmbObj = xEmbedFactory.createInstanceInitFromMediaDescriptor( m_xStorage,
+ "EmbedSub",
+ aMedDescr );
+ xEmbObj = (XEmbeddedObject)UnoRuntime.queryInterface( XEmbeddedObject.class, oEmbObj );
+ }
+ else
+ JOptionPane.showMessageDialog( m_aFrame,
+ "Can't create EmbedFactory!",
+ "Error:",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ catch( Exception e )
+ {
+ JOptionPane.showMessageDialog( m_aFrame, e, "Exception in loadEmbedObject():", JOptionPane.ERROR_MESSAGE );
+ }
+
+ return xEmbObj;
+ }
+
+ public void clearObjectAndStorage()
+ {
+ synchronized( this )
+ {
+ m_aImage = null;
+ }
+
+ m_bOwnFile = false;
+
+ m_aLinkURI = null;
+ m_bLinkObj = false;
+
+ if ( m_xEmbedObj != null )
+ {
+ try {
+ XComponent xComponent = (XComponent)UnoRuntime.queryInterface( XComponent.class, m_xEmbedObj );
+ if ( xComponent != null )
+ xComponent.dispose();
+ }
+ catch ( Exception ex )
+ {}
+ m_xEmbedObj = null;
+ }
+
+ if ( m_xStorage != null )
+ {
+ try {
+ XComponent xComponent = (XComponent)UnoRuntime.queryInterface( XComponent.class, m_xStorage );
+ if ( xComponent != null )
+ xComponent.dispose();
+ }
+ catch ( Exception ex )
+ {}
+ m_xStorage = null;
+ }
+ }
+
+ public XStorage createTempStorage()
+ {
+ XStorage xTempStorage = null;
+
+ try {
+ Object oStorageFactory = m_xServiceFactory.createInstance( "com.sun.star.embed.StorageFactory" );
+ XSingleServiceFactory xStorageFactory = (XSingleServiceFactory)UnoRuntime.queryInterface(
+ XSingleServiceFactory.class,
+ oStorageFactory );
+ if ( xStorageFactory != null )
+ {
+ Object oStorage = xStorageFactory.createInstance();
+ xTempStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oStorage );
+ }
+ else
+ JOptionPane.showMessageDialog( m_aFrame,
+ "Can't create StorageFactory!",
+ "Error:",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ catch( Exception e )
+ {
+ JOptionPane.showMessageDialog( m_aFrame, e, "Exception in createTempStorage():", JOptionPane.ERROR_MESSAGE );
+ }
+
+ return xTempStorage;
+ }
+
+ public void saveStorageAsFileURI( String aFileURI )
+ {
+ try {
+ Object oStorageFactory = m_xServiceFactory.createInstance( "com.sun.star.embed.StorageFactory" );
+ XSingleServiceFactory xStorageFactory = (XSingleServiceFactory)UnoRuntime.queryInterface(
+ XSingleServiceFactory.class,
+ oStorageFactory );
+ if ( xStorageFactory != null )
+ {
+ Object aArgs[] = new Object[2];
+ aArgs[0] = aFileURI;
+ aArgs[1] = new Integer( ElementModes.ELEMENT_READWRITE );
+
+ Object oStorage = xStorageFactory.createInstanceWithArguments( aArgs );
+ XStorage xTargetStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oStorage );
+ m_xStorage.copyToStorage( xTargetStorage );
+
+ XComponent xComponent = (XComponent)UnoRuntime.queryInterface( XComponent.class, m_xStorage );
+ xComponent.dispose();
+
+ m_xStorage = xTargetStorage;
+ m_bOwnFile = true;
+ }
+ else
+ JOptionPane.showMessageDialog( m_aFrame,
+ "Can't create StorageFactory!",
+ "Error:",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ catch( Exception e )
+ {
+ JOptionPane.showMessageDialog( m_aFrame, e, "Exception in saveStorageToFileURI():", JOptionPane.ERROR_MESSAGE );
+ }
+
+ }
+
+ public void loadFileURI( String aFileURI )
+ {
+ try
+ {
+ Object oStorageFactory = m_xServiceFactory.createInstance( "com.sun.star.embed.StorageFactory" );
+ XSingleServiceFactory xStorageFactory = (XSingleServiceFactory)UnoRuntime.queryInterface(
+ XSingleServiceFactory.class,
+ oStorageFactory );
+ Object aArgs[] = new Object[2];
+ aArgs[0] = aFileURI;
+ aArgs[1] = new Integer( ElementModes.ELEMENT_READWRITE );
+
+ Object oStorage = xStorageFactory.createInstanceWithArguments( aArgs );
+ XStorage xTargetStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oStorage );
+
+ Object oEmbedFactory = m_xServiceFactory.createInstance( "com.sun.star.embed.EmbeddedObjectFactory" );
+ XEmbedObjectFactory xEmbedFactory = (XEmbedObjectFactory)UnoRuntime.queryInterface(
+ XEmbedObjectFactory.class,
+ oEmbedFactory );
+
+ XNameAccess xNameAccess = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class,
+ xTargetStorage );
+ if ( xNameAccess == null )
+ {
+ JOptionPane.showMessageDialog( m_aFrame, "No XNameAccess!", "Error:", JOptionPane.ERROR_MESSAGE );
+ return;
+ }
+
+ Object oEmbObj = null;
+ if ( xNameAccess.hasByName( "LinkName" ) && xTargetStorage.isStreamElement( "LinkName" ) )
+ {
+ XStream xLinkStream = xTargetStorage.openStreamElement( "LinkName", ElementModes.ELEMENT_READ );
+ if ( xLinkStream != null )
+ {
+ XInputStream xInStream = xLinkStream.getInputStream();
+ if ( xInStream != null )
+ {
+ byte[][] pBuff = new byte[1][0];
+ int nRead = xInStream.readBytes( pBuff, 1000 );
+ m_aLinkURI = new String( pBuff[0] );
+ xInStream.closeInput();
+ oEmbObj = xEmbedFactory.createInstanceLink( m_aLinkURI );
+ m_bLinkObj = true;
+ }
+ }
+ }
+ else
+ oEmbObj = xEmbedFactory.createInstanceInitFromEntry( xTargetStorage,
+ "EmbedSub",
+ false );
+
+ m_xEmbedObj = (XEmbeddedObject)UnoRuntime.queryInterface( XEmbeddedObject.class, oEmbObj );
+
+ if ( m_xEmbedObj != null )
+ {
+ m_xStorage = xTargetStorage;
+ m_bOwnFile = true;
+ }
+ else
+ JOptionPane.showMessageDialog( m_aFrame,
+ "Can't create EmbedObject from storage!",
+ "Error:",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ catch( Exception e )
+ {
+ JOptionPane.showMessageDialog( m_aFrame, e, "Exception in loadFileURI():", JOptionPane.ERROR_MESSAGE );
+ }
+ }
+
+ public void storeLinkToStorage()
+ {
+ if ( m_xStorage != null && m_bLinkObj )
+ {
+ try {
+ XStream xLinkStream = m_xStorage.openStreamElement( "LinkName", ElementModes.ELEMENT_WRITE );
+
+ if ( xLinkStream != null )
+ {
+ XOutputStream xLinkOutStream = xLinkStream.getOutputStream();
+ XTruncate xTruncate = (XTruncate) UnoRuntime.queryInterface( XTruncate.class,
+ xLinkOutStream );
+ if ( xLinkOutStream != null && xTruncate != null )
+ {
+ xTruncate.truncate();
+
+ char[] aLinkChar = m_aLinkURI.toCharArray();
+ byte[] aLinkBytes = new byte[ aLinkChar.length ];
+ for ( int ind = 0; ind < aLinkChar.length; ind++ )
+ aLinkBytes[ind] = (byte)aLinkChar[ind];
+
+ xLinkOutStream.writeBytes( aLinkBytes );
+ xLinkOutStream.closeOutput();
+
+ XComponent xComponent = (XComponent) UnoRuntime.queryInterface( XComponent.class,
+ xLinkStream );
+ if ( xComponent != null )
+ xComponent.dispose();
+ }
+ else
+ JOptionPane.showMessageDialog( m_aFrame,
+ "The substream can not be truncated or written!",
+ "Error:",
+ JOptionPane.ERROR_MESSAGE );
+
+ }
+ else
+ JOptionPane.showMessageDialog( m_aFrame,
+ "Can't create/open substream!",
+ "Error:",
+ JOptionPane.ERROR_MESSAGE );
+ }
+ catch( Exception e )
+ {
+ JOptionPane.showMessageDialog( m_aFrame,
+ e,
+ "Exception in storeLinkToStorage:",
+ JOptionPane.ERROR_MESSAGE );
+
+ }
+ }
+ }
+}
+
diff --git a/odk/examples/java/EmbedDocument/Container1/EmbedContFrame.java b/odk/examples/java/EmbedDocument/Container1/EmbedContFrame.java
new file mode 100644
index 000000000000..28b6c036b7b0
--- /dev/null
+++ b/odk/examples/java/EmbedDocument/Container1/EmbedContFrame.java
@@ -0,0 +1,108 @@
+import java.awt.*;
+import java.awt.event.*;
+
+import com.sun.star.comp.servicemanager.ServiceManager;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.connection.XConnector;
+import com.sun.star.connection.XConnection;
+
+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.container.*;
+import com.sun.star.beans.*;
+import com.sun.star.lang.*;
+
+
+public class EmbedContFrame extends Frame
+{
+ WindowListener m_aCloser = new WindowAdapter()
+ {
+ public void windowClosing( WindowEvent e )
+ {
+ dispose();
+ System.exit( 0 );
+ }
+ };
+
+ public EmbedContFrame( String sName )
+ {
+ super( sName );
+ addWindowListener( m_aCloser );
+ }
+
+ public static void start()
+ {
+ EmbedContFrame aFrame = new EmbedContFrame( "Testing container." );
+
+ // connect to the office
+ XMultiServiceFactory aServiceFactory = null;
+ try {
+ aServiceFactory = connectOfficeGetServiceFactory();
+ }
+ catch( Exception e )
+ {}
+
+ if ( aServiceFactory == null )
+ {
+ System.out.println( "Can't get service manager!\n" );
+ System.exit( 1 );
+ }
+
+ EmbedContApp aApp = new EmbedContApp( aFrame, aServiceFactory );
+ aApp.init();
+ aApp.start();
+
+ Dimension aSize = aApp.getSize();
+
+ aFrame.add( "Center", aApp );
+ aFrame.pack();
+ aFrame.setSize( aSize );
+
+ aFrame.setVisible( true );
+ }
+
+ public static void main( String args[] )
+ {
+ EmbedContFrame.start();
+ }
+
+ public static XMultiServiceFactory connectOfficeGetServiceFactory()
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException,
+ Exception
+ {
+ String sConnectionString = "uno:socket,host=localhost,port=8100;urp;StarOffice.NamingService";
+
+ // Get component context
+ XComponentContext xComponentContext =
+ com.sun.star.comp.helper.Bootstrap.createInitialComponentContext( null );
+
+ // initial serviceManager
+ XMultiComponentFactory xLocalServiceManager = xComponentContext.getServiceManager();
+
+ // create a connector, so that it can contact the office
+ Object oUrlResolver = xLocalServiceManager.createInstanceWithContext( "com.sun.star.bridge.UnoUrlResolver",
+ xComponentContext );
+ XUnoUrlResolver xUrlResolver = (XUnoUrlResolver)UnoRuntime.queryInterface( XUnoUrlResolver.class, oUrlResolver );
+
+ Object oInitialObject = xUrlResolver.resolve( sConnectionString );
+ XNamingService xName = (XNamingService)UnoRuntime.queryInterface( XNamingService.class, oInitialObject );
+
+ XMultiServiceFactory xMSF = null;
+ if( xName != null ) {
+ Object oMSF = xName.getRegisteredObject( "StarOffice.ServiceManager" );
+ xMSF = (XMultiServiceFactory)UnoRuntime.queryInterface( XMultiServiceFactory.class, oMSF );
+ }
+ else
+ System.out.println( "Error: Can't get XNamingService interface from url resolver!" );
+
+ return xMSF;
+ }
+}
+
diff --git a/odk/examples/java/EmbedDocument/Container1/Makefile b/odk/examples/java/EmbedDocument/Container1/Makefile
new file mode 100644
index 000000000000..be1f5299f773
--- /dev/null
+++ b/odk/examples/java/EmbedDocument/Container1/Makefile
@@ -0,0 +1,48 @@
+# Builds the Java Storage test 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=EmbedDocument.Container1
+OUT_COMP_CLASS = $(OUT_CLASS)/$(COMPONENT_NAME)
+
+JAVAFILES = \
+ EmbedContApp.java\
+ EmbedContFrame.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 : \
+ JavaStorageTestExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(CLASSFILES) : $(JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(JAVAFILES)
+
+JavaStorageTestExample : $(CLASSFILES)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use following command to execute the example!
+ @echo ------
+ @echo $(MAKE) EmbedContFrame.run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_COMP_CLASS)/%.class
+ $(SDK_JAVA) -classpath "$(SDK_CLASSPATH)" $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
+
diff --git a/odk/examples/java/EmbedDocument/EmbeddedObject/EditorFrame.java b/odk/examples/java/EmbedDocument/EmbeddedObject/EditorFrame.java
new file mode 100755
index 000000000000..098555c55e11
--- /dev/null
+++ b/odk/examples/java/EmbedDocument/EmbeddedObject/EditorFrame.java
@@ -0,0 +1,121 @@
+package org.openoffice.examples.embedding;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.image.*;
+import javax.swing.JTextArea;
+import javax.swing.JFrame;
+import java.io.*;
+import javax.imageio.ImageIO;
+
+import org.openoffice.examples.embedding.OwnEmbeddedObject;
+
+public class EditorFrame extends JFrame
+{
+ OwnEmbeddedObject m_aEmbObj;
+ JTextArea m_aTextArea;
+ BufferedImage m_aBufImage;
+
+ WindowListener m_aCloser = new WindowAdapter()
+ {
+ public void windowClosing( WindowEvent e )
+ {
+ // m_aBufImage = m_aTextArea.getGraphicsConfiguration().createCompatibleImage( m_aTextArea.getWidth(), m_aTextArea.getHeight() );
+ m_aBufImage = new BufferedImage( m_aTextArea.getWidth(), m_aTextArea.getHeight(), BufferedImage.TYPE_INT_RGB );
+ Graphics2D aGr = m_aBufImage.createGraphics();
+ m_aTextArea.paintAll( aGr );
+ aGr.dispose();
+
+ hide();
+ m_aEmbObj.CloseFrameRequest();
+ }
+ };
+
+ public EditorFrame( String sName, OwnEmbeddedObject aEmbObj, int nWidth, int nHeight )
+ {
+ super( sName );
+ m_aEmbObj = aEmbObj;
+ addWindowListener( m_aCloser );
+ m_aTextArea = new JTextArea( "", nWidth, nHeight );
+
+ add( "Center", m_aTextArea );
+ pack();
+ // setResizable( false );
+ }
+
+ public String getText()
+ {
+ return m_aTextArea.getText();
+ }
+
+ public void setText( String aText )
+ {
+ m_aTextArea.setText( aText );
+ }
+
+ public Dimension getAppSize()
+ {
+ return m_aTextArea.getSize();
+ }
+
+ public void setAppSize( Dimension aSize )
+ {
+ Dimension aOwnSize = getSize();
+ Dimension aAppSize = m_aTextArea.getSize();
+ Dimension aToSet =
+ new Dimension( (int)( aSize.getWidth() + aOwnSize.getWidth() - aAppSize.getWidth() ),
+ (int)(aSize.getHeight() + aOwnSize.getHeight() - aAppSize.getHeight() ) );
+
+ setSize( aToSet );
+ validate();
+
+ // pack();
+ }
+
+ public byte[] getReplacementImage()
+ {
+ Dimension aDim = m_aTextArea.getSize();
+ BufferedImage aBufImage = null;
+
+ if ( m_aBufImage != null )
+ aBufImage = m_aBufImage;
+ else
+ {
+ try
+ {
+ int nWidth = (int)aDim.getWidth();
+ int nHeight = (int)aDim.getHeight();
+ aBufImage = new BufferedImage( nWidth, nHeight, BufferedImage.TYPE_INT_RGB );
+ Graphics2D aGr = aBufImage.createGraphics();
+ aGr.setBackground( Color.WHITE );
+ aGr.clearRect( 0, 0, nWidth, nHeight );
+ aGr.dispose();
+ }
+ catch ( java.lang.Exception e )
+ {}
+ }
+
+ if ( aBufImage != null )
+ {
+ try
+ {
+ File aTmpFile = File.createTempFile( "temp", ".png" );
+ ImageIO.write( aBufImage, "png", aTmpFile );
+
+ int nLen = (int)aTmpFile.length();
+ byte[] aResult = new byte[nLen];
+ FileInputStream aTmpStream = new FileInputStream( aTmpFile );
+ aTmpStream.read( aResult );
+ aTmpStream.close();
+ aTmpFile.delete();
+
+ return aResult;
+ }
+ catch ( java.lang.Exception e )
+ {}
+ }
+
+ return new byte[0];
+ }
+}
+
diff --git a/odk/examples/java/EmbedDocument/EmbeddedObject/EmbeddedObject.odt b/odk/examples/java/EmbedDocument/EmbeddedObject/EmbeddedObject.odt
new file mode 100644
index 000000000000..dde408bd337f
--- /dev/null
+++ b/odk/examples/java/EmbedDocument/EmbeddedObject/EmbeddedObject.odt
Binary files differ
diff --git a/odk/examples/java/EmbedDocument/EmbeddedObject/EmbeddedObject.xcu b/odk/examples/java/EmbedDocument/EmbeddedObject/EmbeddedObject.xcu
new file mode 100755
index 000000000000..fd6f76745192
--- /dev/null
+++ b/odk/examples/java/EmbedDocument/EmbeddedObject/EmbeddedObject.xcu
@@ -0,0 +1,28 @@
+<?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.Office" oor:name="Embedding">
+ <node oor:name="Objects">
+ <node oor:name="69474366-FD6F-4806-8374-8EDD1B6E771D" oor:op="replace">
+ <prop oor:name="ObjectFactory"><value>org.openoffice.examples.embedding.Factory69474366FD6F480683748EDD1B6E771D</value></prop>
+ <prop oor:name="ObjectDocumentServiceName"><value></value></prop>
+ <prop oor:name="ObjectMiscStatus"/>
+ <prop oor:name="ObjectVerbs"><value>PRIMARY SHOW OPEN HIDE</value></prop>
+ </node>
+ </node>
+ <node oor:name="MimeTypeClassIDRelations">
+ <prop oor:name="application/x-openoffice-embedded-69474366-FD6F-4806-8374-8EDD1B6E771D" oor:op="replace" oor:type="xs:string">
+ <value>69474366-FD6F-4806-8374-8EDD1B6E771D</value>
+ </prop>
+ </node>
+ <node oor:name="ObjectNames">
+ <node oor:name="Object69474366-FD6F-4806-8374-8EDD1B6E771D" oor:op="replace">
+ <prop oor:name="ObjectUIName">
+ <value xml:lang="en-US">Example of a simple outplace text object</value>
+ </prop>
+ <prop oor:name="ClassID">
+ <value>69474366-FD6F-4806-8374-8EDD1B6E771D</value>
+ </prop>
+ </node>
+ </node>
+</oor:component-data>
+
diff --git a/odk/examples/java/EmbedDocument/EmbeddedObject/Makefile b/odk/examples/java/EmbedDocument/EmbeddedObject/Makefile
new file mode 100644
index 000000000000..6b75f4ed72ac
--- /dev/null
+++ b/odk/examples/java/EmbedDocument/EmbeddedObject/Makefile
@@ -0,0 +1,147 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+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 for separating this example
+# from others in the output directory
+SAMPLE_NAME=EmbeddedObject
+SAMPLE_CLASS_OUT=$(OUT_CLASS)/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME)
+
+COMP_NAME=OwnEmbeddedObject
+COMP_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(COMP_NAME)
+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_JAR_NAME=$(COMP_NAME).uno.jar
+COMP_JAR=$(SAMPLE_CLASS_OUT)/$(COMP_JAR_NAME)
+COMP_JAR_MANIFEST=$(COMP_GEN_OUT)/$(COMP_NAME).Manifest
+COMP_UNOPKG_MANIFEST = $(COMP_GEN_OUT)/META-INF/manifest.xml
+COMP_REGISTERFLAG=$(COMP_GEN_OUT)$(PS)java_$(COMP_NAME)_register_component.flag
+
+PACKAGE = org/openoffice/examples/embedding
+
+COMP_JAVAFILES =\
+ OwnEmbeddedObject.java\
+ OwnEmbeddedObjectFactory.java\
+ EditorFrame.java
+
+COMP_CLASSFILES = $(patsubst %.java,$(COMP_CLASS_OUT)/%.class,$(COMP_JAVAFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT)\
+ $(PATH_SEPARATOR)$(COMP_CLASS_OUT))
+
+
+# Targets
+.PHONY: ALL
+ALL : $(COMP_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(COMP_GEN_OUT)/%.Manifest :
+ -$(MKDIR) $(subst \\,\,$(subst /,$(PS),$(@D)))
+ @echo RegistrationClassName: $(subst /,.,$(PACKAGE)).$(COMP_NAME)Factory> $@
+
+# component as well as application are dependent from the generated types
+# rule for component class files
+$(COMP_CLASS_OUT)/%.class : $(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_JAR_MANIFEST) $(COMP_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAR) cvfm $@ $< -C $(COMP_CLASS_OUT) .
+
+# 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)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)$(COMP_NAME).uno.jar$(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)$(SAMPLE_NAME).xcu$(QM)"/$(CSEP) >> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(COMP_JAR) $(COMP_UNOPKG_MANIFEST)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ $(COMP_JAR_NAME) $(SAMPLE_NAME).xcu
+ cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_ZIP) $@ $(COMP_JAR_NAME)
+ cd $(subst /,$(PS),$(COMP_GEN_OUT)) && $(SDK_ZIP) -u $@ META-INF/manifest.xml
+
+$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst \\,\,$(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
+
+$(COMP_NAME) : $(COMP_REGISTERFLAG)
+ @echo ------
+ @echo The $(COMP_NAME) component was installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo Load the "$(QM)$(SAMPLE_NAME).odt$(QM)" document to see how this component works.
+ @echo You can use this component inside your office installation, see the example
+ @echo description.
+ @echo -
+ @echo $(MAKE) $(SAMPLE_NAME).odt.load
+ @echo --------------------------------------------------------------------------------
+
+$(SAMPLE_NAME).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/java/EmbedDocument/EmbeddedObject/OwnEmbeddedObject.java b/odk/examples/java/EmbedDocument/EmbeddedObject/OwnEmbeddedObject.java
new file mode 100755
index 000000000000..3d10824584f5
--- /dev/null
+++ b/odk/examples/java/EmbedDocument/EmbeddedObject/OwnEmbeddedObject.java
@@ -0,0 +1,1124 @@
+package org.openoffice.examples.embedding;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.io.XStream;
+import com.sun.star.io.XOutputStream;
+import com.sun.star.io.XInputStream;
+import com.sun.star.io.XTruncate;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.XComponent;
+import com.sun.star.document.EventObject;
+import com.sun.star.embed.VisualRepresentation;
+import com.sun.star.container.XNameAccess;
+
+
+import com.sun.star.embed.*;
+
+import java.util.Vector;
+import java.awt.Dimension;
+import java.lang.Integer;
+import org.omg.CORBA.COMM_FAILURE;
+
+import org.openoffice.examples.embedding.EditorFrame;
+
+public final class OwnEmbeddedObject extends WeakBase
+ implements com.sun.star.embed.XEmbedPersist,
+ com.sun.star.embed.XEmbeddedObject
+{
+ protected final XComponentContext m_xContext;
+ protected final byte[] m_aClassID;
+
+ protected boolean m_bDisposed = false;
+ protected int m_nObjectState = -1;
+
+ protected com.sun.star.embed.XStorage m_xParentStorage;
+ protected com.sun.star.embed.XStorage m_xOwnStorage;
+ protected String m_aEntryName;
+
+ protected com.sun.star.embed.XStorage m_xNewParentStorage;
+ protected com.sun.star.embed.XStorage m_xNewOwnStorage;
+ protected String m_aNewEntryName;
+ protected boolean m_bWaitSaveCompleted = false;
+
+ protected EditorFrame m_aEditorFrame;
+
+ protected Vector m_aListeners;
+
+ com.sun.star.embed.VerbDescriptor[] m_pOwnVerbs;
+
+ com.sun.star.embed.XEmbeddedClient m_xClient;
+
+ Dimension m_aObjSize;
+
+ // -------------------------------------------------------------
+ protected Vector GetListeners()
+ {
+ if ( m_aListeners == null )
+ m_aListeners = new Vector<Object>( 10, 10 );
+
+ return m_aListeners;
+ }
+
+ // -------------------------------------------------------------
+ protected Dimension UpdateSizeAndGetFromActive()
+ {
+ if ( m_nObjectState == com.sun.star.embed.EmbedStates.ACTIVE )
+ m_aObjSize = m_aEditorFrame.getAppSize();
+
+ if ( m_aObjSize != null )
+ return m_aObjSize;
+ else
+ return new Dimension();
+ }
+
+ // -------------------------------------------------------------
+ protected void SwitchOwnPersistence( XStorage xParentStorage, XStorage xOwnStorage, String aEntryName )
+ {
+ if ( xOwnStorage != m_xOwnStorage )
+ {
+ if ( m_xOwnStorage != null )
+ m_xOwnStorage.dispose();
+ m_xParentStorage = xParentStorage;
+ m_xOwnStorage = xOwnStorage;
+ m_aEntryName = aEntryName;
+ }
+ }
+
+ // -------------------------------------------------------------
+ protected void SwitchOwnPersistence( XStorage xParentStorage, String aEntryName ) throws com.sun.star.io.IOException
+ {
+ if ( xParentStorage != m_xParentStorage || !aEntryName.equals( m_aEntryName ) )
+ {
+ try
+ {
+ XStorage xOwnStorage = xParentStorage.openStorageElement( aEntryName, com.sun.star.embed.ElementModes.READWRITE );
+ SwitchOwnPersistence( xParentStorage, xOwnStorage, aEntryName );
+ }
+ catch( com.sun.star.uno.RuntimeException e )
+ {
+ throw e;
+ }
+ catch( com.sun.star.io.IOException e )
+ {
+ throw e;
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ throw new com.sun.star.io.IOException( "Error while switching object storage!" );
+ }
+ }
+ }
+
+ // -------------------------------------------------------------
+ protected static void SaveDataToStorage( XStorage xStorage, String aString, Dimension aDimension ) throws com.sun.star.io.IOException
+ {
+ try
+ {
+ // save the text
+ XStream xStream = xStorage.openStreamElement( "content.txt", com.sun.star.embed.ElementModes.READWRITE );
+ XComponent xStreamComp = ( XComponent ) UnoRuntime.queryInterface( XComponent.class, xStream );
+ if ( xStreamComp == null )
+ throw new com.sun.star.uno.RuntimeException();
+
+ XOutputStream xOutStream = xStream.getOutputStream();
+ XTruncate xTruncate = ( XTruncate ) UnoRuntime.queryInterface( XTruncate.class, xOutStream );
+ if ( xTruncate == null )
+ throw new com.sun.star.io.IOException();
+
+ xTruncate.truncate();
+ xOutStream.writeBytes( aString.getBytes() );
+
+ // save the size
+ xStream = xStorage.openStreamElement( "properties.txt", com.sun.star.embed.ElementModes.READWRITE );
+ xStreamComp = ( XComponent ) UnoRuntime.queryInterface( XComponent.class, xStream );
+ if ( xStreamComp == null )
+ throw new com.sun.star.uno.RuntimeException();
+
+ xOutStream = xStream.getOutputStream();
+ xTruncate = ( XTruncate ) UnoRuntime.queryInterface( XTruncate.class, xOutStream );
+ if ( xTruncate == null )
+ throw new com.sun.star.io.IOException();
+
+ xTruncate.truncate();
+ String aProps = Integer.toString( (int)aDimension.getWidth() ) + "|" + Integer.toString( (int)aDimension.getHeight() );
+ xOutStream.writeBytes( aProps.getBytes() );
+
+ // set the media type
+ XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, xStorage );
+ if ( xPropSet == null )
+ throw new com.sun.star.uno.RuntimeException();
+ xPropSet.setPropertyValue( "MediaType", "application/x-openoffice-embedded-69474366-FD6F-4806-8374-8EDD1B6E771D" );
+
+ XTransactedObject xTransact = ( XTransactedObject ) UnoRuntime.queryInterface( XTransactedObject.class, xStorage );
+ if ( xTransact != null )
+ xTransact.commit();
+
+ xStreamComp.dispose();
+ }
+ catch( com.sun.star.uno.RuntimeException e )
+ {
+ throw e;
+ }
+ catch( com.sun.star.io.IOException e )
+ {
+ throw e;
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ throw new com.sun.star.io.IOException( "Error while switching object storage!" );
+ }
+ }
+
+ // -------------------------------------------------------------
+ protected void PostEvent( String aEvEntryName )
+ {
+ if ( m_aListeners != null )
+ {
+ com.sun.star.document.EventObject aEventObject = new com.sun.star.document.EventObject( this, aEvEntryName );
+ for ( int nInd = 0; nInd < m_aListeners.size(); nInd++ )
+ {
+ try
+ {
+ com.sun.star.document.XEventListener xListener = ( com.sun.star.document.XEventListener )
+ UnoRuntime.queryInterface( com.sun.star.document.XEventListener.class, m_aListeners.get( nInd ) );
+
+ if ( xListener != null )
+ xListener.notifyEvent( aEventObject );
+ }
+ catch( java.lang.Exception e )
+ {
+ m_aListeners.remove( nInd );
+ }
+ }
+ }
+ }
+
+ // -------------------------------------------------------------
+ protected void StateChangeNotification( boolean bBeforeChange, int nOldState, int nNewState )
+ {
+ if ( m_aListeners != null )
+ {
+ com.sun.star.lang.EventObject aEventObject = new com.sun.star.lang.EventObject( this );
+ for ( int nInd = 0; nInd < m_aListeners.size(); nInd++ )
+ {
+ try
+ {
+ com.sun.star.embed.XStateChangeListener xListener = ( com.sun.star.embed.XStateChangeListener )
+ UnoRuntime.queryInterface( com.sun.star.embed.XStateChangeListener.class, m_aListeners.get( nInd ) );
+
+ if ( xListener != null )
+ {
+ if ( bBeforeChange )
+ xListener.changingState( aEventObject, nOldState, nNewState );
+ else
+ xListener.stateChanged( aEventObject, nOldState, nNewState );
+ }
+ }
+ catch( java.lang.Exception e )
+ {
+ m_aListeners.remove( nInd );
+ }
+ }
+ }
+ }
+
+ // -------------------------------------------------------------
+ protected String ReadStringFromStream( XStorage xStorage, String aStreamName ) throws com.sun.star.io.IOException
+ {
+ if ( xStorage == null )
+ throw new com.sun.star.uno.RuntimeException();
+
+ try
+ {
+ XStream xStream = xStorage.openStreamElement( aStreamName, com.sun.star.embed.ElementModes.READWRITE );
+ XComponent xStreamComp = ( XComponent ) UnoRuntime.queryInterface( XComponent.class, xStream );
+ if ( xStreamComp == null )
+ throw new com.sun.star.uno.RuntimeException();
+
+ XInputStream xInStream = xStream.getInputStream();
+ byte[][] aData = new byte[1][];
+ aData[0] = new byte[0];
+ String aResult = new String();
+
+ int nLen = 0;
+ do
+ {
+ nLen = xInStream.readBytes( aData, 10 );
+ if ( aData.length == 0 || aData[0] == null )
+ throw new com.sun.star.io.IOException();
+ aResult += new String( aData[0] );
+ } while( nLen > 0 );
+
+ xStreamComp.dispose();
+
+ return aResult;
+ }
+ catch( com.sun.star.uno.RuntimeException e )
+ {
+ throw e;
+ }
+ catch( com.sun.star.io.IOException e )
+ {
+ throw e;
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ throw new com.sun.star.io.IOException( "Error while reading one of object streams!" );
+ }
+ }
+
+ // -------------------------------------------------------------
+ protected void ReadSizeFromOwnStorage() throws com.sun.star.io.IOException
+ {
+ String aSize = ReadStringFromStream( m_xOwnStorage, "properties.txt" );
+
+ int nSeparator = aSize.indexOf( '|' );
+ if ( nSeparator > 0 && nSeparator < aSize.length() - 1 )
+ {
+ int nWidth = Integer.parseInt( aSize.substring( 0, nSeparator ) );
+ int nHeight = Integer.parseInt( aSize.substring( nSeparator + 1, aSize.length() ) );
+ m_aObjSize = new Dimension( nWidth, nHeight );
+ }
+ }
+
+ // -------------------------------------------------------------
+ public OwnEmbeddedObject( XComponentContext context, byte[] aClassID )
+ {
+ m_xContext = context;
+ m_aClassID = aClassID;
+ };
+
+ // -------------------------------------------------------------
+ public void CloseFrameRequest()
+ {
+ com.sun.star.embed.XEmbeddedClient xClient = m_xClient;
+ if ( xClient == null )
+ return;
+
+ UpdateSizeAndGetFromActive();
+ StateChangeNotification( true, com.sun.star.embed.EmbedStates.ACTIVE, com.sun.star.embed.EmbedStates.RUNNING );
+
+ try{
+ xClient.visibilityChanged( false );
+ } catch( com.sun.star.uno.Exception e ){}
+
+ try{
+ xClient.saveObject();
+ } catch( com.sun.star.uno.Exception e ){}
+
+ m_nObjectState = com.sun.star.embed.EmbedStates.RUNNING;
+ StateChangeNotification( false, com.sun.star.embed.EmbedStates.ACTIVE, m_nObjectState );
+
+ PostEvent( "OnVisAreaChanged" );
+ }
+
+ // com.sun.star.embed.XCommonEmbedPersist:
+ // -------------------------------------------------------------
+ public void storeOwn() throws com.sun.star.embed.WrongStateException, com.sun.star.io.IOException, com.sun.star.uno.Exception
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 || m_bWaitSaveCompleted )
+ throw new com.sun.star.embed.WrongStateException();
+
+ // nothing to do, if the object is in loaded state
+ if ( m_nObjectState == com.sun.star.embed.EmbedStates.LOADED )
+ return;
+
+ if ( m_xOwnStorage == null )
+ throw new com.sun.star.io.IOException();
+
+ PostEvent( "OnSave" );
+
+ if ( m_aEditorFrame == null )
+ throw new com.sun.star.uno.RuntimeException();
+
+ SaveDataToStorage( m_xOwnStorage, m_aEditorFrame.getText(), UpdateSizeAndGetFromActive() );
+
+ PostEvent( "OnSaveDone" );
+ }
+
+ // -------------------------------------------------------------
+ public boolean isReadonly() throws com.sun.star.embed.WrongStateException
+ {
+ return false;
+ }
+
+ // -------------------------------------------------------------
+ public void reload(com.sun.star.beans.PropertyValue[] aMediaArgs, com.sun.star.beans.PropertyValue[] aObjectArgs) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.embed.WrongStateException, com.sun.star.io.IOException, com.sun.star.uno.Exception
+ {
+ // not implemented currently
+ return;
+ }
+
+ // com.sun.star.embed.XEmbedPersist:
+ // -------------------------------------------------------------
+ public void setPersistentEntry(com.sun.star.embed.XStorage xStorage, String aEntryName, int nEntryConnectionMode, com.sun.star.beans.PropertyValue[] aMediaArgs, com.sun.star.beans.PropertyValue[] aObjectArgs) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.embed.WrongStateException, com.sun.star.io.IOException, com.sun.star.uno.Exception
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( xStorage == null || aEntryName.length() == 0 )
+ throw new com.sun.star.lang.IllegalArgumentException();
+
+ if ( ( m_nObjectState != -1 || nEntryConnectionMode == com.sun.star.embed.EntryInitModes.NO_INIT )
+ && ( m_nObjectState == -1 || nEntryConnectionMode != com.sun.star.embed.EntryInitModes.NO_INIT ) )
+ {
+ // if the object is not loaded
+ // it can not get persistant representation without initialization
+
+ // if the object is loaded
+ // it can switch persistant representation only without initialization
+
+ throw new com.sun.star.embed.WrongStateException();
+ }
+
+ if ( m_bWaitSaveCompleted )
+ {
+ if ( nEntryConnectionMode == com.sun.star.embed.EntryInitModes.NO_INIT )
+ {
+ if ( m_xParentStorage == xStorage && m_aEntryName.equals( aEntryName ) )
+ saveCompleted( false );
+ else if ( m_xNewParentStorage == xStorage && m_aNewEntryName.equals( aEntryName ) )
+ saveCompleted( true );
+ else
+ throw new com.sun.star.embed.WrongStateException();
+ }
+ else
+ throw new com.sun.star.embed.WrongStateException();
+
+ return;
+ }
+
+ boolean bElExists = xStorage.hasByName( aEntryName );
+
+ if ( nEntryConnectionMode == com.sun.star.embed.EntryInitModes.DEFAULT_INIT )
+ {
+ SwitchOwnPersistence( xStorage, aEntryName );
+ if ( bElExists )
+ {
+ XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, m_xOwnStorage );
+ if ( xPropSet == null )
+ throw new com.sun.star.uno.RuntimeException();
+
+ String aMediaType = AnyConverter.toString( xPropSet.getPropertyValue( "MediaType" ) );
+ if ( !aMediaType.equals( "application/x-openoffice-embedded-69474366-FD6F-4806-8374-8EDD1B6E771D" ) )
+ throw new com.sun.star.lang.IllegalArgumentException();
+
+ m_nObjectState = com.sun.star.embed.EmbedStates.LOADED;
+ }
+ else
+ {
+ m_aEditorFrame = new EditorFrame( m_aEntryName, this, 5, 20 );
+ m_nObjectState = com.sun.star.embed.EmbedStates.RUNNING;
+ m_aObjSize = m_aEditorFrame.getAppSize();
+ }
+ }
+ else if ( nEntryConnectionMode == com.sun.star.embed.EntryInitModes.TRUNCATE_INIT )
+ {
+ SwitchOwnPersistence( xStorage, aEntryName );
+ m_aEditorFrame = new EditorFrame( m_aEntryName, this, 5, 20 );
+ m_nObjectState = com.sun.star.embed.EmbedStates.RUNNING;
+ m_aObjSize = m_aEditorFrame.getAppSize();
+ }
+ else
+ throw new com.sun.star.lang.IllegalArgumentException();
+ }
+
+ // -------------------------------------------------------------
+ public void storeToEntry(com.sun.star.embed.XStorage xStorage, String aEntryName, com.sun.star.beans.PropertyValue[] aMediaArgs, com.sun.star.beans.PropertyValue[] aObjectArgs) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.embed.WrongStateException, com.sun.star.io.IOException, com.sun.star.uno.Exception
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 || m_bWaitSaveCompleted )
+ throw new com.sun.star.embed.WrongStateException();
+
+ if ( m_nObjectState == com.sun.star.embed.EmbedStates.LOADED )
+ {
+ m_xParentStorage.copyElementTo( m_aEntryName, xStorage, aEntryName );
+ }
+ else
+ {
+ com.sun.star.embed.XStorage xSubStorage =
+ xStorage.openStorageElement( aEntryName,
+ com.sun.star.embed.ElementModes.READWRITE | com.sun.star.embed.ElementModes.TRUNCATE );
+
+ String aContents = m_aEditorFrame.getText();
+
+ SaveDataToStorage( xSubStorage, m_aEditorFrame.getText(), UpdateSizeAndGetFromActive() );
+ }
+ }
+
+ // -------------------------------------------------------------
+ public void storeAsEntry(com.sun.star.embed.XStorage xStorage, String aEntryName, com.sun.star.beans.PropertyValue[] aMediaArgs, com.sun.star.beans.PropertyValue[] aObjectArgs) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.embed.WrongStateException, com.sun.star.io.IOException, com.sun.star.uno.Exception
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 || m_bWaitSaveCompleted )
+ throw new com.sun.star.embed.WrongStateException();
+
+ com.sun.star.embed.XStorage xSubStorage = null;
+
+ if ( m_nObjectState == com.sun.star.embed.EmbedStates.LOADED )
+ {
+ xSubStorage =
+ xStorage.openStorageElement( aEntryName,
+ com.sun.star.embed.ElementModes.READWRITE | com.sun.star.embed.ElementModes.NOCREATE );
+
+ m_xOwnStorage.copyToStorage( xSubStorage );
+ }
+ else
+ {
+ xSubStorage =
+ xStorage.openStorageElement( aEntryName,
+ com.sun.star.embed.ElementModes.READWRITE | com.sun.star.embed.ElementModes.TRUNCATE );
+
+ SaveDataToStorage( xSubStorage, m_aEditorFrame.getText(), UpdateSizeAndGetFromActive() );
+ }
+
+ m_bWaitSaveCompleted = true;
+ m_xNewOwnStorage = xSubStorage;
+ m_xNewParentStorage = xStorage;
+ m_aNewEntryName = aEntryName;
+
+ }
+
+ // -------------------------------------------------------------
+ public void saveCompleted(boolean bUseNew) throws com.sun.star.embed.WrongStateException, com.sun.star.uno.Exception
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 )
+ throw new com.sun.star.embed.WrongStateException();
+
+ // it is allowed to call saveCompleted( false ) for nonstored objects
+ if ( !m_bWaitSaveCompleted && !bUseNew )
+ return;
+
+ if ( !m_bWaitSaveCompleted )
+ throw new com.sun.star.io.IOException();
+
+ if ( bUseNew )
+ {
+ SwitchOwnPersistence( m_xNewParentStorage, m_xNewOwnStorage, m_aNewEntryName );
+ PostEvent( "OnSaveAsDone" );
+ }
+ else
+ {
+ try
+ {
+ m_xNewOwnStorage.dispose();
+ }
+ catch( com.sun.star.uno.RuntimeException e )
+ {}
+ }
+
+ m_xNewOwnStorage = null;
+ m_xNewParentStorage = null;
+ m_aNewEntryName = null;
+ m_bWaitSaveCompleted = false;
+ }
+
+ // -------------------------------------------------------------
+ public boolean hasEntry() throws com.sun.star.embed.WrongStateException
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_bWaitSaveCompleted )
+ throw new com.sun.star.embed.WrongStateException();
+
+ if ( m_xOwnStorage != null )
+ return true;
+
+ return false;
+ }
+
+ // -------------------------------------------------------------
+ public String getEntryName() throws com.sun.star.embed.WrongStateException
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 || m_bWaitSaveCompleted )
+ throw new com.sun.star.embed.WrongStateException();
+
+ return m_aEntryName;
+ }
+
+ // com.sun.star.embed.XVisualObject:
+ // -------------------------------------------------------------
+ public void setVisualAreaSize(long nAspect, com.sun.star.awt.Size aSize) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.embed.WrongStateException, com.sun.star.uno.Exception
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 )
+ throw new com.sun.star.embed.WrongStateException();
+
+ if ( nAspect == com.sun.star.embed.Aspects.MSOLE_ICON )
+ // the ICON aspect should be handled by the container
+ throw new com.sun.star.embed.WrongStateException();
+
+ if ( m_nObjectState == com.sun.star.embed.EmbedStates.LOADED )
+ changeState( com.sun.star.embed.EmbedStates.RUNNING );
+
+ if ( m_aEditorFrame == null )
+ throw new com.sun.star.uno.RuntimeException();
+
+ m_aObjSize.setSize( aSize.Width, aSize.Height );
+ m_aEditorFrame.setAppSize( m_aObjSize );
+ }
+
+ // -------------------------------------------------------------
+ public com.sun.star.awt.Size getVisualAreaSize(long nAspect) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.embed.WrongStateException, com.sun.star.uno.Exception
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 )
+ throw new com.sun.star.embed.WrongStateException();
+
+ if ( nAspect == com.sun.star.embed.Aspects.MSOLE_ICON )
+ // the ICON aspect should be handled by the container
+ throw new com.sun.star.embed.WrongStateException();
+
+ if ( m_nObjectState == com.sun.star.embed.EmbedStates.LOADED )
+ changeState( com.sun.star.embed.EmbedStates.RUNNING );
+
+ UpdateSizeAndGetFromActive();
+
+ return new com.sun.star.awt.Size( (int)m_aObjSize.getWidth(), (int)m_aObjSize.getHeight() );
+ }
+
+ // -------------------------------------------------------------
+ public VisualRepresentation getPreferredVisualRepresentation(long nAspect) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.embed.WrongStateException, com.sun.star.uno.Exception
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 )
+ throw new com.sun.star.embed.WrongStateException();
+
+ if ( nAspect == com.sun.star.embed.Aspects.MSOLE_ICON )
+ // the ICON aspect should be handled by the container
+ throw new com.sun.star.embed.WrongStateException();
+
+ if ( m_nObjectState == com.sun.star.embed.EmbedStates.LOADED )
+ changeState( com.sun.star.embed.EmbedStates.RUNNING );
+
+ byte[] aData = m_aEditorFrame.getReplacementImage();
+ VisualRepresentation aVisRep = new VisualRepresentation();
+ aVisRep.Data = aData;
+ aVisRep.Flavor = new com.sun.star.datatransfer.DataFlavor( "image/png", "png", new com.sun.star.uno.Type( byte[].class ) );
+ return aVisRep;
+ }
+
+ // -------------------------------------------------------------
+ public int getMapUnit(long nAspect) throws com.sun.star.uno.Exception
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 )
+ throw new com.sun.star.embed.WrongStateException();
+
+ if ( nAspect == com.sun.star.embed.Aspects.MSOLE_ICON )
+ // the ICON aspect should be handled by the container
+ throw new com.sun.star.embed.WrongStateException();
+
+ return com.sun.star.embed.EmbedMapUnits.PIXEL;
+ }
+
+ // com.sun.star.embed.XClassifiedObject:
+ // -------------------------------------------------------------
+ public byte[] getClassID()
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ return m_aClassID;
+ }
+
+ // -------------------------------------------------------------
+ public String getClassName()
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ return new String();
+ }
+
+ // -------------------------------------------------------------
+ public void setClassInfo(byte[] aClassID, String sClassName) throws com.sun.star.lang.NoSupportException
+ {
+ throw new com.sun.star.lang.NoSupportException();
+ }
+
+ // com.sun.star.embed.XComponentSupplier:
+ // -------------------------------------------------------------
+ public com.sun.star.util.XCloseable getComponent()
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ // allows no access to the component, this simple example just has no
+ return null;
+ }
+
+ // com.sun.star.embed.XStateChangeBroadcaster:
+ // -------------------------------------------------------------
+ public void addStateChangeListener(com.sun.star.embed.XStateChangeListener xListener)
+ {
+ if ( m_bDisposed )
+ return;
+
+ GetListeners().add( xListener );
+ }
+
+ // -------------------------------------------------------------
+ public void removeStateChangeListener(com.sun.star.embed.XStateChangeListener xListener)
+ {
+ if ( m_bDisposed )
+ return;
+
+ if ( m_aListeners != null )
+ m_aListeners.remove( xListener );
+ }
+
+ // com.sun.star.document.XEventBroadcaster:
+ // -------------------------------------------------------------
+ public void addEventListener(com.sun.star.document.XEventListener xListener)
+ {
+ if ( m_bDisposed )
+ return;
+
+ GetListeners().add( xListener );
+ }
+
+ // -------------------------------------------------------------
+ public void removeEventListener(com.sun.star.document.XEventListener xListener)
+ {
+ if ( m_bDisposed )
+ return;
+
+ if ( m_aListeners != null )
+ m_aListeners.remove( xListener );
+ }
+
+ // com.sun.star.util.XCloseBroadcaster:
+ // -------------------------------------------------------------
+ public void addCloseListener(com.sun.star.util.XCloseListener xListener)
+ {
+ if ( m_bDisposed )
+ return;
+
+ GetListeners().add( xListener );
+ }
+
+ // -------------------------------------------------------------
+ public void removeCloseListener(com.sun.star.util.XCloseListener xListener)
+ {
+ if ( m_bDisposed )
+ return;
+
+ if ( m_aListeners != null )
+ m_aListeners.remove( xListener );
+ }
+
+ // com.sun.star.util.XCloseable:
+ // -------------------------------------------------------------
+ public void close(boolean bDeliverOwnership) throws com.sun.star.util.CloseVetoException
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ com.sun.star.lang.EventObject aEventObject = new com.sun.star.lang.EventObject( this );
+
+ if ( m_aListeners != null )
+ {
+ for ( int nInd = 0; nInd < m_aListeners.size(); nInd++ )
+ {
+ try
+ {
+ com.sun.star.util.XCloseListener xListener = ( com.sun.star.util.XCloseListener )
+ UnoRuntime.queryInterface( com.sun.star.document.XEventListener.class, m_aListeners.get( nInd ) );
+
+ if ( xListener != null )
+ xListener.queryClosing( aEventObject, bDeliverOwnership );
+ }
+ catch( com.sun.star.util.CloseVetoException e )
+ {
+ throw e;
+ }
+ catch( java.lang.Exception e )
+ {
+ m_aListeners.remove( nInd );
+ }
+ }
+
+ m_bDisposed = true;
+
+ for ( int nInd = 0; nInd < m_aListeners.size(); nInd++ )
+ {
+ try
+ {
+ com.sun.star.util.XCloseListener xListener = ( com.sun.star.util.XCloseListener )
+ UnoRuntime.queryInterface( com.sun.star.document.XEventListener.class, m_aListeners.get( nInd ) );
+
+ if ( xListener != null )
+ xListener.notifyClosing( aEventObject );
+ }
+ catch( java.lang.Exception e )
+ {
+ m_aListeners.remove( nInd );
+ }
+ }
+
+ m_aListeners.clear();
+ }
+
+ m_bDisposed = true;
+
+ if ( m_aEditorFrame != null )
+ {
+ m_aEditorFrame.dispose();
+ m_aEditorFrame = null;
+ }
+
+ if ( m_xOwnStorage != null )
+ {
+ try {
+ m_xOwnStorage.dispose();
+ } catch( java.lang.Exception e ) {}
+ m_xOwnStorage = null;
+ }
+ }
+
+ // com.sun.star.embed.XEmbeddedObject:
+ // -------------------------------------------------------------
+ public void changeState(int nNewState) throws com.sun.star.embed.UnreachableStateException, com.sun.star.embed.WrongStateException, com.sun.star.uno.Exception
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 )
+ throw new com.sun.star.embed.WrongStateException();
+
+ int nOldState = m_nObjectState;
+
+ if ( nOldState == nNewState )
+ {
+ if ( nOldState == com.sun.star.embed.EmbedStates.ACTIVE )
+ {
+ if ( m_aEditorFrame == null )
+ throw new com.sun.star.uno.RuntimeException();
+ m_aEditorFrame.toFront();
+ }
+
+ return;
+ }
+
+ if ( nNewState != com.sun.star.embed.EmbedStates.LOADED
+ && nNewState != com.sun.star.embed.EmbedStates.RUNNING
+ && nNewState != com.sun.star.embed.EmbedStates.ACTIVE )
+ throw new com.sun.star.embed.UnreachableStateException();
+
+ StateChangeNotification( true, nOldState, nNewState );
+
+ try
+ {
+ if ( nOldState == com.sun.star.embed.EmbedStates.LOADED )
+ {
+ // switch to the RUNNING state first
+ String aText = ReadStringFromStream( m_xOwnStorage, "content.txt" );
+
+ EditorFrame aEditorFrame = new EditorFrame( m_aEntryName, this, 5, 20 );
+ aEditorFrame.setText( aText );
+
+ ReadSizeFromOwnStorage();
+
+ m_aEditorFrame = aEditorFrame;
+ m_nObjectState = com.sun.star.embed.EmbedStates.RUNNING;
+
+ if ( nNewState == com.sun.star.embed.EmbedStates.ACTIVE )
+ {
+ if ( m_xClient == null )
+ throw new com.sun.star.embed.WrongStateException();
+
+ m_aEditorFrame.show();
+ m_aEditorFrame.toFront();
+
+ if ( m_aObjSize != null )
+ aEditorFrame.setAppSize( m_aObjSize );
+
+ m_xClient.visibilityChanged( true );
+ m_nObjectState = com.sun.star.embed.EmbedStates.ACTIVE;
+ }
+ }
+ else if ( nOldState == com.sun.star.embed.EmbedStates.RUNNING )
+ {
+ if ( nNewState == com.sun.star.embed.EmbedStates.LOADED )
+ {
+ EditorFrame aFrame = m_aEditorFrame;
+ m_aEditorFrame = null;
+ aFrame.dispose();
+ m_nObjectState = nNewState;
+ }
+ else // nNewState == ACTIVE
+ {
+ if ( m_aEditorFrame == null )
+ throw new com.sun.star.uno.RuntimeException();
+
+ if ( m_xClient == null )
+ throw new com.sun.star.embed.WrongStateException();
+
+ m_aEditorFrame.show();
+ m_aEditorFrame.toFront();
+
+ if ( m_aObjSize != null )
+ m_aEditorFrame.setAppSize( m_aObjSize );
+
+ m_xClient.visibilityChanged( true );
+
+ m_nObjectState = nNewState;
+ }
+ }
+ else // nOldState == ACTIVE
+ {
+ UpdateSizeAndGetFromActive();
+ if ( nNewState == com.sun.star.embed.EmbedStates.RUNNING )
+ {
+ m_aEditorFrame.hide();
+ m_nObjectState = nNewState;
+ }
+ else // nNewState == LOADED
+ {
+ EditorFrame aFrame = m_aEditorFrame;
+ m_aEditorFrame = null;
+ aFrame.dispose();
+ m_nObjectState = nNewState;
+ }
+ }
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ if ( nOldState != m_nObjectState )
+ StateChangeNotification( false, nOldState, m_nObjectState );
+ throw e;
+ }
+
+ StateChangeNotification( true, nOldState, nNewState );
+ }
+
+ // -------------------------------------------------------------
+ public int[] getReachableStates() throws com.sun.star.embed.NeedsRunningStateException, com.sun.star.embed.WrongStateException
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 )
+ throw new com.sun.star.embed.WrongStateException();
+
+ int[] pStates = new int[3];
+ pStates[0] = com.sun.star.embed.EmbedStates.LOADED;
+ pStates[1] = com.sun.star.embed.EmbedStates.RUNNING;
+ pStates[2] = com.sun.star.embed.EmbedStates.ACTIVE;
+
+ return pStates;
+ }
+
+ // -------------------------------------------------------------
+ public int getCurrentState() throws com.sun.star.embed.WrongStateException
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 )
+ throw new com.sun.star.embed.WrongStateException();
+
+ return m_nObjectState;
+ }
+
+ // -------------------------------------------------------------
+ public void doVerb(int nVerbID) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.embed.WrongStateException, com.sun.star.embed.UnreachableStateException, com.sun.star.uno.Exception
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 )
+ throw new com.sun.star.embed.WrongStateException();
+
+ if ( nVerbID == com.sun.star.embed.EmbedVerbs.MS_OLEVERB_PRIMARY
+ || nVerbID == com.sun.star.embed.EmbedVerbs.MS_OLEVERB_SHOW
+ || nVerbID == com.sun.star.embed.EmbedVerbs.MS_OLEVERB_OPEN )
+ changeState( com.sun.star.embed.EmbedStates.ACTIVE );
+ else if ( nVerbID == com.sun.star.embed.EmbedVerbs.MS_OLEVERB_HIDE )
+ changeState( com.sun.star.embed.EmbedStates.RUNNING );
+ }
+
+ // -------------------------------------------------------------
+ public com.sun.star.embed.VerbDescriptor[] getSupportedVerbs() throws com.sun.star.embed.NeedsRunningStateException, com.sun.star.embed.WrongStateException
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 )
+ throw new com.sun.star.embed.WrongStateException();
+
+ if ( m_pOwnVerbs == null )
+ {
+ try
+ {
+ XMultiComponentFactory xFactory = m_xContext.getServiceManager();
+ Object obj = xFactory.createInstanceWithContext( "com.sun.star.configuration.ConfigurationProvider", m_xContext );
+ XMultiServiceFactory xConfProvider = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, obj );
+ if ( xConfProvider == null )
+ throw new com.sun.star.uno.RuntimeException();
+
+ Object[] aArgs = new Object[1];
+ aArgs[0] = "/org.openoffice.Office.Embedding/Objects";
+ Object oSettings = xConfProvider.createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", aArgs );
+ XNameAccess xObjConfNA = ( XNameAccess ) UnoRuntime.queryInterface( XNameAccess.class, oSettings );
+ if ( xObjConfNA == null )
+ throw new com.sun.star.uno.RuntimeException();
+
+ Object oEmbObj = xObjConfNA.getByName( "69474366-FD6F-4806-8374-8EDD1B6E771D" );
+ XNameAccess xEmbObjNA = (XNameAccess) UnoRuntime.queryInterface( XNameAccess.class, oEmbObj );
+ if ( xEmbObjNA == null )
+ throw new com.sun.star.uno.RuntimeException();
+
+ String[] pVerbShortcuts = (String[]) AnyConverter.toArray( xEmbObjNA.getByName( "ObjectVerbs" ) );
+ if ( pVerbShortcuts != null && pVerbShortcuts.length != 0 )
+ {
+ com.sun.star.embed.VerbDescriptor[] pVerbs = new com.sun.star.embed.VerbDescriptor[pVerbShortcuts.length];
+ aArgs[0] = "/org.openoffice.Office.Embedding/Verbs";
+ Object oVerbs = xConfProvider.createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", aArgs );
+ XNameAccess xVerbsConfNA = ( XNameAccess ) UnoRuntime.queryInterface( XNameAccess.class, oVerbs );
+ if ( xVerbsConfNA == null )
+ throw new com.sun.star.uno.RuntimeException();
+
+ for ( int nInd = 0; nInd < pVerbShortcuts.length; nInd++ )
+ {
+ try
+ {
+ XNameAccess xVerbNA = (XNameAccess) UnoRuntime.queryInterface(
+ XNameAccess.class,
+ xVerbsConfNA.getByName( pVerbShortcuts[nInd] ) );
+ if ( xVerbNA != null )
+ {
+ com.sun.star.embed.VerbDescriptor aVerb = new com.sun.star.embed.VerbDescriptor();
+ aVerb.VerbID = AnyConverter.toInt( xVerbNA.getByName( "VerbID" ) );
+ aVerb.VerbName = AnyConverter.toString( xVerbNA.getByName( "VerbUIName" ) );
+ aVerb.VerbFlags = AnyConverter.toInt( xVerbNA.getByName( "VerbFlags" ) );
+ aVerb.VerbAttributes = AnyConverter.toInt( xVerbNA.getByName( "VerbAttributes" ) );
+ pVerbs[nInd] = aVerb;
+ }
+ }
+ catch( java.lang.Exception e )
+ {
+ }
+
+ if ( pVerbs[nInd] == null )
+ {
+ // let the error be visible
+ pVerbs[nInd] = new com.sun.star.embed.VerbDescriptor();
+ pVerbs[nInd].VerbID = com.sun.star.embed.EmbedVerbs.MS_OLEVERB_PRIMARY;
+ pVerbs[nInd].VerbName = "ERROR!";
+ pVerbs[nInd].VerbFlags = 0;
+ pVerbs[nInd].VerbAttributes = com.sun.star.embed.VerbAttributes.MS_VERBATTR_ONCONTAINERMENU;
+ }
+ }
+
+ m_pOwnVerbs = pVerbs;
+ }
+ }
+ catch( com.sun.star.uno.Exception e )
+ {}
+ }
+
+ if ( m_pOwnVerbs != null )
+ return m_pOwnVerbs;
+
+ return new com.sun.star.embed.VerbDescriptor[0];
+ }
+
+ // -------------------------------------------------------------
+ public void setClientSite(com.sun.star.embed.XEmbeddedClient xClient) throws com.sun.star.embed.WrongStateException
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 )
+ throw new com.sun.star.embed.WrongStateException();
+
+ m_xClient = xClient;
+ }
+
+ // -------------------------------------------------------------
+ public com.sun.star.embed.XEmbeddedClient getClientSite() throws com.sun.star.embed.WrongStateException
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 )
+ throw new com.sun.star.embed.WrongStateException();
+
+ return m_xClient;
+ }
+
+ // -------------------------------------------------------------
+ public void update() throws com.sun.star.embed.WrongStateException, com.sun.star.uno.Exception
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 )
+ throw new com.sun.star.embed.WrongStateException();
+
+ // not implemented
+ }
+
+ // -------------------------------------------------------------
+ public void setUpdateMode(int nMode) throws com.sun.star.embed.WrongStateException
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 )
+ throw new com.sun.star.embed.WrongStateException();
+
+ // not implemented
+ }
+
+ // -------------------------------------------------------------
+ public long getStatus(long nAspect) throws com.sun.star.embed.WrongStateException
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ if ( m_nObjectState == -1 )
+ throw new com.sun.star.embed.WrongStateException();
+
+ return 0;
+ }
+
+ // -------------------------------------------------------------
+ public void setContainerName(String sName)
+ {
+ if ( m_bDisposed )
+ throw new com.sun.star.lang.DisposedException();
+
+ // not implemented
+ }
+}
+
diff --git a/odk/examples/java/EmbedDocument/EmbeddedObject/OwnEmbeddedObjectFactory.java b/odk/examples/java/EmbedDocument/EmbeddedObject/OwnEmbeddedObjectFactory.java
new file mode 100755
index 000000000000..fd8f2793c9c5
--- /dev/null
+++ b/odk/examples/java/EmbedDocument/EmbeddedObject/OwnEmbeddedObjectFactory.java
@@ -0,0 +1,101 @@
+package org.openoffice.examples.embedding;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lib.uno.helper.Factory;
+import com.sun.star.lang.XSingleComponentFactory;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.uno.Exception;
+import com.sun.star.lang.IllegalArgumentException;
+
+import com.sun.star.embed.*;
+
+import org.openoffice.examples.embedding.OwnEmbeddedObject;
+
+public final class OwnEmbeddedObjectFactory extends WeakBase
+ implements com.sun.star.lang.XServiceInfo,
+ com.sun.star.embed.XEmbedObjectFactory
+{
+ private final XComponentContext m_xContext;
+ private static final String m_implementationName = OwnEmbeddedObjectFactory.class.getName();
+ private static final String[] m_serviceNames = {
+ "org.openoffice.examples.embedding.Factory69474366FD6F480683748EDD1B6E771D" };
+ private static final byte[] m_classID = { 0x69, 0x47, 0x43, 0x66, (byte)0xFD, 0x6F, 0x48, 0x06, (byte)0x83, 0x74, (byte)0x8E, (byte)0xDD, 0x1B, 0x6E, 0x77, 0x1D };
+
+
+ public OwnEmbeddedObjectFactory( XComponentContext context )
+ {
+ m_xContext = context;
+ };
+
+ public static XSingleComponentFactory __getComponentFactory( String sImplementationName ) {
+ XSingleComponentFactory xFactory = null;
+
+ if ( sImplementationName.equals( m_implementationName ) )
+ xFactory = Factory.createComponentFactory(OwnEmbeddedObjectFactory.class, m_serviceNames);
+ return xFactory;
+ }
+
+ public static boolean __writeRegistryServiceInfo( XRegistryKey xRegistryKey ) {
+ return Factory.writeRegistryServiceInfo(m_implementationName,
+ m_serviceNames,
+ xRegistryKey);
+ }
+
+ // com.sun.star.lang.XServiceInfo:
+ public String getImplementationName() {
+ return m_implementationName;
+ }
+
+ 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;
+ }
+
+ public String[] getSupportedServiceNames() {
+ return m_serviceNames;
+ }
+
+ // com.sun.star.embed.XEmbedObjectFactory:
+ public Object createInstanceUserInit(byte[] aClassID, String sClassName, com.sun.star.embed.XStorage xStorage, String sEntName, int nEntryConnectionMode, com.sun.star.beans.PropertyValue[] aArgs, com.sun.star.beans.PropertyValue[] aObjectArgs) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.io.IOException, com.sun.star.uno.Exception
+ {
+ if ( xStorage == null || sEntName == null || sEntName.length() == 0 )
+ throw new com.sun.star.lang.IllegalArgumentException();
+
+ if ( nEntryConnectionMode == com.sun.star.embed.EntryInitModes.DEFAULT_INIT )
+ {
+ if ( aClassID != null && aClassID.length != 0 )
+ {
+ if ( aClassID.length != m_classID.length )
+ throw new com.sun.star.lang.IllegalArgumentException();
+
+ for ( int i = 0; i < aClassID.length; i++ )
+ if ( aClassID[i] != m_classID[i] )
+ throw new com.sun.star.lang.IllegalArgumentException();
+ }
+ else if ( !xStorage.hasByName( sEntName ) )
+ throw new com.sun.star.lang.IllegalArgumentException();
+ }
+ else if ( nEntryConnectionMode == com.sun.star.embed.EntryInitModes.TRUNCATE_INIT )
+ {
+ if ( aClassID.length != m_classID.length )
+ throw new com.sun.star.lang.IllegalArgumentException();
+
+ for ( int i = 0; i < m_classID.length; i++ )
+ if ( aClassID[i] != m_classID[i] )
+ throw new com.sun.star.lang.IllegalArgumentException();
+ }
+
+ OwnEmbeddedObject aObject = new OwnEmbeddedObject( m_xContext, m_classID );
+ aObject.setPersistentEntry( xStorage, sEntName, nEntryConnectionMode, aArgs, aObjectArgs );
+
+ return aObject;
+ }
+
+}
diff --git a/odk/examples/java/Inspector/Addon.xcu b/odk/examples/java/Inspector/Addon.xcu
new file mode 100755
index 000000000000..7989e35db35f
--- /dev/null
+++ b/odk/examples/java/Inspector/Addon.xcu
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<oor:node xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Addon" oor:package="org.openoffice.Office">
+ <node oor:name="AddonUI">
+ <node oor:name="OfficeToolBar">
+ <node oor:name="org.openoffice.Object-Inspector" oor:op="replace">
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Object Inspector</value>
+ </prop>
+ <node oor:name="m1" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.org.openoffice.inspector:post</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">~Start Inspector...</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="Context" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+ </oor:node>
+
diff --git a/odk/examples/java/Inspector/Addons.xcu b/odk/examples/java/Inspector/Addons.xcu
new file mode 100755
index 000000000000..0daa83fb392b
--- /dev/null
+++ b/odk/examples/java/Inspector/Addons.xcu
@@ -0,0 +1,23 @@
+<?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="OfficeToolBar">
+ <node oor:name="org.openoffice.Office.addon.Inspector" oor:op="replace">
+ <node oor:name="toolBar_Inspector" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>org.openoffice.Office.addon.Inspector:inspect</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Object Inspector</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="Context" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/java/Inspector/HideableMutableTreeNode.java b/odk/examples/java/Inspector/HideableMutableTreeNode.java
new file mode 100644
index 000000000000..c7f10ee69c41
--- /dev/null
+++ b/odk/examples/java/Inspector/HideableMutableTreeNode.java
@@ -0,0 +1,88 @@
+// *** HideableMutableTreeNode ***
+import javax.swing.*;
+import javax.swing.tree.*;
+
+/**
+ * <code>HideableMutableTreeNode</code> is a <code>DefaultMutableTreeNode</code>
+ * implementation that works with <code>HideableTreeModel</code>.
+ */
+public class HideableMutableTreeNode extends DefaultMutableTreeNode {
+ /**
+ * The node is visible flag.
+ */
+ public boolean bIsvisible = true;
+ private static final String SDUMMY = "Dummy";
+
+
+ /**
+ * Creates a tree node that has no parent and no children, but which
+ * allows children.
+ */
+ public HideableMutableTreeNode() {
+ super();
+ }
+
+ /**
+ * Creates a tree node with no parent, no children, but which allows
+ * children, and initializes it with the specified user object.
+ *
+ * @param userObject - an Object provided by the user that
+ * constitutes the node's data
+ */
+ public HideableMutableTreeNode(Object _userObject) {
+ super(_userObject);
+ }
+
+ /**
+ * Creates a tree node with no parent, no children, initialized with the
+ * specified user object, and that allows children only if specified.
+ *
+ * @param _userObject - an Object provided by the user that describes the node's data
+ * @param _ballowsChildren - if true, the node is allowed to have childnodes -- otherwise, it is always a leaf node
+ */
+ public HideableMutableTreeNode(Object _userObject, boolean _ballowsChildren) {
+ super(_userObject, _ballowsChildren);
+ }
+
+ /**
+ * Checks if the node is visible.
+ *
+ * @return true if the node is visible, else false
+ */
+ public boolean isVisible() {
+ return this.bIsvisible;
+ }
+
+ /**
+ * Sets if the node is visible.
+ *
+ * @param returns true if the node is visible, else false
+ */
+ public void setVisible(boolean _bIsVisible) {
+ this.bIsvisible = _bIsVisible;
+ }
+
+
+ public void addDummyNode(){
+ removeDummyNode();
+ DefaultMutableTreeNode oDefaultMutableTreeNode = new DefaultMutableTreeNode(SDUMMY);
+ add(oDefaultMutableTreeNode);
+
+ }
+
+
+ public boolean removeDummyNode(){
+ boolean breturn = false;
+ if (getChildCount() == 1){
+ DefaultMutableTreeNode oDefaultMutableTreeNode = (DefaultMutableTreeNode) getChildAt(0);
+ if (oDefaultMutableTreeNode != null){
+ if (oDefaultMutableTreeNode.getUserObject().equals(SDUMMY)){
+ remove(0);
+ breturn = true;
+ }
+ }
+ }
+ return breturn;
+ }
+
+} \ No newline at end of file
diff --git a/odk/examples/java/Inspector/HideableTreeModel.java b/odk/examples/java/Inspector/HideableTreeModel.java
new file mode 100644
index 000000000000..a4a18553ca87
--- /dev/null
+++ b/odk/examples/java/Inspector/HideableTreeModel.java
@@ -0,0 +1,298 @@
+
+// *** HideableTreeModel ***
+import java.awt.*;
+import java.awt.event.*;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Vector;
+import javax.swing.*;
+import javax.swing.event.*;
+import javax.swing.tree.*;
+
+
+public class HideableTreeModel implements TreeModel {
+
+ private Vector modelListeners = new Vector();
+ private Object root = null;
+
+
+ public HideableTreeModel(TreeNode _root) {
+ super();
+ setRoot(_root);
+ }
+
+
+ public Object getRoot() {
+ return this.root;
+ }
+
+
+ protected void setRoot(Object r) {
+ this.root = r;
+ }
+
+
+ public Object[] getPathToRoot(Object node) {
+ return getPathToRoot(node, 0);
+ }
+
+
+ private Object[] getPathToRoot(Object node, int i) {
+ Object anode[];
+ if(node == null) {
+ if(i == 0) {
+ return null;
+ }
+ anode = new Object[i];
+ } else {
+ i++;
+ if(node == getRoot()) {
+ anode = new Object[i];
+ } else {
+ anode = getPathToRoot(getParent(node), i);
+ }
+ anode[anode.length - i] = node;
+ }
+ return anode;
+ }
+
+
+ public void addTreeModelListener(TreeModelListener l) {
+ modelListeners.addElement(l);
+ }
+
+
+ public void removeTreeModelListener(TreeModelListener l) {
+ modelListeners.removeElement(l);
+ }
+
+
+ public void reload() {
+ reload(getRoot());
+ }
+
+
+ public void reload(Object node) {
+ if(node != null) {
+ TreePath tp = new TreePath(getPathToRoot(node));
+ fireTreeStructureChanged(new TreeModelEvent(this, tp));
+ }
+ }
+
+
+ public void valueForPathChanged(TreePath path, Object newValue) {
+ nodeChanged(path.getLastPathComponent());
+ }
+
+ public void nodeInserted(Object node, Object child) {
+ nodeInserted(node, child, -1);
+ }
+
+
+ public void nodeInserted(Object node, Object child, int index) {
+ if(index < 0) {
+ index = getIndexOfChild(node, child);
+ }
+ if(node != null && child != null && index >= 0) {
+ TreePath tp = new TreePath(getPathToRoot(node));
+ int[] ai = { index };
+ Object[] ac = { child };
+ fireTreeNodesInserted(new TreeModelEvent(this, tp, ai, ac));
+ }
+ }
+
+
+ public void nodeRemoved(Object node, Object child, int index) {
+ if(node != null && child != null && index >= 0) {
+ TreePath tp = new TreePath(getPathToRoot(node));
+ int[] ai = { index };
+ Object[] ac = { child };
+ fireTreeNodesRemoved(new TreeModelEvent(this, tp, ai, ac));
+ }
+ }
+
+
+ public void nodeChanged(Object node) {
+ if(node != null) {
+ TreePath tp = new TreePath(getPathToRoot(node));
+ fireTreeNodesChanged(new TreeModelEvent(this, tp, null, null));
+ }
+ }
+
+
+ protected void fireTreeNodesChanged(TreeModelEvent event) {
+ for(int i = 0; i < modelListeners.size(); i++) {
+ ((TreeModelListener)modelListeners.elementAt(i)).treeNodesChanged(event);
+ }
+ }
+
+
+ protected void fireTreeNodesInserted(TreeModelEvent event) {
+ for(int i = 0; i < modelListeners.size(); i++) {
+ ((TreeModelListener)modelListeners.elementAt(i)).treeNodesInserted(event);
+ }
+ }
+
+
+ protected void fireTreeNodesRemoved(TreeModelEvent event) {
+ for(int i = 0; i < modelListeners.size(); i++) {
+ ((TreeModelListener)modelListeners.elementAt(i)).treeNodesRemoved(event);
+ }
+ }
+
+ protected void fireTreeStructureChanged(TreeModelEvent event) {
+ for(int i = 0; i < modelListeners.size(); i++) {
+ ((TreeModelListener)modelListeners.elementAt(i)).treeStructureChanged(event);
+ }
+ }
+
+
+ public ArrayList getExpandedPaths(JTree tree) {
+ ArrayList expandedPaths = new ArrayList();
+ addExpandedPaths(tree, tree.getPathForRow(0), expandedPaths);
+ return expandedPaths;
+ }
+
+
+ private void addExpandedPaths(JTree tree, TreePath path, ArrayList pathlist) {
+ Enumeration aEnum = tree.getExpandedDescendants(path);
+ while(aEnum.hasMoreElements()) {
+ TreePath tp = (TreePath) aEnum.nextElement();
+ pathlist.add(tp);
+ addExpandedPaths(tree, tp, pathlist);
+ }
+ }
+
+
+ public void expandPaths(JTree tree, ArrayList pathlist) {
+ for(int i = 0; i < pathlist.size(); i++) {
+ tree.expandPath((TreePath)pathlist.get(i));
+ }
+ }
+
+
+ public boolean isLeaf(Object _oNode) {
+ if(_oNode instanceof TreeNode) {
+ return ((TreeNode) _oNode).isLeaf();
+ }
+ return true;
+ }
+
+
+
+ public Object getParent(Object node) {
+ if(node != getRoot() && (node instanceof TreeNode)) {
+ return ((TreeNode)node).getParent();
+ }
+ return null;
+ }
+
+
+ public boolean isNodeVisible(Object node) {
+ if(node != getRoot()) {
+ if(node instanceof HideableMutableTreeNode) {
+ return ((HideableMutableTreeNode)node).isVisible();
+ }
+ }
+ return true;
+ }
+
+
+ public boolean setNodeVisible(Object node, boolean v) {
+ // can't hide root
+ if(node != getRoot()) {
+ if(node instanceof HideableMutableTreeNode) {
+ HideableMutableTreeNode n = (HideableMutableTreeNode)node;
+ if(v != n.isVisible()) {
+ TreeNode parent = n.getParent();
+ if(v) {
+ // need to get index after showing...
+ n.setVisible(v);
+ int index = getIndexOfChild(parent, n);
+ nodeInserted(parent, n, index);
+ } else {
+ // need to get index before hiding...
+ int index = getIndexOfChild(parent, n);
+ n.setVisible(v);
+ nodeRemoved(parent, n, index);
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public boolean isPathToNodeVisible(Object node) {
+ Object[] path = getPathToRoot(node);
+ for(int i = 0; i < path.length; i++) {
+ if(!isNodeVisible(path[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+ public void ensurePathToNodeVisible(Object node) {
+ Object[] path = getPathToRoot(node);
+ for(int i = 0; i < path.length; i++) {
+ setNodeVisible(path[i], true);
+ }
+ }
+
+
+ public Object getChild(Object parent, int index) {
+ if(parent instanceof TreeNode) {
+ TreeNode p = (TreeNode) parent;
+ for(int i = 0, j = -1; i < p.getChildCount(); i++) {
+ TreeNode pc = (TreeNode)p.getChildAt(i);
+ if(isNodeVisible(pc)) {
+ j++;
+ }
+ if(j == index) {
+ return pc;
+ }
+ }
+ }
+ return null;
+ }
+
+
+ public int getChildCount(Object parent) {
+ int count = 0;
+ if(parent instanceof TreeNode) {
+ TreeNode p = (TreeNode) parent;
+ for(int i = 0; i < p.getChildCount(); i++) {
+ TreeNode pc = (TreeNode)p.getChildAt(i);
+ if(isNodeVisible(pc)) {
+ count++;
+ }
+ }
+ }
+ return count;
+ }
+
+
+ public int getIndexOfChild(Object parent, Object child) {
+ int index = -1;
+ if(parent instanceof TreeNode && child instanceof TreeNode) {
+ TreeNode p = (TreeNode)parent;
+ TreeNode c = (TreeNode)child;
+ if(isNodeVisible(c)) {
+ index = 0;
+ for(int i = 0; i < p.getChildCount(); i++) {
+ TreeNode pc = (TreeNode)p.getChildAt(i);
+ if(pc.equals(c)) {
+ return index;
+ }
+ if(isNodeVisible(pc)) {
+ index++;
+ }
+ }
+ }
+ }
+ return index;
+ }
+} \ No newline at end of file
diff --git a/odk/examples/java/Inspector/Inspector.java b/odk/examples/java/Inspector/Inspector.java
new file mode 100644
index 000000000000..c8887d4c0344
--- /dev/null
+++ b/odk/examples/java/Inspector/Inspector.java
@@ -0,0 +1,461 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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.XWindowPeer;
+import com.sun.star.beans.NamedValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.frame.XModel;
+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.lang.XSingleComponentFactory;
+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.ui.dialogs.XExecutableDialog;
+import com.sun.star.ui.dialogs.XFolderPicker;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.util.CloseVetoException;
+import com.sun.star.util.XChangesBatch;
+import com.sun.star.util.XCloseable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Vector;
+import org.openoffice.XInstanceInspector;
+
+
+/** The purpose of this class is to provide a factory for creating the service
+ * (<CODE>__getServiceFactory</CODE>) and writes the information into the given
+ * registry key (<CODE>__writeRegistryServiceInfo</CODE>).
+ */
+public class Inspector{
+ public static final String sIDLDOCUMENTSUBFOLDER = "docs/common/ref/";
+
+
+ /** This class implements the method of the interface XInstanceInspector.
+ * Also the class implements the interfaces XServiceInfo, and XTypeProvider.
+ */
+ static public class _Inspector extends WeakBase implements XInstanceInspector, XServiceInfo{
+
+ static private final String __serviceName = "org.openoffice.InstanceInspector";
+ private HashMap aApplicationHashMap = new HashMap();
+ private String sTitle = "Object Inspector";
+ private Vector aHiddenDocuments = new Vector();
+// private String[] sApplicationDocUrls = new String[]{"private:factory/swriter", "private:factory/scalc", "private:factory/simpress", "private:factory/sdraw", "private:factory/sbase"};
+// private String[] sApplicationDocNames = new String[]{"Text Document", "Spreadsheet", "Presentation", "Drawing", "Database"};
+ private XComponentContext m_xComponentContext;
+ private HashMap aInspectorPanes = new HashMap();
+ private XDialogProvider m_oSwingDialogProvider;
+ private TDocSupplier oTDocSupplier;
+ private Introspector m_oIntrospector = null;
+ // TODO: improve these strings:
+ private static final String sWRONGINSTALLATIONPATH = "Your selected path does not refer to an SDK-Installation!";
+ /** Creates a new instance of Dialog */
+ public _Inspector(XComponentContext _xComponentContext) {
+ m_xComponentContext = _xComponentContext;
+ m_oIntrospector = Introspector.getIntrospector(m_xComponentContext);
+ aApplicationHashMap.put("private:factory/swriter", "Text Document");
+ aApplicationHashMap.put("private:factory/scalc", "Spreadsheet");
+ aApplicationHashMap.put("private:factory/simpress", "Presentation");
+ aApplicationHashMap.put("private:factory/sdraw", "Drawing");
+ aApplicationHashMap.put("private:factory/smath", "Formula");
+ m_oSwingDialogProvider = new SwingDialogProvider(this, sTitle);
+// aApplicationHashMap.put("private:factory/sbase", "Database");
+ }
+
+
+ public XComponentContext getXComponentContext(){
+ return m_xComponentContext;
+ }
+
+
+ public HashMap getInspectorPages(){
+ return aInspectorPanes;
+ }
+
+
+ protected String getSDKPath(){
+ String sRetPath = "";
+ try{
+ XNameAccess xNameAccess = getConfigurationAccess("org.openoffice.inspector.ObjectInspector", true);
+ XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xNameAccess);
+ sRetPath = (String) xPropertySet.getPropertyValue("SDKPath");
+ }catch( Exception exception ) {
+ exception.printStackTrace(System.out);
+ }
+ return sRetPath;
+ }
+
+
+ public String getIDLPath(){
+ String sRetPath = getSDKPath();
+ if (m_oIntrospector.isValidSDKInstallationPath(sRetPath)){
+ sRetPath = m_oIntrospector.addToPath(sRetPath, sIDLDOCUMENTSUBFOLDER);
+ }
+ else{
+ sRetPath = "";
+ }
+ return sRetPath;
+ }
+
+
+ public void openIdlFileforSelectedNode(){
+ InspectorPane oInspectorPane = m_oSwingDialogProvider.getSelectedInspectorPage();
+ if (oInspectorPane != null){
+ XUnoNode oUnoNode = oInspectorPane.getSelectedNode();
+ if (oUnoNode != null){
+ String sPath = getIDLPath();
+ oUnoNode.openIdlDescription(sPath);
+ }
+ }
+ }
+
+
+ public void assignSDKPath() {
+ try {
+ String sInstallationFolder = "";
+ Object oFolderPicker = m_xComponentContext.getServiceManager().createInstanceWithContext("com.sun.star.ui.dialogs.FolderPicker", m_xComponentContext);
+ XFolderPicker xFolderPicker = (XFolderPicker) UnoRuntime.queryInterface(XFolderPicker.class, oFolderPicker);
+ XExecutableDialog xExecutable = (XExecutableDialog) UnoRuntime.queryInterface(XExecutableDialog.class, oFolderPicker);
+ XComponent xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, oFolderPicker);
+ String sPath = getSDKPath();
+ if (!sPath.equals("")){
+ xFolderPicker.setDisplayDirectory(sPath);
+ }
+ xFolderPicker.setTitle("Add the Path to your SDK installation");
+ short nResult = xExecutable.execute();
+ if (nResult == com.sun.star.ui.dialogs.ExecutableDialogResults.OK){
+ sInstallationFolder = xFolderPicker.getDirectory();
+ if (m_oIntrospector.isValidSDKInstallationPath(sInstallationFolder)){
+ XNameAccess xNameAccess = getConfigurationAccess(true);
+ XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xNameAccess);
+ xPropertySet.setPropertyValue("SDKPath", sInstallationFolder);
+ XChangesBatch xBatch = (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class, xNameAccess);
+ xBatch.commitChanges();
+ }
+ else{
+ XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xFolderPicker);
+ Object oWindow = xPropertySet.getPropertyValue("Window");
+ XWindowPeer xWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, oWindow);
+ showErrorMessageBox(xWindowPeer, sTitle, sWRONGINSTALLATIONPATH);
+ assignSDKPath();
+ }
+ }
+ xComponent.dispose();
+ }catch( Exception exception ) {
+ exception.printStackTrace(System.out);
+ }}
+
+
+ public void showErrorMessageBox(XWindowPeer _xWindowPeer, String _sTitle, String _sMessage){
+ try {
+ Object oToolkit = m_xComponentContext.getServiceManager().createInstanceWithContext("com.sun.star.awt.Toolkit", m_xComponentContext);
+ XMessageBoxFactory xMessageBoxFactory = (XMessageBoxFactory) UnoRuntime.queryInterface(XMessageBoxFactory.class, oToolkit);
+ Rectangle aRectangle = new Rectangle();
+ XMessageBox xMessageBox = xMessageBoxFactory.createMessageBox(_xWindowPeer, aRectangle, "errorbox", com.sun.star.awt.MessageBoxButtons.BUTTONS_OK, _sTitle, _sMessage);
+ XComponent xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xMessageBox);
+ if (xMessageBox != null){
+ short nResult = xMessageBox.execute();
+ xComponent.dispose();
+ }
+ } catch (com.sun.star.uno.Exception ex) {
+ ex.printStackTrace(System.out);
+ }}
+
+
+ public void inspect(java.lang.Object _oUserDefinedObject, String _sTitle) throws com.sun.star.uno.RuntimeException {
+ try {
+ int nPageIndex = m_oSwingDialogProvider.getInspectorPageCount();
+ SwingTreeControlProvider oSwingTreeControlProvider = new SwingTreeControlProvider(m_oSwingDialogProvider);
+ InspectorPane oInspectorPane = new InspectorPane(getXComponentContext(), m_oSwingDialogProvider, oSwingTreeControlProvider, getSourceCodeLanguage());
+ oInspectorPane.inspect(_oUserDefinedObject, _sTitle);
+ getInspectorPages().put(_sTitle, oInspectorPane);
+ m_oSwingDialogProvider.show(nPageIndex);
+ }catch( Exception exception ) {
+ exception.printStackTrace(System.out);
+ }}
+
+
+ public void inspectOpenEmptyDocument(String _sApplicationDocUrl){
+ XComponent xComponent = getTDocSupplier().openEmptyDocument(_sApplicationDocUrl);
+ String sRootTitle = (String) aApplicationHashMap.get(_sApplicationDocUrl);
+ inspect(xComponent, sRootTitle);
+ aHiddenDocuments.add(xComponent);
+ }
+
+
+ public void inspectOpenDocument(String _sTDocUrl){
+ String sTreeNodeName = getTDocSupplier().getTitleByTDocUrl(_sTDocUrl);
+ XModel xTDocModel = getTDocSupplier().getXModelByTDocUrl(_sTDocUrl);
+ inspect(xTDocModel, sTreeNodeName);
+ }
+
+
+ public void inspectSelectedNode(){
+ InspectorPane oInspectorPane = m_oSwingDialogProvider.getSelectedInspectorPage();
+ if (oInspectorPane != null){
+ XUnoNode oUnoNode = oInspectorPane.getSelectedNode();
+ Object oUnoObject = oUnoNode.getUnoObject();
+ if (oUnoObject != null){
+ String sNodeDescription = UnoNode.getNodeDescription(oUnoObject);
+ inspect(oUnoObject, sNodeDescription);
+ }
+ }
+ }
+
+
+ public void addSourceCodeOfSelectedNode(){
+ InspectorPane oInspectorPane = m_oSwingDialogProvider.getSelectedInspectorPage();
+ if (oInspectorPane != null){
+ oInspectorPane.addSourceCodeOfSelectedNode();
+ }
+ }
+
+
+ public void invokeSelectedMethod(){
+ InspectorPane oInspectorPane = m_oSwingDialogProvider.getSelectedInspectorPage();
+ if (oInspectorPane != null){
+ oInspectorPane.invokeSelectedMethodNode();
+ }
+ }
+
+
+ public void setSourceCodeLanguage(final int _nLanguage){
+ try{
+ String sLanguage = "Java";
+ XNameAccess xNameAccess = getConfigurationAccess("org.openoffice.inspector.ObjectInspector", true);
+ XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xNameAccess);
+ switch (_nLanguage){
+ case XLanguageSourceCodeGenerator.nJAVA:
+ sLanguage = "Java";
+ break;
+ case XLanguageSourceCodeGenerator.nCPLUSPLUS:
+ sLanguage = "CPlusPlus";
+ break;
+ case XLanguageSourceCodeGenerator.nBASIC:
+ sLanguage = "Basic";
+ break;
+ default:
+ System.out.println("Warning: Sourcecode language is not defined!");
+ }
+ xPropertySet.setPropertyValue("Language", sLanguage);
+ XChangesBatch xBatch = (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class, xNameAccess);
+ xBatch.commitChanges();
+ for (int i = 0; i < m_oSwingDialogProvider.getInspectorPageCount(); i++){
+ m_oSwingDialogProvider.getInspectorPage(i).convertCompleteSourceCode(_nLanguage);
+ }
+ }catch( Exception exception ) {
+ exception.printStackTrace(System.out);
+ }}
+
+
+ private TDocSupplier getTDocSupplier(){
+ if (oTDocSupplier == null){
+ oTDocSupplier = new TDocSupplier(m_xComponentContext);
+ }
+ return oTDocSupplier;
+ }
+
+ public String[] getTDocUrls(){
+ return getTDocSupplier().getTDocUrls();
+ }
+
+
+ public String[] getTDocTitles(String[] _sTDocUrls){
+ return getTDocSupplier().getTDocTitles(_sTDocUrls);
+ }
+
+
+ public String[][] getApplicationUrls(){
+ Set aSet = aApplicationHashMap.keySet();
+ String[][] sReturnList = new String[aSet.size()][];
+ int n= 0;
+ for ( Iterator i = aSet.iterator(); i.hasNext(); ){
+ String[] sSingleApplication = new String[2];
+ sSingleApplication[0] = (String) i.next();
+ // assign the title in the second index
+ sSingleApplication[1] = (String) aApplicationHashMap.get(sSingleApplication[0]);
+ sReturnList[n++] = sSingleApplication;
+ }
+ return sReturnList;
+ }
+
+
+ public void disposeHiddenDocuments(){
+ int nHiddenCount = aHiddenDocuments.size();
+ if (nHiddenCount > 0){
+ for (int i = nHiddenCount - 1; i >= 0; i--){
+ XComponent xComponent = (XComponent) aHiddenDocuments.get(i);
+ if (xComponent != null){
+ try {
+ XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, xComponent);
+ xCloseable.close(true);
+ aHiddenDocuments.remove(i);
+ } catch (CloseVetoException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+
+
+ public static String[] getServiceNames() {
+ String[] sSupportedServiceNames = { __serviceName };
+ return sSupportedServiceNames;
+ }
+
+ // Implement the interface XServiceInfo
+ /** Get all supported service names.
+ * @return Supported service names.
+ */
+ public String[] getSupportedServiceNames() {
+ return getServiceNames();
+ }
+
+ // Implement the interface XServiceInfo
+ /** Test, if the given service will be supported.
+ * @param sService Service name.
+ * @return Return true, if the service will be supported.
+ */
+ public boolean supportsService( String sServiceName ) {
+ return sServiceName.equals( __serviceName );
+ }
+
+ // Implement the interface XServiceInfo
+ /** Get the implementation name of the component.
+ * @return Implementation name of the component.
+ */
+ public String getImplementationName() {
+ return _Inspector.class.getName();
+ }
+
+
+ private int getSourceCodeLanguage(){
+ int nLanguage = XLanguageSourceCodeGenerator.nJAVA;
+ try{
+ XNameAccess xNameAccess = getConfigurationAccess("org.openoffice.inspector.ObjectInspector", false);
+ String sLanguage = (String) xNameAccess.getByName("Language");
+ if (sLanguage.toUpperCase().equals("JAVA")){
+ nLanguage = XLanguageSourceCodeGenerator.nJAVA;
+ }
+ else if (sLanguage.toUpperCase().equals("BASIC")){
+ nLanguage = XLanguageSourceCodeGenerator.nBASIC;
+ }
+ else if (sLanguage.toUpperCase().equals("CPLUSPLUS")){
+ nLanguage = XLanguageSourceCodeGenerator.nCPLUSPLUS;
+ }
+ else{
+ System.out.println("Warning: Sourcecode language " + sLanguage + " is not defined!");
+ }
+ m_oSwingDialogProvider.selectSourceCodeLanguage(nLanguage);
+ }catch( Exception exception ) {
+ exception.printStackTrace(System.out);
+ }
+ return nLanguage;
+ }
+
+
+ public XNameAccess getConfigurationAccess(boolean _bUpdate){
+ return getConfigurationAccess("org.openoffice.inspector.ObjectInspector", _bUpdate);
+ }
+
+
+ public XNameAccess getConfigurationAccess(String _sNodePath, boolean update) {
+ XNameAccess xNameAccess = null;
+ try {
+ String sAccess = "";
+ if (update) {
+ sAccess = "com.sun.star.configuration.ConfigurationUpdateAccess";
+ }
+ else{
+ sAccess = "com.sun.star.configuration.ConfigurationAccess";
+ }
+ XMultiComponentFactory xMCF = m_xComponentContext.getServiceManager();
+ Object oDefaultProvider = xMCF.createInstanceWithContext("com.sun.star.configuration.DefaultProvider", this.getXComponentContext());
+ XMultiServiceFactory xMSFCfg = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDefaultProvider);
+ Object oAccess = xMSFCfg.createInstanceWithArguments(sAccess, new Object[]{new NamedValue("nodepath", _sNodePath)});
+ xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oAccess);
+ } catch (com.sun.star.uno.Exception e) {
+ }
+ return xNameAccess;
+ }
+
+
+ }
+
+// end of inner class
+
+
+ /**
+ * 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( _Inspector.class.getName() ) )
+ xFactory = Factory.createComponentFactory(_Inspector.class, _Inspector.getServiceNames());
+ if ( xFactory == null )
+ xFactory = InspectorAddon.__getComponentFactory(sImplName);
+ 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(_Inspector.class.getName(), _Inspector.getServiceNames(), regKey)
+ && InspectorAddon.__writeRegistryServiceInfo(regKey));
+ }
+}
+
diff --git a/odk/examples/java/Inspector/InspectorAddon.java b/odk/examples/java/Inspector/InspectorAddon.java
new file mode 100644
index 000000000000..be35f8a1988e
--- /dev/null
+++ b/odk/examples/java/Inspector/InspectorAddon.java
@@ -0,0 +1,228 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.frame.DispatchDescriptor;
+import com.sun.star.frame.FrameSearchFlag;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStatusListener;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XSingleComponentFactory;
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lib.uno.helper.Factory;
+
+
+public class InspectorAddon {
+ /** This class implements the component. At least the interfaces XServiceInfo,
+ * XTypeProvider, and XInitialization should be provided by the service.
+ */
+ public static class InspectorAddonImpl extends WeakBase implements XDispatchProvider, XInitialization, XServiceInfo {
+ private static XModel xModel = null;
+ org.openoffice.XInstanceInspector xInstInspector = null;
+// Dispatcher oDispatcher = null;
+ XFrame m_xFrame = null;
+
+ private static final String[] m_serviceNames = {
+ "org.openoffice.InstanceInspectorAddon",
+ "com.sun.star.frame.ProtocolHandler" };
+ ;
+ private XComponentContext m_xContext = null;
+
+ /** Creates a new instance of InspectorAddon */
+ public InspectorAddonImpl(XComponentContext _xContext) {
+ m_xContext = _xContext;
+ }
+
+ 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.Inspector:") == 0 ) {
+ if ( aURL.Path.compareTo( "inspect" ) == 0 ){
+ // Todo: Check if the frame is already administered (use hashtable)
+ xRet = new Dispatcher(m_xFrame);
+ }
+ }
+ 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;
+ }
+
+
+ public void initialize( Object[] object ) throws com.sun.star.uno.Exception {
+ if ( object.length > 0 ){
+ m_xFrame = ( XFrame ) UnoRuntime.queryInterface(XFrame.class, object[ 0 ] );
+ }
+ }
+
+ public class Dispatcher implements XDispatch{
+ private XFrame m_xFrame = null;
+ private XModel xModel = null;
+
+ public Dispatcher(XFrame _xFrame){
+ m_xFrame = _xFrame;
+ if (m_xFrame != null){
+ XController xController = m_xFrame.getController();
+ if (xController != null){
+ xModel = xController.getModel();
+ }
+ }
+ }
+
+ // XDispatch
+ public void dispatch( /*IN*/com.sun.star.util.URL _aURL, /*IN*/com.sun.star.beans.PropertyValue[] aArguments ) {
+ try{
+ if ( _aURL.Protocol.compareTo("org.openoffice.Office.addon.Inspector:") == 0 ){
+ if ( _aURL.Path.equals("inspect")){
+ Object oUnoInspectObject = xModel;
+ com.sun.star.lang.XMultiComponentFactory xMCF = m_xContext.getServiceManager();
+ if (xInstInspector == null){
+ Object obj= xMCF.createInstanceWithContext("org.openoffice.InstanceInspector", m_xContext);
+ xInstInspector = (org.openoffice.XInstanceInspector)UnoRuntime.queryInterface(org.openoffice.XInstanceInspector.class, obj);
+ }
+ if ((m_xFrame == null) || (xModel == null)){
+ Object oDesktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", m_xContext);
+ m_xFrame = (XFrame) UnoRuntime.queryInterface(XFrame.class, oDesktop);
+ oUnoInspectObject = m_xFrame;
+ }
+ XPropertySet xFramePropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, m_xFrame);
+ String sTitle = (String) xFramePropertySet.getPropertyValue("Title");
+ String[] sTitleList = sTitle.split(" - ");
+ if (sTitleList.length > 0){
+ sTitle = sTitleList[0];
+ }
+ xInstInspector.inspect(oUnoInspectObject, sTitle);
+ }
+ }
+ } catch( Exception e ) {
+ System.err.println( e + e.getMessage());
+ e.printStackTrace(System.out);
+ }}
+
+ 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 static String[] getServiceNames() {
+ return m_serviceNames;
+ }
+
+ // Implement the interface XServiceInfo
+ /** Get all supported service names.
+ * @return Supported service names.
+ */
+ public String[] getSupportedServiceNames() {
+ return getServiceNames();
+ }
+
+ // Implement the interface XServiceInfo
+ /** Test, if the given service will be supported.
+ * @param sService Service name.
+ * @return Return true, if the service will be supported.
+ */
+ public boolean supportsService( String sServiceName ) {
+ int len = m_serviceNames.length;
+
+ for( int i=0; i < len; i++) {
+ if ( sServiceName.equals( m_serviceNames[i] ) )
+ return true;
+ }
+
+ return false;
+ }
+
+ // Implement the interface XServiceInfo
+ /** Get the implementation name of the component.
+ * @return Implementation name of the component.
+ */
+ public String getImplementationName() {
+ return InspectorAddonImpl.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( InspectorAddonImpl.class.getName() ) )
+ xFactory = Factory.createComponentFactory(InspectorAddonImpl.class, InspectorAddonImpl.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(InspectorAddonImpl.class.getName(), InspectorAddonImpl.getServiceNames(), regKey);
+ }
+
+// __create( XComponentContext ){
+//
+// }
+}
diff --git a/odk/examples/java/Inspector/InspectorPane.java b/odk/examples/java/Inspector/InspectorPane.java
new file mode 100644
index 000000000000..4748c1a62f77
--- /dev/null
+++ b/odk/examples/java/Inspector/InspectorPane.java
@@ -0,0 +1,629 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.uno.TypeClass;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.beans.XIntrospectionAccess;
+import com.sun.star.beans.Property;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.reflection.XIdlMethod;
+import javax.swing.tree.ExpandVetoException;
+import org.openoffice.XInstanceInspector;
+import javax.swing.tree.TreePath;
+import javax.swing.event.TreeWillExpandListener;
+
+ public class InspectorPane extends WeakBase implements XInstanceInspector{ //, XServiceInfo
+ private XIdlMethod[] xIdlMethods;
+ private Property[] aProperties;
+ private boolean bIncludeContent = false;
+ private XComponentContext m_xComponentContext;
+ private XDialogProvider m_xDialogProvider;
+ private Introspector m_oIntrospector = null;
+ private SourceCodeGenerator m_oSourceCodeGenerator;
+ private XTreeControlProvider m_xTreeControlProvider;
+ private String sTitle = "";
+
+
+ /** The constructor of the inner class has a XMultiServiceFactory parameter.
+ * @param xMultiServiceFactory XMultiServiceFactory
+ */
+ public InspectorPane(XComponentContext _xComponentContext, XDialogProvider _xDialogProvider, XTreeControlProvider _xTreeControlProvider, int _nLanguage) {
+ m_xComponentContext = _xComponentContext;
+ m_xTreeControlProvider = _xTreeControlProvider;
+ m_xDialogProvider = _xDialogProvider;
+ m_oIntrospector = Introspector.getIntrospector(m_xComponentContext);
+ m_oSourceCodeGenerator = new SourceCodeGenerator(_nLanguage);
+ _xTreeControlProvider.addInspectorPane(this);
+ }
+
+
+ private void setMaximumOfProgressBar(Object _oUnoObject){
+ int nMaxValue = 0;
+ xIdlMethods = m_oIntrospector.getMethods(_oUnoObject);
+ aProperties = m_oIntrospector.getProperties(_oUnoObject);
+ }
+
+
+ /** Inspect the given object for methods, properties, interfaces, and
+ * services.
+ * @param a The object to inspect
+ * @throws RuntimeException If
+ */
+ public void inspect(java.lang.Object _oUserDefinedObject, String _sTitle) throws com.sun.star.uno.RuntimeException {
+ try {
+ Object oContainer = m_xTreeControlProvider.inspect(_oUserDefinedObject, _sTitle);
+ m_xDialogProvider.addInspectorPage(getTitle(), oContainer);
+ }
+ catch( Exception exception ) {
+ exception.printStackTrace(System.out);
+ }}
+
+
+ public void setTitle(String _sTitle){
+ if (_sTitle != null){
+ if (_sTitle.length() > 0){
+ sTitle = _sTitle;
+ }
+ }
+ }
+
+
+ public String getTitle(){
+ return sTitle;
+ }
+
+
+
+ private Type[] getTypes(Object _oUnoObject){
+ Type[] aTypes = null;
+ if (m_oIntrospector.isArray(_oUnoObject)){
+ aTypes = (Type[])_oUnoObject;
+ }
+ else{
+ aTypes = m_oIntrospector.getInterfaces(_oUnoObject);
+ }
+ return aTypes;
+ }
+
+
+ private Object invoke(XUnoMethodNode _oUnoMethodNode){
+ try{
+ String sParamValueDescription = "";
+ Object oUnoReturnObject = _oUnoMethodNode.invoke();
+ boolean bHasParameters = _oUnoMethodNode.hasParameters();
+ boolean bIsPrimitive = _oUnoMethodNode.isPrimitive();
+ if (bHasParameters){
+ sParamValueDescription = " (" + m_oSourceCodeGenerator.getMethodParameterValueDescription(_oUnoMethodNode, _oUnoMethodNode.getLastParameterObjects(), true) + ")";
+ }
+ if (oUnoReturnObject != null ){
+ String sNodeDescription = "";
+ XUnoNode oUnoNode = null;
+ if (_oUnoMethodNode.getXIdlMethod().getReturnType().getTypeClass().getValue() == TypeClass.VOID_value){
+ sNodeDescription += _oUnoMethodNode.getXIdlMethod().getReturnType().getName() + " " + _oUnoMethodNode.getXIdlMethod().getName() + sParamValueDescription;
+ _oUnoMethodNode.setLabel(sNodeDescription);
+ m_xTreeControlProvider.nodeChanged(_oUnoMethodNode);
+ }
+ else if (bHasParameters || !bIsPrimitive){
+ if (bIsPrimitive){
+ sNodeDescription += m_oSourceCodeGenerator.getStringValueOfObject(oUnoReturnObject, _oUnoMethodNode.getTypeClass());
+ }
+ else{
+ Any aReturnObject = Any.complete(oUnoReturnObject);
+ String sShortClassName = m_oIntrospector.getShortClassName(aReturnObject.getType().getTypeName());
+ sNodeDescription += m_oSourceCodeGenerator.getVariableNameforUnoObject(sShortClassName);
+ }
+ if (m_oIntrospector.isArray(oUnoReturnObject)){
+ if (m_oIntrospector.isUnoTypeObject(oUnoReturnObject)){
+ oUnoNode = addUnoFacetteNode(_oUnoMethodNode, XUnoFacetteNode.SINTERFACEDESCRIPTION, _oUnoMethodNode.getUnoObject());
+ }
+ else if(m_oIntrospector.isUnoPropertyTypeObject(oUnoReturnObject)){
+ oUnoNode = addUnoFacetteNode(_oUnoMethodNode, XUnoFacetteNode.SPROPERTYINFODESCRIPTION, oUnoReturnObject);
+ }
+ else if(m_oIntrospector.isUnoPropertyValueTypeObject(oUnoReturnObject)){
+ oUnoNode = addUnoFacetteNode(_oUnoMethodNode, XUnoFacetteNode.SPROPERTYVALUEDESCRIPTION, oUnoReturnObject);
+ }
+ }
+ if (oUnoNode == null){
+ if (bHasParameters){
+ sNodeDescription += sParamValueDescription;
+ }
+ oUnoNode = addUnoNode(null, oUnoReturnObject, sNodeDescription);
+ if (bHasParameters){
+ oUnoNode.setParameterObjects(_oUnoMethodNode.getLastParameterObjects());
+ }
+ }
+ if (oUnoNode != null){
+ oUnoNode.setFoldable(!bIsPrimitive);
+ _oUnoMethodNode.setFoldable(false);
+ _oUnoMethodNode.addChildNode(oUnoNode);
+ m_xTreeControlProvider.nodeInserted(_oUnoMethodNode, oUnoNode, _oUnoMethodNode.getChildCount()-1);
+ }
+ }
+ else{
+ if (bIsPrimitive){
+ sNodeDescription = _oUnoMethodNode.getStandardMethodDescription() + "=" + UnoMethodNode.getDisplayValueOfPrimitiveType(oUnoReturnObject);
+ _oUnoMethodNode.setLabel(sNodeDescription);
+ m_xTreeControlProvider.nodeChanged(_oUnoMethodNode);
+ }
+ }
+ }
+ // ReturnObject of method node == null..
+ else{
+ if (!bHasParameters){
+ _oUnoMethodNode.setLabel(_oUnoMethodNode.getLabel() + " = null");
+ }
+ else{
+ _oUnoMethodNode.setLabel(_oUnoMethodNode.getXIdlMethod().getName() + sParamValueDescription + " = null");
+ }
+ m_xTreeControlProvider.nodeChanged(_oUnoMethodNode);
+ }
+ return oUnoReturnObject;
+ }catch(Exception exception ) {
+ return null;
+ }}
+
+
+ public void invokeSelectedMethodNode(){
+ XTreePathProvider xTreePathProvider = m_xTreeControlProvider.getSelectedPath();
+ XUnoNode oUnoNode = xTreePathProvider.getLastPathComponent();
+ if (oUnoNode instanceof XUnoMethodNode){
+ invoke((XUnoMethodNode) oUnoNode);
+ m_xTreeControlProvider.expandPath(xTreePathProvider);
+ }
+ }
+
+
+ public void addSourceCodeOfSelectedNode(){
+ XTreePathProvider oTreePathProvider = m_xTreeControlProvider.getSelectedPath();
+ XUnoNode oUnoNode = oTreePathProvider.getLastPathComponent();
+ if (oUnoNode instanceof XUnoMethodNode){
+ XUnoMethodNode oUnoMethodNode = (XUnoMethodNode) oUnoNode;
+ if (!oUnoMethodNode.isInvoked() && oUnoMethodNode.isInvokable()){
+ invoke(oUnoMethodNode);
+ }
+ }
+ String sSourceCode = m_oSourceCodeGenerator.addSourceCodeOfUnoObject(oTreePathProvider, true, true, true);
+ m_xTreeControlProvider.setSourceCode(sSourceCode);
+ }
+
+
+ public void convertCompleteSourceCode(int _nLanguage){
+ String sSourceCode = m_oSourceCodeGenerator.convertAllUnoObjects(_nLanguage);
+ m_xTreeControlProvider.setSourceCode(sSourceCode);
+ }
+
+ protected XUnoNode getSelectedNode(){
+ return m_xTreeControlProvider.getSelectedNode();
+ }
+
+
+ // add the object to the hashtable for a possible access in the tree
+ private XUnoFacetteNode addUnoFacetteNode(XUnoNode _oParentNode, String _sNodeDescription, Object _oUnoObject){
+ return m_xTreeControlProvider.addUnoFacetteNode( _oParentNode, _sNodeDescription, _oUnoObject);
+ }
+
+
+ private XUnoMethodNode addMethodNode(Object _objectElement, XIdlMethod _xIdlMethod){
+ return m_xTreeControlProvider.addMethodNode(_objectElement, _xIdlMethod);
+ }
+
+
+
+ public void addMethodsToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoParentObject, XIdlMethod[] _xIdlMethods){
+ if (this.m_oIntrospector.isValid(_xIdlMethods)){
+ for ( int n = 0; n < _xIdlMethods.length; n++ ) {
+ XIdlMethod xIdlMethod = _xIdlMethods[n];
+ if (!xIdlMethod.getDeclaringClass().getName().equals("com.sun.star.uno.XInterface")){
+ XUnoMethodNode oChildNode = addMethodNode(_oUnoParentObject, xIdlMethod);
+ if (oChildNode != null){
+ _oGrandParentNode.addChildNode(oChildNode);
+ }
+ }
+ }
+ }
+ }
+
+
+ private void addFacetteNodesToTreeNode(XUnoNode _oParentNode, Object _oUnoObject){
+ if (m_oIntrospector.hasMethods(_oUnoObject)){
+ XUnoFacetteNode oUnoFacetteNode = addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SMETHODDESCRIPTION, _oUnoObject);
+ }
+ if (m_oIntrospector.hasProperties(_oUnoObject)){
+ XUnoFacetteNode oUnoFacetteNode = addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SPROPERTYDESCRIPTION, _oUnoObject);
+ }
+ if (m_oIntrospector.hasInterfaces(_oUnoObject)){
+ XUnoFacetteNode oUnoFacetteNode = addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SINTERFACEDESCRIPTION, _oUnoObject);
+ }
+ if (m_oIntrospector.isContainer(_oUnoObject)){
+ XUnoFacetteNode oUnoFacetteNode = addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SCONTAINERDESCRIPTION, _oUnoObject);
+ }
+ if (m_oIntrospector.hasSupportedServices(_oUnoObject)){
+ XUnoFacetteNode oUnoFacetteNode = addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SSERVICEDESCRIPTION, _oUnoObject);
+ }
+ }
+
+
+ private void addInterfacesToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoParentObject, Type[] _aTypes) {
+ try {
+ if (_oUnoParentObject != null){
+ for ( int m = 0; m < _aTypes.length; m++ ) {
+ addUnoNode(_oGrandParentNode, _oUnoParentObject, _aTypes[m]);
+ }
+ }
+ }
+ catch( Exception exception ) {
+ exception.printStackTrace(System.out);
+ }}
+
+
+ // add all services for the given object to the tree under the node parent
+ private void addServicesToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoObject) {
+ try{
+ XServiceInfo xServiceInfo = ( XServiceInfo ) UnoRuntime.queryInterface( XServiceInfo.class, _oUnoObject );
+ if ( xServiceInfo != null ){
+ String[] sSupportedServiceNames = xServiceInfo.getSupportedServiceNames();
+ for ( int m = 0; m < sSupportedServiceNames.length; m++ ) {
+ String sServiceName = sSupportedServiceNames[m];
+ if (sServiceName.length() > 0){
+ XUnoNode oUnoNode = addUnoNode(_oGrandParentNode, _oUnoObject, sSupportedServiceNames[m]);
+ oUnoNode.setNodeType(XUnoNode.nSERVICE);
+ }
+ }
+ }
+ }
+ catch(Exception exception) {
+ exception.printStackTrace(System.out);
+ }}
+
+
+ private void addPropertiesAndInterfacesOfService(XUnoNode _oUnoServiceNode){
+ String sServiceName = _oUnoServiceNode.getClassName();
+ Object oUnoObject = _oUnoServiceNode.getUnoObject();
+ addInterfacesToTreeNode(_oUnoServiceNode, oUnoObject, m_oIntrospector.getInterfaces(oUnoObject, sServiceName));
+ addPropertiesToTreeNode(_oUnoServiceNode, oUnoObject, m_oIntrospector.getProperties(oUnoObject, sServiceName));
+ }
+
+
+ private void addPropertiesToTreeNode(XUnoNode _oParentNode, Object _oUnoParentObject, Property[] _aProperties) {
+ try {
+ if (_aProperties.length > 0){
+ for ( int n = 0; n < _aProperties.length; n++ ){
+ Property aProperty = _aProperties[n];
+ XIntrospectionAccess xIntrospectionAccess = m_oIntrospector.getXIntrospectionAccess(_oUnoParentObject);
+ XPropertySet xPropertySet = ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, xIntrospectionAccess.queryAdapter(new Type( XPropertySet.class)));
+ if (xPropertySet != null) {
+ if (xPropertySet.getPropertySetInfo().hasPropertyByName(aProperty.Name)){
+ Object objectElement = xPropertySet.getPropertyValue(aProperty.Name);
+ if (objectElement != null) {
+ XUnoNode oChildNode = m_xTreeControlProvider.addUnoPropertyNode(_oUnoParentObject, aProperty, objectElement);
+ if (oChildNode != null){
+ _oParentNode.addChildNode(oChildNode);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ catch(Exception exception) {
+ exception.printStackTrace(System.out);
+ }}
+
+
+ public void addContainerElementsToTreeNode(XUnoNode _oParentNode, Object _oUnoParentObject){
+ Object[] oUnoContainerElements = m_oIntrospector.getUnoObjectsOfContainer(_oUnoParentObject);
+ if (m_oIntrospector.isValid(oUnoContainerElements)){
+ if (oUnoContainerElements.length > 0){
+ for (int i=0; i< oUnoContainerElements.length; i++){
+ XUnoNode oChildNode = addUnoNode(_oParentNode, oUnoContainerElements[i], UnoNode.getNodeDescription(oUnoContainerElements[i]));
+ m_xTreeControlProvider.nodeInserted(_oParentNode, oChildNode, _oParentNode.getChildCount()-1);
+ }
+ }
+ }
+ }
+
+
+ private XUnoNode addUnoNode(XUnoNode _oParentNode, Object _oUnoObject, String _sLabel ){
+ XUnoNode oUnoNode = this.m_xTreeControlProvider.addUnoNode(_oUnoObject);
+ oUnoNode.setLabel(_sLabel);
+ if (_oParentNode != null){
+ _oParentNode.addChildNode(oUnoNode);
+ }
+ setNodeFoldable(oUnoNode, _oUnoObject);
+ return oUnoNode;
+ }
+
+
+ private void setNodeFoldable(XUnoNode _oUnoNode, Object _oUnoObject){
+ if (_oUnoObject != null){
+ if (!m_oIntrospector.isObjectPrimitive(_oUnoObject)){
+ _oUnoNode.setFoldable(true);
+ }
+ }
+ }
+
+
+ private XUnoNode addUnoNode(XUnoNode _oParentNode, Object _oUnoObject, Type _aType){
+ XUnoNode oUnoNode = this.m_xTreeControlProvider.addUnoNode(_oUnoObject, _aType);
+ if (_oParentNode != null){
+ _oParentNode.addChildNode(oUnoNode);
+ }
+ setNodeFoldable(oUnoNode, _oUnoObject);
+ return oUnoNode;
+ }
+
+
+ private void addPropertySetInfoNodesToTreeNode(XUnoFacetteNode _oUnoFacetteNode, Object _oUnoObject){
+ if (_oUnoObject.getClass().isArray()){
+ Object[] object = ( Object[] ) _oUnoObject;
+ for ( int i = 0; i < object.length; i++ ) {
+ Property aProperty = (Property) object[i];
+ XUnoPropertyNode oUnoPropertyNode = m_xTreeControlProvider.addUnoPropertyNode(_oUnoObject, aProperty);
+ oUnoPropertyNode.setLabel(XUnoFacetteNode.SPROPERTYINFODESCRIPTION + " (" + aProperty.Name + ")");
+ oUnoPropertyNode.setFoldable(true);
+ _oUnoFacetteNode.addChildNode(oUnoPropertyNode);
+ }
+ }
+ }
+
+ private void addPrimitiveValuesToTreeNode(XUnoNode _oUnoNode, Object _oUnoObject){
+ if (_oUnoObject.getClass().isArray()){
+ if (!_oUnoObject.getClass().getComponentType().isPrimitive()){
+ Object[] object = ( Object[] ) _oUnoObject;
+ for ( int i = 0; i < object.length; i++ ) {
+ if (m_oIntrospector.isObjectPrimitive(object[i])){
+ XUnoNode oChildNode = addUnoNode(_oUnoNode, null, UnoNode.getNodeDescription(object[i]));
+ }
+ }
+ }
+ else{
+ String[] sDisplayValues = UnoNode.getDisplayValuesofPrimitiveArray(_oUnoObject);
+ for ( int i = 0; i < sDisplayValues.length; i++ ) {
+ XUnoNode oUnoNode = addUnoNode(_oUnoNode, null, sDisplayValues[i]);
+ }
+ }
+ }
+ }
+
+
+ private void addPropertySetInfoSubNodes(XUnoPropertyNode _oUnoPropertyNode){
+ Property aProperty = _oUnoPropertyNode.getProperty();
+ _oUnoPropertyNode.addChildNode(m_xTreeControlProvider.addUnoPropertyNodeWithName(aProperty));
+ _oUnoPropertyNode.addChildNode(m_xTreeControlProvider.addUnoPropertyNodeWithType(aProperty));
+ _oUnoPropertyNode.addChildNode(m_xTreeControlProvider.addUnoPropertyNodeWithHandle(aProperty));
+ _oUnoPropertyNode.addChildNode(m_xTreeControlProvider.addUnoPropertyNodeWithAttributesDescription(aProperty));
+ }
+
+
+ private void addPropertyValueSubNodes(XUnoFacetteNode _oUnoFacetteNode, Object _oUnoObject){
+ if (m_oIntrospector.isUnoPropertyValueTypeObject(_oUnoObject)){
+ Object[] object = ( Object[] ) _oUnoObject;
+ for ( int i = 0; i < object.length; i++ ) {
+ String sObjectClassName = object[i].getClass().getName();
+ if (sObjectClassName.equals("com.sun.star.beans.PropertyValue")){
+ XUnoNode oChildNode = null;
+ PropertyValue aPropertyValue = (PropertyValue) object[i];
+ if (! m_oIntrospector.isObjectPrimitive(aPropertyValue.Value)){
+ oChildNode = m_xTreeControlProvider.addUnoPropertyNode(_oUnoObject, aPropertyValue, _oUnoObject);
+ }
+ else{
+ oChildNode = addUnoNode(null, aPropertyValue.Value, UnoPropertyNode.getStandardPropertyValueDescription(aPropertyValue));
+ }
+ if (oChildNode != null){
+ _oUnoFacetteNode.addChildNode(oChildNode);
+ }
+ }
+ }
+ }
+ }
+
+
+ public boolean expandNode(XUnoNode _oUnoNode, XTreePathProvider _xTreePathProvider){
+ if ( _oUnoNode != null ) {
+ _oUnoNode.setFoldable(false);
+ if (m_xTreeControlProvider.isMethodNode(_oUnoNode)){
+ XUnoMethodNode oUnoMethodNode = (XUnoMethodNode) _oUnoNode;
+ if (!oUnoMethodNode.isInvoked()){
+ Object oUnoReturnObject = invoke((XUnoMethodNode) _oUnoNode);
+ if (oUnoReturnObject == null){
+ _oUnoNode.setFoldable(true);
+ return false;
+ }
+ }
+ }
+ else if (m_xTreeControlProvider.isPropertyNode(_oUnoNode)){
+ XUnoPropertyNode oUnoPropertyNode = (XUnoPropertyNode) _oUnoNode;
+ Object oUnoObject = oUnoPropertyNode.getUnoReturnObject();
+ if (oUnoPropertyNode.getPropertyNodeType() == XUnoPropertyNode.nPROPERTYSETINFOTYPE){
+ addPropertySetInfoSubNodes(oUnoPropertyNode);
+ }
+ else{
+ //TOOD this code is redundant!!!
+ if ( oUnoObject.getClass().isArray()){
+ // TOODO probably we should provid a possibility to insert also non-primitive nodes
+ addPrimitiveValuesToTreeNode(oUnoPropertyNode, oUnoObject);
+ }
+ else{
+ addFacetteNodesToTreeNode(oUnoPropertyNode, oUnoObject);
+ }
+ }
+ }
+ else if (m_xTreeControlProvider.isFacetteNode(_oUnoNode)){
+ XUnoFacetteNode oUnoFacetteNode = (XUnoFacetteNode) _oUnoNode;
+ Object oUnoObject = _oUnoNode.getUnoObject();
+ if (oUnoFacetteNode.isMethodNode()){
+ addMethodsToTreeNode(oUnoFacetteNode, oUnoObject, m_oIntrospector.getMethods(oUnoObject));
+ }
+ if (oUnoFacetteNode.isPropertyNode()){
+ String sNodeDescription = oUnoFacetteNode.getLabel();
+ // TODO: it's very dangerous to distinguishe the different UnoFacetteNodes only by the nodedescription
+ if (sNodeDescription.startsWith(XUnoFacetteNode.SPROPERTYINFODESCRIPTION)){
+ addPropertySetInfoNodesToTreeNode(oUnoFacetteNode, oUnoObject);
+ }
+ else if (sNodeDescription.startsWith(XUnoFacetteNode.SPROPERTYVALUEDESCRIPTION)){
+ addPropertyValueSubNodes(oUnoFacetteNode, oUnoObject);
+ }
+ else{
+ addPropertiesToTreeNode(oUnoFacetteNode, oUnoObject, m_oIntrospector.getProperties(oUnoObject));
+ }
+ }
+ if (oUnoFacetteNode.isServiceNode()){
+ addServicesToTreeNode(oUnoFacetteNode, oUnoObject);
+ }
+ if (oUnoFacetteNode.isInterfaceNode()){
+ addInterfacesToTreeNode(oUnoFacetteNode, oUnoObject, getTypes(oUnoObject));
+ }
+ if (oUnoFacetteNode.isContainerNode()){
+ addContainerElementsToTreeNode(oUnoFacetteNode, oUnoObject);
+ }
+ }
+ else if (_oUnoNode.getNodeType() == XUnoNode.nSERVICE){
+ addPropertiesAndInterfacesOfService(_oUnoNode);
+ }
+ else if (_oUnoNode.getNodeType() == XUnoNode.nINTERFACE){
+ Type aType = _oUnoNode.getUnoType();
+ if (aType != null){
+ addMethodsToTreeNode(_oUnoNode, _oUnoNode.getUnoObject(), m_oIntrospector.getMethodsOfInterface(aType));
+ }
+ }
+ else if (_oUnoNode.getNodeType() == XUnoNode.nOTHERS){
+ Object oUnoObject = _oUnoNode.getUnoObject();
+ if ( oUnoObject.getClass().isArray()){
+ // TOODO probably we should provid a possibility to insert also non-primitive nodes
+ addPrimitiveValuesToTreeNode(_oUnoNode, oUnoObject);
+ }
+ else{
+ addFacetteNodesToTreeNode(_oUnoNode, oUnoObject);
+ }
+ }
+ }
+ return true;
+ }
+
+
+
+ public void applyFilter(XUnoFacetteNode _oUnoFacetteNode, String _sFilter){
+ for (int i = 0; i < _oUnoFacetteNode.getChildCount(); i++){
+ XUnoNode oUnoNode = _oUnoFacetteNode.getChild(i);
+ boolean bIsVisible = oUnoNode.isFilterApplicable(_sFilter);
+ m_xTreeControlProvider.setNodeVisible(oUnoNode, bIsVisible);
+ }
+ _oUnoFacetteNode.setFilter(_sFilter);
+ }
+
+
+ /** In opposition to 'getUnoObjectOfTreeNode' this method inspects the passed node if it represents a Uno object
+ * If not it returns null
+ *
+ */
+ private Object getUnoObjectOfExplicitTreeNode(XTreePathProvider _xTreePathProvider){
+ XUnoNode oUnoNode = _xTreePathProvider.getLastPathComponent();
+ if (oUnoNode != null){
+ return oUnoNode.getUnoObject();
+ }
+ return null;
+ }
+
+
+ public String getFilter(XUnoNode _oUnoNode){
+ String sFilter = "";
+ if (_oUnoNode != null){
+ XUnoNode oUnoNode = _oUnoNode;
+ boolean bleaveLoop = false;
+ do{
+ if (m_xTreeControlProvider.isFacetteNode(oUnoNode)){
+ sFilter = ((XUnoFacetteNode) oUnoNode).getFilter();
+ bleaveLoop = true;
+ }
+ else{
+ if (oUnoNode.getParentNode() != null){
+ oUnoNode = oUnoNode.getParentNode();
+ }
+ else{
+ bleaveLoop = true;
+ }
+ }
+ } while(!bleaveLoop);
+ }
+ return sFilter;
+ }
+
+
+ /** In opposition to 'getUnoObjectOfexplictTreeNode' this method inspects the passed node if it represents a Uno object
+ * if not it keeps checking all ancestors until it finds a Uno representation
+ */
+ private Object getUnoObjectOfTreeNode(XTreePathProvider _xTreePathProvider){
+ XTreePathProvider xTreePathProvider = _xTreePathProvider;
+ HideableMutableTreeNode oNode = null;
+ Object oUnoObject = null;
+ while (xTreePathProvider != null){
+ oUnoObject = getUnoObjectOfExplicitTreeNode(xTreePathProvider);
+ if (oUnoObject != null){
+ if (oUnoObject instanceof String){
+ }
+ else{
+ if (!m_oIntrospector.isUnoTypeObject(oUnoObject)){
+ return oUnoObject;
+ }
+ }
+ }
+ xTreePathProvider = xTreePathProvider.getParentPath();
+ }
+ return null;
+ }
+
+
+ public void showPopUpMenu(Object _invoker, int x, int y) throws ClassCastException{
+ XUnoNode oUnoNode = getSelectedNode();
+ boolean bdoEnableInvoke = oUnoNode instanceof XUnoMethodNode;
+// boolean bdoEnableSourceCodeGeneration = true;
+ if (bdoEnableInvoke){
+ XUnoMethodNode oUnoMethodNode = (XUnoMethodNode) oUnoNode;
+ bdoEnableInvoke = oUnoMethodNode.isInvokable();
+// bdoEnableSourceCodeGeneration = bdoEnableInvoke;
+ }
+ m_xDialogProvider.enablePopupMenuItem(XDialogProvider.SINVOKE, bdoEnableInvoke);
+// m_xDialogProvider.enablePopupMenuItem(XDialogProvider.SADDTOSOURCECODE, bdoEnableSourceCodeGeneration);
+ m_xDialogProvider.showPopUpMenu(_invoker, x, y);
+ }
+}
+ \ No newline at end of file
diff --git a/odk/examples/java/Inspector/InstanceInspector.idl b/odk/examples/java/Inspector/InstanceInspector.idl
new file mode 100644
index 000000000000..79e43cb181e4
--- /dev/null
+++ b/odk/examples/java/Inspector/InstanceInspector.idl
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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_ORG_OPENOFFICE_INSTANCEINSPECTOR_IDL
+#define INCLUDED_ORG_OPENOFFICE_INSTANCEINSPECTOR_IDL
+
+#include <XInstanceInspector.idl>
+
+
+module org { module openoffice {
+
+ /**
+ * This service describes an instance inspector which can inspect
+ * UNO objects and provides information about the implemented
+ * interfaces, the supported services and properties of this onject.
+ */
+ service InstanceInspector: XInstanceInspector;
+
+}; };
+
+#endif
diff --git a/odk/examples/java/Inspector/InstanceInspectorTest.odt b/odk/examples/java/Inspector/InstanceInspectorTest.odt
new file mode 100644
index 000000000000..74cde4e68e21
--- /dev/null
+++ b/odk/examples/java/Inspector/InstanceInspectorTest.odt
Binary files differ
diff --git a/odk/examples/java/Inspector/Introspector.java b/odk/examples/java/Inspector/Introspector.java
new file mode 100644
index 000000000000..f4078931e1ed
--- /dev/null
+++ b/odk/examples/java/Inspector/Introspector.java
@@ -0,0 +1,667 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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.IllegalTypeException;
+import com.sun.star.beans.MethodConcept;
+import com.sun.star.beans.NamedValue;
+import com.sun.star.beans.Property;
+import com.sun.star.beans.XIntrospection;
+import com.sun.star.beans.XIntrospectionAccess;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.bridge.UnoUrlResolver;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.comp.helper.Bootstrap;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XEnumerationAccess;
+import com.sun.star.container.XHierarchicalNameAccess;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.reflection.ParamInfo;
+import com.sun.star.reflection.TypeDescriptionSearchDepth;
+import com.sun.star.reflection.XConstantTypeDescription;
+import com.sun.star.reflection.XConstantsTypeDescription;
+import com.sun.star.reflection.XIdlClass;
+import com.sun.star.reflection.XIdlField;
+import com.sun.star.reflection.XIdlMethod;
+import com.sun.star.reflection.XIdlReflection;
+import com.sun.star.reflection.XIndirectTypeDescription;
+import com.sun.star.reflection.XInterfaceTypeDescription;
+import com.sun.star.reflection.XInterfaceTypeDescription2;
+import com.sun.star.reflection.XPropertyTypeDescription;
+import com.sun.star.reflection.XServiceTypeDescription;
+import com.sun.star.reflection.XTypeDescription;
+import com.sun.star.reflection.XTypeDescriptionEnumeration;
+import com.sun.star.reflection.XTypeDescriptionEnumerationAccess;
+import com.sun.star.ucb.CommandAbortedException;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.TypeClass;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.util.URL;
+import java.util.List;
+import java.util.Vector;
+import javax.swing.JOptionPane;
+
+public class Introspector extends WeakBase{
+
+ private XIntrospection m_xIntrospection;
+ private XMultiComponentFactory m_xMultiComponentFactory;
+ private XComponentContext m_xComponentContext;
+ private XTypeDescriptionEnumerationAccess m_xTDEnumerationAccess;
+ private static XComponentContext xOfficeComponentContext;
+ private XIdlReflection mxIdlReflection;
+ private URL openHyperlink;
+ private static Introspector m_oIntrospector = null;
+ private XSimpleFileAccess xSimpleFileAccess = null;
+
+
+
+ public static Introspector getIntrospector(){
+ if (m_oIntrospector == null){
+ throw new NullPointerException();
+ }
+ else{
+ return m_oIntrospector;
+ }
+ }
+
+ public static Introspector getIntrospector(XComponentContext _xComponentContext){
+ if (m_oIntrospector == null){
+ m_oIntrospector = new Introspector(_xComponentContext);
+ }
+ return m_oIntrospector;
+ }
+
+
+ /** Creates a new instance of Introspection */
+ private Introspector(XComponentContext _xComponentContext) {
+ try{
+ m_xComponentContext = _xComponentContext;
+ m_xMultiComponentFactory = m_xComponentContext.getServiceManager();
+ Object o = m_xMultiComponentFactory.createInstanceWithContext("com.sun.star.beans.Introspection", m_xComponentContext);
+ m_xIntrospection = ( XIntrospection ) UnoRuntime.queryInterface(XIntrospection.class, o );
+ Object oCoreReflection = getXMultiComponentFactory().createInstanceWithContext("com.sun.star.reflection.CoreReflection", getXComponentContext());
+ mxIdlReflection = (XIdlReflection) UnoRuntime.queryInterface(XIdlReflection.class, oCoreReflection);
+ initTypeDescriptionManager();
+ }
+ catch( Exception exception ) {
+ System.err.println( exception );
+ }}
+
+
+ protected XComponentContext getXComponentContext(){
+ return m_xComponentContext;
+ }
+
+
+ protected XMultiComponentFactory getXMultiComponentFactory(){
+ return m_xMultiComponentFactory;
+ }
+
+
+ protected XIntrospectionAccess getXIntrospectionAccess(Object _oUnoComponent){
+ return m_xIntrospection.inspect(_oUnoComponent);
+ }
+
+
+ public boolean isContainer(Object _oUnoObject){
+ boolean bIsContainer = false;
+ try {
+ XIntrospectionAccess xIntrospectionAccessObject = getXIntrospectionAccess(_oUnoObject);
+ if (xIntrospectionAccessObject != null){
+ XEnumerationAccess xEnumerationAccess = (XEnumerationAccess) UnoRuntime.queryInterface(XEnumerationAccess.class, xIntrospectionAccessObject.queryAdapter( new Type( XEnumerationAccess.class ) ) );
+ if (xEnumerationAccess != null){
+ XEnumeration xEnumeration = xEnumerationAccess.createEnumeration();
+ bIsContainer = xEnumeration.hasMoreElements();
+ }
+ if (!bIsContainer){
+ XIndexAccess xIndexAccess = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, xIntrospectionAccessObject.queryAdapter(new Type( XIndexAccess.class )));
+ if (xIndexAccess != null){
+ bIsContainer = (xIndexAccess.getCount() > 0);
+ }
+ }
+ }
+ } catch (IllegalTypeException ex) {
+ ex.printStackTrace(System.out);
+ }
+ return bIsContainer;
+ }
+
+
+ // add all containers for the given object to the tree under the node
+ // parent
+ public Object[] getUnoObjectsOfContainer(Object _oUnoParentObject) {
+ Object[] oRetComponents = null;
+ try {
+ Vector oRetComponentsVector = new Vector();
+ XIntrospectionAccess xIntrospectionAccessObject = getXIntrospectionAccess(_oUnoParentObject);
+ if ( xIntrospectionAccessObject != null ) {
+ XEnumerationAccess xEnumerationAccess = (XEnumerationAccess) UnoRuntime.queryInterface(XEnumerationAccess.class, xIntrospectionAccessObject.queryAdapter( new Type( XEnumerationAccess.class ) ) );
+ if ( xEnumerationAccess != null ) {
+ XEnumeration xEnumeration = xEnumerationAccess.createEnumeration();
+ while ( xEnumeration.hasMoreElements() ) {
+ oRetComponentsVector.add(xEnumeration.nextElement());
+ }
+ }
+ XIndexAccess xIndexAccess = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, xIntrospectionAccessObject.queryAdapter(new Type( XIndexAccess.class )));
+ if ( xIndexAccess != null ) {
+ XIdlMethod mMethod = xIntrospectionAccessObject.getMethod("getByIndex", com.sun.star.beans.MethodConcept.INDEXCONTAINER);
+ for ( int i = 0; i < xIndexAccess.getCount(); i++ ) {
+ Object[][] aParamInfo = new Object[1][1];
+ aParamInfo[0] = new Integer[] { new Integer(i) };
+ oRetComponentsVector.add(mMethod.invoke(_oUnoParentObject, aParamInfo));
+ }
+ }
+ }
+ if (oRetComponentsVector != null){
+ oRetComponents = new Object[oRetComponentsVector.size()];
+ oRetComponentsVector.toArray(oRetComponents);
+ }
+ }
+ catch( Exception exception ) {
+ System.err.println( exception );
+ }
+ return oRetComponents;
+ }
+
+
+ protected XIdlMethod[] getMethodsOfInterface(Type _aType){
+ try{
+ XIdlClass xIdlClass = mxIdlReflection.forName(_aType.getTypeName());
+ return xIdlClass.getMethods();
+ }
+ catch( Exception e ) {
+ System.err.println( e );
+ return null;
+ }}
+
+
+ protected XIdlField[] getFieldsOfType(Type _aType){
+ try{
+ XIdlClass xIdlClass = mxIdlReflection.forName(_aType.getTypeName());
+ return xIdlClass.getFields();
+ }
+ catch( Exception e ) {
+ System.err.println( e );
+ return null;
+ }}
+
+
+ public boolean hasMethods(Object _oUnoObject){
+ boolean bHasMethods = (getMethods(_oUnoObject).length > 0);
+ return bHasMethods;
+ }
+
+
+ // add all methods for the given object to the tree under the node parent
+ public XIdlMethod[] getMethods(Object _oUnoParentObject) {
+ try {
+ XIntrospectionAccess xIntrospectionAccess = getXIntrospectionAccess(_oUnoParentObject);
+ if (xIntrospectionAccess != null){
+ XIdlMethod[] xIdlMethods = xIntrospectionAccess.getMethods(MethodConcept.ALL - MethodConcept.DANGEROUS);
+ return xIdlMethods;
+ }
+ }
+ catch( Exception e ) {
+ System.err.println( e );
+ }
+ return null;
+ }
+
+
+ public boolean hasProperties(Object _oUnoObject){
+ boolean bHasProperties = (getProperties(_oUnoObject).length > 0);
+ return bHasProperties;
+ }
+
+
+ protected Property[] getProperties( Object _oUnoParentObject){
+ try {
+ XIntrospectionAccess xIntrospectionAccess = getXIntrospectionAccess(_oUnoParentObject);
+ if (xIntrospectionAccess != null){
+ Property[] aProperties = xIntrospectionAccess.getProperties(com.sun.star.beans.PropertyConcept.ATTRIBUTES + com.sun.star.beans.PropertyConcept.PROPERTYSET);
+ return aProperties;
+ }
+ }
+ catch( Exception e ) {
+ System.err.println( e );
+ }
+ return null;
+ }
+
+
+ protected Property[] getProperties(Object _oUnoObject, String _sServiceName){
+ Property[] aProperties = getProperties(_oUnoObject);
+ List aListOfProperties = java.util.Arrays.asList(aProperties);
+ Vector aPropertiesVector = new Vector(aListOfProperties);
+ if (aProperties != null){
+ XPropertyTypeDescription[] xPropertyTypeDescriptions = getPropertyDescriptionsOfService(_sServiceName);
+ for (int i = aProperties.length - 1; i >= 0; i--){
+ if (!hasByName(xPropertyTypeDescriptions, _sServiceName + "." + aProperties[i].Name)){
+ aPropertiesVector.remove(i);
+ }
+ }
+ }
+ Property[] aRetProperties = new Property[aPropertiesVector.size()];
+ aPropertiesVector.toArray(aRetProperties);
+ return aRetProperties;
+ }
+
+
+ protected Type[] getInterfaces(Object _oUnoObject, String _sServiceName){
+ Type[] aTypes = getInterfaces(_oUnoObject);
+ List aListOfTypes = java.util.Arrays.asList(aTypes);
+ Vector aTypesVector = new Vector(aListOfTypes);
+ if (aTypes != null){
+ XInterfaceTypeDescription[] xInterfaceTypeDescriptions = getInterfaceDescriptionsOfService(_sServiceName);
+ for (int i = aTypes.length - 1; i >= 0; i--){
+ if (!hasByName(xInterfaceTypeDescriptions, aTypes[i].getTypeName())){
+ aTypesVector.remove(i);
+ }
+ }
+ }
+ Type[] aRetTypes = new Type[aTypesVector.size()];
+ aTypesVector.toArray(aRetTypes);
+ return aRetTypes;
+ }
+
+
+ public boolean hasInterfaces(Object _oUnoObject){
+ return (getInterfaces(_oUnoObject).length > 0);
+ }
+
+
+ protected Type[] getInterfaces(Object _oUnoParentObject){
+ Type[] aTypes = new Type[]{};
+ XTypeProvider xTypeProvider = ( XTypeProvider ) UnoRuntime.queryInterface( XTypeProvider.class, _oUnoParentObject);
+ if ( xTypeProvider != null ) {
+ aTypes = xTypeProvider.getTypes();
+ }
+ return aTypes;
+ }
+
+
+
+ public static boolean isObjectSequence(Object _oUnoObject){
+ Type aType = AnyConverter.getType(_oUnoObject);
+ return aType.getTypeClass().getValue() == TypeClass.SEQUENCE_value;
+ }
+
+
+ public static boolean isObjectPrimitive(Object _oUnoObject){
+ boolean breturn = false;
+ if (_oUnoObject != null){
+ Type aType = AnyConverter.getType(_oUnoObject);
+ breturn = isObjectPrimitive(_oUnoObject.getClass(), aType.getTypeClass());
+ }
+ return breturn;
+ }
+
+
+ public static boolean isPrimitive(TypeClass _typeClass){
+ return (( _typeClass == TypeClass.BOOLEAN )
+ || ( _typeClass == TypeClass.BYTE )
+ || ( _typeClass == TypeClass.CHAR )
+ || ( _typeClass == TypeClass.DOUBLE )
+ || ( _typeClass == TypeClass.ENUM )
+ || ( _typeClass == TypeClass.FLOAT )
+ || ( _typeClass == TypeClass.HYPER )
+ || ( _typeClass == TypeClass.LONG )
+ || ( _typeClass == TypeClass.SHORT )
+ || ( _typeClass == TypeClass.STRING )
+ || ( _typeClass == TypeClass.UNSIGNED_HYPER )
+ || ( _typeClass == TypeClass.UNSIGNED_LONG )
+ || ( _typeClass == TypeClass.UNSIGNED_SHORT ));
+ }
+
+ public static boolean isObjectPrimitive(Class _oUnoClass, TypeClass _typeClass){
+ return !( ( !_oUnoClass.isPrimitive() ) && ( _typeClass != TypeClass.ARRAY )
+ && ( _typeClass != TypeClass.BOOLEAN )
+ && ( _typeClass != TypeClass.BYTE )
+ && ( _typeClass != TypeClass.CHAR )
+ && ( _typeClass != TypeClass.DOUBLE )
+ && ( _typeClass != TypeClass.ENUM )
+ && ( _typeClass != TypeClass.FLOAT )
+ && ( _typeClass != TypeClass.HYPER )
+ && ( _typeClass != TypeClass.LONG )
+ && ( _typeClass != TypeClass.SHORT )
+ && ( _typeClass != TypeClass.STRING )
+ && ( _typeClass != TypeClass.UNSIGNED_HYPER )
+ && ( _typeClass != TypeClass.UNSIGNED_LONG )
+ && ( _typeClass != TypeClass.UNSIGNED_SHORT ));
+ }
+
+
+ protected void initTypeDescriptionManager() {
+ try {
+ Object oTypeDescriptionManager = getXComponentContext().getValueByName("/singletons/com.sun.star.reflection.theTypeDescriptionManager");
+ m_xTDEnumerationAccess = (XTypeDescriptionEnumerationAccess) UnoRuntime.queryInterface(XTypeDescriptionEnumerationAccess.class, oTypeDescriptionManager);
+ } catch ( java.lang.Exception e) {
+ System.out.println(System.out);
+ }}
+
+
+ protected XTypeDescriptionEnumerationAccess getXTypeDescriptionEnumerationAccess(){
+ return m_xTDEnumerationAccess;
+ }
+
+
+ protected XConstantTypeDescription[] getFieldsOfConstantGroup(String _sTypeClass){
+ XConstantTypeDescription[] xConstantTypeDescriptions = null;
+ try {
+ TypeClass[] eTypeClasses = new com.sun.star.uno.TypeClass[1];
+ eTypeClasses[0] = com.sun.star.uno.TypeClass.CONSTANTS;
+ XTypeDescriptionEnumeration xTDEnumeration = m_xTDEnumerationAccess.createTypeDescriptionEnumeration(getModuleName(_sTypeClass), eTypeClasses, TypeDescriptionSearchDepth.INFINITE);
+ while (xTDEnumeration.hasMoreElements()) {
+ XTypeDescription xTD = xTDEnumeration.nextTypeDescription();
+ if (xTD.getName().equals(_sTypeClass)){
+ XConstantsTypeDescription xConstantsTypeDescription = (XConstantsTypeDescription) UnoRuntime.queryInterface(XConstantsTypeDescription.class, xTD);
+ xConstantTypeDescriptions = xConstantsTypeDescription.getConstants();
+ }
+ String sName = xTD.getName();
+ }
+ return xConstantTypeDescriptions;
+ } catch ( java.lang.Exception e) {
+ System.out.println(System.out);
+ }
+ return null;
+ }
+
+ private XServiceTypeDescription getServiceTypeDescription(String _sServiceName, TypeClass _eTypeClass){
+ try{
+ if (_sServiceName.length() > 0){
+ TypeClass[] eTypeClasses = new com.sun.star.uno.TypeClass[2];
+ eTypeClasses[0] = com.sun.star.uno.TypeClass.SERVICE;
+ eTypeClasses[1] = _eTypeClass;
+ XTypeDescriptionEnumeration xTDEnumeration = getXTypeDescriptionEnumerationAccess().createTypeDescriptionEnumeration(Introspector.getModuleName(_sServiceName), eTypeClasses, TypeDescriptionSearchDepth.INFINITE);
+ while (xTDEnumeration.hasMoreElements()) {
+ XTypeDescription xTD = xTDEnumeration.nextTypeDescription();
+ if (xTD.getName().equals(_sServiceName)){
+ XServiceTypeDescription xServiceTypeDescription = (XServiceTypeDescription) UnoRuntime.queryInterface(XServiceTypeDescription.class, xTD);
+ return xServiceTypeDescription;
+ }
+ }
+ }
+ return null;
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ return null;
+ }}
+
+
+ public XPropertyTypeDescription[] getPropertyDescriptionsOfService(String _sServiceName){
+ try {
+ XServiceTypeDescription xServiceTypeDescription = getServiceTypeDescription(_sServiceName, com.sun.star.uno.TypeClass.PROPERTY);
+ if (xServiceTypeDescription != null){
+ XPropertyTypeDescription[] xPropertyTypeDescriptions = xServiceTypeDescription.getProperties();
+ return xPropertyTypeDescriptions;
+ }
+ } catch ( java.lang.Exception e) {
+ System.out.println(System.out);
+ }
+ return new XPropertyTypeDescription[]{};
+ }
+
+
+ public XTypeDescription getReferencedType(String _sTypeName){
+ XTypeDescription xTypeDescription = null;
+ try{
+ XHierarchicalNameAccess xHierarchicalNameAccess = (XHierarchicalNameAccess) UnoRuntime.queryInterface(XHierarchicalNameAccess.class, m_xTDEnumerationAccess);
+ if (xHierarchicalNameAccess != null){
+ if (xHierarchicalNameAccess.hasByHierarchicalName(_sTypeName)){
+ XIndirectTypeDescription xIndirectTypeDescription = (XIndirectTypeDescription) UnoRuntime.queryInterface(XIndirectTypeDescription.class, xHierarchicalNameAccess.getByHierarchicalName(_sTypeName));
+ if (xIndirectTypeDescription != null){
+ xTypeDescription = xIndirectTypeDescription.getReferencedType();
+ }
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ }
+ return xTypeDescription;
+ }
+
+
+ public XInterfaceTypeDescription[] getInterfaceDescriptionsOfService(String _sServiceName){
+ try {
+ XServiceTypeDescription xServiceTypeDescription = getServiceTypeDescription(_sServiceName, com.sun.star.uno.TypeClass.INTERFACE);
+ if (xServiceTypeDescription != null){
+ XInterfaceTypeDescription[] xInterfaceTypeDescriptions = xServiceTypeDescription.getMandatoryInterfaces();
+ return xInterfaceTypeDescriptions;
+ }
+ } catch ( java.lang.Exception e) {
+ System.out.println(System.out);
+ }
+ return new XInterfaceTypeDescription[]{};
+ }
+
+
+ static boolean hasByName(XTypeDescription[] _xTypeDescriptions, String _sTypeName){
+ for (int i = 0; i < _xTypeDescriptions.length; i++){
+ if (_xTypeDescriptions[i].getName().equals(_sTypeName)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public static String getModuleName(String _sTypeClass){
+ int nlastindex = _sTypeClass.lastIndexOf(".");
+ if (nlastindex > -1){
+ return _sTypeClass.substring(0, nlastindex);
+ }
+ else{
+ return "";
+ }
+ }
+
+
+ public static String getShortClassName(String _sClassName){
+ String sShortClassName = _sClassName;
+ int nindex = _sClassName.lastIndexOf(".");
+ if ((nindex < _sClassName.length()) && nindex > -1){
+ sShortClassName = _sClassName.substring(nindex + 1);
+ }
+ return sShortClassName;
+ }
+
+
+
+ public static boolean isUnoTypeObject(Object _oUnoObject){
+ return isOfUnoType(_oUnoObject, "com.sun.star.uno.Type");
+ }
+
+
+ public static boolean isUnoPropertyTypeObject(Object _oUnoObject){
+ return isOfUnoType(_oUnoObject, "com.sun.star.beans.Property");
+ }
+
+
+ public static boolean isUnoPropertyValueTypeObject(Object _oUnoObject){
+ return isOfUnoType(_oUnoObject, "com.sun.star.beans.PropertyValue");
+ }
+
+
+ public static boolean isOfUnoType(Object _oUnoObject, String _sTypeName){
+ boolean bIsUnoObject = false;
+ if (_oUnoObject != null){
+ if (_oUnoObject.getClass().isArray()){
+ if (!_oUnoObject.getClass().getComponentType().isPrimitive()){
+ Object[] oUnoArray = (Object[]) _oUnoObject;
+ if (oUnoArray.length > 0){
+ bIsUnoObject = ( oUnoArray[0].getClass().getName().equals(_sTypeName));
+ }
+ }
+ }
+ }
+ else{
+ bIsUnoObject = (_oUnoObject.getClass().getName().equals(_sTypeName));
+ }
+ return bIsUnoObject;
+ }
+
+
+ public String getConstantDisplayString(int _nValue, XConstantTypeDescription[] _xConstantTypeDescription, String _sDisplayString){
+ String sPrefix = "";
+ int[] nbits = new int[_xConstantTypeDescription.length];
+ for (int i = 0; i < _xConstantTypeDescription.length; i++){
+ short nConstantValue = ((Short) _xConstantTypeDescription[i].getConstantValue()).shortValue();
+ nbits[i] = _nValue & nConstantValue;
+ if (nbits[i] > 0){
+ _sDisplayString += sPrefix + _xConstantTypeDescription[i].getName();
+ sPrefix = " + ";
+ }
+ }
+ return _sDisplayString;
+ }
+
+
+ public static boolean isValid(Object[] _oObject){
+ if (_oObject != null){
+ if (_oObject.length > 0){
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public static boolean isValid(Object _oObject){
+ if (_oObject != null){
+ return (!AnyConverter.isVoid(_oObject));
+ }
+ return false;
+ }
+
+
+ public static boolean isArray(Object _oObject){
+ return _oObject.getClass().isArray();
+ }
+
+
+ public boolean hasSupportedServices(Object _oUnoObject){
+ boolean bHasSupportedServices = false;
+ XServiceInfo xServiceInfo = ( XServiceInfo ) UnoRuntime.queryInterface( XServiceInfo.class, _oUnoObject);
+ if ( xServiceInfo != null ){
+ String[] sSupportedServiceNames = xServiceInfo.getSupportedServiceNames();
+ bHasSupportedServices = sSupportedServiceNames.length > 0;
+ }
+ return bHasSupportedServices;
+ }
+
+
+ public Object getValueOfText(TypeClass aTypeClass, String sText){
+ Object oReturn = null;
+ switch (aTypeClass.getValue()){
+ case TypeClass.CHAR_value:
+ break;
+ case TypeClass.DOUBLE_value:
+ oReturn = Double.valueOf(sText);
+ break;
+ case TypeClass.ENUM_value:
+ break;
+ case TypeClass.FLOAT_value:
+ oReturn = Float.valueOf(sText);
+ break;
+ case TypeClass.HYPER_value:
+ oReturn = Long.valueOf(sText);
+ break;
+ case TypeClass.LONG_value:
+ oReturn = Integer.valueOf(sText);
+ break;
+ case TypeClass.SHORT_value:
+ oReturn = Byte.valueOf(sText);
+ break;
+ case TypeClass.STRING_value:
+ oReturn = sText;
+ break;
+ case TypeClass.UNSIGNED_HYPER_value:
+ oReturn = Long.valueOf(sText);
+ break;
+ case TypeClass.UNSIGNED_LONG_value:
+ oReturn = Integer.valueOf(sText);
+ break;
+ case TypeClass.UNSIGNED_SHORT_value:
+ oReturn = Byte.valueOf(sText);
+ break;
+ default:
+ }
+ return oReturn;
+ }
+
+
+ public XSimpleFileAccess getXSimpleFileAccess(){
+ try {
+ if (xSimpleFileAccess == null){
+ Object oSimpleFileAccess = m_xComponentContext.getServiceManager().createInstanceWithContext("com.sun.star.ucb.SimpleFileAccess", m_xComponentContext);
+ xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, oSimpleFileAccess);
+ }
+ return xSimpleFileAccess;
+ } catch (com.sun.star.uno.Exception ex) {
+ ex.printStackTrace(System.out);
+ return null;
+ }}
+
+
+ public boolean isValidSDKInstallationPath(String _sSDKInstallationPath){
+ boolean bIsValid = false;
+ try {
+ String sIDLFolder = Introspector.addToPath(_sSDKInstallationPath, Inspector.sIDLDOCUMENTSUBFOLDER);
+ String sIndexFile = Introspector.addToPath(_sSDKInstallationPath, "index.html");
+ if (getXSimpleFileAccess() != null){
+ bIsValid = (getXSimpleFileAccess().exists(sIDLFolder) && getXSimpleFileAccess().exists(sIndexFile));
+ }
+ } catch (com.sun.star.uno.Exception ex) {
+ ex.printStackTrace(System.out);
+ }
+ return bIsValid;
+ }
+
+
+ public static String addToPath(String _sPath, String _sSubPath){
+ if (!_sPath.endsWith("/")){
+ _sPath += "/";
+ }
+ return _sPath + _sSubPath;
+ }
+
+}
diff --git a/odk/examples/java/Inspector/Makefile b/odk/examples/java/Inspector/Makefile
new file mode 100644
index 000000000000..2b0c1b376c48
--- /dev/null
+++ b/odk/examples/java/Inspector/Makefile
@@ -0,0 +1,195 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (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 InstanceInspector 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=InstanceInspector
+SAMPLE_CLASS_OUT=$(OUT_CLASS)/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME)
+
+# some special macro names for separating the component jar stuff
+COMP_NAME=Inspector
+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 = InstanceInspector.idl \
+ XInstanceInspector.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 = XDialogProvider.java XTreeControlProvider.java XTreePathProvider.java MethodParametersDialog.java HideableMutableTreeNode.java HideableTreeModel.java Introspector.java XUnoNode.java SwingUnoNode.java UnoNode.java XUnoMethodNode.java SwingUnoMethodNode.java UnoMethodNode.java XUnoPropertyNode.java SwingUnoPropertyNode.java UnoPropertyNode.java XUnoFacetteNode.java SwingUnoFacetteNode.java TDocSupplier.java UnoTreeRenderer.java InspectorAddon.java XLanguageSourceCodeGenerator.java SourceCodeGenerator.java InspectorPane.java SwingDialogProvider.java SwingTreeControlProvider.java SwingTreePathProvider.java Inspector.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 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))
+
+COMP_IMAGE_FILES= images/containers_16.png \
+ images/content_16.png \
+ images/interfaces_16.png \
+ images/methods_16.png \
+ images/properties_16.png \
+ images/services_16.png
+
+# Targets
+.PHONY: ALL
+ALL : JavaInspectorExample
+
+include $(SETTINGS)/stdtarget.mk
+
+# rule for component manifest file
+$(COMP_GEN_OUT)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo RegistrationClassName: $(basename $(basename $(@F)))> $@
+
+# rule for compiling the IDL files
+$(SAMPLE_GEN_OUT)/%.urd : %.idl
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(IDLC) -C -I. -I$(IDL_DIR) -O$(SAMPLE_GEN_OUT) $<
+
+# rule for creating the component rdb file
+$(COMP_GEN_OUT)/%.rdb : $(GEN_URDFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(REGMERGE) $@ /UCR $(GEN_URDFILES)
+
+# rule for creating IDL dependent class files
+$(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)" -sourcepath . -d $(COMP_CLASS_OUT) $<
+
+# rule for component jar file
+$(COMP_JAR) : $(COMP_JAR_MANIFEST) $(COMP_CLASSFILES) $(COMP_IMAGE_FILES)
+ -$(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)
+ +$(SDK_JAR) uvf $@ $(COMP_IMAGE_FILES)
+
+# 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.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.configuration-schema$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)ObjectInspector.xcs$(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)ObjectInspector.xcu$(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) Addons.xcu ProtocolHandler.xcu ObjectInspector.xcu ObjectInspector.xcs $(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)
+ $(SDK_ZIP) -u $@ Addons.xcu ProtocolHandler.xcu ObjectInspector.xcu ObjectInspector.xcs
+ 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
+
+JavaInspectorExample : $(COMP_REGISTERFLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The InstanceInspector component was installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo You can use this component inside your office installation, see the example
+ @echo document.
+ @echo -
+ @echo $(MAKE) InstanceInspectorTest.odt.load
+ @echo --------------------------------------------------------------------------------
+
+InstanceInspectorTest.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/java/Inspector/MethodParametersDialog.java b/odk/examples/java/Inspector/MethodParametersDialog.java
new file mode 100644
index 000000000000..a2ebf7e66c41
--- /dev/null
+++ b/odk/examples/java/Inspector/MethodParametersDialog.java
@@ -0,0 +1,353 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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.reflection.ParamInfo;
+import com.sun.star.reflection.XIdlMethod;
+import com.sun.star.uno.TypeClass;
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.Vector;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+/**
+ * @author bc93774
+ */
+public class MethodParametersDialog extends JDialog{
+ private javax.swing.JPanel jPnlParamContainer;
+ private ParameterPanel[] m_aParameterPanels;
+ private ParamInfo[] m_aParamInfo;
+ private XIdlMethod m_xIdlMethod;
+ private ActionListener oActionListener;
+ private JButton jHelpButton = new JButton("Help");
+ private JButton jOKButton = new JButton("Ok");
+ private JButton jInvokeButton = new JButton("Invoke");
+ private Object m_oReturnButton = null;
+ private Object m_oUnoObject = null;
+ private Object m_oUnoReturnObject = null;
+ private JLabel jLblResult;
+ private JPanel jResultPanel = null;
+ private boolean bisdiposed = false;
+ private XUnoMethodNode m_xUnoMethodNode;
+
+
+ public MethodParametersDialog(XUnoMethodNode _xUnoMethodNode){
+ m_xUnoMethodNode = _xUnoMethodNode;
+ m_xIdlMethod = _xUnoMethodNode.getXIdlMethod();
+ m_aParamInfo = m_xIdlMethod.getParameterInfos();
+ m_oUnoObject = m_xUnoMethodNode.getUnoObject();
+ Object[] m_aParameterObjects = new Object[m_aParamInfo.length];
+ }
+
+
+ public Vector getMethodObjects() {
+ super.setModal(true);
+ addBorderPanel(getContentPane(), BorderLayout.NORTH);
+ addBorderPanel(getContentPane(), BorderLayout.WEST);
+ addBorderPanel(getContentPane(), BorderLayout.EAST);
+ jPnlParamContainer = new JPanel();
+ jPnlParamContainer.setLayout(new javax.swing.BoxLayout(jPnlParamContainer, javax.swing.BoxLayout.Y_AXIS));
+ JPanel jHeaderPanel = new JPanel(new BorderLayout());
+ JLabel jLblHeader = new JLabel();
+ jLblHeader.setText("Please insert the values for the given Parameters of the method '" + m_xIdlMethod.getName() + "'");
+ jHeaderPanel.add(jLblHeader,BorderLayout.WEST);
+ jPnlParamContainer.add(jHeaderPanel);
+
+ m_aParameterPanels = new ParameterPanel[m_aParamInfo.length];
+ for (int i = 0; i < m_aParameterPanels.length; i++){
+ m_aParameterPanels[i] = new ParameterPanel(m_aParamInfo[i]);
+ jPnlParamContainer.add(m_aParameterPanels[i]);
+ }
+ jPnlParamContainer.add(new ButtonPanel(), java.awt.BorderLayout.SOUTH);
+ getContentPane().add(jPnlParamContainer, java.awt.BorderLayout.CENTER);
+ pack();
+ setLocation(350, 350);
+ setTitle("Object Inspector - Parameter Values of '" + m_xIdlMethod.getName() + "'");
+ super.setFocusable(true);
+ super.setFocusableWindowState(true);
+ super.requestFocus();
+ m_aParameterPanels[0].getInputComponent().requestFocusInWindow();
+ setVisible(true);
+ if (!bisdiposed){
+ Vector aMethodObjects = new Vector();
+ for (int i = 0; i < m_aParameterPanels.length; i++){
+ aMethodObjects.add(m_aParameterPanels[i].getValue());
+ }
+ aMethodObjects.add(m_oUnoReturnObject);
+ return aMethodObjects;
+ }
+ else{
+ return null;
+ }
+ }
+
+
+ private void insertResultPanel(Exception _oInvocationException){
+ boolean bAddPanel = false;
+ if (jResultPanel == null){
+ jResultPanel = new JPanel(new BorderLayout());
+ bAddPanel = true;
+ }
+ else{
+ jResultPanel.removeAll();
+ }
+ jLblResult = new JLabel();
+ jLblResult.setMaximumSize(new java.awt.Dimension(getSize().width - 20, 57));
+ if (_oInvocationException != null){
+ jLblResult.setText("<html>Invoking the method cause an exception: <br>" + _oInvocationException.toString() + "</html>");
+ }
+ else{
+ jLblResult.setText("<html>The invocation of the method did not produce any error</html>");
+ }
+ jResultPanel.add(jLblResult,BorderLayout.WEST);
+ if (bAddPanel){
+ int nPos = jPnlParamContainer.getComponentCount() - 1;
+ jPnlParamContainer.add(jResultPanel, nPos);
+ }
+ super.pack();
+ super.validate();
+ }
+
+
+ private Object[] getParameterValues(){
+ Object[] oParameterValues = new Object[m_aParameterPanels.length];
+ for (int i = 0; i < m_aParameterPanels.length; i++){
+ oParameterValues[i] = m_aParameterPanels[i].getValue();
+ }
+ return oParameterValues;
+ }
+
+
+ private boolean isCompleted(){
+ boolean bIsCompleted = true;
+ for (int i = 0; i < m_aParameterPanels.length; i++){
+ bIsCompleted = m_aParameterPanels[i].isCompleted();
+ if (!bIsCompleted){
+ break;
+ }
+ }
+ return bIsCompleted;
+ }
+
+
+ private void addBorderPanel(java.awt.Container _jContainer, String _sLayout){
+ JPanel jPnlBorder = new JPanel();
+ jPnlBorder.setPreferredSize(new java.awt.Dimension(10, 10));
+ _jContainer.add(jPnlBorder, _sLayout);
+ }
+
+ private void addGapPanel(java.awt.Container _jContainer){
+ JPanel jPnlBorder = new JPanel();
+ jPnlBorder.setPreferredSize(new java.awt.Dimension(10, 10));
+ jPnlBorder.setMaximumSize(new java.awt.Dimension(10, 10));
+ _jContainer.add(jPnlBorder);
+ }
+
+
+ private class ParameterPanel extends JPanel{
+ private JComponent m_jComponent;
+ private TypeClass m_aTypeClass = null;
+
+ public ParameterPanel(ParamInfo _aParamInfo){
+ JTextField jTextField = new JTextField();
+ JComboBox jComboBox = new JComboBox();
+ m_aTypeClass = _aParamInfo.aType.getTypeClass();
+ setLayout(new java.awt.BorderLayout());
+ addBorderPanel(this, BorderLayout.NORTH);
+ addBorderPanel(this, BorderLayout.SOUTH);
+ JPanel jPnlCenter1 = new javax.swing.JPanel();
+ jPnlCenter1.setLayout(new javax.swing.BoxLayout(jPnlCenter1, javax.swing.BoxLayout.X_AXIS));
+ JLabel jLabel1 = new JLabel();
+ jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
+ String sParamText = _aParamInfo.aName + " (" + _aParamInfo.aType.getName() +")";
+ jLabel1.setText(sParamText);
+ jPnlCenter1.add(jLabel1);
+ addGapPanel(jPnlCenter1);
+ switch (m_aTypeClass.getValue()){
+ case TypeClass.BOOLEAN_value:
+ jComboBox.setBackground(new java.awt.Color(255, 255, 255));
+ jComboBox.setPreferredSize(new java.awt.Dimension(50, 19));
+ jComboBox.addItem("True");
+ jComboBox.addItem("False");
+ jComboBox.addKeyListener(new UpdateUIAdapter());
+ jPnlCenter1.add(jComboBox);
+ m_jComponent = jComboBox;
+ break;
+ case TypeClass.BYTE_value:
+ case TypeClass.CHAR_value:
+ case TypeClass.DOUBLE_value:
+ case TypeClass.ENUM_value:
+ case TypeClass.FLOAT_value:
+ case TypeClass.HYPER_value:
+ case TypeClass.LONG_value:
+ case TypeClass.SHORT_value:
+ case TypeClass.STRING_value:
+ case TypeClass.UNSIGNED_HYPER_value:
+ case TypeClass.UNSIGNED_LONG_value:
+ case TypeClass.UNSIGNED_SHORT_value:
+ jTextField.setPreferredSize(new java.awt.Dimension(50, 19));
+ jTextField.addKeyListener(new UpdateUIAdapter());
+ jPnlCenter1.add(jTextField);
+ m_jComponent = jTextField;
+ break;
+ default:
+ System.out.println("Type " + m_aTypeClass.getValue() + " not yet defined in 'ParameterPanel()'");
+ }
+ add(jPnlCenter1, java.awt.BorderLayout.CENTER);
+ JPanel jPnlEast = new JPanel();
+ add(jPnlEast, BorderLayout.EAST);
+ }
+
+ private JComponent getInputComponent(){
+ return m_jComponent;
+ }
+
+ public Object getValue(){
+ Object oReturn = null;
+ if (m_jComponent instanceof JTextField){
+ String sText = ((JTextField) m_jComponent).getText();
+ oReturn = Introspector.getIntrospector().getValueOfText(m_aTypeClass, sText);
+ }
+ else{
+ JComboBox jComboBox = ((JComboBox) m_jComponent);
+ oReturn = Boolean.valueOf(jComboBox.getSelectedIndex() == 0);
+ }
+ return oReturn;
+ }
+
+
+ public boolean isCompleted(){
+ if (m_jComponent instanceof JTextField){
+ return !((JTextField) m_jComponent).getText().equals("");
+ }
+ else{
+ return true;
+ }
+ }
+ }
+
+
+ private class UpdateUIAdapter extends KeyAdapter{
+ public void keyReleased(KeyEvent e){
+ boolean bIsCompleted = isCompleted();
+ jOKButton.setEnabled(bIsCompleted);
+ jInvokeButton.setEnabled(bIsCompleted);
+ if (jLblResult != null){
+ jLblResult.setEnabled(false);
+ jLblResult.invalidate();
+ }
+ }
+ }
+
+
+
+ private class ButtonPanel extends JPanel{
+ public ButtonPanel(){
+ super();
+ setLayout(new BorderLayout());
+ addBorderPanel(this, BorderLayout.NORTH);
+ addBorderPanel(this, BorderLayout.SOUTH);
+ JPanel jPnlBottomCenter = new JPanel();
+ jPnlBottomCenter.setLayout(new javax.swing.BoxLayout(jPnlBottomCenter, javax.swing.BoxLayout.X_AXIS));
+ jHelpButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ oActionListener.actionPerformed(e);
+ }
+ });
+ jHelpButton.setEnabled(oActionListener != null);
+ jPnlBottomCenter.add(jHelpButton);
+ addGapPanel(jPnlBottomCenter);
+ jOKButton.setEnabled(false);
+ jOKButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ invokeParameterMethod();
+ dispose();
+ }
+ });
+ jOKButton.setEnabled(isCompleted());
+ jInvokeButton.setEnabled(isCompleted());
+ jInvokeButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ invokeParameterMethod();
+ }
+ });
+
+ jPnlBottomCenter.add(jOKButton);
+ addGapPanel(jPnlBottomCenter);
+ jPnlBottomCenter.add(jInvokeButton);
+ addGapPanel(jPnlBottomCenter);
+ JButton jCancelButton = new JButton("Cancel");
+ jCancelButton.setFocusCycleRoot(true);
+ jCancelButton.setFocusPainted(true);
+ jCancelButton.addActionListener(new ActionListener(){
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ bisdiposed = true;
+ dispose();
+ }
+ });
+
+ jPnlBottomCenter.add(jCancelButton);
+ add(jPnlBottomCenter);
+ }
+ }
+
+
+ public void addActionListener(ActionListener _oActionListener){
+ oActionListener = _oActionListener;
+ jHelpButton.setEnabled(oActionListener != null);
+ }
+
+
+ public void invokeParameterMethod(){
+ try{
+ Object[] oParameters = getParameterValues();
+ m_oUnoReturnObject = m_xUnoMethodNode.invoke(m_oUnoObject, oParameters);
+ insertResultPanel(null);
+ } catch (Exception ex) {
+ insertResultPanel(ex);
+ m_oUnoReturnObject = null;
+ }}
+
+}
diff --git a/odk/examples/java/Inspector/ObjectInspector.xcs b/odk/examples/java/Inspector/ObjectInspector.xcs
new file mode 100755
index 000000000000..01a35ca111c0
--- /dev/null
+++ b/odk/examples/java/Inspector/ObjectInspector.xcs
@@ -0,0 +1,18 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<oor:component-schema
+ xmlns:oor="http://openoffice.org/2001/registry"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ oor:name="ObjectInspector"
+ oor:package="org.openoffice.inspector"
+ xml:lang="en-US">
+ <info>
+ <desc>Configuration parameters for the Object Inspector.</desc>
+ </info>
+ <component>
+ <prop oor:name="Language" oor:type="xs:string"/>
+ <prop oor:name="SDKPath" oor:type="xs:string"/>
+ </component>
+
+</oor:component-schema>
diff --git a/odk/examples/java/Inspector/ObjectInspector.xcu b/odk/examples/java/Inspector/ObjectInspector.xcu
new file mode 100755
index 000000000000..79459ab48f24
--- /dev/null
+++ b/odk/examples/java/Inspector/ObjectInspector.xcu
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE local [
+ <!ENTITY ProductName "Object Inspector">
+ <!ENTITY ProductVersion "0.8">
+]>
+<oor:component-data
+ xmlns:oor="http://openoffice.org/2001/registry"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ oor:name="ObjectInspector" oor:package="org.openoffice.inspector">
+ <prop oor:name="Language" oor:type="xs:string">
+ <value>Java</value>
+ </prop>
+ <prop oor:name="SDKPath" oor:type="xs:string">
+ <value></value>
+ </prop>
+
+</oor:component-data>
+
diff --git a/odk/examples/java/Inspector/ProtocolHandler.xcu b/odk/examples/java/Inspector/ProtocolHandler.xcu
new file mode 100755
index 000000000000..932c0f208cc9
--- /dev/null
+++ b/odk/examples/java/Inspector/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="InspectorAddon$InspectorAddonImpl" oor:op="replace">
+ <prop oor:name="Protocols" oor:type="oor:string-list">
+ <value>org.openoffice.Office.addon.Inspector:*</value>
+ </prop>
+ </node>
+ </node>
+</oor:component-data>
+
diff --git a/odk/examples/java/Inspector/ProtocolHandlerAddon.java b/odk/examples/java/Inspector/ProtocolHandlerAddon.java
new file mode 100644
index 000000000000..ad3b0efe8747
--- /dev/null
+++ b/odk/examples/java/Inspector/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/java/Inspector/SourceCodeGenerator.java b/odk/examples/java/Inspector/SourceCodeGenerator.java
new file mode 100644
index 000000000000..6661fe9604ad
--- /dev/null
+++ b/odk/examples/java/Inspector/SourceCodeGenerator.java
@@ -0,0 +1,1766 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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.UnknownPropertyException;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.Locale;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.reflection.ParamInfo;
+import com.sun.star.reflection.XIdlClass;
+import com.sun.star.reflection.XIdlMethod;
+import com.sun.star.reflection.XTypeDescription;
+import com.sun.star.text.XTextTablesSupplier;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.TypeClass;
+import com.sun.star.uno.UnoRuntime;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+
+
+public class SourceCodeGenerator {
+ private Vector sExceptions = new Vector();
+ Vector sHeaderStatements = new HeaderStatements();
+ private XLanguageSourceCodeGenerator m_xLanguageSourceCodeGenerator;
+ private String sHeaderCode = "";
+ private String sStatementCode = "";
+ private String sMainMethodSignature = "";
+
+ private Hashtable aVariables = new Hashtable();
+ private final String SSUFFIXSEPARATOR = "_";
+ private final String SVARIABLENAME = "VariableName";
+ private final String SARRAYVARIABLENAME = "VariableNameList";
+ private final String SUNOOBJECTNAME = "oUnobject";
+ private final String SUNOSTRUCTNAME = "aUnoStruct";
+ private Introspector m_oIntrospector;
+ private Vector aTreepathProviders = new Vector();
+ private XTreePathProvider xTreepathProvider = null;
+ private boolean baddExceptionHandling = false;
+ private boolean bXPropertySetExceptionsAreAdded = false;
+ private XUnoNode oInitialUnoNode = null;
+ private final String sINITIALVARIABLENAME = "_oUnoEntryObject";
+
+
+ /** Creates a new instance of SourceCodeGenerator */
+ public SourceCodeGenerator(int _nLanguage) {
+ this.setLanguage(_nLanguage);
+ m_oIntrospector = Introspector.getIntrospector();
+ }
+
+
+ public String addSourceCodeOfUnoObject(XTreePathProvider _xTreepathProvider, boolean _brememberPath, boolean _bAddMethodSignature, boolean _baddHeader){
+ String sSourceCode = "";
+ String sVariableName = "";
+ if (_xTreepathProvider != null) {
+ for (int i = 0; i < _xTreepathProvider.getPathCount(); i++){
+ XUnoNode oUnoNode = _xTreepathProvider.getPathComponent(i);
+ if (i == 0){
+ sVariableName = sINITIALVARIABLENAME;
+ oInitialUnoNode = oUnoNode;
+ }
+ else{
+ if (oUnoNode instanceof XUnoMethodNode){
+ XUnoMethodNode oUnoMethodNode = (XUnoMethodNode) oUnoNode;
+ if (oUnoMethodNode.isInvoked()){
+ UnoObjectDefinition oUnoReturnObjectDefinition = getUnoObjectDefinition(_xTreepathProvider, oUnoMethodNode, i);
+ if (!isVariableDeclared(oUnoReturnObjectDefinition, this.generateVariableNameFromMethod(oUnoMethodNode.getXIdlMethod()))){
+// sStatementCode += "\n";
+ sStatementCode += "\n" + getMethodStatementSourceCode(oUnoMethodNode, sVariableName, oUnoReturnObjectDefinition);
+ }
+ sVariableName = oUnoReturnObjectDefinition.getVariableName();
+ }
+ }
+ else if (oUnoNode instanceof XUnoPropertyNode){
+ XUnoPropertyNode oUnoPropertyNode = (XUnoPropertyNode) oUnoNode;
+ Any oReturnObject = com.sun.star.uno.Any.complete(oUnoPropertyNode.getUnoReturnObject());
+ UnoObjectDefinition oUnoReturnObjectDefinition = new UnoObjectDefinition(oReturnObject);
+ if (!isVariableDeclared(oUnoReturnObjectDefinition, oUnoPropertyNode.getProperty().Name)){
+// sStatementCode += "\n";
+ sStatementCode += "\n" + getPropertyStatementSourceCode(oUnoPropertyNode, sVariableName, oUnoReturnObjectDefinition);
+ }
+ sVariableName = oUnoReturnObjectDefinition.getVariableName();
+ }
+ }
+ }
+ }
+ String sCompleteCode = combineCompleteSourceCode(sMainMethodSignature, _baddHeader);
+ xTreepathProvider = _xTreepathProvider;
+ if (_brememberPath){
+ aTreepathProviders.add(_xTreepathProvider);
+ }
+ return sCompleteCode;
+ }
+
+
+ private void setLanguage(int _nLanguage){
+ XLanguageSourceCodeGenerator xLanguageSourceCodeGenerator = null;
+ switch(_nLanguage){
+ case XLanguageSourceCodeGenerator.nJAVA:
+ xLanguageSourceCodeGenerator = new JavaCodeGenerator();
+ break;
+ case XLanguageSourceCodeGenerator.nCPLUSPLUS:
+ xLanguageSourceCodeGenerator = new CPlusPlusCodeGenerator();
+ break;
+ case XLanguageSourceCodeGenerator.nBASIC:
+ xLanguageSourceCodeGenerator = new BasicCodeGenerator();
+ break;
+ default:
+ System.out.println("Unknown Sourcecode Language. Check Menus!");
+ }
+ if (xLanguageSourceCodeGenerator != null){
+ m_xLanguageSourceCodeGenerator = xLanguageSourceCodeGenerator;
+ }
+ }
+
+ private void resetSourceCodeGeneration(int _nLanguage){
+ aVariables.clear();
+ this.sHeaderStatements.clear();
+ setLanguage(_nLanguage);
+ String sHeaderCode = "";
+ sStatementCode = "";
+ }
+
+ private String generateVariableNameFromMethod(String _sMethodName, String _sPrefix, boolean _bConsiderAll){
+ String sReturn = "";
+ if (_sMethodName.startsWith(_sPrefix)){
+ int nPrefixLength = _sPrefix.length();
+ if (_sMethodName.length() > nPrefixLength){
+ String sChar = _sMethodName.substring(nPrefixLength, nPrefixLength + 1);
+ String sUpperChar = sChar.toUpperCase();
+ if (sUpperChar.equals(sChar)){
+ if (_bConsiderAll){
+ sReturn = _sMethodName;
+ }
+ else{
+ sReturn = _sMethodName.substring(nPrefixLength, _sMethodName.length());
+ }
+ }
+ }
+ }
+ return sReturn;
+ }
+
+
+ private String generateVariableNameFromMethod(XIdlMethod _xIdlMethod){
+ // todo: refactor this!!!
+ String sMethodName = _xIdlMethod.getName();
+ String sReturn = "";
+ sReturn = generateVariableNameFromMethod(sMethodName, "getBy", false);
+ if (sReturn.equals("")){
+ sReturn = generateVariableNameFromMethod(sMethodName, "get", false);
+ }
+ if (sReturn.equals("")){
+ sReturn = generateVariableNameFromMethod(sMethodName, "attach", false);
+ }
+ if (sReturn.equals("")){
+ sReturn = generateVariableNameFromMethod(sMethodName, "assign", false);
+ }
+ if (sReturn.equals("")){
+ sReturn = generateVariableNameFromMethod(sMethodName, "attach", false);
+ }
+ if (sReturn.equals("")){
+ sReturn = generateVariableNameFromMethod(sMethodName, "create", false);
+ }
+ if (sReturn.equals("")){
+ sReturn = generateVariableNameFromMethod(sMethodName, "is", true);
+ }
+ if (sReturn.equals("")){
+ sReturn = generateVariableNameFromMethod(sMethodName, "has", true);
+ }
+ if (sReturn.equals("")){
+ sReturn = sMethodName;
+ }
+ return sReturn;
+ }
+
+
+ public String convertAllUnoObjects(int _nLanguage){
+ String sSourceCode = "";
+ resetSourceCodeGeneration(_nLanguage);
+ int ncount = aTreepathProviders.size();
+ for (int i=0; i< ncount; i++){
+ sSourceCode = addSourceCodeOfUnoObject((XTreePathProvider) aTreepathProviders.get(i), false, (i==0), (i == (ncount-1)));
+ }
+ return sSourceCode;
+ }
+
+ private UnoObjectDefinition getUnoObjectDefinition(XTreePathProvider _xTreePathProvider, XUnoMethodNode _oUnoMethodNode, int _nindex){
+ XUnoNode oUnoNode = null;
+ Object oUnoReturnObject = null;
+ Object[] oParamObjects = null;
+ XIdlClass xIdlClass = _oUnoMethodNode.getXIdlMethod().getReturnType();
+ String sTypeName = xIdlClass.getName();
+ TypeClass aTypeClass = xIdlClass.getTypeClass();
+ if (aTypeClass.getValue() != TypeClass.VOID_value){
+ if (_xTreePathProvider.getPathCount() > _nindex + 1){
+ oUnoNode = _xTreePathProvider.getPathComponent(_nindex + 1);
+ oUnoReturnObject = oUnoNode.getUnoObject();
+ }
+ }
+ if (oUnoReturnObject == null){
+ oUnoReturnObject = _oUnoMethodNode.getLastUnoReturnObject();
+ }
+ UnoObjectDefinition oUnoObjectDefinition = new UnoObjectDefinition(oUnoReturnObject, sTypeName, aTypeClass);
+ if (_oUnoMethodNode.hasParameters()){
+ if (oUnoNode != null){
+ oParamObjects = oUnoNode.getParameterObjects();
+ }
+ else{
+ oParamObjects = _oUnoMethodNode.getLastParameterObjects();
+ }
+ }
+ if (oParamObjects != null){
+ oUnoObjectDefinition.addParameterObjects(oParamObjects);
+ }
+ return oUnoObjectDefinition;
+ }
+
+
+ private String combineCompleteSourceCode(String _sMethodSignature, boolean _bAddHeader){
+ String sCompleteCode = "";
+ if (_bAddHeader){
+ sMainMethodSignature = m_xLanguageSourceCodeGenerator.getMainMethodSignatureSourceCode(oInitialUnoNode, sINITIALVARIABLENAME);
+ m_xLanguageSourceCodeGenerator.assignqueryInterfaceHeaderSourceCode();
+ sCompleteCode += getHeaderSourceCode();
+ }
+ sCompleteCode += sMainMethodSignature;
+ sCompleteCode += sStatementCode;
+ if (_bAddHeader){
+ sCompleteCode += m_xLanguageSourceCodeGenerator.getMethodTerminationSourceCode();
+ sCompleteCode += "\n" + m_xLanguageSourceCodeGenerator.getCommentSign() + "...";
+ }
+ return sCompleteCode;
+ }
+
+
+ public String getPropertyStatementSourceCode(XUnoPropertyNode _oUnoPropertyNode, String _sVariableName, UnoObjectDefinition _oUnoReturnObjectDefinition){
+ String sReturnObjectVariableDefinition = "";
+ String sStatement = "";
+ String sPropertyName = _oUnoPropertyNode.getProperty().Name;
+ UnoObjectDefinition oUnoObjectDefinition = new UnoObjectDefinition(_oUnoPropertyNode.getUnoObject(), "com.sun.star.beans.XPropertySet");
+ if (!m_xLanguageSourceCodeGenerator.needsqueryInterface() || (oUnoObjectDefinition.getTypeClass().getValue() == TypeClass.STRUCT_value)){
+ oUnoObjectDefinition.setVariableName(_sVariableName);
+ if (oUnoObjectDefinition.getTypeClass().getValue() == TypeClass.STRUCT_value){
+ sReturnObjectVariableDefinition = getVariableInitialization(_oUnoReturnObjectDefinition, false);
+ sStatement += m_xLanguageSourceCodeGenerator.getStructSourceCode(sReturnObjectVariableDefinition, oUnoObjectDefinition.getVariableName(), sPropertyName);
+ return sStatement;
+ }
+ }
+ sStatement += addQueryInterfaceSourceCode(oUnoObjectDefinition, _sVariableName, "com.sun.star.beans.XPropertySet");
+ if (_oUnoReturnObjectDefinition.getTypeClass().getValue() != TypeClass.VOID_value){
+ sReturnObjectVariableDefinition = getVariableInitialization(_oUnoReturnObjectDefinition, true);
+ }
+ sStatement += m_xLanguageSourceCodeGenerator.getPropertyValueGetterSourceCode(sPropertyName, sReturnObjectVariableDefinition, oUnoObjectDefinition.getVariableName(), _oUnoReturnObjectDefinition.getTypeClass(), _oUnoReturnObjectDefinition.getTypeName());
+ addXPropertySetRelatedExceptions();
+ return sStatement;
+ }
+
+
+ public String getMethodStatementSourceCode(XUnoMethodNode _oUnoMethodNode, String _sVariableName, UnoObjectDefinition _oUnoReturnObjectDefinition){
+ String sReturnObjectVariableDefinition = "";
+ String sStatement = "";
+ XIdlMethod xIdlMethod = _oUnoMethodNode.getXIdlMethod();
+ TypeClass aReturnTypeClass = xIdlMethod.getReturnType().getTypeClass();
+ UnoObjectDefinition oUnoObjectDefinition = new UnoObjectDefinition(_oUnoMethodNode.getUnoObject(), _oUnoMethodNode.getClassName());
+ String sVariableStemName = this.generateVariableNameFromMethod(xIdlMethod);
+ sStatement += addQueryInterfaceSourceCode(oUnoObjectDefinition, _sVariableName, oUnoObjectDefinition.getTypeName());
+ if (_oUnoReturnObjectDefinition.getTypeClass().getValue() != TypeClass.VOID_value){
+ sReturnObjectVariableDefinition = getVariableInitialization(_oUnoReturnObjectDefinition, false) + " = ";
+ }
+ Object[] oParamObjects = _oUnoReturnObjectDefinition.getParameterObjects();
+ String sParameterCode = getMethodParameterValueDescription(_oUnoMethodNode, oParamObjects, false);
+ String sSeparator = m_xLanguageSourceCodeGenerator.getMethodSeparator();
+ sStatement += "\t" + sReturnObjectVariableDefinition + oUnoObjectDefinition.getVariableName() + sSeparator + xIdlMethod.getName() + "(" + sParameterCode + ")";
+ sStatement += m_xLanguageSourceCodeGenerator.getStatementTerminationCharacter();
+ addExceptions(xIdlMethod);
+ return sStatement;
+ }
+
+
+ private String addQueryInterfaceSourceCode(UnoObjectDefinition _oUnoObjectDefinition, String _sVariableName, String _sTypeName){
+ String sLocStatement = "";
+ if (m_xLanguageSourceCodeGenerator.needsqueryInterface()){
+ if (!isVariableDeclared(_oUnoObjectDefinition, "")){
+ String sObjectVariableDefinition = getVariableDeclaration(_oUnoObjectDefinition, false, "");
+ sLocStatement += m_xLanguageSourceCodeGenerator.getqueryInterfaceSourceCode(_sTypeName, sObjectVariableDefinition, _sVariableName);
+ }
+ }
+ else{
+ _oUnoObjectDefinition.setVariableName(_sVariableName);
+ }
+ return sLocStatement;
+ }
+
+
+ private void addXPropertySetRelatedExceptions(){
+ if (!bXPropertySetExceptionsAreAdded){
+ sExceptions.add("com.sun.star.beans.UnknownPropertyException");
+ sExceptions.add("com.sun.star.lang.WrappedTargetException");
+ sExceptions.add("com.sun.star.lang.IllegalArgumentException");
+ bXPropertySetExceptionsAreAdded = true;
+ baddExceptionHandling = true;
+ }
+ }
+
+
+ private void addExceptions(XIdlMethod _xIdlMethod){
+ XIdlClass[] xIdlClasses = _xIdlMethod.getExceptionTypes();
+ for (int i = 0; i > xIdlClasses.length; i++){
+ sExceptions.add(xIdlClasses[0].getName());
+ baddExceptionHandling = true;
+ }
+ }
+
+ private String getRootDescription(XUnoNode _oUnoNode){
+ return "_o" + _oUnoNode.toString();
+ }
+
+
+ private String getHeaderSourceCode(){
+ Enumeration aEnumeration = aVariables.elements();
+ while(aEnumeration.hasMoreElements()){
+ UnoObjectDefinition oUnoObjectDefinition = (UnoObjectDefinition) aEnumeration.nextElement();
+ String sCurHeaderStatement = m_xLanguageSourceCodeGenerator.getHeaderSourceCode(oUnoObjectDefinition.getUnoObject(), oUnoObjectDefinition.getTypeName(), oUnoObjectDefinition.getTypeClass());
+ sHeaderStatements.add(sCurHeaderStatement);
+ }
+ String sHeaderSourcecode = "";
+ String[] sHeaderStatementArray = new String[sHeaderStatements.size()];
+ sHeaderStatements.toArray(sHeaderStatementArray);
+ java.util.Arrays.sort(sHeaderStatementArray);
+ for (int i = 0; i < sHeaderStatementArray.length; i++){
+ sHeaderSourcecode += sHeaderStatementArray[i];
+ }
+ sHeaderSourcecode += m_xLanguageSourceCodeGenerator.getFinalHeaderStatements();
+ return sHeaderSourcecode +"\n" + m_xLanguageSourceCodeGenerator.getCommentSign() + "...\n";
+ }
+
+
+ private class HeaderStatements extends Vector{
+
+ public boolean contains(Object _oElement){
+ String sCompName = (String) _oElement;
+ for (int i = 0; i < this.size(); i++){
+ String sElement = (String) this.get(i);
+ if (sElement.equals(sCompName)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public boolean add(Object _oElement){
+ if (_oElement instanceof String){
+ if (!contains(_oElement)){
+ super.add(_oElement);
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+
+ private boolean isVariableDeclared(UnoObjectDefinition _oUnoObjectDefinition, String _sDefaultStemName){
+ boolean bisDeclared = false;
+ if (!_sDefaultStemName.equals("")){
+ _oUnoObjectDefinition.setCentralVariableStemName(_sDefaultStemName);
+ }
+ String sVariableStemName = _oUnoObjectDefinition.getVariableStemName();
+ bisDeclared = aVariables.containsKey(sVariableStemName);
+ if (bisDeclared){
+ Object oUnoObject = _oUnoObjectDefinition.getUnoObject();
+ if (m_oIntrospector.isObjectPrimitive(oUnoObject)){
+ bisDeclared = false;
+ }
+ else if (m_oIntrospector.isObjectSequence(oUnoObject)){
+ bisDeclared = false;
+ }
+ else{
+ String sCompVariableName = sVariableStemName;
+ String sUnoObjectIdentity = oUnoObject.toString();
+ boolean bleaveloop = false;
+ int a = 2;
+ while (!bleaveloop){
+ if (aVariables.containsKey(sCompVariableName)){
+ Object oUnoCompObject = ((UnoObjectDefinition) aVariables.get(sCompVariableName)).getUnoObject();
+ String sUnoCompObjectIdentity = oUnoCompObject.toString();
+ bleaveloop = sUnoCompObjectIdentity.equals(sUnoObjectIdentity);
+ bisDeclared = bleaveloop;
+ if (!bleaveloop){
+ sCompVariableName = sVariableStemName + SSUFFIXSEPARATOR + a++;
+ }
+ }
+ else{
+ bleaveloop = true;
+ bisDeclared = false;
+ }
+ }
+ }
+ }
+ return bisDeclared;
+ }
+
+
+ private String addUniqueVariableName(String _sStemVariableName, UnoObjectDefinition _oUnoObjectDefinition){
+ boolean bElementexists = true;
+ int a = 2;
+ String sCompName = _sStemVariableName;
+ while (bElementexists){
+ if (! aVariables.containsKey(sCompName)){
+ aVariables.put(sCompName, _oUnoObjectDefinition);
+ break;
+ }
+ sCompName = _sStemVariableName + SSUFFIXSEPARATOR + a++;
+ }
+ return sCompName;
+ }
+
+
+
+ private String getTypeString(String _sTypeName, TypeClass _aTypeClass, boolean _bAsHeaderSourceCode){
+ String sTypeString = "";
+ switch (_aTypeClass.getValue()){
+ case TypeClass.BOOLEAN_value:
+ sTypeString = m_xLanguageSourceCodeGenerator.getbooleanTypeDescription();
+ break;
+ case TypeClass.BYTE_value:
+ sTypeString = m_xLanguageSourceCodeGenerator.getbyteTypeDescription();
+ break;
+ case TypeClass.CHAR_value:
+ sTypeString = m_xLanguageSourceCodeGenerator.getcharTypeDescription();
+ break;
+ case TypeClass.DOUBLE_value:
+ sTypeString = m_xLanguageSourceCodeGenerator.getdoubleTypeDescription();
+ break;
+ case TypeClass.FLOAT_value:
+ sTypeString = m_xLanguageSourceCodeGenerator.getfloatTypeDescription();
+ break;
+ case TypeClass.HYPER_value:
+ sTypeString = m_xLanguageSourceCodeGenerator.gethyperTypeDescription();
+ break;
+ case TypeClass.LONG_value:
+ sTypeString = m_xLanguageSourceCodeGenerator.getlongTypeDescription();
+ break;
+ case TypeClass.SHORT_value:
+ sTypeString = m_xLanguageSourceCodeGenerator.getshortTypeDescription();
+ break;
+ case TypeClass.STRING_value:
+ sTypeString = m_xLanguageSourceCodeGenerator.getstringTypeDescription(_bAsHeaderSourceCode);
+ break;
+ case TypeClass.UNSIGNED_HYPER_value:
+ sTypeString = m_xLanguageSourceCodeGenerator.getunsignedhyperTypeDescription();
+ break;
+ case TypeClass.UNSIGNED_LONG_value:
+ sTypeString = m_xLanguageSourceCodeGenerator.getunsignedlongTypeDescription();
+ break;
+ case TypeClass.UNSIGNED_SHORT_value:
+ sTypeString = m_xLanguageSourceCodeGenerator.getdoubleTypeDescription();
+ break;
+ case TypeClass.SEQUENCE_value:
+ //TODO consider mulitdimensional Arrays
+ XTypeDescription xTypeDescription = Introspector.getIntrospector().getReferencedType(_sTypeName);
+ if (xTypeDescription != null){
+ sTypeString = getTypeString(xTypeDescription.getName(), xTypeDescription.getTypeClass(), _bAsHeaderSourceCode);
+ }
+ break;
+ case TypeClass.ANY_value:
+ sTypeString = m_xLanguageSourceCodeGenerator.getanyTypeDescription(_bAsHeaderSourceCode);
+ break;
+ case TypeClass.TYPE_value:
+ sTypeString = m_xLanguageSourceCodeGenerator.getObjectTypeDescription("com.sun.star.uno.Type", _bAsHeaderSourceCode);
+ break;
+ case TypeClass.ENUM_value:
+ case TypeClass.STRUCT_value:
+ case TypeClass.INTERFACE_ATTRIBUTE_value:
+ case TypeClass.INTERFACE_METHOD_value:
+ case TypeClass.INTERFACE_value:
+ case TypeClass.PROPERTY_value:
+ sTypeString = m_xLanguageSourceCodeGenerator.getObjectTypeDescription(_sTypeName, _bAsHeaderSourceCode);
+ break;
+ default:
+ }
+ return sTypeString;
+ }
+
+
+ private String getVariableDeclaration(UnoObjectDefinition _oUnoObjectDefinition, boolean _bInitialize, String _sVariableDefaultName){
+ TypeClass aTypeClass = _oUnoObjectDefinition.getTypeClass();
+ TypeClass aLocTypeClass = aTypeClass;
+ boolean bIsArray = false;
+ if (_oUnoObjectDefinition.getUnoObject() != null){
+ bIsArray = m_oIntrospector.isObjectSequence(_oUnoObjectDefinition.getUnoObject());
+ }
+ else{
+ bIsArray = _oUnoObjectDefinition.getTypeClass().getValue() == TypeClass.SEQUENCE_value;
+ }
+ String sVariableName = _oUnoObjectDefinition.getVariableName(_sVariableDefaultName);
+ String sTypeName = _oUnoObjectDefinition.getTypeName();
+ String sTypeString = getTypeString(sTypeName, aLocTypeClass, false);
+ if (bIsArray){
+ XTypeDescription xTypeDescription = Introspector.getIntrospector().getReferencedType(sTypeName);
+ if (xTypeDescription != null){
+ aLocTypeClass = xTypeDescription.getTypeClass();
+ }
+ }
+ String sVariableDeclaration = m_xLanguageSourceCodeGenerator.getVariableDeclaration(sTypeString, sVariableName, bIsArray, aLocTypeClass, _bInitialize);
+ addUniqueVariableName(sVariableName, _oUnoObjectDefinition);
+ return sVariableDeclaration;
+ }
+
+
+ public String getVariableInitialization(UnoObjectDefinition _oUnoObjectDefinition, boolean _bInitialize){
+ String sObjectVariableDeclaration = "";
+ String sVariableName = _oUnoObjectDefinition.getVariableName();
+ if (isVariableDeclared(_oUnoObjectDefinition, "")){
+ sObjectVariableDeclaration = sVariableName;
+ }
+ else{
+ sObjectVariableDeclaration = getVariableDeclaration(_oUnoObjectDefinition, _bInitialize, "");
+ }
+ return sObjectVariableDeclaration;
+ }
+
+
+
+ public String getVariableNameforUnoObject(String _sShortClassName){
+ if (_sShortClassName.startsWith("X")){
+ return "x" + _sShortClassName.substring(1);
+ }
+ else{
+ return _sShortClassName;
+ }
+ }
+
+
+class UnoObjectDefinition{
+ Object m_oUnoObject = null;
+ Type aType = null;
+ String sVariableStemName = "";
+ String m_sCentralVariableStemName = "";
+ String sVariableName = "";
+ String m_sTypeName = "";
+ TypeClass m_aTypeClass = null;
+ Object[] m_oParameterObjects = null;
+
+
+ public UnoObjectDefinition(Any _oUnoObject){
+ m_sTypeName = _oUnoObject.getType().getTypeName();
+ m_aTypeClass = _oUnoObject.getType().getTypeClass();
+ m_oUnoObject = _oUnoObject;
+ m_sCentralVariableStemName = getCentralVariableStemName(m_aTypeClass);
+ }
+
+
+ public UnoObjectDefinition(Object _oUnoObject, String _sTypeName, TypeClass _aTypeClass){
+ m_oUnoObject = _oUnoObject;
+ m_sTypeName = _sTypeName;
+ m_aTypeClass = _aTypeClass;
+ m_sCentralVariableStemName = getCentralVariableStemName(m_aTypeClass);
+ }
+
+
+ public UnoObjectDefinition(Object _oUnoObject, String _sTypeName){
+ m_oUnoObject = _oUnoObject;
+ m_sTypeName = _sTypeName;
+ m_aTypeClass = AnyConverter.getType(_oUnoObject).getTypeClass();
+ m_sCentralVariableStemName = getCentralVariableStemName(m_aTypeClass);
+ }
+
+
+ private String getCentralVariableStemName(TypeClass _aTypeClass){
+ String sCentralVariableStemName = "";
+ int nTypeClass = _aTypeClass.getValue();
+ switch(nTypeClass){
+ case TypeClass.SEQUENCE_value:
+ //TODO consider mulitdimensional Arrays
+ XTypeDescription xTypeDescription = Introspector.getIntrospector().getReferencedType(getTypeName());
+ if (xTypeDescription != null){
+ sCentralVariableStemName = getCentralVariableStemName(xTypeDescription.getTypeClass());
+ }
+ break;
+ case TypeClass.TYPE_value:
+ sCentralVariableStemName = SVARIABLENAME;
+ break;
+ case TypeClass.STRUCT_value:
+ sCentralVariableStemName = Introspector.getShortClassName(getTypeName());
+ break;
+ case TypeClass.INTERFACE_ATTRIBUTE_value:
+ case TypeClass.INTERFACE_METHOD_value:
+ case TypeClass.INTERFACE_value:
+ case TypeClass.PROPERTY_value:
+ String sShortClassName = m_oIntrospector.getShortClassName(getTypeName());
+ sCentralVariableStemName = getVariableNameforUnoObject(sShortClassName);
+ default:
+ sCentralVariableStemName = SVARIABLENAME;
+ }
+ return sCentralVariableStemName;
+ }
+
+ /** may return null
+ */
+ public Object getUnoObject(){
+ return m_oUnoObject;
+ }
+
+
+ public void setTypeClass(TypeClass _aTypeClass){
+ sVariableStemName = "";
+ m_aTypeClass = _aTypeClass;
+ }
+
+
+ public TypeClass getTypeClass(){
+ return m_aTypeClass;
+ }
+
+
+ public void setTypeName(String _sTypeName){
+ sVariableStemName = "";
+ m_sTypeName = _sTypeName;
+ }
+
+
+ public String getTypeName(){
+ return m_sTypeName;
+ }
+
+
+ public void setCentralVariableStemName(String _sCentralVariableStemName){
+ m_sCentralVariableStemName = _sCentralVariableStemName;
+ }
+
+
+ public String getVariableStemName(){
+ if (sVariableStemName.equals("")){
+ sVariableStemName = getVariableStemName(m_aTypeClass);
+ }
+ return sVariableStemName;
+ }
+
+
+ public void addParameterObjects(Object[] _oParameterObjects){
+ m_oParameterObjects = _oParameterObjects;
+ }
+
+
+ public Object[] getParameterObjects(){
+ return m_oParameterObjects;
+ }
+
+
+ public boolean hasParameterObjects(){
+ boolean breturn = false;
+ if (m_oParameterObjects != null){
+ breturn = m_oParameterObjects.length > 0;
+ }
+ return breturn;
+ }
+
+
+ public String getVariableStemName(TypeClass _aTypeClass){
+ int nTypeClass = _aTypeClass.getValue();
+ switch(nTypeClass){
+ case TypeClass.BOOLEAN_value:
+ sVariableStemName = "b" + m_sCentralVariableStemName;
+ break;
+ case TypeClass.DOUBLE_value:
+ case TypeClass.FLOAT_value:
+ sVariableStemName = "f" + m_sCentralVariableStemName;
+ break;
+ case TypeClass.BYTE_value:
+ case TypeClass.HYPER_value:
+ case TypeClass.LONG_value:
+ case TypeClass.UNSIGNED_HYPER_value:
+ case TypeClass.UNSIGNED_LONG_value:
+ case TypeClass.UNSIGNED_SHORT_value:
+ case TypeClass.SHORT_value:
+ sVariableStemName = "n" + m_sCentralVariableStemName;
+ break;
+ case TypeClass.CHAR_value:
+ case TypeClass.STRING_value:
+ sVariableStemName = "s" + m_sCentralVariableStemName;
+ break;
+ case TypeClass.SEQUENCE_value:
+ //TODO consider mulitdimensional Arrays
+ XTypeDescription xTypeDescription = Introspector.getIntrospector().getReferencedType(getTypeName());
+ if (xTypeDescription != null){
+ sVariableStemName = getVariableStemName(xTypeDescription.getTypeClass());
+ }
+ break;
+ case TypeClass.TYPE_value:
+ sVariableStemName = "a" + m_sCentralVariableStemName;
+ break;
+ case TypeClass.ANY_value:
+ sVariableStemName = "o" + m_sCentralVariableStemName;
+ break;
+ case TypeClass.STRUCT_value:
+ case TypeClass.ENUM_value:
+ sVariableStemName = "a" + m_sCentralVariableStemName;
+ break;
+ case TypeClass.INTERFACE_ATTRIBUTE_value:
+ case TypeClass.INTERFACE_METHOD_value:
+ case TypeClass.INTERFACE_value:
+ case TypeClass.PROPERTY_value:
+ String sShortClassName = m_oIntrospector.getShortClassName(getTypeName());
+ sVariableStemName = getVariableNameforUnoObject(sShortClassName);
+ default:
+ }
+ return sVariableStemName;
+ }
+
+
+ private void setVariableName(String _sVariableName){
+ sVariableName = _sVariableName;
+ }
+
+
+ private String getVariableName(String _sCentralVariableStemName){
+ if (!_sCentralVariableStemName.equals("")){
+ this.m_sCentralVariableStemName = _sCentralVariableStemName;
+ }
+ return getVariableName();
+ }
+
+
+ private String getVariableName() throws NullPointerException{
+ if (sVariableName.equals("")){
+ int a = 2;
+ sVariableName = getVariableStemName();
+ boolean bleaveloop = false;
+ while (!bleaveloop){
+ if (aVariables.containsKey(sVariableName)){
+ String sUnoObjectIdentity = ((UnoObjectDefinition) aVariables.get(sVariableName)).getUnoObject().toString();
+ if (m_oUnoObject != null){
+ if ((sUnoObjectIdentity.equals(m_oUnoObject.toString()) && (!m_oIntrospector.isPrimitive(this.getTypeClass())) &&
+ (! m_oIntrospector.isObjectSequence(m_oUnoObject)))){
+ bleaveloop = true;
+ }
+ else{
+ sVariableName = getVariableStemName() + SSUFFIXSEPARATOR + a++;
+ }
+ }
+ else{
+ bleaveloop = true;
+ }
+ }
+ else{
+ bleaveloop = true;
+ // throw new NullPointerException("SourceCode Variable " + _sStemVariableName + " not defined");
+ }
+ }
+ }
+ return sVariableName;
+ }
+ }
+
+
+ public String getStringValueOfObject(Object _oUnoObject, TypeClass _aTypeClass){
+ String sReturn = "";
+ switch (_aTypeClass.getValue()){
+ case TypeClass.BOOLEAN_value:
+ boolean bbooleanValue = ((Boolean) _oUnoObject).booleanValue();
+ sReturn += Boolean.toString(bbooleanValue);
+ case TypeClass.CHAR_value:
+ break;
+ case TypeClass.DOUBLE_value:
+ double fdoubleValue = ((Double) _oUnoObject).doubleValue();
+ sReturn += Double.toString(fdoubleValue);
+ break;
+ case TypeClass.ENUM_value:
+ break;
+ case TypeClass.FLOAT_value:
+ float floatValue = ((Float) _oUnoObject).floatValue();
+ sReturn += Float.toString(floatValue);
+ break;
+ case TypeClass.HYPER_value:
+ long nlongValue = ((Long) _oUnoObject).longValue();
+ sReturn += Long.toString(nlongValue);
+ break;
+ case TypeClass.LONG_value:
+ int nintValue = ((Integer) _oUnoObject).intValue();
+ sReturn += Integer.toString(nintValue);
+ break;
+ case TypeClass.SHORT_value:
+ short nshortValue = ((Short) _oUnoObject).shortValue();
+ sReturn += Short.toString(nshortValue);
+ break;
+ case TypeClass.STRING_value:
+ sReturn += (String) _oUnoObject;
+ break;
+ case TypeClass.UNSIGNED_HYPER_value:
+ nlongValue = ((Long) _oUnoObject).longValue();
+ sReturn += Long.toString(nlongValue);
+ break;
+ case TypeClass.UNSIGNED_LONG_value:
+ nintValue = ((Integer) _oUnoObject).intValue();
+ sReturn += Integer.toString(nintValue);
+ break;
+ case TypeClass.UNSIGNED_SHORT_value:
+ nshortValue = ((Short) _oUnoObject).shortValue();
+ sReturn += Short.toString(nshortValue);
+ break;
+ default:
+ System.out.println("Type " + _aTypeClass.getValue() + " not yet defined in 'getStringValueOfObject()'");
+ }
+ return sReturn;
+ }
+
+
+ public String getMethodParameterValueDescription(XUnoMethodNode _oUnoMethodNode, Object[] _oParamObjects, boolean _bIncludeParameterNames){
+ String sParamSourceCode = "";
+ ParamInfo[] aParamInfos = _oUnoMethodNode.getXIdlMethod().getParameterInfos();
+ if (_oParamObjects != null){
+ for (int i = 0; i < _oParamObjects.length; i++){
+ TypeClass aTypeClass = aParamInfos[i].aType.getTypeClass();
+ if (_bIncludeParameterNames){
+ sParamSourceCode += aParamInfos[i].aName + "=";
+ }
+ String sParamDescription = getStringValueOfObject(_oParamObjects[i], aTypeClass);
+ sParamDescription = this.m_xLanguageSourceCodeGenerator.castLiteral(sParamDescription, aTypeClass);
+ sParamSourceCode += sParamDescription;
+
+ if (i < _oParamObjects.length - 1){
+ sParamSourceCode += ", ";
+ }
+ }
+ }
+ return sParamSourceCode;
+ }
+
+
+ public class JavaCodeGenerator implements XLanguageSourceCodeGenerator{
+ String sStatementsCode = "";
+ boolean bAddAnyConverter = false;
+// boolean bAddTypeImport = false;
+ boolean bIsPropertyUnoObjectDefined = false;
+
+ public JavaCodeGenerator(){
+ }
+
+
+ public String getStatementTerminationCharacter(){
+ return ";";
+ }
+
+
+ public String getHeaderSourceCode(Object _oUnoObject, String _sClassName, TypeClass _aTypeClass){
+ String sClassName = _sClassName;
+ String sHeaderStatement = "";
+ if (_oUnoObject != null){
+ if (!m_oIntrospector.isObjectPrimitive(_oUnoObject)){
+ if (m_oIntrospector.isObjectSequence(_oUnoObject)){
+ XTypeDescription xTypeDescription = m_oIntrospector.getReferencedType(sClassName);
+ if (xTypeDescription != null){
+ if (!m_oIntrospector.isPrimitive(xTypeDescription.getTypeClass())){
+ sClassName = getTypeString(xTypeDescription.getName(), xTypeDescription.getTypeClass(), true);
+ }
+ // primitive Types are not supposed to turn up in the import section...
+ else{
+ sClassName = "";
+ }
+ }
+ }
+ else{
+ sClassName = getTypeString(_sClassName, _aTypeClass, true);
+ }
+ }
+ else if (_aTypeClass.getValue() == TypeClass.ENUM_value){
+ sClassName = _sClassName;
+ }
+ else{
+ sClassName = "";
+ }
+ if (!sClassName.equals("")){
+ sHeaderStatement = "import " + sClassName + ";\n";
+ }
+ }
+ return sHeaderStatement;
+ }
+
+
+ public String getFinalHeaderStatements(){
+ return "";
+ }
+
+
+ public void assignqueryInterfaceHeaderSourceCode(){
+ sHeaderStatements.add("import com.sun.star.uno.UnoRuntime;\n");
+ sHeaderStatements.add("import com.sun.star.uno.XInterface;\n");
+ if (bAddAnyConverter){
+ sHeaderStatements.add("import com.sun.star.uno.AnyConverter;\n");
+ }
+ }
+
+
+
+ public String getConvertedSourceCodeValueOfObject(String _sReturnVariableName, String _sObjectDescription, TypeClass _aTypeClass, String _sTypeName){
+ boolean bLocAddAnyConverter = true;
+ String sReturn = "";
+ switch (_aTypeClass.getValue()){
+ case TypeClass.BOOLEAN_value:
+ sReturn = _sReturnVariableName + " = AnyConverter.toBoolean(" + _sObjectDescription + ")";
+ break;
+ case TypeClass.CHAR_value:
+ sReturn = _sReturnVariableName + " = AnyConverter.toChar(" + _sObjectDescription + ")";
+ break;
+ case TypeClass.BYTE_value:
+ sReturn = _sReturnVariableName + " = AnyConverter.toByte(" + _sObjectDescription + ")";
+ break;
+ case TypeClass.DOUBLE_value:
+ sReturn = _sReturnVariableName + " = AnyConverter.toDouble(" + _sObjectDescription + ")";
+ break;
+ case TypeClass.FLOAT_value:
+ sReturn = _sReturnVariableName + " = AnyConverter.toFloat(" + _sObjectDescription + ")";
+ break;
+ case TypeClass.UNSIGNED_HYPER_value:
+ sReturn = _sReturnVariableName + " = AnyConverter.toUnsignedLong(" + _sObjectDescription + ")";
+ break;
+ case TypeClass.HYPER_value:
+ sReturn = _sReturnVariableName + " = AnyConverter.toLong(" + _sObjectDescription + ")";
+ break;
+ case TypeClass.UNSIGNED_LONG_value:
+ sReturn = _sReturnVariableName + " = AnyConverter.toUnsignedInt(" + _sObjectDescription + ")";
+ break;
+ case TypeClass.LONG_value:
+ sReturn = _sReturnVariableName + " = AnyConverter.toInt(" + _sObjectDescription + ")";
+ break;
+ case TypeClass.SHORT_value:
+ sReturn = _sReturnVariableName + " = AnyConverter.toShort(" + _sObjectDescription + ")";
+ break;
+ case TypeClass.UNSIGNED_SHORT_value:
+ sReturn = _sReturnVariableName + " = AnyConverter.toUnsignedShort(" + _sObjectDescription + ")";
+ break;
+ case TypeClass.STRING_value:
+ sReturn = _sReturnVariableName + " = AnyConverter.toString(" + _sObjectDescription + ")";
+ break;
+ default:
+ String sShortTypeName = Introspector.getShortClassName(_sTypeName);
+ if (bIsPropertyUnoObjectDefined){
+ sReturn = "oUnoObject = " + _sObjectDescription + ";\n\t";
+ }
+ else{
+ sReturn = "Object oUnoObject = " + _sObjectDescription + ";\n\t";
+ bIsPropertyUnoObjectDefined = true;
+ }
+ sReturn += _sReturnVariableName + " = (" + sShortTypeName + ") AnyConverter.toObject(" + sShortTypeName + ".class, oUnoObject);";
+// this.bAddTypeImport = true;
+ break;
+ }
+ if (!bAddAnyConverter){
+ bAddAnyConverter = bLocAddAnyConverter;
+ }
+ return sReturn;
+ }
+
+
+ public String getStructSourceCode(String _sReturnVariableDescription, String _sObjectDescription, String _sMember){
+ return "\t" + _sReturnVariableDescription + " = " + _sObjectDescription + "." + _sMember + ";";
+ }
+
+ public String getMainMethodSignatureSourceCode(XUnoNode _oUnoNode, String _soReturnObjectDescription){
+ //TODO try to use + _oUnoNode.getClassName() instead of the hack
+ String sReturn = "public void codesnippet(XInterface " + _soReturnObjectDescription + "){";
+ if (baddExceptionHandling){
+ sReturn += "\ntry{";
+ }
+ return sReturn;
+ }
+
+ public String getMethodSeparator(){
+ return ".";
+ }
+
+ public boolean needsqueryInterface(){
+ return true;
+ }
+
+ public String getqueryInterfaceSourceCode(String _sClassName, String _sReturnVariableName, String _sIncomingObjectName){
+ String sShortClassName = m_oIntrospector.getShortClassName(_sClassName);
+ return "\t" + _sReturnVariableName + " = (" + sShortClassName + ") UnoRuntime.queryInterface(" + sShortClassName + ".class, " + _sIncomingObjectName + ");\n";
+ }
+
+
+ public String getPropertyValueGetterSourceCode(String _sPropertyName, String _sReturnVariableName, String _sIncomingObjectName, TypeClass _aTypeClass, String _sTypeName){
+ String sObjectDescription = _sIncomingObjectName + ".getPropertyValue(\"" + _sPropertyName + "\")";
+ String sReturn = getConvertedSourceCodeValueOfObject(_sReturnVariableName, sObjectDescription, _aTypeClass, _sTypeName);
+ sReturn += ";";
+ sReturn = "\t" + sReturn;
+ return sReturn;
+// return "\t" + _sReturnVariableName + " = " + _sIncomingObjectName + ".getPropertyValue(\"" + _sPropertyName + "\");";
+ }
+
+
+ public String getObjectTypeDescription(String _sClassName, boolean _bAsHeader){
+ String sReturn = "";
+ if (_bAsHeader){
+ sReturn = _sClassName;
+ }
+ else{
+ sReturn = m_oIntrospector.getShortClassName(_sClassName);
+ }
+ return sReturn;
+ }
+
+
+ public String getMethodTerminationSourceCode(){
+ String sReturn = "";
+ int nIndex = 1;
+ String sExceptionName = "e";
+ if (baddExceptionHandling){
+ for (int i = 0; i < sExceptions.size(); i++){
+ String sCurException = (String) sExceptions.get(i);
+ if (sReturn.indexOf(sCurException) == -1){
+ if (nIndex > 1){
+ sExceptionName = "e"+ nIndex;
+ }
+ else{
+ sReturn +="\n}";
+ }
+ sReturn += "catch (" + sCurException + " " + sExceptionName + "){\n";
+ sReturn += "\t" + sExceptionName + ".printStackTrace(System.out);\n";
+ sReturn += "\t" + getCommentSign() + "Enter your Code here...\n}";
+ nIndex++;
+ }
+ }
+ }
+ sReturn += "\n}";
+ return sReturn;
+ }
+
+ public String castLiteral(String _sExpression, TypeClass _aTypeClass){
+ String sReturn = "";
+ switch (_aTypeClass.getValue()){
+ case TypeClass.BOOLEAN_value:
+ sReturn = _sExpression;
+ break;
+ case TypeClass.BYTE_value:
+ sReturn = "(byte) " + _sExpression;
+ break;
+ case TypeClass.CHAR_value:
+ sReturn = "'" + _sExpression + "'";
+ break;
+ case TypeClass.DOUBLE_value:
+ sReturn = "(double) " + _sExpression;
+ break;
+ case TypeClass.FLOAT_value:
+ sReturn = "(float) " + _sExpression;
+ break;
+ case TypeClass.UNSIGNED_SHORT_value:
+ case TypeClass.SHORT_value:
+ sReturn = "(short) " + _sExpression;
+ break;
+ case TypeClass.STRING_value:
+ sReturn = "\"" + _sExpression + "\"";
+ break;
+ case TypeClass.HYPER_value:
+ case TypeClass.UNSIGNED_HYPER_value:
+ sReturn = "(long) " + _sExpression;
+ break;
+ case TypeClass.LONG_value:
+ sReturn = _sExpression;
+ break;
+ case TypeClass.ENUM_value:
+ default:
+ sReturn = _sExpression;
+ System.out.println("Type " + _aTypeClass.getValue() + " not yet defined in 'castliteral()'");
+ }
+ return sReturn;
+ }
+
+
+ public String getbooleanTypeDescription(){
+ return "boolean";
+ }
+
+ public String getbyteTypeDescription(){
+ return "byte";
+ }
+
+ public String getshortTypeDescription(){
+ return "short";
+ }
+
+ public String getunsignedshortTypeDescription(){
+ return "short";
+ }
+
+ public String getlongTypeDescription(){
+ return "int";
+ }
+
+ public String getunsignedlongTypeDescription(){
+ return "int";
+ }
+
+ public String gethyperTypeDescription(){
+ return "long";
+ }
+
+ public String getunsignedhyperTypeDescription(){
+ return "long";
+ }
+
+ public String getfloatTypeDescription(){
+ return "float";
+ }
+
+ public String getdoubleTypeDescription(){
+ return "double";
+ }
+
+ public String getcharTypeDescription(){
+ return "char";
+ }
+
+ public String getstringTypeDescription(boolean _bAsHeaderSourceCode){
+ if (_bAsHeaderSourceCode){
+ return "";
+ }
+ else{
+ return "String";
+ }
+ }
+
+ public String gettypeTypeDescription(boolean _bAsHeaderSourceCode){
+ if (_bAsHeaderSourceCode){
+ return "com.sun.star.uno.Type";
+ }
+ else{
+ return "Type";
+ }
+ }
+
+ public String getanyTypeDescription(boolean _bAsHeaderSourceCode){
+ if (_bAsHeaderSourceCode){
+ return "";
+ }
+ else{
+ return "Object";
+ }
+ }
+
+
+ public String getStringValue(String _sValue){
+ return _sValue;
+ }
+
+
+ public String getVariableDeclaration(String _sTypeString, String _sVariableName, boolean _bIsArray, TypeClass _aTypeClass, boolean _bInitialize){
+ String sReturn = "";
+ if (_bIsArray){
+ sReturn = _sTypeString + "[] " + _sVariableName;
+ }
+ else{
+ sReturn = _sTypeString + " " + _sVariableName;
+ }
+ return sReturn;
+ }
+
+
+ public String getArrayDeclaration(String _sVariableDeclaration){
+ String sReturn = "";
+ String[] sDeclarations = _sVariableDeclaration.split(" ");
+ for (int i = 0; i< sDeclarations.length;i++){
+ sReturn += sDeclarations[i];
+ if (i == 0){
+ sReturn += "[]";
+ }
+ if (i < (sDeclarations.length -1)){
+ sReturn += " ";
+ }
+ }
+ return sReturn;
+ }
+
+ public String getCommentSign(){
+ return "//";
+ }
+ }
+
+
+ public class BasicCodeGenerator implements XLanguageSourceCodeGenerator{
+ String sStatementsCode = "";
+
+ public BasicCodeGenerator(){
+ }
+
+ public String getHeaderSourceCode(Object _oUnoObject, String _sClassName, TypeClass _aTypeClass){
+ String sHeaderStatement = "";
+ return sHeaderStatement;
+ }
+
+ public String getFinalHeaderStatements(){
+ return "";
+ }
+
+ public String getMainMethodSignatureSourceCode(XUnoNode _oUnoNode, String _soReturnObjectDescription){
+ //TODO try to use + _oUnoNode.getClassName() instead of the hack
+ return "Sub Main(" + _soReturnObjectDescription + " as " + getanyTypeDescription(false) + ")";
+ }
+
+ public boolean needsqueryInterface(){
+ return false;
+ }
+
+ public void assignqueryInterfaceHeaderSourceCode(){
+ }
+
+ public String getMethodSeparator(){
+ return ".";
+ }
+
+
+ public String getqueryInterfaceSourceCode(String _sClassName, String _sReturnVariableName, String _sIncomingObjectName){
+ return _sIncomingObjectName;
+ }
+
+
+ public String getPropertyValueGetterSourceCode(String _sPropertyName, String _sReturnVariableName, String _sIncomingObjectName, TypeClass _aTypeClass, String _sTypeName){
+ return "\t" + _sReturnVariableName + " = " + _sIncomingObjectName + "." + _sPropertyName;
+ }
+
+
+ public String getStructSourceCode(String _sReturnVariableDescription, String _sObjectDescription, String _sMember){
+ return getPropertyValueGetterSourceCode(_sMember, _sReturnVariableDescription, _sObjectDescription, null, "" );
+ }
+
+ public String getConvertedSourceCodeValueOfObject(String _sReturnVariableName, String _sObjectDescription, TypeClass _aTypeClass, String _sTypeName){
+ return _sReturnVariableName + " = " + _sObjectDescription;
+ }
+
+
+ public String getObjectTypeDescription(String _sClassName, boolean _bAsHeader){
+ return "Object";
+ }
+
+
+ public String getMethodTerminationSourceCode(){
+ return "\nEnd Sub\n";
+ }
+
+
+ public String castLiteral(String _sExpression, TypeClass _aTypeClass){
+ String sReturn = "";
+ switch (_aTypeClass.getValue()){
+ case TypeClass.BOOLEAN_value:
+ case TypeClass.BYTE_value:
+ case TypeClass.DOUBLE_value:
+ case TypeClass.FLOAT_value:
+ case TypeClass.UNSIGNED_SHORT_value:
+ case TypeClass.SHORT_value:
+ case TypeClass.LONG_value:
+ case TypeClass.UNSIGNED_LONG_value:
+ case TypeClass.HYPER_value:
+ case TypeClass.UNSIGNED_HYPER_value:
+ sReturn = _sExpression;
+ break;
+ case TypeClass.CHAR_value:
+ case TypeClass.STRING_value:
+ sReturn = "\"" +_sExpression + "\"";
+ break;
+ case TypeClass.ENUM_value:
+ default:
+ sReturn = _sExpression;
+ System.out.println("Type " + _aTypeClass.getValue() + " not yet defined in 'castliteral()'");
+ }
+ return sReturn;
+ }
+
+
+
+ public String getbooleanTypeDescription(){
+ return "Boolean";
+ }
+
+ public String getbyteTypeDescription(){
+ return "Integer";
+ }
+
+ public String getshortTypeDescription(){
+ return "Integer";
+ }
+
+ public String getunsignedshortTypeDescription(){
+ return "Integer";
+ }
+
+ public String getlongTypeDescription(){
+ return "Integer";
+ }
+
+ public String getunsignedlongTypeDescription(){
+ return "Long";
+ }
+
+ public String gethyperTypeDescription(){
+ return "Long";
+ }
+
+ public String getunsignedhyperTypeDescription(){
+ return "Long";
+ }
+
+ public String getfloatTypeDescription(){
+ return "Double";
+ }
+
+ public String getdoubleTypeDescription(){
+ return "Double";
+ }
+
+ public String getcharTypeDescription(){
+ return "String";
+ }
+
+ public String getstringTypeDescription(boolean _bAsHeaderSourceCode){
+ if (_bAsHeaderSourceCode){
+ return "";
+ }
+ else{
+ return "String";
+ }
+ }
+
+ public String gettypeTypeDescription(boolean _bAsHeaderSourceCode){
+ if (_bAsHeaderSourceCode){
+ return "";
+ }
+ else{
+ return "Object";
+ }
+ }
+
+ public String getanyTypeDescription(boolean _bAsHeaderSourceCode){
+ if (_bAsHeaderSourceCode){
+ return "";
+ }
+ else{
+ return "Object";
+ }
+ }
+
+ public String getStatementTerminationCharacter(){
+ return "";
+ }
+
+
+ public String getVariableDeclaration(String _sTypeString, String _sVariableName, boolean bIsArray, TypeClass _aTypeClass, boolean _bInitialize){
+ String sReturn = "";
+ if (bIsArray){
+ sReturn = "Dim " + _sVariableName + "() as " + _sTypeString + "\n\t" + _sVariableName;
+ }
+ else{
+ sReturn = "Dim " + _sVariableName + " as " + _sTypeString + "\n\t" + _sVariableName;
+ }
+ return sReturn;
+ }
+
+
+ public String getStringValue(String _sValue){
+ return _sValue;
+ }
+
+
+ public String getArrayDeclaration(String _sVariableDeclaration){
+ String sReturn = "";
+ String[] sDeclarations = _sVariableDeclaration.split(" ");
+ for (int i = 0; i< sDeclarations.length;i++){
+ sReturn += sDeclarations[i];
+ if (i == 0){
+ sReturn += "[]";
+ }
+ if (i < (sDeclarations.length -1)){
+ sReturn += " ";
+ }
+ }
+ return sReturn;
+ }
+
+ public String getCommentSign(){
+ return "'";
+ }
+
+ }
+
+ public class CPlusPlusCodeGenerator implements XLanguageSourceCodeGenerator{
+ String sStatementsCode = "";
+ boolean bIncludeStringHeader = false;
+ boolean bIncludeAny = false;
+ boolean bIncludeSequenceHeader = false;
+
+ public CPlusPlusCodeGenerator(){
+ }
+
+ private String getCSSNameSpaceString(){
+ return "css";
+ }
+
+ public String getStatementTerminationCharacter(){
+ return ";";
+ }
+
+
+ public String getHeaderSourceCode(Object _oUnoObject, String _sClassName, TypeClass _aTypeClass){
+ String sClassName = _sClassName;
+ String sHeaderStatement = "";
+ if (_oUnoObject != null){
+ if (!m_oIntrospector.isObjectPrimitive(_oUnoObject)){
+ if (m_oIntrospector.isObjectSequence(_oUnoObject)){
+ XTypeDescription xTypeDescription = m_oIntrospector.getReferencedType(sClassName);
+ if (xTypeDescription != null){
+ if (!m_oIntrospector.isPrimitive(xTypeDescription.getTypeClass())){
+ sClassName = getTypeString(xTypeDescription.getName(), xTypeDescription.getTypeClass(), true);
+ }
+ // primitive Types are not supposed to turn up in the import section...
+ else{
+ sClassName = "";
+ }
+ }
+ }
+ else{
+ sClassName = getTypeString(_sClassName, _aTypeClass, true);
+ }
+ if (!sClassName.equals("")){
+ sHeaderStatement = getHeaderOfClass(sClassName);
+ }
+ }
+ }
+ return sHeaderStatement;
+ }
+
+
+
+ public String getFinalHeaderStatements(){
+ String sReturn = "";
+ sReturn += "\nnamespace " + getCSSNameSpaceString() + " = com::sun::star;\n";
+ sReturn += "using namespace rtl;\n";
+ return sReturn;
+ }
+
+
+ private String getHeaderOfClass(String _sClassName){
+ return "#include \"" + _sClassName.replace('.', '/') + ".hpp\"\n"; // #include <com/sun/star/uno/XComponentContext.hpp>
+ }
+
+
+
+ public void assignqueryInterfaceHeaderSourceCode(){
+ sHeaderStatements.add("#include \"sal/config.h\"\n");
+ sHeaderStatements.add("#include \"sal/types.h\"\n");
+ if (bIncludeStringHeader){
+ sHeaderStatements.add("#include \"rtl/ustring.hxx\"\n");
+ }
+ sHeaderStatements.add("#include \"com/sun/star/uno/Reference.hxx\"\n");
+ if (bIncludeSequenceHeader){
+ sHeaderStatements.add("#include \"com/sun/star/uno/Sequence.hxx\"\n");
+ }
+ sHeaderStatements.add(getHeaderOfClass("com.sun.star.uno.XInterface"));
+ if (bIncludeAny){
+ sHeaderStatements.add(getHeaderOfClass("com.sun.star.uno.Any"));
+ }
+ }
+
+
+ public String getMainMethodSignatureSourceCode(XUnoNode _oUnoNode, String _soReturnObjectDescription){
+ String sReturn = "";
+ sReturn = "void codesnippet(const " + getCSSNameSpaceString() + "::uno::Reference<" + getCSSNameSpaceString() + "::uno::XInterface>& " + _soReturnObjectDescription + " ){";
+ int a = 0;
+ if (!sExceptions.contains("com.sun.star.uno.RuntimeException")){
+ sExceptions.add("com.sun.star.uno.RuntimeException");
+ }
+ if (baddExceptionHandling){
+ sReturn += "\n//throw ";
+ for (int i = 0; i < sExceptions.size(); i++){
+ String sCurException = (String) sExceptions.get(i);
+ if (sReturn.indexOf(sCurException) == -1){
+ if (a++ > 0){
+ sReturn += ", ";
+ }
+ sReturn += getObjectTypeDescription(sCurException, false);
+
+ }
+ }
+
+ }
+ sReturn += "{";
+ return sReturn;
+ }
+
+
+ public boolean needsqueryInterface(){
+ return true;
+ }
+
+
+ public String getqueryInterfaceSourceCode(String _sClassName, String _sReturnVariableName, String _sIncomingObjectName){
+ return "\t" + _sReturnVariableName + "( " + _sIncomingObjectName + ", " + getCSSNameSpaceString() + "::uno::UNO_QUERY_THROW);\n";
+ }
+
+
+ public String getPropertyValueGetterSourceCode(String _sPropertyName, String _sReturnVariableName, String _sIncomingObjectName, TypeClass _aTypeClass, String _sTypeName){
+ String sFirstLine = "\t";
+ String sReturnVariableName = _sReturnVariableName;
+ // e.g. uno::Any a = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" )) );
+ String[] sVarDefinition = _sReturnVariableName.split("=");
+ if (sVarDefinition.length > 0){
+ String sVariable = sVarDefinition[0];
+ String[] sVarDeclaration = sVariable.split(" ");
+ if (sVarDeclaration.length > 0){
+ sFirstLine += sReturnVariableName + ";\n";
+ sReturnVariableName = sVarDeclaration[sVarDeclaration.length-1];
+ }
+ }
+ String sObjectDescription = _sIncomingObjectName + "->getPropertyValue(" + getStringValue(_sPropertyName) + ")";
+ String sSecondLine = "\t" + getConvertedSourceCodeValueOfObject(sReturnVariableName, sObjectDescription, _aTypeClass, _sTypeName) + ";";
+ return sFirstLine + sSecondLine;
+ }
+
+
+ public String getStructSourceCode(String _sReturnVariableDescription, String _sObjectDescription, String _sMember){
+ return "\t" + _sReturnVariableDescription + " = " + _sObjectDescription + "->" + _sMember + ";";
+ }
+
+
+ public String getConvertedSourceCodeValueOfObject(String _sReturnVariableName, String _sObjectDescription, TypeClass _aTypeClass, String _sTypeName){
+// if (m_oIntrospector.isPrimitive(_aTypeClass)){
+ return _sObjectDescription + " >>= " + _sReturnVariableName;
+// }
+// else{
+// return _sReturnVariableName + " = " + _sObjectDescription;
+// }
+ }
+
+
+ public String getStringValue(String _sValue){
+ bIncludeStringHeader = true;
+ return "OUString(RTL_CONSTASCII_USTRINGPARAM(\"" + _sValue + "\"))";
+ }
+
+
+ public String getObjectTypeDescription(String _sClassName, boolean _bAsHeader){
+ String sReturn = "";
+ if (_bAsHeader){
+ sReturn = _sClassName.replace('.', '/');
+ }
+ else{
+ String sModuleName = m_oIntrospector.getModuleName(_sClassName);
+ sModuleName = m_oIntrospector.getShortClassName(sModuleName);
+ sReturn = getCSSNameSpaceString() + "::" + sModuleName + "::" + m_oIntrospector.getShortClassName(_sClassName);
+ }
+ return sReturn;
+ }
+
+
+ public String getMethodTerminationSourceCode(){
+ return "\n}";
+ }
+
+ public String getMethodSeparator(){
+ return "->";
+ }
+
+
+ public String castLiteral(String _sExpression, TypeClass _aTypeClass){
+ String sReturn = "";
+ switch (_aTypeClass.getValue()){
+ case TypeClass.BOOLEAN_value:
+ case TypeClass.BYTE_value:
+ case TypeClass.DOUBLE_value:
+ case TypeClass.FLOAT_value:
+ case TypeClass.UNSIGNED_SHORT_value:
+ case TypeClass.SHORT_value:
+ case TypeClass.LONG_value:
+ case TypeClass.UNSIGNED_LONG_value:
+ case TypeClass.HYPER_value:
+ case TypeClass.UNSIGNED_HYPER_value:
+ sReturn = _sExpression;
+ break;
+ case TypeClass.CHAR_value:
+ sReturn = "'" + _sExpression + "'";
+ break;
+ case TypeClass.STRING_value:
+ sReturn = getStringValue(_sExpression);
+ break;
+ case TypeClass.ENUM_value:
+ default:
+ sReturn = _sExpression;
+ System.out.println("Type " + _aTypeClass.getValue() + " not yet defined in 'castliteral()'");
+ }
+ return sReturn;
+ }
+
+ public String getbooleanTypeDescription(){
+ return "sal_Bool";
+ }
+
+ public String getbyteTypeDescription(){
+ return "sal_Int8";
+ }
+
+ public String getshortTypeDescription(){
+ return "sal_Int16";
+ }
+
+ public String getunsignedshortTypeDescription(){
+ return "sal_uInt16";
+ }
+
+ public String getlongTypeDescription(){
+ return "sal_Int32";
+ }
+
+ public String getunsignedlongTypeDescription(){
+ return "sal_uInt32";
+ }
+
+ public String gethyperTypeDescription(){
+ return "sal_Int64";
+ }
+
+ public String getunsignedhyperTypeDescription(){
+ return "sal_uInt64";
+ }
+
+ public String getfloatTypeDescription(){
+ return "float";
+ }
+
+ public String getdoubleTypeDescription(){
+ return "double";
+ }
+
+ public String getcharTypeDescription(){
+ return "sal_Unicode";
+ }
+
+ public String getstringTypeDescription(boolean _bAsHeaderSourceCode){
+ bIncludeStringHeader = true;
+ if (_bAsHeaderSourceCode){
+ return "";
+ }
+ else{
+ return "OUString";
+ }
+ }
+
+ public String gettypeTypeDescription(boolean _bAsHeaderSourceCode){
+ if (_bAsHeaderSourceCode){
+ return "com/sun/star/uno/Type";
+ }
+ else{
+ return "Type";
+ }
+ }
+
+ public String getanyTypeDescription(boolean _bAsHeaderSourceCode){
+ if (_bAsHeaderSourceCode){
+ return "com/sun/star/uno/XInterface";
+ }
+ else{
+ return "XInterface";
+ }
+ }
+
+
+ public String getVariableDeclaration(String _sTypeString, String _sVariableName, boolean bIsArray, TypeClass _aTypeClass, boolean _bInitialize){
+ boolean bIsPrimitive = m_oIntrospector.isPrimitive(_aTypeClass);
+
+ // uno::Reference< frame::XDispatch > m_xDispatch
+ String sReturn = "";
+ if (bIsArray){
+ bIncludeSequenceHeader = true;
+ sReturn = getCSSNameSpaceString() + "::uno::Sequence<" + _sTypeString + "> " + _sVariableName;
+ }
+ else{
+ if (bIsPrimitive){
+ sReturn = _sTypeString + " " + _sVariableName;
+ if (_bInitialize){
+ switch (_aTypeClass.getValue()){
+ case TypeClass.BOOLEAN_value:
+ sReturn = sReturn + " = false";
+ break;
+ case TypeClass.BYTE_value:
+ case TypeClass.UNSIGNED_SHORT_value:
+ case TypeClass.SHORT_value:
+ case TypeClass.LONG_value:
+ case TypeClass.UNSIGNED_LONG_value:
+ case TypeClass.HYPER_value:
+ case TypeClass.UNSIGNED_HYPER_value:
+ sReturn = sReturn + " = 0";
+ break;
+ case TypeClass.DOUBLE_value:
+ case TypeClass.FLOAT_value:
+ sReturn = sReturn + " = 0.0";
+ break;
+ case TypeClass.CHAR_value:
+ sReturn = sReturn + "'0'";
+ break;
+ case TypeClass.STRING_value:
+ sReturn = _sTypeString + " " + _sVariableName;
+ break;
+ default:
+ sReturn = _sTypeString + " " + _sVariableName;
+ System.out.println("Type " + _aTypeClass.getValue() + " not yet defined in 'getVariableDeclaration()'");
+ }
+ }
+ }
+ else{
+ sReturn = getCSSNameSpaceString() + "::uno::Reference<" + _sTypeString + "> " +_sVariableName;
+ }
+ }
+ return sReturn;
+ }
+
+ public String getArrayDeclaration(String _sVariableDeclaration){
+ this.bIncludeSequenceHeader = true;
+ String sReturn = "";
+ String[] sDeclarations = _sVariableDeclaration.split(" ");
+ if (sDeclarations.length == 2){
+ sReturn = getCSSNameSpaceString() +"::uno::Sequence<" + sDeclarations[1] + ">";
+ }
+ return sReturn;
+ }
+
+ public String getCommentSign(){
+ return "//";
+ }
+
+ }
+}
diff --git a/odk/examples/java/Inspector/SwingDialogProvider.java b/odk/examples/java/Inspector/SwingDialogProvider.java
new file mode 100644
index 000000000000..59a35726e11e
--- /dev/null
+++ b/odk/examples/java/Inspector/SwingDialogProvider.java
@@ -0,0 +1,442 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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 java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.event.ActionListener;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import javax.swing.ButtonGroup;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JDialog;
+import javax.swing.JEditorPane;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JRadioButtonMenuItem;
+import javax.swing.JTabbedPane;
+import javax.swing.KeyStroke;
+
+
+
+public class SwingDialogProvider implements XDialogProvider{
+
+ private JPopupMenu m_jPopupMenu = new JPopupMenu();
+ private XComponentContext m_xComponentContext;
+ private Inspector._Inspector m_oInspector;
+ private JDialog m_jInspectorDialog = new JDialog();
+ private JTabbedPane m_jTabbedPane1 = new JTabbedPane();
+ private Container cp;
+
+ private JMenu jMnuOptions = new JMenu("Options");
+ private JRadioButtonMenuItem jJavaMenuItem = null;
+ private JRadioButtonMenuItem jCPlusPlusMenuItem = null;
+ private JRadioButtonMenuItem jBasicMenuItem = null;
+
+ /** Creates a new instance of SwingPopupMentuProvider */
+ public SwingDialogProvider(Inspector._Inspector _oInspector, String _sTitle) {
+ m_oInspector = _oInspector;
+ m_xComponentContext = _oInspector.getXComponentContext();
+ insertMenus();
+ initializePopupMenu();
+ cp = m_jInspectorDialog.getContentPane();
+ cp.setLayout(new java.awt.BorderLayout(0, 10));
+ m_jTabbedPane1.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
+ m_jInspectorDialog.addWindowListener(new InspectorWindowAdapter());
+ m_jInspectorDialog.addComponentListener(new InspectorComponentAdapter());
+ m_jInspectorDialog.setTitle(_sTitle);
+ m_jInspectorDialog.setLocation(100, 50);
+ m_jInspectorDialog.getContentPane().add(m_jTabbedPane1);
+ }
+
+
+
+ public JDialog getDialog(){
+ return m_jInspectorDialog;
+ }
+
+
+ public void addMenuBar(JMenuBar _jMenuBar){
+ getDialog().setJMenuBar(_jMenuBar);
+ }
+
+
+ public void removeTabPaneByIndex(int _nIndex){
+ if (_nIndex > -1){
+ String sSelInspectorPanelTitle = m_jTabbedPane1.getTitleAt(_nIndex);
+ m_jTabbedPane1.remove(_nIndex);
+ m_oInspector.getInspectorPages().remove(sSelInspectorPanelTitle);
+ }
+ }
+
+
+ public void selectInspectorPageByIndex(int nTabIndex){
+ m_jTabbedPane1.setSelectedIndex(nTabIndex);
+ }
+
+
+ public int getInspectorPageCount(){
+ return m_jTabbedPane1.getTabCount();
+ }
+
+
+ public JTabbedPane getTabbedPane(){
+ return m_jTabbedPane1;
+ }
+
+
+ public InspectorPane getSelectedInspectorPage(){
+ int nIndex = m_jTabbedPane1.getSelectedIndex();
+ return getInspectorPage(nIndex);
+ }
+
+
+ public InspectorPane getInspectorPage(int _nIndex){
+ InspectorPane oInspectorPane = null;
+ if (_nIndex > -1){
+ JPanel jPnlContainerInspectorPanel = (JPanel) m_jTabbedPane1.getComponentAt(_nIndex);
+ String sInspectorPanelTitle = m_jTabbedPane1.getTitleAt(_nIndex);
+ oInspectorPane = (InspectorPane) m_oInspector.getInspectorPages().get(sInspectorPanelTitle);
+ }
+ return oInspectorPane;
+ }
+
+
+ public void removeTabPanes(){
+ int nCount = m_jTabbedPane1.getTabCount();
+ if (nCount > 0){
+ for (int i = nCount-1; i >= 0; i--){
+ removeTabPaneByIndex(i);
+ }
+ }
+ }
+
+ public void removeSelectedTabPane(){
+ int nIndex = getTabbedPane().getSelectedIndex();
+ removeTabPaneByIndex(nIndex);
+ }
+
+
+ private class InspectorComponentAdapter extends ComponentAdapter{
+ public void componentHidden(ComponentEvent e){
+ m_jInspectorDialog.pack();
+ m_jInspectorDialog.invalidate();
+
+ }
+
+ public void componentShown(ComponentEvent e){
+ m_jInspectorDialog.pack();
+ m_jInspectorDialog.invalidate();
+ }
+ }
+
+ private class InspectorWindowAdapter extends WindowAdapter{
+ public void windowClosed(WindowEvent e){
+ removeTabPanes();
+ m_oInspector.disposeHiddenDocuments();
+ }
+
+ public void windowClosing(WindowEvent e){
+ removeTabPanes();
+ m_oInspector.disposeHiddenDocuments();
+ }
+ }
+
+
+
+ private void initializePopupMenu(){
+ m_jPopupMenu.add(getInspectMenuItem("Inspect"));
+ m_jPopupMenu.add(getSourceCodeMenuItem(SADDTOSOURCECODE));
+ m_jPopupMenu.add(getInvokeMenuItem(SINVOKE));
+ m_jPopupMenu.addSeparator();
+ m_jPopupMenu.add(getHelpMenuItem("Help"));
+ }
+
+
+ private void addOpenDocumentMenu(JMenu _jMnuRoot){
+ ActionListener oActionListener = new ActionListener(){
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ String sTDocUrl = evt.getActionCommand();
+ m_oInspector.inspectOpenDocument(sTDocUrl);
+ }
+ };
+ String[] sTDocUrls = m_oInspector.getTDocUrls();
+ String[] sTDocTitles = m_oInspector.getTDocTitles(sTDocUrls);
+ for (int i = 0; i < sTDocUrls.length; i++){
+ addSingleMenuItem(_jMnuRoot, sTDocTitles[i], sTDocUrls[i], oActionListener);
+ }
+ }
+
+
+ private void addApplicationDocumentMenu(JMenu _jMnuRoot){
+ ActionListener oActionListener = new ActionListener(){
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ String sApplicationDocUrl = evt.getActionCommand();
+ m_oInspector.inspectOpenEmptyDocument(sApplicationDocUrl);
+ }
+ };
+ String[][] sApplUrls = m_oInspector.getApplicationUrls();
+ for (int i = 0; i < sApplUrls.length; i++){
+ addSingleMenuItem(_jMnuRoot, sApplUrls[i][1], sApplUrls[i][0], oActionListener);
+ }
+ }
+
+
+ private void addSingleMenuItem(JMenu _jMnuOpenDocs, String _sTitle, String _sActionCommand, ActionListener _oActionListener){
+ javax.swing.JMenuItem jMnuItemOpenDoc = new javax.swing.JMenuItem(_sTitle);
+ jMnuItemOpenDoc.setActionCommand(_sActionCommand);
+ jMnuItemOpenDoc.addActionListener(_oActionListener);
+ _jMnuOpenDocs.add(jMnuItemOpenDoc);
+ }
+
+
+ private void addHelpMenu(JMenuBar _jInspectMenuBar){
+ JMenu jMnuHelp = new JMenu("Help");
+ jMnuHelp.add(getHelpMenuItem("Idl-Help"));
+ _jInspectMenuBar.add(jMnuHelp);
+ }
+
+
+ private JMenuItem getHelpMenuItem(String _sMenuTitle){
+ JMenuItem jMnuHelpItem = new JMenuItem(_sMenuTitle);
+ jMnuHelpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
+ jMnuHelpItem.setMnemonic('H');
+ jMnuHelpItem.addActionListener(new ActionListener(){
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ m_oInspector.openIdlFileforSelectedNode();
+ }
+ });
+ return jMnuHelpItem;
+ }
+
+ private void addFileMenu(JMenuBar _jInspectMenuBar){
+ JMenu jMnuFile = new JMenu("File");
+ JMenuItem jMnuItemRemoveInspector = new JMenuItem("Remove");
+ jMnuItemRemoveInspector.addActionListener(new ActionListener(){
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ removeSelectedTabPane();
+ }
+ });
+ jMnuFile.add(jMnuItemRemoveInspector);
+ JMenuItem jMnuItemExit = new JMenuItem("Exit");
+ jMnuItemExit.addActionListener(new ActionListener(){
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ getDialog().dispose();
+ }
+ });
+ jMnuFile.add(jMnuItemExit);
+ _jInspectMenuBar.add(jMnuFile);
+ }
+
+ private JMenuItem getInspectMenuItem(String _sLabel){
+ JMenuItem jMnuSelectedObject = new JMenuItem(_sLabel);
+ jMnuSelectedObject.addActionListener(new ActionListener(){
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ m_oInspector.inspectSelectedNode();
+ }
+ });
+ return jMnuSelectedObject;
+ }
+
+
+ private JMenuItem getSourceCodeMenuItem(String _sLabel){
+ JMenuItem jMnuSelectedObject = new JMenuItem(_sLabel);
+ jMnuSelectedObject.addActionListener(new ActionListener(){
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ m_oInspector.addSourceCodeOfSelectedNode();
+ }
+ });
+ return jMnuSelectedObject;
+ }
+
+ private JMenuItem getInvokeMenuItem(String _sLabel){
+ JMenuItem jMnuSelectedObject = new JMenuItem(_sLabel);
+ jMnuSelectedObject.addActionListener(new ActionListener(){
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ m_oInspector.invokeSelectedMethod();
+ }
+ });
+ return jMnuSelectedObject;
+ }
+
+
+ private void addInspectMenu(JMenuBar _jInspectMenuBar){
+ JMenu jMnuInspect = new JMenu("Inspect");
+ addApplicationDocumentMenu(jMnuInspect);
+ jMnuInspect.addSeparator();
+ addGlobalServiceManagerMenu(jMnuInspect);
+ jMnuInspect.addSeparator();
+ jMnuInspect.add(getInspectMenuItem("Selected Object"));
+ jMnuInspect.addSeparator();
+ addOpenDocumentMenu(jMnuInspect);
+ _jInspectMenuBar.add(jMnuInspect);
+ }
+
+ public int getLanguage(){
+ return XLanguageSourceCodeGenerator.nJAVA;
+ }
+
+
+ public void selectSourceCodeLanguage(int _nLanguage){
+ switch (_nLanguage){
+ case XLanguageSourceCodeGenerator.nJAVA:
+ jJavaMenuItem.setSelected(true);
+ break;
+ case XLanguageSourceCodeGenerator.nCPLUSPLUS:
+ jCPlusPlusMenuItem.setSelected(true);
+ break;
+ case XLanguageSourceCodeGenerator.nBASIC:
+ jBasicMenuItem.setSelected(true);
+ break;
+ default:
+ System.out.println("Warning: Sourcecode language is not defined!");
+ }
+ }
+
+ private JRadioButtonMenuItem addLanguageMenuItem(ButtonGroup _group, String _sLanguageTitle, boolean _bSelect, char _sMnemonic, final int _nLanguage){
+ JRadioButtonMenuItem jMenuItem = new JRadioButtonMenuItem(_sLanguageTitle, _bSelect);
+ jMenuItem.setMnemonic(_sMnemonic);
+ _group.add(jMenuItem);
+ jMenuItem.addActionListener(new ActionListener(){
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ m_oInspector.setSourceCodeLanguage(_nLanguage);
+ }
+ });
+ return jMenuItem;
+ }
+
+
+ public String getIDLPath(){
+ return this.m_oInspector.getIDLPath();
+ }
+
+ private void addOptionsMenu(JMenuBar _jInspectMenuBar){
+ ButtonGroup oButtonGroup = new ButtonGroup();
+ jJavaMenuItem = addLanguageMenuItem(oButtonGroup, "Generate Java Sourcecode", true, 'J', XLanguageSourceCodeGenerator.nJAVA);
+ jMnuOptions.add(jJavaMenuItem);
+ jCPlusPlusMenuItem = addLanguageMenuItem(oButtonGroup, "Generate C++ Sourcecode", false, 'C', XLanguageSourceCodeGenerator.nCPLUSPLUS);
+ jMnuOptions.add(jCPlusPlusMenuItem);
+ jBasicMenuItem = addLanguageMenuItem(oButtonGroup, "Generate OpenOffice.org Basic Sourcecode", false, 'B', XLanguageSourceCodeGenerator.nBASIC);
+ jMnuOptions.add(jBasicMenuItem);
+ jMnuOptions.addSeparator();
+ JMenuItem jMenuItem = new JMenuItem("Path to SDK-Installation");
+ jMenuItem.setMnemonic('I');
+ jMenuItem.addActionListener(new ActionListener(){
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ m_oInspector.assignSDKPath();
+ }
+ });
+
+ jMnuOptions.add(jMenuItem);
+ _jInspectMenuBar.add(jMnuOptions);
+ }
+
+
+ private void insertMenus(){
+ JMenuBar jMenuBar1 = new javax.swing.JMenuBar();
+ addFileMenu(jMenuBar1);
+ addInspectMenu(jMenuBar1);
+ JMenu jMnuEdit = new JMenu("Edit");
+ JMenu jMnuView = new JMenu("View");
+ addOptionsMenu(jMenuBar1);
+ jMenuBar1.setFont(new java.awt.Font("Dialog", 0, 12));
+ jMenuBar1.add(jMnuEdit);
+ jMenuBar1.add(jMnuView);
+ addHelpMenu(jMenuBar1);
+ addMenuBar(jMenuBar1);
+ }
+
+ private void addGlobalServiceManagerMenu(JMenu _jMnuRoot){
+ JMenuItem jMnuGlobalServiceManager = new JMenuItem("Global Service Manager");
+ jMnuGlobalServiceManager.addActionListener(new ActionListener(){
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ m_oInspector.inspect(m_xComponentContext.getServiceManager(), "Global ServiceManager");
+ }
+ });
+ _jMnuRoot.add(jMnuGlobalServiceManager);
+ }
+
+
+
+ public void enablePopupMenuItem(String _sMenuTitle, boolean _bdoEnable){
+ Component[] oComponents = m_jPopupMenu.getComponents();
+ for (int i = 0; i < oComponents.length; i++){
+ if (oComponents[i] instanceof JMenuItem){
+ JMenuItem jMenuItem = (JMenuItem) oComponents[i];
+ if (jMenuItem.getText().equals(_sMenuTitle)){
+ jMenuItem.setEnabled(_bdoEnable);
+ }
+ }
+ }
+ }
+
+
+ public void showPopUpMenu(Object _invoker, int x, int y) throws ClassCastException{
+ if (_invoker instanceof Component){
+ m_jPopupMenu.show((Component) _invoker, x, y);
+ }
+ }
+
+
+ public void show(int _nPageIndex){
+ Dimension aDimension = m_jInspectorDialog.getSize();
+ selectInspectorPageByIndex(_nPageIndex);
+ if (_nPageIndex > 0){
+ m_jInspectorDialog.setSize(aDimension);
+ }
+ else{
+ m_jInspectorDialog.pack();
+ }
+// m_jInspectorDialog.paint(m_jInspectorDialog.getGraphics());
+ m_jInspectorDialog.setVisible(true);
+ }
+
+ public void paint(){
+ m_jTabbedPane1.paintImmediately(m_jTabbedPane1.getBounds());
+ }
+
+
+ public void addInspectorPage(String _sTitle, Object _oContainer) throws ClassCastException{
+ if (_oContainer instanceof Component){
+ m_jTabbedPane1.addTab(_sTitle, (Component) _oContainer);
+ }
+ }
+}
diff --git a/odk/examples/java/Inspector/SwingTreeControlProvider.java b/odk/examples/java/Inspector/SwingTreeControlProvider.java
new file mode 100644
index 000000000000..2405e8bc36ce
--- /dev/null
+++ b/odk/examples/java/Inspector/SwingTreeControlProvider.java
@@ -0,0 +1,427 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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.Property;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.NullPointerException;
+import com.sun.star.reflection.XConstantTypeDescription;
+import com.sun.star.reflection.XIdlMethod;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+import javax.swing.JScrollBar;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.JTree;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.event.TreeWillExpandListener;
+import javax.swing.tree.DefaultTreeSelectionModel;
+import javax.swing.tree.ExpandVetoException;
+import javax.swing.tree.TreePath;
+import javax.swing.tree.TreeSelectionModel;
+
+
+
+public class SwingTreeControlProvider implements XTreeControlProvider{
+ private JTextArea jtxtGeneratedSourceCode = new JTextArea();
+ private JTextField jtxtFilter = new JTextField();
+ private javax.swing.JLabel jlblFilter = new javax.swing.JLabel("Set a filter");
+ private JPanel jPnlBottom = new JPanel(new BorderLayout());
+ private JPanel jPanelProgress = new JPanel(new BorderLayout());
+ private JPanel jPnlPath = new JPanel(new BorderLayout());
+ private JLabel jLblPath = new JLabel("Generated source code");
+ private JProgressBar jProgressBar1 = new JProgressBar();
+ private JTree jTree = new javax.swing.JTree();
+ private XDialogProvider m_xDialogProvider;
+ private HideableTreeModel treeModel;
+ private UnoTreeRenderer oUnoTreeRenderer;
+ private InspectorPane m_oInspectorPane;
+ private Object oUserDefinedObject = null;
+ private boolean bIsUserDefined = false;
+ private SwingUnoNode oRootNode;
+
+ private final int nDIALOGWIDTH = 800;
+
+
+
+ public SwingTreeControlProvider(XDialogProvider _xDialogProvider){
+ m_xDialogProvider = _xDialogProvider;
+ }
+
+
+ public void addInspectorPane(InspectorPane _oInspectorPane){
+ m_oInspectorPane = _oInspectorPane;
+ }
+
+ public InspectorPane getInspectorPane() throws NullPointerException{
+ if (m_oInspectorPane == null){
+ throw new NullPointerException("InspectorPage has not been added to TreeControl");
+ }
+ else{
+ return m_oInspectorPane;
+ }
+ }
+
+ private void ComponentSelector(Object _oRootObject, String _sRootTreeNodeName) {
+ String sTreeNodeName = _sRootTreeNodeName;
+ oRootNode = new SwingUnoNode(_oRootObject);
+ oRootNode.setLabel(_sRootTreeNodeName);
+ treeModel = new HideableTreeModel(oRootNode);
+ jTree.setModel(treeModel);
+ jTree.setRootVisible(true);
+ jTree.setVisible(true);
+ oRootNode.setFoldable(true);
+ enableFilterElements(null);
+ }
+
+
+
+ private void insertTopPanel(JPanel _jPnlCenter){
+ javax.swing.JPanel jPnlTop = new javax.swing.JPanel(new BorderLayout(10, 10));
+ jPnlTop.setPreferredSize(new java.awt.Dimension(nDIALOGWIDTH, 20));
+ jlblFilter.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+ jlblFilter.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
+ jPnlTop.add(jlblFilter, java.awt.BorderLayout.WEST);
+ jtxtFilter.setHorizontalAlignment(javax.swing.JTextField.LEFT);
+ jtxtFilter.setPreferredSize(new java.awt.Dimension(200, 10));
+ jtxtFilter.addKeyListener(new InspectorKeyFilterAdapter());
+ jPnlTop.add(jtxtFilter, java.awt.BorderLayout.CENTER);
+ _jPnlCenter.add(jPnlTop, java.awt.BorderLayout.NORTH);
+ }
+
+
+ private void insertBottomPanel(JSplitPane _jSplitPane){ //JPanel _jPnlCenter){
+ jtxtGeneratedSourceCode.setTabSize(4);
+ jtxtGeneratedSourceCode.getAccessibleContext().setAccessibleName("generated SourceCode");
+ JScrollPane jScrollPane = new JScrollPane(jtxtGeneratedSourceCode);
+ jScrollPane.setPreferredSize(new Dimension(nDIALOGWIDTH,205));
+ jtxtGeneratedSourceCode.setEditable(false);
+ _jSplitPane.setBottomComponent(jScrollPane);
+ }
+
+ private void insertBorderPanes(Container _cp){
+ JPanel jPnlEast = new JPanel(new BorderLayout());
+ JPanel jPnlNorth = new JPanel(new BorderLayout());
+ JPanel jPnlSouth = new JPanel(new BorderLayout());
+ JPanel jPnlWest = new JPanel(new BorderLayout());
+ _cp.add(jPnlNorth, java.awt.BorderLayout.NORTH);
+ jPnlWest.setPreferredSize(new java.awt.Dimension(10, 10));
+ _cp.add(jPnlWest, java.awt.BorderLayout.WEST);
+ jPnlEast.setPreferredSize(new java.awt.Dimension(10, 10));
+ _cp.add(jPnlEast, java.awt.BorderLayout.EAST);
+ jPnlSouth.setPreferredSize(new java.awt.Dimension(10, 10));
+ _cp.add(jPnlSouth, java.awt.BorderLayout.SOUTH);
+ }
+
+
+ public String enableFilterElements(XUnoNode _oUnoNode){
+ String sFilter ="";
+ boolean bIsFacetteNode = isFacetteNode(_oUnoNode);
+ this.jtxtFilter.setEnabled(bIsFacetteNode);
+ this.jlblFilter.setEnabled(bIsFacetteNode);
+ sFilter = m_oInspectorPane.getFilter(_oUnoNode);
+ jtxtFilter.setText(sFilter);
+ return sFilter;
+ }
+
+
+ private class InspectorKeyFilterAdapter extends KeyAdapter{
+ public void keyReleased(KeyEvent e){
+ String sFilter = jtxtFilter.getText();
+ SwingTreePathProvider oSwingTreePathProvider = new SwingTreePathProvider(jTree.getSelectionPath());
+ XUnoNode oUnoNode = oSwingTreePathProvider.getLastPathComponent();
+ if (oUnoNode instanceof XUnoFacetteNode){
+ m_oInspectorPane.applyFilter((XUnoFacetteNode) oUnoNode, sFilter);
+ }
+ }
+ }
+
+
+
+ /** Inspect the given object for methods, properties, interfaces, and
+ * services.
+ * @param a The object to inspect
+ * @throws RuntimeException If
+ */
+ public Object inspect(java.lang.Object _oUserDefinedObject, String _sTitle) throws com.sun.star.uno.RuntimeException {
+ JPanel jPnlContainer = new javax.swing.JPanel(new BorderLayout(10, 10));
+ try {
+ javax.swing.JPanel jPnlCenter = new javax.swing.JPanel();
+ bIsUserDefined = (_oUserDefinedObject != null);
+ if (bIsUserDefined){
+ oUserDefinedObject = _oUserDefinedObject;
+ m_oInspectorPane.setTitle(_sTitle);
+ }
+ javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane();
+ TreeSelectionModel tsm = new DefaultTreeSelectionModel();
+ tsm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+ jTree.setSelectionModel(tsm);
+ jTree.setVisible(false);
+ jPnlCenter.setLayout(new java.awt.BorderLayout(10, 10));
+ jPnlCenter.getAccessibleContext().setAccessibleName("inspection tab view");
+ insertTopPanel(jPnlCenter);
+ jScrollPane1.setViewportView(jTree);
+ jScrollPane1.setPreferredSize(new java.awt.Dimension(600, 600));
+ jScrollPane1.getAccessibleContext().setAccessibleName("API view scroll pane");
+
+ JScrollBar jHScrollBar = jScrollPane1.createHorizontalScrollBar();
+ jHScrollBar.getAccessibleContext().setAccessibleName("API view horizontal scroll bar");
+ jScrollPane1.setHorizontalScrollBar(jHScrollBar);
+
+ JScrollBar jVScrollBar = jScrollPane1.createVerticalScrollBar();
+ jVScrollBar.getAccessibleContext().setAccessibleName("API view vertical scroll bar");
+ jScrollPane1.setVerticalScrollBar(jVScrollBar);
+
+ JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
+ jSplitPane.setTopComponent(jScrollPane1);
+ jPnlCenter.add(jSplitPane, java.awt.BorderLayout.CENTER);
+ jSplitPane.setDividerLocation(500);
+ insertBottomPanel(jSplitPane);
+ UnoTreeRenderer oUnoTreeRenderer = new UnoTreeRenderer();
+ jTree.setCellRenderer(oUnoTreeRenderer);
+ jTree.addTreeSelectionListener(
+ new TreeSelectionListener() {
+ public void valueChanged(TreeSelectionEvent event) {
+ TreePath tp = event.getNewLeadSelectionPath();
+ if (tp != null){
+ XUnoNode oUnoNode = getSelectedNode();
+ String sFilter = enableFilterElements(oUnoNode);
+ }
+ }
+ }
+ );
+ // Add KeyListener for help
+ jTree.addKeyListener( new java.awt.event.KeyAdapter() {
+ public void keyReleased(java.awt.event.KeyEvent event) {
+ if ( event.getKeyCode() == KeyEvent.VK_F1 ) {
+ // function key F1 pressed
+ TreePath aTreePath = jTree.getSelectionPath();
+ SwingUnoNode oUnoNode = (SwingUnoNode) aTreePath.getLastPathComponent();
+ oUnoNode.openIdlDescription(m_xDialogProvider.getIDLPath());
+ }
+ }
+ });
+ jTree.addMouseListener(new MouseAdapter() {
+ public void mousePressed (MouseEvent e) {
+ if (e.isPopupTrigger()){
+ m_oInspectorPane.showPopUpMenu(e.getComponent(), e.getX(), e.getY());
+ }
+ //unfortunately under Windows the method "isPopupTrigger" always returns false
+ else if ((e.getModifiersEx() & MouseEvent.BUTTON3_DOWN_MASK) == MouseEvent.BUTTON3_DOWN_MASK){
+ m_oInspectorPane.showPopUpMenu(e.getComponent(), e.getX(), e.getY());
+ }
+ }
+ });
+ jPnlContainer.add(jPnlCenter, java.awt.BorderLayout.CENTER);
+ insertBorderPanes(jPnlContainer);
+ if (this.bIsUserDefined){
+ ComponentSelector(oUserDefinedObject, m_oInspectorPane.getTitle());
+ }
+ m_xDialogProvider.addInspectorPage(m_oInspectorPane.getTitle(), jPnlContainer);
+ addTreeExpandListener();
+ }
+ catch( Exception exception ) {
+ exception.printStackTrace(System.out);
+ }
+ return jPnlContainer;
+ }
+
+ public HideableTreeModel getModel(){
+ return treeModel;
+ }
+
+
+ public void addTreeExpandListener(){
+ jTree.addTreeWillExpandListener(
+ new TreeWillExpandListener() {
+ public void treeWillExpand(javax.swing.event.TreeExpansionEvent event) throws javax.swing.tree.ExpandVetoException {
+ SwingTreePathProvider oSwingTreePathProvider = new SwingTreePathProvider(event.getPath());
+ XUnoNode oUnoNode = oSwingTreePathProvider.getLastPathComponent();
+ if (!m_oInspectorPane.expandNode(oUnoNode, oSwingTreePathProvider)){
+ throw new ExpandVetoException(event);
+ }
+ }
+
+ public void treeWillCollapse( javax.swing.event.TreeExpansionEvent evt) throws javax.swing.tree.ExpandVetoException {
+ }
+ });
+ }
+
+
+ public void setSourceCode(String _sSourceCode){
+ jtxtGeneratedSourceCode.setText(_sSourceCode);
+ }
+
+
+ public XTreePathProvider getSelectedPath(){
+ return new SwingTreePathProvider(jTree.getSelectionPath());
+ }
+
+
+ public void expandPath(XTreePathProvider _xTreePathProvider) throws ClassCastException{
+ SwingTreePathProvider oSwingTreePathProvider = (SwingTreePathProvider) _xTreePathProvider;
+ jTree.expandPath(oSwingTreePathProvider.getSwingTreePath());
+ }
+
+
+ public XUnoNode getSelectedNode(){
+ XUnoNode oUnoNode = null;
+ TreePath aTreePath = jTree.getSelectionPath();
+ Object oNode = aTreePath.getLastPathComponent();
+ if (oNode instanceof XUnoNode){
+ oUnoNode = (XUnoNode) oNode;
+ }
+ return oUnoNode;
+ }
+
+
+ public void nodeInserted(XUnoNode _oParentNode, XUnoNode _oChildNode, int index) {
+ getModel().nodeInserted(_oParentNode, _oChildNode, _oParentNode.getChildCount()-1);
+ }
+
+
+ public void nodeChanged(XUnoNode _oNode) {
+ getModel().nodeChanged(_oNode);
+ }
+
+
+ public boolean setNodeVisible(Object node, boolean v) {
+ return getModel().setNodeVisible(node, v);
+ }
+
+
+ public boolean isPropertyNode(XUnoNode _oUnoNode){
+ return (_oUnoNode instanceof SwingUnoPropertyNode);
+ }
+
+
+ public boolean isMethodNode(XUnoNode _oUnoNode){
+ return (_oUnoNode instanceof SwingUnoMethodNode);
+ }
+
+
+ public boolean isFacetteNode(XUnoNode _oUnoNode){
+ return (_oUnoNode instanceof SwingUnoFacetteNode);
+ }
+
+
+ public XUnoNode addUnoNode(Object _oUnoObject){
+ return new SwingUnoNode(_oUnoObject);
+ }
+
+
+ public XUnoNode addUnoNode(Object _oUnoObject, Type _aType){
+ return new SwingUnoNode(_oUnoObject, _aType);
+ }
+
+
+ public XUnoFacetteNode addUnoFacetteNode(XUnoNode _oParentNode, String _sNodeDescription, Object _oUnoObject){
+ SwingUnoFacetteNode oSwingUnoFacetteNode = new SwingUnoFacetteNode(_oUnoObject);
+ oSwingUnoFacetteNode.setLabel(_sNodeDescription);
+ if (_oParentNode != null){
+ ((SwingUnoNode) _oParentNode).addChildNode(oSwingUnoFacetteNode);
+ }
+ return oSwingUnoFacetteNode;
+ }
+
+
+ public XUnoMethodNode addMethodNode(Object _objectElement, XIdlMethod _xIdlMethod){
+ SwingUnoMethodNode oSwingUnoMethodNode = new SwingUnoMethodNode(_xIdlMethod, _objectElement, m_xDialogProvider);
+ return oSwingUnoMethodNode;
+ }
+
+
+ public XUnoPropertyNode addUnoPropertyNodeWithName(Property _aProperty){
+ SwingUnoPropertyNode oUnoPropertyNode = new SwingUnoPropertyNode(_aProperty);
+ oUnoPropertyNode.setLabel("Name: " + _aProperty.Name);
+ return oUnoPropertyNode;
+ }
+
+
+ public XUnoPropertyNode addUnoPropertyNodeWithHandle(Property _aProperty){
+ SwingUnoPropertyNode oUnoPropertyNode = new SwingUnoPropertyNode(_aProperty);
+ oUnoPropertyNode.setLabel("Handle: " + _aProperty.Handle);
+ return oUnoPropertyNode;
+ }
+
+
+ public XUnoPropertyNode addUnoPropertyNodeWithType(Property _aProperty){
+ SwingUnoPropertyNode oUnoPropertyNode = new SwingUnoPropertyNode(_aProperty);
+ oUnoPropertyNode.setLabel("Type: " + _aProperty.Type.getTypeName());
+ return oUnoPropertyNode;
+ }
+
+
+ public XUnoPropertyNode addUnoPropertyNodeWithAttributesDescription(Property _aProperty){
+ SwingUnoPropertyNode oUnoPropertyNode = new SwingUnoPropertyNode(_aProperty);
+ XConstantTypeDescription[] xPropertyAttributesTypeDescriptions = Introspector.getIntrospector().getFieldsOfConstantGroup("com.sun.star.beans.PropertyAttribute");
+ String sDisplay = Introspector.getIntrospector().getConstantDisplayString((int) _aProperty.Attributes, xPropertyAttributesTypeDescriptions, "Attributes: ");
+ oUnoPropertyNode.setLabel(sDisplay);
+ return oUnoPropertyNode;
+ }
+
+
+ public XUnoPropertyNode addUnoPropertyNode(Object _oUnoObject, Property _aProperty){
+ SwingUnoPropertyNode oUnoPropertyNode = new SwingUnoPropertyNode(_aProperty, _oUnoObject, null);
+ oUnoPropertyNode.setPropertyNodeType(XUnoPropertyNode.nPROPERTYSETINFOTYPE);
+ oUnoPropertyNode.setLabel(UnoPropertyNode.getStandardPropertyDescription(_aProperty, null));
+ return oUnoPropertyNode;
+ }
+
+
+ public XUnoPropertyNode addUnoPropertyNode(Object _oUnoObject, Property _aProperty, Object _oUnoReturnObject){
+ SwingUnoPropertyNode oUnoPropertyNode = new SwingUnoPropertyNode(_aProperty, _oUnoObject, _oUnoReturnObject);
+ oUnoPropertyNode.setLabel(UnoPropertyNode.getStandardPropertyDescription(_aProperty, _oUnoReturnObject));
+ return oUnoPropertyNode;
+ }
+
+
+ public XUnoPropertyNode addUnoPropertyNode(Object _oUnoObject, PropertyValue _aPropertyValue, Object _oReturnObject){
+ SwingUnoPropertyNode oUnoPropertyNode = new SwingUnoPropertyNode(_aPropertyValue, _oUnoObject, _oReturnObject);
+ oUnoPropertyNode.setLabel(UnoPropertyNode.getStandardPropertyValueDescription(_aPropertyValue));
+ return oUnoPropertyNode;
+ }
+}
diff --git a/odk/examples/java/Inspector/SwingTreePathProvider.java b/odk/examples/java/Inspector/SwingTreePathProvider.java
new file mode 100644
index 000000000000..02829682bc50
--- /dev/null
+++ b/odk/examples/java/Inspector/SwingTreePathProvider.java
@@ -0,0 +1,40 @@
+import javax.swing.tree.TreePath;
+
+
+public class SwingTreePathProvider implements XTreePathProvider {
+ TreePath m_aTreePath;
+
+ /** Creates a new instance of TreePathProvider */
+ public SwingTreePathProvider(TreePath _aTreePath) {
+ m_aTreePath = _aTreePath;
+ }
+
+
+ public XUnoNode getLastPathComponent(){
+ return (XUnoNode) m_aTreePath.getLastPathComponent();
+ }
+
+
+ public XUnoNode getPathComponent(int i){
+ return (XUnoNode) m_aTreePath.getPathComponent(i);
+ }
+
+ public int getPathCount(){
+ return m_aTreePath.getPathCount();
+ }
+
+
+ public XTreePathProvider getParentPath(){
+ return new SwingTreePathProvider(m_aTreePath.getParentPath());
+ }
+
+
+ public XTreePathProvider pathByAddingChild(XUnoNode _oUnoNode){
+ TreePath aTreePath = m_aTreePath.pathByAddingChild(_oUnoNode);
+ return new SwingTreePathProvider(aTreePath);
+ }
+
+ public TreePath getSwingTreePath(){
+ return m_aTreePath;
+ }
+}
diff --git a/odk/examples/java/Inspector/SwingUnoFacetteNode.java b/odk/examples/java/Inspector/SwingUnoFacetteNode.java
new file mode 100644
index 000000000000..96374f1e5b9e
--- /dev/null
+++ b/odk/examples/java/Inspector/SwingUnoFacetteNode.java
@@ -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.
+ *
+ *************************************************************************/
+
+import com.sun.star.reflection.XIdlMethod;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.XComponentContext;
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public class SwingUnoFacetteNode extends SwingUnoNode implements XUnoFacetteNode{
+ String m_sFilter = "";
+
+ /** Creates a new instance of UnoMethodNode */
+ public SwingUnoFacetteNode(Object _oUnoObject){
+ super(_oUnoObject);
+ setFoldable(true);
+ }
+
+
+ public String getFilter(){
+ return m_sFilter;
+ }
+
+ public void setFilter(String _sFilter){
+ m_sFilter = _sFilter;
+ }
+
+ public String getName(){
+ return toString();
+ }
+
+// TODO The implementation of the following methods is not really robust and should be changed!!!
+ public boolean isMethodNode(){
+ return ((String) getUserObject()).equals(SMETHODDESCRIPTION);
+ }
+
+ public boolean isPropertyNode(){
+ String sNodeDescription = (String) getUserObject();
+ return ((sNodeDescription.equals(SPROPERTYDESCRIPTION)) || (sNodeDescription.equals(SPROPERTYINFODESCRIPTION)) || (sNodeDescription.equals(SPROPERTYVALUEDESCRIPTION)));
+ }
+
+ public boolean isContainerNode(){
+ return ((String) getUserObject()).equals(SCONTAINERDESCRIPTION);
+ }
+
+ public boolean isServiceNode(){
+ return ((String) getUserObject()).equals(SSERVICEDESCRIPTION);
+ }
+
+ public boolean isInterfaceNode(){
+ return ((String) getUserObject()).equals(SINTERFACEDESCRIPTION);
+ }
+}
+
diff --git a/odk/examples/java/Inspector/SwingUnoMethodNode.java b/odk/examples/java/Inspector/SwingUnoMethodNode.java
new file mode 100644
index 000000000000..c01c6074b795
--- /dev/null
+++ b/odk/examples/java/Inspector/SwingUnoMethodNode.java
@@ -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.
+ *
+ *************************************************************************/
+import com.sun.star.reflection.XIdlMethod;
+import com.sun.star.uno.TypeClass;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Vector;
+
+
+
+public class SwingUnoMethodNode extends SwingUnoNode implements ActionListener, XUnoMethodNode{
+
+ private UnoMethodNode m_oUnoMethodNode;
+ private XDialogProvider m_xDialogProvider = null;
+
+ public SwingUnoMethodNode(XIdlMethod _xIdlMethod, Object _oUnoObject, XDialogProvider _xDialogProvider) {
+ super(_oUnoObject);
+ m_oUnoMethodNode = new UnoMethodNode(_xIdlMethod, _oUnoObject, this);
+ m_xDialogProvider = _xDialogProvider;
+ setUserObject(m_oUnoMethodNode.getNodeDescription());
+ if (m_oUnoMethodNode.isFoldable()){
+ setFoldable(true);
+ }
+ }
+
+ public boolean isFoldable(){
+ return m_oUnoMethodNode.isFoldable();
+ }
+
+ public String getName(){
+ return m_oUnoMethodNode.getName();
+ }
+
+ public String getClassName(){
+ String sClassName = "";
+ sClassName = getXIdlMethod().getDeclaringClass().getName();
+ if (sClassName.equals("")){
+ sClassName = super.getClassName();
+ }
+ return sClassName;
+ }
+
+ public String getAnchor(){
+ return m_oUnoMethodNode.getAnchor();
+ }
+
+ public Object invoke(Object _oUnoObject, Object[] _oParameters) throws com.sun.star.uno.Exception{
+ return m_oUnoMethodNode.invoke(_oUnoObject, _oParameters);
+ }
+
+
+ public Object[] getLastParameterObjects(){
+ return m_oUnoMethodNode.getLastParameterObjects();
+ }
+
+ public Object getLastUnoReturnObject(){
+ return m_oUnoMethodNode.getLastUnoReturnObject();
+ }
+
+ public TypeClass getTypeClass() {
+ return m_oUnoMethodNode.getTypeClass();
+ }
+
+ public XIdlMethod getXIdlMethod() {
+ return m_oUnoMethodNode.getXIdlMethod();
+ }
+
+ public boolean hasParameters() {
+ return m_oUnoMethodNode.hasParameters();
+ }
+
+ public Object invoke() throws com.sun.star.uno.Exception{
+ return m_oUnoMethodNode.invoke();
+ }
+
+ public boolean isInvoked() {
+ return m_oUnoMethodNode.isInvoked();
+ }
+
+ public boolean isInvokable(){
+ return m_oUnoMethodNode.isInvokable();
+ }
+
+ public boolean isPrimitive() {
+ return m_oUnoMethodNode.isPrimitive();
+ }
+
+ public void actionPerformed(ActionEvent e){
+ openIdlDescription(m_xDialogProvider.getIDLPath());
+ }
+
+ public Vector getMethodObjects(){
+ MethodParametersDialog oMethodParametersDialog = new MethodParametersDialog(this);
+ oMethodParametersDialog.addActionListener(this);
+ return oMethodParametersDialog.getMethodObjects();
+ }
+
+
+ public String getParameterDescription(){
+ return m_oUnoMethodNode.getParameterDescription();
+ }
+
+
+ public String getStandardMethodDescription(){
+ return m_oUnoMethodNode.getStandardMethodDescription();
+ }
+} \ No newline at end of file
diff --git a/odk/examples/java/Inspector/SwingUnoNode.java b/odk/examples/java/Inspector/SwingUnoNode.java
new file mode 100644
index 000000000000..19295cc4b4d0
--- /dev/null
+++ b/odk/examples/java/Inspector/SwingUnoNode.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 com.sun.star.uno.Type;
+import javax.swing.tree.TreeNode;
+
+
+public class SwingUnoNode extends HideableMutableTreeNode implements XUnoNode{
+ private UnoNode m_oUnoNode;
+
+ /** Creates a new instance of SwingUnoNode */
+ public SwingUnoNode(Object _oUnoObject) {
+ super();
+ m_oUnoNode = new UnoNode(_oUnoObject);
+ }
+
+
+ public SwingUnoNode(Object _oUnoObject, Type _aType) {
+ super();
+ m_oUnoNode = new UnoNode(_oUnoObject, _aType);
+ if (_aType != null){
+ this.setLabel(_aType.getTypeName());
+ }
+ }
+
+
+ public Object getUnoObject(){
+ return m_oUnoNode.getUnoObject();
+ }
+
+ public void setVisible(String _sFilter){
+ boolean bisVisible = isFilterApplicable(_sFilter);
+ super.setVisible(bisVisible);
+ }
+
+ public boolean isFilterApplicable(String _sFilter) {
+ return m_oUnoNode.isFilterApplicable(_sFilter, getName());
+ }
+
+ public void setParameterObjects(Object[] _oParamObjects) {
+ m_oUnoNode.setParameterObjects(_oParamObjects);
+ }
+
+ public void openIdlDescription(String _SDKPath) {
+ m_oUnoNode.openIdlDescription(_SDKPath, getClassName(), getAnchor());
+ }
+
+ public Object[] getParameterObjects() {
+ return m_oUnoNode.getParameterObjects();
+ }
+
+ public String getClassName(){
+ String sClassName = m_oUnoNode.getClassName();
+ if (sClassName.equals("")){
+ TreeNode oTreeNode = getParent();
+ if (oTreeNode != null){
+ if (oTreeNode instanceof XUnoNode){
+ SwingUnoNode oUnoNode = (SwingUnoNode) oTreeNode;
+ sClassName = oUnoNode.getClassName();
+ }
+ }
+ }
+ return sClassName;
+ }
+
+ public String getAnchor() {
+ return m_oUnoNode.getAnchor();
+ }
+
+
+ public void setFoldable(boolean _bIsFoldable){
+ if (_bIsFoldable){
+ addDummyNode();
+ }
+ else{
+ removeDummyNode();
+ }
+ }
+
+
+ public XUnoNode getParentNode(){
+ return (SwingUnoNode) super.getParent();
+ }
+
+
+ public void addChildNode(XUnoNode _xUnoNode) {
+ super.add((SwingUnoNode) _xUnoNode);
+ }
+
+ public void setLabel(String _sLabel){
+ super.setUserObject(_sLabel);
+ this.m_oUnoNode.setLabel(_sLabel);
+ }
+
+ public String getLabel(){
+ return (String) super.getUserObject();
+ }
+
+
+ public int getChildCount(){
+ return super.getChildCount();
+ }
+
+
+ public XUnoNode getChild(int _i){
+ return (SwingUnoNode) super.getChildAt(_i);
+ }
+
+ public int getNodeType(){
+ return m_oUnoNode.getNodeType();
+ }
+
+ public void setNodeType(int _nNodeType){
+ m_oUnoNode.setNodeType(_nNodeType);
+ }
+
+
+ public String getName(){
+ return getClassName();
+ }
+
+
+ public Type getUnoType(){
+ return m_oUnoNode.getUnoType();
+ }
+}
diff --git a/odk/examples/java/Inspector/SwingUnoPropertyNode.java b/odk/examples/java/Inspector/SwingUnoPropertyNode.java
new file mode 100644
index 000000000000..f72229db6f10
--- /dev/null
+++ b/odk/examples/java/Inspector/SwingUnoPropertyNode.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.
+ *
+ *************************************************************************/
+import com.sun.star.beans.Property;
+import com.sun.star.beans.PropertyValue;
+
+public class SwingUnoPropertyNode extends SwingUnoNode implements XUnoPropertyNode{
+
+ private UnoPropertyNode m_oUnoPropertyNode = null;
+
+
+ public SwingUnoPropertyNode(Property _aProperty, Object _oUnoObject, Object _oUnoReturnObject) {
+ super(_oUnoObject);
+ m_oUnoPropertyNode = new UnoPropertyNode(_aProperty, _oUnoObject, _oUnoReturnObject);
+ super.setUserObject(m_oUnoPropertyNode.getLabel());
+ setFoldable(m_oUnoPropertyNode.isFoldable());
+ }
+
+
+ public SwingUnoPropertyNode(Property _aProperty){
+ super(null);
+ m_oUnoPropertyNode = new UnoPropertyNode(_aProperty);
+ }
+
+
+ public SwingUnoPropertyNode(PropertyValue _aPropertyValue, Object _oUnoObject, Object _oUnoReturnObject) {
+ super(_oUnoObject);
+ m_oUnoPropertyNode = new UnoPropertyNode(_aPropertyValue, _oUnoObject, _oUnoReturnObject);
+ }
+
+ public String getName(){
+ return m_oUnoPropertyNode.getName();
+ }
+
+
+ public Object getUnoReturnObject(){
+ return m_oUnoPropertyNode.getUnoReturnObject();
+ }
+
+
+ public String getClassName(){
+ String sClassName = m_oUnoPropertyNode.getClassName();
+ if (sClassName.equals("")){
+ sClassName = super.getClassName();
+ }
+ return sClassName;
+ }
+
+ public String getAnchor(){
+ return m_oUnoPropertyNode.getAnchor();
+ }
+
+ public int getPropertyNodeType(){
+ return m_oUnoPropertyNode.getPropertyNodeType();
+ }
+
+
+ public void setPropertyNodeType(int _nPropertyType){
+ m_oUnoPropertyNode.setPropertyNodeType(_nPropertyType);
+ }
+
+ public Property getProperty(){
+ return m_oUnoPropertyNode.getProperty();
+ }
+
+}
diff --git a/odk/examples/java/Inspector/TDocSupplier.java b/odk/examples/java/Inspector/TDocSupplier.java
new file mode 100644
index 000000000000..1022507eb387
--- /dev/null
+++ b/odk/examples/java/Inspector/TDocSupplier.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.beans.Property;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.sdbc.XRow;
+import com.sun.star.ucb.Command;
+import com.sun.star.ucb.XCommandProcessor;
+import com.sun.star.ucb.XContent;
+import com.sun.star.ucb.XContentIdentifier;
+import com.sun.star.ucb.XContentIdentifierFactory;
+import com.sun.star.ucb.XContentProvider;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import javax.swing.JOptionPane;
+
+
+public class TDocSupplier {
+ private XMultiComponentFactory m_xMultiComponentFactory;
+ private XComponentContext m_xComponentContext;
+
+
+ /** Creates a new instance of TDocSupplier */
+ public TDocSupplier(XComponentContext _xComponentContext) {
+ m_xComponentContext = _xComponentContext;
+ m_xMultiComponentFactory = m_xComponentContext.getServiceManager();
+ }
+
+
+ protected XComponentContext getXComponentContext(){
+ return m_xComponentContext;
+ }
+
+
+ protected XMultiComponentFactory getXMultiComponentFactory(){
+ return m_xMultiComponentFactory;
+ }
+
+ public XModel getXModelByTDocUrl(String _sTDocUrl){
+ try{
+ XRow xRow = getXRowOfTDocUrl(_sTDocUrl, "DocumentModel");
+ if (xRow != null){
+ Object oModel = xRow.getObject(1, null);
+ XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, oModel);
+ return xModel;
+ }
+ }catch(Exception exception){
+ exception.printStackTrace(System.out);
+ }
+ JOptionPane.showMessageDialog(new javax.swing.JFrame(), "The selected Document could not be opened!", "Object Inspector", JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+
+
+ public String getTitleByTDocUrl(String _sTDocUrl){
+ try{
+ XRow xRow = this.getXRowOfTDocUrl(_sTDocUrl, "Title");
+ if (xRow != null){
+ return xRow.getString(1);
+ }
+ }catch(Exception exception){
+ exception.printStackTrace(System.out);
+ }
+ JOptionPane.showMessageDialog(new javax.swing.JFrame(), "The selected Document could not be opened!", "Object Inspector", JOptionPane.ERROR_MESSAGE);
+ return "";
+ }
+
+
+ private XRow getXRowOfTDocUrl(String _sTDocUrl, String _sPropertyName){
+ try{
+ String[] keys = new String[2];
+ keys[ 0 ] = "Local";
+ keys[ 1 ] = "Office";
+ Object oUCB = getXMultiComponentFactory().createInstanceWithArgumentsAndContext( "com.sun.star.ucb.UniversalContentBroker", keys, getXComponentContext() );
+ XContentIdentifierFactory xIdFactory = (XContentIdentifierFactory)UnoRuntime.queryInterface(XContentIdentifierFactory.class, oUCB);
+ XContentProvider xProvider = (XContentProvider)UnoRuntime.queryInterface(XContentProvider.class, oUCB);
+ XContentIdentifier xId = xIdFactory.createContentIdentifier(_sTDocUrl);
+ XContent xContent = xProvider.queryContent(xId);
+ XCommandProcessor xCmdProcessor = (XCommandProcessor) UnoRuntime.queryInterface(XCommandProcessor.class, xContent);
+ Property aProperty = new Property();
+ aProperty.Name = _sPropertyName; // "DocumentModel"; //DocumentModel
+ Command aCommand = new Command();
+ aCommand.Name = "getPropertyValues";
+ aCommand.Handle = -1; // not available
+ aCommand.Argument = new Property[]{aProperty};
+ Object oAny = xCmdProcessor.execute(aCommand, 0, null);
+ XRow xRow = (XRow) UnoRuntime.queryInterface(XRow.class, oAny);
+ return xRow;
+ }catch(Exception exception){
+ exception.printStackTrace(System.out);
+ return null;
+ }}
+
+
+ protected String[] getTDocTitles(String[] _sTDocUrls){
+ String[] sTitles = new String[_sTDocUrls.length];
+ for (int i = 0; i < _sTDocUrls.length; i++){
+ sTitles[i] = getTitleByTDocUrl(_sTDocUrls[i]);
+ }
+ return sTitles;
+ }
+
+
+ protected String[] getTDocUrls(){
+ try{
+ Object oSimpleFileAccess = getXMultiComponentFactory().createInstanceWithContext("com.sun.star.ucb.SimpleFileAccess", getXComponentContext());
+ XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class, oSimpleFileAccess);
+ String[] sContent = xSimpleFileAccess.getFolderContents("vnd.sun.star.tdoc:/", false);
+ return sContent;
+ } catch( Exception e ) {
+ System.err.println( e );
+ return new String[]{};
+ }}
+
+
+ public XComponent openEmptyDocument(String _sUrl){
+ try{
+ PropertyValue[] aPropertyValues = new PropertyValue[1];
+ aPropertyValues[0] = new PropertyValue();
+ aPropertyValues[0].Name = "Hidden";
+ aPropertyValues[0].Value = Boolean.TRUE;
+ Object oDesktop = getXMultiComponentFactory().createInstanceWithContext("com.sun.star.frame.Desktop", getXComponentContext());
+ XComponentLoader xCL = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, oDesktop);
+ return xCL.loadComponentFromURL(_sUrl, "_default", 0, aPropertyValues);
+ }
+ catch( Exception exception ) {
+ System.err.println( exception );
+ return null;
+ }}
+
+}
diff --git a/odk/examples/java/Inspector/TestInspector.java b/odk/examples/java/Inspector/TestInspector.java
new file mode 100644
index 000000000000..a2255dff859a
--- /dev/null
+++ b/odk/examples/java/Inspector/TestInspector.java
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.lang.XSingleComponentFactory;
+import com.sun.star.uno.UnoRuntime;
+
+import java.io.DataInputStream;
+
+public class TestInspector {
+
+ public static void main(String args[]) {
+ com.sun.star.uno.XComponentContext xContext = null;
+ try {
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ if( xContext != null )
+ System.out.println("Connected to a running office ...");
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.out);
+ System.exit(1);
+ }
+
+ try {
+ com.sun.star.lang.XMultiComponentFactory xMCF = xContext.getServiceManager();
+ // Creating an instance of the instance inspector with arguments
+
+ XSingleComponentFactory xFactory = Inspector.__getComponentFactory(Inspector._Inspector.class.getName());
+ Object obj= null;
+ if (xFactory != null) {
+ obj = xFactory.createInstanceWithContext(xContext);
+ }
+ org.openoffice.XInstanceInspector xInstInspector = null;
+ if (obj != null) {
+ xInstInspector = (org.openoffice.XInstanceInspector)UnoRuntime.queryInterface(org.openoffice.XInstanceInspector.class, obj);
+ }
+
+ /* A desktop environment contains tasks with one or more
+ frames in which components can be loaded. Desktop is the
+ environment for components which can instanciate within
+ frames. */
+ com.sun.star.frame.XComponentLoader xCmpLoader = (com.sun.star.frame.XComponentLoader)UnoRuntime.queryInterface( com.sun.star.frame.XComponentLoader.class,
+ xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext));
+
+ // Load a new spreadsheet document, which will be automaticly
+ // displayed and is used for inspection
+ com.sun.star.lang.XComponent xComp = xCmpLoader.loadComponentFromURL("private:factory/scalc", "_blank", 0, new com.sun.star.beans.PropertyValue[0] );
+ xInstInspector.inspect(xCmpLoader, "");
+ System.out.println("You can now inspect the new spreadsheet " + "document ...\n");
+ }
+ catch( Exception e ) {
+ System.err.println( e + e.getMessage());
+ e.printStackTrace();
+ }
+// System.exit( 0 );
+ }
+}
diff --git a/odk/examples/java/Inspector/UnoFacetteNode.java b/odk/examples/java/Inspector/UnoFacetteNode.java
new file mode 100644
index 000000000000..53296129b2da
--- /dev/null
+++ b/odk/examples/java/Inspector/UnoFacetteNode.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.reflection.XIdlMethod;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.XComponentContext;
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public class UnoFacetteNode extends UnoNode{
+ String m_sFilter = "";
+
+
+ /** Creates a new instance of UnoMethodNode */
+ public UnoFacetteNode(Object _oUnoObject){
+ super(_oUnoObject);
+ addDummyNode();
+ }
+
+
+ public String getFilter(){
+ return m_sFilter;
+ }
+
+ public void setFilter(String _sFilter){
+ m_sFilter = _sFilter;
+ }
+
+ public String getName(){
+ return toString();
+ }
+
+// TODO The implementation of the following nodes is not really robust and should be changed!!!
+ public boolean isMethodNode(){
+ return ((String) getUserObject()).equals(SMETHODDESCRIPTION);
+ }
+
+ public boolean isPropertyNode(){
+ String sNodeDescription = (String) getUserObject();
+ return ((sNodeDescription.equals(SPROPERTYDESCRIPTION)) || (sNodeDescription.equals(SPROPERTYINFODESCRIPTION)) || (sNodeDescription.equals(SPROPERTYVALUEDESCRIPTION)));
+ }
+
+ public boolean isContainerNode(){
+ return ((String) getUserObject()).equals(SCONTAINERDESCRIPTION);
+ }
+
+ public boolean isServiceNode(){
+ return ((String) getUserObject()).equals(SSERVICEDESCRIPTION);
+ }
+
+ public boolean isInterfaceNode(){
+ return ((String) getUserObject()).equals(SINTERFACEDESCRIPTION);
+ }
+}
+
diff --git a/odk/examples/java/Inspector/UnoMethodNode.java b/odk/examples/java/Inspector/UnoMethodNode.java
new file mode 100644
index 000000000000..57793809bc5e
--- /dev/null
+++ b/odk/examples/java/Inspector/UnoMethodNode.java
@@ -0,0 +1,228 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.reflection.ParamInfo;
+import com.sun.star.reflection.ParamMode;
+import com.sun.star.reflection.XIdlClass;
+import com.sun.star.reflection.XIdlMethod;
+import com.sun.star.uno.TypeClass;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Vector;
+
+public class UnoMethodNode extends UnoNode{
+ XIdlMethod m_xIdlMethod = null;
+ Object[] m_oParamObjects = null;
+ Object m_oUnoReturnObject = null;
+ boolean m_bisInvoked = false;
+ XUnoMethodNode m_xUnoMethodNode = null;
+
+
+ /** Creates a new instance of UnoMethodNode */
+ public UnoMethodNode(XIdlMethod _xIdlMethod, Object _oUnoObject, XUnoMethodNode _xUnoMethodNode) {
+ super(_oUnoObject);
+ m_xIdlMethod = _xIdlMethod;
+ m_oParamObjects = new Object[m_xIdlMethod.getParameterInfos().length];
+ m_xUnoMethodNode = _xUnoMethodNode;
+ }
+
+ protected boolean isFoldable(){
+ return ((!this.isPrimitive()) && (getTypeClass().getValue() != TypeClass.VOID_value));
+ }
+
+ protected boolean isInvokable(){
+ boolean bisFoldable = true;
+ XIdlClass[] xIdlClasses = m_xIdlMethod.getParameterTypes();
+ for (int i = 0; i < xIdlClasses.length; i++){
+ bisFoldable = Introspector.isPrimitive(xIdlClasses[i].getTypeClass());
+ if (!bisFoldable){
+ return false;
+ }
+ }
+ return bisFoldable;
+ }
+
+ public XIdlMethod getXIdlMethod(){
+ return m_xIdlMethod;
+ }
+
+
+ public String getAnchor(){
+ return getXIdlMethod().getName();
+ }
+
+
+ public String getName(){
+ return getXIdlMethod().getName();
+ }
+
+
+ public Object invoke(){
+ Object oUnoReturnObject = null;
+ if (!hasParameters()){
+ oUnoReturnObject = invokeParameterlessMethod();
+ m_bisInvoked = true;
+ }
+ else{
+ Vector oUnoMethodObjects = m_xUnoMethodNode.getMethodObjects();
+ if (oUnoMethodObjects != null){
+ for (int i = 0; i < getXIdlMethod().getParameterInfos().length; i++){
+ this.m_oParamObjects[i] = oUnoMethodObjects.get(i);
+ }
+ if (oUnoMethodObjects.size() == m_oParamObjects.length + 1){
+ oUnoReturnObject = oUnoMethodObjects.get(oUnoMethodObjects.size()-1);
+ }
+ m_bisInvoked = (oUnoReturnObject != null);
+ }
+ }
+ m_oUnoReturnObject = oUnoReturnObject;
+ return oUnoReturnObject;
+ }
+
+
+ public boolean isInvoked(){
+ return m_bisInvoked;
+ }
+
+
+ protected String getNodeDescription(){
+ String sNodeDescription = "";
+ String sParameters = getParameterDescription();
+ if (m_xIdlMethod.getParameterInfos().length > 0){
+ sNodeDescription = getStandardMethodDescription();
+ }
+ else{
+ TypeClass typeClass = getTypeClass();
+ if (typeClass != TypeClass.VOID){
+ sNodeDescription = getStandardMethodDescription();
+ }
+ else{
+ sNodeDescription = getStandardMethodDescription();
+ }
+ }
+ return sNodeDescription;
+ }
+
+
+ public String getStandardMethodDescription(){
+ String sNodeDescription = m_xIdlMethod.getReturnType().getName() + " " + m_xIdlMethod.getName() + " (" + getParameterDescription() + " )";
+ if (isPrimitive()){
+ sNodeDescription += "";
+ }
+ return sNodeDescription;
+ }
+
+
+ public boolean hasParameters(){
+ return (m_xIdlMethod.getParameterInfos().length > 0);
+ }
+
+
+ public Object[] getLastParameterObjects(){
+ return m_oParamObjects;
+ }
+
+
+ public Object getLastUnoReturnObject(){
+ return m_oUnoReturnObject;
+ }
+
+
+ public String getParameterDescription(){
+ ParamInfo[] paramInfo = m_xIdlMethod.getParameterInfos();
+ String sParameters = "";
+ String sStandardMethodDisplayText = m_xIdlMethod.getReturnType().getName() + " " + m_xIdlMethod.getName() + " (" + sParameters + " )";
+ if (Introspector.isValid(paramInfo)) {
+ // get all parameters with type and mode
+ for ( int i = 0; i < paramInfo.length; i++ ) {
+ XIdlClass xIdlClass = paramInfo[ i ].aType;
+ if ( i == 0 ) {
+ // the first parameter has no leading comma
+ sParameters += "[" + getParamMode(paramInfo[ i ].aMode ) + "] " + xIdlClass.getName();
+ }
+ else {
+ // all other parameters are separated with comma
+ sParameters += ", [" + getParamMode(paramInfo[ i ].aMode ) + "] " + xIdlClass.getName();
+ }
+ }
+ }
+ return sParameters;
+ }
+
+
+ // return the parameter mode (IN, OUT, INOUT)
+ private static String getParamMode(ParamMode paramMode) {
+ String toReturn = "";
+ if ( paramMode == ParamMode.IN ) {
+ toReturn = "IN";
+ }
+ if ( paramMode == ParamMode.OUT ) {
+ toReturn = "OUT";
+ }
+ if ( paramMode == ParamMode.INOUT ) {
+ toReturn = "INOUT";
+ }
+ return( toReturn );
+ }
+
+ public TypeClass getTypeClass(){
+ XIdlClass xIdlClass = m_xIdlMethod.getReturnType();
+ return xIdlClass.getTypeClass();
+ }
+
+
+ private Object invokeParameterlessMethod(){
+ try {
+ Object[][] aParamInfo = new Object[1][];
+ aParamInfo[0] = new Object[] {};
+ return getXIdlMethod().invoke(getUnoObject(), aParamInfo);
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ return null;
+ }}
+
+
+ public boolean isPrimitive(){
+ return Introspector.isObjectPrimitive(m_xIdlMethod.getClass(), getTypeClass());
+ }
+
+
+ protected Object invoke(Object _oUnoObject, Object[] oParameters) throws com.sun.star.uno.Exception{
+ Object[][] aParams = new Object[1][oParameters.length];
+ for ( int i = 0; i < oParameters.length; i++ ) {
+ aParams[0][i] = oParameters[i];
+ }
+ return m_xIdlMethod.invoke(_oUnoObject, aParams);
+ }
+}
diff --git a/odk/examples/java/Inspector/UnoNode.java b/odk/examples/java/Inspector/UnoNode.java
new file mode 100644
index 000000000000..2bfaaf34a356
--- /dev/null
+++ b/odk/examples/java/Inspector/UnoNode.java
@@ -0,0 +1,437 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.FrameSearchFlag;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.frame.XFrame;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.reflection.TypeDescriptionSearchDepth;
+import com.sun.star.reflection.XServiceTypeDescription;
+import com.sun.star.reflection.XTypeDescription;
+import com.sun.star.reflection.XTypeDescriptionEnumeration;
+import com.sun.star.reflection.XTypeDescriptionEnumerationAccess;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.TypeClass;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.util.URL;
+import com.sun.star.util.XURLTransformer;
+import java.util.List;
+import java.util.Vector;
+
+public class UnoNode{
+
+ String sPath = null;
+ Object m_oUnoObject;
+ private XMultiComponentFactory m_xMultiComponentFactory;
+ private XComponentContext m_xComponentContext;
+ private Object[] m_oParamObjects = null;
+ private int m_nNodeType = XUnoNode.nOTHERS;
+ private Type aType = null;
+ private String sLabel = "";
+
+
+
+ /** Creates a new instance of UnoNode */
+ public UnoNode(Object _oUnoObject) {
+ m_xComponentContext = Introspector.getIntrospector().getXComponentContext();
+ m_xMultiComponentFactory = m_xComponentContext.getServiceManager();
+ m_oUnoObject = _oUnoObject;
+ }
+
+ public UnoNode(Object _oUnoObject, Type _aType) {
+ this(_oUnoObject);
+ aType = _aType;
+ m_nNodeType = XUnoNode.nINTERFACE;
+ }
+
+ public Object getUnoObject(){
+ return m_oUnoObject;
+ }
+
+
+ protected XComponentContext getXComponentContext(){
+ return m_xComponentContext;
+ }
+
+
+ protected XMultiComponentFactory getXMultiComponentFactory(){
+ return m_xMultiComponentFactory;
+ }
+
+
+ private static XTypeDescriptionEnumerationAccess getXTypeDescriptionEnumerationAccess(){
+ return Introspector.getIntrospector().getXTypeDescriptionEnumerationAccess();
+ }
+
+
+ public String getAnchor(){
+ return "";
+ }
+
+ public int getNodeType(){
+ return m_nNodeType;
+ }
+
+ public void setNodeType(int _nNodeType){
+ m_nNodeType = _nNodeType;
+ }
+
+ public String getClassName(){
+ String sClassName = "";
+ if (m_nNodeType == XUnoNode.nINTERFACE){
+ sClassName = aType.getTypeName();
+ }
+ else if(m_nNodeType == XUnoNode.nSERVICE){
+ sClassName = sLabel;
+ }
+ return sClassName;
+ }
+
+
+ public Type getUnoType(){
+ return aType;
+ }
+
+ protected void setLabel(String _sLabel){
+ sLabel = _sLabel;
+ }
+
+ public void openIdlDescription(String _sIDLUrl, String _sClassName, String _sAnchor){
+ try{
+ String sIDLUrl = _sIDLUrl;
+ String sAnchor = ""; // TODO find out how the Anchor may be set at the html file; //_sAnchor;
+ boolean bExists = Introspector.getIntrospector().getXSimpleFileAccess().exists(sIDLUrl);
+ if (sIDLUrl.equals("") || (!bExists)){
+ sIDLUrl = "http://api.openoffice.org/" + Inspector.sIDLDOCUMENTSUBFOLDER;
+ }
+ if (!sIDLUrl.endsWith("/")){
+ sIDLUrl += "/";
+ }
+ if (_sClassName.equals("")){
+ sIDLUrl += "com/sun/star/module-ix";
+ sAnchor = "";
+ }
+ else{
+ sIDLUrl += _sClassName.replace('.', '/');
+ }
+ if (sAnchor != null){
+ if (!sAnchor.equals("")){
+ sIDLUrl += "#" + sAnchor;
+ }
+ }
+ sIDLUrl += ".html";
+ URL openHyperlink = getDispatchURL(".uno:OpenHyperlink");
+ PropertyValue pv = new PropertyValue();
+ pv.Name = "URL";
+ pv.Value = sIDLUrl;
+ getXDispatcher(openHyperlink).dispatch(openHyperlink, new PropertyValue[] {pv});
+ } catch(Exception exception) {
+ exception.printStackTrace(System.out);
+ }}
+
+
+ private com.sun.star.util.URL getDispatchURL(String _sURL){
+ try {
+ Object oTransformer = getXMultiComponentFactory().createInstanceWithContext("com.sun.star.util.URLTransformer", getXComponentContext());
+ XURLTransformer xTransformer = (XURLTransformer) UnoRuntime.queryInterface(XURLTransformer.class, oTransformer);
+ com.sun.star.util.URL[] oURL = new com.sun.star.util.URL[1];
+ oURL[0] = new com.sun.star.util.URL();
+ oURL[0].Complete = _sURL;
+ xTransformer.parseStrict(oURL);
+ return oURL[0];
+ } catch (Exception e) {
+ e.printStackTrace(System.out);
+ }
+ return null;
+ }
+
+
+ private XFrame getCurrentFrame(){
+ try{
+ Object oDesktop = getXMultiComponentFactory().createInstanceWithContext("com.sun.star.frame.Desktop", getXComponentContext());
+ XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, oDesktop);
+ return xDesktop.getCurrentFrame();
+ } catch (Exception e) {
+ e.printStackTrace(System.out);
+ return null;
+ }}
+
+
+ private XDispatch getXDispatcher(com.sun.star.util.URL oURL) {
+ try {
+ com.sun.star.util.URL[] oURLArray = new com.sun.star.util.URL[1];
+ oURLArray[0] = oURL;
+ XDispatchProvider xDispatchProvider = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, getCurrentFrame());
+ XDispatch xDispatch = xDispatchProvider.queryDispatch(oURLArray[0], "_top", FrameSearchFlag.ALL); // "_self"
+ return xDispatch;
+ } catch (Exception e) {
+ e.printStackTrace(System.out);
+ return null;
+ }}
+
+
+ private PropertyValue[] loadArgs(String url) {
+ PropertyValue pv = new PropertyValue();
+ pv.Name = "URL";
+ pv.Value = url;
+ return new PropertyValue[] {pv};
+ }
+
+
+
+ public boolean isFilterApplicable(String _sFilter, String _sName){
+ boolean bFilterDoesApply = true;
+ if (_sFilter.length() > 0){
+ if (_sName.indexOf(_sFilter) == -1){
+ bFilterDoesApply = false;
+ }
+ }
+ return bFilterDoesApply;
+ }
+
+
+// public static String getServiceDescription(Object _oUnoObject){
+// String sClassName = "";
+// XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, _oUnoObject);
+// if (xServiceInfo != null){
+// String[] sChildServiceNames = removeMandatoryServiceNames(xServiceInfo.getSupportedServiceNames());
+// if (sChildServiceNames.length > 0){
+// sClassName = sChildServiceNames[0];
+// }
+// }
+// return sClassName;
+// }
+
+
+
+ private static String[] getMandatoryServiceNames(String _sServiceName){
+ String[] sMandatoryServiceNames = new String[]{};
+ try {
+ TypeClass[] eTypeClasses = new com.sun.star.uno.TypeClass[1];
+ eTypeClasses[0] = com.sun.star.uno.TypeClass.SERVICE;
+ XTypeDescriptionEnumeration xTDEnumeration = getXTypeDescriptionEnumerationAccess().createTypeDescriptionEnumeration(Introspector.getModuleName(_sServiceName), eTypeClasses, TypeDescriptionSearchDepth.INFINITE);
+ while (xTDEnumeration.hasMoreElements()) {
+ XTypeDescription xTD = xTDEnumeration.nextTypeDescription();
+ if (xTD.getName().equals(_sServiceName)){
+ XServiceTypeDescription xServiceTypeDescription = (XServiceTypeDescription) UnoRuntime.queryInterface(XServiceTypeDescription.class, xTD);
+ XServiceTypeDescription[] xMandatoryServiceTypeDescriptions = xServiceTypeDescription.getMandatoryServices();
+ int nlength = xMandatoryServiceTypeDescriptions.length;
+ sMandatoryServiceNames = new String[nlength];
+ for (int i = 0; i < nlength; i++){
+ sMandatoryServiceNames[i] = xMandatoryServiceTypeDescriptions[i].getName();
+ }
+
+ }
+ }
+ } catch ( java.lang.Exception e) {
+ System.out.println(System.out);
+ }
+ return sMandatoryServiceNames;
+ }
+
+
+ private static String[] removeMandatoryServiceNames(String[] _sServiceNames){
+ try{
+ List aList = java.util.Arrays.asList(_sServiceNames);
+ Vector aVector = new Vector(aList);
+ for (int n = 0; n < _sServiceNames.length; n++){
+ String[] sDelServiceNames = getMandatoryServiceNames(_sServiceNames[n]);
+ for (int m = 0; m < sDelServiceNames.length; m++){
+ if (aVector.contains(sDelServiceNames[m])){
+ int nIndex = aVector.indexOf(sDelServiceNames[m]);
+ aVector.remove(nIndex);
+ }
+ }
+ }
+ String[] sRetArray = new String[aVector.size()];
+ aVector.toArray(sRetArray);
+ return sRetArray;
+ } catch (java.lang.Exception exception) {
+ exception.printStackTrace(System.out);
+ }
+ return new String[]{};
+ }
+
+
+ public static String getDisplayValueOfPrimitiveType(Object _objectElement){
+ String sValue ="";
+ try{
+ if (AnyConverter.isString(_objectElement)){
+ sValue = AnyConverter.toString(_objectElement);
+ }
+ else if (AnyConverter.isBoolean(_objectElement)){
+ sValue += AnyConverter.toBoolean(_objectElement);
+ }
+ else if (AnyConverter.isByte(_objectElement)){
+ sValue += AnyConverter.toByte(_objectElement);
+ }
+ else if (AnyConverter.isChar(_objectElement)){
+ sValue += AnyConverter.toChar(_objectElement);
+ }
+ else if (AnyConverter.isDouble(_objectElement)){
+ sValue += AnyConverter.toDouble(_objectElement);
+ }
+ else if (AnyConverter.isFloat(_objectElement)){
+ sValue += AnyConverter.toFloat(_objectElement);
+ }
+ else if (AnyConverter.isInt(_objectElement)){
+ sValue += AnyConverter.toInt(_objectElement);
+ }
+ else if (AnyConverter.isLong(_objectElement)){
+ sValue += AnyConverter.toLong(_objectElement);
+ }
+ else if (AnyConverter.isShort(_objectElement)){
+ sValue += AnyConverter.toShort(_objectElement);
+ }
+ }
+ catch( Exception e ) {
+ System.err.println( e );
+ }
+ return sValue;
+ }
+
+ protected static String[] getDisplayValuesofPrimitiveArray(Object _oUnoObject){
+ String[] sDisplayValues = null;
+ try{
+ Type aType = AnyConverter.getType(_oUnoObject);
+ TypeClass aTypeClass = aType.getTypeClass();
+ int nTypeValue = aTypeClass.getValue();
+ if (nTypeValue == TypeClass.SEQUENCE_value){
+ nTypeValue = (sequenceComponentType(aType)).getTypeClass().getValue();
+ }
+ switch (nTypeValue){
+ case TypeClass.BOOLEAN_value:
+ boolean[] bBooleans = (boolean[]) AnyConverter.toArray(_oUnoObject);
+ sDisplayValues = new String[bBooleans.length];
+ for (int i = 0; i < bBooleans.length; i++){
+ sDisplayValues[i] = Boolean.toString(bBooleans[i]);
+ }
+ break;
+ case TypeClass.BYTE_value:
+ byte[] bBytes = (byte[]) AnyConverter.toArray(_oUnoObject);
+ sDisplayValues = new String[bBytes.length];
+ for (int i = 0; i < bBytes.length; i++){
+ sDisplayValues[i] = "" + bBytes[i];
+ }
+ break;
+ case TypeClass.DOUBLE_value:
+ double[] fdoubles = (double[]) AnyConverter.toArray(_oUnoObject);
+ sDisplayValues = new String[fdoubles.length];
+ for (int i = 0; i < fdoubles.length; i++){
+ sDisplayValues[i] = String.valueOf(fdoubles[i]);
+ }
+ break;
+ case TypeClass.FLOAT_value:
+ float[] ffloats = (float[]) AnyConverter.toArray(_oUnoObject);
+ sDisplayValues = new String[ffloats.length];
+ for (int i = 0; i < ffloats.length; i++){
+ sDisplayValues[i] = String.valueOf(ffloats[i]);
+ }
+ break;
+ case TypeClass.LONG_value:
+ int[] nints = (int[]) AnyConverter.toArray(_oUnoObject);
+ sDisplayValues = new String[nints.length];
+ for (int i = 0; i < nints.length; i++){
+ sDisplayValues[i] = String.valueOf(nints[i]);
+ }
+ break;
+ case TypeClass.HYPER_value:
+ long[] nlongs = (long[]) AnyConverter.toArray(_oUnoObject);
+ sDisplayValues = new String[nlongs.length];
+ for (int i = 0; i < nlongs.length; i++){
+ sDisplayValues[i] = String.valueOf(nlongs[i]);
+ }
+ break;
+ case TypeClass.SHORT_value:
+ short[] nShorts = (short[]) AnyConverter.toArray(_oUnoObject);
+ sDisplayValues = new String[nShorts.length];
+ for (int i = 0; i < nShorts.length; i++){
+ sDisplayValues[i] = "" + nShorts[i];
+ }
+ break;
+ case TypeClass.CHAR_value:
+ break;
+ default:
+ System.out.println("Value could not be retrieved: " + aType.getTypeClass().getClass().getName());
+ }
+ return sDisplayValues;
+ }
+ catch( Exception e ) {
+ System.err.println( e );
+ return null;
+ }}
+
+
+ private static Type sequenceComponentType(Type sequenceType) {
+// assert sequenceType.getTypeClass() == TypeClass.SEQUENCE;
+ String n = sequenceType.getTypeName();
+ final String PREFIX = "[]";
+// assert n.startsWith(PREFIX);
+ return new Type(n.substring(PREFIX.length()));
+ }
+
+
+ public static String getNodeDescription(Object _oUnoObject, int _nIndex){
+ return getNodeDescription(_oUnoObject) + "[" + (_nIndex + 1) + "]";
+ }
+
+
+ public static String getNodeDescription(Object _oUnoObject){
+ XServiceInfo xServiceInfo = ( XServiceInfo ) UnoRuntime.queryInterface( XServiceInfo.class, _oUnoObject );
+ if ( xServiceInfo != null ) {
+ return xServiceInfo.getImplementationName();
+ }
+ String sClassName = _oUnoObject.getClass().getName();
+ if (Introspector.getIntrospector().isObjectPrimitive(_oUnoObject)){ //super.isO{sObjectClassName.equals("java.lang.String"))issClassName.equals("java.lang.String"))
+ return _oUnoObject.toString();
+ }
+ else{
+ return _oUnoObject.getClass().getName();
+ }
+ }
+
+ public void setParameterObjects(Object[] _oParamObjects){
+ m_oParamObjects = _oParamObjects;
+ }
+
+ public Object[] getParameterObjects(){
+ return m_oParamObjects;
+ }
+}
diff --git a/odk/examples/java/Inspector/UnoPropertyNode.java b/odk/examples/java/Inspector/UnoPropertyNode.java
new file mode 100644
index 000000000000..4b22b01f1b8a
--- /dev/null
+++ b/odk/examples/java/Inspector/UnoPropertyNode.java
@@ -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.
+ *
+ *************************************************************************/
+
+import com.sun.star.beans.Property;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.reflection.TypeDescriptionSearchDepth;
+import com.sun.star.reflection.XConstantTypeDescription;
+import com.sun.star.reflection.XPropertyTypeDescription;
+import com.sun.star.reflection.XServiceTypeDescription;
+import com.sun.star.reflection.XTypeDescription;
+import com.sun.star.reflection.XTypeDescriptionEnumeration;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.TypeClass;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public class UnoPropertyNode extends UnoNode{
+
+ Property aProperty;
+ PropertyValue aPropertyValue;
+ String m_sPropertyName;
+ Object m_oUnoReturnObject;
+ private int m_nPropertyType = XUnoPropertyNode.nDEFAULT;
+ private String sLabel = "";
+
+ private static XConstantTypeDescription[] xPropertyAttributesTypeDescriptions = null;
+
+
+ /** Creates a new instance of UnoMethodNode */
+ public UnoPropertyNode(Property _aProperty, Object _oUnoObject, Object _oUnoReturnObject) {
+ super(_oUnoObject);
+ aProperty = _aProperty;
+ m_sPropertyName = aProperty.Name;
+ m_oUnoReturnObject = _oUnoReturnObject;
+ }
+
+
+ public UnoPropertyNode(Property _aProperty){
+ super(null);
+ aProperty = _aProperty;
+ m_sPropertyName = aProperty.Name;
+ m_oUnoReturnObject = null;
+ }
+
+ public UnoPropertyNode(PropertyValue _aPropertyValue, Object _oUnoObject, Object _oUnoReturnObject) {
+ super(_oUnoObject);
+ m_oUnoReturnObject = _oUnoReturnObject;
+ aPropertyValue = _aPropertyValue;
+ m_sPropertyName = aPropertyValue.Name;
+ }
+
+
+ public int getPropertyNodeType(){
+ return m_nPropertyType;
+ }
+
+
+ public void setPropertyNodeType(int _nPropertyType){
+ m_nPropertyType = _nPropertyType;
+ }
+
+
+ public String getPropertyName(){
+ return m_sPropertyName;
+ }
+
+ public String getName(){
+ return this.m_sPropertyName;
+ }
+
+
+ public String getClassName(){
+ String sClassName = "";
+ if (m_oUnoObject != null){
+ XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, m_oUnoObject);
+ if (xServiceInfo != null){
+ String[] sServiceNames = xServiceInfo.getSupportedServiceNames();
+ for (int i = 0; i < sServiceNames.length; i++){
+ if (doesServiceSupportProperty(sServiceNames[i], m_sPropertyName)){
+ sClassName = sServiceNames[i];
+ break;
+ }
+ }
+ }
+ }
+ else{
+ sClassName = "com.sun.star.beans.Property";
+ }
+ return sClassName;
+ }
+
+
+ public String getAnchor(){
+ return m_sPropertyName;
+ }
+
+
+
+ protected boolean doesServiceSupportProperty(String _sServiceName, String _sPropertyName){
+ try {
+ XPropertyTypeDescription[] xPropertyTypeDescriptions = Introspector.getIntrospector().getPropertyDescriptionsOfService(_sServiceName);
+ for (int i = 0; i < xPropertyTypeDescriptions.length; i++){
+ if (xPropertyTypeDescriptions[i].getName().equals(_sServiceName + "." + _sPropertyName)){
+ return true;
+ }
+ }
+ } catch ( java.lang.Exception e) {
+ System.out.println(System.out);
+ }
+ return false;
+ }
+
+
+ public Object getUnoReturnObject(){
+ return m_oUnoReturnObject;
+ }
+
+
+ private boolean isPrimitive(){
+ boolean bIsPrimitive = true;
+ if (getUnoReturnObject() != null){
+ if (getProperty() != null){
+ bIsPrimitive = Introspector.isObjectPrimitive(getUnoReturnObject().getClass(), getProperty().Type.getTypeClass());
+ }
+ else{
+ bIsPrimitive = Introspector.isObjectPrimitive(getUnoReturnObject().getClass());
+ }
+ }
+ else{
+ bIsPrimitive = Introspector.isObjectPrimitive(aProperty.Type.getTypeClass());
+ }
+ return bIsPrimitive;
+ }
+
+
+ protected boolean isFoldable(){
+ boolean bIsFoldable = false;
+ if (! isPrimitive()){
+ String sTypeName = getUnoReturnObject().getClass().getName();
+ bIsFoldable = (!sTypeName.equals("com.sun.star.uno.Type"));
+ }
+ return bIsFoldable;
+ }
+
+
+ protected String getLabel(){
+ if (!sLabel.equals("")){
+ if (! isPrimitive()){
+ if (isFoldable()){
+ sLabel = getPropertyTypeDescription(aProperty, getUnoReturnObject());
+ }
+ else{
+ sLabel = getStandardPropertyDescription(aProperty, getUnoReturnObject());
+ }
+ }
+ else {
+ sLabel = getStandardPropertyDescription(aProperty, getUnoReturnObject());
+ }
+ }
+ return sLabel;
+ }
+
+ public Property getProperty(){
+ return aProperty;
+ }
+
+ protected static String getPropertyTypeDescription(Property _aProperty, Object _oUnoObject){
+ return _aProperty.Type.getTypeName() + " " + _aProperty.Name + " = " + _oUnoObject.toString();
+ }
+
+
+ protected static String getStandardPropertyDescription(Property _aProperty, Object _objectElement){
+ if (!Introspector.isObjectPrimitive(_objectElement)){
+ return _aProperty.Name + " = (" + _aProperty.Type.getTypeName() + ") ";
+ }
+ else{
+ return _aProperty.Name + " (" + _aProperty.Type.getTypeName() + ") = " + getDisplayValueOfPrimitiveType(_objectElement);
+ }
+ }
+
+
+ protected static String getStandardPropertyValueDescription(PropertyValue _aPropertyValue){
+ if (!Introspector.isObjectPrimitive(_aPropertyValue.Value)){
+ return _aPropertyValue.Name;
+ }
+ else{
+ return _aPropertyValue.Name + " : " + UnoNode.getDisplayValueOfPrimitiveType(_aPropertyValue.Value);
+ }
+ }
+}
+
+
diff --git a/odk/examples/java/Inspector/UnoTreeRenderer.java b/odk/examples/java/Inspector/UnoTreeRenderer.java
new file mode 100644
index 000000000000..54094275606c
--- /dev/null
+++ b/odk/examples/java/Inspector/UnoTreeRenderer.java
@@ -0,0 +1,135 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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.Component;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.SystemColor;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+
+
+public class UnoTreeRenderer extends DefaultTreeCellRenderer{
+ private Icon m_oMethodIcon;
+ private Icon m_oPropertyIcon;
+ private Icon m_oContainerIcon;
+ private Icon m_oContentIcon;
+ private Icon m_oServiceIcon;
+ private Icon m_oInterfaceIcon;
+ private Icon m_oPropertyValueIcon;
+ private boolean bSelected;
+ private int nWidth = 0;
+
+
+ /** Creates a new instance of UnoTreeRenderer */
+ public UnoTreeRenderer(){
+ super();
+ try {
+
+ final ClassLoader loader = ClassLoader.getSystemClassLoader();
+ m_oMethodIcon = new ImageIcon(loader.getResource("images/methods_16.png"));
+ m_oPropertyIcon = new ImageIcon("images/properties_16.png");
+ m_oPropertyValueIcon = new ImageIcon("images/properties_16.png");
+ m_oContainerIcon = new ImageIcon("images/containers_16.png");
+ m_oServiceIcon = new ImageIcon("images/services_16.png");
+ m_oInterfaceIcon = new ImageIcon("images/interfaces_16.png");
+ m_oContentIcon = new ImageIcon("images/content_16.png");
+ } catch (RuntimeException e) {
+ System.out.println("Sorry, could not locate resourecs, treecell icons will not be displayed.");
+ }
+ }
+
+
+ public synchronized Component getTreeCellRendererComponent(JTree tree,Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus){
+ try{
+ bSelected = sel;
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
+ Component rc = super.getTreeCellRendererComponent( tree, value, sel,expanded, leaf, row,hasFocus);
+ String sLabelText = (String)node.getUserObject();
+ if (sLabelText != null){
+ if (sLabelText.equals(XUnoFacetteNode.SCONTAINERDESCRIPTION)){
+// setIcon(m_oContainerIcon);
+ } else if (sLabelText.equals(XUnoFacetteNode.SCONTENTDESCRIPTION)){
+// setIcon(m_oContentIcon);
+ } else if (sLabelText.equals(XUnoFacetteNode.SINTERFACEDESCRIPTION)){
+// setIcon(m_oInterfaceIcon);
+ } else if (sLabelText.equals(XUnoFacetteNode.SMETHODDESCRIPTION)){
+// setIcon(m_oMethodIcon);
+ } else if (sLabelText.equals(XUnoFacetteNode.SPROPERTYDESCRIPTION)){
+// setIcon(m_oPropertyIcon);
+ } else if (sLabelText.startsWith(XUnoFacetteNode.SPROPERTYINFODESCRIPTION)){
+// setIcon(m_oPropertyIcon);
+ } else if (sLabelText.equals(XUnoFacetteNode.SPROPERTYVALUEDESCRIPTION)){
+// setIcon(m_oPropertyValueIcon);
+ } else if (sLabelText.equals(XUnoFacetteNode.SSERVICEDESCRIPTION)){
+// setIcon(m_oServiceIcon);
+ } else{
+ setText(sLabelText);
+ rc.validate();
+ }
+ setSize(getPreferredSize()); //fm.stringWidth(sLabelText), (int) getSize().getHeight());
+ rc.validate();
+// nWidth = (int) rc.getPreferredSize().getWidth();
+ doLayout();
+ }
+ } catch (RuntimeException e) {
+ System.out.println("Sorry, icon for treecell could not be displayed.");
+ }
+ return this;
+ }
+
+
+
+ public void paintComponent(Graphics g) {
+ FontMetrics fm = getFontMetrics(getFont());
+ int x, y;
+ y = fm.getAscent() + 2;
+ if(getIcon() == null) {
+ x = 0;
+ } else {
+ x = getIcon().getIconWidth() + getIconTextGap();
+ }
+ g.setColor(getForeground());
+// g.fillRect(x,y,x + fm.stringWidth(getText()),y);
+// System.out.println("Text: " + getText());
+ super.paintComponent(g);
+ }
+}
+
+
diff --git a/odk/examples/java/Inspector/XDialogProvider.java b/odk/examples/java/Inspector/XDialogProvider.java
new file mode 100644
index 000000000000..e8bfadc1873f
--- /dev/null
+++ b/odk/examples/java/Inspector/XDialogProvider.java
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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 interface XDialogProvider {
+
+ public static String SINVOKE = "Invoke";
+
+ public static String SADDTOSOURCECODE = "Add to Sourcecode";
+
+ public void enablePopupMenuItem(String _sMenuTitle, boolean _bdoEnable);
+
+ public void showPopUpMenu(Object invoker, int x, int y) throws java.lang.ClassCastException;
+
+ public InspectorPane getSelectedInspectorPage();
+
+ public void addInspectorPage(String _sTitle, Object _oContainer);
+
+ public InspectorPane getInspectorPage(int _nIndex);
+
+ public int getInspectorPageCount();
+
+ public void selectInspectorPageByIndex(int nTabIndex);
+
+ public void show(int _nPageIndex) throws java.lang.ClassCastException;
+
+ public void selectSourceCodeLanguage(int _nLanguage);
+
+ public void paint();
+
+ // returns one of the constants defined in XLanguageSourceCodeGenerator
+ public int getLanguage();
+
+ public String getIDLPath();
+}
diff --git a/odk/examples/java/Inspector/XInstanceInspector.idl b/odk/examples/java/Inspector/XInstanceInspector.idl
new file mode 100644
index 000000000000..134879f68cee
--- /dev/null
+++ b/odk/examples/java/Inspector/XInstanceInspector.idl
@@ -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.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_ORG_OPENOFFICE_XINSTANCEINSPECTOR_IDL
+#define INCLUDED_ORG_OPENOFFICE_XINSTANCEINSPECTOR_IDL
+
+#include <com/sun/star/uno/XInterface.idl>
+
+module org { module openoffice {
+
+ interface XInstanceInspector {
+ /**
+ * For a given instance this method displays all services, interfaces,
+ * methods, attributes, and contents in a tree. All dependend
+ * instances are also inspected and displayed, so the user could browse
+ * the tree. If you press the key "F1", the API-documentation from
+ * www.openoffice.org for the current instance will be displayed in a
+ * new window.
+ */
+ void inspect( [in] any aInstance, [in] string sTitle );
+ };
+
+}; };
+
+#endif
diff --git a/odk/examples/java/Inspector/XLanguageSourceCodeGenerator.java b/odk/examples/java/Inspector/XLanguageSourceCodeGenerator.java
new file mode 100644
index 000000000000..832f0aa51d4b
--- /dev/null
+++ b/odk/examples/java/Inspector/XLanguageSourceCodeGenerator.java
@@ -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.
+ *
+ *************************************************************************/
+import com.sun.star.uno.TypeClass;
+import java.util.Vector;
+
+public interface XLanguageSourceCodeGenerator {
+
+ public static final int nJAVA = 0;
+ public static final int nCPLUSPLUS = 1;
+ public static final int nBASIC = 2;
+
+ public String getHeaderSourceCode(Object _oUnoObject, String _sClassName, TypeClass _aTypeClass);
+
+ public String getFinalHeaderStatements();
+
+ public void assignqueryInterfaceHeaderSourceCode();
+
+ public String getMainMethodSignatureSourceCode(XUnoNode _oUnoNode, String _soReturnObjectDescription);
+
+ public String getMethodTerminationSourceCode();
+
+ public String getStatementTerminationCharacter();
+
+ public boolean needsqueryInterface();
+
+ public String getqueryInterfaceSourceCode(String _sReturnValueDescription, String _sClassName, String _sObjectDescription);
+
+ public String getPropertyValueGetterSourceCode(String _sPropertyName, String _sReturnVariableName, String _sIncomingObjectName, TypeClass _aTypeClass, String _sTypeName);
+
+ public String getStructSourceCode(String _sReturnVariableDescription, String _sObjectDescription, String _sMember);
+
+ public String getObjectTypeDescription(String _sClassName, boolean _bAsHeader);
+
+ public String getbooleanTypeDescription();
+
+ public String getbyteTypeDescription();
+
+ public String getshortTypeDescription();
+
+ public String getunsignedshortTypeDescription();
+
+ public String getlongTypeDescription();
+
+ public String getunsignedlongTypeDescription();
+
+ public String gethyperTypeDescription();
+
+ public String getunsignedhyperTypeDescription();
+
+ public String getfloatTypeDescription();
+
+ public String getdoubleTypeDescription();
+
+ public String getcharTypeDescription();
+
+ public String getstringTypeDescription(boolean _bAsHeaderSourceCode);
+
+ public String gettypeTypeDescription(boolean _bAsHeaderSourceCode);
+
+ public String getanyTypeDescription(boolean _bAsHeaderSourceCode);
+
+ public String getArrayDeclaration(String sVariableDeclaration);
+
+ public String getVariableDeclaration(String _sTypeString, String _sVariableName, boolean _bIsArray, TypeClass aTypeClass, boolean _bInitialize);
+
+ public String getMethodSeparator();
+
+ public String getStringValue(String _sValue);
+
+ public String getConvertedSourceCodeValueOfObject(String _sReturnVariableName, String _sObjectDescription, TypeClass _aTypeClass, String _sTypeName);
+
+ public String castLiteral(String _sExpression, TypeClass _aTypeClass);
+
+ public String getCommentSign();
+}
diff --git a/odk/examples/java/Inspector/XMethodParametersDialog.java b/odk/examples/java/Inspector/XMethodParametersDialog.java
new file mode 100644
index 000000000000..8bad4f19b9c5
--- /dev/null
+++ b/odk/examples/java/Inspector/XMethodParametersDialog.java
@@ -0,0 +1,37 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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 interface XMethodParametersDialog {
+
+}
diff --git a/odk/examples/java/Inspector/XTreeControlProvider.java b/odk/examples/java/Inspector/XTreeControlProvider.java
new file mode 100644
index 000000000000..ca40d70afae2
--- /dev/null
+++ b/odk/examples/java/Inspector/XTreeControlProvider.java
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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.Property;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.reflection.XIdlMethod;
+import com.sun.star.uno.Type;
+
+public interface XTreeControlProvider {
+
+ public static String sTitle = "User defined";
+
+ public String enableFilterElements(XUnoNode _oUnoNode);
+
+ public void setSourceCode(String _sSourceCode);
+
+ public Object inspect(java.lang.Object _oUserDefinedObject, String _sTitle) throws com.sun.star.uno.RuntimeException;
+
+ public void nodeInserted(XUnoNode _oParentNode, XUnoNode _oChildNode, int index);
+
+ public void nodeChanged(XUnoNode _oNode);
+
+ public boolean setNodeVisible(Object node, boolean v);
+
+ public XUnoNode getSelectedNode();
+
+ public XTreePathProvider getSelectedPath();
+
+ public void expandPath(XTreePathProvider xTreePathProvider) throws java.lang.ClassCastException;
+
+ public void addTreeExpandListener();
+
+ public void addInspectorPane(InspectorPane _oInspectorPane);
+
+ public boolean isPropertyNode(XUnoNode _oUnoNode);
+
+ public boolean isMethodNode(XUnoNode _oUnoNode);
+
+ public boolean isFacetteNode(XUnoNode _oUnoNode);
+
+ public XUnoNode addUnoNode(Object _oUnoObject);
+
+ public XUnoNode addUnoNode(Object _oUnoObject, Type _aType);
+
+ public XUnoFacetteNode addUnoFacetteNode(XUnoNode _oParentNode, String _sNodeDescription, Object _oUnoObject);
+
+ public XUnoMethodNode addMethodNode(Object _objectElement, XIdlMethod _xIdlMethod);
+
+ public XUnoPropertyNode addUnoPropertyNodeWithName(Property _aProperty);
+
+ public XUnoPropertyNode addUnoPropertyNodeWithHandle(Property _aProperty);
+
+ public XUnoPropertyNode addUnoPropertyNodeWithType(Property _aProperty);
+
+ public XUnoPropertyNode addUnoPropertyNodeWithAttributesDescription(Property _aProperty);
+
+ public XUnoPropertyNode addUnoPropertyNode(Object _oUnoObject, Property _aProperty);
+
+ public XUnoPropertyNode addUnoPropertyNode(Object _oUnoObject, PropertyValue _aPropertyValue, Object _oReturnObject);
+
+ public XUnoPropertyNode addUnoPropertyNode(Object _oUnoObject, Property _aProperty, Object _oUnoReturnObject);
+}
diff --git a/odk/examples/java/Inspector/XTreePathProvider.java b/odk/examples/java/Inspector/XTreePathProvider.java
new file mode 100644
index 000000000000..5067bad409c1
--- /dev/null
+++ b/odk/examples/java/Inspector/XTreePathProvider.java
@@ -0,0 +1,25 @@
+/*
+ * xTreePathProvider.java
+ *
+ * Created on 12. Dezember 2006, 13:30
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+/**
+ *
+ * @author bc93774
+ */
+public interface XTreePathProvider {
+
+ public XUnoNode getLastPathComponent();
+
+ public XUnoNode getPathComponent(int i);
+
+ public int getPathCount();
+
+ public XTreePathProvider getParentPath();
+
+ public XTreePathProvider pathByAddingChild(XUnoNode _oUnoNode);
+}
diff --git a/odk/examples/java/Inspector/XUnoFacetteNode.java b/odk/examples/java/Inspector/XUnoFacetteNode.java
new file mode 100644
index 000000000000..6ef4bf4d67a9
--- /dev/null
+++ b/odk/examples/java/Inspector/XUnoFacetteNode.java
@@ -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.
+ *
+ *************************************************************************/
+
+
+
+public interface XUnoFacetteNode extends XUnoNode {
+
+ public static String SMETHODDESCRIPTION = "Methods";
+ public static String SPROPERTYDESCRIPTION = "Properties";
+ public static String SPROPERTYINFODESCRIPTION = "PropertyInfo";
+ public static String SCONTAINERDESCRIPTION = "Container";
+ public static String SSERVICEDESCRIPTION = "Services";
+ public static String SINTERFACEDESCRIPTION = "Interfaces";
+ public static String SCONTENTDESCRIPTION = "Content";
+ public static String SPROPERTYVALUEDESCRIPTION = "PropertyValues";
+
+
+ public boolean isMethodNode();
+
+ public boolean isPropertyNode();
+
+ public boolean isContainerNode();
+
+ public boolean isServiceNode();
+
+ public boolean isInterfaceNode();
+
+ public String getFilter();
+
+ public void setFilter(String _sFilter);
+
+}
diff --git a/odk/examples/java/Inspector/XUnoMethodNode.java b/odk/examples/java/Inspector/XUnoMethodNode.java
new file mode 100644
index 000000000000..074c2fe913ba
--- /dev/null
+++ b/odk/examples/java/Inspector/XUnoMethodNode.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.reflection.XIdlMethod;
+import com.sun.star.uno.TypeClass;
+import java.util.Vector;
+
+
+public interface XUnoMethodNode extends XUnoNode {
+
+ public XIdlMethod getXIdlMethod();
+
+ public boolean isInvoked();
+
+ public Object invoke() throws com.sun.star.uno.Exception;
+
+ public Object invoke(Object _oUnoObject, Object[] _oParameters) throws com.sun.star.uno.Exception;
+
+ public boolean isInvokable();
+
+ public boolean hasParameters();
+
+ public Object[] getLastParameterObjects();
+
+ public Object getLastUnoReturnObject();
+
+ public TypeClass getTypeClass();
+
+ public boolean isPrimitive();
+
+ public Vector getMethodObjects();
+
+ public boolean isFoldable();
+
+ public String getStandardMethodDescription();
+
+}
diff --git a/odk/examples/java/Inspector/XUnoNode.java b/odk/examples/java/Inspector/XUnoNode.java
new file mode 100644
index 000000000000..ae65374aca7a
--- /dev/null
+++ b/odk/examples/java/Inspector/XUnoNode.java
@@ -0,0 +1,84 @@
+import com.sun.star.uno.Type;
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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 interface XUnoNode {
+
+ public static final int nINTERFACE = 1;
+ public static final int nSERVICE = 2;
+ public static final int nOTHERS = 3;
+
+ public String getAnchor();
+
+ public String getClassName();
+
+ public void openIdlDescription(String _sIDLUrl);
+
+ public boolean isFilterApplicable(String _sFilter);
+
+ public void setVisible(String _sFilter);
+
+ public void setParameterObjects(Object[] _oParamObjects);
+
+ public Object[] getParameterObjects();
+
+ public String getName();
+
+ public void setFoldable(boolean _bIsFoldable);
+
+ public Object getUnoObject();
+
+ public XUnoNode getParentNode();
+
+ public void addChildNode(XUnoNode _xUnoNode);
+
+ public void setLabel(String _sLabel);
+
+ public String getLabel();
+
+ public int getChildCount();
+
+ public XUnoNode getChild(int _index);
+
+ public int getNodeType();
+
+ // possible values are nINTERFACE, nSERVICE, nOTHERS
+ public void setNodeType(int _nNodeType);
+
+ /** delivers only the Uno-Type when the NodeType is set to nINTERFACE
+ * otherwise (when the NodeType has not been set returns null
+ */
+ public Type getUnoType();
+}
diff --git a/odk/examples/java/Inspector/XUnoPropertyNode.java b/odk/examples/java/Inspector/XUnoPropertyNode.java
new file mode 100644
index 000000000000..e4aa4caba668
--- /dev/null
+++ b/odk/examples/java/Inspector/XUnoPropertyNode.java
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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.Property;
+
+
+public interface XUnoPropertyNode extends XUnoNode {
+
+ public static int nDEFAULT = 0;
+ public static int nPROPERTYSETINFOTYPE = 1;
+ public static int nPROPERTYVALUETYPE = 2;
+
+ public Object getUnoReturnObject();
+
+ public int getPropertyNodeType();
+
+ public void setPropertyNodeType(int _nPropertyType);
+
+ public Property getProperty();
+
+}
diff --git a/odk/examples/java/Inspector/images/containers_16.png b/odk/examples/java/Inspector/images/containers_16.png
new file mode 100755
index 000000000000..0b4c62f11294
--- /dev/null
+++ b/odk/examples/java/Inspector/images/containers_16.png
Binary files differ
diff --git a/odk/examples/java/Inspector/images/content_16.png b/odk/examples/java/Inspector/images/content_16.png
new file mode 100755
index 000000000000..758169260f54
--- /dev/null
+++ b/odk/examples/java/Inspector/images/content_16.png
Binary files differ
diff --git a/odk/examples/java/Inspector/images/interfaces_16.png b/odk/examples/java/Inspector/images/interfaces_16.png
new file mode 100755
index 000000000000..cf633ac9c7c3
--- /dev/null
+++ b/odk/examples/java/Inspector/images/interfaces_16.png
Binary files differ
diff --git a/odk/examples/java/Inspector/images/methods_16.png b/odk/examples/java/Inspector/images/methods_16.png
new file mode 100755
index 000000000000..25cd8b45cf1c
--- /dev/null
+++ b/odk/examples/java/Inspector/images/methods_16.png
Binary files differ
diff --git a/odk/examples/java/Inspector/images/properties_16.png b/odk/examples/java/Inspector/images/properties_16.png
new file mode 100755
index 000000000000..4e22dd1d5ce7
--- /dev/null
+++ b/odk/examples/java/Inspector/images/properties_16.png
Binary files differ
diff --git a/odk/examples/java/Inspector/images/services_16.png b/odk/examples/java/Inspector/images/services_16.png
new file mode 100755
index 000000000000..024a16ed63d3
--- /dev/null
+++ b/odk/examples/java/Inspector/images/services_16.png
Binary files differ
diff --git a/odk/examples/java/Inspector/manifest.mf b/odk/examples/java/Inspector/manifest.mf
new file mode 100755
index 000000000000..328e8e5bc3b7
--- /dev/null
+++ b/odk/examples/java/Inspector/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/odk/examples/java/MinimalComponent/BuildMinimalComponent.xml b/odk/examples/java/MinimalComponent/BuildMinimalComponent.xml
new file mode 100644
index 000000000000..6aa7c5b9322f
--- /dev/null
+++ b/odk/examples/java/MinimalComponent/BuildMinimalComponent.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ author: Bertram Nolte
+ created: 2001-10-11
+ revision: 1.0
+ -->
+<project name="MinimalComponent" basedir="." default="all">
+
+ <target name="init">
+ <!--
+ In this target you have to change all parts, so that the properties
+ fit to your odk installation and to your service
+ -->
+ <property name="ODKPATH" value="D:/cvs/api/odk"/>
+ <property name="OUTPUTPATH" value="D:/cvs/api/odk/WINexample.out"/>
+ <property name="PACKAGE_NAME" value="org.OpenOffice."/>
+ <property name="JAR_FILE_NAME" value="MinimalComponent"/>
+ <property name="INTERFACE_NAME" value="MinimalComponent"/>
+ <property name="RDB_NAME" value="MinimalComponent.rdb"/>
+ </target>
+ <target depends="init" name="unoidl">
+
+ <exec dir="${ODKPATH}/WINexample.out/misc/" executable="${ODKPATH}/windows/bin/idlc.exe" timeout="600">
+ <arg line="-I. -I${ODKPATH}/idl ${ODKPATH}/examples/java/MinimalComponent/${INTERFACE_NAME}.idl"/>
+ </exec>
+
+ <exec dir="." executable="${ODKPATH}/windows/bin/regmerge.exe" timeout="600">
+ <arg line="./${RDB_NAME} /UCR ./${INTERFACE_NAME}.urd"/>
+ </exec>
+
+ <exec dir="." executable="${ODKPATH}/windows/bin/regmerge.exe" timeout="600">
+ <arg line="./${RDB_NAME} / ${ODKPATH}/windows/bin/applicat.rdb"/>
+ </exec>
+
+ <exec dir="." executable="${ODKPATH}/windows/bin/javamaker.exe" timeout="600">
+ <arg line="-BUCR -O${OUTPUTPATH}/class/${INTERFACE_NAME} -nD ./${RDB_NAME}"/>
+<!--
+ <arg line="-BUCR -T${PACKAGE_NAME}${INTERFACE_NAME} -O${OUTPUTPATH}/class/${INTERFACE_NAME} -nD ./${INTERFACE_NAME}.urd"/>
+ -->
+ </exec>
+
+ </target>
+
+ <target depends="init,unoidl" name="compile">
+ <mkdir dir="classes"/>
+ <javac debug="on" destdir="./classes" srcdir="." >
+ <classpath>
+ <fileset dir="${ODKPATH}/classes/">
+ <include name="**/*.jar"/>
+ </fileset>
+ <pathelement location="./classes"/>
+ </classpath>
+ </javac>
+ </target>
+
+ <target depends="compile,init" name="jar">
+ <jar basedir="./classes" compress="true" jarfile="${JAR_FILE_NAME}.jar" manifest="Manifest">
+ </jar>
+ </target>
+
+ <target depends="compile,init,jar" name="all">
+ <!-- WRITEME -->
+ </target>
+</project>
diff --git a/odk/examples/java/MinimalComponent/Makefile b/odk/examples/java/MinimalComponent/Makefile
new file mode 100644
index 000000000000..8fd4ade8fb9d
--- /dev/null
+++ b/odk/examples/java/MinimalComponent/Makefile
@@ -0,0 +1,203 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (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 Minimal 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=MinimalComponent
+SAMPLE_CLASS_OUT=$(OUT_CLASS)/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME)
+
+COMP_NAME=MinimalComponent
+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
+
+APP1_NAME=TestMinimalComponent
+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
+
+IDLFILES = MinimalComponent.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 = MinimalComponent.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 : JavaMinimalComponentExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(COMP_GEN_OUT)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo UNO-Type-Path: $(basename $*).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 example application class files
+$(APP1_CLASS_OUT)/%.class : %.java $(GEN_CLASSFILES)
+ -$(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 $(GEN_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAR) cvfm $@ $< -C $(APP1_CLASS_OUT) .
+ +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) uvf $(@F) $(GEN_CLASSFILENAMES)
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+# 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
+
+JavaMinimalComponentExample : $(COMP_REGISTERFLAG) $(APP1_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo ------
+ @echo The $(COMP_NAME) 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: $(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))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
diff --git a/odk/examples/java/MinimalComponent/MinimalComponent.idl b/odk/examples/java/MinimalComponent/MinimalComponent.idl
new file mode 100644
index 000000000000..c24011ccdafc
--- /dev/null
+++ b/odk/examples/java/MinimalComponent/MinimalComponent.idl
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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_MinimalComponent_idl_
+#define _org_openoffice_MinimalComponent_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. But
+ // here it is used to show the new code generation feature for services.
+ // See the TestMinimalComponent.java how it can be used!
+ service MinimalComponent: ::com::sun::star::lang::XServiceInfo;
+ };
+};
+
+#endif
diff --git a/odk/examples/java/MinimalComponent/MinimalComponent.java b/odk/examples/java/MinimalComponent/MinimalComponent.java
new file mode 100644
index 000000000000..47129efc00d2
--- /dev/null
+++ b/odk/examples/java/MinimalComponent/MinimalComponent.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 MinimalComponent {
+ /** This class implements the component. At least the interfaces XServiceInfo,
+ * XTypeProvider, and XInitialization should be provided by the service.
+ */
+ public static class _MinimalComponent extends WeakBase
+ implements XInitialization, XServiceInfo {
+ /** The service name, that must be used to get an instance of this service.
+ */
+ static private final String __serviceName =
+ "org.openoffice.MinimalComponent";
+
+ /** 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 _MinimalComponent(XComponentContext xCompContext) {
+ try {
+ m_cmpCtx = xCompContext;
+ m_xMCF = m_cmpCtx.getServiceManager();
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ }
+ }
+
+ /** 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.
+ */
+ }
+
+ /** 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 _MinimalComponent.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( _MinimalComponent.class.getName() ) )
+ xFactory = Factory.createComponentFactory(_MinimalComponent.class,
+ _MinimalComponent.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(_MinimalComponent.class.getName(),
+ _MinimalComponent.getServiceNames(),
+ regKey);
+ }
+}
diff --git a/odk/examples/java/MinimalComponent/TestMinimalComponent.java b/odk/examples/java/MinimalComponent/TestMinimalComponent.java
new file mode 100644
index 000000000000..9a6df86f6fe1
--- /dev/null
+++ b/odk/examples/java/MinimalComponent/TestMinimalComponent.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.XSingleComponentFactory;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.container.XSet;
+import com.sun.star.lang.XServiceInfo;
+
+public class TestMinimalComponent {
+ public static void main(String args[]) {
+ com.sun.star.uno.XComponentContext xContext = null;
+
+ try {
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ if( xContext != null )
+ System.out.println("Connected to a running office ...");
+
+ XServiceInfo xSIMinimalComponent =
+ org.openoffice.MinimalComponent.create(xContext);
+
+ System.out.println("\nXServiceInfo is used to get the implementation" +
+ " name: " +
+ xSIMinimalComponent.getImplementationName() +
+ "\nOk\n");
+ xContext = null;
+
+ System.exit(0);
+ }
+ catch( Exception e ) {
+ System.err.println( e );
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+}
diff --git a/odk/examples/java/NotesAccess/Makefile b/odk/examples/java/NotesAccess/Makefile
new file mode 100644
index 000000000000..87e41d3c1e7a
--- /dev/null
+++ b/odk/examples/java/NotesAccess/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 Java NotesAccess 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
+EXAMPLE_NAME=NotesAccessExample
+OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+APP_NAME=NotesAccess
+APP_JAR=$(OUT_APP_CLASS)/$(APP_NAME).jar
+
+JAVAFILES = \
+ NotesAccess.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 : \
+ JavaNotesAccessExample
+
+include $(SETTINGS)/stdtarget.mk
+
+NotesAPIs :
+ @echo --------------------------------------------------------------------------------
+ @echo This example uses external APIs from Lotus Notes/Domino. You can download a
+ @echo trial version from "$(QM)http://www.lotus.com/downloads$(QM)". After installation
+ @echo please do the following:
+ @echo 1. Add the install path to the PATH or LD_LIBRARY_PATH of this shell.
+ @echo e.g "$(QM)PATH=C:\Program Files\lotus\notes;...$(QM)"
+ @echo 2. Add the "$(QM)Notes.jar$(QM)" to your CLASSPATH
+ @echo e.g. "$(QM)CLASSPATH=C:\Program Files\lotus\notes\Notes.jar;$(QM)"
+ @echo --------------------------------------------------------------------------------
+
+
+$(CLASSFILES) : $(JAVAFILES)
+ -$(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 Class-Path: Notes.jar> $@
+ @echo Main-Class: com.sun.star.lib.loader.Loader>> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+$(APP_JAR) : $(OUT_APP_CLASS)/$(APP_NAME).mf $(OUT_APP_CLASS)/$(APP_NAME).class
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(APP_NAME).mf $(APP_NAME).class
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+JavaNotesAccessExample : NotesAPIs $(APP_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo NOTE: Before you run this example make sure that the exaternal "$(QM)Notes.jar$(QM)" can
+ @echo be found besides "$(QM)$(APP_JAR)"$(QM)
+ @echo and that the PATH variable includes the Notes installation directory.
+ @echo -
+ @echo Please use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) NotesAccess.run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(APP_JAR)
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "$(QM)$(QM)" "$(QM)$(QM)" "$(QM)$(QM)" Stocks.nsf
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst \\,\,$(subst /,$(PS),$(OUT_APP_CLASS)))
diff --git a/odk/examples/java/NotesAccess/NotesAccess.java b/odk/examples/java/NotesAccess/NotesAccess.java
new file mode 100644
index 000000000000..f337304e09c7
--- /dev/null
+++ b/odk/examples/java/NotesAccess/NotesAccess.java
@@ -0,0 +1,288 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// Lotus Notes Domino API
+import lotus.domino.NotesThread;
+import lotus.domino.Session;
+import lotus.domino.Database;
+import lotus.domino.DocumentCollection;
+import lotus.domino.Document;
+import lotus.domino.NotesFactory;
+
+// OpenOffice.org API
+import com.sun.star.bridge.XUnoUrlResolver;
+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.sheet.XSpreadsheetDocument;
+import com.sun.star.sheet.XSpreadsheets;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.table.XCell;
+
+/** This class creates an OpenOffice.org Calc spreadsheet document and fills it
+ * with existing values of documents from a Lotus Notes database.
+ */
+public class NotesAccess implements Runnable {
+
+ /** Host server of the Domino Directory.
+ */
+ static String stringHost = "";
+
+ /** User in the host's Domino Directory.
+ */
+ static String stringUser = "";
+
+ /** Password for the user in the host's Domino Directory.
+ */
+ static String stringPassword = "";
+
+ /** Database with documents to get data from.
+ */
+ static String stringDatabase = "";
+
+ /** Reading the arguments and constructing the thread.
+ * @param argv Holding values for the host, user, and the password of the user.
+ */
+ public static void main( String args[] ) {
+ Thread thread;
+
+ if ( args.length < 4 ) {
+ System.out.println(
+ "usage: java -jar NotesAccess.jar \"<Domino Host>\" \"<User>\" " +
+ "\"<Password>\" \"<Database>\"" );
+ System.out.println( "\ne.g.:" );
+ System.out.println(
+ "java -jar NotesAccess.jar \"\" \"\" \"\" \"Stocks.nsf\"" );
+ System.exit( 1 );
+ }
+
+ if ( !args[ 0 ].trim().equals( "" ) ) {
+ stringHost = args[ 0 ].trim();
+ }
+ if ( !args[ 1 ].trim().equals( "" ) ) {
+ stringUser = args[ 1 ].trim();
+ }
+ stringPassword = args[ 2 ].trim();
+
+ try {
+ java.io.File sourceFile = new java.io.File(args[ 3 ].trim());
+ stringDatabase = sourceFile.getCanonicalPath();
+ } catch (java.io.IOException e) {
+ System.out.println("Error: Please check the name or path to your database file.");
+ e.printStackTrace();
+ System.exit( 1 );
+ }
+
+ if ( stringHost.equals( "" ) ) {
+ // Initializing.
+ NotesAccess notesaccess = new NotesAccess();
+
+ // Allowing only local calls to the Domino classes.
+ thread = new NotesThread( ( Runnable ) notesaccess );
+ }
+ else {
+ // Extracting the host, user, and password.
+ NotesAccess notesaccess = new NotesAccess();
+
+ // Allowing remote calls to the Domino classes.
+ thread = new Thread( ( Runnable ) notesaccess );
+ }
+
+ // Starting the thread.
+ thread.start();
+ }
+
+ /** This is the default constructor without arguments.
+ */
+ public NotesAccess() {
+ }
+
+ /** Reading all documents from the given database and writing the data to
+ * an OpenOffice.org Calc spreadsheet document.
+ */
+ public void run() {
+ try {
+ // get the remote office component context
+ XComponentContext xContext =
+ com.sun.star.comp.helper.Bootstrap.bootstrap();
+
+ System.out.println("Connected to a running office ...");
+
+ XMultiComponentFactory xMCF = xContext.getServiceManager();
+
+ /* A desktop environment contains tasks with one or more
+ frames in which components can be loaded. Desktop is the
+ environment for components which can instanciate within
+ frames. */
+ XComponentLoader xLoader = ( XComponentLoader )
+ UnoRuntime.queryInterface(XComponentLoader.class,
+ xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xContext));
+
+ // Load a Writer document, which will be automaticly displayed
+ XComponent xComponent = xLoader.loadComponentFromURL(
+ "private:factory/scalc", "_blank", 0,
+ new PropertyValue[0] );
+
+ // Querying for the interface XSpreadsheetDocument
+ XSpreadsheetDocument xSpreadsheetDoc =
+ (XSpreadsheetDocument) UnoRuntime.queryInterface(
+ XSpreadsheetDocument.class, xComponent);
+
+ // Getting all sheets from the spreadsheet document.
+ XSpreadsheets xSpreadsheets = xSpreadsheetDoc.getSheets() ;
+
+ // Querying for the interface XIndexAccess.
+ XIndexAccess xIndexAccess = (XIndexAccess) UnoRuntime.queryInterface(
+ XIndexAccess.class, xSpreadsheets);
+
+ // Getting the first spreadsheet.
+ XSpreadsheet xSpreadsheet = (XSpreadsheet) UnoRuntime.queryInterface(
+ XSpreadsheet.class, xIndexAccess.getByIndex(0));
+
+ Session session;
+ if ( !stringHost.equals( "" ) ) {
+ // Creating a Notes session for remote calls to the Domino classes.
+ session = NotesFactory.createSession(stringHost, stringUser,
+ stringPassword);
+ }
+ else {
+ // Creating a Notes session for only local calls to the
+ // Domino classes.
+ session = NotesFactory.createSession();
+ }
+
+ // Getting the specified Notes database.
+ Database database = session.getDatabase( "", stringDatabase );
+
+ // Getting a collection of all documents from the database.
+ DocumentCollection documentCollection = database.getAllDocuments();
+
+ // Getting the first document from the database
+ Document document = documentCollection.getFirstDocument();
+
+ // Start to write to cells at this row.
+ int intRowToStart = 0;
+
+ // The current row.
+ int intRow = intRowToStart;
+
+ // The current column.
+ int intColumn = 0;
+
+ // Process all documents
+ while ( document != null ) {
+ // Getting the name of the stock.
+ String stringName = document.getItemValueString("Name");
+
+ // Inserting the name to a specified cell.
+ insertIntoCell(intColumn, intRow, stringName, xSpreadsheet, "");
+
+ // Getting the number of stocks.
+ double intNumber = document.getItemValueInteger( "Number" );
+
+ // Inserting the number of stocks to a specified cell.
+ insertIntoCell( intColumn + 1, intRow, String.valueOf(intNumber),
+ xSpreadsheet, "V" );
+
+ // Getting current share price.
+ double doubleSharePrice = document.getItemValueDouble("SharePrice");
+
+ // Inserting the current share price to a specified cell.
+ insertIntoCell(intColumn + 2, intRow,
+ String.valueOf(doubleSharePrice),
+ xSpreadsheet, "V");
+
+ // Inserting the total value.
+ insertIntoCell(intColumn + 3, intRow, "=B"
+ + String.valueOf( intRow + 1 )
+ + "*C" + String.valueOf(intRow + 1),
+ xSpreadsheet, "");
+
+ // Increasing the current row.
+ intRow++;
+
+ // Getting the next document from the collection.
+ document = documentCollection.getNextDocument();
+ }
+
+ // Summing all specific amounts.
+ insertIntoCell(intColumn + 3, intRow, "=sum(D"
+ + String.valueOf( intRowToStart + 1 ) + ":D"
+ + String.valueOf( intRow ),
+ xSpreadsheet, "");
+
+ xContext = null;
+
+ // Leaving the program.
+ System.exit(0);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /** Inserting a value or formula to a cell defined by the row and column.
+ * @param intCellX Row.
+ * @param intCellY Column.
+ * @param stringValue This value will be written to the cell.
+ * @param xSpreadsheet Write the value to the cells of this spreadsheet.
+ * @param stringFlag If this string contains "V", the value will be written,
+ * otherwise the formula.
+ */
+ public static void insertIntoCell(int intCellX, int intCellY,
+ String stringValue,
+ XSpreadsheet xSpreadsheet,
+ String stringFlag)
+ {
+ XCell xCell = null;
+
+ try {
+ xCell = xSpreadsheet.getCellByPosition( intCellX, intCellY );
+ } catch ( com.sun.star.lang.IndexOutOfBoundsException exception ) {
+ System.out.println( "Could not get Cell" );
+ }
+ if ( stringFlag.equals( "V" )) {
+ xCell.setValue((new Float(stringValue)).floatValue());
+ }
+ else {
+ xCell.setFormula(stringValue);
+ }
+ }
+}
diff --git a/odk/examples/java/NotesAccess/Stocks.nsf b/odk/examples/java/NotesAccess/Stocks.nsf
new file mode 100644
index 000000000000..10ed138ed3b6
--- /dev/null
+++ b/odk/examples/java/NotesAccess/Stocks.nsf
Binary files differ
diff --git a/odk/examples/java/PropertySet/Makefile b/odk/examples/java/PropertySet/Makefile
new file mode 100644
index 000000000000..0a382d15042e
--- /dev/null
+++ b/odk/examples/java/PropertySet/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 Java PropertySet 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=PropTest
+COMP_CLASS_OUT=$(OUT_CLASS)/$(COMP_NAME)
+COMP_GEN_OUT=$(OUT_MISC)/$(COMP_NAME)
+COMP_PACKAGE=$(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_JAR_NAME=$(COMP_NAME).uno.jar
+COMP_JAR=$(COMP_CLASS_OUT)/$(COMP_JAR_NAME)
+COMP_JAR_MANIFEST=$(COMP_CLASS_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_JAVAFILES = PropTest.java
+
+COMP_CLASSFILES = $(patsubst %.java,$(COMP_CLASS_OUT)/%.class,$(COMP_JAVAFILES))
+
+$(COMP_NAME)_CLASSFILES = $(COMP_NAME).class
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(COMP_CLASS_OUT))
+
+
+# Targets
+.PHONY: ALL
+ALL : JavaPropertySetExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(COMP_CLASS_OUT)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo RegistrationClassName: $(basename $(basename $(@F)))> $@
+
+$(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_JAR_MANIFEST) $(COMP_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(COMP_CLASS_OUT)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
+
+# 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-component;type=Java$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_MISC)/,,$(@D))).uno.jar$(QM)"/$(CSEP) >> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(COMP_JAR) $(COMP_UNOPKG_MANIFEST)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(COMP_CLASS_OUT)) && $(SDK_ZIP) ../../bin/$(@F) $(<F)
+ 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
+
+JavaPropertySetExample : $(COMP_REGISTERFLAG)
+ @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) PropertySet.odt.load
+ @echo --------------------------------------------------------------------------------
+
+PropertySet.odt.load : $(COMP_REGISTERFLAG)
+ "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(COMP_CLASS_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(COMP_GEN_OUT))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
diff --git a/odk/examples/java/PropertySet/PropTest.java b/odk/examples/java/PropertySet/PropTest.java
new file mode 100644
index 000000000000..e8652c7689bb
--- /dev/null
+++ b/odk/examples/java/PropertySet/PropTest.java
@@ -0,0 +1,265 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+/*
+This example shows a UNO component that inherits com.sun.star.lib.uno.helper.PropertySet in
+order to provide implementations of these interfaces:
+
+ com.sun.star.beans.XPropertySet
+ com.sun.star.beans.XMultiPropertySet
+ com.sun.star.beans.XFastPropertySet
+ com.sun.star.lang.XComponent
+ com.sun.star.uno.XWeak
+ com.sun.star.lang.XTypeProvider
+*/
+import com.sun.star.lib.uno.helper.PropertySet;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.beans.PropertyAttribute;
+
+/**
+ This component contains the followin properties:
+ * <table border>
+ * <tr>
+ * <th> Property Name </th>
+ * <th> Type Name </th>
+ * <th> PropertyAttribute </th>
+ * <tr><td>boolA</td><td>BOOLEAN</td><td> - </td</tr>
+ * <tr><td>charA</td><td>CHAR</td><td> - </td></tr>
+ * <tr><td>byteA</td><td>BYTE</td><td> - </td></tr>
+ * <tr><td>shortA</td><td>SHORT</td><td> - </td></tr>
+ * <tr><td>intA</td><td>LONG</td><td> - </td></tr>
+ * <tr><td>longA</td><td>HYPER</td><td> - </td></tr>
+ * <tr><td>floatA</td><td>FLOAT</td><td> - </td></tr>
+ * <tr><td>doubleA</td><td>DOUBLE</td><td> - </td></tr>
+ * <tr><td>stringA</td><td>STRING</td><td> - </td></tr>
+ * <tr><td>objectA</td><td>ANY</td><td> - </td></tr>
+ * <tr><td>anyA</td><td>ANY</td><td> - </td></tr>
+ * <tr><td>typeA</td><td>TYPE</td><td> - </td></tr>
+ * <tr><td>xinterfaceA</td><td>INTERFACE</td><td> - </td></tr>
+ * <tr><td>xtypeproviderA</td><td>INTERFACE</td><td> - </td></tr>
+ * <tr><td>arBoolA</td><td>[]boolean</td><td> - </td></tr>
+ * <tr><td>arCharA</td><td>[]char</td><td> - </td></tr>
+ * <tr><td>arByteA</td><td>[]byte</td><td> - </td></tr>
+ * <tr><td>arShortA</td><td>[]short</td><td> - </td></tr>
+ * <tr><td>arIntA</td><td>[]long</td><td> - </td></tr>
+ * <tr><td>arLongA</td><td>[]hyper</td><td> - </td></tr>
+ * <tr><td>arFloatA</td><td>[]float</td><td> - </td></tr>
+ * <tr><td>arDoubleA</td><td>[]double</td><td> - </td></tr>
+ * <tr><td>arStringA</td><td>[]string</td><td> - </td></tr>
+ * <tr><td>arObjectA</td><td>[]any</td><td> - </td></tr>
+ * <tr><td>arXinterfaceA</td><td>[]com.sun.star.uno.XInterface</td><td> - </td></tr>
+ * <tr><td>ar2BoolA</td><td>[][]boolean</td><td> - </td></tr>
+ * <tr><td>boolClassA</td><td>boolean</td><td> - </td></tr>
+ * <tr><td>charClassA</td><td>char</td><td> - </td></tr>
+ * <tr><td>byteClassA</td><td>byte</td><td> - </td></tr>
+ * <tr><td>shortClassA</td><td>short</td><td> - </td></tr>
+ * <tr><td>intClassA</td><td>long</td><td> - </td></tr>
+ * <tr><td>longClassA</td><td>hyper</td><td> - </td></tr>
+ * <tr><td>floatClassA</td><td>float</td><td> - </td></tr>
+ * <tr><td>doubleClassA</td><td>double</td><td> - </td></tr>
+ * <tr><td>roIntA</td><td>long</td><td>READONLY</td></tr>
+ * <tr><td>roIntClassA</td><td>long</td><td>READONLY</td></tr>
+ * <tr><td>roObjectA</td><td>any</td><td>READONLY</td></tr>
+ * <tr><td>roAnyA</td><td>any</td><td>READONLY</td></tr>
+ * <tr><td>bcBoolA</td><td>boolean</td><td>BOUND,CONSTRAINED</td></tr>
+ * <tr><td>bcBoolClassA</td><td>boolean</td><td>BOUND,CONSTRAINED</td></tr>
+ * <tr><td>bcObjectA</td><td>any</td><td>BOUND,CONSTRAINED</td></tr>
+ * <tr><td>bcAnyA</td><td>any</td><td>BOUND,CONSTRAINED</td></tr>
+ * <tr><td>mvIntA</td><td>long</td><td>MAYBEVOID</td></tr>
+ * <tr><td>mvObjectA</td><td>any</td><td>MAYBEVOID</td></tr>
+ * <tr><td>mvAnyA</td><td>any</td><td>MAYBEVOID</td></tr>
+ * <tr><td>mvXinterfaceA</td><td>any</td><td>MAYBEVOID</td></tr>
+ </table>
+*/
+
+public class PropTest extends PropertySet implements XServiceInfo
+{
+
+ public boolean boolA;
+ public char charA;
+ public byte byteA;
+ public short shortA;
+ public int intA;
+ public long longA;
+ public float floatA;
+ public double doubleA;
+ public String stringA; // MAYBEVOID
+ public Object objectA; // MAYBEVOID
+ public Any anyA; // MAYBEVOID
+ public Type typeA;// MAYBEVOID
+ public XInterface xinterfaceA;// MAYBEVOID
+ public XTypeProvider xtypeproviderA;// MAYBEVOID
+ public boolean[] arBoolA; // MAYBEVOID
+ public char[] arCharA; // MAYBEVOID
+ public byte[] arByteA; // MAYBEVOID
+ public short[] arShortA; // MAYBEVOID
+ public int[] arIntA; // MAYBEVOID
+ public long[] arLongA; // MAYBEVOID
+ public float[] arFloatA; // MAYBEVOID
+ public double[] arDoubleA; // MAYBEVOID
+ public String[] arStringA; // MAYBEVOID
+ public Object[] arObjectA; // MAYBEVOID
+ public Any[] arAnyA; // MAYBEVOID
+ public XInterface[] arXinterfaceA; // MAYBEVOID
+ public boolean[][] ar2BoolA; // MAYBEVOID
+ public Boolean boolClassA; // MAYBEVOID
+ public Character charClassA; // MAYBEVOID
+ public Byte byteClassA; // MAYBEVOID
+ public Short shortClassA; // MAYBEVOID
+ public Integer intClassA; // MAYBEVOID
+ public Long longClassA; // MAYBEVOID
+ public Float floatClassA; // MAYBEVOID
+ public Double doubleClassA; // MAYBEVOID
+
+ // readonly
+ public int roIntA= 100;
+ public Integer roIntClassA= new Integer(100);
+ public Object roObjectA= new Integer(101);
+ public Any roAnyA= new Any( new Type(int.class), new Integer(102));
+
+ // BOUND & CONSTRAINED
+ public boolean bcBoolA;
+ public Boolean bcBoolClassA; // MAYBEVOID
+ public Object bcObjectA; // MAYBEVOID
+ public Any bcAnyA; // MAYBEVOID
+
+ // MAYBEVOID
+ public Integer mvIntA;
+ public Object mvObjectA;
+ public Any mvAnyA;
+ public XInterface mvXinterfaceA;
+
+ public static final String __serviceName="PropTest";
+
+ public PropTest() {
+ registerProperty("boolA", (short) 0);
+ registerProperty("charA", (short) 0);
+ registerProperty("byteA", (short) 0);
+ registerProperty("shortA", (short) 0);
+ registerProperty("intA", (short) 0);
+ registerProperty("longA", (short) 0);
+ registerProperty("floatA", (short) 0);
+ registerProperty("doubleA", (short) 0);
+ registerProperty("stringA", PropertyAttribute.MAYBEVOID);
+ registerProperty("objectA", PropertyAttribute.MAYBEVOID);
+ registerProperty("anyA", PropertyAttribute.MAYBEVOID);
+ registerProperty("typeA", PropertyAttribute.MAYBEVOID);
+ registerProperty("xinterfaceA", PropertyAttribute.MAYBEVOID);
+ registerProperty("xtypeproviderA", PropertyAttribute.MAYBEVOID);
+ registerProperty("arBoolA", PropertyAttribute.MAYBEVOID);
+ registerProperty("arCharA", PropertyAttribute.MAYBEVOID);
+ registerProperty("arByteA", PropertyAttribute.MAYBEVOID);
+ registerProperty("arShortA", PropertyAttribute.MAYBEVOID);
+ registerProperty("arIntA", PropertyAttribute.MAYBEVOID);
+ registerProperty("arLongA", PropertyAttribute.MAYBEVOID);
+ registerProperty("arFloatA", PropertyAttribute.MAYBEVOID);
+ registerProperty("arDoubleA", PropertyAttribute.MAYBEVOID);
+ registerProperty("arStringA", PropertyAttribute.MAYBEVOID);
+ registerProperty("arObjectA", PropertyAttribute.MAYBEVOID);
+ registerProperty("arAnyA", PropertyAttribute.MAYBEVOID);
+ registerProperty("arXinterfaceA", PropertyAttribute.MAYBEVOID);
+ registerProperty("ar2BoolA", PropertyAttribute.MAYBEVOID);
+ registerProperty("boolClassA", PropertyAttribute.MAYBEVOID);
+ registerProperty("charClassA", PropertyAttribute.MAYBEVOID);
+ registerProperty("byteClassA", PropertyAttribute.MAYBEVOID);
+ registerProperty("shortClassA", PropertyAttribute.MAYBEVOID);
+ registerProperty("intClassA", PropertyAttribute.MAYBEVOID);
+ registerProperty("longClassA", PropertyAttribute.MAYBEVOID);
+ registerProperty("floatClassA", PropertyAttribute.MAYBEVOID);
+ registerProperty("doubleClassA", PropertyAttribute.MAYBEVOID);
+ registerProperty("roIntA", PropertyAttribute.READONLY);
+ registerProperty("roIntClassA", PropertyAttribute.READONLY);
+ registerProperty("roObjectA", PropertyAttribute.READONLY);
+ registerProperty("roAnyA", PropertyAttribute.READONLY);
+ registerProperty("bcBoolA",(short) ( PropertyAttribute.BOUND | PropertyAttribute.CONSTRAINED));
+ registerProperty("bcBoolClassA", (short) (PropertyAttribute.BOUND | PropertyAttribute.CONSTRAINED | PropertyAttribute.MAYBEVOID));
+ registerProperty("bcObjectA", (short) (PropertyAttribute.BOUND | PropertyAttribute.CONSTRAINED | PropertyAttribute.MAYBEVOID));
+ registerProperty("bcAnyA", (short) (PropertyAttribute.BOUND | PropertyAttribute.CONSTRAINED |PropertyAttribute.MAYBEVOID));
+ registerProperty("mvIntA", PropertyAttribute.MAYBEVOID);
+ registerProperty("mvObjectA", PropertyAttribute.MAYBEVOID);
+ registerProperty("mvAnyA", PropertyAttribute.MAYBEVOID);
+ registerProperty("mvXinterfaceA", PropertyAttribute.MAYBEVOID);
+ }
+
+
+ // XServiceName
+ public String getImplementationName( )
+ {
+ return getClass().getName();
+ }
+
+ // XServiceName
+ public boolean supportsService( /*IN*/String name )
+ {
+ if (name.equals(__serviceName))
+ return true;
+ return false;
+ }
+
+ //XServiceName
+ public String[] getSupportedServiceNames( )
+ {
+ String[] retValue= new String[]{__serviceName};
+ return retValue;
+ }
+
+ public static XSingleServiceFactory __getServiceFactory(String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey)
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if (implName.equals( PropTest.class.getName()) )
+ xSingleServiceFactory = FactoryHelper.getServiceFactory( PropTest.class,
+ PropTest.__serviceName,
+ multiFactory,
+ regKey);
+
+ return xSingleServiceFactory;
+ }
+
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey)
+ {
+ return FactoryHelper.writeRegistryServiceInfo( PropTest.class.getName(),
+ PropTest.__serviceName, regKey);
+ }
+}
diff --git a/odk/examples/java/PropertySet/PropertySet.odt b/odk/examples/java/PropertySet/PropertySet.odt
new file mode 100644
index 000000000000..31d326e4106f
--- /dev/null
+++ b/odk/examples/java/PropertySet/PropertySet.odt
Binary files differ
diff --git a/odk/examples/java/Spreadsheet/CalcAddins.java b/odk/examples/java/Spreadsheet/CalcAddins.java
new file mode 100644
index 000000000000..6a052a7e2eea
--- /dev/null
+++ b/odk/examples/java/Spreadsheet/CalcAddins.java
@@ -0,0 +1,304 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// Template for an Office Calc add-in Java implementation file.
+
+/** You can find more
+ * information on the following web page:
+ * http://api.openoffice.org/common/ref/com/sun/star/index.html
+ */
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XServiceName;
+import com.sun.star.sheet.XAddIn;
+import com.sun.star.lang.Locale;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.uno.Type;
+
+import org.openoffice.sheet.addin.XCalcAddins;
+
+/** This outer class provides an inner class to implement the service
+ * description, a method to instantiate the
+ * component on demand (__getServiceFactory()), and a method to give
+ * information about the component (__writeRegistryServiceInfo()).
+ */
+public class CalcAddins {
+
+/** This inner class provides the component as a concrete implementation
+ * of the service description. It implements the needed interfaces.
+ * @implements XCalcAddins, XAddIn, XServiceName, XServiceInfo, XTypeProvider
+ */
+ static public class _CalcAddins extends WeakBase implements
+ XCalcAddins,
+ XAddIn,
+ XServiceName,
+ XServiceInfo
+ {
+
+/** The component will be registered under this name.
+ */
+ static private final String __serviceName = "org.openoffice.sheet.addin.CalcAddins";
+
+ static private final String ADDIN_SERVICE = "com.sun.star.sheet.AddIn";
+
+ private Locale aFuncLoc;
+
+ private static final String[] stringFunctionName = {
+/** TO DO:
+ * You should replace these method names by the method names of your interface.
+ */
+ "getMyFirstValue",
+ "getMySecondValue"
+ };
+
+ private static final short shortINVALID = -1;
+
+/** TO DO:
+ * For each of your methods you should make up a new constant with a different value.
+ */
+ private static final short shortGETMYFIRSTVALUE = 0;
+ private static final short shortGETMYSECONDVALUE = 1;
+
+
+/** TO DO:
+ * This is where you implement all methods of your interface. The parameters have to
+ * be the same as in your IDL file and their types have to be the correct
+ * IDL-to-Java mappings of their types in the IDL file.
+ */
+ public int getMyFirstValue(
+ com.sun.star.beans.XPropertySet xOptions
+ ) {
+ return (int) 1;
+ }
+
+ public int getMySecondValue(
+ com.sun.star.beans.XPropertySet xOptions,
+ int intDummy
+ ) {
+ return( (int) ( 2 + intDummy ) );
+ }
+
+
+ // Implement method from interface XServiceName
+ public String getServiceName() {
+ return( __serviceName );
+ }
+
+ // Implement methods from interface XServiceInfo
+ public boolean supportsService(String stringServiceName) {
+ return( stringServiceName.equals( ADDIN_SERVICE ) ||
+ stringServiceName.equals( __serviceName ) );
+ }
+
+ public String getImplementationName() {
+ return( _CalcAddins.class.getName() );
+ }
+
+ public String[] getSupportedServiceNames() {
+ String[] stringSupportedServiceNames = { ADDIN_SERVICE, __serviceName };
+ return( stringSupportedServiceNames );
+ }
+
+ // Implement methods from interface XAddIn
+ public String getDisplayArgumentName(String stringProgrammaticFunctionName,int intArgument) {
+ String stringReturn = "";
+
+ switch( this.getFunctionID( stringProgrammaticFunctionName ) ) {
+/** TO DO:
+ * You should list all argument names for each of your methods, here.
+ */
+ case shortGETMYFIRSTVALUE:
+ switch( intArgument ) {
+ case 0:
+ stringReturn = "(internal)";
+ break;
+ }
+ break;
+ case shortGETMYSECONDVALUE:
+ switch( intArgument ) {
+ case 0:
+ stringReturn = "(internal)";
+ break;
+ case 1:
+ stringReturn = "intDummy";
+ break;
+ }
+ break;
+ }
+ return( stringReturn );
+ }
+
+ public String getDisplayFunctionName(String stringProgrammaticName) {
+ String stringReturn = "";
+
+ switch( this.getFunctionID( stringProgrammaticName ) ) {
+/** TO DO:
+ * Assign the name of each of your methods.
+ */
+ case shortGETMYFIRSTVALUE:
+ stringReturn = "getMyFirstValue";
+ break;
+ case shortGETMYSECONDVALUE:
+ stringReturn = "getMySecondValue";
+ break;
+ }
+
+ return( stringReturn );
+ }
+
+ public String getProgrammaticCategoryName(String p1) {
+ return( "Add-In" );
+ }
+
+ public String getDisplayCategoryName(String p1) {
+ return( "Add-In" );
+ }
+
+ public String getFunctionDescription(String stringProgrammaticName) {
+ String stringReturn = "";
+
+ switch( this.getFunctionID( stringProgrammaticName ) ) {
+/** TO DO:
+ * Enter a description for each of your methods that office users will understand.
+ */
+ case shortGETMYFIRSTVALUE:
+ stringReturn = "This is your first method.";
+ break;
+ case shortGETMYSECONDVALUE:
+ stringReturn = "This is your second method.";
+ break;
+ }
+
+ return( stringReturn );
+ }
+
+ public String getArgumentDescription(String stringProgrammaticFunctionName,int intArgument) {
+ String stringReturn = "";
+
+ switch( this.getFunctionID( stringProgrammaticFunctionName ) ) {
+/** TO DO:
+ * Enter a description for every argument of every method. Make them so that office users will understand.
+ */
+ case shortGETMYFIRSTVALUE:
+ switch( intArgument ) {
+ case 0:
+ stringReturn = "(internal)";
+ break;
+ }
+ break;
+ case shortGETMYSECONDVALUE:
+ switch( intArgument ) {
+ case 0:
+ stringReturn = "(internal)";
+ break;
+ case 1:
+ stringReturn = "You can add this value.";
+ break;
+ }
+ break;
+ }
+ return( stringReturn );
+ }
+
+ public String getProgrammaticFuntionName(String p1) {
+ return( "" );
+ }
+
+ // Implement methods from interface XLocalizable
+ public Locale getLocale() {
+ return( aFuncLoc );
+ }
+
+ public void setLocale(Locale p1) {
+ aFuncLoc = p1;
+ }
+
+ // Auxiliary functions
+ private short getFunctionID( String stringProgrammaticName ) {
+ for ( int i = 0; i < stringFunctionName.length; i++ ) {
+ if ( stringProgrammaticName.equals( stringFunctionName[ i ] ) ) {
+ return( ( short ) i );
+ }
+ }
+
+ return( -1 );
+ }
+ }
+
+ /**
+ * 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,
+ XRegistryKey regKey) {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if (implName.equals(_CalcAddins.class.getName()) )
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(_CalcAddins.class,
+ _CalcAddins.__serviceName,
+ multiFactory,
+ regKey);
+
+ return xSingleServiceFactory;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
+ return FactoryHelper.writeRegistryServiceInfo(_CalcAddins.class.getName(),
+ _CalcAddins.__serviceName, regKey)
+ && FactoryHelper.writeRegistryServiceInfo(_CalcAddins.class.getName(),
+ _CalcAddins.ADDIN_SERVICE, regKey);
+ }
+}
diff --git a/odk/examples/java/Spreadsheet/CalcAddins.ods b/odk/examples/java/Spreadsheet/CalcAddins.ods
new file mode 100644
index 000000000000..133539d5a554
--- /dev/null
+++ b/odk/examples/java/Spreadsheet/CalcAddins.ods
Binary files differ
diff --git a/odk/examples/java/Spreadsheet/ChartTypeChange.java b/odk/examples/java/Spreadsheet/ChartTypeChange.java
new file mode 100644
index 000000000000..1a86ee3d0b97
--- /dev/null
+++ b/odk/examples/java/Spreadsheet/ChartTypeChange.java
@@ -0,0 +1,355 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.chart.XDiagram;
+import com.sun.star.chart.XChartDocument;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XIndexAccess;
+
+import com.sun.star.document.XEmbeddedObjectSupplier;
+
+import com.sun.star.frame.XComponentLoader;
+
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XMultiComponentFactory;
+
+import com.sun.star.sheet.XSpreadsheets;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.sheet.XCellRangeAddressable;
+
+import com.sun.star.table.XTableChart;
+import com.sun.star.table.XTableCharts;
+import com.sun.star.table.XCell;
+import com.sun.star.table.XCellRange;
+import com.sun.star.table.XTableChartsSupplier;
+import com.sun.star.table.CellRangeAddress;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.XComponentContext;
+
+
+
+/** This class loads an OpenOffice.org Calc document and changes the type of the
+ * embedded chart.
+ * @author Bertram Nolte
+ */
+public class ChartTypeChange {
+
+ /** Table chart, which type will be changed.
+ */
+ private XTableChart xtablechart = null;
+
+ /** Service factory
+ */
+ private XMultiComponentFactory xMCF = null;
+
+ /** Component context
+ */
+ private XComponentContext xCompContext = null;
+
+ /** Beginning of the program.
+ * @param args No arguments will be passed to the class.
+ */
+ public static void main(String args[]) {
+ try {
+ ChartTypeChange charttypechange = new ChartTypeChange();
+
+ // Double array holding all values the chart should be based on.
+ String[][] stringValues = {
+ { "", "Jan", "Feb", "Mar", "Apr", "Mai" },
+ { "Profit", "12.3", "43.2", "5.1", "76", "56.8" },
+ { "Rival in business", "12.2", "12.6", "17.7", "20.4", "100" },
+ };
+
+ // Create the chart with
+ charttypechange.getChart( stringValues );
+
+ String[] stringChartType = {
+ "com.sun.star.chart.LineDiagram",
+ "com.sun.star.chart.BarDiagram",
+ "com.sun.star.chart.PieDiagram",
+ "com.sun.star.chart.NetDiagram",
+ "com.sun.star.chart.XYDiagram",
+ "com.sun.star.chart.StockDiagram",
+ "com.sun.star.chart.AreaDiagram"
+ };
+
+ for ( int intCounter = 0; intCounter < stringChartType.length;
+ intCounter++ ) {
+ charttypechange.changeChartType( stringChartType[ intCounter ],
+ false );
+ Thread.sleep( 3000 );
+ }
+
+ System.exit(0);
+ }
+ catch( Exception exception ) {
+ System.err.println( exception );
+ }
+ }
+
+ /** The constructor connects to the OpenOffice.org.
+ * @param args Parameters for this constructor (connection string).
+ * @throws Exception All exceptions are thrown from this method.
+ */
+ public ChartTypeChange()
+ throws Exception {
+
+ /* Bootstraps a component context. Component context to be granted
+ to a component for running. Arbitrary values can be retrieved
+ from the context. */
+ xCompContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+
+ /* Gets the service manager instance to be used (or null). This method has
+ been added for convenience, because the service manager is a often used
+ object. */
+ xMCF = xCompContext.getServiceManager();
+ }
+
+ /** This method will change the type of a specified chart.
+ * @param stringType The chart will be converted to this type.
+ * @param booleanIs3D If the chart should be displayed in 3D this parameter should be set to true.
+ * @throws Exception All exceptions are thrown from this method.
+ */
+ public void changeChartType( String stringType, boolean booleanIs3D )
+ throws Exception {
+ XEmbeddedObjectSupplier xEmbeddedObjSupplier = (XEmbeddedObjectSupplier)
+ UnoRuntime.queryInterface(XEmbeddedObjectSupplier.class, xtablechart);
+ XInterface xInterface = xEmbeddedObjSupplier.getEmbeddedObject();
+
+ XChartDocument xChartDoc = (XChartDocument)UnoRuntime.queryInterface(
+ XChartDocument.class, xInterface);
+ XDiagram xDiagram = (XDiagram) xChartDoc.getDiagram();
+ XMultiServiceFactory xMSF = (XMultiServiceFactory)
+ UnoRuntime.queryInterface( XMultiServiceFactory.class, xChartDoc );
+ Object object = xMSF.createInstance( stringType );
+ xDiagram = (XDiagram) UnoRuntime.queryInterface(XDiagram.class, object);
+
+ XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, xDiagram );
+ xPropSet.setPropertyValue( "Dim3D", new Boolean( booleanIs3D ) );
+
+ xChartDoc.setDiagram(xDiagram);
+ }
+
+ /** Loading an OpenOffice.org Calc document and getting a chart by name.
+ * @param stringFileName Name of the OpenOffice.org Calc document which should
+ * be loaded.
+ * @param stringChartName Name of the chart which should get a new chart type.
+ */
+ public void getChart( String stringFileName, String stringChartName ) {
+ try {
+ /* A desktop environment contains tasks with one or more
+ frames in which components can be loaded. Desktop is the
+ environment for components which can instanciate within
+ frames. */
+ XComponentLoader xComponentloader = (XComponentLoader)
+ UnoRuntime.queryInterface( XComponentLoader.class,
+ xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
+ xCompContext ) );
+
+ // Load a Writer document, which will be automaticly displayed
+ XComponent xComponent = xComponentloader.loadComponentFromURL(
+ "file:///" + stringFileName, "_blank", 0,
+ new PropertyValue[0] );
+
+ // Query for the interface XSpreadsheetDocument
+ XSpreadsheetDocument xSpreadSheetDocument = ( XSpreadsheetDocument )
+ UnoRuntime.queryInterface( XSpreadsheetDocument.class, xComponent );
+
+ XSpreadsheets xSpreadsheets = xSpreadSheetDocument.getSheets() ;
+
+ XIndexAccess xIndexAccess = (XIndexAccess)
+ UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets );
+
+ XSpreadsheet xSpreadsheet = (XSpreadsheet) UnoRuntime.queryInterface(
+ XSpreadsheet.class, xIndexAccess.getByIndex(0));
+
+ XTableChartsSupplier xTableChartsSupplier = ( XTableChartsSupplier )
+ UnoRuntime.queryInterface( XTableChartsSupplier.class, xSpreadsheet );
+
+ xIndexAccess = (XIndexAccess) UnoRuntime.queryInterface(
+ XIndexAccess.class, xTableChartsSupplier.getCharts() );
+
+ this.xtablechart = (XTableChart) UnoRuntime.queryInterface(
+ XTableChart.class, xIndexAccess.getByIndex( 0 ) );
+ }
+ catch( Exception exception ) {
+ System.err.println( exception );
+ }
+ }
+
+ /** Creating an empty OpenOffice.org Calc document, inserting data, and getting a
+ * chart by name.
+ * @param stringValues Double array with the values for the chart.
+ */
+ public void getChart( String[][] stringValues ) {
+ try {
+ /* A desktop environment contains tasks with one or more
+ frames in which components can be loaded. Desktop is the
+ environment for components which can instanciate within
+ frames. */
+ XComponentLoader xcomponentloader = ( XComponentLoader )
+ UnoRuntime.queryInterface( XComponentLoader.class,
+ xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop",
+ xCompContext ) );
+
+ // Create an empty calc document, which will be automaticly displayed
+ XComponent xComponent = xcomponentloader.loadComponentFromURL(
+ "private:factory/scalc", "_blank", 0,
+ new PropertyValue[0] );
+
+ // Query for the interface XSpreadsheetDocument
+ XSpreadsheetDocument xspreadsheetdocument = ( XSpreadsheetDocument )
+ UnoRuntime.queryInterface( XSpreadsheetDocument.class, xComponent );
+
+ // Get all sheets of the spreadsheet document.
+ XSpreadsheets xspreadsheets = xspreadsheetdocument.getSheets() ;
+
+ // Get the index of the spreadsheet document.
+ XIndexAccess xindexaccess = (XIndexAccess) UnoRuntime.queryInterface(
+ XIndexAccess.class, xspreadsheets );
+
+ // Get the first spreadsheet.
+ XSpreadsheet xspreadsheet = (XSpreadsheet) UnoRuntime.queryInterface(
+ XSpreadsheet.class, xindexaccess.getByIndex(0));
+
+ // The double array will written to the spreadsheet
+ for ( int intY = 0; intY < stringValues.length; intY++ ) {
+ for ( int intX = 0; intX < stringValues[ intY ].length;
+ intX++ ) {
+ // Insert the value to the cell, specified by intY and intX.
+ this.insertIntoCell( intY, intX,
+ stringValues[ intY ][ intX ], xspreadsheet, "" );
+ }
+ }
+
+ // Create a rectangle, which holds the size of the chart.
+ Rectangle rectangle = new Rectangle();
+ rectangle.X = 500;
+ rectangle.Y = 3000;
+ rectangle.Width = 25000;
+ rectangle.Height = 11000;
+
+ // Get the cell range of the spreadsheet.
+ XCellRange xcellrange = ( XCellRange ) UnoRuntime.queryInterface(
+ XCellRange.class, xspreadsheet );
+
+ // Create the Unicode of the character for the column name.
+ char charRectangle = ( char ) ( 65 + stringValues.length - 1 );
+
+ // Get maximum length all rows in the double array.
+ int intMaximumWidthRow = 0;
+ for ( int intRow = 0; intRow < stringValues.length; intRow++ ) {
+ if ( stringValues[ intRow ].length > intMaximumWidthRow ) {
+ intMaximumWidthRow = stringValues[ intRow ].length;
+ }
+ }
+
+ // Get the cell range of the written values.
+ XCellRange xcellrangeChart = xcellrange.getCellRangeByName( "A1:" +
+ charRectangle + intMaximumWidthRow );
+
+ // Get the addressable cell range.
+ XCellRangeAddressable xcellrangeaddressable =
+ ( XCellRangeAddressable ) UnoRuntime.queryInterface(
+ XCellRangeAddressable.class, xcellrangeChart );
+
+ // Get the cell range address.
+ CellRangeAddress cellrangeaddress = xcellrangeaddressable.getRangeAddress();
+
+ // Create the cell range address for the chart.
+ CellRangeAddress[] cellrangeaddressChart =
+ new CellRangeAddress[ 1 ];
+ cellrangeaddressChart[ 0 ] = cellrangeaddress;
+
+ // Get the table charts supplier of the spreadsheet.
+ XTableChartsSupplier xtablechartssupplier = ( XTableChartsSupplier )
+ UnoRuntime.queryInterface( XTableChartsSupplier.class, xspreadsheet );
+
+ // Get all table charts of the spreadsheet.
+ XTableCharts xtablecharts = xtablechartssupplier.getCharts();
+
+ // Create a table chart with all written values.
+ xtablecharts.addNewByName( "Example", rectangle,
+ cellrangeaddressChart, true, true );
+
+ // Get the created table chart.
+ this.xtablechart = ( XTableChart ) UnoRuntime.queryInterface(
+ XTableChart.class, (( XNameAccess ) UnoRuntime.queryInterface(
+ XNameAccess.class, xtablecharts ) ).getByName( "Example" ));
+ }
+ catch( Exception exception ) {
+ System.err.println( exception );
+ }
+ }
+
+ /** Inserting a given value to a cell, that is specified by the parameters intX
+ * and intY.
+ * @param intX Column on the spreadsheet.
+ * @param intY Row on the spreadsheet.
+ * @param stringValue Value to be inserted to a cell.
+ * @param xspreadsheet Spreadsheet of the cell, which will be changed.
+ * @param stringFlag If the value of stringFlag is "V", the stringValue
+ * will be converted to the
+ * float type. Otherwise the stringValue will be written as a formula.
+ */
+ public static void insertIntoCell( int intX, int intY, String stringValue,
+ XSpreadsheet xspreadsheet, String stringFlag )
+ {
+ XCell xcell = null;
+
+ try {
+ xcell = xspreadsheet.getCellByPosition( intX, intY );
+ }
+ catch ( com.sun.star.lang.IndexOutOfBoundsException exception ) {
+ System.out.println( "Could not get cell." );
+ }
+ if ( stringFlag.equals( "V" ) ) {
+ xcell.setValue( ( new Float( stringValue ) ).floatValue() );
+ }
+ else {
+ xcell.setFormula( stringValue );
+ }
+ }
+}
diff --git a/odk/examples/java/Spreadsheet/EuroAdaption.java b/odk/examples/java/Spreadsheet/EuroAdaption.java
new file mode 100644
index 000000000000..f167f93810bd
--- /dev/null
+++ b/odk/examples/java/Spreadsheet/EuroAdaption.java
@@ -0,0 +1,389 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+//***************************************************************************
+// comment: Step 1: get the Desktop object from the office
+// Step 2: open an empty Calc document
+// Step 3: enter a example text, set the numberformat to DM
+// Step 4: change the numberformat to EUR (Euro)
+// Step 5: use the DM/EUR factor on each cell with a content
+//***************************************************************************
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.container.XEnumerationAccess;
+
+import com.sun.star.document.XActionLockable;
+
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XComponentLoader;
+
+import com.sun.star.lang.Locale;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiComponentFactory;
+
+import com.sun.star.table.XCell;
+import com.sun.star.table.XCellRange;
+
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheets;
+import com.sun.star.sheet.XSheetCellRanges;
+import com.sun.star.sheet.XCellRangesQuery;
+import com.sun.star.sheet.XCellFormatRangesSupplier;
+import com.sun.star.sheet.XCellRangesQuery;
+import com.sun.star.sheet.XSpreadsheetDocument;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.XComponentContext;
+
+import com.sun.star.util.NumberFormat;
+import com.sun.star.util.XNumberFormats;
+import com.sun.star.util.XNumberFormatsSupplier;
+
+
+public class EuroAdaption {
+
+ public static void main(String args[]) {
+ // You need the desktop to create a document
+ // The getDesktop method does the UNO bootstrapping, gets the
+ // remote servie manager and the desktop object.
+ com.sun.star.frame.XDesktop xDesktop = null;
+ xDesktop = getDesktop();
+
+ // create a sheet document
+ XSpreadsheetDocument xSheetdocument = null;
+ xSheetdocument = ( XSpreadsheetDocument ) createSheetdocument( xDesktop );
+ System.out.println( "Create a new Spreadsheet" );
+
+ // get the collection of all sheets from the document
+ XSpreadsheets xSheets = null;
+ xSheets = (XSpreadsheets) xSheetdocument.getSheets();
+
+ // the Action Interface provides methods to hide actions,
+ // like inserting data, on a sheet, that increase the performance
+ XActionLockable xActionInterface = null;
+ xActionInterface = (XActionLockable) UnoRuntime.queryInterface(
+ XActionLockable.class, xSheetdocument );
+
+ // lock all actions
+ xActionInterface.addActionLock();
+
+ com.sun.star.sheet.XSpreadsheet xSheet = null;
+ try {
+ // get via the index access the first sheet
+ XIndexAccess xElements = (XIndexAccess) UnoRuntime.queryInterface(
+ XIndexAccess.class, xSheets );
+
+ // specify the first sheet from the spreadsheet
+ xSheet = (XSpreadsheet) UnoRuntime.queryInterface(
+ XSpreadsheet.class, xElements.getByIndex( 0 ));
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ // get the interface to apply and create new numberformats
+ XNumberFormatsSupplier xNumberFormatSupplier = null;
+ xNumberFormatSupplier = (XNumberFormatsSupplier) UnoRuntime.queryInterface(
+ XNumberFormatsSupplier.class, xSheetdocument );
+ XNumberFormats xNumberFormats = null;
+ xNumberFormats = xNumberFormatSupplier.getNumberFormats();
+
+ // insert some example data in a sheet
+ createExampleData( xSheet, xNumberFormats );
+ System.out.println( "Insert example data and use the number format with the currency 'DM'" );
+
+ // Change the currency from the cells from DM to Euro
+ Convert( xSheet, xNumberFormats, "DM", "EUR", 1.95583f );
+ System.out.println( "Change the number format to EUR and divide the values with the factor 1.95583" );
+
+ // remove all locks, the user see all changes
+ xActionInterface.removeActionLock();
+
+ System.out.println("done");
+ System.exit(0);
+ }
+
+
+ public static void Convert( XSpreadsheet xSheet, XNumberFormats xNumberFormats,
+ String sOldSymbol, String sNewSymbol,
+ float fFactor ) {
+ try {
+ Locale xLanguage = new Locale();
+ xLanguage.Country = "de"; // Germany -> DM
+ xLanguage.Language = "de"; // German
+
+ // Numberformat string with sNewSymbol
+ String sSimple = "0 [$" + sNewSymbol + "]";
+ // create a number format key with the sNewSymbol
+ int iSimpleKey = NumberFormat( xNumberFormats, sSimple, xLanguage );
+
+ // you have to use the FormatSupplier interface to get the
+ // CellFormat enumeration
+ XCellFormatRangesSupplier xCellFormatSupplier =
+ (XCellFormatRangesSupplier)UnoRuntime.queryInterface(
+ XCellFormatRangesSupplier.class, xSheet );
+
+ // getCellFormatRanges() has the interfaces for the enumeration
+ XEnumerationAccess xEnumerationAccess =
+ (XEnumerationAccess)UnoRuntime.queryInterface(
+ XEnumerationAccess.class,
+ xCellFormatSupplier.getCellFormatRanges() );
+
+ XEnumeration xRanges = xEnumerationAccess.createEnumeration();
+
+ // create an AnyConverter for later use
+ AnyConverter aAnyConv = new AnyConverter();
+
+ while( xRanges.hasMoreElements() ) {
+ // the enumeration returns a cellrange
+ XCellRange xCellRange = (XCellRange) UnoRuntime.queryInterface(
+ XCellRange.class, xRanges.nextElement());
+
+ // the PropertySet the get and set the properties from the cellrange
+ XPropertySet xCellProp = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xCellRange );
+
+ // getPropertyValue returns an Object, you have to cast it to
+ // type that you need
+ Object oNumberObject = xCellProp.getPropertyValue( "NumberFormat" );
+ int iNumberFormat = aAnyConv.toInt(oNumberObject);
+
+ // get the properties from the cellrange numberformat
+ XPropertySet xFormat = (XPropertySet)
+ xNumberFormats.getByKey(iNumberFormat );
+
+ short fType = aAnyConv.toShort(xFormat.getPropertyValue("Type"));
+ String sCurrencySymbol = aAnyConv.toString(
+ xFormat.getPropertyValue("CurrencySymbol"));
+
+ // change the numberformat only on cellranges with a
+ // currency numberformat
+ if( ( (fType & com.sun.star.util.NumberFormat.CURRENCY) > 0) &&
+ ( sCurrencySymbol.compareTo( sOldSymbol ) == 0 ) ) {
+ boolean bThousandSep = aAnyConv.toBoolean(
+ xFormat.getPropertyValue("ThousandsSeparator"));
+ boolean bNegativeRed = aAnyConv.toBoolean(
+ xFormat.getPropertyValue("NegativeRed"));
+ short fDecimals = aAnyConv.toShort(
+ xFormat.getPropertyValue("Decimals"));
+ short fLeadingZeros = aAnyConv.toShort(
+ xFormat.getPropertyValue("LeadingZeros"));
+ Locale oLocale = (Locale) aAnyConv.toObject(
+ new com.sun.star.uno.Type(Locale.class),
+ xFormat.getPropertyValue("Locale"));
+
+ // create a new numberformat string
+ String sNew = xNumberFormats.generateFormat( iSimpleKey,
+ oLocale, bThousandSep, bNegativeRed,
+ fDecimals, fLeadingZeros );
+
+ // get the NumberKey from the numberformat
+ int iNewNumberFormat = NumberFormat( xNumberFormats,
+ sNew, oLocale );
+
+ // set the new numberformat to the cellrange DM->EUR
+ xCellProp.setPropertyValue( "NumberFormat",
+ new Integer( iNewNumberFormat ) );
+
+ // interate over all cells from the cellrange with an
+ // content and use the DM/EUR factor
+ XCellRangesQuery xCellRangesQuery = (XCellRangesQuery)
+ UnoRuntime.queryInterface(
+ XCellRangesQuery.class, xCellRange );
+
+ XSheetCellRanges xSheetCellRanges =
+ xCellRangesQuery.queryContentCells(
+ (short) com.sun.star.sheet.CellFlags.VALUE );
+
+ if( xSheetCellRanges.getCount() > 0 ) {
+ XEnumerationAccess xCellEnumerationAccess =
+ xSheetCellRanges.getCells();
+ XEnumeration xCellEnumeration =
+ xCellEnumerationAccess.createEnumeration();
+
+ while( xCellEnumeration.hasMoreElements() ) {
+ XCell xCell = (XCell) UnoRuntime.queryInterface(
+ XCell.class, xCellEnumeration.nextElement());
+ xCell.setValue( (double) xCell.getValue() / fFactor );
+ }
+ }
+ }
+ }
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+ }
+
+
+ public static int NumberFormat( XNumberFormats xNumberFormat, String sFormat,
+ com.sun.star.lang.Locale xLanguage ) {
+ int nRetKey = 0;
+
+ try {
+ // exists the numberformat
+ nRetKey = xNumberFormat.queryKey( sFormat, xLanguage, true );
+
+ // if not, create a new one
+ if( nRetKey == -1 ) {
+ nRetKey = xNumberFormat.addNew( sFormat, xLanguage );
+ if( nRetKey == -1 )
+ nRetKey = 0;
+ }
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ return( nRetKey );
+ }
+
+
+ public static void createExampleData( XSpreadsheet xSheet,
+ XNumberFormats xNumberFormat ) {
+
+ // enter in a cellrange numbers and change the numberformat to DM
+ XCell xCell = null;
+ XCellRange xCellRange = null;
+
+ try {
+ Locale xLanguage = new Locale();
+ xLanguage.Country = "de"; // Germany -> DM
+ xLanguage.Language = "de"; // German
+
+ // Numberformat string from DM
+ String sSimple = "0 [$DM]";
+
+ // get the numberformat key
+ int iNumberFormatKey = NumberFormat(xNumberFormat, sSimple, xLanguage);
+
+ for( int iCounter=1; iCounter < 10; iCounter++ ) {
+ // get one cell and insert a number
+ xCell = xSheet.getCellByPosition( 2, 1 + iCounter );
+ xCell.setValue( (double) iCounter * 2 );
+ xCellRange = xSheet.getCellRangeByPosition( 2, 1 + iCounter,
+ 2, 1 + iCounter );
+
+ // get the ProperySet from the cell, to change the numberformat
+ XPropertySet xCellProp = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xCellRange );
+ xCellProp.setPropertyValue( "NumberFormat",
+ new Integer(iNumberFormatKey) );
+ }
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+ }
+
+ public static XDesktop getDesktop() {
+ XDesktop xDesktop = null;
+ XMultiComponentFactory xMCF = null;
+
+ try {
+ XComponentContext xContext = null;
+
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+
+ // get the remote office service manager
+ xMCF = xContext.getServiceManager();
+ if( xMCF != null ) {
+ System.out.println("Connected to a running office ...");
+
+ Object oDesktop = xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xContext);
+ xDesktop = (XDesktop) UnoRuntime.queryInterface(
+ XDesktop.class, oDesktop);
+ }
+ else
+ System.out.println( "Can't create a desktop. No connection, no remote servicemanager available!" );
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+
+
+ return xDesktop;
+ }
+
+
+ public static XSpreadsheetDocument createSheetdocument( XDesktop xDesktop ) {
+ XSpreadsheetDocument aSheetDocument = null;
+
+ try {
+ XComponent xComponent = null;
+ xComponent = CreateNewDocument( xDesktop, "scalc" );
+
+ aSheetDocument = (XSpreadsheetDocument) UnoRuntime.queryInterface(
+ XSpreadsheetDocument.class, xComponent);
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ return aSheetDocument;
+ }
+
+ protected static XComponent CreateNewDocument( XDesktop xDesktop,
+ String sDocumentType ) {
+ String sURL = "private:factory/" + sDocumentType;
+
+ XComponent xComponent = null;
+ XComponentLoader xComponentLoader = null;
+ PropertyValue xValues[] = new PropertyValue[1];
+ PropertyValue xEmptyArgs[] = new PropertyValue[0];
+
+ try {
+ xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(
+ XComponentLoader.class, xDesktop );
+
+ xComponent = xComponentLoader.loadComponentFromURL(
+ sURL, "_blank", 0, xEmptyArgs);
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ return xComponent ;
+ }
+
+}
diff --git a/odk/examples/java/Spreadsheet/Makefile b/odk/examples/java/Spreadsheet/Makefile
new file mode 100644
index 000000000000..4a251ae2062b
--- /dev/null
+++ b/odk/examples/java/Spreadsheet/Makefile
@@ -0,0 +1,213 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (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 Spreadsheet examples 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
+EXAMPLE_NAME=JavaSpreadsheetExamples
+OUT_COMP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+OUT_COMP_GEN = $(OUT_MISC)/$(EXAMPLE_NAME)
+
+APP1_NAME=EuroAdaption
+APP1_JAR=$(OUT_COMP_CLASS)/$(APP1_NAME).jar
+APP2_NAME=SCalc
+APP2_JAR=$(OUT_COMP_CLASS)/$(APP2_NAME).jar
+APP3_NAME=ChartTypeChange
+APP3_JAR=$(OUT_COMP_CLASS)/$(APP3_NAME).jar
+
+COMPONENT_NAME=CalcAddins
+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)java_$(COMPONENT_NAME)_register_component.flag
+
+IDLFILES = XCalcAddins.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
+
+COMPJAVAFILES = CalcAddins.java
+
+#GENJAVAFILES = $(patsubst %.idl,$(OUT_COMP_GEN)/$(PACKAGE)/%.java,$(IDLFILES))
+GENCLASSFILES = $(patsubst %.idl,$(OUT_COMP_CLASS)/$(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))
+#COMPCLASSFILES += $(subst $(OUT_COMP_GEN),$(OUT_COMP_CLASS),$(GENJAVAFILES:.java=.class))
+
+$(COMPONENT_NAME)_CLASSFILES = $(COMPONENT_NAME).class \
+ $(COMPONENT_NAME)$(QUOTE)$$_$(COMPONENT_NAME).class
+
+#$(COMPONENT_NAME)_CLASSFILES += $(subst $(OUT_COMP_GEN)/,,$(GENJAVAFILES:.java=.class))
+$(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 : $(EXAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+# rule for a component manifest file
+$(OUT_COMP_CLASS)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo UNO-Type-Path: $(basename $*).uno.jar> $@
+ @echo RegistrationClassName: $(basename $*)>> $@
+
+$(OUT_COMP_GEN)/%.urd : %.idl
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(IDLC) -C -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_GEN)/%.java : $(COMPONENT_RDB)
+$(GENCLASSFILES) : $(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
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $<
+
+# only the component depends on the generated types
+$(COMPCLASSFILES) : $(JAVAFILES) $(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
+$(OUT_COMP_CLASS)/%.jar : $(OUT_COMP_CLASS)/%.mf $(OUT_COMP_CLASS)/%.class
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $*.mf $*.class
+ +$(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 package file
+$(COMPONENT_PACKAGE) : $(COMPONENT_RDB) $(COMPONENT_JAR) $(COMPONENT_UNOPKG_MANIFEST)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(COPY) $(subst /,$(PS),$<) $(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)/$(<F)))
+
+$(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) : $(OUT_COMP_CLASS)/$(APP1_NAME).mf $(OUT_COMP_CLASS)/$(APP1_NAME).class
+$(APP2_JAR) : $(OUT_COMP_CLASS)/$(APP2_NAME).mf $(OUT_COMP_CLASS)/$(APP2_NAME).class
+$(APP3_JAR) : $(OUT_COMP_CLASS)/$(APP3_NAME).mf $(OUT_COMP_CLASS)/$(APP3_NAME).class
+
+$(EXAMPLE_NAME) : $(REGISTERFLAG) $(APP1_JAR) $(APP2_JAR) $(APP3_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following command to execute the examples!
+ @echo -
+ @echo $(MAKE) EuroAdaption.run
+ @echo $(MAKE) SCalc.run
+ @echo $(MAKE) ChartTypeChange.run
+ @echo --------------------------------------------------------------------------------
+ @echo The Calc add-in 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)CalcAddins.ods$(QM)" document to see
+ @echo how the add-in functions works.
+ @echo -
+ @echo $(MAKE) CalcAddins.ods.load
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_COMP_CLASS)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+CalcAddins.ods.load : $(REGISTERFLAG)
+ "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
+
+.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/java/Spreadsheet/SCalc.java b/odk/examples/java/Spreadsheet/SCalc.java
new file mode 100644
index 000000000000..1ff2c56ddbdb
--- /dev/null
+++ b/odk/examples/java/Spreadsheet/SCalc.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.
+ *
+ *************************************************************************/
+
+//***************************************************************************
+// comment: Step 1: get the remote component context from the office
+// Step 2: open an empty calc document
+// Step 3: create cell styles
+// Step 4: get the sheet an insert some data
+// Step 5: apply the created cell syles
+// Step 6: insert a 3D Chart
+//***************************************************************************
+
+import com.sun.star.awt.Rectangle;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.chart.XDiagram;
+import com.sun.star.chart.XChartDocument;
+
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNameContainer;
+
+import com.sun.star.document.XEmbeddedObjectSupplier;
+
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XComponentLoader;
+
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XMultiComponentFactory;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.XComponentContext;
+
+import com.sun.star.sheet.XCellRangeAddressable;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheets;
+import com.sun.star.sheet.XSpreadsheetDocument;
+
+import com.sun.star.style.XStyleFamiliesSupplier;
+
+import com.sun.star.table.CellRangeAddress;
+import com.sun.star.table.XCell;
+import com.sun.star.table.XCellRange;
+import com.sun.star.table.XTableChart;
+import com.sun.star.table.XTableCharts;
+import com.sun.star.table.XTableChartsSupplier;
+
+
+public class SCalc {
+
+ public static void main(String args[]) {
+
+ //oooooooooooooooooooooooooooStep 1oooooooooooooooooooooooooooooooooooooooooo
+ // call UNO bootstrap method and get the remote component context form
+ // the a running office (office will be started if necessary)
+ //***************************************************************************
+ XComponentContext xContext = null;
+
+ // get the remote office component context
+ try {
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ } catch( Exception e) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+
+ //oooooooooooooooooooooooooooStep 2oooooooooooooooooooooooooooooooooooooooooo
+ // open an empty document. In this case it's a calc document.
+ // For this purpose an instance of com.sun.star.frame.Desktop
+ // is created. The desktop provides the XComponentLoader interface,
+ // which is used to open the document via loadComponentFromURL
+ //***************************************************************************
+
+ //Open document
+
+ //Calc
+ XSpreadsheetDocument myDoc = null;
+// XCell oCell = null;
+
+ System.out.println("Opening an empty Calc document");
+ myDoc = openCalc(xContext);
+
+ //***************************************************************************
+
+
+ //oooooooooooooooooooooooooooStep 3oooooooooooooooooooooooooooooooooooooooooo
+ // create cell styles.
+ // For this purpose get the StyleFamiliesSupplier and the the familiy
+ // CellStyle. Create an instance of com.sun.star.style.CellStyle and
+ // add it to the family. Now change some properties
+ //***************************************************************************
+
+ try {
+ XStyleFamiliesSupplier xSFS = (XStyleFamiliesSupplier)
+ UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, myDoc);
+ XNameAccess xSF = (XNameAccess) xSFS.getStyleFamilies();
+ XNameAccess xCS = (XNameAccess) UnoRuntime.queryInterface(
+ XNameAccess.class, xSF.getByName("CellStyles"));
+ XMultiServiceFactory oDocMSF = (XMultiServiceFactory)
+ UnoRuntime.queryInterface(XMultiServiceFactory.class, myDoc );
+ XNameContainer oStyleFamilyNameContainer = (XNameContainer)
+ UnoRuntime.queryInterface(
+ XNameContainer.class, xCS);
+ XInterface oInt1 = (XInterface) oDocMSF.createInstance(
+ "com.sun.star.style.CellStyle");
+ oStyleFamilyNameContainer.insertByName("My Style", oInt1);
+ XPropertySet oCPS1 = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, oInt1 );
+ oCPS1.setPropertyValue("IsCellBackgroundTransparent", new Boolean(false));
+ oCPS1.setPropertyValue("CellBackColor",new Integer(6710932));
+ oCPS1.setPropertyValue("CharColor",new Integer(16777215));
+ XInterface oInt2 = (XInterface) oDocMSF.createInstance(
+ "com.sun.star.style.CellStyle");
+ oStyleFamilyNameContainer.insertByName("My Style2", oInt2);
+ XPropertySet oCPS2 = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, oInt2 );
+ oCPS2.setPropertyValue("IsCellBackgroundTransparent", new Boolean(false));
+ oCPS2.setPropertyValue("CellBackColor",new Integer(13421823));
+ } catch (Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ //***************************************************************************
+
+ //oooooooooooooooooooooooooooStep 4oooooooooooooooooooooooooooooooooooooooooo
+ // get the sheet an insert some data.
+ // Get the sheets from the document and then the first from this container.
+ // Now some data can be inserted. For this purpose get a Cell via
+ // getCellByPosition and insert into this cell via setValue() (for floats)
+ // or setFormula() for formulas and Strings
+ //***************************************************************************
+
+
+ XSpreadsheet xSheet=null;
+
+ try {
+ System.out.println("Getting spreadsheet") ;
+ XSpreadsheets xSheets = myDoc.getSheets() ;
+ XIndexAccess oIndexSheets = (XIndexAccess) UnoRuntime.queryInterface(
+ XIndexAccess.class, xSheets);
+ xSheet = (XSpreadsheet) UnoRuntime.queryInterface(
+ XSpreadsheet.class, oIndexSheets.getByIndex(0));
+
+ } catch (Exception e) {
+ System.out.println("Couldn't get Sheet " +e);
+ e.printStackTrace(System.err);
+ }
+
+
+
+ System.out.println("Creating the Header") ;
+
+ insertIntoCell(1,0,"JAN",xSheet,"");
+ insertIntoCell(2,0,"FEB",xSheet,"");
+ insertIntoCell(3,0,"MAR",xSheet,"");
+ insertIntoCell(4,0,"APR",xSheet,"");
+ insertIntoCell(5,0,"MAI",xSheet,"");
+ insertIntoCell(6,0,"JUN",xSheet,"");
+ insertIntoCell(7,0,"JUL",xSheet,"");
+ insertIntoCell(8,0,"AUG",xSheet,"");
+ insertIntoCell(9,0,"SEP",xSheet,"");
+ insertIntoCell(10,0,"OCT",xSheet,"");
+ insertIntoCell(11,0,"NOV",xSheet,"");
+ insertIntoCell(12,0,"DEC",xSheet,"");
+ insertIntoCell(13,0,"SUM",xSheet,"");
+
+
+ System.out.println("Fill the lines");
+
+ insertIntoCell(0,1,"Smith",xSheet,"");
+ insertIntoCell(1,1,"42",xSheet,"V");
+ insertIntoCell(2,1,"58.9",xSheet,"V");
+ insertIntoCell(3,1,"-66.5",xSheet,"V");
+ insertIntoCell(4,1,"43.4",xSheet,"V");
+ insertIntoCell(5,1,"44.5",xSheet,"V");
+ insertIntoCell(6,1,"45.3",xSheet,"V");
+ insertIntoCell(7,1,"-67.3",xSheet,"V");
+ insertIntoCell(8,1,"30.5",xSheet,"V");
+ insertIntoCell(9,1,"23.2",xSheet,"V");
+ insertIntoCell(10,1,"-97.3",xSheet,"V");
+ insertIntoCell(11,1,"22.4",xSheet,"V");
+ insertIntoCell(12,1,"23.5",xSheet,"V");
+ insertIntoCell(13,1,"=SUM(B2:M2)",xSheet,"");
+
+
+ insertIntoCell(0,2,"Jones",xSheet,"");
+ insertIntoCell(1,2,"21",xSheet,"V");
+ insertIntoCell(2,2,"40.9",xSheet,"V");
+ insertIntoCell(3,2,"-57.5",xSheet,"V");
+ insertIntoCell(4,2,"-23.4",xSheet,"V");
+ insertIntoCell(5,2,"34.5",xSheet,"V");
+ insertIntoCell(6,2,"59.3",xSheet,"V");
+ insertIntoCell(7,2,"27.3",xSheet,"V");
+ insertIntoCell(8,2,"-38.5",xSheet,"V");
+ insertIntoCell(9,2,"43.2",xSheet,"V");
+ insertIntoCell(10,2,"57.3",xSheet,"V");
+ insertIntoCell(11,2,"25.4",xSheet,"V");
+ insertIntoCell(12,2,"28.5",xSheet,"V");
+ insertIntoCell(13,2,"=SUM(B3:M3)",xSheet,"");
+
+ insertIntoCell(0,3,"Brown",xSheet,"");
+ insertIntoCell(1,3,"31.45",xSheet,"V");
+ insertIntoCell(2,3,"-20.9",xSheet,"V");
+ insertIntoCell(3,3,"-117.5",xSheet,"V");
+ insertIntoCell(4,3,"23.4",xSheet,"V");
+ insertIntoCell(5,3,"-114.5",xSheet,"V");
+ insertIntoCell(6,3,"115.3",xSheet,"V");
+ insertIntoCell(7,3,"-171.3",xSheet,"V");
+ insertIntoCell(8,3,"89.5",xSheet,"V");
+ insertIntoCell(9,3,"41.2",xSheet,"V");
+ insertIntoCell(10,3,"71.3",xSheet,"V");
+ insertIntoCell(11,3,"25.4",xSheet,"V");
+ insertIntoCell(12,3,"38.5",xSheet,"V");
+ insertIntoCell(13,3,"=SUM(A4:L4)",xSheet,"");
+
+ //***************************************************************************
+
+ //oooooooooooooooooooooooooooStep 5oooooooooooooooooooooooooooooooooooooooooo
+ // apply the created cell style.
+ // For this purpose get the PropertySet of the Cell and change the
+ // property CellStyle to the appropriate value.
+ //***************************************************************************
+
+ // change backcolor
+ chgbColor( 1 , 0, 13, 0, "My Style", xSheet );
+ chgbColor( 0 , 1, 0, 3, "My Style", xSheet );
+ chgbColor( 1 , 1, 13, 3, "My Style2", xSheet );
+
+ //***************************************************************************
+
+ //oooooooooooooooooooooooooooStep 6oooooooooooooooooooooooooooooooooooooooooo
+ // insert a 3D chart.
+ // get the CellRange which holds the data for the chart and its RangeAddress
+ // get the TableChartSupplier from the sheet and then the TableCharts from it.
+ // add a new chart based on the data to the TableCharts.
+ // get the ChartDocument, which provide the Diagramm. Change the properties
+ // Dim3D (3 dimension) and String (the title) of the diagramm.
+ //***************************************************************************
+
+ // insert a chart
+
+ Rectangle oRect = new Rectangle();
+ oRect.X = 500;
+ oRect.Y = 3000;
+ oRect.Width = 25000;
+ oRect.Height = 11000;
+
+ XCellRange oRange = (XCellRange)UnoRuntime.queryInterface(
+ XCellRange.class, xSheet);
+ XCellRange myRange = oRange.getCellRangeByName("A1:N4");
+ XCellRangeAddressable oRangeAddr = (XCellRangeAddressable)
+ UnoRuntime.queryInterface(XCellRangeAddressable.class, myRange);
+ CellRangeAddress myAddr = oRangeAddr.getRangeAddress();
+
+ CellRangeAddress[] oAddr = new CellRangeAddress[1];
+ oAddr[0] = myAddr;
+ XTableChartsSupplier oSupp = (XTableChartsSupplier)UnoRuntime.queryInterface(
+ XTableChartsSupplier.class, xSheet);
+
+ XTableChart oChart = null;
+
+ System.out.println("Insert Chart");
+
+ XTableCharts oCharts = oSupp.getCharts();
+ oCharts.addNewByName("Example", oRect, oAddr, true, true);
+
+ // get the diagramm and Change some of the properties
+
+ try {
+ oChart = (XTableChart) (UnoRuntime.queryInterface(
+ XTableChart.class, ((XNameAccess)UnoRuntime.queryInterface(
+ XNameAccess.class, oCharts)).getByName("Example")));
+ XEmbeddedObjectSupplier oEOS = (XEmbeddedObjectSupplier)
+ UnoRuntime.queryInterface(XEmbeddedObjectSupplier.class, oChart);
+ XInterface oInt = oEOS.getEmbeddedObject();
+ XChartDocument xChart = (XChartDocument) UnoRuntime.queryInterface(
+ XChartDocument.class,oInt);
+ XDiagram oDiag = (XDiagram) xChart.getDiagram();
+ System.out.println("Change Diagramm to 3D");
+ XPropertySet oCPS = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, oDiag );
+ oCPS.setPropertyValue("Dim3D", new Boolean(true));
+ System.out.println("Change the title");
+ Thread.sleep(200);
+ XPropertySet oTPS = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xChart.getTitle() );
+ oTPS.setPropertyValue("String","The new title");
+ //oDiag.Dim3D();
+ } catch (Exception e){
+ System.err.println("Changin Properties failed "+e);
+ e.printStackTrace(System.err);
+ }
+
+ System.out.println("done");
+ System.exit(0);
+ }
+
+ public static XSpreadsheetDocument openCalc(XComponentContext xContext)
+ {
+ //define variables
+ XMultiComponentFactory xMCF = null;
+ XComponentLoader xCLoader;
+ XSpreadsheetDocument xSpreadSheetDoc = null;
+ XComponent xComp = null;
+
+ try {
+ // get the servie manager rom the office
+ xMCF = xContext.getServiceManager();
+
+ // create a new instance of the the desktop
+ Object oDesktop = xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xContext );
+
+ // query the desktop object for the XComponentLoader
+ xCLoader = ( XComponentLoader ) UnoRuntime.queryInterface(
+ XComponentLoader.class, oDesktop );
+
+ PropertyValue [] szEmptyArgs = new PropertyValue [0];
+ String strDoc = "private:factory/scalc";
+
+ xComp = xCLoader.loadComponentFromURL(strDoc, "_blank", 0, szEmptyArgs );
+ xSpreadSheetDoc = (XSpreadsheetDocument) UnoRuntime.queryInterface(
+ XSpreadsheetDocument.class, xComp);
+
+ } catch(Exception e){
+ System.err.println(" Exception " + e);
+ e.printStackTrace(System.err);
+ }
+
+ return xSpreadSheetDoc;
+ }
+
+
+ public static void insertIntoCell(int CellX, int CellY, String theValue,
+ XSpreadsheet TT1, String flag)
+ {
+ XCell xCell = null;
+
+ try {
+ xCell = TT1.getCellByPosition(CellX, CellY);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException ex) {
+ System.err.println("Could not get Cell");
+ ex.printStackTrace(System.err);
+ }
+
+ if (flag.equals("V")) {
+ xCell.setValue((new Float(theValue)).floatValue());
+ } else {
+ xCell.setFormula(theValue);
+ }
+
+ }
+
+ public static void chgbColor( int x1, int y1, int x2, int y2,
+ String template, XSpreadsheet TT )
+ {
+ XCellRange xCR = null;
+ try {
+ xCR = TT.getCellRangeByPosition(x1,y1,x2,y2);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException ex) {
+ System.err.println("Could not get CellRange");
+ ex.printStackTrace(System.err);
+ }
+
+ XPropertySet xCPS = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xCR );
+
+ try {
+ xCPS.setPropertyValue("CellStyle", template);
+ } catch (Exception e) {
+ System.err.println("Can't change colors chgbColor" + e);
+ e.printStackTrace(System.err);
+ }
+ }
+
+}
diff --git a/odk/examples/java/Spreadsheet/XCalcAddins.idl b/odk/examples/java/Spreadsheet/XCalcAddins.idl
new file mode 100644
index 000000000000..bd515b6ebced
--- /dev/null
+++ b/odk/examples/java/Spreadsheet/XCalcAddins.idl
@@ -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.
+ *
+ *************************************************************************/
+#ifndef INCLUDED_ORG_OPENOFFICE_SHEET_ADDIN_XCALCADDIN_IDL
+#define INCLUDED_ORG_OPENOFFICE_SHEET_ADDIN_XCALCADDIN_IDL
+
+#include <com/sun/star/beans/XPropertySet.idl>
+#include <com/sun/star/sheet/AddIn.idl>
+
+
+module org {
+ module openoffice {
+ module sheet {
+ module addin {
+ /** Interface with your additional methods.
+
+ You may declare several methods. Each method may have
+ any number of arguments after xOptions.
+ Furthermore, you could replace the name of the service and
+ the interface, but only if you want to replace this name in all
+ your project files. This example will work with tNeccessaryhe default
+ names.
+ Interface names should start with an X prefix.
+ */
+ interface XCalcAddins
+ {
+ /** Declare your methods:
+ This is where you could add the declarations of your methods.
+ If you want to learn more about
+ the IDL syntax including the base types, you could
+ visit the following web page:
+ http://www.openoffice.org/project/udk/common/man/idl_syntax.html .
+ */
+ long getMyFirstValue(
+ /** Parameters:
+ You could insert further arguments after the
+ parameter xOptions.
+ */
+ [in] com::sun::star::beans::XPropertySet xOptions
+ );
+
+ long getMySecondValue(
+ /** Parameters:
+ You could insert further arguments after the
+ parameter xOptions.
+ */
+ [in] com::sun::star::beans::XPropertySet xOptions,
+ [in] long intDummy
+ );
+ };
+
+ service CalcAddins
+ {
+ /** Exported interfaces:
+ This is where you put all interfaces that this service exports. The service
+ supports its main interface only.
+ */
+ interface XCalcAddins;
+
+ /** Necessary base service.
+ All add-ins must implement this service
+ */
+ service com::sun::star::sheet::AddIn;
+ };
+ };
+ };
+ };
+};
+
+#endif
diff --git a/odk/examples/java/Storage/Makefile b/odk/examples/java/Storage/Makefile
new file mode 100644
index 000000000000..663f22dfe3e7
--- /dev/null
+++ b/odk/examples/java/Storage/Makefile
@@ -0,0 +1,58 @@
+# Builds the Java Storage test 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=JavaStorageTestExample
+OUT_COMP_CLASS = $(OUT_CLASS)/$(COMPONENT_NAME)
+
+JAVAFILES = \
+ StorageFunctionality.java \
+ TestHelper.java \
+ StorageTest.java \
+ Test01.java \
+ Test02.java \
+ Test03.java \
+ Test04.java \
+ Test05.java \
+ Test06.java \
+ Test07.java \
+ Test08.java \
+ Test09.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 : \
+ JavaStorageTestExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(CLASSFILES) : $(JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(JAVAFILES)
+
+JavaStorageTestExample : $(CLASSFILES)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use following command to execute the example!
+ @echo ------
+ @echo $(MAKE) StorageFunctionality.run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_COMP_CLASS)/%.class
+ $(SDK_JAVA) -classpath "$(SDK_CLASSPATH)" $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
+
diff --git a/odk/examples/java/Storage/StorageFunctionality.java b/odk/examples/java/Storage/StorageFunctionality.java
new file mode 100644
index 000000000000..0532259821b9
--- /dev/null
+++ b/odk/examples/java/Storage/StorageFunctionality.java
@@ -0,0 +1,147 @@
+import com.sun.star.comp.servicemanager.ServiceManager;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.connection.XConnector;
+import com.sun.star.connection.XConnection;
+
+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.container.*;
+import com.sun.star.beans.*;
+import com.sun.star.lang.*;
+
+import storagetesting.*;
+
+public class StorageFunctionality {
+
+ public static void main( String args[] )
+ {
+ // connect to the office
+ String sConnectionString = "uno:socket,host=localhost,port=8100;urp;StarOffice.NamingService";
+
+ // It is possible to use a different connection string, passed as argument
+ if ( args.length == 1 ) {
+ sConnectionString = args[0];
+ }
+
+ XMultiServiceFactory xMSF = null;
+
+ // create connection(s) and get multiservicefactory
+ try {
+ xMSF = connect( sConnectionString );
+
+ if ( xMSF == null )
+ {
+ System.out.println( "Error: Couldn't get MSF!" );
+ return;
+ }
+ } catch( Exception e ) {
+ System.out.println( "Error: Couldn't get MSF, exception: " + e );
+ return;
+ }
+
+ XSingleServiceFactory xStorageFactory = null;
+ try
+ {
+ Object oStorageFactory = xMSF.createInstance( "com.sun.star.embed.StorageFactory" );
+ xStorageFactory = (XSingleServiceFactory)UnoRuntime.queryInterface( XSingleServiceFactory.class,
+ oStorageFactory );
+
+ if ( xStorageFactory == null )
+ {
+ System.out.println( "Error: Can not get storage factory!" );
+ return;
+ }
+ }
+ catch ( Exception e )
+ {
+ System.out.println( "Error: Can't get storage factory, exception: " + e + "!" );
+ return;
+ }
+
+ boolean bTestsPassed = true;
+
+ final int nNumTests = 9;
+ StorageTest pTests[] = new StorageTest[nNumTests];
+ pTests[0] = (StorageTest) new Test01( xMSF, xStorageFactory );
+ pTests[1] = (StorageTest) new Test02( xMSF, xStorageFactory );
+ pTests[2] = (StorageTest) new Test03( xMSF, xStorageFactory );
+ pTests[3] = (StorageTest) new Test04( xMSF, xStorageFactory );
+ pTests[4] = (StorageTest) new Test05( xMSF, xStorageFactory );
+ pTests[5] = (StorageTest) new Test06( xMSF, xStorageFactory );
+ pTests[6] = (StorageTest) new Test07( xMSF, xStorageFactory );
+ pTests[7] = (StorageTest) new Test08( xMSF, xStorageFactory );
+ pTests[8] = (StorageTest) new Test09( xMSF, xStorageFactory );
+
+ System.out.println( "\nstart testing\n" );
+
+ for ( int nInd = 0; nInd < nNumTests; nInd++ )
+ {
+ String sTestName = "Test" + ( ( nInd < 9 ) ? "0" : "" ) + ( nInd + 1 );
+
+ System.out.println( "======= Storage test " + sTestName + " started!" );
+ if ( pTests[nInd].test() )
+ System.out.println( "======= Storage test " + sTestName + " passed!" );
+ else
+ {
+ System.out.println( "======= Storage test " + sTestName + " failed!" );
+ bTestsPassed = false;
+ }
+ }
+
+ if ( bTestsPassed )
+ System.out.println( "\ntesting passed" );
+ else
+ System.out.println( "\ntesting failed" );
+
+ System.out.println( "done" );
+
+ System.exit( 0 );
+ }
+
+
+ public static XMultiServiceFactory connect( String sConnectStr )
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException,
+ Exception
+ {
+ // Get component context
+ XComponentContext xComponentContext =
+ com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(
+ null );
+
+ // initial serviceManager
+ XMultiComponentFactory xLocalServiceManager =
+ xComponentContext.getServiceManager();
+
+ // create a connector, so that it can contact the office
+ Object oUrlResolver = xLocalServiceManager.createInstanceWithContext(
+ "com.sun.star.bridge.UnoUrlResolver", xComponentContext );
+ XUnoUrlResolver xUrlResolver = (XUnoUrlResolver)UnoRuntime.queryInterface(
+ XUnoUrlResolver.class, oUrlResolver );
+
+ Object oInitialObject = xUrlResolver.resolve( sConnectStr );
+ XNamingService xName = (XNamingService)UnoRuntime.queryInterface(
+ XNamingService.class, oInitialObject );
+
+ XMultiServiceFactory xMSF = null;
+ if( xName != null ) {
+ System.err.println( "got the remote naming service !" );
+ Object oMSF = xName.getRegisteredObject("StarOffice.ServiceManager" );
+
+ xMSF = (XMultiServiceFactory)
+ UnoRuntime.queryInterface( XMultiServiceFactory.class, oMSF );
+ }
+ else
+ System.out.println( "Error: Can't get XNamingService interface from url resolver!" );
+
+ return xMSF;
+ }
+
+}
+
diff --git a/odk/examples/java/Storage/StorageTest.java b/odk/examples/java/Storage/StorageTest.java
new file mode 100644
index 000000000000..3d748d045109
--- /dev/null
+++ b/odk/examples/java/Storage/StorageTest.java
@@ -0,0 +1,7 @@
+package storagetesting;
+
+public interface StorageTest
+{
+ boolean test();
+}
+
diff --git a/odk/examples/java/Storage/Test01.java b/odk/examples/java/Storage/Test01.java
new file mode 100644
index 000000000000..7c3309dbcbbd
--- /dev/null
+++ b/odk/examples/java/Storage/Test01.java
@@ -0,0 +1,158 @@
+package storagetesting;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+import com.sun.star.embed.*;
+
+import storagetesting.TestHelper;
+import storagetesting.StorageTest;
+
+public class Test01 implements StorageTest {
+
+ XMultiServiceFactory m_xMSF;
+ XSingleServiceFactory m_xStorageFactory;
+ TestHelper m_aTestHelper;
+
+ public Test01( XMultiServiceFactory xMSF, XSingleServiceFactory xStorageFactory )
+ {
+ m_xMSF = xMSF;
+ m_xStorageFactory = xStorageFactory;
+ m_aTestHelper = new TestHelper( "Test01: " );
+ }
+
+ public boolean test()
+ {
+ try
+ {
+ String sTempFileURL = m_aTestHelper.CreateTempFile( m_xMSF );
+ if ( sTempFileURL == null || sTempFileURL == "" )
+ {
+ m_aTestHelper.Error( "No valid temporary file was created!" );
+ return false;
+ }
+
+ // create temporary storage based on arbitrary medium
+ // after such a storage is closed it is lost
+ Object oTempStorage = m_xStorageFactory.createInstance();
+ XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ if ( xTempStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create temporary storage representation!" );
+ return false;
+ }
+
+ // open a new substorage
+ XStorage xTempSubStorage = m_aTestHelper.openSubStorage( xTempStorage,
+ "SubStorage1",
+ ElementModes.ELEMENT_WRITE );
+ if ( xTempSubStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create substorage!" );
+ return false;
+ }
+
+ byte pBytes1[] = { 1, 1, 1, 1, 1 };
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "SubStream1", "MediaType1", true, pBytes1 ) )
+ return false;
+
+ byte pBytes2[] = { 2, 2, 2, 2, 2 };
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "SubStream2", "MediaType2", false, pBytes2 ) )
+ return false;
+
+ // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
+ if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempStorage,
+ "MediaType3",
+ true,
+ ElementModes.ELEMENT_READWRITE ) )
+ return false;
+
+ // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
+ if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempSubStorage,
+ "MediaType4",
+ false,
+ ElementModes.ELEMENT_WRITE ) )
+ return false;
+
+ // create temporary storage based on a previously created temporary file
+ Object pArgs[] = new Object[2];
+ pArgs[0] = (Object) sTempFileURL;
+ pArgs[1] = new Integer( ElementModes.ELEMENT_WRITE );
+
+ Object oTempFileStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
+ XStorage xTempFileStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
+ if ( xTempFileStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create storage based on temporary file!" );
+ return false;
+ }
+
+ // copy xTempStorage to xTempFileStorage
+ // xTempFileStorage will be automatically commited
+ if ( !m_aTestHelper.copyStorage( xTempStorage, xTempFileStorage ) )
+ return false;
+
+ // dispose used storages to free resources
+ if ( !m_aTestHelper.disposeStorage( xTempStorage ) || !m_aTestHelper.disposeStorage( xTempFileStorage ) )
+ return false;
+
+ // ================================================
+ // now check all the written and copied information
+ // ================================================
+
+ // the temporary file must not be locked any more after storage disposing
+ pArgs[1] = new Integer( ElementModes.ELEMENT_READWRITE );
+ Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
+ XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage );
+ if ( xResultStorage == null )
+ {
+ m_aTestHelper.Error( "Can't reopen storage based on temporary file!" );
+ return false;
+ }
+
+ if ( !m_aTestHelper.checkStorageProperties( xResultStorage, "MediaType3", true, ElementModes.ELEMENT_READWRITE ) )
+ return false;
+
+ // open existing substorage
+ XStorage xResultSubStorage = m_aTestHelper.openSubStorage( xResultStorage,
+ "SubStorage1",
+ ElementModes.ELEMENT_READ );
+ if ( xResultSubStorage == null )
+ {
+ m_aTestHelper.Error( "Can't open existing substorage!" );
+ return false;
+ }
+
+ if ( !m_aTestHelper.checkStorageProperties( xResultSubStorage, "MediaType4", false, ElementModes.ELEMENT_READ ) )
+ return false;
+
+ if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream1", "MediaType1", pBytes1 ) )
+ return false;
+
+ if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream2", "MediaType2", pBytes2 ) )
+ return false;
+
+ // dispose used storages to free resources
+ if ( !m_aTestHelper.disposeStorage( xResultStorage ) )
+ return false;
+
+ return true;
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Exception: " + e );
+ return false;
+ }
+ }
+
+}
+
diff --git a/odk/examples/java/Storage/Test02.java b/odk/examples/java/Storage/Test02.java
new file mode 100644
index 000000000000..40f8706657b9
--- /dev/null
+++ b/odk/examples/java/Storage/Test02.java
@@ -0,0 +1,152 @@
+package storagetesting;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.io.XStream;
+import com.sun.star.io.XInputStream;
+
+import com.sun.star.embed.*;
+
+import storagetesting.TestHelper;
+import storagetesting.StorageTest;
+
+public class Test02 implements StorageTest {
+
+ XMultiServiceFactory m_xMSF;
+ XSingleServiceFactory m_xStorageFactory;
+ TestHelper m_aTestHelper;
+
+ public Test02( XMultiServiceFactory xMSF, XSingleServiceFactory xStorageFactory )
+ {
+ m_xMSF = xMSF;
+ m_xStorageFactory = xStorageFactory;
+ m_aTestHelper = new TestHelper( "Test02: " );
+ }
+
+ public boolean test()
+ {
+ try
+ {
+ XStream xTempFileStream = m_aTestHelper.CreateTempFileStream( m_xMSF );
+ if ( xTempFileStream == null )
+ return false;
+
+ // create storage based on the temporary stream
+ Object pArgs[] = new Object[2];
+ pArgs[0] = (Object) xTempFileStream;
+ pArgs[1] = new Integer( ElementModes.ELEMENT_WRITE );
+
+ Object oTempStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
+ XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ if ( xTempStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create temporary storage representation!" );
+ return false;
+ }
+
+ // open a new substorage
+ XStorage xTempSubStorage = m_aTestHelper.openSubStorage( xTempStorage,
+ "SubStorage1",
+ ElementModes.ELEMENT_WRITE );
+ if ( xTempSubStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create substorage!" );
+ return false;
+ }
+
+ byte pBytes1[] = { 1, 1, 1, 1, 1 };
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "SubStream1", "MediaType1", true, pBytes1 ) )
+ return false;
+
+ // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
+ if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempStorage,
+ "MediaType2",
+ true,
+ ElementModes.ELEMENT_WRITE ) )
+ return false;
+
+ // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
+ if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempSubStorage,
+ "MediaType3",
+ false,
+ ElementModes.ELEMENT_WRITE ) )
+ return false;
+
+ // commit substorage first
+ if ( !m_aTestHelper.commitStorage( xTempSubStorage ) )
+ return false;
+
+ // commit the root storage so the contents must be stored now
+ if ( !m_aTestHelper.commitStorage( xTempStorage ) )
+ return false;
+
+ // dispose used storage to free resources
+ // the substorage dispose will be triggered by this call
+ if ( !m_aTestHelper.disposeStorage( xTempStorage ) )
+ return false;
+
+
+ // ================================================
+ // now check all the written information
+ // ================================================
+
+ // close the output part of the temporary stream
+ // the output part must present since we already wrote to the stream
+ if ( !m_aTestHelper.closeOutput( xTempFileStream ) )
+ return false;
+
+ XInputStream xTempInStream = m_aTestHelper.getInputStream( xTempFileStream );
+ if ( xTempInStream == null )
+ return false;
+
+
+ // open input stream
+ // since no mode is provided the result storage must be opened readonly
+ Object pOneArg[] = new Object[1];
+ pOneArg[0] = (Object) xTempInStream;
+
+ Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pOneArg );
+ XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage );
+ if ( xResultStorage == null )
+ {
+ m_aTestHelper.Error( "Can't open storage based on input stream!" );
+ return false;
+ }
+
+ if ( !m_aTestHelper.checkStorageProperties( xResultStorage, "MediaType2", true, ElementModes.ELEMENT_READ ) )
+ return false;
+
+ // open existing substorage
+ XStorage xResultSubStorage = m_aTestHelper.openSubStorage( xResultStorage,
+ "SubStorage1",
+ ElementModes.ELEMENT_READ );
+ if ( xResultSubStorage == null )
+ {
+ m_aTestHelper.Error( "Can't open existing substorage!" );
+ return false;
+ }
+
+ if ( !m_aTestHelper.checkStorageProperties( xResultSubStorage, "MediaType3", false, ElementModes.ELEMENT_READ ) )
+ return false;
+
+ if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream1", "MediaType1", pBytes1 ) )
+ return false;
+
+ return true;
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Exception: " + e );
+ return false;
+ }
+ }
+
+}
+
diff --git a/odk/examples/java/Storage/Test03.java b/odk/examples/java/Storage/Test03.java
new file mode 100644
index 000000000000..962e52323e6a
--- /dev/null
+++ b/odk/examples/java/Storage/Test03.java
@@ -0,0 +1,209 @@
+package storagetesting;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+import com.sun.star.embed.*;
+import com.sun.star.container.XNameAccess;
+
+import storagetesting.TestHelper;
+import storagetesting.StorageTest;
+
+public class Test03 implements StorageTest {
+
+ XMultiServiceFactory m_xMSF;
+ XSingleServiceFactory m_xStorageFactory;
+ TestHelper m_aTestHelper;
+
+ public Test03( XMultiServiceFactory xMSF, XSingleServiceFactory xStorageFactory )
+ {
+ m_xMSF = xMSF;
+ m_xStorageFactory = xStorageFactory;
+ m_aTestHelper = new TestHelper( "Test03: " );
+ }
+
+ public boolean test()
+ {
+ try
+ {
+ // create temporary storage based on arbitrary medium
+ // after such a storage is closed it is lost
+ Object oTempStorage = m_xStorageFactory.createInstance();
+ XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ if ( xTempStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create temporary storage representation!" );
+ return false;
+ }
+
+ // open a new substorage
+ XStorage xTempSubStorage = m_aTestHelper.openSubStorage( xTempStorage,
+ "SubStorage1",
+ ElementModes.ELEMENT_WRITE );
+ if ( xTempSubStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create substorage!" );
+ return false;
+ }
+
+ byte pBytes1[] = { 1, 1, 1, 1, 1 };
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempStorage, "SubStream1", "MediaType1", true, pBytes1 ) )
+ return false;
+
+ byte pBytes2[] = { 2, 2, 2, 2, 2 };
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage, "SubStream2", "MediaType2", false, pBytes2 ) )
+ return false;
+
+ // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
+ if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempSubStorage,
+ "MediaType3",
+ false,
+ ElementModes.ELEMENT_WRITE ) )
+ return false;
+
+ if ( !m_aTestHelper.commitStorage( xTempSubStorage ) )
+ return false;
+
+ if ( !m_aTestHelper.disposeStorage( xTempSubStorage ) )
+ return false;
+
+ // ================================================
+ // check storage hyerarchy tree
+ // ================================================
+
+ // check that isStorageElement() and isStreamElement reacts to nonexisting object correctly
+ try {
+ xTempStorage.isStorageElement( "does not exist" );
+ m_aTestHelper.Error( "Nonexisting element doesn't detected by isStorageElement() call!" );
+ return false;
+ }
+ catch( com.sun.star.container.NoSuchElementException ne )
+ {
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Wrong exception is thrown by isStorageElement() call: " + e );
+ return false;
+ }
+
+ try {
+ xTempStorage.isStreamElement( "does not exist" );
+ m_aTestHelper.Error( "Nonexisting element doesn't detected by isStreamElement() call!" );
+ return false;
+ }
+ catch( com.sun.star.container.NoSuchElementException ne )
+ {
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Wrong exception is thrown by isStreamElement() call: " + e );
+ return false;
+ }
+
+ XNameAccess xRootNameAccess = (XNameAccess) UnoRuntime.queryInterface( XNameAccess.class, xTempStorage );
+ if ( xRootNameAccess == null )
+ {
+ m_aTestHelper.Error( "Root storage doesn't support XNameAccess!" );
+ return false;
+ }
+
+ try {
+ if ( !xTempStorage.isStorageElement( "SubStorage1" ) || xTempStorage.isStreamElement( "SubStorage1" ) )
+ {
+ m_aTestHelper.Error( "Child 'SubStorage1' can not be detected as storage!" );
+ return false;
+ }
+
+ if ( xTempStorage.isStorageElement( "SubStream1" ) || !xTempStorage.isStreamElement( "SubStream1" ) )
+ {
+ m_aTestHelper.Error( "Child 'SubStream1' can not be detected as stream!" );
+ return false;
+ }
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Child's type can not be detected, exception: " + e );
+ return false;
+ }
+
+
+ // check that root storage contents are represented correctly
+ String sRootCont[] = xRootNameAccess.getElementNames();
+
+ if ( sRootCont.length != 2 )
+ {
+ m_aTestHelper.Error( "Root storage contains wrong amount of children!" );
+ return false;
+ }
+
+ if ( !( sRootCont[0].equals( "SubStorage1" ) && sRootCont[1].equals( "SubStream1" )
+ || sRootCont[0].equals( "SubStream1" ) && sRootCont[1].equals( "SubStorage1" ) )
+ || !( xRootNameAccess.hasByName( "SubStream1" ) && xRootNameAccess.hasByName( "SubStorage1" ) ) )
+ {
+ m_aTestHelper.Error( "Root storage contains wrong list of children!" );
+ return false;
+ }
+
+ // get storage through XNameAccess
+ XStorage xResultSubStorage = getStorageFromNameAccess( xRootNameAccess, "SubStorage1" );
+ if ( xResultSubStorage == null )
+ return false;
+
+ if ( !m_aTestHelper.checkStorageProperties( xResultSubStorage, "MediaType3", false, ElementModes.ELEMENT_READ ) )
+ return false;
+
+ XNameAccess xChildAccess = (XNameAccess) UnoRuntime.queryInterface( XNameAccess.class, xResultSubStorage );
+ if ( xChildAccess == null )
+ {
+ m_aTestHelper.Error( "Child storage doesn't support XNameAccess!" );
+ return false;
+ }
+
+ if ( !xChildAccess.hasByName( "SubStream2" )
+ || !xResultSubStorage.isStreamElement( "SubStream2" )
+ || xResultSubStorage.isStorageElement( "SubStream2" ) )
+ {
+ m_aTestHelper.Error( "'SubStream2' can not be detected as child stream element of 'SubStorage1'!" );
+ return false;
+ }
+
+ return true;
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Exception: " + e );
+ return false;
+ }
+ }
+
+ public XStorage getStorageFromNameAccess( XNameAccess xAccess, String sName )
+ {
+ try
+ {
+ Object oStorage = xAccess.getByName( sName );
+ XStorage xResult = (XStorage) UnoRuntime.queryInterface( XStorage.class, oStorage );
+
+ if ( xResult != null )
+ return xResult;
+ else
+ m_aTestHelper.Error( "Can't retrieve substorage '" + sName + "' through XNameAccess!" );
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Can't retrieve substorage '" + sName + "' through XNameAccess, exception: " + e );
+ }
+
+ return null;
+ }
+
+}
+
diff --git a/odk/examples/java/Storage/Test04.java b/odk/examples/java/Storage/Test04.java
new file mode 100644
index 000000000000..19b988f10ff5
--- /dev/null
+++ b/odk/examples/java/Storage/Test04.java
@@ -0,0 +1,273 @@
+package storagetesting;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.DisposedException;
+
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+import com.sun.star.container.XNameAccess;
+
+import com.sun.star.embed.*;
+
+import storagetesting.TestHelper;
+import storagetesting.StorageTest;
+
+public class Test04 implements StorageTest {
+
+ XMultiServiceFactory m_xMSF;
+ XSingleServiceFactory m_xStorageFactory;
+ TestHelper m_aTestHelper;
+
+ public Test04( XMultiServiceFactory xMSF, XSingleServiceFactory xStorageFactory )
+ {
+ m_xMSF = xMSF;
+ m_xStorageFactory = xStorageFactory;
+ m_aTestHelper = new TestHelper( "Test04: " );
+ }
+
+ public boolean test()
+ {
+ try
+ {
+ String sTempFileURL = m_aTestHelper.CreateTempFile( m_xMSF );
+ if ( sTempFileURL == null || sTempFileURL == "" )
+ {
+ m_aTestHelper.Error( "No valid temporary file was created!" );
+ return false;
+ }
+
+ // create temporary storage based on arbitrary medium
+ // after such a storage is closed it is lost
+ Object oTempStorage = m_xStorageFactory.createInstance();
+ XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ if ( xTempStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create temporary storage representation!" );
+ return false;
+ }
+
+ // open substorages and create streams there
+
+ // first substorage of the root storage
+ XStorage xTempSubStorage1 = m_aTestHelper.openSubStorage( xTempStorage,
+ "SubStorage1",
+ ElementModes.ELEMENT_WRITE );
+ if ( xTempSubStorage1 == null )
+ {
+ m_aTestHelper.Error( "Can't create substorage!" );
+ return false;
+ }
+
+ byte pBytes1[] = { 1, 1, 1, 1, 1 };
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage1, "SubStream1", "MediaType1", true, pBytes1 ) )
+ return false;
+
+ // second substorage of the root storage
+ XStorage xTempSubStorage2 = m_aTestHelper.openSubStorage( xTempStorage,
+ "SubStorage2",
+ ElementModes.ELEMENT_WRITE );
+ if ( xTempSubStorage2 == null )
+ {
+ m_aTestHelper.Error( "Can't create substorage!" );
+ return false;
+ }
+
+ byte pBytes2[] = { 2, 2, 2, 2, 2 };
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage2, "SubStream2", "MediaType2", false, pBytes2 ) )
+ return false;
+
+ // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
+ if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempStorage,
+ "MediaType3",
+ true,
+ ElementModes.ELEMENT_READWRITE ) )
+ return false;
+
+ // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
+ if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempSubStorage1,
+ "MediaType4",
+ false,
+ ElementModes.ELEMENT_WRITE ) )
+ return false;
+
+ // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
+ if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempSubStorage2,
+ "MediaType5",
+ false,
+ ElementModes.ELEMENT_WRITE ) )
+ return false;
+
+ // create temporary storage based on a previously created temporary file
+ Object pArgs[] = new Object[2];
+ pArgs[0] = (Object) sTempFileURL;
+ pArgs[1] = new Integer( ElementModes.ELEMENT_WRITE );
+
+ Object oTempFileStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
+ XStorage xTempFileStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
+ if ( xTempFileStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create storage based on temporary file!" );
+ return false;
+ }
+
+ if ( !m_aTestHelper.copyElementTo( xTempStorage, "SubStorage1", xTempFileStorage ) )
+ return false;
+
+ // if storage is not commited before disposing all the changes will be lost
+ if ( !m_aTestHelper.commitStorage( xTempSubStorage2 ) )
+ return false;
+
+ // a storage must be disposed before moving/removing otherwise the access will be denied
+ if ( !m_aTestHelper.disposeStorage( xTempSubStorage2 ) )
+ return false;
+
+ if ( !m_aTestHelper.moveElementTo( xTempStorage, "SubStorage2", xTempFileStorage ) )
+ return false;
+
+ // SubStorage2 must be removed and disposed now
+ try
+ {
+ xTempSubStorage2.isStreamElement( "SubStream2" );
+ m_aTestHelper.Error( "SubStorage2 must be disposed already!" );
+ return false;
+ }
+ catch( com.sun.star.lang.DisposedException de )
+ {
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Wrong exception in case of disposed storage, exception: " + e );
+ return false;
+ }
+
+ if ( !m_aTestHelper.copyElementTo( xTempSubStorage1, "SubStream1", xTempFileStorage ) )
+ return false;
+
+ if ( !m_aTestHelper.renameElement( xTempFileStorage, "SubStream1", "SubStream1_copy" ) )
+ return false;
+
+ if ( !m_aTestHelper.moveElementTo( xTempSubStorage1, "SubStream1", xTempFileStorage ) )
+ return false;
+
+ if ( !m_aTestHelper.commitStorage( xTempFileStorage ) )
+ return false;
+
+ // dispose used storages to free resources
+ if ( !m_aTestHelper.disposeStorage( xTempStorage ) || !m_aTestHelper.disposeStorage( xTempFileStorage ) )
+ return false;
+
+ // ================================================
+ // now check all the written and copied information
+ // ================================================
+
+ // the temporary file must not be locked any more after storage disposing
+ pArgs[1] = new Integer( ElementModes.ELEMENT_READWRITE );
+ Object oResStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
+ XStorage xResStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResStorage );
+ if ( xResStorage == null )
+ {
+ m_aTestHelper.Error( "Can't reopen storage based on temporary file!" );
+ return false;
+ }
+
+ // open and check SubStorage1
+ XStorage xResSubStorage1 = m_aTestHelper.openSubStorage( xResStorage,
+ "SubStorage1",
+ ElementModes.ELEMENT_READ );
+ if ( xResSubStorage1 == null )
+ {
+ m_aTestHelper.Error( "Can't open existing substorage!" );
+ return false;
+ }
+
+ if ( !m_aTestHelper.checkStorageProperties( xResSubStorage1, "MediaType4", false, ElementModes.ELEMENT_READ ) )
+ return false;
+
+
+ // open and check SubStorage2
+ XStorage xResSubStorage2 = m_aTestHelper.openSubStorage( xResStorage,
+ "SubStorage2",
+ ElementModes.ELEMENT_READ );
+ if ( xResSubStorage2 == null )
+ {
+ m_aTestHelper.Error( "Can't open existing substorage!" );
+ return false;
+ }
+
+ if ( !m_aTestHelper.checkStorageProperties( xResSubStorage2, "MediaType5", false, ElementModes.ELEMENT_READ ) )
+ return false;
+
+
+ // check all the result streams
+
+ if ( !m_aTestHelper.checkStream( xResStorage, "SubStream1", "MediaType1", pBytes1 ) )
+ return false;
+
+ if ( !m_aTestHelper.checkStream( xResStorage, "SubStream1_copy", "MediaType1", pBytes1 ) )
+ return false;
+
+ if ( !m_aTestHelper.checkStream( xResSubStorage1, "SubStream1", "MediaType1", pBytes1 ) )
+ return false;
+
+ if ( !m_aTestHelper.checkStream( xResSubStorage2, "SubStream2", "MediaType2", pBytes2 ) )
+ return false;
+
+ // the storage must be disposed before removing
+ if ( !m_aTestHelper.disposeStorage( xResSubStorage2 ) )
+ return false;
+
+ // remove element and check that it was removed completelly
+ if ( !m_aTestHelper.removeElement( xResStorage, "SubStorage2" ) )
+ return false;
+
+ try
+ {
+ XNameAccess xResAccess = (XNameAccess) UnoRuntime.queryInterface( XNameAccess.class, xResStorage );
+ if ( xResAccess.hasByName( "SubStorage2" ) )
+ m_aTestHelper.Error( "SubStorage2 must be removed already!" );
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Can't get access to root storage, exception: " + e );
+ return false;
+ }
+
+ try
+ {
+ xResSubStorage2.isStreamElement( "SubStream2" );
+
+ m_aTestHelper.Error( "SubStorage2 must be disposed already!" );
+ return false;
+ }
+ catch( com.sun.star.lang.DisposedException de )
+ {
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Wrong exception in case of disposed storage, exception: " + e );
+ return false;
+ }
+
+ // dispose used storages to free resources
+ if ( !m_aTestHelper.disposeStorage( xResStorage ) )
+ return false;
+
+ return true;
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Exception: " + e );
+ return false;
+ }
+ }
+
+}
+
diff --git a/odk/examples/java/Storage/Test05.java b/odk/examples/java/Storage/Test05.java
new file mode 100644
index 000000000000..5d2f2e359136
--- /dev/null
+++ b/odk/examples/java/Storage/Test05.java
@@ -0,0 +1,268 @@
+package storagetesting;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.io.XStream;
+
+import com.sun.star.embed.*;
+
+import storagetesting.TestHelper;
+import storagetesting.StorageTest;
+
+public class Test05 implements StorageTest {
+
+ XMultiServiceFactory m_xMSF;
+ XSingleServiceFactory m_xStorageFactory;
+ TestHelper m_aTestHelper;
+
+ public Test05( XMultiServiceFactory xMSF, XSingleServiceFactory xStorageFactory )
+ {
+ m_xMSF = xMSF;
+ m_xStorageFactory = xStorageFactory;
+ m_aTestHelper = new TestHelper( "Test05: " );
+ }
+
+ public boolean test()
+ {
+ try
+ {
+ String sTempFileURL = m_aTestHelper.CreateTempFile( m_xMSF );
+ if ( sTempFileURL == null || sTempFileURL == "" )
+ {
+ m_aTestHelper.Error( "No valid temporary file was created!" );
+ return false;
+ }
+
+ // create temporary storage based on a previously created temporary file
+ Object pArgs[] = new Object[2];
+ pArgs[0] = (Object) sTempFileURL;
+ pArgs[1] = new Integer( ElementModes.ELEMENT_WRITE );
+
+ Object oTempFileStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
+ XStorage xTempFileStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
+ if ( xTempFileStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create storage based on temporary file!" );
+ return false;
+ }
+
+ // open a new substorage
+ XStorage xTempSubStorage = m_aTestHelper.openSubStorage( xTempFileStorage,
+ "SubStorage1",
+ ElementModes.ELEMENT_WRITE );
+ if ( xTempSubStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create substorage!" );
+ return false;
+ }
+
+ // open a new substorage
+ XStorage xSubSubStorage = m_aTestHelper.openSubStorage( xTempSubStorage,
+ "SubSubStorage1",
+ ElementModes.ELEMENT_WRITE );
+ if ( xSubSubStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create substorage!" );
+ return false;
+ }
+
+
+ byte pBytes1[] = { 1, 1, 1, 1, 1 };
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xSubSubStorage, "SubStream1", "MediaType1", true, pBytes1 ) )
+ return false;
+
+ byte pBytes2[] = { 2, 2, 2, 2, 2 };
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToSubstream( xSubSubStorage, "SubStream2", "MediaType2", false, pBytes2 ) )
+ return false;
+
+ // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
+ if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempFileStorage,
+ "MediaType3",
+ true,
+ ElementModes.ELEMENT_WRITE ) )
+ return false;
+
+ // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
+ if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempSubStorage,
+ "MediaType4",
+ false,
+ ElementModes.ELEMENT_WRITE ) )
+ return false;
+
+ // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
+ if ( !m_aTestHelper.setStorageTypeAndCheckProps( xSubSubStorage,
+ "MediaType5",
+ false,
+ ElementModes.ELEMENT_WRITE ) )
+ return false;
+
+
+ // commit all the storages
+ if ( !m_aTestHelper.commitStorage( xSubSubStorage ) )
+ return false;
+
+ if ( !m_aTestHelper.commitStorage( xTempSubStorage ) )
+ return false;
+
+ if ( !m_aTestHelper.commitStorage( xTempFileStorage ) )
+ return false;
+
+ // try to open an opened substorage, open call must fail
+ if ( !m_aTestHelper.cantOpenStorage( xTempFileStorage, "SubStorage1" ) )
+ return false;
+
+
+ // reopen created streams
+ XStream xSubStream1 = m_aTestHelper.OpenStream( xSubSubStorage,
+ "SubStream1",
+ ElementModes.ELEMENT_READWRITE | ElementModes.ELEMENT_NOCREATE );
+ XStream xSubStream2 = m_aTestHelper.OpenStream( xSubSubStorage,
+ "SubStream2",
+ ElementModes.ELEMENT_READ | ElementModes.ELEMENT_NOCREATE );
+ if ( xSubStream1 == null || xSubStream2 == null )
+ return false;
+
+ // it should be possible to have more then one copy of stream for reading
+ XStream xSubStream2clone = m_aTestHelper.OpenStream( xSubSubStorage,
+ "SubStream2",
+ ElementModes.ELEMENT_READ | ElementModes.ELEMENT_NOCREATE );
+ if ( xSubStream2 == null )
+ return false;
+
+
+ // so now the first stream can not be open neither for reading nor for writing
+ if ( !m_aTestHelper.cantOpenStream( xSubSubStorage, "SubStream1", ElementModes.ELEMENT_WRITE )
+ || !m_aTestHelper.cantOpenStream( xSubSubStorage, "SubStream1", ElementModes.ELEMENT_READ ) )
+ return false;
+
+ // the second stream can not be open for writing
+ if ( !m_aTestHelper.cantOpenStream( xSubSubStorage, "SubStream2", ElementModes.ELEMENT_WRITE ) )
+ return false;
+
+
+ // dispose xTestSubStorage, all the subtree must be disposed
+ if ( !m_aTestHelper.disposeStorage( xTempSubStorage ) )
+ return false;
+
+ // check that subtree was disposed correctly
+ try
+ {
+ xSubSubStorage.isStreamElement( "SubStream1" );
+ m_aTestHelper.Error( "Substorage was not disposed!" );
+ return false;
+ }
+ catch ( com.sun.star.lang.DisposedException de )
+ {}
+ catch ( Exception e )
+ {
+ m_aTestHelper.Error( "Wrong exception is thrown by disposed storage: " + e );
+ return false;
+ }
+
+ try
+ {
+ xSubStream1.getInputStream();
+ m_aTestHelper.Error( "Writeable substream was not disposed!" );
+ return false;
+ }
+ catch ( com.sun.star.lang.DisposedException de )
+ {}
+ catch ( Exception e )
+ {
+ m_aTestHelper.Error( "Wrong exception is thrown by disposed stream: " + e );
+ return false;
+ }
+
+ try
+ {
+ xSubStream2.getInputStream();
+ m_aTestHelper.Error( "Readonly substream was not disposed!" );
+ return false;
+ }
+ catch ( com.sun.star.lang.DisposedException de )
+ {}
+ catch ( Exception e )
+ {
+ m_aTestHelper.Error( "Wrong exception is thrown by disposed stream: " + e );
+ return false;
+ }
+
+
+ // dispose root storage
+ if ( !m_aTestHelper.disposeStorage( xTempFileStorage ) )
+ return false;
+
+
+ // ================================================
+ // now check all the written and copied information
+ // ================================================
+
+ pArgs[1] = new Integer( ElementModes.ELEMENT_READ );
+ Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
+ XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage );
+ if ( xResultStorage == null )
+ {
+ m_aTestHelper.Error( "Can't reopen storage based on temporary file!" );
+ return false;
+ }
+
+ if ( !m_aTestHelper.checkStorageProperties( xResultStorage, "MediaType3", true, ElementModes.ELEMENT_READ ) )
+ return false;
+
+ // open existing substorage
+ XStorage xResSubStorage = m_aTestHelper.openSubStorage( xResultStorage,
+ "SubStorage1",
+ ElementModes.ELEMENT_READ );
+ if ( xResSubStorage == null )
+ {
+ m_aTestHelper.Error( "Can't open existing substorage 'SubSubStorage'!" );
+ return false;
+ }
+
+ if ( !m_aTestHelper.checkStorageProperties( xResSubStorage, "MediaType4", false, ElementModes.ELEMENT_READ ) )
+ return false;
+
+ // open existing substorage
+ XStorage xResSubSubStorage = m_aTestHelper.openSubStorage( xResSubStorage,
+ "SubSubStorage1",
+ ElementModes.ELEMENT_READ );
+ if ( xResSubSubStorage == null )
+ {
+ m_aTestHelper.Error( "Can't open existing substorage 'SubSubStorage'!" );
+ return false;
+ }
+
+ if ( !m_aTestHelper.checkStorageProperties( xResSubSubStorage, "MediaType5", false, ElementModes.ELEMENT_READ ) )
+ return false;
+
+ // check substreams
+ if ( !m_aTestHelper.checkStream( xResSubSubStorage, "SubStream1", "MediaType1", pBytes1 ) )
+ return false;
+
+ if ( !m_aTestHelper.checkStream( xResSubSubStorage, "SubStream2", "MediaType2", pBytes2 ) )
+ return false;
+
+ // dispose used storages to free resources
+ if ( !m_aTestHelper.disposeStorage( xResultStorage ) )
+ return false;
+
+ return true;
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Exception: " + e );
+ return false;
+ }
+ }
+
+}
+
diff --git a/odk/examples/java/Storage/Test06.java b/odk/examples/java/Storage/Test06.java
new file mode 100644
index 000000000000..854bc27b446c
--- /dev/null
+++ b/odk/examples/java/Storage/Test06.java
@@ -0,0 +1,278 @@
+package storagetesting;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.container.ElementExistException;
+
+import com.sun.star.embed.*;
+
+import storagetesting.TestHelper;
+import storagetesting.StorageTest;
+
+public class Test06 implements StorageTest {
+
+ XMultiServiceFactory m_xMSF;
+ XSingleServiceFactory m_xStorageFactory;
+ TestHelper m_aTestHelper;
+
+ public Test06( XMultiServiceFactory xMSF, XSingleServiceFactory xStorageFactory )
+ {
+ m_xMSF = xMSF;
+ m_xStorageFactory = xStorageFactory;
+ m_aTestHelper = new TestHelper( "Test06: " );
+ }
+
+ public boolean test()
+ {
+ try
+ {
+ // create temporary storage based on arbitrary medium
+ // after such a storage is closed it is lost
+ Object oTempStorage = m_xStorageFactory.createInstance();
+ XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ if ( xTempStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create temporary storage representation!" );
+ return false;
+ }
+
+ try
+ {
+ xTempStorage.copyToStorage( null );
+ m_aTestHelper.Error( "The method must throw an exception because of illegal parameter!" );
+ return false;
+ }
+ catch( com.sun.star.lang.IllegalArgumentException iae )
+ {}
+ catch( com.sun.star.uno.Exception ue )
+ {}
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Unexpected excepion because of illegal parameter : " + e );
+ return false;
+ }
+
+ // open new substorages
+ XStorage xTempSubStorage1 = m_aTestHelper.openSubStorage( xTempStorage,
+ "SubStorage1",
+ ElementModes.ELEMENT_WRITE );
+ XStorage xTempSubStorage2 = m_aTestHelper.openSubStorage( xTempStorage,
+ "SubStorage2",
+ ElementModes.ELEMENT_WRITE );
+ if ( xTempSubStorage1 == null || xTempSubStorage2 == null )
+ {
+ m_aTestHelper.Error( "Can't create substorage!" );
+ return false;
+ }
+
+ // in case stream is open for reading it must exist
+ try
+ {
+ xTempSubStorage1.openStreamElement( "NonExistingStream", ElementModes.ELEMENT_READ );
+ m_aTestHelper.Error( "The method must throw an exception in case of try to open nonexistent stream for reading!" );
+ return false;
+ }
+ catch( com.sun.star.uno.Exception ue )
+ {}
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Unexpected excepion in case of try to open nonexistent stream for reading : " + e );
+ return false;
+ }
+
+ // in case a storage is open for reading it must exist
+ try
+ {
+ xTempSubStorage1.openStreamElement( "NonExistingStorage", ElementModes.ELEMENT_READ );
+ m_aTestHelper.Error( "The method must throw an exception in case of try to open nonexistent storage for reading!" );
+ return false;
+ }
+ catch( com.sun.star.uno.Exception ue )
+ {}
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Unexpected excepion in case of try to open nonexistent storage for reading : " + e );
+ return false;
+ }
+
+ // in case of removing nonexistent element an exception must be thrown
+ try
+ {
+ xTempSubStorage1.removeElement( "NonExistingElement" );
+ m_aTestHelper.Error( "An exception must be thrown in case of removing nonexistent element!" );
+ return false;
+ }
+ catch( com.sun.star.container.NoSuchElementException ne )
+ {}
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Unexpected excepion in case of try to remove nonexistent element : " + e );
+ return false;
+ }
+
+ // in case of renaming of nonexistent element an exception must be thrown
+ try
+ {
+ xTempSubStorage1.renameElement( "NonExistingElement", "NewName" );
+ m_aTestHelper.Error( "An exception must be thrown in case of renaming nonexistent element!" );
+ return false;
+ }
+ catch( com.sun.star.container.NoSuchElementException ne )
+ {}
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Unexpected excepion in case of try to rename nonexistent element : " + e );
+ return false;
+ }
+
+ // in case of renaming to a name of existent element an exception must be thrown
+ try
+ {
+ xTempStorage.renameElement( "SubStorage1", "SubStorage2" );
+ m_aTestHelper.Error( "An exception must be thrown in case of renaming to the name of existent element!" );
+ return false;
+ }
+ catch( com.sun.star.container.ElementExistException ee )
+ {}
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Unexpected excepion in case of try to rename to the name of existent element : " + e );
+ return false;
+ }
+
+ // in case of copying target storage must be provided
+ try
+ {
+ xTempStorage.copyElementTo( "SubStorage1", null, "SubStorage1" );
+ m_aTestHelper.Error( "An exception must be thrown in case empty reference is provided as target for copying!" );
+ return false;
+ }
+ catch( com.sun.star.lang.IllegalArgumentException iae )
+ {}
+ catch( com.sun.star.uno.Exception ue )
+ {}
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Unexpected excepion in case empty reference is provieded as target for copying : " + e );
+ return false;
+ }
+
+ // in case of moving target storage must be provided
+ try
+ {
+ xTempStorage.moveElementTo( "SubStorage1", null, "SubStorage1" );
+ m_aTestHelper.Error( "An exception must be thrown in case empty reference is provided as target for moving!" );
+ return false;
+ }
+ catch( com.sun.star.lang.IllegalArgumentException iae )
+ {}
+ catch( com.sun.star.uno.Exception ue )
+ {}
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Unexpected excepion in case empty reference is provieded as target for moving : " + e );
+ return false;
+ }
+
+
+ // prepare target for further testings
+
+ // create new temporary storage based on arbitrary medium
+ Object oTargetStorage = m_xStorageFactory.createInstance();
+ XStorage xTargetStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTargetStorage );
+ if ( xTargetStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create temporary storage representation!" );
+ return false;
+ }
+
+ // open a new substorage
+ XStorage xTargetSubStorage = m_aTestHelper.openSubStorage( xTargetStorage,
+ "SubStorage1",
+ ElementModes.ELEMENT_WRITE );
+ if ( xTargetSubStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create substorage!" );
+ return false;
+ }
+
+ // in case of copying of nonexistent element an exception must be thrown
+ try
+ {
+ xTempStorage.copyElementTo( "Nonexistent element", xTargetStorage, "Target" );
+ m_aTestHelper.Error( "An exception must be thrown in case of copying of nonexisting element!" );
+ return false;
+ }
+ catch( com.sun.star.container.NoSuchElementException ne )
+ {}
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Unexpected excepion in case of copying of nonexistent element: " + e );
+ return false;
+ }
+
+ // in case of moving of nonexistent element an exception must be thrown
+ try
+ {
+ xTempStorage.moveElementTo( "Nonexistent element", xTargetStorage, "Target" );
+ m_aTestHelper.Error( "An exception must be thrown in case of moving of nonexisting element!" );
+ return false;
+ }
+ catch( com.sun.star.container.NoSuchElementException ne )
+ {}
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Unexpected excepion in case of moving of nonexistent element: " + e );
+ return false;
+ }
+
+ // in case target for copying already exists an exception must be thrown
+ try
+ {
+ xTempStorage.copyElementTo( "SubStorage1", xTargetStorage, "SubStorage1" );
+ m_aTestHelper.Error( "An exception must be thrown in case target for copying already exists!" );
+ return false;
+ }
+ catch( com.sun.star.container.ElementExistException ee )
+ {}
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Unexpected excepion in case target for copying already exists: " + e );
+ return false;
+ }
+
+ // in case target for moving already exists an exception must be thrown
+ try
+ {
+ xTempStorage.moveElementTo( "SubStorage1", xTargetStorage, "SubStorage1" );
+ m_aTestHelper.Error( "An exception must be thrown in case target for moving already exists!" );
+ return false;
+ }
+ catch( com.sun.star.container.ElementExistException ee )
+ {}
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Unexpected excepion in case target for moving already exists: " + e );
+ return false;
+ }
+
+
+ return true;
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Exception: " + e );
+ return false;
+ }
+ }
+
+}
+
diff --git a/odk/examples/java/Storage/Test07.java b/odk/examples/java/Storage/Test07.java
new file mode 100644
index 000000000000..25a2677f3728
--- /dev/null
+++ b/odk/examples/java/Storage/Test07.java
@@ -0,0 +1,137 @@
+package storagetesting;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+import com.sun.star.embed.*;
+
+import storagetesting.TestHelper;
+import storagetesting.StorageTest;
+
+public class Test07 implements StorageTest {
+
+ XMultiServiceFactory m_xMSF;
+ XSingleServiceFactory m_xStorageFactory;
+ TestHelper m_aTestHelper;
+
+ public Test07( XMultiServiceFactory xMSF, XSingleServiceFactory xStorageFactory )
+ {
+ m_xMSF = xMSF;
+ m_xStorageFactory = xStorageFactory;
+ m_aTestHelper = new TestHelper( "Test07: " );
+ }
+
+ public boolean test()
+ {
+ try
+ {
+ String sTempFileURL = m_aTestHelper.CreateTempFile( m_xMSF );
+ if ( sTempFileURL == null || sTempFileURL == "" )
+ {
+ m_aTestHelper.Error( "No valid temporary file was created!" );
+ return false;
+ }
+
+ // create temporary storage based on arbitrary medium
+ // after such a storage is closed it is lost
+ Object oTempStorage = m_xStorageFactory.createInstance();
+ XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ if ( xTempStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create temporary storage representation!" );
+ return false;
+ }
+
+ byte pBytes1[] = { 1, 1, 1, 1, 1 };
+ byte pPass1[] = { 1, 2, 3, 4, 5 };
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "SubStream1", "MediaType1", true, pBytes1, pPass1 ) )
+ return false;
+
+ byte pBytes2[] = { 2, 2, 2, 2, 2 };
+ byte pPass2[] = { 5, 4, 3, 2, 1 };
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "SubStream2", "MediaType2", false, pBytes2, pPass2 ) )
+ return false;
+
+ // create temporary storage based on a previously created temporary file
+ Object pArgs[] = new Object[2];
+ pArgs[0] = (Object) sTempFileURL;
+ pArgs[1] = new Integer( ElementModes.ELEMENT_WRITE );
+
+ Object oTempFileStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
+ XStorage xTempFileStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
+ if ( xTempFileStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create storage based on temporary file!" );
+ return false;
+ }
+
+ // copy xTempStorage to xTempFileStorage
+ // xTempFileStorage will be automatically commited
+ if ( !m_aTestHelper.copyStorage( xTempStorage, xTempFileStorage ) )
+ return false;
+
+ // dispose used storages to free resources
+ if ( !m_aTestHelper.disposeStorage( xTempStorage ) || !m_aTestHelper.disposeStorage( xTempFileStorage ) )
+ return false;
+
+ // ================================================
+ // now check all the written and copied information
+ // ================================================
+
+ // the temporary file must not be locked any more after storage disposing
+ pArgs[1] = new Integer( ElementModes.ELEMENT_READWRITE );
+ Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
+ XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage );
+ if ( xResultStorage == null )
+ {
+ m_aTestHelper.Error( "Can't reopen storage based on temporary file!" );
+ return false;
+ }
+
+ Object o2CopyStorage = m_xStorageFactory.createInstance();
+ XStorage x2CopyStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, o2CopyStorage );
+ if ( x2CopyStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create temporary storage representation!" );
+ return false;
+ }
+
+ if ( !m_aTestHelper.copyStorage( xResultStorage, x2CopyStorage ) )
+ return false;
+
+ if ( !m_aTestHelper.checkEncrStream( xResultStorage, "SubStream1", "MediaType1", pBytes1, pPass1 ) )
+ return false;
+
+ if ( !m_aTestHelper.checkEncrStream( xResultStorage, "SubStream2", "MediaType2", pBytes2, pPass2 ) )
+ return false;
+
+ if ( !m_aTestHelper.checkEncrStream( x2CopyStorage, "SubStream1", "MediaType1", pBytes1, pPass1 ) )
+ return false;
+
+ if ( !m_aTestHelper.checkEncrStream( x2CopyStorage, "SubStream2", "MediaType2", pBytes2, pPass2 ) )
+ return false;
+
+ // dispose used storages to free resources
+ if ( !m_aTestHelper.disposeStorage( xResultStorage ) )
+ return false;
+
+ return true;
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Exception: " + e );
+ return false;
+ }
+ }
+
+}
+
diff --git a/odk/examples/java/Storage/Test08.java b/odk/examples/java/Storage/Test08.java
new file mode 100644
index 000000000000..6c839943abc9
--- /dev/null
+++ b/odk/examples/java/Storage/Test08.java
@@ -0,0 +1,213 @@
+package storagetesting;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+import com.sun.star.embed.*;
+
+import storagetesting.TestHelper;
+import storagetesting.StorageTest;
+
+public class Test08 implements StorageTest {
+
+ XMultiServiceFactory m_xMSF;
+ XSingleServiceFactory m_xStorageFactory;
+ TestHelper m_aTestHelper;
+
+ public Test08( XMultiServiceFactory xMSF, XSingleServiceFactory xStorageFactory )
+ {
+ m_xMSF = xMSF;
+ m_xStorageFactory = xStorageFactory;
+ m_aTestHelper = new TestHelper( "Test08: " );
+ }
+
+ public boolean test()
+ {
+ try
+ {
+
+ // create temporary storage based on arbitrary medium
+ // after such a storage is closed it is lost
+ Object oTempStorage = m_xStorageFactory.createInstance();
+ XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ if ( xTempStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create temporary storage representation!" );
+ return false;
+ }
+
+ // set the global password for the root storage
+ XEncryptionProtectedSource xTempStorageEncryption =
+ (XEncryptionProtectedSource) UnoRuntime.queryInterface( XEncryptionProtectedSource.class, xTempStorage );
+
+ if ( xTempStorageEncryption == null )
+ {
+ m_aTestHelper.Message( "Optional interface XEncryptionProtectedSource is not implemented, feature can not be tested!" );
+ return true;
+ }
+
+ byte pPass1[] = { 1, 2, 3 };
+ byte pPass2[] = { 3, 2, 1 };
+
+ try {
+ xTempStorageEncryption.setEncryptionKey( pPass1 );
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Can't set a common encryption key for the storage, exception:" + e );
+ return false;
+ }
+
+ // open a new substorage
+ XStorage xTempSubStorage = m_aTestHelper.openSubStorage( xTempStorage,
+ "SubStorage1",
+ ElementModes.ELEMENT_WRITE );
+ if ( xTempSubStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create substorage!" );
+ return false;
+ }
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ // the stream will be encrypted with common password
+ byte pBytes1[] = { 1, 1, 1, 1, 1 };
+ if ( !m_aTestHelper.WBToSubstrOfEncr( xTempSubStorage, "SubStream1", "MediaType1", true, pBytes1, true ) )
+ return false;
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ // the stream will not be encrypted
+ byte pBytes2[] = { 2, 2, 2, 2, 2 };
+ if ( !m_aTestHelper.WBToSubstrOfEncr( xTempSubStorage, "SubStream2", "MediaType2", false, pBytes2, false ) )
+ return false;
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ // the stream will be compressed with own password
+ byte pBytes3[] = { 3, 3, 3, 3, 3 };
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ // the stream will not be encrypted
+ if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempSubStorage, "SubStream3", "MediaType3", false, pBytes3, pPass2 ) )
+ return false;
+
+ // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
+ if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempStorage,
+ "MediaType4",
+ true,
+ ElementModes.ELEMENT_READWRITE ) )
+ return false;
+
+ // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly
+ if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempSubStorage,
+ "MediaType5",
+ false,
+ ElementModes.ELEMENT_WRITE ) )
+ return false;
+
+ // create temporary file
+ String sTempFileURL = m_aTestHelper.CreateTempFile( m_xMSF );
+ if ( sTempFileURL == null || sTempFileURL == "" )
+ {
+ m_aTestHelper.Error( "No valid temporary file was created!" );
+ return false;
+ }
+
+ // create temporary storage based on a previously created temporary file
+ Object pArgs[] = new Object[2];
+ pArgs[0] = (Object) sTempFileURL;
+ pArgs[1] = new Integer( ElementModes.ELEMENT_WRITE );
+
+ Object oTempFileStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
+ XStorage xTempFileStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
+ if ( xTempFileStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create storage based on temporary file!" );
+ return false;
+ }
+
+ // copy xTempStorage to xTempFileStorage
+ // xTempFileStorage will be automatically commited
+ if ( !m_aTestHelper.copyStorage( xTempStorage, xTempFileStorage ) )
+ return false;
+
+ // dispose used storages to free resources
+ if ( !m_aTestHelper.disposeStorage( xTempStorage ) || !m_aTestHelper.disposeStorage( xTempFileStorage ) )
+ return false;
+
+ // ================================================
+ // now check all the written and copied information
+ // ================================================
+
+ // the temporary file must not be locked any more after storage disposing
+ pArgs[1] = new Integer( ElementModes.ELEMENT_READ );
+ Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
+ XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage );
+ if ( xResultStorage == null )
+ {
+ m_aTestHelper.Error( "Can't reopen storage based on temporary file!" );
+ return false;
+ }
+
+ if ( !m_aTestHelper.checkStorageProperties( xResultStorage, "MediaType4", true, ElementModes.ELEMENT_READ ) )
+ return false;
+
+ // open existing substorage
+ XStorage xResultSubStorage = m_aTestHelper.openSubStorage( xResultStorage,
+ "SubStorage1",
+ ElementModes.ELEMENT_READ );
+ if ( xResultSubStorage == null )
+ {
+ m_aTestHelper.Error( "Can't open existing substorage!" );
+ return false;
+ }
+
+ if ( !m_aTestHelper.checkStorageProperties( xResultSubStorage, "MediaType5", false, ElementModes.ELEMENT_READ ) )
+ return false;
+
+ // set the global password for the root storage
+ XEncryptionProtectedSource xResultStorageEncryption =
+ (XEncryptionProtectedSource) UnoRuntime.queryInterface( XEncryptionProtectedSource.class, xResultStorage );
+
+ if ( xResultStorageEncryption == null )
+ {
+ m_aTestHelper.Error( "XEncryptionProtectedSource was successfully used already, so it must be supported!" );
+ return false;
+ }
+
+ try {
+ xResultStorageEncryption.setEncryptionKey( pPass2 );
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Can't set a common encryption key for the storage, exception:" + e );
+ return false;
+ }
+
+ if ( !m_aTestHelper.checkEncrStream( xResultSubStorage, "SubStream1", "MediaType1", pBytes1, pPass1 ) )
+ return false;
+
+ if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream2", "MediaType2", pBytes2 ) )
+ return false;
+
+ // the common root storage password should allow to open this stream
+ if ( !m_aTestHelper.checkStream( xResultSubStorage, "SubStream3", "MediaType3", pBytes3 ) )
+ return false;
+
+ // dispose used storages to free resources
+ if ( !m_aTestHelper.disposeStorage( xResultStorage ) )
+ return false;
+
+ return true;
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Exception: " + e );
+ return false;
+ }
+ }
+}
+
diff --git a/odk/examples/java/Storage/Test09.java b/odk/examples/java/Storage/Test09.java
new file mode 100644
index 000000000000..319766024fc8
--- /dev/null
+++ b/odk/examples/java/Storage/Test09.java
@@ -0,0 +1,123 @@
+package storagetesting;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+import com.sun.star.embed.*;
+
+import storagetesting.TestHelper;
+import storagetesting.StorageTest;
+
+public class Test09 implements StorageTest {
+
+ XMultiServiceFactory m_xMSF;
+ XSingleServiceFactory m_xStorageFactory;
+ TestHelper m_aTestHelper;
+
+ public Test09( XMultiServiceFactory xMSF, XSingleServiceFactory xStorageFactory )
+ {
+ m_xMSF = xMSF;
+ m_xStorageFactory = xStorageFactory;
+ m_aTestHelper = new TestHelper( "Test09: " );
+ }
+
+ public boolean test()
+ {
+ try
+ {
+
+ // create temporary storage based on arbitrary medium
+ // after such a storage is closed it is lost
+ Object oTempStorage = m_xStorageFactory.createInstance();
+ XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oTempStorage );
+ if ( xTempStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create temporary storage representation!" );
+ return false;
+ }
+
+ byte pPass1[] = { 1, 2, 3 };
+ byte pPass2[] = { 3, 2, 1 };
+ byte pBytes[] = { 1, 1, 1, 1, 1 };
+
+ // open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes
+ // the stream will not be encrypted
+ if ( !m_aTestHelper.WriteBytesToEncrSubstream( xTempStorage, "SubStream1", "MediaType1", false, pBytes, pPass1 ) )
+ return false;
+
+ // create temporary file
+ String sTempFileURL = m_aTestHelper.CreateTempFile( m_xMSF );
+ if ( sTempFileURL == null || sTempFileURL == "" )
+ {
+ m_aTestHelper.Error( "No valid temporary file was created!" );
+ return false;
+ }
+
+ // create temporary storage based on a previously created temporary file
+ Object pArgs[] = new Object[2];
+ pArgs[0] = (Object) sTempFileURL;
+ pArgs[1] = new Integer( ElementModes.ELEMENT_WRITE );
+
+ Object oTempFileStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
+ XStorage xTempFileStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oTempFileStorage );
+ if ( xTempFileStorage == null )
+ {
+ m_aTestHelper.Error( "Can't create storage based on temporary file!" );
+ return false;
+ }
+
+ // copy xTempStorage to xTempFileStorage
+ // xTempFileStorage will be automatically commited
+ if ( !m_aTestHelper.copyStorage( xTempStorage, xTempFileStorage ) )
+ return false;
+
+ // change password of the substream of new storage based on file
+ int nResult = m_aTestHelper.ChangeStreamPass( xTempFileStorage, "SubStream1", pPass1, pPass2 );
+ if ( nResult == 0 )
+ return false; // test failed
+ else if ( nResult == -1 )
+ return true; // tested optional feature is not supported
+
+ if ( !m_aTestHelper.commitStorage( xTempFileStorage ) )
+ return false;
+
+ // dispose used storages to free resources
+ if ( !m_aTestHelper.disposeStorage( xTempStorage ) || !m_aTestHelper.disposeStorage( xTempFileStorage ) )
+ return false;
+
+ // ================================================
+ // now check all the written and copied information
+ // ================================================
+
+ // the temporary file must not be locked any more after storage disposing
+ pArgs[1] = new Integer( ElementModes.ELEMENT_READ );
+ Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
+ XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage );
+ if ( xResultStorage == null )
+ {
+ m_aTestHelper.Error( "Can't reopen storage based on temporary file!" );
+ return false;
+ }
+
+ if ( !m_aTestHelper.checkEncrStream( xResultStorage, "SubStream1", "MediaType1", pBytes, pPass2 ) )
+ return false;
+
+ // dispose used storages to free resources
+ if ( !m_aTestHelper.disposeStorage( xResultStorage ) )
+ return false;
+
+ return true;
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Exception: " + e );
+ return false;
+ }
+ }
+}
+
diff --git a/odk/examples/java/Storage/TestHelper.java b/odk/examples/java/Storage/TestHelper.java
new file mode 100644
index 000000000000..f5b487bc5730
--- /dev/null
+++ b/odk/examples/java/Storage/TestHelper.java
@@ -0,0 +1,864 @@
+package storagetesting;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.AnyConverter;
+
+import com.sun.star.lang.*;
+import com.sun.star.embed.*;
+import com.sun.star.packages.*;
+import com.sun.star.io.*;
+import com.sun.star.beans.*;
+
+public class TestHelper {
+
+ String m_sTestPrefix;
+
+ public TestHelper( String sTestPrefix )
+ {
+ m_sTestPrefix = sTestPrefix;
+ }
+
+ public boolean WriteBytesToStream( XStream xStream,
+ String sStreamName,
+ String sMediaType,
+ boolean bCompressed,
+ byte[] pBytes )
+ {
+ // get output stream of substream
+ XOutputStream xOutput = xStream.getOutputStream();
+ if ( xOutput == null )
+ {
+ Error( "Can't get XOutputStream implementation from substream '" + sStreamName + "'!" );
+ return false;
+ }
+
+ // get XTrucate implementation from output stream
+ XTruncate xTruncate = (XTruncate) UnoRuntime.queryInterface( XTruncate.class, xOutput );
+ if ( xTruncate == null )
+ {
+ Error( "Can't get XTruncate implementation from substream '" + sStreamName + "'!" );
+ return false;
+ }
+
+ // write requested byte sequence
+ try
+ {
+ xTruncate.truncate();
+ xOutput.writeBytes( pBytes );
+ }
+ catch( Exception e )
+ {
+ Error( "Can't write to stream '" + sStreamName + "', exception: " + e );
+ return false;
+ }
+
+ // get access to the XPropertySet interface
+ XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xStream );
+ if ( xPropSet == null )
+ {
+ Error( "Can't get XPropertySet implementation from substream '" + sStreamName + "'!" );
+ return false;
+ }
+
+ // set properties to the stream
+ try
+ {
+ xPropSet.setPropertyValue( "MediaType", sMediaType );
+ xPropSet.setPropertyValue( "Compressed", new Boolean( bCompressed ) );
+ }
+ catch( Exception e )
+ {
+ Error( "Can't set properties to substream '" + sStreamName + "', exception: " + e );
+ return false;
+ }
+
+ // check size property of the stream
+ try
+ {
+ int nSize = AnyConverter.toInt( xPropSet.getPropertyValue( "Size" ) );
+ if ( nSize != pBytes.length )
+ {
+ Error( "The 'Size' property of substream '" + sStreamName + "' contains wrong value!" );
+ return false;
+ }
+ }
+ catch( Exception e )
+ {
+ Error( "Can't get 'Size' property from substream '" + sStreamName + "', exception: " + e );
+ return false;
+ }
+
+ // free the stream resources, garbage collector may remove the object too late
+ XComponent xComponent = (XComponent) UnoRuntime.queryInterface( XComponent.class, xStream );
+ if ( xComponent == null )
+ {
+ Error( "Can't get XComponent implementation from substream '" + sStreamName + "'!" );
+ return false;
+ }
+ xComponent.dispose();
+
+ return true;
+ }
+
+
+ public boolean WriteBytesToSubstream( XStorage xStorage,
+ String sStreamName,
+ String sMediaType,
+ boolean bCompressed,
+ byte[] pBytes )
+ {
+ // open substream element
+ XStream xSubStream = null;
+ try
+ {
+ Object oSubStream = xStorage.openStreamElement( sStreamName, ElementModes.ELEMENT_WRITE );
+ xSubStream = (XStream) UnoRuntime.queryInterface( XStream.class, oSubStream );
+ if ( xSubStream == null )
+ {
+ Error( "Can't create substream '" + sStreamName + "'!" );
+ return false;
+ }
+ }
+ catch( Exception e )
+ {
+ Error( "Can't create substream '" + sStreamName + "', exception : " + e + "!" );
+ return false;
+ }
+
+ return WriteBytesToStream( xSubStream, sStreamName, sMediaType, bCompressed, pBytes );
+ }
+
+ public boolean WriteBytesToEncrSubstream( XStorage xStorage,
+ String sStreamName,
+ String sMediaType,
+ boolean bCompressed,
+ byte[] pBytes,
+ byte[] pPass )
+ {
+ // open substream element
+ XStream xSubStream = null;
+ try
+ {
+ Object oSubStream = xStorage.openEncryptedStreamElement( sStreamName, ElementModes.ELEMENT_WRITE, pPass );
+ xSubStream = (XStream) UnoRuntime.queryInterface( XStream.class, oSubStream );
+ if ( xSubStream == null )
+ {
+ Error( "Can't create substream '" + sStreamName + "'!" );
+ return false;
+ }
+ }
+ catch( Exception e )
+ {
+ Error( "Can't create substream '" + sStreamName + "', exception : " + e + "!" );
+ return false;
+ }
+
+ return WriteBytesToStream( xSubStream, sStreamName, sMediaType, bCompressed, pBytes );
+ }
+
+ public boolean WBToSubstrOfEncr( XStorage xStorage,
+ String sStreamName,
+ String sMediaType,
+ boolean bCompressed,
+ byte[] pBytes,
+ boolean bEncrypted )
+ {
+ // open substream element
+ XStream xSubStream = null;
+ try
+ {
+ Object oSubStream = xStorage.openStreamElement( sStreamName, ElementModes.ELEMENT_WRITE );
+ xSubStream = (XStream) UnoRuntime.queryInterface( XStream.class, oSubStream );
+ if ( xSubStream == null )
+ {
+ Error( "Can't create substream '" + sStreamName + "'!" );
+ return false;
+ }
+ }
+ catch( Exception e )
+ {
+ Error( "Can't create substream '" + sStreamName + "', exception : " + e + "!" );
+ return false;
+ }
+
+ // get access to the XPropertySet interface
+ XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xSubStream );
+ if ( xPropSet == null )
+ {
+ Error( "Can't get XPropertySet implementation from substream '" + sStreamName + "'!" );
+ return false;
+ }
+
+ // set properties to the stream
+ try
+ {
+ xPropSet.setPropertyValue( "Encrypted", new Boolean( bEncrypted ) );
+ }
+ catch( Exception e )
+ {
+ Error( "Can't set 'Encrypted' property to substream '" + sStreamName + "', exception: " + e );
+ return false;
+ }
+
+ return WriteBytesToStream( xSubStream, sStreamName, sMediaType, bCompressed, pBytes );
+ }
+
+ public int ChangeStreamPass( XStorage xStorage,
+ String sStreamName,
+ byte[] pOldPass,
+ byte[] pNewPass )
+ {
+ // open substream element
+ XStream xSubStream = null;
+ try
+ {
+ Object oSubStream = xStorage.openEncryptedStreamElement( sStreamName, ElementModes.ELEMENT_WRITE, pOldPass );
+ xSubStream = (XStream) UnoRuntime.queryInterface( XStream.class, oSubStream );
+ if ( xSubStream == null )
+ {
+ Error( "Can't open substream '" + sStreamName + "'!" );
+ return 0;
+ }
+ }
+ catch( Exception e )
+ {
+ Error( "Can't open substream '" + sStreamName + "', exception : " + e + "!" );
+ return 0;
+ }
+
+
+ // change the password for the stream
+ XEncryptionProtectedSource xStreamEncryption =
+ (XEncryptionProtectedSource) UnoRuntime.queryInterface( XEncryptionProtectedSource.class, xSubStream );
+
+ if ( xStreamEncryption == null )
+ {
+ Message( "Optional interface XEncryptionProtectedSource is not implemented, feature can not be tested!" );
+ return -1;
+ }
+
+ try {
+ xStreamEncryption.setEncryptionKey( pNewPass );
+ }
+ catch( Exception e )
+ {
+ Error( "Can't change encryption key of the substream '" + sStreamName + "', exception:" + e );
+ return 0;
+ }
+
+ // free the stream resources, garbage collector may remove the object too late
+ XComponent xComponent = (XComponent) UnoRuntime.queryInterface( XComponent.class, xSubStream );
+ if ( xComponent == null )
+ {
+ Error( "Can't get XComponent implementation from substream '" + sStreamName + "'!" );
+ return 0;
+ }
+ xComponent.dispose();
+
+ return 1;
+ }
+
+ public boolean setStorageTypeAndCheckProps( XStorage xStorage, String sMediaType, boolean bIsRoot, int nMode )
+ {
+ boolean bOk = false;
+
+ // get access to the XPropertySet interface
+ XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xStorage );
+ if ( xPropSet != null )
+ {
+ try
+ {
+ // set "MediaType" property to the stream
+ xPropSet.setPropertyValue( "MediaType", sMediaType );
+
+ // get "IsRoot" and "OpenMode" properties and control there values
+ boolean bPropIsRoot = AnyConverter.toBoolean( xPropSet.getPropertyValue( "IsRoot" ) );
+ int nPropMode = AnyConverter.toInt( xPropSet.getPropertyValue( "OpenMode" ) );
+
+ bOk = true;
+ if ( bPropIsRoot != bIsRoot )
+ {
+ Error( "'IsRoot' property contains wrong value!" );
+ bOk = false;
+ }
+
+ if ( ( bIsRoot && ( nPropMode | ElementModes.ELEMENT_READ ) != ( nMode | ElementModes.ELEMENT_READ ) )
+ || ( !bIsRoot && ( nPropMode & nMode ) != nMode ) )
+ {
+ Error( "'OpenMode' property contains wrong value!" );
+ bOk = false;
+ }
+ }
+ catch( Exception e )
+ {
+ Error( "Can't control properties of substorage, exception: " + e );
+ }
+ }
+ else
+ {
+ Error( "Can't get XPropertySet implementation from storage!" );
+ }
+
+ return bOk;
+ }
+
+ public boolean checkStorageProperties( XStorage xStorage, String sMediaType, boolean bIsRoot, int nMode )
+ {
+ boolean bOk = false;
+
+ // get access to the XPropertySet interface
+ XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xStorage );
+ if ( xPropSet != null )
+ {
+ try
+ {
+ // get "MediaType", "IsRoot" and "OpenMode" properties and control there values
+ String sPropMediaType = AnyConverter.toString( xPropSet.getPropertyValue( "MediaType" ) );
+ boolean bPropIsRoot = AnyConverter.toBoolean( xPropSet.getPropertyValue( "IsRoot" ) );
+ int nPropMode = AnyConverter.toInt( xPropSet.getPropertyValue( "OpenMode" ) );
+
+ bOk = true;
+ if ( !sPropMediaType.equals( sMediaType ) )
+ {
+ Error( "'MediaType' property contains wrong value, expected '"
+ + sMediaType + "', set '" + sPropMediaType + "' !" );
+ bOk = false;
+ }
+
+ if ( bPropIsRoot != bIsRoot )
+ {
+ Error( "'IsRoot' property contains wrong value!" );
+ bOk = false;
+ }
+
+ if ( ( bIsRoot && ( nPropMode | ElementModes.ELEMENT_READ ) != ( nMode | ElementModes.ELEMENT_READ ) )
+ || ( !bIsRoot && ( nPropMode & nMode ) != nMode ) )
+ {
+ Error( "'OpenMode' property contains wrong value!" );
+ bOk = false;
+ }
+ }
+ catch( Exception e )
+ {
+ Error( "Can't get properties of substorage, exception: " + e );
+ }
+ }
+ else
+ {
+ Error( "Can't get XPropertySet implementation from storage!" );
+ }
+
+ return bOk;
+ }
+
+ public boolean InternalCheckStream( XStream xStream,
+ String sName,
+ String sMediaType,
+ byte[] pBytes )
+ {
+ // get input stream of substream
+ XInputStream xInput = xStream.getInputStream();
+ if ( xInput == null )
+ {
+ Error( "Can't get XInputStream implementation from substream '" + sName + "'!" );
+ return false;
+ }
+
+ byte pContents[][] = new byte[1][]; // ???
+
+ // read contents
+ try
+ {
+ xInput.readBytes( pContents, pBytes.length + 1 );
+ }
+ catch( Exception e )
+ {
+ Error( "Can't read from stream '" + sName + "', exception: " + e );
+ return false;
+ }
+
+ // check size of stream data
+ if ( pContents.length == 0 )
+ {
+ Error( "SubStream '" + sName + "' reading produced disaster!" );
+ return false;
+ }
+
+ if ( pBytes.length != pContents[0].length )
+ {
+ Error( "SubStream '" + sName + "' contains wrong amount of data! (" + pContents[0].length + "/" + pBytes.length + ")" );
+ return false;
+ }
+
+ // check stream data
+ for ( int ind = 0; ind < pBytes.length; ind++ )
+ {
+ if ( pBytes[ind] != pContents[0][ind] )
+ {
+ Error( "SubStream '" + sName + "' contains wrong data!" );
+ return false;
+ }
+ }
+
+
+ // check properties
+ boolean bOk = false;
+
+ // get access to the XPropertySet interface
+ XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xStream );
+ if ( xPropSet != null )
+ {
+ try
+ {
+ // get "MediaType" and "Size" properties and control there values
+ String sPropMediaType = AnyConverter.toString( xPropSet.getPropertyValue( "MediaType" ) );
+ int nPropSize = AnyConverter.toInt( xPropSet.getPropertyValue( "Size" ) );
+
+ bOk = true;
+ if ( !sPropMediaType.equals( sMediaType ) )
+ {
+ Error( "'MediaType' property contains wrong value for stream '" + sName + "',\nexpected: '"
+ + sMediaType + "', set: '" + sPropMediaType + "'!" );
+ bOk = false;
+ }
+
+ if ( nPropSize != pBytes.length )
+ {
+ Error( "'Size' property contains wrong value for stream'" + sName + "'!" );
+ bOk = false;
+ }
+ }
+ catch( Exception e )
+ {
+ Error( "Can't get properties of substream '" + sName + "', exception: " + e );
+ }
+ }
+ else
+ {
+ Error( "Can't get XPropertySet implementation from stream '" + sName + "'!" );
+ }
+
+ return bOk;
+ }
+
+ public boolean checkStream( XStorage xParentStorage,
+ String sName,
+ String sMediaType,
+ byte[] pBytes )
+ {
+ // open substream element first
+ XStream xSubStream = null;
+ try
+ {
+ Object oSubStream = xParentStorage.openStreamElement( sName, ElementModes.ELEMENT_READ );
+ xSubStream = (XStream) UnoRuntime.queryInterface( XStream.class, oSubStream );
+ if ( xSubStream == null )
+ {
+ Error( "Can't open substream '" + sName + "'!" );
+ return false;
+ }
+ }
+ catch( Exception e )
+ {
+ Error( "Can't open substream '" + sName + "', exception : " + e + "!" );
+ return false;
+ }
+
+ return InternalCheckStream( xSubStream, sName, sMediaType, pBytes );
+ }
+
+ public boolean checkEncrStream( XStorage xParentStorage,
+ String sName,
+ String sMediaType,
+ byte[] pBytes,
+ byte[] pPass )
+ {
+ // Important: a common password for any of parent storage should not be set or
+ // should be different from pPass
+
+ if ( pPass.length == 0 )
+ {
+ Error( "Wrong password is used in the test!" );
+ return false;
+ }
+
+ try
+ {
+ Object oSubStream = xParentStorage.openStreamElement( sName, ElementModes.ELEMENT_READ );
+ Error( "Encrypted stream '" + sName + "' was opened without password!" );
+ return false;
+ }
+ catch( WrongPasswordException wpe )
+ {}
+ catch( Exception e )
+ {
+ Error( "Unexpected exception in case of opening of encrypted stream '" + sName + "' without password: " + e + "!" );
+ return false;
+ }
+
+ byte pWrongPass[] = { 1, 1 };
+ pWrongPass[0] += pPass[0];
+ try
+ {
+ Object oSubStream = xParentStorage.openEncryptedStreamElement( sName, ElementModes.ELEMENT_READ, pWrongPass );
+ Error( "Encrypted stream '" + sName + "' was opened with wrong password!" );
+ return false;
+ }
+ catch( WrongPasswordException wpe )
+ {}
+ catch( Exception e )
+ {
+ Error( "Unexpected exception in case of opening of encrypted stream '" + sName + "' with wrong password: " + e + "!" );
+ return false;
+ }
+
+ XStream xSubStream = null;
+ try
+ {
+ Object oSubStream = xParentStorage.openEncryptedStreamElement( sName, ElementModes.ELEMENT_READ, pPass );
+ xSubStream = (XStream) UnoRuntime.queryInterface( XStream.class, oSubStream );
+ if ( xSubStream == null )
+ {
+ Error( "Can't open encrypted substream '" + sName + "'!" );
+ return false;
+ }
+ }
+ catch( Exception e )
+ {
+ Error( "Can't open encrypted substream '" + sName + "', exception : " + e + "!" );
+ return false;
+ }
+
+ return InternalCheckStream( xSubStream, sName, sMediaType, pBytes );
+ }
+
+ public boolean copyStorage( XStorage xSourceStorage, XStorage xDestStorage )
+ {
+ // copy xSourceStorage to xDestStorage
+ try
+ {
+ xSourceStorage.copyToStorage( xDestStorage );
+ }
+ catch( Exception e )
+ {
+ Error( "Storage copying failed, exception: " + e );
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean commitStorage( XStorage xStorage )
+ {
+ // XTransactedObject must be supported by storages
+ XTransactedObject xTransact = (XTransactedObject) UnoRuntime.queryInterface( XTransactedObject.class, xStorage );
+ if ( xTransact == null )
+ {
+ Error( "Storage doesn't implement transacted access!" );
+ return false;
+ }
+
+ try
+ {
+ xTransact.commit();
+ }
+ catch( Exception e )
+ {
+ Error( "Storage commit failed, exception:" + e );
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean disposeStorage( XStorage xStorage )
+ {
+ // dispose the storage
+ XComponent xComponent = (XComponent) UnoRuntime.queryInterface( XComponent.class, xStorage );
+ if ( xComponent == null )
+ {
+ Error( "Can't retrieve XComponent implementation from storage!" );
+ return false;
+ }
+
+ try
+ {
+ xComponent.dispose();
+ }
+ catch( Exception e )
+ {
+ Error( "Storage disposing failed!" );
+ return false;
+ }
+
+ return true;
+ }
+
+ public XInputStream getInputStream( XStream xStream )
+ {
+ XInputStream xInTemp = null;
+ try
+ {
+ xInTemp = xStream.getInputStream();
+ if ( xInTemp == null )
+ Error( "Can't get the input part of a stream!" );
+ }
+ catch ( Exception e )
+ {
+ Error( "Can't get the input part of a stream, exception :" + e );
+ }
+
+ return xInTemp;
+ }
+
+ public boolean closeOutput( XStream xStream )
+ {
+ XOutputStream xOutTemp = null;
+ try
+ {
+ xOutTemp = xStream.getOutputStream();
+ if ( xOutTemp == null )
+ {
+ Error( "Can't get the output part of a stream!" );
+ return false;
+ }
+ }
+ catch ( Exception e )
+ {
+ Error( "Can't get the output part of a stream, exception :" + e );
+ return false;
+ }
+
+ try
+ {
+ xOutTemp.closeOutput();
+ }
+ catch ( Exception e )
+ {
+ Error( "Can't close output part of a stream, exception :" + e );
+ return false;
+ }
+
+ return true;
+ }
+
+ public XStorage openSubStorage( XStorage xStorage, String sName, int nMode )
+ {
+ // open existing substorage
+ try
+ {
+ Object oSubStorage = xStorage.openStorageElement( sName, nMode );
+ XStorage xSubStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oSubStorage );
+ return xSubStorage;
+ }
+ catch( Exception e )
+ {
+ Error( "Can't open substorage '" + sName + "', exception: " + e );
+ }
+
+ return null;
+ }
+
+ public XStream CreateTempFileStream( XMultiServiceFactory xMSF )
+ {
+ // try to get temporary file representation
+ XStream xTempFileStream = null;
+ try
+ {
+ Object oTempFile = xMSF.createInstance( "com.sun.star.io.TempFile" );
+ xTempFileStream = (XStream)UnoRuntime.queryInterface( XStream.class, oTempFile );
+ }
+ catch( Exception e )
+ {}
+
+ if ( xTempFileStream == null )
+ Error( "Can't create temporary file!" );
+
+ return xTempFileStream;
+ }
+
+ public String CreateTempFile( XMultiServiceFactory xMSF )
+ {
+ String sResult = null;
+
+ // try to get temporary file representation
+ XPropertySet xTempFileProps = null;
+ try
+ {
+ Object oTempFile = xMSF.createInstance( "com.sun.star.io.TempFile" );
+ xTempFileProps = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, oTempFile );
+ }
+ catch( Exception e )
+ {}
+
+ if ( xTempFileProps != null )
+ {
+ try
+ {
+ xTempFileProps.setPropertyValue( "RemoveFile", new Boolean( false ) );
+ sResult = AnyConverter.toString( xTempFileProps.getPropertyValue( "Uri" ) );
+ }
+ catch( Exception e )
+ {
+ Error( "Can't control TempFile properties, exception: " + e );
+ }
+ }
+ else
+ {
+ Error( "Can't create temporary file representation!" );
+ }
+
+ // close temporary file explicitly
+ try
+ {
+ XStream xStream = (XStream)UnoRuntime.queryInterface( XStream.class, xTempFileProps );
+ if ( xStream != null )
+ {
+ XOutputStream xOut = xStream.getOutputStream();
+ if ( xOut != null )
+ xOut.closeOutput();
+
+ XInputStream xIn = xStream.getInputStream();
+ if ( xIn != null )
+ xIn.closeInput();
+ }
+ else
+ Error( "Can't close TempFile!" );
+ }
+ catch( Exception e )
+ {
+ Error( "Can't close TempFile, exception: " + e );
+ }
+
+ return sResult;
+ }
+
+ public boolean copyElementTo( XStorage xSource, String sName, XStorage xDest )
+ {
+ // copy element with name sName from xSource to xDest
+ try
+ {
+ xSource.copyElementTo( sName, xDest, sName );
+ }
+ catch( Exception e )
+ {
+ Error( "Element copying failed, exception: " + e );
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean moveElementTo( XStorage xSource, String sName, XStorage xDest )
+ {
+ // move element with name sName from xSource to xDest
+ try
+ {
+ xSource.moveElementTo( sName, xDest, sName );
+ }
+ catch( Exception e )
+ {
+ Error( "Element moving failed, exception: " + e );
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean renameElement( XStorage xStorage, String sOldName, String sNewName )
+ {
+ // rename element with name sOldName to sNewName
+ try
+ {
+ xStorage.renameElement( sOldName, sNewName );
+ }
+ catch( Exception e )
+ {
+ Error( "Element renaming failed, exception: " + e );
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean removeElement( XStorage xStorage, String sName )
+ {
+ // remove element with name sName
+ try
+ {
+ xStorage.removeElement( sName );
+ }
+ catch( Exception e )
+ {
+ Error( "Element removing failed, exception: " + e );
+ return false;
+ }
+
+ return true;
+ }
+
+ public XStream OpenStream( XStorage xStorage,
+ String sStreamName,
+ int nMode )
+ {
+ // open substream element
+ XStream xSubStream = null;
+ try
+ {
+ Object oSubStream = xStorage.openStreamElement( sStreamName, nMode );
+ xSubStream = (XStream) UnoRuntime.queryInterface( XStream.class, oSubStream );
+ if ( xSubStream == null )
+ Error( "Can't create substream '" + sStreamName + "'!" );
+ }
+ catch( Exception e )
+ {
+ Error( "Can't create substream '" + sStreamName + "', exception : " + e + "!" );
+ }
+
+ return xSubStream;
+ }
+
+ public boolean cantOpenStorage( XStorage xStorage, String sName )
+ {
+ // try to open an opened substorage, open call must fail
+ try
+ {
+ Object oDummyStorage = xStorage.openStorageElement( sName, ElementModes.ELEMENT_READ );
+ Error( "The trying to reopen opened substorage '" + sName + "' must fail!" );
+ }
+ catch( Exception e )
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ public boolean cantOpenStream( XStorage xStorage, String sName, int nMode )
+ {
+ // try to open the substream with specified mode must fail
+ try
+ {
+ Object oDummyStream = xStorage.openStreamElement( sName, nMode );
+ Error( "The trying to open substoream '" + sName + "' must fail!" );
+ }
+ catch( Exception e )
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ public void Error( String sError )
+ {
+ System.out.println( m_sTestPrefix + "Error: " + sError );
+ }
+
+ public void Message( String sError )
+ {
+ System.out.println( m_sTestPrefix + sError );
+ }
+}
+
diff --git a/odk/examples/java/Text/BookmarkInsertion.java b/odk/examples/java/Text/BookmarkInsertion.java
new file mode 100644
index 000000000000..89fb0ec4e841
--- /dev/null
+++ b/odk/examples/java/Text/BookmarkInsertion.java
@@ -0,0 +1,284 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+//***************************************************************************
+// comment: Step 1: get the Desktop object from the office
+// Step 2: open an empty text document
+// Step 3: enter a example text
+// Step 4: insert some bookmarks
+//
+// Chapter 5.1.1.4 Inserting bookmarks
+//***************************************************************************
+
+import com.sun.star.uno.UnoRuntime;
+
+public class BookmarkInsertion {
+
+ public static void main(String args[]) {
+ // You need the desktop to create a document
+ // The getDesktop method does the UNO bootstrapping, gets the
+ // remote servie manager and the desktop object.
+ com.sun.star.frame.XDesktop xDesktop = null;
+ xDesktop = getDesktop();
+
+ // create text document
+ com.sun.star.text.XTextDocument xTextDocument = null;
+ xTextDocument = createTextdocument(xDesktop);
+
+ // put example text in document
+ createExampleData(xTextDocument);
+
+
+ String mOffending[] = { "negro(e|es)?","bor(ed|ing)?",
+ "bloody?", "bleed(ing)?" };
+ String mBad[] = { "possib(le|ilit(y|ies))", "real(ly)+", "brilliant" };
+
+ String sOffendPrefix = "Offending";
+ String sBadPrefix = "BadStyle";
+
+ markList(xTextDocument, mOffending, sOffendPrefix);
+ markList(xTextDocument, mBad, sBadPrefix);
+
+ System.out.println("Done");
+
+ System.exit(0);
+ }
+
+ public static void markList(com.sun.star.text.XTextDocument xTextDocument,
+ String mList[], String sPrefix) {
+ int iCounter=0;
+ com.sun.star.uno.XInterface xSearchInterface = null;
+ com.sun.star.text.XTextRange xSearchTextRange = null;
+
+ try {
+ for( iCounter = 0; iCounter < mList.length; iCounter++ ) {
+ // the findfirst returns a XInterface
+ xSearchInterface = (com.sun.star.uno.XInterface)FindFirst(
+ xTextDocument, mList[ iCounter ] );
+
+ if( xSearchInterface != null ) {
+ // get the TextRange form the XInterface
+ xSearchTextRange = (com.sun.star.text.XTextRange)
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XTextRange.class, xSearchInterface);
+
+ InsertBookmark(xTextDocument, xSearchTextRange,
+ sPrefix + iCounter);
+ }
+ }
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+
+
+ public static void InsertBookmark(com.sun.star.text.XTextDocument xTextDocument,
+ com.sun.star.text.XTextRange xTextRange,
+ String sBookName) {
+ // create a bookmark on a TextRange
+ try {
+ // get the MultiServiceFactory from the text document
+ com.sun.star.lang.XMultiServiceFactory xDocMSF;
+ xDocMSF = (com.sun.star.lang.XMultiServiceFactory)
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, xTextDocument);
+
+ // the bookmark service is a context dependend service, you need
+ // the MultiServiceFactory from the document
+ Object xObject = xDocMSF.createInstance("com.sun.star.text.Bookmark");
+
+ // set the name from the bookmark
+ com.sun.star.container.XNamed xNameAccess = null;
+ xNameAccess = (com.sun.star.container.XNamed)
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XNamed.class, xObject);
+
+ xNameAccess.setName(sBookName);
+
+ // create a XTextContent, for the method 'insertTextContent'
+ com.sun.star.text.XTextContent xTextContent = null;
+ xTextContent = (com.sun.star.text.XTextContent)
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XTextContent.class, xNameAccess);
+
+ // insertTextContent need a TextRange not a cursor to specify the
+ // position from the bookmark
+ xTextDocument.getText().insertTextContent(xTextRange, xTextContent, true);
+
+ System.out.println("Insert bookmark: " + sBookName);
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+ }
+
+ protected static com.sun.star.uno.XInterface FindFirst(
+ com.sun.star.text.XTextDocument xTextDocument, String sSearchString)
+ {
+ com.sun.star.util.XSearchDescriptor xSearchDescriptor = null;
+ com.sun.star.util.XSearchable xSearchable = null;
+ com.sun.star.uno.XInterface xSearchInterface = null;
+
+ try {
+ xSearchable = (com.sun.star.util.XSearchable)
+ UnoRuntime.queryInterface(
+ com.sun.star.util.XSearchable.class, xTextDocument);
+ xSearchDescriptor = (com.sun.star.util.XSearchDescriptor)
+ xSearchable.createSearchDescriptor();
+
+ xSearchDescriptor.setSearchString(sSearchString);
+
+ com.sun.star.beans.XPropertySet xPropertySet = null;
+ xPropertySet = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xSearchDescriptor);
+
+ xPropertySet.setPropertyValue("SearchRegularExpression",
+ new Boolean( true ) );
+
+ xSearchInterface = (com.sun.star.uno.XInterface)
+ xSearchable.findFirst(xSearchDescriptor);
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ return xSearchInterface;
+ }
+
+ protected static void createExampleData(
+ com.sun.star.text.XTextDocument xTextDocument )
+ {
+ com.sun.star.text.XTextCursor xTextCursor = null;
+
+ try {
+ xTextCursor = (com.sun.star.text.XTextCursor)
+ xTextDocument.getText().createTextCursor();
+
+ xTextCursor.setString( "He heard quiet steps behind him. That didn't bode well. Who could be following him this late at night and in this deadbeat part of town? And at this particular moment, just after he pulled off the big time and was making off with the greenbacks. Was there another crook who'd had the same idea, and was now watching him and waiting for a chance to grab the fruit of his labor?" );
+ xTextCursor.collapseToEnd();
+ xTextCursor.setString( "Or did the steps behind him mean that one of many bloody officers in town was on to him and just waiting to pounce and snap those cuffs on his wrists? He nervously looked all around. Suddenly he saw the alley. Like lightening he darted off to the left and disappeared between the two warehouses almost falling over the trash can lying in the middle of the sidewalk. He tried to nervously tap his way along in the inky darkness and suddenly stiffened: it was a dead-end, he would have to go back the way he had come" );
+ xTextCursor.collapseToEnd();
+ xTextCursor.setString( "The steps got louder and louder, he saw the black outline of a figure coming around the corner. Is this the end of the line? he thought pressing himself back against the wall trying to make himself invisible in the dark, was all that planning and energy wasted? He was dripping with sweat now, cold and wet, he could smell the brilliant fear coming off his clothes. Suddenly next to him, with a barely noticeable squeak, a door swung quietly to and fro in the night's breeze." );
+
+ xTextCursor.gotoStart(false);
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ }
+
+ public static com.sun.star.frame.XDesktop getDesktop() {
+ com.sun.star.frame.XDesktop xDesktop = null;
+ com.sun.star.lang.XMultiComponentFactory xMCF = null;
+
+ try {
+ com.sun.star.uno.XComponentContext xContext = null;
+
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+
+ // get the remote office service manager
+ xMCF = xContext.getServiceManager();
+ if( xMCF != null ) {
+ System.out.println("Connected to a running office ...");
+
+ Object oDesktop = xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xContext);
+ xDesktop = (com.sun.star.frame.XDesktop) UnoRuntime.queryInterface(
+ com.sun.star.frame.XDesktop.class, oDesktop);
+ }
+ else
+ System.out.println( "Can't create a desktop. No connection, no remote office servicemanager available!" );
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+
+
+ return xDesktop;
+ }
+
+ public static com.sun.star.text.XTextDocument createTextdocument(
+ com.sun.star.frame.XDesktop xDesktop )
+ {
+ com.sun.star.text.XTextDocument aTextDocument = null;
+
+ try {
+ com.sun.star.lang.XComponent xComponent = CreateNewDocument(xDesktop,
+ "swriter");
+ aTextDocument = (com.sun.star.text.XTextDocument)
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xComponent);
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ return aTextDocument;
+ }
+
+
+ protected static com.sun.star.lang.XComponent CreateNewDocument(
+ com.sun.star.frame.XDesktop xDesktop,
+ String sDocumentType )
+ {
+ String sURL = "private:factory/" + sDocumentType;
+
+ com.sun.star.lang.XComponent xComponent = null;
+ com.sun.star.frame.XComponentLoader xComponentLoader = null;
+ com.sun.star.beans.PropertyValue xValues[] =
+ new com.sun.star.beans.PropertyValue[1];
+ com.sun.star.beans.PropertyValue xEmptyArgs[] =
+ new com.sun.star.beans.PropertyValue[0];
+
+ try {
+ xComponentLoader = (com.sun.star.frame.XComponentLoader)
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, xDesktop);
+
+ xComponent = xComponentLoader.loadComponentFromURL(
+ sURL, "_blank", 0, xEmptyArgs);
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.out);
+ }
+
+ return xComponent ;
+ }
+}
diff --git a/odk/examples/java/Text/GraphicsInserter.java b/odk/examples/java/Text/GraphicsInserter.java
new file mode 100644
index 000000000000..866da1c0849f
--- /dev/null
+++ b/odk/examples/java/Text/GraphicsInserter.java
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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 java.io.PrintWriter;
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+
+
+public class GraphicsInserter {
+ public static void main(String args[]) {
+ if ( args.length < 1 )
+ {
+ System.out.println(
+ "usage: java -jar GraphicsInserter.jar \"<Graphic URL|path>\"" );
+ System.out.println( "\ne.g.:" );
+ System.out.println(
+ "java -jar GraphicsInserter.jar \"file:///f:/TestGraphics.gif\"" );
+ System.exit( 1 );
+ }
+
+ com.sun.star.uno.XComponentContext xContext = null;
+
+ try {
+
+ // bootstrap UNO and get the remote component context. The context can
+ // be used to get the service manager
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+
+ // get the remote office service manager
+ com.sun.star.lang.XMultiComponentFactory xMCF =
+ xContext.getServiceManager();
+
+ /* A desktop environment contains tasks with one or more
+ frames in which components can be loaded. Desktop is the
+ environment for components which can instanciate within
+ frames. */
+ com.sun.star.frame.XDesktop xDesktop = (com.sun.star.frame.XDesktop)
+ UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class,
+ xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
+ xContext ) );
+
+ com.sun.star.frame.XComponentLoader xCompLoader =
+ (com.sun.star.frame.XComponentLoader)UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, xDesktop);
+
+ // Load a Writer document, which will be automaticly displayed
+ com.sun.star.lang.XComponent xComp = xCompLoader.loadComponentFromURL(
+ "private:factory/swriter", "_blank", 0,
+ new com.sun.star.beans.PropertyValue[0]);
+
+ // Querying for the interface XTextDocument on the xcomponent
+ com.sun.star.text.XTextDocument xTextDoc =
+ (com.sun.star.text.XTextDocument)UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xComp);
+
+ // Querying for the interface XMultiServiceFactory on the xtextdocument
+ com.sun.star.lang.XMultiServiceFactory xMSFDoc =
+ (com.sun.star.lang.XMultiServiceFactory)UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, xTextDoc);
+
+ // Providing a log file for output
+ PrintWriter printwriterLog = new PrintWriter(
+ new BufferedWriter( new FileWriter("log.txt") ) );
+
+ Object oGraphic = null;
+ try {
+ // Creating the service GraphicObject
+ oGraphic =
+ xMSFDoc.createInstance("com.sun.star.text.TextGraphicObject");
+ }
+ catch ( Exception exception ) {
+ System.out.println( "Could not create instance" );
+ exception.printStackTrace( printwriterLog );
+ }
+
+ // Getting the text
+ com.sun.star.text.XText xText = xTextDoc.getText();
+
+ // Getting the cursor on the document
+ com.sun.star.text.XTextCursor xTextCursor = xText.createTextCursor();
+
+ // Querying for the interface XTextContent on the GraphicObject
+ com.sun.star.text.XTextContent xTextContent =
+ (com.sun.star.text.XTextContent)UnoRuntime.queryInterface(
+ com.sun.star.text.XTextContent.class, oGraphic );
+
+ // Printing information to the log file
+ printwriterLog.println( "inserting graphic" );
+ try {
+ // Inserting the content
+ xText.insertTextContent(xTextCursor, xTextContent, true);
+ } catch ( Exception exception ) {
+ System.out.println( "Could not insert Content" );
+ exception.printStackTrace(System.err);
+ }
+
+ // Printing information to the log file
+ printwriterLog.println( "adding graphic" );
+
+ // Querying for the interface XPropertySet on GraphicObject
+ com.sun.star.beans.XPropertySet xPropSet =
+ (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, oGraphic);
+ try {
+ // Creating a string for the graphic url
+ java.io.File sourceFile = new java.io.File(args[0]);
+ StringBuffer sUrl = new StringBuffer("file:///");
+ sUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
+ System.out.println( "insert graphic \"" + sUrl + "\"");
+
+ // Setting the anchor type
+ xPropSet.setPropertyValue("AnchorType",
+ com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH );
+
+ // Setting the graphic url
+ xPropSet.setPropertyValue( "GraphicURL", sUrl.toString() );
+
+ // Setting the horizontal position
+ xPropSet.setPropertyValue( "HoriOrientPosition",
+ new Integer( 5500 ) );
+
+ // Setting the vertical position
+ xPropSet.setPropertyValue( "VertOrientPosition",
+ new Integer( 4200 ) );
+
+ // Setting the width
+ xPropSet.setPropertyValue( "Width", new Integer( 4400 ) );
+
+ // Setting the height
+ xPropSet.setPropertyValue( "Height", new Integer( 4000 ) );
+ } catch ( Exception exception ) {
+ System.out.println( "Couldn't set property 'GraphicURL'" );
+ exception.printStackTrace( printwriterLog );
+ }
+
+ xContext = null;
+
+ System.exit(0);
+ }
+ catch( Exception e ) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+}
diff --git a/odk/examples/java/Text/HardFormatting.java b/odk/examples/java/Text/HardFormatting.java
new file mode 100644
index 000000000000..b1ec48da7cb7
--- /dev/null
+++ b/odk/examples/java/Text/HardFormatting.java
@@ -0,0 +1,286 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+//***************************************************************************
+// comment: Step 1: get the Desktop object from the office
+// Step 2: open an empty text document
+// Step 3: enter a example text
+// Step 4: get some text attributes
+// Step 5: check the PropertyState from the selection
+//
+// Chapter 4.1.4 Hard formatting
+//***************************************************************************
+
+import com.sun.star.uno.UnoRuntime;
+
+public class HardFormatting {
+
+ public static void main(String args[]) {
+ // You need the desktop to create a document
+ // The getDesktop method does the UNO bootstrapping, gets the
+ // remote servie manager and the desktop object.
+ com.sun.star.frame.XDesktop xDesktop = null;
+ xDesktop = getDesktop();
+
+ try {
+ // create text document
+ com.sun.star.text.XTextDocument xTextDocument = null;
+ xTextDocument = createTextdocument(xDesktop);
+
+ // the text interface contains all methods and properties to
+ // manipulate the content from a text document
+ com.sun.star.text.XText xText = null;
+ xText = xTextDocument.getText();
+
+ String sMyText = "A very short paragraph for illustration only";
+
+ // you can travel with the cursor throught the text document.
+ // you travel only at the model, not at the view. The cursor that you can
+ // see on the document doesn't change the position
+ com.sun.star.text.XTextCursor xTextCursor = null;
+ xTextCursor = (com.sun.star.text.XTextCursor)
+ xTextDocument.getText().createTextCursor();
+
+ xText.insertString( xTextCursor, "Headline", false );
+ xText.insertControlCharacter(xTextCursor,
+ com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false);
+
+ xText.insertString(xTextCursor, sMyText, false);
+
+ com.sun.star.text.XTextRange xTextRange = null;
+ com.sun.star.beans.XPropertySet xPropertySet = null;
+
+ // BEGIN: 'Hard formating'
+ // the text range not the cursor contains the 'parastyle' property
+ xTextRange = xText.getEnd();
+ xPropertySet = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xTextRange);
+
+ // create a paragraph cursor to travel throught the paragraphs
+ com.sun.star.text.XParagraphCursor xParagraphCursor = null;
+ xParagraphCursor = (com.sun.star.text.XParagraphCursor)
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XParagraphCursor.class, xTextRange);
+
+ xParagraphCursor.gotoStart( false );
+ xParagraphCursor.gotoEndOfParagraph( true );
+ xTextRange = xParagraphCursor.getText().getStart();
+
+ // create a WordCursor to travel into the paragraph
+ com.sun.star.text.XWordCursor xWordCursor = null;
+ xWordCursor = (com.sun.star.text.XWordCursor) UnoRuntime.queryInterface(
+ com.sun.star.text.XWordCursor.class, xTextRange);
+
+ // the PropertySet from the cursor contains the text attributes
+ xPropertySet = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xWordCursor);
+ System.out.println(
+ "Parastyle : "
+ +xPropertySet.getPropertyValue("ParaStyleName").toString()
+ + "\nFontname : "
+ + xPropertySet.getPropertyValue("CharFontName").toString()
+ + "\nWeight : "
+ + xPropertySet.getPropertyValue("CharWeight").toString() );
+
+ xWordCursor.gotoNextWord(false);
+ xWordCursor.gotoNextWord(false);
+ xWordCursor.gotoEndOfWord(true);
+
+ xPropertySet = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xWordCursor);
+ xPropertySet.setPropertyValue("CharWeight",
+ new Float(com.sun.star.awt.FontWeight.BOLD));
+ xPropertySet.setPropertyValue("CharColor", new Integer( 255 ) );
+
+ System.out.println(
+ "Parastyle : "
+ + xPropertySet.getPropertyValue("ParaStyleName").toString()
+ + "\nFontname : "
+ + xPropertySet.getPropertyValue("CharFontName").toString()
+ + "\nWeight : "
+ + xPropertySet.getPropertyValue("CharWeight").toString() );
+
+ // the PropertyState contains information where the attribute is set,
+ // is a text part hard formated or not.
+ com.sun.star.beans.XPropertyState xPropertyState = null;
+ xPropertyState = (com.sun.star.beans.XPropertyState)
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertyState.class, xWordCursor);
+
+ com.sun.star.beans.PropertyState xPropertyStateValue =
+ xPropertyState.getPropertyState("CharWeight");
+
+ checkPropertyState( xWordCursor, xPropertyStateValue );
+
+ xWordCursor.goRight( (short) 3 , true );
+ xPropertyStateValue = xPropertyState.getPropertyState("CharWeight");
+
+ System.out.println("Increase the selection with three characters");
+ checkPropertyState(xWordCursor, xPropertyStateValue);
+
+ xPropertyState.setPropertyToDefault("CharWeight");
+
+ System.out.println("Set the default value on the selection");
+ xPropertyStateValue = xPropertyState.getPropertyState("CharWeight");
+ checkPropertyState(xWordCursor, xPropertyStateValue);
+
+ // END: 'Hard formating' Section from the Cookbook
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+
+
+ System.out.println("Done");
+
+ System.exit(0);
+
+ }
+
+
+ public static void checkPropertyState(
+ com.sun.star.text.XWordCursor xWordCursor,
+ com.sun.star.beans.PropertyState xPropertyStateValue )
+ {
+ switch( xPropertyStateValue.getValue() ) {
+ case com.sun.star.beans.PropertyState.DIRECT_VALUE_value: {
+ System.out.println( "-> The selection '"
+ + xWordCursor.getString()
+ + "' completly hard formated" );
+ break;
+ }
+
+ case com.sun.star.beans.PropertyState.DEFAULT_VALUE_value: {
+ System.out.println( "-> The selection '"
+ + xWordCursor.getString()
+ + "' isn't hard formated" );
+ break;
+ }
+
+ case com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE_value: {
+ System.out.println( "-> The selection '"
+ + xWordCursor.getString()
+ + "' isn't completly hard formated" );
+ break;
+ }
+
+ default:
+ System.out.println( "No PropertyState found" );
+ }
+ }
+
+ public static com.sun.star.frame.XDesktop getDesktop() {
+ com.sun.star.frame.XDesktop xDesktop = null;
+ com.sun.star.lang.XMultiComponentFactory xMCF = null;
+
+ try {
+ com.sun.star.uno.XComponentContext xContext = null;
+
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+
+ // get the remote office service manager
+ xMCF = xContext.getServiceManager();
+ if( xMCF != null ) {
+ System.out.println("Connected to a running office ...");
+
+ Object oDesktop = xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xContext);
+ xDesktop = (com.sun.star.frame.XDesktop) UnoRuntime.queryInterface(
+ com.sun.star.frame.XDesktop.class, oDesktop);
+ }
+ else
+ System.out.println( "Can't create a desktop. No connection, no remote office servicemanager available!" );
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+
+
+ return xDesktop;
+ }
+
+ public static com.sun.star.text.XTextDocument createTextdocument(
+ com.sun.star.frame.XDesktop xDesktop )
+ {
+ com.sun.star.text.XTextDocument aTextDocument = null;
+
+ try {
+ com.sun.star.lang.XComponent xComponent = CreateNewDocument(xDesktop,
+ "swriter");
+ aTextDocument = (com.sun.star.text.XTextDocument)
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xComponent);
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ return aTextDocument;
+ }
+
+
+ protected static com.sun.star.lang.XComponent CreateNewDocument(
+ com.sun.star.frame.XDesktop xDesktop,
+ String sDocumentType )
+ {
+ String sURL = "private:factory/" + sDocumentType;
+
+ com.sun.star.lang.XComponent xComponent = null;
+ com.sun.star.frame.XComponentLoader xComponentLoader = null;
+ com.sun.star.beans.PropertyValue xValues[] =
+ new com.sun.star.beans.PropertyValue[1];
+ com.sun.star.beans.PropertyValue xEmptyArgs[] =
+ new com.sun.star.beans.PropertyValue[0];
+
+ try {
+ xComponentLoader = (com.sun.star.frame.XComponentLoader)
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, xDesktop);
+
+ xComponent = xComponentLoader.loadComponentFromURL(
+ sURL, "_blank", 0, xEmptyArgs);
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ return xComponent ;
+ }
+}
diff --git a/odk/examples/java/Text/Makefile b/odk/examples/java/Text/Makefile
new file mode 100644
index 000000000000..9fb4b6226407
--- /dev/null
+++ b/odk/examples/java/Text/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 Java Text examples 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
+EXAMPLE_NAME=JavaTextExamples
+OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+APP1_NAME=BookmarkInsertion
+APP1_JAR=$(OUT_APP_CLASS)/$(APP1_NAME).jar
+APP2_NAME=HardFormatting
+APP2_JAR=$(OUT_APP_CLASS)/$(APP2_NAME).jar
+APP3_NAME=StyleCreation
+APP3_JAR=$(OUT_APP_CLASS)/$(APP3_NAME).jar
+APP4_NAME=StyleInitialization
+APP4_JAR=$(OUT_APP_CLASS)/$(APP4_NAME).jar
+APP5_NAME=SWriter
+APP5_JAR=$(OUT_APP_CLASS)/$(APP5_NAME).jar
+APP6_NAME=TextDocumentStructure
+APP6_JAR=$(OUT_APP_CLASS)/$(APP6_NAME).jar
+APP7_NAME=TextReplace
+APP7_JAR=$(OUT_APP_CLASS)/$(APP7_NAME).jar
+APP8_NAME=WriterSelector
+APP8_JAR=$(OUT_APP_CLASS)/$(APP8_NAME).jar
+APP9_NAME=GraphicsInserter
+APP9_JAR=$(OUT_APP_CLASS)/$(APP9_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
+ -$(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
+$(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
+$(APP9_JAR) : $(OUT_APP_CLASS)/$(APP9_NAME).mf $(OUT_APP_CLASS)/$(APP9_NAME).class
+
+$(EXAMPLE_NAME) : $(APP1_JAR) $(APP2_JAR) $(APP3_JAR) $(APP4_JAR) $(APP5_JAR) $(APP6_JAR) $(APP7_JAR) $(APP8_JAR) $(APP9_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo The GraphicsInserter example loads the graphic "$(QM)./oo_smiley.gif$(QM)" into a
+ @echo new document.
+ @echo -
+ @echo Please use one of the following commands to execute the examples!
+ @echo ------
+ @echo $(MAKE) BookmarkInsertion.run
+ @echo $(MAKE) HardFormatting.run
+ @echo $(MAKE) StyleCreation.run
+ @echo $(MAKE) StyleInitialization.run
+ @echo $(MAKE) SWriter.run
+ @echo $(MAKE) TextDocumentStructure.run
+ @echo $(MAKE) TextReplace.run
+ @echo $(MAKE) WriterSelector.run
+ @echo $(MAKE) GraphicsInserter.run
+ @echo --------
+ @echo The GraphicsInserter needs parameters. Please use the following command to
+ @echo start the demo if you do not want the default parameters specified in the
+ @echo this makefile. Starting without parameters print a command line help:
+ @echo --- GraphicsInserter ---
+ @echo java -jar GraphicsInserter.jar "$(QM)graphic Url|path$(QM)"
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_APP_CLASS)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+GraphicsInserter.run: $(OUT_APP_CLASS)/GraphicsInserter.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< oo_smiley.gif
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_CLASS))
diff --git a/odk/examples/java/Text/SWriter.java b/odk/examples/java/Text/SWriter.java
new file mode 100644
index 000000000000..18ae35481189
--- /dev/null
+++ b/odk/examples/java/Text/SWriter.java
@@ -0,0 +1,397 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+//***************************************************************************
+// comment: Step 1: bootstrap UNO and get the remote component context
+// Step 2: open an empty text document
+// Step 3: enter some text
+// Step 4: insert a text table
+// Step 5: insert colored text
+// Step 6: insert a text frame
+//***************************************************************************
+
+import com.sun.star.uno.UnoRuntime;
+
+public class SWriter {
+
+ public static void main(String args[]) {
+
+
+ //oooooooooooooooooooooooooooStep 1oooooooooooooooooooooooooooooooooooooooo
+ // bootstrap UNO and get the remote component context. The context can
+ // be used to get the service manager
+ //*************************************************************************
+ com.sun.star.uno.XComponentContext xContext = null;
+
+ try {
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ if( xContext != null )
+ System.out.println("Connected to a running office ...");
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+
+ //oooooooooooooooooooooooooooStep 2oooooooooooooooooooooooooooooooooooooooo
+ // open an empty document. In this case it's a writer document.
+ // For this purpose an instance of com.sun.star.frame.Desktop
+ // is created. It's interface XDesktop provides the XComponentLoader,
+ // which is used to open the document via loadComponentFromURL
+ //*************************************************************************
+
+ //Open Writer document
+
+ System.out.println("Opening an empty Writer document");
+ com.sun.star.text.XTextDocument myDoc = openWriter(xContext);
+
+ //*************************************************************************
+
+
+ //oooooooooooooooooooooooooooStep 3oooooooooooooooooooooooooooooooooooooooo
+ // insert some text.
+ // For this purpose get the Text-Object of the document an create the
+ // cursor. Now it is possible to insert a text at the cursor-position
+ // via insertString
+ //*************************************************************************
+
+
+ //getting the text object
+ com.sun.star.text.XText xText = myDoc.getText();
+
+ //create a cursor object
+ com.sun.star.text.XTextCursor xTCursor = xText.createTextCursor();
+
+ //inserting some Text
+ xText.insertString( xTCursor, "The first line in the newly created text document.\n", false );
+
+ //inserting a second line
+ xText.insertString( xTCursor, "Now we're in the second line\n", false );
+
+ //*************************************************************************
+
+
+ //oooooooooooooooooooooooooooStep 4oooooooooooooooooooooooooooooooooooooooo
+ // insert a text table.
+ // For this purpose get MultiServiceFactory of the document, create an
+ // instance of com.sun.star.text.TextTable and initialize it. Now it can
+ // be inserted at the cursor position via insertTextContent.
+ // After that some properties are changed and some data is inserted.
+ //*************************************************************************
+
+ //inserting a text table
+ System.out.println("Inserting a text table");
+
+ //getting MSF of the document
+ com.sun.star.lang.XMultiServiceFactory xDocMSF =
+ (com.sun.star.lang.XMultiServiceFactory) UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, myDoc);
+
+ //create instance of a text table
+ com.sun.star.text.XTextTable xTT = null;
+
+ try {
+ Object oInt = xDocMSF.createInstance("com.sun.star.text.TextTable");
+ xTT = (com.sun.star.text.XTextTable)
+ UnoRuntime.queryInterface(com.sun.star.text.XTextTable.class,oInt);
+ } catch (Exception e) {
+ System.err.println("Couldn't create instance "+ e);
+ e.printStackTrace(System.err);
+ }
+
+ //initialize the text table with 4 columns an 4 rows
+ xTT.initialize(4,4);
+
+ com.sun.star.beans.XPropertySet xTTRowPS = null;
+
+ //insert the table
+ try {
+ xText.insertTextContent(xTCursor, xTT, false);
+ // get first Row
+ com.sun.star.container.XIndexAccess xTTRows = xTT.getRows();
+ xTTRowPS = (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xTTRows.getByIndex(0));
+
+ } catch (Exception e) {
+ System.err.println("Couldn't insert the table " + e);
+ e.printStackTrace(System.err);
+ }
+
+
+ // get the property set of the text table
+
+ com.sun.star.beans.XPropertySet xTTPS = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, xTT);
+
+ // Change the BackColor
+ try {
+ xTTPS.setPropertyValue("BackTransparent", new Boolean(false));
+ xTTPS.setPropertyValue("BackColor",new Integer(13421823));
+ xTTRowPS.setPropertyValue("BackTransparent", new Boolean(false));
+ xTTRowPS.setPropertyValue("BackColor",new Integer(6710932));
+
+ } catch (Exception e) {
+ System.err.println("Couldn't change the color " + e);
+ e.printStackTrace(System.err);
+ }
+
+ // write Text in the Table headers
+ System.out.println("Write text in the table headers");
+
+ insertIntoCell("A1","FirstColumn", xTT);
+ insertIntoCell("B1","SecondColumn", xTT) ;
+ insertIntoCell("C1","ThirdColumn", xTT) ;
+ insertIntoCell("D1","SUM", xTT) ;
+
+
+ //Insert Something in the text table
+ System.out.println("Insert something in the text table");
+
+ (xTT.getCellByName("A2")).setValue(22.5);
+ (xTT.getCellByName("B2")).setValue(5615.3);
+ (xTT.getCellByName("C2")).setValue(-2315.7);
+ (xTT.getCellByName("D2")).setFormula("sum <A2:C2>");
+
+ (xTT.getCellByName("A3")).setValue(21.5);
+ (xTT.getCellByName("B3")).setValue(615.3);
+ (xTT.getCellByName("C3")).setValue(-315.7);
+ (xTT.getCellByName("D3")).setFormula("sum <A3:C3>");
+
+ (xTT.getCellByName("A4")).setValue(121.5);
+ (xTT.getCellByName("B4")).setValue(-615.3);
+ (xTT.getCellByName("C4")).setValue(415.7);
+ (xTT.getCellByName("D4")).setFormula("sum <A4:C4>");
+
+
+ //oooooooooooooooooooooooooooStep 5oooooooooooooooooooooooooooooooooooooooo
+ // insert a colored text.
+ // Get the propertySet of the cursor, change the CharColor and add a
+ // shadow. Then insert the Text via InsertString at the cursor position.
+ //*************************************************************************
+
+ // get the property set of the cursor
+ com.sun.star.beans.XPropertySet xTCPS = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class,
+ xTCursor);
+
+ Object oldValue = null;
+
+ // Change the CharColor and add a Shadow
+ try {
+ xTCPS.setPropertyValue("CharColor",new Integer(255));
+ xTCPS.setPropertyValue("CharShadowed", new Boolean(true));
+ } catch (Exception e) {
+ System.err.println("Couldn't change the color " + e);
+ e.printStackTrace(System.err);
+ }
+
+ //create a paragraph break
+ try {
+ xText.insertControlCharacter(xTCursor,
+ com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false);
+
+ } catch (Exception e) {
+ System.err.println("Couldn't insert break "+ e);
+ e.printStackTrace(System.err);
+ }
+
+ //inserting colored Text
+ System.out.println("Inserting colored Text");
+
+ xText.insertString(xTCursor, " This is a colored Text - blue with shadow\n",
+ false );
+
+ //create a paragraph break
+ try {
+ xText.insertControlCharacter(xTCursor,
+ com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false);
+
+ } catch (Exception e) {
+ System.err.println("Couldn't insert break "+ e);
+ e.printStackTrace(System.err);
+ }
+
+ //oooooooooooooooooooooooooooStep 6oooooooooooooooooooooooooooooooooooooooo
+ // insert a text frame.
+ // create an instance of com.sun.star.text.TextFrame using the MSF of the
+ // document. Change some properties an insert it.
+ // Now get the text-Object of the frame an the corresponding cursor.
+ // Insert some text via insertString.
+ //*************************************************************************
+
+ // Create a TextFrame
+ com.sun.star.text.XTextFrame xTF = null;
+ com.sun.star.drawing.XShape xTFS = null;
+
+ try {
+ Object oInt = xDocMSF.createInstance("com.sun.star.text.TextFrame");
+ xTF = (com.sun.star.text.XTextFrame) UnoRuntime.queryInterface(
+ com.sun.star.text.XTextFrame.class,oInt);
+ xTFS = (com.sun.star.drawing.XShape) UnoRuntime.queryInterface(
+ com.sun.star.drawing.XShape.class,oInt);
+
+ com.sun.star.awt.Size aSize = new com.sun.star.awt.Size();
+ aSize.Height = 400;
+ aSize.Width = 15000;
+
+ xTFS.setSize(aSize);
+ } catch (Exception e) {
+ System.err.println("Couldn't create instance "+ e);
+ e.printStackTrace(System.err);
+ }
+
+ // get the property set of the text frame
+ com.sun.star.beans.XPropertySet xTFPS = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, xTF);
+
+ // Change the AnchorType
+ try {
+ xTFPS.setPropertyValue("AnchorType",
+ com.sun.star.text.TextContentAnchorType.AS_CHARACTER);
+ } catch (Exception e) {
+ System.err.println("Couldn't change the color " + e);
+ e.printStackTrace(System.err);
+ }
+
+ //insert the frame
+ System.out.println("Insert the text frame");
+
+ try {
+ xText.insertTextContent(xTCursor, xTF, false);
+ } catch (Exception e) {
+ System.err.println("Couldn't insert the frame " + e);
+ e.printStackTrace(System.err);
+ }
+
+ //getting the text object of Frame
+ com.sun.star.text.XText xTextF = xTF.getText();
+
+ //create a cursor object
+ com.sun.star.text.XTextCursor xTCF = xTextF.createTextCursor();
+
+ //inserting some Text
+ xTextF.insertString(xTCF,
+ "The first line in the newly created text frame.", false);
+
+
+ xTextF.insertString(xTCF,
+ "\nWith this second line the height of the frame raises.", false);
+
+ //insert a paragraph break
+ try {
+ xText.insertControlCharacter(xTCursor,
+ com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false );
+
+ } catch (Exception e) {
+ System.err.println("Couldn't insert break "+ e);
+ e.printStackTrace(System.err);
+ }
+
+ // Change the CharColor and add a Shadow
+ try {
+ xTCPS.setPropertyValue("CharColor",new Integer(65536));
+ xTCPS.setPropertyValue("CharShadowed", new Boolean(false));
+ } catch (Exception e) {
+ System.err.println("Couldn't change the color " + e);
+ e.printStackTrace(System.err);
+ }
+
+ xText.insertString(xTCursor, " That's all for now !!", false );
+
+ System.out.println("done");
+
+ System.exit(0);
+ }
+
+
+ public static com.sun.star.text.XTextDocument openWriter(
+ com.sun.star.uno.XComponentContext xContext)
+ {
+ //define variables
+ com.sun.star.frame.XComponentLoader xCLoader;
+ com.sun.star.text.XTextDocument xDoc = null;
+ com.sun.star.lang.XComponent xComp = null;
+
+ try {
+ // get the remote office service manager
+ com.sun.star.lang.XMultiComponentFactory xMCF =
+ xContext.getServiceManager();
+
+ Object oDesktop = xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xContext);
+
+ xCLoader = (com.sun.star.frame.XComponentLoader)
+ UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class,
+ oDesktop);
+ com.sun.star.beans.PropertyValue [] szEmptyArgs =
+ new com.sun.star.beans.PropertyValue [0];
+ String strDoc = "private:factory/swriter";
+ xComp = xCLoader.loadComponentFromURL(strDoc, "_blank", 0, szEmptyArgs);
+ xDoc = (com.sun.star.text.XTextDocument)
+ UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class,
+ xComp);
+
+ } catch(Exception e){
+ System.err.println(" Exception " + e);
+ e.printStackTrace(System.err);
+ }
+ return xDoc;
+ }
+
+ public static void insertIntoCell(String CellName, String theText,
+ com.sun.star.text.XTextTable xTTbl) {
+
+ com.sun.star.text.XText xTableText = (com.sun.star.text.XText)
+ UnoRuntime.queryInterface(com.sun.star.text.XText.class,
+ xTTbl.getCellByName(CellName));
+
+ //create a cursor object
+ com.sun.star.text.XTextCursor xTC = xTableText.createTextCursor();
+
+ com.sun.star.beans.XPropertySet xTPS = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, xTC);
+
+ try {
+ xTPS.setPropertyValue("CharColor",new Integer(16777215));
+ } catch (Exception e) {
+ System.err.println(" Exception " + e);
+ e.printStackTrace(System.err);
+ }
+
+ //inserting some Text
+ xTableText.setString( theText );
+
+ }
+}
diff --git a/odk/examples/java/Text/StyleCreation.java b/odk/examples/java/Text/StyleCreation.java
new file mode 100644
index 000000000000..91cfb3f7a8c6
--- /dev/null
+++ b/odk/examples/java/Text/StyleCreation.java
@@ -0,0 +1,226 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+//***************************************************************************
+// comment: Step 1: get the Desktop object from the office
+// Step 2: open an empty text document
+// Step 3: create a new Paragraph style
+// Step 4: apply the Paragraph style
+//
+// Chapter 4.1.3 Defining Your Own Style
+//***************************************************************************
+
+import com.sun.star.uno.UnoRuntime;
+
+
+public class StyleCreation {
+ public static void main(String args[]) {
+ // You need the desktop to create a document
+ // The getDesktop method does the UNO bootstrapping, gets the
+ // remote servie manager and the desktop object.
+ com.sun.star.frame.XDesktop xDesktop = null;
+ xDesktop = getDesktop();
+
+ try {
+ // create text document
+ com.sun.star.text.XTextDocument xTextDocument = null;
+ xTextDocument = createTextdocument(xDesktop);
+
+ // the service '..ParagraphStyle' is context dependend, you need
+ // the multi service factory from the document to use the service
+ com.sun.star.lang.XMultiServiceFactory xDocMSF =
+ (com.sun.star.lang.XMultiServiceFactory)UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, xTextDocument);
+
+ // use the service 'com.sun.star.style.ParagraphStyle'
+ com.sun.star.uno.XInterface xInterface = (com.sun.star.uno.XInterface)
+ xDocMSF.createInstance("com.sun.star.style.ParagraphStyle");
+
+ // create a supplier to get the Style family collection
+ com.sun.star.style.XStyleFamiliesSupplier xSupplier =
+ (com.sun.star.style.XStyleFamiliesSupplier)UnoRuntime.queryInterface(
+ com.sun.star.style.XStyleFamiliesSupplier.class, xTextDocument );
+
+ // get the NameAccess interface from the Style family collection
+ com.sun.star.container.XNameAccess xNameAccess =
+ xSupplier.getStyleFamilies();
+
+ // select the Paragraph styles, you get the Paragraph style collection
+ com.sun.star.container.XNameContainer xParaStyleCollection =
+ (com.sun.star.container.XNameContainer) UnoRuntime.queryInterface(
+ com.sun.star.container.XNameContainer.class,
+ xNameAccess.getByName("ParagraphStyles"));
+
+ // create a PropertySet to set the properties for the new Paragraphstyle
+ com.sun.star.beans.XPropertySet xPropertySet =
+ (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xInterface );
+ System.out.println( "create a PropertySet to set the properties for the new Paragraphstyle" );
+
+ // set some properties from the Paragraph style
+ xPropertySet.setPropertyValue("CharFontName", new String( "Helvetica" ) );
+ System.out.println( "set name of the font to 'Helvetica'" );
+
+ xPropertySet.setPropertyValue("CharHeight", new Float( 36 ) );
+ System.out.println( "Change the height of th font to 36" );
+
+ xPropertySet.setPropertyValue("CharWeight",
+ new Float( com.sun.star.awt.FontWeight.BOLD ) );
+ System.out.println( "set the font attribute 'Bold'" );
+
+ xPropertySet.setPropertyValue("CharAutoKerning", new Boolean( true ) );
+ System.out.println( "set the paragraph attribute 'AutoKerning'" );
+ xPropertySet.setPropertyValue("ParaAdjust",
+ new Integer( com.sun.star.style.ParagraphAdjust.CENTER_value ) );
+ System.out.println( "set the paragraph adjust to LEFT" );
+
+ xPropertySet.setPropertyValue("ParaFirstLineIndent", new Integer( 0 ) );
+ System.out.println( "set the first line indent to 0 cm" );
+
+ xPropertySet.setPropertyValue("BreakType",
+ com.sun.star.style.BreakType.PAGE_AFTER );
+ System.out.println( "set the paragraph attribute Breaktype to PageAfter" );
+
+ // insert the new Paragraph style in the Paragraph style collection
+ xParaStyleCollection.insertByName( "myheading", xPropertySet );
+ System.out.println( "create new paragraph style, with the values from the Propertyset");
+
+ // get the Textrange from the document
+ com.sun.star.text.XTextRange xTextRange =
+ xTextDocument.getText().getStart();
+
+ // get the PropertySet from the current paragraph
+ com.sun.star.beans.XPropertySet xParagraphPropertySet =
+ (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xTextRange );
+ // change the value from the property 'ParaStyle' to apply the
+ // Paragraph style
+ // To run the sample with StarOffice 5.2 you'll have to change
+ // 'ParaStyleName' to 'ParaStyle' in the next line
+ xParagraphPropertySet.setPropertyValue("ParaStyleName",
+ new String( "myheading" ) );
+ System.out.println( "apply the new paragraph style");
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+
+ System.out.println("done");
+
+ System.exit(0);
+ }
+
+
+ public static com.sun.star.frame.XDesktop getDesktop() {
+ com.sun.star.frame.XDesktop xDesktop = null;
+ com.sun.star.lang.XMultiComponentFactory xMCF = null;
+
+ try {
+ com.sun.star.uno.XComponentContext xContext = null;
+
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+
+ // get the remote office service manager
+ xMCF = xContext.getServiceManager();
+ if( xMCF != null ) {
+ System.out.println("Connected to a running office ...");
+
+ Object oDesktop = xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xContext);
+ xDesktop = (com.sun.star.frame.XDesktop) UnoRuntime.queryInterface(
+ com.sun.star.frame.XDesktop.class, oDesktop);
+ }
+ else
+ System.out.println( "Can't create a desktop. No connection, no remote office servicemanager available!" );
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+
+
+ return xDesktop;
+ }
+
+ public static com.sun.star.text.XTextDocument createTextdocument(
+ com.sun.star.frame.XDesktop xDesktop )
+ {
+ com.sun.star.text.XTextDocument aTextDocument = null;
+
+ try {
+ com.sun.star.lang.XComponent xComponent = CreateNewDocument(xDesktop,
+ "swriter");
+ aTextDocument = (com.sun.star.text.XTextDocument)
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xComponent);
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ return aTextDocument;
+ }
+
+
+ protected static com.sun.star.lang.XComponent CreateNewDocument(
+ com.sun.star.frame.XDesktop xDesktop,
+ String sDocumentType )
+ {
+ String sURL = "private:factory/" + sDocumentType;
+
+ com.sun.star.lang.XComponent xComponent = null;
+ com.sun.star.frame.XComponentLoader xComponentLoader = null;
+ com.sun.star.beans.PropertyValue xValues[] =
+ new com.sun.star.beans.PropertyValue[1];
+ com.sun.star.beans.PropertyValue xEmptyArgs[] =
+ new com.sun.star.beans.PropertyValue[0];
+
+ try {
+ xComponentLoader = (com.sun.star.frame.XComponentLoader)
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, xDesktop);
+
+ xComponent = xComponentLoader.loadComponentFromURL(
+ sURL, "_blank", 0, xEmptyArgs);
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ return xComponent ;
+ }
+}
+
diff --git a/odk/examples/java/Text/StyleInitialization.java b/odk/examples/java/Text/StyleInitialization.java
new file mode 100644
index 000000000000..c08243609499
--- /dev/null
+++ b/odk/examples/java/Text/StyleInitialization.java
@@ -0,0 +1,320 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+//***************************************************************************
+// comment: Step 1: get the Desktop object from the office
+// Step 2: open an empty text document
+// Step 3: enter a example text
+// Step 4: use the paragraph collection
+// Step 5: apply a different paragraph style on the paragraphs
+//***************************************************************************
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.AnyConverter;
+
+public class StyleInitialization {
+
+ public static void main(String args[]) {
+ // You need the desktop to create a document
+ // The getDesktop method does the UNO bootstrapping, gets the
+ // remote servie manager and the desktop object.
+ com.sun.star.frame.XDesktop xDesktop = null;
+ xDesktop = getDesktop();
+
+ try {
+ // BEGIN: 'Style basics' Section from the Tutorial
+
+ // create text document
+ com.sun.star.text.XTextDocument xTextDocument = null;
+ xTextDocument = createTextdocument( xDesktop );
+
+ // the text interface contains all methods and properties to
+ // manipulate the content from a text document
+ com.sun.star.text.XText xText = null;
+ xText = xTextDocument.getText();
+
+ String sMyText = "A very short paragraph for illustration only";
+
+ // you can travel with the cursor throught the text document.
+ // you travel only at the model, not at the view. The cursor that you can
+ // see on the document doesn't change the position
+ com.sun.star.text.XTextCursor xTextCursor = null;
+ xTextCursor = (com.sun.star.text.XTextCursor)
+ xTextDocument.getText().createTextCursor();
+
+ com.sun.star.beans.XPropertySet oCPS = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xTextCursor);
+ try {
+ oCPS.setPropertyValue("CharFontName","Helvetica");
+ }
+ catch (Exception ex) {
+
+ }
+
+ xText.insertString( xTextCursor, "Headline", false );
+
+ try {
+ oCPS.setPropertyValue("CharFontName","Times");
+ }
+ catch (Exception ex) {
+
+ }
+ xText.insertControlCharacter(xTextCursor,
+ com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false);
+
+ xText.insertString( xTextCursor, sMyText, false );
+
+ com.sun.star.text.XTextRange xTextRange = null;
+ com.sun.star.beans.XPropertySet xPropertySet = null;
+
+ // the text range not the cursor contains the 'parastyle' property
+ xTextRange = xText.getEnd();
+ xPropertySet = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xTextRange );
+
+ // To run the sample with StarOffice 5.2 you'll have to change
+ // 'ParaStyleName' to 'ParaStyle' in the next line
+ System.out.println( "Current Parastyle : "
+ + xPropertySet.getPropertyValue("ParaStyleName") );
+
+ // END: 'Style basics' Section from the Tutorial
+
+ // There are two way to travel throught the paragraphs, with a
+ // paragraph cursor, or a enumeration.
+ // You find both ways in this example
+
+ // The first way, with the paragraph cursor
+ com.sun.star.text.XParagraphCursor xParagraphCursor = null;
+ xParagraphCursor = (com.sun.star.text.XParagraphCursor)
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XParagraphCursor.class, xTextRange );
+
+ xParagraphCursor.gotoStart( false );
+ xParagraphCursor.gotoEndOfParagraph( true );
+
+ // The second way, with the paragraph enumeration
+ com.sun.star.container.XEnumerationAccess xEnumerationAccess = null;
+ xEnumerationAccess = (com.sun.star.container.XEnumerationAccess)
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XEnumerationAccess.class, xText );
+
+ // the enumeration contains all paragraph form the document
+ com.sun.star.container.XEnumeration xParagraphEnumeration = null;
+ xParagraphEnumeration = xEnumerationAccess.createEnumeration();
+
+ com.sun.star.text.XTextContent xParagraph = null;
+ com.sun.star.text.XTextRange xWord = null;
+
+ com.sun.star.container.XEnumerationAccess xParaEnumerationAccess = null;
+ com.sun.star.container.XEnumeration xPortionEnumeration = null;
+
+ // check if a paragraph is available
+ while ( xParagraphEnumeration.hasMoreElements() ) {
+ // get the next paragraph
+ xParagraph = (com.sun.star.text.XTextContent)
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XTextContent.class,
+ xParagraphEnumeration.nextElement());
+
+ // you need the method getAnchor to a TextRange -> to manipulate
+ // the paragraph
+ String sText = xParagraph.getAnchor().getString();
+
+ // create a cursor from this paragraph
+ com.sun.star.text.XTextCursor xParaCursor = null;
+ xParaCursor = xParagraph.getAnchor().getText().createTextCursor();
+
+ // goto the start and end of the paragraph
+ xParaCursor.gotoStart( false );
+ xParaCursor.gotoEnd( true );
+
+ // The enumeration from the paragraphs contain parts from the
+ // paragraph with a different attributes.
+ xParaEnumerationAccess = (com.sun.star.container.XEnumerationAccess)
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XEnumerationAccess.class, xParagraph);
+ xPortionEnumeration = xParaEnumerationAccess.createEnumeration();
+
+ while ( xPortionEnumeration.hasMoreElements() ) {
+ // output of all parts from the paragraph with different attributes
+ xWord = (com.sun.star.text.XTextRange) UnoRuntime.queryInterface(
+ com.sun.star.text.XTextRange.class,
+ xPortionEnumeration.nextElement());
+ String sWordString = xWord.getString();
+ System.out.println( "Content of the paragraph : " + sWordString );
+ }
+ }
+
+ // BEGIN: 'Finding a suitable style' Section from the Tutorial
+
+ // craete a supplier to get the styles-collection
+ com.sun.star.style.XStyleFamiliesSupplier xSupplier = null;
+ xSupplier = ( com.sun.star.style.XStyleFamiliesSupplier ) UnoRuntime.queryInterface(
+ com.sun.star.style.XStyleFamiliesSupplier.class, xTextDocument );
+
+ // use the name access from the collection
+ com.sun.star.container.XNameAccess xNameAccess = null;
+ xNameAccess = xSupplier.getStyleFamilies();
+
+ com.sun.star.container.XNameContainer xParaStyleCollection = null;
+ xParaStyleCollection = (com.sun.star.container.XNameContainer) UnoRuntime.queryInterface(
+ com.sun.star.container.XNameContainer.class, xNameAccess.getByName( "ParagraphStyles" ));
+
+ // create a array from strings with the name of all paragraph styles from the text document
+ String[] sElementNames = xParaStyleCollection.getElementNames();
+ int iElementCount = sElementNames.length;
+
+ for( int iCounter = 0; iCounter < iElementCount; iCounter++ ) {
+ // specify one paragraph style
+ com.sun.star.style.XStyle xStyle = null;
+ xStyle = (com.sun.star.style.XStyle) UnoRuntime.queryInterface(
+ com.sun.star.style.XStyle.class,
+ xParaStyleCollection.getByName( sElementNames[iCounter] ));
+
+ // create a property set of all properties from the style
+ xPropertySet = (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xStyle );
+
+ AnyConverter aAnyConv = new AnyConverter();
+ String sFontname = aAnyConv.toString(xPropertySet.getPropertyValue("CharFontName"));
+ sFontname = sFontname.toLowerCase();
+
+ // if the style use the font 'Albany', apply it to the current paragraph
+ if( sFontname.compareTo("albany") == 0 ) {
+ // create a property set from the current paragraph, to change the paragraph style
+ xPropertySet = (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xTextRange );
+
+ // To run the sample with StarOffice 5.2 you'll have to change 'ParaStyleName'
+ // to 'ParaStyle' in the next line
+ xPropertySet.setPropertyValue("ParaStyleName", new String( sElementNames[iCounter] ) );
+ System.out.println( "Apply the paragraph style : " + sElementNames[iCounter] );
+ break;
+ }
+ }
+ // END: 'Finding a suitable style' Section from the Tutorial
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+
+ System.out.println("Done");
+
+ System.exit(0);
+
+ }
+
+ public static com.sun.star.frame.XDesktop getDesktop() {
+ com.sun.star.frame.XDesktop xDesktop = null;
+ com.sun.star.lang.XMultiComponentFactory xMCF = null;
+
+ try {
+ com.sun.star.uno.XComponentContext xContext = null;
+
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+
+ // get the remote office service manager
+ xMCF = xContext.getServiceManager();
+ if( xMCF != null ) {
+ System.out.println("Connected to a running office ...");
+
+ Object oDesktop = xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xContext);
+ xDesktop = (com.sun.star.frame.XDesktop) UnoRuntime.queryInterface(
+ com.sun.star.frame.XDesktop.class, oDesktop);
+ }
+ else
+ System.out.println( "Can't create a desktop. No connection, no remote office servicemanager available!" );
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+
+
+ return xDesktop;
+ }
+
+ public static com.sun.star.text.XTextDocument createTextdocument(
+ com.sun.star.frame.XDesktop xDesktop )
+ {
+ com.sun.star.text.XTextDocument aTextDocument = null;
+
+ try {
+ com.sun.star.lang.XComponent xComponent = CreateNewDocument(xDesktop,
+ "swriter");
+ aTextDocument = (com.sun.star.text.XTextDocument)
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xComponent);
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ return aTextDocument;
+ }
+
+
+ protected static com.sun.star.lang.XComponent CreateNewDocument(
+ com.sun.star.frame.XDesktop xDesktop,
+ String sDocumentType )
+ {
+ String sURL = "private:factory/" + sDocumentType;
+
+ com.sun.star.lang.XComponent xComponent = null;
+ com.sun.star.frame.XComponentLoader xComponentLoader = null;
+ com.sun.star.beans.PropertyValue xValues[] =
+ new com.sun.star.beans.PropertyValue[1];
+ com.sun.star.beans.PropertyValue xEmptyArgs[] =
+ new com.sun.star.beans.PropertyValue[0];
+
+ try {
+ xComponentLoader = (com.sun.star.frame.XComponentLoader)
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, xDesktop);
+
+ xComponent = xComponentLoader.loadComponentFromURL(
+ sURL, "_blank", 0, xEmptyArgs);
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ return xComponent ;
+ }
+}
diff --git a/odk/examples/java/Text/TextDocumentStructure.java b/odk/examples/java/Text/TextDocumentStructure.java
new file mode 100644
index 000000000000..f60ce98c937d
--- /dev/null
+++ b/odk/examples/java/Text/TextDocumentStructure.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.
+ *
+ *************************************************************************/
+
+//***************************************************************************
+// comment: Step 1: bootstrap UNO and get the remote component context
+// Step 2: open an empty text document
+// Step 3: create an enumeration of all paragraphs
+// Step 4: create an enumeration of all text portions
+//***************************************************************************
+
+import com.sun.star.uno.UnoRuntime;
+
+public class TextDocumentStructure {
+
+ public static void main(String args[]) {
+ com.sun.star.uno.XComponentContext xContext = null;
+
+ try {
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+
+ // get the rmeote service manger
+ com.sun.star.lang.XMultiComponentFactory xMCF =
+ xContext.getServiceManager();
+
+ // create a new instance of the desktop
+ Object oDesktop = xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", 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 [] szEmptyArgs =
+ new com.sun.star.beans.PropertyValue [0];
+ String strDoc = "private:factory/swriter";
+
+ System.out.println("create new text document");
+
+ com.sun.star.lang.XComponent xComp = xCLoader.loadComponentFromURL(
+ strDoc, "_blank", 0, szEmptyArgs);
+
+ // query the new document for the XTextDocument interface
+ com.sun.star.text.XTextDocument xTextDocument =
+ (com.sun.star.text.XTextDocument)UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xComp);
+
+ // create some example data
+ com.sun.star.text.XText xText = xTextDocument.getText();
+ createExampleData( xText );
+
+ // Begin section 'The structure of text documents' of the Tutorial
+
+ com.sun.star.container.XEnumeration xParagraphEnumeration = null;
+ com.sun.star.container.XEnumerationAccess xParaEnumerationAccess = null;
+ com.sun.star.container.XEnumeration xPortionEnumeration = null;
+ com.sun.star.container.XEnumeration xTextPortionEnum;
+ com.sun.star.text.XTextContent xTextElement = null;
+
+ System.out.println("create an enumeration of all paragraphs");
+ // create an enumeration access of all paragraphs of a document
+ com.sun.star.container.XEnumerationAccess xEnumerationAccess =
+ (com.sun.star.container.XEnumerationAccess)
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XEnumerationAccess.class, xText);
+ xParagraphEnumeration = xEnumerationAccess.createEnumeration();
+
+ // Loop through all paragraphs of the document
+ while ( xParagraphEnumeration.hasMoreElements() ) {
+ xTextElement = (com.sun.star.text.XTextContent)
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XTextContent.class,
+ xParagraphEnumeration.nextElement());
+ com.sun.star.lang.XServiceInfo xServiceInfo =
+ (com.sun.star.lang.XServiceInfo)UnoRuntime.queryInterface(
+ com.sun.star.lang.XServiceInfo.class, xTextElement);
+
+ // check ifs the current paragraph really a paragraph or an
+ // anchor of a frame or picture
+ if( xServiceInfo.supportsService("com.sun.star.text.Paragraph") ) {
+ com.sun.star.text.XTextRange xTextRange =
+ xTextElement.getAnchor();
+ System.out.println( "This is a Paragraph" );
+
+ // create another enumeration to get all text portions of
+ // the paragraph
+ xParaEnumerationAccess =
+ (com.sun.star.container.XEnumerationAccess)
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XEnumerationAccess.class,
+ xTextElement);
+ xTextPortionEnum = xParaEnumerationAccess.createEnumeration();
+
+ while ( xTextPortionEnum.hasMoreElements() ) {
+ com.sun.star.text.XTextRange xTextPortion =
+ (com.sun.star.text.XTextRange)UnoRuntime.queryInterface(
+ com.sun.star.text.XTextRange.class,
+ xTextPortionEnum.nextElement());
+ System.out.println( "Text from the portion : "
+ + xTextPortion.getString() );
+
+ com.sun.star.beans.XPropertySet xPropertySet =
+ (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class,
+ xTextPortion);
+ System.out.println( "Name of the font : "
+ + xPropertySet.getPropertyValue( "CharFontName" ) );
+
+ // PropertyState status of each text portion.
+ com.sun.star.beans.XPropertyState xPropertyState =
+ (com.sun.star.beans.XPropertyState)
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertyState.class,
+ xTextPortion);
+
+ if( xPropertyState.getPropertyState("CharWeight").equals(
+ com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE) )
+ System.out.println( "- The text range contains more than one different attributes" );
+
+ if( xPropertyState.getPropertyState( "CharWeight" ).equals(
+ com.sun.star.beans.PropertyState.DIRECT_VALUE ) )
+ System.out.println( " - The text range contains hard formats" );
+
+ if( xPropertyState.getPropertyState( "CharWeight" ).equals(
+ com.sun.star.beans.PropertyState.DEFAULT_VALUE ) )
+ System.out.println( " - The text range doesn't contains hard formats" );
+ }
+ }
+ else
+ System.out.println( "The text portion isn't a text paragraph" );
+ // End section 'The structure of text documents' of the Tutorial
+ }
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+
+ System.out.println("done");
+ System.exit(0);
+ }
+
+ public static void createExampleData( com.sun.star.text.XText xText ) {
+
+ try {
+ xText.setString( "This is an example sentence" );
+
+ com.sun.star.text.XWordCursor xWordCursor =
+ (com.sun.star.text.XWordCursor)UnoRuntime.queryInterface(
+ com.sun.star.text.XWordCursor.class, xText.getStart());
+
+ xWordCursor.gotoNextWord(false);
+ xWordCursor.gotoNextWord(false);
+ xWordCursor.gotoEndOfWord(true);
+
+ com.sun.star.beans.XPropertySet xPropertySet =
+ (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xWordCursor );
+ xPropertySet.setPropertyValue("CharWeight",
+ new Float( com.sun.star.awt.FontWeight.BOLD ));
+
+ System.out.println("create example data");
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+
+ }
+}
diff --git a/odk/examples/java/Text/TextReplace.java b/odk/examples/java/Text/TextReplace.java
new file mode 100644
index 000000000000..980b955e990f
--- /dev/null
+++ b/odk/examples/java/Text/TextReplace.java
@@ -0,0 +1,231 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+//***************************************************************************
+// comment: Step 1: get the Desktop object from the office
+// Step 2: open an empty text document
+// Step 3: enter a example text
+// Step 4: replace some english spelled words with US spelled
+//***************************************************************************
+
+
+import com.sun.star.uno.UnoRuntime;
+
+public class TextReplace {
+
+ public static void main(String args[]) {
+ // You need the desktop to create a document
+ // The getDesktop method does the UNO bootstrapping, gets the
+ // remote servie manager and the desktop object.
+ com.sun.star.frame.XDesktop xDesktop = null;
+ xDesktop = getDesktop();
+
+ com.sun.star.text.XTextDocument xTextDocument =
+ createTextdocument( xDesktop );
+
+ createExampleData( xTextDocument );
+
+ String mBritishWords[] = {"colour", "neighbour", "centre", "behaviour",
+ "metre", "through" };
+ String mUSWords[] = { "color", "neighbor", "center", "behavior",
+ "meter", "thru" };
+
+ try {
+ com.sun.star.util.XReplaceDescriptor xReplaceDescr = null;
+ com.sun.star.util.XSearchDescriptor xSearchDescriptor = null;
+ com.sun.star.util.XReplaceable xReplaceable = null;
+
+ xReplaceable = (com.sun.star.util.XReplaceable)
+ UnoRuntime.queryInterface(
+ com.sun.star.util.XReplaceable.class, xTextDocument);
+
+ // You need a descriptor to set properies for Replace
+ xReplaceDescr = (com.sun.star.util.XReplaceDescriptor)
+ xReplaceable.createReplaceDescriptor();
+
+ System.out.println("Change all occurrences of ...");
+ for( int iArrayCounter = 0; iArrayCounter < mBritishWords.length;
+ iArrayCounter++ )
+ {
+ System.out.println(mBritishWords[iArrayCounter] +
+ " -> " + mUSWords[iArrayCounter]);
+ // Set the properties the replace method need
+ xReplaceDescr.setSearchString(mBritishWords[iArrayCounter] );
+ xReplaceDescr.setReplaceString(mUSWords[iArrayCounter] );
+
+ // Replace all words
+ xReplaceable.replaceAll( xReplaceDescr );
+ }
+
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ System.out.println("Done");
+
+ System.exit(0);
+
+ }
+
+ protected static void createExampleData(
+ com.sun.star.text.XTextDocument xTextDocument )
+ {
+ // Create textdocument and insert example text
+ com.sun.star.text.XTextCursor xTextCursor = null;
+
+ try {
+ xTextCursor = (com.sun.star.text.XTextCursor)
+ xTextDocument.getText().createTextCursor();
+ com.sun.star.text.XText xText = (com.sun.star.text.XText)
+ xTextDocument.getText();
+
+ xText.insertString( xTextCursor,
+ "He nervously looked all around. Suddenly he saw his ", false );
+
+ xText.insertString( xTextCursor, "neighbour ", true );
+ com.sun.star.beans.XPropertySet xCPS = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xTextCursor);
+ // Set the word blue
+ xCPS.setPropertyValue( "CharColor", new Integer( 255 ) );
+ // Go to last character
+ xTextCursor.gotoEnd(false);
+ xCPS.setPropertyValue( "CharColor", new Integer( 0 ) );
+
+ xText.insertString( xTextCursor, "in the alley. Like lightening he darted off to the left and disappeared between the two warehouses almost falling over the trash can lying in the ", false );
+
+ xText.insertString( xTextCursor, "centre ", true );
+ xCPS = (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xTextCursor);
+ // Set the word blue
+ xCPS.setPropertyValue( "CharColor", new Integer( 255 ) );
+ // Go to last character
+ xTextCursor.gotoEnd(false);
+ xCPS.setPropertyValue( "CharColor", new Integer( 0 ) );
+
+ xText.insertString( xTextCursor, "of the sidewalk.", false );
+
+ xText.insertControlCharacter( xTextCursor,
+ com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false );
+ xText.insertString( xTextCursor, "He tried to nervously tap his way along in the inky darkness and suddenly stiffened: it was a dead-end, he would have to go back the way he had come.", false );
+
+ xTextCursor.gotoStart(false);
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ }
+
+ public static com.sun.star.frame.XDesktop getDesktop() {
+ com.sun.star.frame.XDesktop xDesktop = null;
+ com.sun.star.lang.XMultiComponentFactory xMCF = null;
+
+ try {
+ com.sun.star.uno.XComponentContext xContext = null;
+
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+
+ // get the remote office service manager
+ xMCF = xContext.getServiceManager();
+ if( xMCF != null ) {
+ System.out.println("Connected to a running office ...");
+
+ Object oDesktop = xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xContext);
+ xDesktop = (com.sun.star.frame.XDesktop) UnoRuntime.queryInterface(
+ com.sun.star.frame.XDesktop.class, oDesktop);
+ }
+ else
+ System.out.println( "Can't create a desktop. No connection, no remote office servicemanager available!" );
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+
+
+ return xDesktop;
+ }
+
+ public static com.sun.star.text.XTextDocument createTextdocument(
+ com.sun.star.frame.XDesktop xDesktop )
+ {
+ com.sun.star.text.XTextDocument aTextDocument = null;
+
+ try {
+ com.sun.star.lang.XComponent xComponent = CreateNewDocument(xDesktop,
+ "swriter");
+ aTextDocument = (com.sun.star.text.XTextDocument)
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xComponent);
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ return aTextDocument;
+ }
+
+
+ protected static com.sun.star.lang.XComponent CreateNewDocument(
+ com.sun.star.frame.XDesktop xDesktop,
+ String sDocumentType )
+ {
+ String sURL = "private:factory/" + sDocumentType;
+
+ com.sun.star.lang.XComponent xComponent = null;
+ com.sun.star.frame.XComponentLoader xComponentLoader = null;
+ com.sun.star.beans.PropertyValue xValues[] =
+ new com.sun.star.beans.PropertyValue[1];
+ com.sun.star.beans.PropertyValue xEmptyArgs[] =
+ new com.sun.star.beans.PropertyValue[0];
+
+ try {
+ xComponentLoader = (com.sun.star.frame.XComponentLoader)
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, xDesktop);
+
+ xComponent = xComponentLoader.loadComponentFromURL(
+ sURL, "_blank", 0, xEmptyArgs);
+ }
+ catch( Exception e) {
+ e.printStackTrace(System.err);
+ }
+
+ return xComponent ;
+ }
+}
diff --git a/odk/examples/java/Text/WriterSelector.java b/odk/examples/java/Text/WriterSelector.java
new file mode 100644
index 000000000000..6fd00189d657
--- /dev/null
+++ b/odk/examples/java/Text/WriterSelector.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.uno.UnoRuntime;
+
+/** This class gives you information on the selected objects (text range, text
+ * frame, or graphics) at an OpenOffice.org Server. The Office must be started in
+ * advance and you must have selected something (text, graphics, ...)
+ */
+public class WriterSelector {
+ /**
+ * @param args No arguments.
+ */
+ public static void main(String args[]) {
+ com.sun.star.uno.XComponentContext xContext = null;
+
+ try {
+
+ // bootstrap UNO and get the remote component context. The context can
+ // be used to get the service manager
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+
+ // get the remote office service manager
+ com.sun.star.lang.XMultiComponentFactory xMCF =
+ xContext.getServiceManager();
+
+ // get a new instance of the desktop
+ com.sun.star.frame.XDesktop xDesktop = (com.sun.star.frame.XDesktop)
+ UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class,
+ xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
+ xContext ) );
+
+ 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]);
+ {
+ com.sun.star.text.XTextDocument xDoc =(com.sun.star.text.XTextDocument)
+ UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class,
+ xComponent);
+ xDoc.getText().setString("Please select something in this text and press then \"return\" in the shell where you have started the example.\n");
+
+ // 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);
+
+ 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
+
+ System.out.println("\nPlease select something in the test document and press then \"return\" to continues the example ...");
+ char c = 'X';
+ do{
+ c = (char) System.in.read();
+ }while ((c != 13) && (c != 10));
+
+ // Getting the current frame from the OpenOffice.org Server.
+ com.sun.star.frame.XFrame xframe = xDesktop.getCurrentFrame();
+
+ // Getting the controller.
+ com.sun.star.frame.XController xController = xframe.getController();
+
+ com.sun.star.view.XSelectionSupplier xSelSupplier =
+ (com.sun.star.view.XSelectionSupplier)UnoRuntime.queryInterface(
+ com.sun.star.view.XSelectionSupplier.class, xController );
+
+ Object oSelection = xSelSupplier.getSelection();
+
+ com.sun.star.lang.XServiceInfo xServInfo =
+ (com.sun.star.lang.XServiceInfo)UnoRuntime.queryInterface(
+ com.sun.star.lang.XServiceInfo.class, oSelection );
+
+ if ( xServInfo.supportsService("com.sun.star.text.TextRanges") )
+ {
+ com.sun.star.container.XIndexAccess xIndexAccess =
+ (com.sun.star.container.XIndexAccess)UnoRuntime.queryInterface(
+ com.sun.star.container.XIndexAccess.class, oSelection);
+
+ int count = xIndexAccess.getCount();
+ com.sun.star.text.XTextRange xTextRange = null;
+ for ( int i = 0; i < count; i++ ) {
+ xTextRange = (com.sun.star.text.XTextRange)
+ UnoRuntime.queryInterface(
+ com.sun.star.text.XTextRange.class,
+ xIndexAccess.getByIndex(i));
+
+ System.out.println( "You have selected a text range: \""
+ + xTextRange.getString() + "\"." );
+ }
+ }
+
+ if ( xServInfo.supportsService("com.sun.star.text.TextGraphicObject") )
+ {
+ System.out.println( "You have selected a graphics." );
+ }
+
+ if ( xServInfo.supportsService("com.sun.star.text.TextTableCursor") )
+ {
+ System.out.println( "You have selected a text table." );
+ }
+
+
+ // 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 e ) {
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+}
diff --git a/odk/examples/java/Text/oo_smiley.gif b/odk/examples/java/Text/oo_smiley.gif
new file mode 100644
index 000000000000..f9fc08d5090c
--- /dev/null
+++ b/odk/examples/java/Text/oo_smiley.gif
Binary files differ
diff --git a/odk/examples/java/ToDo/Makefile b/odk/examples/java/ToDo/Makefile
new file mode 100644
index 000000000000..476ff6620dbc
--- /dev/null
+++ b/odk/examples/java/ToDo/Makefile
@@ -0,0 +1,166 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the Java Calc Addin 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=ToDo
+COMP_CLASS_OUT=$(OUT_CLASS)/$(COMP_NAME)
+COMP_GEN_OUT=$(OUT_MISC)/$(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=$(COMP_CLASS_OUT)/$(COMP_JAR_NAME)
+COMP_JAR_MANIFEST=$(COMP_CLASS_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 = XToDo.idl \
+ ToDo.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 = ToDo.java
+COMP_CLASSFILES = $(patsubst %.java,$(COMP_CLASS_OUT)/%.class,$(COMP_JAVAFILES))
+
+GEN_CLASSFILES = $(patsubst %.idl,$(COMP_CLASS_OUT)/$(PACKAGE)/%.class,$(IDLFILES))
+GEN_TYPELIST = $(subst /,.,$(patsubst %.idl,-T$(PACKAGE)/% ,$(IDLFILES)))
+GEN_URDFILES = $(patsubst %.idl,$(COMP_GEN_OUT)/%.urd,$(IDLFILES))
+
+
+$(COMP_NAME)_CLASSFILES = $(COMP_NAME).class \
+ $(COMP_NAME)$(QUOTE)$$$(COMP_NAME)Impl.class
+
+$(COMP_NAME)_CLASSFILES += $(subst $(COMP_CLASS_OUT)/,,$(GEN_CLASSFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(COMP_CLASS_OUT))
+
+
+# Targets
+.PHONY: ALL
+ALL : JavaToDoExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(COMP_CLASS_OUT)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo UNO-Type-Path: $(basename $*).uno.jar> $@
+ @echo RegistrationClassName: $(basename $(basename $(@F)))>> $@
+
+$(COMP_GEN_OUT)/%.urd : %.idl
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(IDLC) -C -I. -I$(IDL_DIR) -O$(COMP_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$(COMP_CLASS_OUT) $(COMP_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES)
+
+$(COMP_CLASSFILES) : $(COMP_JAVAFILES) $(GEN_CLASSFILES)
+ -$(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_JAR_MANIFEST) $(COMP_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(COMP_CLASS_OUT)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
+
+# 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 $(OUT_MISC)/,,$(@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_MISC)/,,$(@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),$(COMP_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
+
+JavaToDoExample : $(COMP_REGISTERFLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The $(COMP_NAME) Java component was installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo Please load the "$(QM)ToDo.ods$(QM)" document to see how this component works, see
+ @echo the example description.
+ @echo -
+ @echo $(MAKE) ToDo.ods.load
+ @echo --------------------------------------------------------------------------------
+
+ToDo.ods.load : $(COMP_REGISTERFLAG)
+ "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(COMP_CLASS_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(COMP_GEN_OUT))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
diff --git a/odk/examples/java/ToDo/ToDo.idl b/odk/examples/java/ToDo/ToDo.idl
new file mode 100644
index 000000000000..3aa45ccf4448
--- /dev/null
+++ b/odk/examples/java/ToDo/ToDo.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 INCLUDED_ORG_OPENOFFICE_TODO_IDL
+#define INCLUDED_ORG_OPENOFFICE_TODO_IDL
+
+#include <XToDo.idl>
+
+/// org
+module org {
+ /// openoffice
+ module openoffice {
+
+ /// example service
+ service ToDo: XToDo;
+ };
+};
+
+#endif
diff --git a/odk/examples/java/ToDo/ToDo.java b/odk/examples/java/ToDo/ToDo.java
new file mode 100644
index 000000000000..87257c406903
--- /dev/null
+++ b/odk/examples/java/ToDo/ToDo.java
@@ -0,0 +1,965 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (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.XInitialization;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XSingleComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.XWeak;
+import com.sun.star.uno.XComponentContext;
+import org.openoffice.*;
+
+// addintional interfaces used by the implementation
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XCellRangeMovement;
+import com.sun.star.sheet.XFunctionAccess;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.table.XCellRange;
+import com.sun.star.table.XCell;
+import com.sun.star.table.CellAddress;
+import com.sun.star.table.CellRangeAddress;
+import com.sun.star.table.XColumnRowRange;
+import com.sun.star.table.XTableRows;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.text.XTextRange;
+import com.sun.star.text.XSimpleText;
+import com.sun.star.text.XTextCursor;
+import com.sun.star.text.XText;
+import com.sun.star.text.XTextField;
+
+import java.util.GregorianCalendar;
+import java.util.Calendar;
+import java.util.Vector;
+import java.util.Arrays;
+
+/** This class capsulates the class, that implements the minimal component, a
+ * factory for creating the service (<CODE>__getServiceFactory</CODE>) and a
+ * method, that writes the information into the given registry key
+ * (<CODE>__writeRegistryServiceInfo</CODE>).
+ */
+public class ToDo {
+
+ /** This class implements the component. At least the interfaces
+ * XInterface, XTypeProvider, and XWeak implemented by the helper class
+ * WeakBase and XServiceInfo should be provided by the service.
+ */
+ public static class ToDoImpl extends WeakBase implements XServiceInfo, XToDo {
+
+ /** The service name, that must be used to get an instance of this service.
+ */
+ private static final String __serviceName = "org.openoffice.ToDo";
+
+ /** 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;
+
+ // Implementation helper variables
+ static private final int INT_COLUMN_FEATURE = 0;
+ static private final int INT_COLUMN_COMMENT = 1;
+ static private final int INT_COLUMN_NEEDEDDAYS = 2;
+ static private final int INT_COLUMN_STARTDATE = 3;
+ static private final int INT_COLUMN_START_DAY_OF_WEEK = 4;
+ static private final int INT_COLUMN_ENDDATE = 5;
+ static private final int INT_COLUMN_END_DAY_OF_WEEK = 6;
+ static private final int INT_COLUMN_DUEDATE = 7;
+ static private final int INT_COLUMN_STATUS = 8;
+
+ static private final int INT_ROW_FROM = 14; // 8
+
+ static private final int INT_ROW_HOLIDAYS_START = 4;
+ static private final int INT_COLUMN_HOLIDAYS_START = 7; // 10
+
+ static private final String STRING_SEPARATOR = "/";
+
+
+ /** The constructor of the inner class has a XComponenContext parameter.
+ * @param xCompContext the initial component context
+ */
+ public ToDoImpl(XComponentContext xCompContext) {
+ try {
+ m_cmpCtx = xCompContext;
+ m_xMCF = m_cmpCtx.getServiceManager();
+ }
+ catch( Exception e ) {
+ e.printStackTrace(System.err);
+ }
+ }
+
+ /** 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() {
+ String[] sSupportedServiceNames = { __serviceName };
+ return sSupportedServiceNames;
+ }
+
+ /** This method returns true, if the given service will be
+ * supported by the component.
+ * @param sService 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 ToDoImpl.class.getName();
+ }
+
+ /** For every bug/feature listed in a spreadsheet document this method
+ * calculates the start date, day of week of the start date, the end date
+ * and the day of week of the end date. All calculations are dependent
+ * on the values of "Needed Days", "Due Date" and "Status". The columns
+ * "Needed Days" and "Status" are mandatory. The first feature/bug should
+ * be placed in row nine. The date to start the calculation should be
+ * placed in cell C6. The private holidays should be placed in cell K4/K5
+ * and below. All rows will be calculated up to the first empty cell in
+ * the first column. If a cell in the column "Due Date" will be colored
+ * red, you should take a look at your entries.
+ * @param aInstance Spreadsheet document.
+ * @throws com.sun.star.uno.RuntimeException This exception could occur
+ * at every interface method.
+ */
+ public void recalc( java.lang.Object aInstance )
+ throws com.sun.star.uno.RuntimeException {
+ try {
+ // Querying for the interface XSpreadsheetDocument
+ XSpreadsheetDocument xspreadsheetdocument =
+ ( XSpreadsheetDocument ) UnoRuntime.queryInterface(
+ XSpreadsheetDocument.class, aInstance );
+
+ // Querying for the interface XIndexAccess
+ XIndexAccess xindexaccess = ( XIndexAccess )
+ UnoRuntime.queryInterface( XIndexAccess.class,
+ xspreadsheetdocument.getSheets() );
+
+ // Getting the first XSpreadsheet
+ XSpreadsheet xspreadsheet = (XSpreadsheet)UnoRuntime.queryInterface(
+ XSpreadsheet.class, xindexaccess.getByIndex( 0 ));
+
+ // Querying for the interface XCellRange on the XSpeadsheet
+ XCellRange xcellrange = ( XCellRange )
+ UnoRuntime.queryInterface( XCellRange.class, xspreadsheet );
+
+ /* Getting the gregorian calendar with the date on which to start
+ the calculation */
+ GregorianCalendar gregCalAbsoluteStartDate =
+ this.getGregorianCalendarFromString(this.getStringFromCell(
+ xcellrange, 5, 2 ) );
+ gregCalAbsoluteStartDate.add( Calendar.DATE, -1 );
+
+ // Set the start date with the absolute start date
+ GregorianCalendar gregCalStartDate =
+ (GregorianCalendar) gregCalAbsoluteStartDate.clone();
+
+ /* Creating the service FunctionAccess, which allows generic
+ access to all spreadsheet functions */
+ Object objectFunctionAccess =
+ m_xMCF.createInstanceWithContext(
+ "com.sun.star.sheet.FunctionAccess", m_cmpCtx );
+
+ // Querying for the interface XFunctionAccess on service
+ // FunctionAccess
+ XFunctionAccess xfunctionaccess = (XFunctionAccess)
+ UnoRuntime.queryInterface(XFunctionAccess.class,
+ objectFunctionAccess );
+
+ // Creating vector for holidays
+ Vector vectorHolidays = new Vector();
+
+ // Get the Official Holidays
+ this.getOfficialHolidays( vectorHolidays, xcellrange,
+ xfunctionaccess,
+ gregCalStartDate.get(
+ Calendar.YEAR ) );
+
+ // Get the private holidays
+ this.getPrivateHolidays(vectorHolidays, xcellrange,
+ xfunctionaccess);
+
+ // Getting the object array of holidays
+ Object[] objectSortedHolidays = vectorHolidays.toArray();
+
+ // Sorting the holidays
+ Arrays.sort( objectSortedHolidays );
+
+ // Collect the Official Holidays and the private holidays
+ Object [][]objectHolidays =
+ new Object[][] { objectSortedHolidays };
+
+ // Row index
+ int intRowTo = this.INT_ROW_FROM - 1;
+
+ // Getting the feature of the first cell
+ String sFeature = this.getStringFromCell(xcellrange,
+ intRowTo + 1,
+ this.INT_COLUMN_FEATURE);
+
+ // Determine the last row with an entry in the first column
+ while ( ( sFeature != null ) &&
+ ( !sFeature.equals( "" ) ) ) {
+ intRowTo++;
+ sFeature = this.getStringFromCell( xcellrange,
+ intRowTo + 1, this.INT_COLUMN_FEATURE );
+ }
+
+ // Setting the last row to be calculated
+ final int INT_ROW_TO = intRowTo + 1;
+
+ // Deleting cells which will be recalculated
+ for ( int intRow = this.INT_ROW_FROM; intRow < INT_ROW_TO + 5;
+ intRow++ ) {
+ for ( int intColumn = this.INT_COLUMN_STARTDATE;
+ intColumn <= this.INT_COLUMN_END_DAY_OF_WEEK;
+ intColumn++ ) {
+ this.setStringToCell(xcellrange, intRow, intColumn, "");
+ }
+ }
+
+ /* Clearing the background color of the due date cells and setting
+ the hyperlink to the bugtracker */
+ for (int intRow = this.INT_ROW_FROM; intRow < INT_ROW_TO; intRow++)
+ {
+ // Querying for the interface XPropertySet for the cell
+ // providing the due date
+ XPropertySet xpropertyset = ( XPropertySet )
+ UnoRuntime.queryInterface(XPropertySet.class,
+ xcellrange.getCellByPosition(
+ this.INT_COLUMN_DUEDATE,
+ intRow ));
+
+ // Changing the background color of the cell to white
+ xpropertyset.setPropertyValue( "CellBackColor",
+ new Integer( 16777215 ) );
+
+ // Getting the cell of the bug id
+ XCell xcell = xcellrange.getCellByPosition(
+ this.INT_COLUMN_FEATURE, intRow );
+
+ // Querying for the interface XSimpleText
+ XSimpleText xsimpletext = ( XSimpleText )
+ UnoRuntime.queryInterface( XSimpleText.class, xcell );
+
+ // Getting the text cursor
+ XTextCursor xtextcursor = xsimpletext.createTextCursor();
+
+ // Querying for the interface XTextRange
+ XTextRange xtextrange = ( XTextRange )
+ UnoRuntime.queryInterface( XTextRange.class, xtextcursor );
+
+ // Getting the bug ID from the cell
+ String sBugID = xtextrange.getString();
+ if ( !sBugID.startsWith(
+ "http://www.openoffice.org/issues/show_bug.cgi?id=") ) {
+ String sBugIDLink =
+ "http://www.openoffice.org/issues/show_bug.cgi?id=" + sBugID;
+
+ // Querying for the interface XMultiServiceFactory
+ XMultiServiceFactory xMSFTextField =
+ (XMultiServiceFactory)UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, aInstance );
+
+ // Creating an instance of the text field URL
+ Object objectTextField =
+ xMSFTextField.createInstance(
+ "com.sun.star.text.TextField.URL" );
+
+ // Querying for the interface XTextField
+ XTextField xtextfield = ( XTextField )
+ UnoRuntime.queryInterface( XTextField.class,
+ objectTextField );
+
+ // Querying for the interface XPropertySet
+ XPropertySet xpropertysetTextField = ( XPropertySet )
+ UnoRuntime.queryInterface( XPropertySet.class,
+ xtextfield );
+
+ // Setting the URL
+ xpropertysetTextField.setPropertyValue( "URL",
+ sBugIDLink );
+
+ // Setting the representation of the URL
+ xpropertysetTextField.setPropertyValue( "Representation",
+ sBugID );
+
+ // Querying for the interface XText
+ XText xtext = ( XText )UnoRuntime.queryInterface(
+ XText.class, xcell );
+
+ // Delete cell content
+ xtextrange.setString( "" );
+
+ // Inserting the text field URL to the cell
+ xtext.insertTextContent( xtextrange, xtextfield, false );
+ }
+ }
+
+ // Processing all features/bugs in the table
+ for (int intRow = this.INT_ROW_FROM; intRow < INT_ROW_TO; intRow++)
+ {
+ // Getting the cell of the column "Needed Days" in the
+ // current row
+ XCell xcell = xcellrange.getCellByPosition(
+ INT_COLUMN_NEEDEDDAYS, intRow );
+
+ // Getting the number of needed days to perform the feature
+ int intNeededDays = (int) Math.round( xcell.getValue() );
+
+ // Getting the content of a specified cell
+ String sStatus = this.getStringFromCell( xcellrange,
+ intRow, this.INT_COLUMN_STATUS );
+
+ /* Testing if the number of needed days is greater than
+ zero and if
+ the status is not "done" */
+ if ( ( intNeededDays > 0 )
+ && !( sStatus.toLowerCase().trim().equals("done")) ) {
+ // Getting the start date after a specified number of
+ // workdays
+ gregCalStartDate = this.getWorkday(
+ gregCalStartDate, 1, objectHolidays,
+ xfunctionaccess );
+
+ // Getting a string with the date format jjjj-mm-dd from
+ // the gregorian calendar
+ String sDate = this.getStringFromGregorianCalendar(
+ gregCalStartDate );
+
+ // Set the start date in the specified cell of the table
+ this.setStringToCell(xcellrange, intRow,
+ this.INT_COLUMN_STARTDATE, sDate);
+
+ // For the start day set the day of week in the specified
+ // cell of the table
+ this.setDayOfWeek( gregCalStartDate,
+ xcellrange, intRow,
+ this.INT_COLUMN_START_DAY_OF_WEEK );
+
+ // Getting the end date after a specified number of workdays
+ GregorianCalendar gregCalEndDate =
+ this.getWorkday( gregCalStartDate,
+ intNeededDays - 1,
+ objectHolidays, xfunctionaccess );
+
+ // Creating a string with the date format jjjj-mm-dd
+ sDate = this.getStringFromGregorianCalendar(
+ gregCalEndDate );
+
+ // Set the end date in the specified cell of the table
+ this.setStringToCell( xcellrange, intRow,
+ this.INT_COLUMN_ENDDATE, sDate );
+
+ // For the end day set the day of week in the specified
+ // cell of the table
+ this.setDayOfWeek(gregCalEndDate, xcellrange,
+ intRow, this.INT_COLUMN_END_DAY_OF_WEEK);
+
+ // Set the initial date for the next loop
+ gregCalStartDate = ( GregorianCalendar )
+ gregCalEndDate.clone();
+
+ // Get the due date from the table
+ String sDueDate = this.getStringFromCell(
+ xcellrange, intRow, this.INT_COLUMN_DUEDATE );
+
+ // Testing if the due date is not empty
+ if ( !sDueDate.equals( "" ) ) {
+ GregorianCalendar gregCalDueDate =
+ this.getGregorianCalendarFromString(sDueDate);
+
+ // Testing if the due date is before the calculated
+ // end date
+ if ( gregCalDueDate.before(
+ gregCalEndDate ) ) {
+ /* Getting the date when the processing of the
+ feature/bug should
+ be started at the latest */
+ GregorianCalendar gregCalLatestDateToStart =
+ this.getWorkday(gregCalDueDate,
+ -( intNeededDays - 1 ),
+ objectHolidays,
+ xfunctionaccess);
+
+ // Begin with the current row
+ int intRowToInsert = intRow;
+
+ // Get the start date for the feature/bug in the
+ // current row
+ GregorianCalendar gregCalPreviousStartDate =
+ this.getGregorianCalendarFromString(
+ this.getStringFromCell(
+ xcellrange, intRowToInsert,
+ this.INT_COLUMN_STARTDATE ) );
+
+ // Testing if we have to search for an earlier date
+ // to begin
+ while ((gregCalLatestDateToStart.before(
+ gregCalPreviousStartDate)) &&
+ (INT_ROW_FROM != intRowToInsert)) {
+ // Decrease the row
+ intRowToInsert--;
+
+ // Get the start date for the feature/bug in
+ // the current row
+ String sStartDate = this.getStringFromCell(
+ xcellrange, intRowToInsert,
+ this.INT_COLUMN_STARTDATE );
+
+ // Search until a valid start date is found
+ while ( sStartDate.equals( "" ) ) {
+ // Decrease the row
+ intRowToInsert--;
+
+ // Get the start date for the feature/bug
+ // in the current row
+ sStartDate = this.getStringFromCell(
+ xcellrange, intRowToInsert,
+ this.INT_COLUMN_STARTDATE );
+ }
+
+ // Get the GregorianCalender format for the
+ // start date
+ gregCalPreviousStartDate =
+ this.getGregorianCalendarFromString(
+ sStartDate );
+ }
+
+ // Getting the cell of the column "Needed Days"
+ // in the row where to insert
+ XCell xcellNeededDaysWhereToInsert =
+ xcellrange.getCellByPosition(
+ INT_COLUMN_NEEDEDDAYS, intRowToInsert );
+ // Getting the number of needed days to perform
+ // the feature
+ int intNeededDaysWhereToInsert = (int)
+ Math.round(
+ xcellNeededDaysWhereToInsert.getValue());
+
+ GregorianCalendar gregCalPreviousNewEndDate =
+ this.getWorkday(gregCalPreviousStartDate,
+ intNeededDays - 1 +
+ intNeededDaysWhereToInsert,
+ objectHolidays,
+ xfunctionaccess);
+ String sPreviousDueDate = this.getStringFromCell(
+ xcellrange, intRowToInsert,
+ this.INT_COLUMN_DUEDATE );
+
+ GregorianCalendar gregCalPreviousDueDate = null;
+
+ if ( !sPreviousDueDate.equals( "" ) ) {
+ gregCalPreviousDueDate =
+ this.getGregorianCalendarFromString(
+ sPreviousDueDate );
+ }
+
+ if ( ( intRowToInsert == intRow ) ||
+ ( gregCalPreviousNewEndDate.after(
+ gregCalPreviousDueDate ) ) ) {
+ // Querying for the interface XPropertySet for
+ // the cell providing the due date
+ XPropertySet xpropertyset = ( XPropertySet )
+ UnoRuntime.queryInterface(
+ XPropertySet.class,
+ xcellrange.getCellByPosition(
+ this.INT_COLUMN_DUEDATE,
+ intRow ) );
+
+ // Changing the background color of the cell
+ // to red
+ xpropertyset.setPropertyValue(
+ "CellBackColor", new Integer( 16711680 ) );
+ } else {
+ // Querying for the interface XColumnRowRange
+ // on the XCellRange
+ XColumnRowRange xcolumnrowrange =
+ ( XColumnRowRange)UnoRuntime.queryInterface(
+ XColumnRowRange.class, xcellrange );
+ // Inserting one row to the table
+ XTableRows xTableRows =
+ xcolumnrowrange.getRows();
+ xTableRows.insertByIndex( intRowToInsert, 1 );
+
+ // Querying for the interface
+ // XCellRangeMovement on XCellRange
+ XCellRangeMovement xcellrangemovement =
+ (XCellRangeMovement)UnoRuntime.queryInterface(
+ XCellRangeMovement.class, xcellrange );
+
+ // Creating the cell address of the destination
+ CellAddress celladdress = new CellAddress();
+ celladdress.Sheet = 0;
+ celladdress.Column = 0;
+ celladdress.Row = intRowToInsert;
+
+ // Creating the cell range of the source
+ CellRangeAddress cellrangeaddress =
+ new CellRangeAddress();
+ cellrangeaddress.Sheet = 0;
+ cellrangeaddress.StartColumn = 0;
+ cellrangeaddress.StartRow = intRow + 1;
+ cellrangeaddress.EndColumn = 8;
+ cellrangeaddress.EndRow = intRow + 1;
+
+ // Moves the cell range to another position in
+ // the document
+ xcellrangemovement.moveRange(celladdress,
+ cellrangeaddress);
+
+ // Removing the row not needed anymore
+ xcolumnrowrange.getRows().removeByIndex(intRow
+ + 1, 1);
+
+ // Set the current row, because we want to
+ // recalculate all rows below
+ intRow = intRowToInsert - 1;
+
+ // Tests at which line we want to insert
+ if ( intRow >= this.INT_ROW_FROM ) {
+ // Get the start date
+ gregCalStartDate =
+ this.getGregorianCalendarFromString(
+ this.getStringFromCell( xcellrange,
+ intRow,this.INT_COLUMN_ENDDATE));
+ }
+ else {
+ // Set the start date with the absolute s
+ // tart date
+ gregCalStartDate = (GregorianCalendar)
+ gregCalAbsoluteStartDate.clone();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ catch( Exception exception ) {
+ showExceptionMessage( exception );
+ }
+ }
+
+ /** Getting a string from a gregorian calendar.
+ * @param gregCal Date to be converted.
+ * @return string (converted gregorian calendar).
+ */
+ public String getStringFromGregorianCalendar( GregorianCalendar gregCal ) {
+ String sDate = ( gregCal.get( Calendar.MONTH ) + 1 )
+ + STRING_SEPARATOR + gregCal.get( Calendar.DATE )
+// + STRING_SEPARATOR + ( gregCal.get( Calendar.MONTH ) + 1 )
+ + STRING_SEPARATOR + gregCal.get( Calendar.YEAR );
+
+ return sDate;
+ }
+
+ /** Getting a GregorianCalendar from a string.
+ * @param sDate String to be converted.
+ * @return The result of the converting of the string.
+ */
+ public GregorianCalendar getGregorianCalendarFromString( String sDate ) {
+ int []intDateValue = this.getDateValuesFromString( sDate );
+
+ return( new GregorianCalendar( intDateValue[ 2 ], intDateValue[ 0 ],
+ intDateValue[ 1 ] ) );
+ }
+
+ /** Getting the day, month and year from a string.
+ * @param sDate String to be parsed.
+ * @return Returns an array of integer variables.
+ */
+ public int[] getDateValuesFromString( String sDate) {
+ int[] intDateValues = new int[ 3 ];
+
+ int intPositionFirstTag = sDate.indexOf( STRING_SEPARATOR );
+ int intPositionSecondTag = sDate.indexOf(STRING_SEPARATOR,
+ intPositionFirstTag + 1);
+
+ // Getting the value of the month
+ intDateValues[ 0 ] = Integer.parseInt(
+ sDate.substring(0, intPositionFirstTag)) - 1;
+ // Getting the value of the day
+ intDateValues[ 1 ] = Integer.parseInt(
+ sDate.substring(intPositionFirstTag + 1, intPositionSecondTag));
+ // Getting the value of the year
+ intDateValues[ 2 ] = Integer.parseInt(
+ sDate.substring(intPositionSecondTag + 1, sDate.length()));
+
+ return intDateValues;
+ }
+
+ /** Getting a content from a specified cell.
+ * @param xcellrange Providing access to cells.
+ * @param intRow Number of row.
+ * @param intColumn Number of column.
+ * @return String from the specified cell.
+ */
+ public String getStringFromCell( XCellRange xcellrange, int intRow,
+ int intColumn ) {
+ XTextRange xtextrangeStartDate = null;
+
+ try {
+ // Getting the cell holding the information about the start date
+ XCell xcellStartDate = xcellrange.getCellByPosition(intColumn,
+ intRow);
+ // Querying for the interface XTextRange on the XCell
+ xtextrangeStartDate = (XTextRange)
+ UnoRuntime.queryInterface(XTextRange.class, xcellStartDate);
+ }
+ catch( Exception exception ) {
+ this.showExceptionMessage( exception );
+ }
+
+ // Getting the start date
+ return xtextrangeStartDate.getString().trim();
+ }
+
+ /** Writing a specified string to a specified cell.
+ * @param xcellrange Providing access to the cells.
+ * @param intRow Number of row.
+ * @param intColumn Number of column.
+ * @param sDate Date to write to the cell.
+ */
+ public void setStringToCell( XCellRange xcellrange, int intRow,
+ int intColumn, String sDate ) {
+ try {
+ // Getting the cell holding the information on the day to start
+ XCell xcellStartDate = xcellrange.getCellByPosition(intColumn,
+ intRow);
+ // Querying for the interface XTextRange on the XCell
+ XTextRange xtextrange = (XTextRange)
+ UnoRuntime.queryInterface(XTextRange.class, xcellStartDate);
+ // Setting the new start date
+ xtextrange.setString( sDate );
+ }
+ catch( Exception exception ) {
+ this.showExceptionMessage( exception );
+ }
+ }
+
+ /** Calculates the week of day and calls the method "setStringToCell".
+ * @param gregCal Day to be written to the cell.
+ * @param xcellrange Providing access to the cells.
+ * @param intRow Number of row.
+ * @param intColumn Number of column.
+ */
+ public void setDayOfWeek( GregorianCalendar gregCal,
+ XCellRange xcellrange, int intRow,
+ int intColumn) {
+ int intDayOfWeek = gregCal.get( Calendar.DAY_OF_WEEK );
+ String sDayOfWeek = "";
+ if ( intDayOfWeek == Calendar.MONDAY ) {
+ sDayOfWeek = "MON";
+ } else if ( intDayOfWeek == Calendar.TUESDAY ) {
+ sDayOfWeek = "TUE";
+ } else if ( intDayOfWeek == Calendar.WEDNESDAY ) {
+ sDayOfWeek = "WED";
+ } else if ( intDayOfWeek == Calendar.THURSDAY ) {
+ sDayOfWeek = "THU";
+ } else if ( intDayOfWeek == Calendar.FRIDAY ) {
+ sDayOfWeek = "FRI";
+ }
+
+ this.setStringToCell( xcellrange, intRow, intColumn,
+ sDayOfWeek );
+ }
+
+ /** Calculates the dates of the official holidays with help of Calc
+ * functions.
+ * @param vectorHolidays Holding all holidays.
+ * @param xcellrange Providing the cells.
+ * @param xfunctionaccess Provides access to functions of the Calc.
+ * @param intYear Year to calculate the official holidays.
+ */
+ public void getOfficialHolidays(
+ Vector vectorHolidays,
+ XCellRange xcellrange,
+ XFunctionAccess xfunctionaccess,
+ int intYear ) {
+ try {
+ // Official Holidays for how many years?
+ final int intHowManyYears = 2;
+
+ // Get the Official Holiday for two years
+ for ( int intNumberOfYear = 0;
+ intNumberOfYear <= ( intHowManyYears - 1 );
+ intNumberOfYear++ ) {
+ intYear += intNumberOfYear;
+
+ // Getting the Easter sunday
+ Double dEasterSunday = ( Double )
+ xfunctionaccess.callFunction(
+ "EASTERSUNDAY", new Object[] { new Integer(intYear) });
+
+ int intEasterSunday = (int)Math.round(
+ dEasterSunday.doubleValue());
+
+ // New-year
+ vectorHolidays.addElement( xfunctionaccess.callFunction(
+ "DATE",
+ new Object[] {
+ new Integer( intYear ),
+ new Integer( 1 ),
+ new Integer( 1 ) } ));
+
+ // Good Friday
+ vectorHolidays.addElement(
+ new Double( intEasterSunday - 2 ) );
+
+ // Easter monday
+ vectorHolidays.addElement(
+ new Double( intEasterSunday + 1 ) );
+
+ // Labour Day
+ vectorHolidays.addElement( xfunctionaccess.callFunction(
+ "DATE",
+ new Object[] {
+ new Integer( intYear ),
+ new Integer( 5 ),
+ new Integer( 1 ) } ));
+
+ // Ascension Day
+ vectorHolidays.addElement(new Double(intEasterSunday + 39 ));
+
+ // Pentecost monday
+ vectorHolidays.addElement(new Double(intEasterSunday + 50 ));
+
+ // German Unification
+ vectorHolidays.addElement( xfunctionaccess.callFunction(
+ "DATE",
+ new Object[] {
+ new Integer( intYear ),
+ new Integer( 10 ),
+ new Integer( 3 ) } ));
+
+ // Christmas Day First
+ vectorHolidays.addElement( xfunctionaccess.callFunction(
+ "DATE",
+ new Object[] {
+ new Integer( intYear ),
+ new Integer( 12 ),
+ new Integer( 25 ) } ));
+
+ // Christmas Day Second
+ vectorHolidays.addElement( xfunctionaccess.callFunction(
+ "DATE",
+ new Object[] {
+ new Integer( intYear ),
+ new Integer( 12 ),
+ new Integer( 26 ) } ));
+ }
+ }
+ catch( Exception exception ) {
+ this.showExceptionMessage( exception );
+ }
+ }
+
+ /** Returns the serial number of the date before or after a specified
+ * number of workdays.
+ * @param gregCalStartDate Date to start with the calculation.
+ * @param intDays Number of workdays (e.g. 5 or -3).
+ * @param objectHolidays Private and public holidays to take into account.
+ * @param xfunctionaccess Allows to call functions from the Calc.
+ * @return The gregorian date before or after a specified number of
+ * workdays.
+ */
+ public GregorianCalendar getWorkday(
+ GregorianCalendar gregCalStartDate,
+ int intDays, Object[][] objectHolidays,
+ XFunctionAccess xfunctionaccess ) {
+ GregorianCalendar gregCalWorkday = null;
+
+ try {
+ // Getting the value of the start date
+ Double dDate = ( Double ) xfunctionaccess.callFunction(
+ "DATE",
+ new Object[] {
+ new Integer( gregCalStartDate.get( Calendar.YEAR ) ),
+ new Integer( gregCalStartDate.get( Calendar.MONTH ) + 1 ),
+ new Integer( gregCalStartDate.get( Calendar.DATE ) )
+ } );
+
+ Double dWorkday = ( Double ) xfunctionaccess.callFunction(
+ "com.sun.star.sheet.addin.Analysis.getWorkday",
+ new Object[] { dDate, new Integer( intDays ), objectHolidays } );
+
+ Double dYear = ( Double ) xfunctionaccess.callFunction(
+ "YEAR", new Object[] { dWorkday } );
+ Double dMonth = ( Double ) xfunctionaccess.callFunction(
+ "MONTH", new Object[] { dWorkday } );
+ Double dDay = ( Double ) xfunctionaccess.callFunction(
+ "DAY", new Object[] { dWorkday } );
+
+ gregCalWorkday = new GregorianCalendar(
+ dYear.intValue(),
+ dMonth.intValue() - 1,
+ dDay.intValue() );
+ }
+ catch( Exception exception ) {
+ this.showExceptionMessage( exception );
+ }
+
+ return gregCalWorkday;
+ }
+
+ /** Getting the holidays from the spreadsheet.
+ * @param vectorHolidays Holding all holidays.
+ * @param xcellrange Providing the cells.
+ * @param xfunctionaccess Provides the access to functions of the Calc.
+ */
+ public void getPrivateHolidays( Vector vectorHolidays,
+ XCellRange xcellrange,
+ XFunctionAccess xfunctionaccess ) {
+ try {
+ int intRow = this.INT_ROW_HOLIDAYS_START;
+ int intColumn = this.INT_COLUMN_HOLIDAYS_START;
+
+ double dHolidayStart = xcellrange.getCellByPosition(
+ intColumn, intRow ).getValue();
+
+ double dHolidayEnd = xcellrange.getCellByPosition(
+ intColumn + 1, intRow ).getValue();
+
+ while ( dHolidayStart != 0 ) {
+ if ( dHolidayEnd == 0 ) {
+ vectorHolidays.addElement(
+ new Integer( (int) Math.round(
+ dHolidayStart ) ) );
+ }
+ else {
+ for ( int intHoliday = (int) Math.round(
+ dHolidayStart );
+ intHoliday <= (int) Math.round( dHolidayEnd );
+ intHoliday++ ) {
+ vectorHolidays.addElement( new Double( intHoliday ) );
+ }
+ }
+
+ intRow++;
+ dHolidayStart = xcellrange.getCellByPosition(
+ intColumn, intRow).getValue();
+ dHolidayEnd = xcellrange.getCellByPosition(
+ intColumn + 1, intRow).getValue();
+ }
+ }
+ catch( Exception exception ) {
+ this.showExceptionMessage( exception );
+ }
+ }
+
+ /** Showing the stack trace in a JOptionPane.
+ * @param sMessage The message to show.
+ */
+ public void showMessage( String sMessage ) {
+ javax.swing.JFrame jframe = new javax.swing.JFrame();
+ jframe.setLocation(100, 100);
+ jframe.setSize(300, 200);
+ jframe.setVisible(true);
+ javax.swing.JOptionPane.showMessageDialog(
+ jframe, sMessage, "Debugging information",
+ javax.swing.JOptionPane.INFORMATION_MESSAGE);
+ jframe.dispose();
+ }
+
+ /** Writing the stack trace from an exception to a string and calling
+ * the method showMessage() with this string.
+ * @param exception The occured exception.
+ * @see showMessage
+ */
+ public void showExceptionMessage( Exception exception ) {
+ java.io.StringWriter swriter = new java.io.StringWriter();
+ java.io.PrintWriter printwriter =
+ new java.io.PrintWriter( swriter );
+ exception.printStackTrace( printwriter);
+ System.err.println( exception );
+ this.showMessage( swriter.getBuffer().substring(0) );
+ }
+ }
+
+ /**
+ * 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( ToDoImpl.class.getName() ) )
+ xFactory = Factory.createComponentFactory(ToDoImpl.class,
+ ToDoImpl.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(ToDoImpl.class.getName(),
+ ToDoImpl.getServiceNames(), regKey);
+ }
+}
+
diff --git a/odk/examples/java/ToDo/ToDo.ods b/odk/examples/java/ToDo/ToDo.ods
new file mode 100644
index 000000000000..344a5c2e9f47
--- /dev/null
+++ b/odk/examples/java/ToDo/ToDo.ods
Binary files differ
diff --git a/odk/examples/java/ToDo/XToDo.idl b/odk/examples/java/ToDo/XToDo.idl
new file mode 100644
index 000000000000..5cae425c4ea0
--- /dev/null
+++ b/odk/examples/java/ToDo/XToDo.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 INCLUDED_ORG_OPENOFFICE_XTODO_IDL
+#define INCLUDED_ORG_OPENOFFICE_XTODO_IDL
+
+
+/// org
+module org {
+ /// openoffice
+ module openoffice {
+ /// example interface
+ interface XToDo {
+ void recalc( [in] any aInstance );
+ };
+ };
+};
+
+#endif
diff --git a/odk/examples/java/makefile.mk b/odk/examples/java/makefile.mk
new file mode 100644
index 000000000000..564b615e9356
--- /dev/null
+++ b/odk/examples/java/makefile.mk
@@ -0,0 +1,155 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=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= \
+ $(DESTDIRJAVAEXAMPLES)$/Drawing$/SDraw.java \
+ $(DESTDIRJAVAEXAMPLES)$/Drawing$/Makefile
+
+SPREADSHEET_FILES= \
+ $(DESTDIRJAVAEXAMPLES)$/Spreadsheet$/SCalc.java \
+ $(DESTDIRJAVAEXAMPLES)$/Spreadsheet$/EuroAdaption.java \
+ $(DESTDIRJAVAEXAMPLES)$/Spreadsheet$/ChartTypeChange.java \
+ $(DESTDIRJAVAEXAMPLES)$/Spreadsheet$/CalcAddins.java \
+ $(DESTDIRJAVAEXAMPLES)$/Spreadsheet$/CalcAddins.ods \
+ $(DESTDIRJAVAEXAMPLES)$/Spreadsheet$/XCalcAddins.idl \
+ $(DESTDIRJAVAEXAMPLES)$/Spreadsheet$/Makefile
+
+TEXT_FILES= \
+ $(DESTDIRJAVAEXAMPLES)$/Text$/SWriter.java \
+ $(DESTDIRJAVAEXAMPLES)$/Text$/StyleInitialization.java \
+ $(DESTDIRJAVAEXAMPLES)$/Text$/TextDocumentStructure.java \
+ $(DESTDIRJAVAEXAMPLES)$/Text$/TextReplace.java \
+ $(DESTDIRJAVAEXAMPLES)$/Text$/BookmarkInsertion.java \
+ $(DESTDIRJAVAEXAMPLES)$/Text$/HardFormatting.java \
+ $(DESTDIRJAVAEXAMPLES)$/Text$/StyleCreation.java \
+ $(DESTDIRJAVAEXAMPLES)$/Text$/WriterSelector.java \
+ $(DESTDIRJAVAEXAMPLES)$/Text$/GraphicsInserter.java \
+ $(DESTDIRJAVAEXAMPLES)$/Text$/oo_smiley.gif \
+ $(DESTDIRJAVAEXAMPLES)$/Text$/Makefile
+
+DOCUMENTHANDLING_FILES= \
+ $(DESTDIRJAVAEXAMPLES)$/DocumentHandling$/DocumentConverter.java \
+ $(DESTDIRJAVAEXAMPLES)$/DocumentHandling$/DocumentLoader.java \
+ $(DESTDIRJAVAEXAMPLES)$/DocumentHandling$/DocumentPrinter.java \
+ $(DESTDIRJAVAEXAMPLES)$/DocumentHandling$/DocumentSaver.java \
+ $(DESTDIRJAVAEXAMPLES)$/DocumentHandling$/Makefile \
+ $(DESTDIRJAVAEXAMPLES)$/DocumentHandling$/test$/test1.odt
+
+CONVERTERSERVLET_FILES= \
+ $(DESTDIRJAVAEXAMPLES)$/ConverterServlet$/ConverterServlet.html \
+ $(DESTDIRJAVAEXAMPLES)$/ConverterServlet$/ConverterServlet.java \
+ $(DESTDIRJAVAEXAMPLES)$/ConverterServlet$/web.xml \
+ $(DESTDIRJAVAEXAMPLES)$/ConverterServlet$/Makefile \
+ $(DESTDIRJAVAEXAMPLES)$/ConverterServlet$/README
+
+EMBEDDEDOBJECT_FILES= \
+ $(DESTDIRJAVAEXAMPLES)$/EmbedDocument$/EmbeddedObject$/EmbeddedObject.xcu \
+ $(DESTDIRJAVAEXAMPLES)$/EmbedDocument$/EmbeddedObject$/OwnEmbeddedObject.java \
+ $(DESTDIRJAVAEXAMPLES)$/EmbedDocument$/EmbeddedObject$/EditorFrame.java \
+ $(DESTDIRJAVAEXAMPLES)$/EmbedDocument$/EmbeddedObject$/Makefile \
+ $(DESTDIRJAVAEXAMPLES)$/EmbedDocument$/EmbeddedObject$/OwnEmbeddedObjectFactory.java
+
+INSPECTOR_FILES= \
+ $(DESTDIRJAVAEXAMPLES)$/Inspector$/Inspector.jpg \
+ $(DESTDIRJAVAEXAMPLES)$/Inspector$/InspectorThumbnail.jpg \
+ $(DESTDIRJAVAEXAMPLES)$/Inspector$/Inspector.uno.xml \
+ $(DESTDIRJAVAEXAMPLES)$/Inspector$/Inspector.java \
+ $(DESTDIRJAVAEXAMPLES)$/Inspector$/Makefile \
+ $(DESTDIRJAVAEXAMPLES)$/Inspector$/TestInspector.java \
+ $(DESTDIRJAVAEXAMPLES)$/Inspector$/XInstanceInspector.idl \
+ $(DESTDIRJAVAEXAMPLES)$/Inspector$/InstanceInspector.idl \
+ $(DESTDIRJAVAEXAMPLES)$/Inspector$/InstanceInspectorTest.odt
+
+NOTESACCESS_FILES= \
+ $(DESTDIRJAVAEXAMPLES)$/NotesAccess$/NotesAccess.java \
+ $(DESTDIRJAVAEXAMPLES)$/NotesAccess$/Makefile \
+ $(DESTDIRJAVAEXAMPLES)$/NotesAccess$/Stocks.nsf
+
+TODO_FILES= \
+ $(DESTDIRJAVAEXAMPLES)$/ToDo$/ToDo.java \
+ $(DESTDIRJAVAEXAMPLES)$/ToDo$/ToDo.ods \
+ $(DESTDIRJAVAEXAMPLES)$/ToDo$/ToDo.uno.xml \
+ $(DESTDIRJAVAEXAMPLES)$/ToDo$/ToDo.idl \
+ $(DESTDIRJAVAEXAMPLES)$/ToDo$/XToDo.idl \
+ $(DESTDIRJAVAEXAMPLES)$/ToDo$/Makefile
+
+MINIMALCOMPONENT_FILES= \
+ $(DESTDIRJAVAEXAMPLES)$/MinimalComponent$/MinimalComponent.idl \
+ $(DESTDIRJAVAEXAMPLES)$/MinimalComponent$/MinimalComponent.java\
+ $(DESTDIRJAVAEXAMPLES)$/MinimalComponent$/MinimalComponent.uno.xml \
+ $(DESTDIRJAVAEXAMPLES)$/MinimalComponent$/TestMinimalComponent.java\
+ $(DESTDIRJAVAEXAMPLES)$/MinimalComponent$/Makefile
+
+PROPERTYSET_FILES= \
+ $(DESTDIRJAVAEXAMPLES)$/PropertySet$/PropTest.java \
+ $(DESTDIRJAVAEXAMPLES)$/PropertySet$/PropertySet.odt \
+ $(DESTDIRJAVAEXAMPLES)$/PropertySet$/Makefile
+
+DIR_FILE_LIST= \
+ $(DRAWING_FILES) \
+ $(SPREADSHEET_FILES) \
+ $(TEXT_FILES) \
+ $(DOCUMENTHANDLING_FILES) \
+ $(CONVERTERSERVLET_FILES) \
+ $(EMBEDDEDOBJECT_FILES) \
+ $(INSPECTOR_FILES) \
+ $(NOTESACCESS_FILES) \
+ $(TODO_FILES) \
+ $(MINIMALCOMPONENT_FILES) \
+ $(PROPERTYSET_FILES)
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/ex_java_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/ex_java_files.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
+
diff --git a/odk/inc/makefile.mk b/odk/inc/makefile.mk
new file mode 100644
index 000000000000..c22fda1d96e2
--- /dev/null
+++ b/odk/inc/makefile.mk
@@ -0,0 +1,47 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME=odk
+TARGET=inc
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+.IF "$(ENABLE_PCH)"!=""
+ALLTAR : \
+ $(SLO)$/precompiled.pch \
+ $(SLO)$/precompiled_ex.pch
+
+.ENDIF # "$(ENABLE_PCH)"!=""
+
diff --git a/odk/inc/pch/precompiled_odk.cxx b/odk/inc/pch/precompiled_odk.cxx
new file mode 100644
index 000000000000..789e7b984131
--- /dev/null
+++ b/odk/inc/pch/precompiled_odk.cxx
@@ -0,0 +1,29 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_odk.hxx"
+
diff --git a/odk/inc/pch/precompiled_odk.hxx b/odk/inc/pch/precompiled_odk.hxx
new file mode 100644
index 000000000000..6da69733e500
--- /dev/null
+++ b/odk/inc/pch/precompiled_odk.hxx
@@ -0,0 +1,32 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): Generated on 2006-09-01 17:49:53.545647
+
+#ifdef PRECOMPILED_HEADERS
+#endif
+
diff --git a/odk/index.html b/odk/index.html
new file mode 100644
index 000000000000..6490e2354218
--- /dev/null
+++ b/odk/index.html
@@ -0,0 +1,203 @@
+<html>
+<head>
+ <title>OpenOffice.org %PRODUCT_RELEASE% SDK - Overview</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">
+
+<table class="table1" cellpadding=0>
+ <tr style="background-image:url(docs/images/sdk_head-2.png)">
+ <td 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="nothing30" src="docs/images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <table class="table2">
+ <tr>
+ <td><img class="nothing8" src="docs/images/nada.gif"></td>
+ <td>
+ <p>OpenOffice.org %PRODUCT_RELEASE% software is a complete, feature-rich
+ office productivity suite that provides, in combination with this
+ SDK, all the essential tools for building and deploying custom
+ solutions that build on, or integrate with, the OpenOffice.org %PRODUCT_RELEASE% suite
+ of products.</p>
+ <p>The SDK is a development kit for OpenOffice.org %PRODUCT_RELEASE%, which
+ eases the development of office components. It provides a set of
+ libraries, binaries, header, and IDL files which have final API's
+ and can only be extended with new functionality. This set of libraries
+ and binaries is the minimum set of functions needed to use system
+ abstraction for base functionality and for using UNO (Universal
+ Network Objects) component technology. The UNO component model is the
+ base of the whole Office API. The SDK provides everything necessary
+ to use the Office API from external programs (e.g. Java, C++) or to
+ extend the Office functionality with new components (e.g. new filter
+ components, CalcAddin functions). It is compatible over several
+ versions because the API remains unaffected and will only be extended
+ with new functions.</p>
+ <p>The SDK provides the basic building blocks for external developers
+ to develop components in any language for which a binding exists.
+ Currently, there are language bindings for OpenOffice.org %PRODUCT_RELEASE% Basic, Java,
+ and different C++ compilers on different platforms, for OpenOffice.org %PRODUCT_RELEASE%,
+ thus covering the two most commonly used programming languages. There
+ will be no limit for office automation in heterogeneous environments.
+ Currently supported platforms of the SDK are Linux, Solaris (sparc,
+ x86), and Windows.</p>
+ <p>The SDK also contains <a href="docs/common/ref/com/sun/star/module-ix.html" title="link to the IDL reference documentation"> reference</a> documentation
+ for the API and a complete <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/OpenOffice.org_Developers_Guide" title="link to the Developer's Guide in the Wiki">Developer's Guide</a> is availbale online in the OpenOffice.org Wiki, with
+ lots of examples, which introduce the API, explain the concepts behind
+ it, and make it possible for all users to quickly get started with
+ the Office API.</p>
+ </td>
+ <td><img class="nothing8" src="docs/images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td><img class="nothing8" src="docs/images/nada.gif"></td>
+ <td><img class="line" src="docs/images/sdk_line-1.gif"></td>
+ <td><img class="nothing8" src="docs/images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td><img class="nothing8" src="docs/images/nada.gif"></td>
+ <td>
+ <table class="table3">
+ <tr valign="top">
+ <td colspan="4" class="head1">Content</td>
+ </tr>
+ <tr>
+ <td colspan="4"><img class="nothing8" src="docs/images/nada.gif"></td>
+ </tr>
+ <tr valign="top">
+ <td class="content4"><img src="docs/images/arrow-1.gif"></td>
+ <td colspan="2"><a href="docs/install.html" title="link to the installation guide">Installation Guide</a></td>
+ <td class="content70">An overview of all necessary
+ installation steps (e.g. environment variables) to use this SDK.</td>
+ </tr>
+ <tr valign="middle">
+ <td><img class="nothing10" src="docs/images/nada.gif"></td>
+ <td colspan="3"><img class="line" src="docs/images/sdk_line-1.gif"></td>
+ </tr>
+ <tr valign="top">
+ <td class="content4"><img src="docs/images/arrow-1.gif"></td>
+ <td colspan="2"><a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/OpenOffice.org_Developers_Guide" title="link to the Developer's Guide in the Wiki">Developer's Guide</a></td>
+ <td class="content70">Detailed documentation, explaining the OpenOffice.org %PRODUCT_RELEASE%
+ API and the concepts behind it, with a rich set of examples,
+ implemented mainly in Java. This documentation is online in the
+ OpenOffice.org Wiki.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content4"><img src="docs/images/arrow-1.gif"></td>
+ <td colspan="2"><a href="docs/common/ref/com/sun/star/module-ix.html" title="link to the IDL reference documentation">IDL Reference</a></td>
+ <td class="content70">Complete OpenOffice.org %PRODUCT_RELEASE% API reference.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content4"><img src="docs/images/arrow-1.gif"></td>
+ <td colspan="2"><a href="docs/java/ref/index.html" title="link to the Java UNO runtime API reference documentation">Java UNO Runtime Reference </a></td>
+ <td class="content70">Reference documentation of the Java UNO runtime API.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content4"><img src="docs/images/arrow-1.gif"></td>
+ <td colspan="2"><a href="docs/cpp/ref/names/index.html" title="link to the C++ API reference documentation">C++ Reference</a></td>
+ <td class="content70">Reference documentation of the C++ UNO runtime and a
+ set of C/C++ base and helper functions and classes to abstract from
+ the system layer.</td>
+ </tr>
+ <tr valign="middle">
+ <td><img class="nothing10" src="docs/images/nada.gif"></td>
+ <td colspan="3"><img class="line" src="docs/images/sdk_line-1.gif"></td>
+ </tr>
+ <tr valign="top">
+ <td class="content4"><img src="docs/images/arrow-1.gif"></td>
+ <td colspan="2"><a href="docs/tools.html" title="link to the tools overview page">Development Tools</a></td>
+ <td class="content70">Overview and a short description of the UNO
+ development tools.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content4"><img src="docs/images/arrow-1.gif"></td>
+ <td colspan="2"><a href="examples/examples.html" title="link to the examples overview page">Examples</a></td>
+ <td class="content70">A collection of examples in different
+ programming languages (Java, C++, Basic, OLE, CLI).</td>
+ </tr>
+ <tr valign="middle">
+ <td><img class="nothing10" src="docs/images/nada.gif"></td>
+ <td colspan="3"><img class="line" src="docs/images/sdk_line-1.gif"></td>
+ </tr>
+ <tr valign="top">
+ <td class="content4"><img src="docs/images/arrow-1.gif"></td>
+ <td colspan="2"><a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office" title="link to the OASIS Open Office XML Format TC (online)">OASIS Open Document Format for Office Applications (OpenDocument) TC</a></td>
+ <td class="content70">Link to the OASIS Open Document Format for
+ Office Applications (OpenDocument) Technical Committee where you
+ can find the latest information about the OASIS Open Document XML
+ file format which is the default document format
+ for OpenOffice.org %PRODUCT_RELEASE%.</td>
+ </tr>
+ <tr valign="top">
+ <td class="content4"><img src="docs/images/arrow-1.gif"></td>
+ <td colspan="2"><a href="http://xml.openoffice.org/xml_specification.pdf" title="link to the OpenOffice.org XML File Format Specification">OpenOffice.org XML File Format</a></td>
+ <td class="content70">Specification of the initial OpenOffice.org
+ XML File Format.</td>
+ </tr>
+ <tr valign="middle">
+ <td><img class="nothing10" src="docs/images/nada.gif"></td>
+ <td colspan="3"><img class="line" src="docs/images/sdk_line-1.gif"></td>
+ </tr>
+ <tr valign="top">
+ <td class="content4"><img src="docs/images/arrow-1.gif"></td>
+ <td colspan="2"><a href="share/readme/LICENSE_en-US.html" title="link to the SDK license file">License</a></td>
+ <td class="content70">The license for the OpenOffice.org %PRODUCT_RELEASE% SDK.</td>
+ </tr>
+ <tr valign="middle">
+ <td><img class="nothing10" src="docs/images/nada.gif"></td>
+ <td colspan="3"><img class="line" src="docs/images/sdk_line-1.gif"></td>
+ </tr>
+ <tr valign="top">
+ <td colspan="4"><img class="nothing8" src="docs/images/nada.gif"></td>
+ </tr>
+ <tr valign="top">
+ <td colspan="4" class="head1">Additional Resources</td>
+ </tr>
+ <tr valign="top">
+ <td colspan="4"><img class="nothing8" src="docs/images/nada.gif"></td>
+ </tr>
+ <tr valign="middle">
+ <td class="content4"><img class="arrow" src="docs/images/arrow-1.gif"</td>
+ <td width="5%"><a target="_blank" href="http://www.oracle.com/us/products/applications/open-office" title="link to the Oracle Open Office homepage (online)"><img class="appicon" src="docs/images/orc-main-app_32.png"></a></td>
+ <td width="21%"><a target="_blank" href="http://www.oracle.com/us/products/applications/open-office" title="link to the Oracle Open Office homepage (online)">Oracle Open Office&#153</a></td>
+ <td class="content70">Full-featured suite of office productivity tools.</td>
+ </tr>
+ <tr valign="middle">
+ <td class="content4"><img class="arrow" src="docs/images/arrow-1.gif"</td>
+ <td width="5%"><a target="_blank" href="http://www.openoffice.org/" title="link to the OpenOffice.org homepage (online)"><img class="appicon" src="docs/images/ooo-main-app_32.png"></a></td>
+ <td width="21%"><a target="_blank" href="http://www.openoffice.org/" title="link to the OpenOffice.org homepage (online)">OpenOffice.org&#153</a></td>
+ <td class="content70">Open Source community project of office-productivity software.</td>
+ </tr>
+ </table>
+ </td>
+ <td><img class="nothing8" src="docs/images/nada.gif"></td>
+ </tr>
+ </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>
+</table>
+<map name="Map">
+ <area shape="rect" coords="10,68,93,105" href="http://www.oracle.com">
+</map>
+</body>
+</html>
diff --git a/odk/no_localization b/odk/no_localization
new file mode 100644
index 000000000000..3ce3aa0ec048
--- /dev/null
+++ b/odk/no_localization
@@ -0,0 +1 @@
+Touch me to prevent that the localisation process extracts strings #i85733#
diff --git a/odk/pack/checkbin/makefile.mk b/odk/pack/checkbin/makefile.mk
new file mode 100644
index 000000000000..52c744c6c6f1
--- /dev/null
+++ b/odk/pack/checkbin/makefile.mk
@@ -0,0 +1,51 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+PRJNAME=odk
+TARGET=checkbin
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+.IF "$(L10N_framework)"==""
+
+ODKCHECKFILE=$(MISC)$/$(TARGET).txt
+
+all: $(ODKCHECKFILE)
+
+$(ODKCHECKFILE) : $(SDK_CONTENT_CHECK_FILES)
+ @echo "" > $(ODKCHECKFILE)
+# THE PERL SCRIPT DELETES THE CHECK FILE, WHEN AN ERROR OCCURS
+ $(PERL) $(PRJ)$/util$/check.pl $(DESTDIR) $(DESTPLATFROM) "$(EXEPOSTFIX)" $(ODKCHECKFILE)
+# RAISE AN ERROR WHEN TAG FILE IS NOT THERE ANYMORE
+ cat $(ODKCHECKFILE)
+
+.ELSE
+pseudo:
+
+.ENDIF
diff --git a/odk/pack/checkidl/makefile.mk b/odk/pack/checkidl/makefile.mk
new file mode 100644
index 000000000000..f585bb3c4b52
--- /dev/null
+++ b/odk/pack/checkidl/makefile.mk
@@ -0,0 +1,51 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+PRJNAME=odk
+TARGET=checkidl
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+.IF "$(L10N_framework)"==""
+ODKCHECKFILE=$(MISC)$/$(TARGET).txt
+
+all : $(ODKCHECKFILE)
+
+$(ODKCHECKFILE) : $(SDK_CONTENT_CHECK_FILES)
+ @echo "" > $(ODKCHECKFILE)
+# THE PERL SCRIPT DELETES THE CHECK FILE, WHEN AN ERROR OCCURS
+ -diff -br $(DESTDIRIDL) $(SOLARIDLDIR) $(PIPEERROR) $(PERL) $(PRJ)$/util$/checkdiff.pl $(ODKCHECKFILE)
+# RAISE AN ERROR WHEN TAG FILE IS NOT THERE ANYMORE
+ cat $(ODKCHECKFILE)
+
+.ELSE
+pseudo:
+
+.ENDIF
diff --git a/odk/pack/checkinc/makefile.mk b/odk/pack/checkinc/makefile.mk
new file mode 100644
index 000000000000..0f7e7c6a42bf
--- /dev/null
+++ b/odk/pack/checkinc/makefile.mk
@@ -0,0 +1,54 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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=checkinc
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+.IF "$(L10N_framework)"==""
+ODKCHECKFILE=$(MISC)$/$(TARGET).txt
+
+all : $(ODKCHECKFILE)
+
+$(ODKCHECKFILE) : $(SDK_CONTENT_CHECK_FILES)
+ @echo "" > $(ODKCHECKFILE)
+# THE PERL SCRIPT DELETES THE CHECK FILE, WHEN AN ERROR OCCURS
+ -diff -br $(DESTDIRINC)$/osl $(SOLARINCDIR)$/osl $(PIPEERROR) $(PERL) $(PRJ)$/util$/checkdiff.pl $(ODKCHECKFILE)
+ -diff -br $(DESTDIRINC)$/rtl $(SOLARINCDIR)$/rtl $(PIPEERROR) $(PERL) $(PRJ)$/util$/checkdiff.pl $(ODKCHECKFILE)
+ -diff -br $(DESTDIRINC)$/sal $(SOLARINCDIR)$/sal $(PIPEERROR) $(PERL) $(PRJ)$/util$/checkdiff.pl $(ODKCHECKFILE)
+ -diff -br $(DESTDIRINC)$/stl $(SOLARINCDIR)$/stl $(PIPEERROR) $(PERL) $(PRJ)$/util$/checkdiff.pl $(ODKCHECKFILE)
+ -diff -br $(DESTDIRINC)$/store $(SOLARINCDIR)$/store $(PIPEERROR) $(PERL) $(PRJ)$/util$/checkdiff.pl $(ODKCHECKFILE)
+ -diff -br $(DESTDIRINC)$/vos $(SOLARINCDIR)$/vos $(PIPEERROR) $(PERL) $(PRJ)$/util$/checkdiff.pl $(ODKCHECKFILE)
+# RAISE AN ERROR WHEN TAG FILE IS NOT THERE ANYMORE
+ cat $(ODKCHECKFILE)
+.ELSE
+pseudo:
+
+.ENDIF
diff --git a/odk/pack/checkinc2/makefile.mk b/odk/pack/checkinc2/makefile.mk
new file mode 100644
index 000000000000..78e0aa35d1c7
--- /dev/null
+++ b/odk/pack/checkinc2/makefile.mk
@@ -0,0 +1,54 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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=checkinc2
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+.IF "$(L10N_framework)"==""
+ODKCHECKFILE=$(MISC)$/$(TARGET).txt
+
+all : $(ODKCHECKFILE)
+
+$(ODKCHECKFILE) : $(SDK_CONTENT_CHECK_FILES)
+ @echo "" > $(ODKCHECKFILE)
+# THE PERL SCRIPT DELETES THE CHECK FILE, WHEN AN ERROR OCCURS
+ -diff -br $(DESTDIRINC)$/typelib $(SOLARINCDIR)$/typelib $(PIPEERROR) $(PERL) $(PRJ)$/util$/checkdiff.pl $(ODKCHECKFILE)
+ -diff -br $(DESTDIRINC)$/uno $(SOLARINCDIR)$/uno $(PIPEERROR) $(PERL) $(PRJ)$/util$/checkdiff.pl $(ODKCHECKFILE)
+ -diff -br $(DESTDIRINC)$/bridges $(SOLARINCDIR)$/bridges $(PIPEERROR) $(PERL) $(PRJ)$/util$/checkdiff.pl $(ODKCHECKFILE)
+ -diff -br $(DESTDIRINC)$/cppu $(SOLARINCDIR)$/cppu $(PIPEERROR) $(PERL) $(PRJ)$/util$/checkdiff.pl $(ODKCHECKFILE)
+ -diff -br $(DESTDIRINC)$/com$/sun$/star$/uno $(SOLARINCDIR)$/com$/sun$/star$/uno $(PIPEERROR) $(PERL) $(PRJ)$/util$/checkdiff.pl $(ODKCHECKFILE)
+ -diff -br $(DESTDIRINC)$/cppuhelper $(SOLARINCDIR)$/cppuhelper $(PIPEERROR) $(PERL) $(PRJ)$/util$/checkdiff.pl $(ODKCHECKFILE)
+# RAISE AN ERROR WHEN TAG FILE IS NOT THERE ANYMORE
+ cat $(ODKCHECKFILE)
+.ELSE
+pseudo:
+
+.ENDIF
diff --git a/odk/pack/copying/addsym-macosx.sh b/odk/pack/copying/addsym-macosx.sh
new file mode 100755
index 000000000000..d3bac6e5e878
--- /dev/null
+++ b/odk/pack/copying/addsym-macosx.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+# This script is needed in the process of generating exported
+# symbols list on Mac OS X
+
+# Please note that the awk expression expects to get the output of 'nm -gx'!
+# On Panther we have to filter out symbols with a value "1f" otherwise external
+# symbols will erroneously be added to the generated export symbols list file.
+awk -v SYMBOLSREGEXP="^__ZTI.*$|^__ZTS.*$" '
+match ($6,SYMBOLSREGEXP) > 0 && $6 !~ /_GLOBAL_/ { if (($2 != 1) && ( $2 != "1f" ) ) print $6 }'
+
diff --git a/odk/pack/copying/dk.mk b/odk/pack/copying/dk.mk
new file mode 100644
index 000000000000..4cbe5b1ab563
--- /dev/null
+++ b/odk/pack/copying/dk.mk
@@ -0,0 +1,3 @@
+# OpenOffice.org @@RELEASE@@ SDK dependent settings
+SDKVERSION=@@RELEASE@@
+BUILDID=@@BUILDID@@
diff --git a/odk/pack/copying/idl_chapter_refs.txt b/odk/pack/copying/idl_chapter_refs.txt
new file mode 100644
index 000000000000..58d93cce9c1b
--- /dev/null
+++ b/odk/pack/copying/idl_chapter_refs.txt
@@ -0,0 +1,7555 @@
+LINK:Documentation/DevGuide/AppendixC/The_File_Content_Provider#Commands_and_Properties
+DESCR:AppendixC - The File Content Provider - Commands and Properties
+REF:
+com.sun.star.ucb.XContent
+com.sun.star.lang.XServiceInfo
+com.sun.star.ucb.XContentCreator
+com.sun.star.lang.XComponent
+com.sun.star.container.XChild
+com.sun.star.ucb.XCommandInfoChangeNotifier
+com.sun.star.beans.XPropertySetInfoChangeNotifier
+com.sun.star.beans.XPropertiesChangeNotifier
+com.sun.star.beans.XPropertyContainer
+com.sun.star.ucb.XCommandProcessor
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Implementing_a_New_Locale#XCharacterClassification
+DESCR:OfficeDev - Implementing a New Locale - XCharacterClassification
+REF:
+com.sun.star.i18n.XCharacterClassification
+TOPIC:
+com.sun.star.i18n.XCharacterClassification
+
+LINK:Documentation/DevGuide/ProUNO/Service_Manager_and_Component_Context
+DESCR:ProUNO - Service Manager and Component Context
+REF:
+TOPIC:
+com.sun.star.uno.XComponentContext
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.lang.XMultiComponentFactory
+com.sun.star.lang.ServiceManager
+
+LINK:Documentation/DevGuide/ProUNO/C++/Mapping_of_Singletons
+DESCR:ProUNO - C++ - Mapping of Singletons
+REF:
+com.sun.star.uno.XComponentContext
+com.sun.star.uno.DeploymentException
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Overview_and_Using_the_API#XNumberFormatCode
+DESCR:OfficeDev - Overview and Using the API - XNumberFormatCode
+REF:
+com.sun.star.i18n.XLocaleData
+com.sun.star.i18n.XNumberFormatCode
+TOPIC:
+com.sun.star.i18n.XNumberFormatCode
+
+LINK:Documentation/DevGuide/ProUNO/C++/Exception_Handling_in_C++
+DESCR:ProUNO - C++ - Exception Handling in C++
+REF:
+com.sun.star.bridge.XUnoUrlResolver
+TOPIC:
+com.sun.star.uno.Exception
+com.sun.star.uno.RuntimeException
+
+LINK:Documentation/DevGuide/Charts/Data_Access
+DESCR:Charts - Data Access
+REF:
+com.sun.star.chart.XChartDataArray
+com.sun.star.chart.ChartDataRowSource
+com.sun.star.table.CellRange
+com.sun.star.chart.XChartData
+com.sun.star.chart.XChartDocument
+com.sun.star.chart.XChartDataChangeEventListener
+com.sun.star.chart.ChartDataArray
+com.sun.star.lang.XEventListener
+TOPIC:
+com.sun.star.chart.XChartDataArray
+com.sun.star.chart.XChartData
+com.sun.star.chart.ChartDataArray
+com.sun.star.chart.ChartData
+
+LINK:Documentation/DevGuide/OfficeDev/Implementing_a_New_Locale#XBreakIterator
+DESCR:OfficeDev - Implementing a New Locale - XBreakIterator
+REF:
+com.sun.star.i18n.XBreakIterator
+TOPIC:
+com.sun.star.i18n.XBreakIterator
+
+LINK:Documentation/DevGuide/Spreadsheets/Named_Ranges
+DESCR:Spreadsheets - Named Ranges
+REF:
+com.sun.star.sheet.XNamedRanges
+com.sun.star.sheet.NamedRangeFlag
+com.sun.star.container.XNamed
+com.sun.star.sheet.XNamedRange
+com.sun.star.sheet.Border
+com.sun.star.sheet.XCellRangeReferrer
+com.sun.star.sheet.NamedRange
+TOPIC:
+com.sun.star.sheet.XNamedRanges
+
+LINK:Documentation/DevGuide/Database/Moving_the_Result_Set_Cursor
+DESCR:Database - Moving the Result Set Cursor
+REF:
+com.sun.star.sdbc.XResultSet
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Preprocessing
+DESCR:WritingUNO - Preprocessing
+REF:
+com.sun.star.lang.IllegalArgumentException
+com.sun.star.connection.NoConnectException
+com.sun.star.connection.ConnectionSetupException
+com.sun.star.uno.XInterface
+TOPIC:
+
+LINK:Documentation/DevGuide/FirstSteps/First_Contact#Getting_Started
+DESCR:FirstSteps - First Contact - Getting Started
+REF:
+TOPIC:
+com.sun.star.uno.XComponentContext
+com.sun.star.lang.XMultiComponentFactory
+com.sun.star.lang.ServiceManager
+
+LINK:Documentation/DevGuide/Database/Handling_Unsupported_Functionality
+DESCR:Database - Handling Unsupported Functionality
+REF:
+com.sun.star.sdbc.XDatabaseMetaData
+com.sun.star.sdbc.SQLException
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Document_Events
+DESCR:OfficeDev - Document Events
+REF:
+com.sun.star.document.EventObject
+com.sun.star.frame.GlobalEventBroadcaster
+com.sun.star.container.NoSuchElementException
+com.sun.star.lang.XComponent
+com.sun.star.document.OfficeDocument
+com.sun.star.document.XEventBroadcaster
+com.sun.star.lang.EventObject
+com.sun.star.beans.PropertyValue
+com.sun.star.document.XEventsSupplier
+com.sun.star.document.Events
+com.sun.star.container.XNameReplace
+com.sun.star.document.XEventListener
+TOPIC:
+com.sun.star.document.EventObject
+com.sun.star.document.XEventBroadcaster
+com.sun.star.lang.EventObject
+com.sun.star.document.Events
+
+LINK:Documentation/DevGuide/GUI/Radio_Button
+DESCR:GUI - Radio Button
+REF:
+com.sun.star.awt.UnoControlRadioButtonModel
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleExtendedComponent
+DESCR:Accessibility - XAccessibleExtendedComponent
+REF:
+com.sun.star.accessibility.XAccessibleComponent
+com.sun.star.accessibility.XAccessibleExtendedComponent
+TOPIC:
+com.sun.star.accessibility.XAccessibleExtendedComponent
+
+LINK:Documentation/DevGuide/WritingUNO/Disable_Commands#Disabling_Commands_at_Runtime
+DESCR:WritingUNO - Disable Commands - Disabling Commands at Runtime
+REF:
+TOPIC:
+com.sun.star.configuration.ConfigurationUpdateAccess
+com.sun.star.configuration.ConfigurationProvider
+com.sun.star.util.XChangesBatch
+
+LINK:Documentation/DevGuide/Database/Catalog_Service
+DESCR:Database - Catalog Service
+REF:
+com.sun.star.sdbcx.XDataDefinitionSupplier
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Handling_Text_Document_Files#Creating_and_Loading_Text_Documents
+DESCR:Text - Handling Text Document Files - Creating and Loading Text Documents
+REF:
+com.sun.star.frame.XComponentLoader
+com.sun.star.lang.XComponent
+com.sun.star.document.MediaDescriptor
+com.sun.star.frame.Desktop
+TOPIC:
+com.sun.star.frame.XComponentLoader
+
+LINK:Documentation/DevGuide/Text/Overall_Document_Features#Paragraph_Styles
+DESCR:Text - Overall Document Features - Styles - Paragraph Styles
+REF:
+com.sun.star.style.ConditionalParagraphStyle
+com.sun.star.style.ParagraphProperties
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.style.ParagraphPropertiesAsian
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Redline
+DESCR:Text - Redline
+REF:
+com.sun.star.text.RedlinePortion
+com.sun.star.beans.XPropertySet
+com.sun.star.container.XEnumerationAccess
+com.sun.star.container.XIndexAccess
+com.sun.star.text.XText
+com.sun.star.document.XRedlinesSupplier
+TOPIC:
+com.sun.star.document.XRedlinesSupplier
+
+LINK:Documentation/DevGuide/OfficeDev/Properties_of_a_Type
+DESCR:OfficeDev - Properties of a Type
+REF:
+com.sun.star.document.TypeDetection
+com.sun.star.container.XNameAccess
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleRelationSet
+DESCR:Accessibility - XAccessibleRelationSet
+REF:
+com.sun.star.accessibility.XAccessibleRelationSet
+com.sun.star.accessibility.AccessibleRelation
+com.sun.star.accessibility.AccessibleRelationType
+TOPIC:
+com.sun.star.accessibility.XAccessibleRelationSet
+com.sun.star.accessibility.AccessibleRelation
+com.sun.star.accessibility.AccessibleRelationType
+
+LINK:Documentation/DevGuide/OfficeDev/Java_Window_Integration#A_Hack
+DESCR:OfficeDev - Java Window Integration - Using the Window Handle - A Hack
+REF:
+com.sun.star.awt.XSystemDependentWindowPeer
+com.sun.star.awt.XWindow
+com.sun.star.awt.XWindowPeer
+com.sun.star.frame.XFrame
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/Text_Field
+DESCR:Basic - Text Field
+REF:
+com.sun.star.awt.UnoControlEdit
+com.sun.star.awt.XTextComponent
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Intercepting_Context_Menus#Changing_a_Menu
+DESCR:WritingUNO - Intercepting Context Menus - Writing an Interceptor - Changing a Menu
+REF:
+com.sun.star.ui.ContextMenuExecuteEvent
+com.sun.star.ui.ActionTriggerContainer
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.ui.ActionTriggerSeparator
+com.sun.star.ui.ActionTrigger
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Properties_of_Cell_Ranges
+DESCR:Spreadsheets - Properties of Cell Ranges
+REF:
+com.sun.star.table.CellRange
+com.sun.star.sheet.SheetCellRange
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Cell_Cursor#Cursor_Movement
+DESCR:Spreadsheets - Cell Cursor - Cursor Movement
+REF:
+com.sun.star.table.XCellCursor
+com.sun.star.sheet.XSpreadsheet
+com.sun.star.table.XCellRange
+com.sun.star.table.CellCursor
+com.sun.star.sheet.XSheetCellCursor
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Implementing_a_New_Locale#XCalendar
+DESCR:OfficeDev - Implementing a New Locale - XCalendar
+REF:
+com.sun.star.i18n.XCalendar
+TOPIC:
+com.sun.star.i18n.XCalendar
+
+LINK:Documentation/DevGuide/Spreadsheets/Querying_for_Cells_with_Specific_Properties
+DESCR:Spreadsheets - Querying for Cells with Specific Properties
+REF:
+com.sun.star.sheet.XCellRangesQuery
+com.sun.star.sheet.CellFlags
+com.sun.star.sheet.XSheetCellRanges
+com.sun.star.sheet.XFormulaQuery
+com.sun.star.sheet.FormulaResult
+com.sun.star.sheet.SheetRangesQuery
+TOPIC:
+com.sun.star.sheet.XCellRangesQuery
+com.sun.star.sheet.XFormulaQuery
+com.sun.star.sheet.SheetRangesQuery
+
+LINK:Documentation/DevGuide/Text/Embedded_Objects
+DESCR:Text - Embedded Objects
+REF:
+com.sun.star.text.TextEmbeddedObject
+com.sun.star.text.BaseFrame
+com.sun.star.document.XEmbeddedObjectSupplier
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/Implementing_Accessible_Objects#Implementation_Rules
+DESCR:Accessibility - Implementing Accessible Objects - Implementation Rules
+REF:
+com.sun.star.accessibility.XAccessibleTable
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Column_and_Row_Access
+DESCR:Spreadsheets - Column and Row Access
+REF:
+com.sun.star.table.XTableColumns
+com.sun.star.table.XColumnRowRange
+com.sun.star.table.XTableRows
+TOPIC:
+com.sun.star.table.XColumnRowRange
+
+LINK:Documentation/DevGuide/OfficeDev/Path_Settings
+DESCR:OfficeDev - Path Settings
+REF:
+com.sun.star.util.PathSettings
+TOPIC:
+com.sun.star.util.PathSettings
+
+LINK:Documentation/DevGuide/Spreadsheets/Printing_Spreadsheet_Documents#Page_Breaks_and_Scaling_for_Printout
+DESCR:Spreadsheets - Printing Spreadsheet Documents - Page Breaks and Scaling for Printout
+REF:
+com.sun.star.style.XStyleFamiliesSupplier
+com.sun.star.table.TableColumn
+com.sun.star.table.TableRow
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Formatting#Cell_Formatting
+DESCR:Spreadsheets - Formatting - Cell Formatting
+REF:
+com.sun.star.beans.XPropertySet
+com.sun.star.table.BorderLine
+com.sun.star.table.CellProperties
+com.sun.star.table.TableBorder
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Implementing_without_Helpers#XComponent
+DESCR:WritingUNO - Implementing without Helpers - XComponent
+REF:
+com.sun.star.lang.XEventListener
+com.sun.star.lang.DisposedException
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Forms_Container
+DESCR:Forms - Forms Container
+REF:
+com.sun.star.form.Forms
+com.sun.star.drawing.DrawPage
+com.sun.star.form.FormComponent
+com.sun.star.form.FormComponents
+com.sun.star.form.XFormsSupplier
+TOPIC:
+
+LINK:Documentation/DevGuide/Extensions/Location_of_Installed_Extensions
+DESCR:Extensions - Location of Installed Extensions
+REF:
+com.sun.star.deployment.XPackageInformationProvider
+com.sun.star.deployment.PackageInformationProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Structs
+DESCR:ProUNO - Structs
+REF:
+com.sun.star.beans.Optional
+com.sun.star.beans.Ambiguous
+com.sun.star.beans.Defaulted
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Lifetime_of_UNO_objects
+DESCR:ProUNO - Lifetime of UNO objects
+REF:
+TOPIC:
+com.sun.star.lang.XComponent
+com.sun.star.uno.XInterface
+com.sun.star.uno.XWeak
+
+LINK:Documentation/DevGuide/Scripting/Writing_Macros#Creating_dialogs_from_macros
+DESCR:Scripting - Writing Macros - Creating dialogs from macros
+REF:
+com.sun.star.awt.XDialogProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Java_Window_Integration
+DESCR:OfficeDev - Java Window Integration
+REF:
+TOPIC:
+com.sun.star.awt.XToolkit
+com.sun.star.awt.Toolkit
+com.sun.star.awt.XWindowPeer
+
+LINK:Documentation/DevGuide/GUI/The_Toolkit_Service
+DESCR:GUI - The Toolkit Service
+REF:
+com.sun.star.awt.XToolkit
+com.sun.star.awt.XWindow
+com.sun.star.awt.Toolkit
+com.sun.star.frame.XFrame
+com.sun.star.awt.WindowClass
+com.sun.star.frame.XLayoutManager
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/A_Hierarchy_of_Models
+DESCR:Forms - A Hierarchy of Models
+REF:
+com.sun.star.container.XIndexAccess
+com.sun.star.container.XChild
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Models#Document_Specific_Features
+DESCR:OfficeDev - Component - Models - Document Specific Features
+REF:
+com.sun.star.sheet.SpreadsheetDocument
+com.sun.star.lang.XServiceInfo
+com.sun.star.drawing.DrawingDocument
+com.sun.star.chart.ChartDocument
+com.sun.star.formula.FormulaProperties
+com.sun.star.text.TextDocument
+com.sun.star.presentation.PresentationDocument
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Indexes_and_Index_Marks#Indexes
+DESCR:Text - Indexes and Index Marks - Indexes
+REF:
+com.sun.star.text.BibliographyDataType
+com.sun.star.text.BibliographyDataField
+com.sun.star.text.IllustrationIndex
+com.sun.star.beans.XPropertySet
+com.sun.star.container.XIndexReplace
+com.sun.star.text.Bibliography
+com.sun.star.text.BaseIndex
+com.sun.star.container.XNameAccess
+com.sun.star.text.DocumentIndexLevelFormat
+com.sun.star.text.ContentIndex
+com.sun.star.text.XDocumentIndex
+com.sun.star.text.UserIndex
+com.sun.star.text.TextContent
+com.sun.star.container.XNamed
+com.sun.star.text.ObjectIndex
+com.sun.star.text.TableIndex
+com.sun.star.text.XDocumentIndexesSupplier
+com.sun.star.beans.PropertyValues
+com.sun.star.text.DocumentIndex
+com.sun.star.container.XIndexAccess
+com.sun.star.text.ChapterFormat
+com.sun.star.beans.PropertyValue
+com.sun.star.text.DocumentIndexes
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Forms
+DESCR:Forms - Forms
+REF:
+com.sun.star.form
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/The_Service_Manager_Component#Instantiation
+DESCR:ProUNO - Bridge - The Service Manager Component - Instantiation
+REF:
+TOPIC:
+com.sun.star.lang.ServiceManager
+
+LINK:Documentation/DevGuide/WritingUNO/Implementing_without_Helpers#XInterface
+DESCR:WritingUNO - Implementing without Helpers - XInterface
+REF:
+com.sun.star.uno.XInterface
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Usage
+DESCR:Database - Usage
+REF:
+com.sun.star.sdbcx.Privilege
+com.sun.star.sdbc.ResultSetType
+com.sun.star.sdbc.TransactionIsolation
+com.sun.star.sdbc.XConnection
+com.sun.star.sdb.RowSet
+com.sun.star.sdbc.RowSet
+com.sun.star.sdb.ResultSet
+com.sun.star.beans.XPropertyChangeListener
+com.sun.star.sdb.CommandType
+com.sun.star.sdbc.XRowSet
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Basic/Instantiating_UNO_Services
+DESCR:ProUNO - Basic - Instantiating UNO Services
+REF:
+com.sun.star.ucb.SimpleFileAccess
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.frame.Desktop
+com.sun.star.lang.ServiceManager
+TOPIC:
+com.sun.star.lang.ServiceManager
+
+LINK:Documentation/DevGuide/Text/Shape_Objects_in_Text
+DESCR:Text - Shape Objects in Text
+REF:
+TOPIC:
+com.sun.star.text.TextEmbeddedObject
+com.sun.star.text.BaseFrame
+com.sun.star.text.Shape
+com.sun.star.text.TextGraphicObject
+com.sun.star.text.TextFrame
+
+LINK:Documentation/DevGuide/Forms/Automatic_Key_Generation
+DESCR:Forms - Automatic Key Generation
+REF:
+com.sun.star.sdb.XRowSetApproveBroadcaster
+TOPIC:
+com.sun.star.sdb.XRowSetApproveBroadcaster
+
+LINK:Documentation/DevGuide/ProUNO/Java/Getting_a_Service_Manager
+DESCR:ProUNO - Java - Getting a Service Manager
+REF:
+com.sun.star.loader.Java
+com.sun.star.lang.MultiServiceFactory
+com.sun.star.loader.Java2
+com.sun.star.connection.Acceptor
+com.sun.star.connection.Connector
+com.sun.star.bridge.UnoUrlResolver
+com.sun.star.bridge.BridgeFactory
+com.sun.star.frame.Desktop
+com.sun.star.lang.ServiceManager
+TOPIC:
+com.sun.star.uno.XComponentContext
+com.sun.star.bridge.XUnoUrlResolver
+com.sun.star.lang.DisposedException
+com.sun.star.bridge.UnoUrlResolver
+com.sun.star.lang.XMultiComponentFactory
+com.sun.star.lang.ServiceManager
+
+LINK:Documentation/DevGuide/Drawings/Shapes
+DESCR:Drawings - Shapes
+REF:
+com.sun.star.beans.XPropertySet
+com.sun.star.drawing.RectangleShape
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Component_Context#ComponentContext_API
+DESCR:ProUNO - Component Context - ComponentContext API
+REF:
+com.sun.star.uno.XComponentContext
+com.sun.star.lang.XMultiComponentFactory
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Implementing_without_Helpers#XTypeProvider
+DESCR:WritingUNO - Implementing without Helpers - XTypeProvider
+REF:
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/AppendixC/The_WebDAV_Content_Provider#Creation_of_New_DCP_Contents
+DESCR:AppendixC - The WebDAV Content Provider - Creation of New DCP Contents
+REF:
+com.sun.star.ucb.XContentCreator
+TOPIC:
+com.sun.star.ucb.XContentCreator
+
+LINK:Documentation/DevGuide/Database/Database_Design#Determining_Feature_Support
+DESCR:Database - Database Design - Retrieving Information about a Database - Determining Feature Support
+REF:
+com.sun.star.sdbc.XDatabaseMetaData
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Writing_the_Filtering_Component
+DESCR:OfficeDev - Writing the Filtering Component
+REF:
+com.sun.star.xml.XMLExportFilter
+com.sun.star.xml.ImportFilter
+com.sun.star.xml.ExportFilter
+com.sun.star.xml.sax.XDocumentHandler
+com.sun.star.xml.XMLImportFilter
+TOPIC:
+com.sun.star.xml.ImportFilter
+com.sun.star.xml.ExportFilter
+com.sun.star.xml.sax.XDocumentHandler
+com.sun.star.xml.XMLImportFilter
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/Using_Automation_Objects_from_UNO#Properties_with_Arguments
+DESCR:ProUNO - Bridge - Using Automation Objects from UNO - Instantiation - Properties with Arguments
+REF:
+com.sun.star.bridge.oleautomation.PropertyPutArgument
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Command_Line_Registry_Tools#Component_Registration_Tool
+DESCR:WritingUNO - Command Line Registry Tools - Component Registration Tool
+REF:
+com.sun.star.loader.SharedLibrary
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Implementation
+DESCR:WritingUNO - Implementation
+REF:
+com.sun.star.frame.ProtocolHandler
+com.sun.star.lang.XInitialization
+com.sun.star.frame.XNotifyingDispatch
+com.sun.star.frame.XDispatchProvider
+com.sun.star.frame.Frame
+com.sun.star.frame.XFrame
+com.sun.star.frame.XDispatch
+com.sun.star.frame.XStatusListener
+TOPIC:
+com.sun.star.frame.ProtocolHandler
+com.sun.star.frame.XDispatchProvider
+
+LINK:Documentation/DevGuide/Forms/Data_Validation
+DESCR:Forms - Data Validation
+REF:
+com.sun.star.form.validation.XValidator
+com.sun.star.sdb.RowChangeAction
+com.sun.star.form.XUpdateListener
+com.sun.star.sdb.XRowSetApproveListener
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/The_Exporter#Exporter_Filtering
+DESCR:OfficeDev - The Exporter - Exporter Filtering
+REF:
+com.sun.star.xml.sax.XDocumentHandler
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/General_Structure
+DESCR:Basic - General Structure
+REF:
+com.sun.star.io.XInputStreamProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/FirstSteps/Using_Services#Using_Properties
+DESCR:FirstSteps - Using Services - Using Properties
+REF:
+com.sun.star.beans.XPropertySet
+com.sun.star.beans.XMultiPropertySet
+TOPIC:
+com.sun.star.beans.XPropertySet
+
+LINK:Documentation/DevGuide/Drawings/Storing
+DESCR:Drawings - Storing
+REF:
+com.sun.star.frame.XStorable
+TOPIC:
+com.sun.star.frame.XStorable
+
+LINK:Documentation/DevGuide/Charts/Prerequisites
+DESCR:Charts - Prerequisites
+REF:
+com.sun.star.lang.XServiceInfo
+com.sun.star.lang.XInitialization
+com.sun.star.lang.XServiceName
+com.sun.star.util.XRefreshable
+com.sun.star.chart.Diagram
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Writing_the_Filtering_Component#XImportFilter
+DESCR:OfficeDev - Writing the Filtering Component - XImportFilter
+REF:
+com.sun.star.xml.XMLImportFilter
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Data_Types
+DESCR:ProUNO - Data Types
+REF:
+TOPIC:
+com.sun.star.uno.TypeClass
+
+LINK:Documentation/DevGuide/UCB/Services_and_Interfaces
+DESCR:UCB - Services and Interfaces
+REF:
+com.sun.star.ucb.XContentProviderManager
+com.sun.star.ucb.XContent
+com.sun.star.ucb.Content
+com.sun.star.ucb.XContentCreator
+com.sun.star.ucb.XContentProvider
+com.sun.star.ucb.ContentProvider
+com.sun.star.container.XChild
+com.sun.star.ucb.XCommandProcessor2
+com.sun.star.beans.XPropertyContainer
+com.sun.star.ucb.XCommandProcessor
+com.sun.star.ucb.UniversalContentBroker
+TOPIC:
+com.sun.star.ucb.XContent
+com.sun.star.ucb.Content
+com.sun.star.ucb.XContentCreator
+com.sun.star.container.XChild
+com.sun.star.beans.XPropertyContainer
+com.sun.star.ucb.XCommandProcessor2
+com.sun.star.ucb.XCommandProcessor
+
+LINK:Documentation/DevGuide/Spreadsheets/Function_Descriptions
+DESCR:Spreadsheets - Function Descriptions
+REF:
+com.sun.star.sheet.XAddIn
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Creating_Frames_Manually#Frame_Creation
+DESCR:OfficeDev - Creating Frames Manually - Frame Creation
+REF:
+com.sun.star.frame.Frame
+TOPIC:
+com.sun.star.frame.Frame
+com.sun.star.frame.XFrame
+
+LINK:Documentation/DevGuide/GUI/Font-specific_Properties
+DESCR:GUI - Font-specific Properties
+REF:
+com.sun.star.awt.FontUnderline
+com.sun.star.awt.FontType
+com.sun.star.awt.FontPitch
+com.sun.star.awt.FontStrikeout
+com.sun.star.awt.FontFamily
+com.sun.star.awt.FontDescriptor
+com.sun.star.awt.FontSlant
+com.sun.star.awt.FontEmphasisMark
+com.sun.star.awt.CharSet
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/Accessibility_Tree
+DESCR:Accessibility - Accessibility Tree
+REF:
+com.sun.star.accessibility.XAccessibleContext
+com.sun.star.lang.IndexOutOfBoundsException
+com.sun.star.accessibility.XAccessible
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Indexed_Cells_and_Cell_Ranges
+DESCR:Text - Indexed Cells and Cell Ranges
+REF:
+com.sun.star.table.XCell
+com.sun.star.text.XText
+com.sun.star.table.XCellRange
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Defining_an_Exception
+DESCR:WritingUNO - Defining an Exception
+REF:
+com.sun.star.uno.Exception
+com.sun.star.uno.RuntimeException
+TOPIC:
+
+LINK:Documentation/DevGuide/AdvUNO/UNO_C++_Bridges#Binary_UNO_Interfaces
+DESCR:AdvUNO - UNO C++ Bridges - Binary UNO Interfaces
+REF:
+com.sun.star.uno.XInterface
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/The_XComponent_Interface
+DESCR:ProUNO - The XComponent Interface
+REF:
+com.sun.star.lang.XComponent
+com.sun.star.lang.XEventListener
+com.sun.star.lang.DisposedException
+com.sun.star.uno.RuntimeException
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/File_IO
+DESCR:Basic - File IO
+REF:
+com.sun.star.io.XActiveDataSource
+com.sun.star.io.XStream
+com.sun.star.io.XInputStream
+com.sun.star.io.XActiveDataSink
+com.sun.star.io.TextInputStream
+com.sun.star.ucb.SimpleFileAccess
+com.sun.star.io.XTextOutputStream
+com.sun.star.io.XTextInputStream
+com.sun.star.io.TextOutputStream
+com.sun.star.io.XOutputStream
+com.sun.star.ucb.XSimpleFileAccess2
+com.sun.star.ucb.XSimpleFileAccess
+com.sun.star.io.XSeekable
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Models#XViewDataSupplier
+DESCR:OfficeDev - Component - Models - XViewDataSupplier
+REF:
+com.sun.star.document.XViewDataSupplier
+com.sun.star.container.XIndexAccess
+com.sun.star.beans.PropertyValue
+TOPIC:
+com.sun.star.document.XViewDataSupplier
+
+LINK:Documentation/DevGuide/Charts/Accessing_Existing_Chart_Documents
+DESCR:Charts - Accessing Existing Chart Documents
+REF:
+com.sun.star.table.XTableChartsSupplier
+com.sun.star.container.XIndexAccess
+com.sun.star.drawing.XDrawPage
+com.sun.star.sheet.Spreadsheet
+TOPIC:
+
+LINK:Documentation/DevGuide/UCB/Accessing_a_UCB_Content
+DESCR:UCB - Accessing a UCB Content
+REF:
+com.sun.star.ucb.XContentProvider
+com.sun.star.ucb.XContentIdentifierFactory
+TOPIC:
+com.sun.star.ucb.XContentProvider
+com.sun.star.ucb.XContentIdentifierFactory
+
+LINK:Documentation/DevGuide/OfficeDev/Implementing_a_New_Locale#XTextConversion
+DESCR:OfficeDev - Implementing a New Locale - XTextConversion
+REF:
+com.sun.star.linguistic2.XConversionDictionary
+com.sun.star.i18n.XTextConversion
+com.sun.star.i18n.TextConversion
+TOPIC:
+com.sun.star.i18n.XTextConversion
+
+LINK:Documentation/DevGuide/OfficeDev/Overview_and_Using_the_API#XCalendar
+DESCR:OfficeDev - Overview and Using the API - XCalendar
+REF:
+com.sun.star.i18n.XLocaleData
+com.sun.star.i18n.Calendar
+com.sun.star.i18n.XCalendar
+TOPIC:
+com.sun.star.i18n.XCalendar
+
+LINK:Documentation/DevGuide/UCB/Copying%2C_Moving_and_Linking
+DESCR:UCB - Copying, Moving and Linking
+REF:
+com.sun.star.ucb.GlobalTransferCommandArgument
+com.sun.star.ucb.XCommandProcessor
+com.sun.star.ucb.UniversalContentBroker
+TOPIC:
+
+LINK:Documentation/DevGuide/Drawings/Handling_Drawing_Document_Files#Creating_and_Loading_Drawing_Documents
+DESCR:Drawings - Handling Drawing Document Files - Creating and Loading Drawing Documents
+REF:
+com.sun.star.frame.XComponentLoader
+com.sun.star.lang.XComponent
+com.sun.star.document.MediaDescriptor
+com.sun.star.frame.Desktop
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/Pattern_Field
+DESCR:GUI - Pattern Field
+REF:
+com.sun.star.awt.UnoControlPatternField
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Named_Table_Cells_in_Rows%2C_Columns_and_the_Table_Cursor
+DESCR:Text - Named Table Cells in Rows, Columns and the Table Cursor
+REF:
+com.sun.star.table.XTableColumns
+com.sun.star.text.TableColumnSeparator
+com.sun.star.table.XCell
+com.sun.star.text.TextTableRow
+com.sun.star.text.TextTableCursor
+com.sun.star.style.ParagraphProperties
+com.sun.star.beans.XPropertySet
+com.sun.star.text.XTextTableCursor
+com.sun.star.style.CharacterPropertiesAsian
+com.sun.star.style.CharacterProperties
+com.sun.star.table.XTableRows
+com.sun.star.style.GraphicLocation
+com.sun.star.container.XIndexAccess
+com.sun.star.text.XText
+com.sun.star.style.CharacterPropertiesComplex
+TOPIC:
+
+LINK:Documentation/DevGuide/Charts/3-D_Charts
+DESCR:Charts - 3-D Charts
+REF:
+com.sun.star.chart.BarDiagram
+com.sun.star.chart.Dim3DDiagram
+com.sun.star.chart.Chart3DBarProperties
+com.sun.star.chart.ChartSolidType
+TOPIC:
+com.sun.star.chart.Dim3DDiagram
+com.sun.star.chart.Chart3DBarProperties
+
+LINK:Documentation/DevGuide/OfficeDev/Frames#Components_in_Frames
+DESCR:OfficeDev - Frames - Components in Frames
+REF:
+com.sun.star.frame.Controller
+com.sun.star.frame.XController
+com.sun.star.lang.XComponent
+com.sun.star.awt.XWindow
+com.sun.star.frame.XDispatchProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Controllers#Document_Specific_Controller_Services
+DESCR:OfficeDev - Component - Controllers - Document Specific Controller Services
+REF:
+com.sun.star.frame.Controller
+com.sun.star.sheet.SpreadsheetViewSettings
+com.sun.star.lang.XServiceInfo
+com.sun.star.sdb.DataSourceBrowser
+com.sun.star.presentation.XPresentationSupplier
+com.sun.star.text.TextDocumentView
+com.sun.star.presentation.PresentationView
+com.sun.star.drawing.DrawingDocumentDrawView
+com.sun.star.sheet.SpreadsheetViewPane
+TOPIC:
+com.sun.star.frame.Controller
+com.sun.star.sdb.DataSourceBrowser
+com.sun.star.text.TextDocumentView
+com.sun.star.drawing.DrawingDocumentDrawView
+com.sun.star.sheet.SpreadsheetView
+
+LINK:Documentation/DevGuide/Text/Navigating#Locating_Text_Contents
+DESCR:Text - Navigating - Locating Text Contents
+REF:
+com.sun.star.text.XTextTablesSupplier
+com.sun.star.text.XTextSectionsSupplier
+com.sun.star.text.XBookmarksSupplier
+com.sun.star.text.XTextGraphicObjectsSupplier
+com.sun.star.text.XTextEmbeddedObjectsSupplier
+com.sun.star.text.XTextFramesSupplier
+com.sun.star.text.XDocumentIndexesSupplier
+com.sun.star.text.XTextFieldsSupplier
+com.sun.star.text.XReferenceMarksSupplier
+com.sun.star.text.XTextContent
+com.sun.star.text.XFootnotesSupplier
+com.sun.star.text.XEndnotesSupplier
+com.sun.star.document.XRedlinesSupplier
+TOPIC:
+com.sun.star.text.XTextContent
+
+LINK:Documentation/DevGuide/Spreadsheets/Handling_Array_Formulas
+DESCR:Spreadsheets - Handling Array Formulas
+REF:
+com.sun.star.table.XCell
+com.sun.star.sheet.XArrayFormulaRange
+TOPIC:
+com.sun.star.sheet.XArrayFormulaRange
+
+LINK:Documentation/DevGuide/OfficeDev/Filtering_Process
+DESCR:OfficeDev - Filtering Process
+REF:
+com.sun.star.frame.XStorable
+com.sun.star.document.FilterFactory
+com.sun.star.document.TypeDetection
+com.sun.star.frame.SynchronousFrameLoader
+com.sun.star.document.ExtendedTypeDetection
+com.sun.star.frame.XFrameLoader
+com.sun.star.document.ImportFilter
+com.sun.star.document.MediaDescriptor
+com.sun.star.frame.FrameLoader
+com.sun.star.document.ExportFilter
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/Events#Paint_Listener
+DESCR:GUI - Events - Paint Listener
+REF:
+com.sun.star.awt.XPaintListener
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Models_and_Views_for_Form_Controls
+DESCR:Forms - Models and Views for Form Controls
+REF:
+com.sun.star.form.component
+com.sun.star.awt.UnoControlModel
+com.sun.star.awt.UnoControl
+com.sun.star.form.control
+com.sun.star.awt
+TOPIC:
+com.sun.star.awt.UnoControlModel
+com.sun.star.awt.UnoControl
+
+LINK:Documentation/DevGuide/OfficeDev/Common_Application_Features#Clipboard
+DESCR:OfficeDev - Common Application Features - Clipboard
+REF:
+com.sun.star.datatransfer.clipboard.SystemClipboard
+com.sun.star.datatransfer.XTransferable
+com.sun.star.datatransfer.DataFlavor
+TOPIC:
+com.sun.star.datatransfer.clipboard.SystemClipboard
+com.sun.star.datatransfer.clipboard.XClipboard
+
+LINK:Documentation/DevGuide/Text/Shape_Objects_in_Text#Drawing_Shapes
+DESCR:Text - Shape Objects in Text - null - Drawing Shapes
+REF:
+com.sun.star.drawing.XDrawPageSupplier
+com.sun.star.text.Shape
+com.sun.star.text.XTextContent
+com.sun.star.drawing.Shape
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Custom_Path_Variables#Rules
+DESCR:OfficeDev - Custom Path Variables - Rules
+REF:
+com.sun.star.util.XStringSubstitution
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Control_Models_and_Shapes
+DESCR:Forms - Control Models and Shapes
+REF:
+com.sun.star.drawing.ControlShape
+TOPIC:
+com.sun.star.drawing.ControlShape
+
+LINK:Documentation/DevGuide/Database/Driver_Specifics#Driver_Specifics
+DESCR:Database - Driver Specifics - Driver Specifics
+REF:
+com.sun.star.sdbc.Driver
+com.sun.star.sdbcx.Driver
+TOPIC:
+com.sun.star.sdbcx.Driver
+
+LINK:Documentation/DevGuide/FirstSteps/Objects%2C_Interfaces%2C_and_Services#Services
+DESCR:FirstSteps - Objects, Interfaces, and Services - Services
+REF:
+com.sun.star.drawing.DrawingDocument
+com.sun.star.bridge.XUnoUrlResolver
+com.sun.star.document.OfficeDocument
+com.sun.star.beans.XPropertySet
+com.sun.star.beans.XMultiPropertySet
+com.sun.star.document.MediaDescriptor
+com.sun.star.frame.Desktop
+com.sun.star.frame.Frame
+com.sun.star.text.TextDocument
+TOPIC:
+
+LINK:Documentation/DevGuide/Charts/How_Add-Ins_Work
+DESCR:Charts - How Add-Ins Work
+REF:
+com.sun.star.lang.XInitialization
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.util.XRefreshable
+TOPIC:
+com.sun.star.util.XRefreshable
+
+LINK:Documentation/DevGuide/FirstSteps/Using_Services
+DESCR:FirstSteps - Using Services
+REF:
+com.sun.star.document.OfficeDocument
+com.sun.star.text.TextDocument
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Overview_and_Using_the_API#XLocaleData
+DESCR:OfficeDev - Overview and Using the API - XLocaleData
+REF:
+com.sun.star.i18n.XLocaleData
+TOPIC:
+com.sun.star.i18n.XLocaleData
+
+LINK:Documentation/DevGuide/Text/Link_Targets
+DESCR:Text - Link Targets
+REF:
+com.sun.star.beans.XPropertySet
+com.sun.star.document.XLinkTargetSupplier
+com.sun.star.container.XNameAccess
+com.sun.star.awt.XBitmap
+TOPIC:
+com.sun.star.document.XLinkTargetSupplier
+
+LINK:Documentation/DevGuide/WritingUNO/Defining_an_Interface
+DESCR:WritingUNO - Defining an Interface
+REF:
+com.sun.star.document.XFilter
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Function_Handling#Recently_Used_Functions
+DESCR:Spreadsheets - Function Handling - Recently Used Functions
+REF:
+com.sun.star.sheet.FunctionDescriptions
+com.sun.star.sheet.RecentFunctions
+com.sun.star.sheet.XRecentFunctions
+TOPIC:
+com.sun.star.sheet.RecentFunctions
+
+LINK:Documentation/DevGuide/Database/Connection_Pooling
+DESCR:Database - Connection Pooling
+REF:
+com.sun.star.sdb.Connection
+com.sun.star.sdbc.XDriverManager
+com.sun.star.sdbc.XConnection
+com.sun.star.sdbc.XPooledConnection
+com.sun.star.sdbc.ConnectionPool
+TOPIC:
+com.sun.star.sdbc.XPooledConnection
+com.sun.star.sdbc.ConnectionPool
+
+LINK:Documentation/DevGuide/ProUNO/Interfaces
+DESCR:ProUNO - Interfaces
+REF:
+com.sun.star.uno.XInterface
+com.sun.star.uno.RuntimeException
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/External_List_Sources
+DESCR:Forms - External List Sources
+REF:
+com.sun.star.form.binding.XListEntrySource
+com.sun.star.form.binding.XListEntrySink
+com.sun.star.table.CellRangeListSource
+com.sun.star.form.binding.ListEntrySource
+TOPIC:
+com.sun.star.form.binding.XListEntrySink
+com.sun.star.form.binding.XListEntrySource
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/Using_Automation_Objects_from_UNO#Instantiation
+DESCR:ProUNO - Bridge - Using Automation Objects from UNO - Instantiation
+REF:
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.bridge.oleautomation.Factory
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Overview_and_Using_the_API#XTextConversion
+DESCR:OfficeDev - Overview and Using the API - XTextConversion
+REF:
+com.sun.star.i18n.XTextConversion
+TOPIC:
+com.sun.star.i18n.XTextConversion
+
+LINK:Documentation/DevGuide/GUI/Text_Field
+DESCR:GUI - Text Field
+REF:
+com.sun.star.awt.UnoControlEdit
+com.sun.star.awt.LineEndFormat
+com.sun.star.awt.XTextComponent
+com.sun.star.awt.UnoControlEditModel
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Services#Referencing_other_Services
+DESCR:ProUNO - Services - Referencing other Services
+REF:
+com.sun.star.text.TextContent
+com.sun.star.text.Paragraph
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleEventBroadcaster
+DESCR:Accessibility - XAccessibleEventBroadcaster
+REF:
+com.sun.star.accessibility.XAccessibleEventBroadcaster
+com.sun.star.lang.DisposedException
+com.sun.star.lang.IndexOutOfBoundsException
+TOPIC:
+com.sun.star.accessibility.XAccessibleEventBroadcaster
+
+LINK:Documentation/DevGuide/AdvUNO/UNO_Reflection_API#Introspection
+DESCR:AdvUNO - UNO Reflection API - CoreReflection Service - Introspection
+REF:
+com.sun.star.beans.XPropertySet
+com.sun.star.container.XIndexAccess
+com.sun.star.container.XNameAccess
+com.sun.star.beans.XIntrospection
+com.sun.star.beans.XIntrospectionAccess
+com.sun.star.beans.Introspection
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/XComponent#Disposing_of_an_XComponent
+DESCR:WritingUNO - XComponent - Disposing of an XComponent
+REF:
+com.sun.star.lang.DisposedException
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Basic/Getting_Information_about_UNO_Objects#Inspecting_interfaces_during_debugging
+DESCR:ProUNO - Basic - Getting Information about UNO Objects - Inspecting interfaces during debugging
+REF:
+com.sun.star.container.XElementAccess
+com.sun.star.container.XEnumerationAccess
+com.sun.star.container.XSet
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Multiple_Operations
+DESCR:Spreadsheets - Multiple Operations
+REF:
+TOPIC:
+com.sun.star.sheet.XMultipleOperation
+
+LINK:Documentation/DevGuide/Basic/HorizontalVertical_Line
+DESCR:Basic - HorizontalVertical Line
+REF:
+com.sun.star.awt.UnoControlFixedLine
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/C++/Class_Definition_with_Helper_Template_Classes
+DESCR:WritingUNO - C++ - Class Definition with Helper Template Classes
+REF:
+com.sun.star.lang.XServiceInfo
+com.sun.star.lang.XComponent
+com.sun.star.lang.XInitialization
+com.sun.star.uno.XInterface
+com.sun.star.uno.XWeak
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Using_Dialogs_in_Components#Accept_events_created_by_dialog_controls
+DESCR:WritingUNO - Using Dialogs in Components - Accept events created by dialog controls
+REF:
+com.sun.star.test.XTestDialogHandler
+com.sun.star.awt.XActionListener
+com.sun.star.awt.ActionEvent
+com.sun.star.awt.XDialogEventHandler
+com.sun.star.lang.XTypeProvider
+com.sun.star.beans.Introspection
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/C++/C++_Component
+DESCR:WritingUNO - C++ - C++ Component
+REF:
+com.sun.star.lang.XInitialization
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Frames#Frame_Actions
+DESCR:OfficeDev - Component - Frames - XFrame - Frame Actions
+REF:
+com.sun.star.frame.XComponentLoader
+com.sun.star.frame.FrameActionEvent
+com.sun.star.awt.XWindow
+com.sun.star.frame.XFrameLoader
+com.sun.star.frame.XFrameActionListener
+com.sun.star.frame.XSynchronousFrameLoader
+com.sun.star.frame.Desktop
+com.sun.star.frame.FrameLoader
+com.sun.star.frame.XFrame
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/Currency_Field
+DESCR:Basic - Currency Field
+REF:
+com.sun.star.awt.UnoControlCurrencyField
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Jobs/Implementation
+DESCR:WritingUNO - Jobs - Implementation
+REF:
+com.sun.star.lang.XComponent
+com.sun.star.awt.Toolkit
+com.sun.star.task.Job
+com.sun.star.task.AsyncJob
+com.sun.star.util.XCloseable
+TOPIC:
+com.sun.star.task.XAsyncJob
+com.sun.star.task.XJob
+com.sun.star.task.Job
+com.sun.star.task.AsyncJob
+
+LINK:Documentation/DevGuide/UCB/Preconfigured_UCBs
+DESCR:UCB - Preconfigured UCBs
+REF:
+com.sun.star.ucb.UniversalContentBroker
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Modules
+DESCR:ProUNO - Modules
+REF:
+com.sun.star.table
+com.sun.star.sheet
+com.sun.star.document
+com.sun.star.text
+com.sun.star.style
+com.sun.star.drawing
+com.sun.star.uno
+TOPIC:
+
+LINK:Documentation/DevGuide/Scripting/How_the_Scripting_Framework_Works
+DESCR:Scripting - How the Scripting Framework Works
+REF:
+com.sun.star.script.provider.LanguageScriptProvider
+com.sun.star.script.provider.XScript
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Example:_Adding_a_New_Spreadsheet
+DESCR:Spreadsheets - Example: Adding a New Spreadsheet
+REF:
+com.sun.star.lang.XComponent
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Intercepting_Context_Menus#Querying_a_Menu_Structure
+DESCR:WritingUNO - Intercepting Context Menus - Writing an Interceptor - Querying a Menu Structure
+REF:
+com.sun.star.lang.XServiceInfo
+com.sun.star.beans.XPropertySet
+com.sun.star.ui.ActionTriggerContainer
+com.sun.star.ui.ActionTriggerSeparatorType
+com.sun.star.ui.ActionTriggerSeparator
+com.sun.star.ui.ActionTrigger
+com.sun.star.container.XIndexContainer
+com.sun.star.awt.XBitmap
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Using_Prepared_Statements#Supplying_Values_for_PreparedStatement_Parameters
+DESCR:Database - Using Prepared Statements - Supplying Values for PreparedStatement Parameters
+REF:
+com.sun.star.sdbc.XParameters
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Driver_Statements#PreparedStatement
+DESCR:Database - Driver Statements - PreparedStatement
+REF:
+com.sun.star.sdbc.XParameters
+com.sun.star.sdbc.XResultSetMetaDataSupplier
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Settings
+DESCR:Spreadsheets - Settings
+REF:
+com.sun.star.sheet.GlobalSheetSettings
+com.sun.star.beans.XPropertySet
+TOPIC:
+com.sun.star.sheet.GlobalSheetSettings
+
+LINK:Documentation/DevGuide/WritingUNO/XWeak
+DESCR:WritingUNO - XWeak
+REF:
+TOPIC:
+com.sun.star.uno.XWeak
+
+LINK:Documentation/DevGuide/GUI/Graphical_User_Interfaces#Basic_Concepts
+DESCR:GUI - Graphical User Interfaces - Basic Concepts
+REF:
+com.sun.star.awt
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/Events#Focus_Listener
+DESCR:GUI - Events - Focus Listener
+REF:
+com.sun.star.awt.XFocusListener
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Loadable_Forms
+DESCR:Forms - Loadable Forms
+REF:
+com.sun.star.sdbc.XRowSetListener
+com.sun.star.form.XLoadable
+com.sun.star.form.XLoadListener
+com.sun.star.sdbc.XRowSet
+TOPIC:
+com.sun.star.form.XLoadable
+com.sun.star.form.XLoadListener
+
+LINK:Documentation/DevGuide/Database/The_SDBC_Driver_for_dBase
+DESCR:Database - The SDBC Driver for dBase
+REF:
+com.sun.star.sdbcx.Driver
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Graphic_Objects
+DESCR:Text - Graphic Objects
+REF:
+com.sun.star.awt.Size
+com.sun.star.text.BaseFrame
+com.sun.star.drawing.ColorMode
+com.sun.star.text.TextGraphicObject
+com.sun.star.drawing.PointSequenceSequence
+com.sun.star.container.XIndexContainer
+com.sun.star.text.GraphicCrop
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Overall_Document_Features#Numbering_Styles
+DESCR:Text - Overall Document Features - Styles - Numbering Styles
+REF:
+com.sun.star.text.NumberingStyle
+com.sun.star.lang.XMultiServiceFactory
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/PreparedStatement_From_DataSource_Queries
+DESCR:Database - PreparedStatement From DataSource Queries
+REF:
+com.sun.star.sdb.XCommandPreparation
+com.sun.star.sdb.DataSource
+com.sun.star.sdb.CommandType
+TOPIC:
+com.sun.star.sdb.XCommandPreparation
+com.sun.star.sdb.CommandType
+
+LINK:Documentation/DevGuide/Accessibility/Overview
+DESCR:Accessibility - Overview
+REF:
+com.sun.star.awt.XExtendedToolkit
+com.sun.star.awt.XWindow
+com.sun.star.accessibility.XAccessibleContext
+com.sun.star.accessibility.XAccessible
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Settings#Creating_Document_Settings
+DESCR:Text - Settings - Creating Document Settings
+REF:
+com.sun.star.document.Settings
+TOPIC:
+
+LINK:Documentation/DevGuide/FirstSteps/Any
+DESCR:FirstSteps - Any
+REF:
+com.sun.star.beans.PropertyValue
+TOPIC:
+
+LINK:Documentation/DevGuide/AdvUNO/Implementing_UNO_Language_Bindings#UNO_Bridge
+DESCR:AdvUNO - Implementing UNO Language Bindings - Overview of Language Bindings and Bridges - UNO Bridge
+REF:
+com.sun.star.reflection.CoreReflection
+com.sun.star.script.XInvocation
+com.sun.star.script.Converter
+com.sun.star.script.Invocation
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Data_Aware_Controls
+DESCR:Forms - Data Aware Controls
+REF:
+com.sun.star.form.DataAwareControlModel
+TOPIC:
+com.sun.star.form.DataAwareControlModel
+
+LINK:Documentation/DevGuide/Database/Queries
+DESCR:Database - Queries
+REF:
+com.sun.star.sdb.XCommandPreparation
+com.sun.star.sdb.RowSet
+com.sun.star.sdb.QueryDefinition
+TOPIC:
+com.sun.star.sdb.QueryDefinition
+
+LINK:Documentation/DevGuide/ProUNO/Basic/Exception_Handling
+DESCR:ProUNO - Basic - Exception Handling
+REF:
+com.sun.star.container.XNameAccess
+TOPIC:
+com.sun.star.uno.Exception
+com.sun.star.uno.RuntimeException
+
+LINK:Documentation/DevGuide/ProUNO/Differences_Between_the_Lifetime_of_C++_and_Java_Objects
+DESCR:ProUNO - Differences Between the Lifetime of C++ and Java Objects
+REF:
+com.sun.star.uno.XInterface
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Shape_Objects_in_Text#Base_Frames
+DESCR:Text - Shape Objects in Text - Base Frames
+REF:
+com.sun.star.awt.Size
+com.sun.star.text.TextEmbeddedObjects
+com.sun.star.beans.XPropertySet
+com.sun.star.text.XTextFrame
+com.sun.star.container.XNameAccess
+com.sun.star.text.XTextEmbeddedObjectsSupplier
+com.sun.star.text.TextContent
+com.sun.star.text.XTextFramesSupplier
+com.sun.star.table.ShadowFormat
+com.sun.star.container.XIndexAccess
+com.sun.star.text.TextFrames
+com.sun.star.document.XEventsSupplier
+com.sun.star.text.TextFrame
+com.sun.star.drawing.XShape
+com.sun.star.text.TextEmbeddedObject
+com.sun.star.container.XContainer
+com.sun.star.text.XTextGraphicObjectsSupplier
+com.sun.star.text.RelOrientation
+com.sun.star.text.TextGraphicObjects
+com.sun.star.text.BaseFrame
+com.sun.star.container.XNamed
+com.sun.star.style.GraphicLocation
+com.sun.star.text.TextGraphicObject
+com.sun.star.table.BorderLine
+com.sun.star.text.BaseFrameProperties
+com.sun.star.text.HoriOrientation
+TOPIC:
+
+LINK:Documentation/DevGuide/Charts/Common_Parts_of_all_Chart_Types#Data_Series_and_Data_Points
+DESCR:Charts - Common Parts of all Chart Types - Data Series and Data Points
+REF:
+com.sun.star.chart.XYDiagram
+com.sun.star.chart.XDiagram
+com.sun.star.chart.LineDiagram
+com.sun.star.drawing.FillProperties
+com.sun.star.drawing.LineProperties
+com.sun.star.style.CharacterProperties
+TOPIC:
+
+LINK:Documentation/DevGuide/Drawings/Grouping%2C_Combining_and_Binding
+DESCR:Drawings - Grouping, Combining and Binding
+REF:
+com.sun.star.drawing.XShapeBinder
+com.sun.star.drawing.GroupShape
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.drawing.ShapeCollection
+com.sun.star.drawing.XShapeGroup
+com.sun.star.drawing.XShapeGrouper
+com.sun.star.drawing.XShapeCombiner
+com.sun.star.drawing.XShape
+com.sun.star.drawing.Shape
+com.sun.star.drawing.XShapes
+TOPIC:
+com.sun.star.drawing.GroupShape
+com.sun.star.drawing.ShapeCollection
+com.sun.star.drawing.XShapeGrouper
+com.sun.star.drawing.XShapeCombiner
+
+LINK:Documentation/DevGuide/GUI/Common_Workflow_to_add_Controls
+DESCR:GUI - Common Workflow to add Controls
+REF:
+com.sun.star.beans.XMultiPropertySet
+TOPIC:
+
+LINK:Documentation/DevGuide/FirstSteps/Common_Types#Enum_Types_and_Groups_of_Constants
+DESCR:FirstSteps - Common Types - Enum Types and Groups of Constants
+REF:
+com.sun.star.table.CellVertJustify
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/View_Settings
+DESCR:Spreadsheets - View Settings
+REF:
+com.sun.star.sheet.SpreadsheetViewSettings
+com.sun.star.beans.XPropertySet
+TOPIC:
+com.sun.star.sheet.SpreadsheetViewSettings
+
+LINK:Documentation/DevGuide/OfficeDev/Common_Application_Features#Becoming_a_Clipboard_Viewer
+DESCR:OfficeDev - Common Application Features - Clipboard - Using the Clipboard - Becoming a Clipboard Viewer
+REF:
+com.sun.star.datatransfer.clipboard.XClipboardListener
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Window_Interfaces#XWindowPeer
+DESCR:OfficeDev - Component - Window Interfaces - XWindowPeer
+REF:
+com.sun.star.awt.XWindowPeer
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Cell_Area_Links
+DESCR:Spreadsheets - Cell Area Links
+REF:
+com.sun.star.sheet.XAreaLink
+com.sun.star.beans.XPropertySet
+com.sun.star.sheet.XAreaLinks
+com.sun.star.sheet.CellAreaLink
+com.sun.star.table.CellAddress
+com.sun.star.util.XRefreshable
+TOPIC:
+com.sun.star.sheet.XAreaLink
+com.sun.star.sheet.XAreaLinks
+
+LINK:Documentation/DevGuide/ProUNO/Properties
+DESCR:ProUNO - Properties
+REF:
+com.sun.star.beans.XPropertyAccess
+com.sun.star.beans.XPropertyState
+com.sun.star.beans.PropertyAttribute
+com.sun.star.beans.XPropertySet
+com.sun.star.view.PrintOptions
+com.sun.star.beans.XPropertySetInfo
+com.sun.star.beans.XFastPropertySet
+com.sun.star.beans.PropertyValue
+com.sun.star.beans.XMultiPropertySet
+com.sun.star.document.MediaDescriptor
+com.sun.star.beans.XPropertyContainer
+com.sun.star.beans.XPropertyChangeListener
+TOPIC:
+com.sun.star.beans.XPropertyState
+com.sun.star.beans.XPropertySet
+com.sun.star.beans.XPropertySetInfo
+com.sun.star.beans.XFastPropertySet
+com.sun.star.beans.XMultiPropertySet
+
+LINK:Documentation/DevGuide/Drawings/Layer_Handling
+DESCR:Drawings - Layer Handling
+REF:
+com.sun.star.drawing.XLayerSupplier
+com.sun.star.drawing.DrawingDocument
+com.sun.star.drawing.XLayerManager
+TOPIC:
+com.sun.star.drawing.XLayerManager
+
+LINK:Documentation/DevGuide/AdvUNO/UNO_Reflection_API#Invocation
+DESCR:AdvUNO - UNO Reflection API - CoreReflection Service - Invocation
+REF:
+com.sun.star.lang.XSingleServiceFactory
+com.sun.star.script.Converter
+com.sun.star.script.XInvocation
+com.sun.star.script.InvocationInfo
+com.sun.star.script.XInvocation2
+com.sun.star.script.Invocation
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Implementing_a_Hyphenator
+DESCR:OfficeDev - Implementing a Hyphenator
+REF:
+com.sun.star.lang.XServiceInfo
+com.sun.star.linguistic2.XHyphenator
+com.sun.star.lang.XComponent
+com.sun.star.linguistic2.XLinguServiceEventBroadcaster
+com.sun.star.linguistic2.XSpellChecker
+com.sun.star.lang.XInitialization
+com.sun.star.lang.XServiceDisplayName
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Text_Documents
+DESCR:Text - Text Documents
+REF:
+TOPIC:
+com.sun.star.text.TextDocument
+
+LINK:Documentation/DevGuide/Spreadsheets/Modifying_a_DataPilot_Table
+DESCR:Spreadsheets - Modifying a DataPilot Table
+REF:
+com.sun.star.sheet.DataPilotTable
+com.sun.star.sheet.XDataPilotTable
+com.sun.star.container.XNameAccess
+com.sun.star.sheet.XDataPilotDescriptor
+com.sun.star.sheet.DataPilotTables
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleContext
+DESCR:Accessibility - XAccessibleContext
+REF:
+com.sun.star.accessibility.XAccessibleContext
+com.sun.star.accessibility.AccessibleRole
+com.sun.star.accessibility.XAccessible
+TOPIC:
+com.sun.star.accessibility.XAccessibleContext
+
+LINK:Documentation/DevGuide/Spreadsheets/Other_Table_Operations#Scenarios
+DESCR:Spreadsheets - Other Table Operations - Scenarios
+REF:
+com.sun.star.sheet.Spreadsheet
+com.sun.star.sheet.Scenarios
+com.sun.star.sheet.XScenario
+com.sun.star.sheet.ScenariosEnumeration
+com.sun.star.sheet.XScenariosSupplier
+com.sun.star.sheet.XScenarios
+TOPIC:
+com.sun.star.sheet.XScenarios
+
+LINK:Documentation/DevGuide/FirstSteps/Common_Mechanisms_for_Text%2C_Tables_and_Drawings
+DESCR:FirstSteps - Common Mechanisms for Text, Tables and Drawings
+REF:
+com.sun.star.table.XCell
+com.sun.star.drawing.LineShape
+com.sun.star.style.ParagraphProperties
+com.sun.star.text.XTextRange
+com.sun.star.text.XSimpleText
+com.sun.star.drawing.TextShape
+com.sun.star.table.CellProperties
+com.sun.star.drawing.TextProperties
+com.sun.star.drawing.LineProperties
+com.sun.star.drawing.PolyPolygonBezierShape
+com.sun.star.style.CharacterProperties
+com.sun.star.drawing.ConnectorShape
+com.sun.star.drawing.Shape
+com.sun.star.drawing.Text
+com.sun.star.table.XCellRange
+com.sun.star.drawing.RectangleShape
+com.sun.star.drawing.CaptionShape
+com.sun.star.drawing.MeasureShape
+com.sun.star.drawing.FillProperties
+com.sun.star.drawing.XShape
+com.sun.star.drawing.EllipseShape
+com.sun.star.text.TextTableCursor
+com.sun.star.drawing.PolyPolygonBezierDescriptor
+com.sun.star.drawing.PolyPolygonShape
+com.sun.star.drawing.RotationDescriptor
+com.sun.star.sheet.SheetCellCursor
+com.sun.star.drawing.ShadowProperties
+com.sun.star.drawing.ClosedBezierShape
+com.sun.star.presentation.Shape
+com.sun.star.text.XText
+com.sun.star.text.TextTable
+com.sun.star.drawing.PolyLineShape
+TOPIC:
+
+LINK:Documentation/DevGuide/Drawings/Printing_Drawing_Documents#Printer_and_Print_Job_Settings
+DESCR:Drawings - Printing Drawing Documents - Printer and Print Job Settings
+REF:
+com.sun.star.awt.Size
+com.sun.star.view.PaperOrientation
+com.sun.star.view.PrintOptions
+com.sun.star.view.PrinterDescriptor
+com.sun.star.view.XPrintable
+com.sun.star.view.PaperFormat
+TOPIC:
+com.sun.star.view.PrintOptions
+com.sun.star.view.PrinterDescriptor
+com.sun.star.view.XPrintable
+
+LINK:Documentation/DevGuide/JavaBean/OfficeConnection_Interface
+DESCR:JavaBean - OfficeConnection Interface
+REF:
+com.sun.star.uno.XComponentContext
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleEditableText
+DESCR:Accessibility - XAccessibleEditableText
+REF:
+com.sun.star.accessibility.XAccessibleEditableText
+com.sun.star.accessibility.XAccessibleText
+TOPIC:
+com.sun.star.accessibility.XAccessibleEditableText
+
+LINK:Documentation/DevGuide/ProUNO/Basic/Mapping_of_Simple_Types
+DESCR:ProUNO - Basic - Mapping of Simple Types
+REF:
+com.sun.star.reflection.XIdlClass
+com.sun.star.container.XNameContainer
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/Creating_Dialogs_at_Runtime
+DESCR:Basic - Creating Dialogs at Runtime
+REF:
+com.sun.star.awt.XDialog
+com.sun.star.awt.UnoControlDialogModel
+com.sun.star.awt.XDialogProvider
+com.sun.star.awt.UnoControlDialog
+com.sun.star.awt.XActionListener
+com.sun.star.beans.XPropertySet
+com.sun.star.lang.XEventListener
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.task.XJobExecutor
+com.sun.star.container.XNameContainer
+com.sun.star.beans.XMultiPropertySet
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Filtering_Process#FrameLoader
+DESCR:OfficeDev - Filtering Process - FrameLoader
+REF:
+com.sun.star.frame.Controller
+com.sun.star.frame.SynchronousFrameLoader
+com.sun.star.document.OfficeDocument
+com.sun.star.awt.XWindow
+com.sun.star.frame.FrameLoaderFactory
+com.sun.star.frame.FrameLoader
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/Scroll_Bar
+DESCR:GUI - Scroll Bar
+REF:
+com.sun.star.awt.UnoControlScrollBar
+com.sun.star.awt.XAdjustmentListener
+com.sun.star.awt.UnoControlScrollBarModel
+com.sun.star.awt.XScrollBar
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Number_Formats
+DESCR:OfficeDev - Number Formats
+REF:
+TOPIC:
+com.sun.star.util.XNumberFormatTypes
+com.sun.star.util.XNumberFormatter
+com.sun.star.util.XNumberFormatPreviewer
+com.sun.star.util.XNumberFormats
+com.sun.star.util.NumberFormats
+com.sun.star.util.NumberFormatter
+com.sun.star.util.XNumberFormatsSupplier
+
+LINK:Documentation/DevGuide/WritingUNO/Providing_a_Single_Factory_Using_a_Helper_Method
+DESCR:WritingUNO - Providing a Single Factory Using a Helper Method
+REF:
+com.sun.star.uno.XComponentContext
+com.sun.star.lang.XMultiServiceFactory
+TOPIC:
+
+LINK:Documentation/DevGuide/Config/Configuration_Management#Architecture
+DESCR:Config - Configuration Management - Architecture
+REF:
+com.sun.star.beans.NamedValue
+com.sun.star.beans.PropertyValue
+com.sun.star.configuration.ConfigurationProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Navigating#Cursors
+DESCR:Text - Navigating - Cursors
+REF:
+com.sun.star.text.TextViewCursor
+com.sun.star.text.TextCursor
+com.sun.star.text.TextLayoutCursor
+com.sun.star.text.XTextRange
+com.sun.star.text.XTextCursor
+TOPIC:
+com.sun.star.text.TextCursor
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Frames#XFramesSupplier
+DESCR:OfficeDev - Component - Frames - XFramesSupplier
+REF:
+com.sun.star.frame.XFrames
+com.sun.star.container.XIndexAccess
+com.sun.star.frame.XFramesSupplier
+com.sun.star.frame.XFrame
+TOPIC:
+com.sun.star.frame.XFramesSupplier
+
+LINK:Documentation/DevGuide/Spreadsheets/Other_Table_Operations#Data_Validation
+DESCR:Spreadsheets - Other Table Operations - Data Validation
+REF:
+com.sun.star.sheet.ValidationAlertStyle
+com.sun.star.sheet.XSheetCondition
+com.sun.star.beans.XPropertySet
+com.sun.star.sheet.ValidationType
+com.sun.star.sheet.XSpreadsheet
+com.sun.star.sheet.TableValidation
+TOPIC:
+com.sun.star.sheet.TableValidation
+
+LINK:Documentation/DevGuide/OfficeDev/Overview_and_Using_the_API#XIndexEntrySupplier
+DESCR:OfficeDev - Overview and Using the API - XIndexEntrySupplier
+REF:
+com.sun.star.i18n.XIndexEntrySupplier
+TOPIC:
+com.sun.star.i18n.XIndexEntrySupplier
+
+LINK:Documentation/DevGuide/Spreadsheets/Cell_Cursor
+DESCR:Spreadsheets - Cell Cursor
+REF:
+com.sun.star.sheet.XSheetCellRange
+com.sun.star.sheet.XSpreadsheet
+com.sun.star.table.CellCursor
+com.sun.star.sheet.XSheetCellCursor
+com.sun.star.sheet.SheetCellCursor
+TOPIC:
+com.sun.star.sheet.XSheetCellCursor
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Window_Interfaces#XWindow
+DESCR:OfficeDev - Component - Window Interfaces - XWindow
+REF:
+com.sun.star.awt.XWindowListener
+com.sun.star.awt.WindowEvent
+com.sun.star.awt.XWindow
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/Image_Control
+DESCR:GUI - Image Control
+REF:
+com.sun.star.awt.UnoControlImageControlModel
+com.sun.star.awt.UnoControlImageControl
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/List_Box
+DESCR:GUI - List Box
+REF:
+com.sun.star.awt.UnoControlListBox
+com.sun.star.awt.XItemListener
+com.sun.star.awt.XActionListener
+com.sun.star.awt.UnoControlListBoxModel
+com.sun.star.awt.XListBox
+TOPIC:
+
+LINK:Documentation/DevGuide/Charts/Common_Parts_of_all_Chart_Types#Axis
+DESCR:Charts - Common Parts of all Chart Types - Axis
+REF:
+com.sun.star.chart.BarDiagram
+com.sun.star.chart.ChartTwoAxisXSupplier
+com.sun.star.chart.PieDiagram
+com.sun.star.chart.XYDiagram
+com.sun.star.drawing.LineProperties
+com.sun.star.style.CharacterProperties
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/Using_Automation_Objects_from_UNO#Named_Arguments
+DESCR:ProUNO - Bridge - Using Automation Objects from UNO - Instantiation - Named Arguments
+REF:
+com.sun.star.script.XInvocation
+com.sun.star.bridge.oleautomation.NamedArgument
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Filtering
+DESCR:Spreadsheets - Filtering
+REF:
+com.sun.star.beans.XPropertySet
+com.sun.star.sheet.SheetFilterDescriptor
+com.sun.star.sheet.XSheetFilterDescriptor
+com.sun.star.sheet.TableFilterField
+com.sun.star.sheet.XSheetFilterableEx
+com.sun.star.sheet.XSheetFilterable
+TOPIC:
+com.sun.star.sheet.SheetFilterDescriptor
+com.sun.star.sheet.XSheetFilterableEx
+com.sun.star.sheet.XSheetFilterable
+
+LINK:Documentation/DevGuide/OfficeDev/Closing_Documents#Reacting_Upon_Closing
+DESCR:OfficeDev - Closing Documents - Reacting Upon Closing
+REF:
+com.sun.star.util.XCloseListener
+com.sun.star.lang.XComponent
+com.sun.star.lang.XEventListener
+com.sun.star.util.CloseVetoException
+com.sun.star.util.XCloseable
+com.sun.star.uno.XWeak
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/C++/Implementing_without_Helpers#XInterface_Implementation
+DESCR:WritingUNO - C++ - Implementing without Helpers - XInterface Implementation
+REF:
+com.sun.star.uno.XInterface
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Dispatch_Process#Dispatching_a_Command
+DESCR:OfficeDev - Dispatch Process - Dispatching a Command
+REF:
+com.sun.star.beans.PropertyValue
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Spreadsheet#Naming
+DESCR:Spreadsheets - Spreadsheet - Naming
+REF:
+com.sun.star.container.XNamed
+com.sun.star.sheet.CellInsertMode
+com.sun.star.sheet.XCellRangeMovement
+com.sun.star.sheet.CellDeleteMode
+TOPIC:
+
+LINK:Documentation/DevGuide/FirstSteps/Element_Access#Enumeration_Access
+DESCR:FirstSteps - Element Access - Enumeration Access
+REF:
+com.sun.star.sheet.XCellRangesQuery
+com.sun.star.sheet.XSheetCellRanges
+com.sun.star.sheet.CellFlags
+com.sun.star.container.XEnumerationAccess
+com.sun.star.container.XEnumeration
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Path_Settings#Accessing_Path_Settings
+DESCR:OfficeDev - Path Settings - Accessing Path Settings
+REF:
+com.sun.star.lang.IllegalArgumentException
+com.sun.star.beans.XPropertySet
+com.sun.star.beans.XFastPropertySet
+com.sun.star.beans.XMultiPropertySet
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/DataPilot_Sources
+DESCR:Spreadsheets - DataPilot Sources
+REF:
+com.sun.star.sheet.XLevelsSupplier
+com.sun.star.sheet.XHierarchiesSupplier
+com.sun.star.sheet.DataPilotSourceHierarchies
+com.sun.star.sheet.DataPilotSource
+com.sun.star.sheet.XMembersSupplier
+com.sun.star.sheet.DataPilotSourceDimensions
+com.sun.star.container.XNameAccess
+com.sun.star.sheet.DataPilotSourceLevels
+com.sun.star.sheet.DataPilotSourceMembers
+com.sun.star.sheet.XDimensionsSupplier
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/Automation_Objects_with_UNO_Interfaces#Requirements
+DESCR:ProUNO - Bridge - Automation Objects with UNO Interfaces - Requirements
+REF:
+com.sun.star.uno.XInterface
+com.sun.star.script.XInvocation
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/List_Box
+DESCR:Basic - List Box
+REF:
+com.sun.star.awt.UnoControlListBox
+com.sun.star.awt.XListBox
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Jobs/Configuration
+DESCR:WritingUNO - Jobs - Configuration
+REF:
+com.sun.star.task.Job
+com.sun.star.task.JobExecutor
+com.sun.star.task.AsyncJob
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Resolving_Path_Variables
+DESCR:OfficeDev - Resolving Path Variables
+REF:
+com.sun.star.container.NoSuchElementException
+com.sun.star.util.XStringSubstitution
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Spreadsheet_Services_-_Overview
+DESCR:Spreadsheets - Spreadsheet Services - Overview
+REF:
+com.sun.star.sheet.SheetCell
+com.sun.star.sheet.SheetCellRanges
+com.sun.star.sheet.SheetCellRange
+com.sun.star.sheet.Spreadsheet
+com.sun.star.table.TableColumn
+com.sun.star.table.TableRow
+TOPIC:
+com.sun.star.sheet.SheetCell
+com.sun.star.sheet.SheetCellRanges
+com.sun.star.sheet.SheetCellRange
+com.sun.star.sheet.Spreadsheet
+com.sun.star.table.TableColumn
+com.sun.star.table.TableRow
+
+LINK:Documentation/DevGuide/Extensions/File_Format#Extension_Tooltip_Description
+DESCR:Extensions - File Format - Extension Tooltip Description
+REF:
+com.sun.star.util.MacroExpander
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Using_SDBCX_to_Access_the_Database_Design#The_Extension_Layer_SDBCX
+DESCR:Database - Using SDBCX to Access the Database Design - The Extension Layer SDBCX
+REF:
+com.sun.star.sdbcx.Container
+com.sun.star.container.XNameAccess
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Filtering_Process#MediaDescriptor
+DESCR:OfficeDev - Filtering Process - MediaDescriptor
+REF:
+com.sun.star.beans.PropertyValue
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Properties_of_a_Filter
+DESCR:OfficeDev - Properties of a Filter
+REF:
+com.sun.star.document.FilterFactory
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.beans.PropertyValue
+com.sun.star.container.XNameAccess
+com.sun.star.document.ImportFilter
+com.sun.star.document.ExportFilter
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/DataPilot_Tables
+DESCR:Spreadsheets - DataPilot Tables
+REF:
+com.sun.star.sheet.DataPilotSource
+com.sun.star.sheet.XDataPilotTables
+com.sun.star.sheet.XDataPilotTablesSupplier
+com.sun.star.sheet.DataPilotTables
+TOPIC:
+com.sun.star.sheet.DataPilotTables
+
+LINK:Documentation/DevGuide/Spreadsheets/Overall_Document_Features#Cell_Styles
+DESCR:Spreadsheets - Overall Document Features - Styles - Cell Styles
+REF:
+com.sun.star.container.XNamed
+com.sun.star.sheet.XSpreadsheetDocument
+com.sun.star.sheet.TableCellStyle
+TOPIC:
+com.sun.star.sheet.TableCellStyle
+
+LINK:Documentation/DevGuide/Basic/Programming_Dialogs_and_Dialog_Controls
+DESCR:Basic - Programming Dialogs and Dialog Controls
+REF:
+com.sun.star.awt.XWindow
+com.sun.star.beans.XPropertySet
+com.sun.star.awt.UnoControl
+com.sun.star.awt.UnoControlModel
+com.sun.star.awt.UnoControlEditModel
+com.sun.star.awt.XControl
+com.sun.star.awt.XView
+com.sun.star.awt
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Cells
+DESCR:Spreadsheets - Cells
+REF:
+com.sun.star.sheet.SheetCell
+com.sun.star.table.Cell
+TOPIC:
+com.sun.star.sheet.SheetCell
+
+LINK:Documentation/DevGuide/AdvUNO/Advanced_UNO#Java
+DESCR:AdvUNO - Advanced UNO - Choosing an Implementation Language - Supported Programming Environments - Java
+REF:
+com.sun.star.beans.XPropertySet
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Managing_Number_Formats#XNumberFormats
+DESCR:OfficeDev - Managing Number Formats - NumberFormats Service - XNumberFormats
+REF:
+com.sun.star.util.XNumberFormats
+com.sun.star.util.NumberFormatProperties
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Navigating#Search_and_Replace
+DESCR:Text - Navigating - Search and Replace
+REF:
+com.sun.star.util.XPropertyReplace
+com.sun.star.style.ParagraphProperties
+com.sun.star.container.XIndexAccess
+com.sun.star.uno.XInterface
+com.sun.star.beans.PropertyValue
+com.sun.star.util.SearchDescriptor
+com.sun.star.util.XReplaceable
+com.sun.star.util.XSearchable
+com.sun.star.style.CharacterPropertiesAsian
+com.sun.star.style.CharacterProperties
+TOPIC:
+com.sun.star.util.SearchDescriptor
+com.sun.star.util.XReplaceable
+com.sun.star.util.XSearchable
+
+LINK:Documentation/DevGuide/Basic/Accessing_the_UNO_API#ThisComponent
+DESCR:Basic - Accessing the UNO API - ThisComponent
+REF:
+com.sun.star.frame.XStorable
+com.sun.star.util.XModifiable
+com.sun.star.document.XViewDataSupplier
+com.sun.star.sheet
+com.sun.star.text
+com.sun.star.beans.XPropertySet
+com.sun.star.document.XEventBroadcaster
+com.sun.star.document.XLinkTargetSupplier
+com.sun.star.drawing
+com.sun.star.lang.XEventListener
+com.sun.star.sheet.SpreadsheetDocumentSettings
+com.sun.star.view.XPrintable
+com.sun.star.text.TextDocument
+com.sun.star.frame.XModel
+com.sun.star.sheet.SpreadsheetDocument
+com.sun.star.lang.XServiceInfo
+com.sun.star.text.XTextDocument
+com.sun.star.drawing.DrawingDocument
+com.sun.star.style.XStyleFamiliesSupplier
+com.sun.star.document.OfficeDocument
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.container.XChild
+com.sun.star.document.XEventsSupplier
+com.sun.star.document.XDocumentInfoSupplier
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/The_Example_Listings
+DESCR:GUI - The Example Listings
+REF:
+com.sun.star.container.ElementExistException
+com.sun.star.container.XNameAccess
+TOPIC:
+
+LINK:Documentation/DevGuide/Drawings/Zooming
+DESCR:Drawings - Zooming
+REF:
+com.sun.star.awt.Rectangle
+com.sun.star.view.DocumentZoomType
+com.sun.star.drawing.DrawingDocumentDrawView
+com.sun.star.awt.Point
+TOPIC:
+com.sun.star.drawing.DrawingDocumentDrawView
+
+LINK:Documentation/DevGuide/Database/Document_Links
+DESCR:Database - Document Links
+REF:
+com.sun.star.frame.XComponentLoader
+com.sun.star.sdb.DefinitionContainer
+com.sun.star.container.XEnumerationAccess
+com.sun.star.container.XIndexAccess
+com.sun.star.container.XNameContainer
+com.sun.star.sdb.XBookmarksSupplier
+com.sun.star.frame.Desktop
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/ResultSetMetaData
+DESCR:Database - ResultSetMetaData
+REF:
+com.sun.star.sdbc.XResultSetMetaData
+com.sun.star.sdbc.DataType
+TOPIC:
+com.sun.star.sdbc.XResultSetMetaData
+
+LINK:Documentation/DevGuide/WritingUNO/Storing_the_Service_Manager_for_Further_Use
+DESCR:WritingUNO - Storing the Service Manager for Further Use
+REF:
+com.sun.star.uno.XComponentContext
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Key_Service
+DESCR:Database - Key Service
+REF:
+com.sun.star.sdbc.KeyRule
+com.sun.star.sdbcx.KeyType
+TOPIC:
+com.sun.star.sdbcx.KeyType
+
+LINK:Documentation/DevGuide/Text/Auto_Text
+DESCR:Text - Auto Text
+REF:
+com.sun.star.text.AutoTextGroup
+com.sun.star.text.AutoTextContainer
+com.sun.star.text.AutoTextEntry
+TOPIC:
+com.sun.star.text.AutoTextGroup
+com.sun.star.text.AutoTextContainer
+com.sun.star.text.AutoTextEntry
+
+LINK:Documentation/DevGuide/Scripting/Writing_Macros#The_HelloWorld_macro
+DESCR:Scripting - Writing Macros - The HelloWorld macro
+REF:
+com.sun.star.uno.XComponentContext
+com.sun.star.frame.XDesktop
+com.sun.star.frame.XModel
+com.sun.star.script.provider.XScriptContext
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Class_Definition_with_Helper_Class
+DESCR:WritingUNO - Class Definition with Helper Class
+REF:
+com.sun.star.lang.XServiceInfo
+TOPIC:
+
+LINK:Documentation/DevGuide/FirstSteps/Using_Services#Using_Interfaces
+DESCR:FirstSteps - Using Services - Using Interfaces
+REF:
+com.sun.star.frame.XComponentLoader
+com.sun.star.lang.XComponent
+com.sun.star.frame.Frame
+com.sun.star.frame.Desktop
+TOPIC:
+com.sun.star.uno.XInterface
+
+LINK:Documentation/DevGuide/Text/Text_Sections
+DESCR:Text - Text Sections
+REF:
+com.sun.star.text.XTextSectionsSupplier
+com.sun.star.container.XIndexAccess
+com.sun.star.container.XNameAccess
+com.sun.star.text.TextSection
+TOPIC:
+com.sun.star.text.TextSection
+
+LINK:Documentation/DevGuide/GUI/Message_Box
+DESCR:GUI - Message Box
+REF:
+com.sun.star.awt.Toolkit
+com.sun.star.awt.XMessageBoxFactory
+com.sun.star.awt.MessageBoxButtons
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleText#Text_type
+DESCR:Accessibility - XAccessibleText - Text type
+REF:
+com.sun.star.accessibility.XAccessibleEditableText
+com.sun.star.accessibility.AccessibleTextType
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Integrating_Import_and_Export_Filters
+DESCR:OfficeDev - Integrating Import and Export Filters
+REF:
+TOPIC:
+com.sun.star.document.FilterFactory
+com.sun.star.document.TypeDetection
+com.sun.star.frame.SynchronousFrameLoader
+com.sun.star.frame.XComponentLoader
+com.sun.star.document.ExtendedTypeDetection
+com.sun.star.document.ImportFilter
+com.sun.star.frame.FrameLoader
+com.sun.star.document.ExportFilter
+
+LINK:Documentation/DevGuide/Spreadsheets/Working_With_Spreadsheet_Documents#Spreadsheet_Document
+DESCR:Spreadsheets - Working With Spreadsheet Documents - Document Structure - Spreadsheet Document
+REF:
+com.sun.star.sheet.SpreadsheetDocument
+com.sun.star.container.XNameContainer
+com.sun.star.container.XIndexAccess
+com.sun.star.sheet.XSpreadsheetDocument
+com.sun.star.sheet.Spreadsheets
+com.sun.star.container.XNameAccess
+com.sun.star.sheet.XSpreadsheets
+com.sun.star.container.XNameReplace
+com.sun.star.sheet.SpreadsheetsEnumeration
+TOPIC:
+com.sun.star.sheet.SpreadsheetDocument
+com.sun.star.sheet.Spreadsheets
+
+LINK:Documentation/DevGuide/Database/Column_Service
+DESCR:Database - Column Service
+REF:
+com.sun.star.sdbcx.IndexColumn
+com.sun.star.sdbcx.Column
+com.sun.star.sdbcx.XDataDescriptorFactory
+com.sun.star.sdbc.DataType
+com.sun.star.sdbc.ColumnValue
+com.sun.star.sdbcx.KeyColumn
+TOPIC:
+com.sun.star.sdbcx.IndexColumn
+com.sun.star.sdbcx.Column
+com.sun.star.sdbcx.KeyColumn
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Window_Interfaces
+DESCR:OfficeDev - Component - Window Interfaces
+REF:
+TOPIC:
+com.sun.star.awt.XWindow
+com.sun.star.awt.XWindowPeer
+com.sun.star.awt.XTopWindow
+
+LINK:Documentation/DevGuide/Charts/Handling_Chart_Documents#Creating_Charts
+DESCR:Charts - Handling Chart Documents - Creating Charts
+REF:
+com.sun.star.chart.XChartDataArray
+com.sun.star.table.XTableChartsSupplier
+com.sun.star.sheet.Spreadsheet
+TOPIC:
+
+LINK:Documentation/DevGuide/Drawings/General_Drawing_Properties
+DESCR:Drawings - General Drawing Properties
+REF:
+com.sun.star.style.LineSpacing
+com.sun.star.drawing.TextFitToSizeType
+com.sun.star.style.ParagraphProperties
+com.sun.star.style.TabStop
+com.sun.star.drawing.TextAnimationDirection
+com.sun.star.drawing.LineStyle
+com.sun.star.drawing.LineDash
+com.sun.star.awt.FontSlant
+com.sun.star.awt.Gradient
+com.sun.star.drawing.TextProperties
+com.sun.star.drawing.LineProperties
+com.sun.star.style.CharacterProperties
+com.sun.star.drawing.RectanglePoint
+com.sun.star.drawing.Hatch
+com.sun.star.lang.Locale
+com.sun.star.drawing.PolyPolygonBezierCoords
+com.sun.star.drawing.TextVerticalAdjust
+com.sun.star.style.CharacterPropertiesComplex
+com.sun.star.style.ParagraphPropertiesAsian
+com.sun.star.drawing.FillProperties
+com.sun.star.awt.XBitmap
+com.sun.star.text.WritingMode
+com.sun.star.drawing.LineJoint
+com.sun.star.container.XIndexReplace
+com.sun.star.style.CharacterPropertiesAsian
+com.sun.star.drawing.ShadowProperties
+com.sun.star.drawing.BitmapMode
+com.sun.star.drawing.FillStyle
+com.sun.star.uno.XInterface
+com.sun.star.drawing.TextHorizontalAdjust
+com.sun.star.drawing.TextAnimationKind
+TOPIC:
+com.sun.star.drawing.TextProperties
+com.sun.star.drawing.FillProperties
+com.sun.star.drawing.LineProperties
+
+LINK:Documentation/DevGuide/Spreadsheets/Cell_Ranges_and_Cells_Container#Properties_of_SheetCellRanges
+DESCR:Spreadsheets - Cell Ranges and Cells Container - Properties of SheetCellRanges
+REF:
+com.sun.star.sheet.SheetCellRanges
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Source_Object
+DESCR:Spreadsheets - Source Object
+REF:
+com.sun.star.sheet.DataResult
+com.sun.star.sheet.DataResultFlags
+com.sun.star.sheet.XDataPilotResults
+com.sun.star.beans.XPropertySet
+com.sun.star.lang.XInitialization
+com.sun.star.sheet.DataPilotSource
+com.sun.star.util.XRefreshable
+TOPIC:
+com.sun.star.sheet.DataPilotSource
+
+LINK:Documentation/DevGuide/Drawings/Printing_Presentation_Documents
+DESCR:Drawings - Printing Presentation Documents
+REF:
+com.sun.star.presentation.DocumentSettings
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Models#XEventsSupplier
+DESCR:OfficeDev - Component - Models - XEventsSupplier
+REF:
+com.sun.star.document.XEventBroadcaster
+com.sun.star.document.XEventsSupplier
+TOPIC:
+com.sun.star.document.XEventsSupplier
+
+LINK:Documentation/DevGuide/Database/Events_and_Other_Notifications
+DESCR:Database - Events and Other Notifications
+REF:
+com.sun.star.beans.XPropertySet
+com.sun.star.sdb.XRowSetApproveBroadcaster
+com.sun.star.sdbc.XRowSetListener
+com.sun.star.lang.EventObject
+com.sun.star.sdb.XRowSetApproveListener
+com.sun.star.sdbc.XRowSet
+TOPIC:
+com.sun.star.sdb.XRowSetApproveBroadcaster
+com.sun.star.sdbc.XRowSetListener
+com.sun.star.lang.EventObject
+com.sun.star.sdb.XRowSetApproveListener
+
+LINK:Documentation/DevGuide/Forms/Form_Control_Models
+DESCR:Forms - Form Control Models
+REF:
+com.sun.star.form.FormComponent
+com.sun.star.form.FormComponents
+com.sun.star.form.FormControlModel
+TOPIC:
+com.sun.star.form.FormControlModel
+
+LINK:Documentation/DevGuide/OfficeDev/The_Exporter#Evaluating_XExportFilter_Parameters
+DESCR:OfficeDev - The Exporter - Evaluating XExportFilter Parameters
+REF:
+com.sun.star.xml.sax.XDocumentHandler
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/Numeric_Field
+DESCR:Basic - Numeric Field
+REF:
+com.sun.star.awt.UnoControlNumericField
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Services#Including_Properties
+DESCR:ProUNO - Services - Including Properties
+REF:
+com.sun.star.beans.XPropertySet
+com.sun.star.beans.XPropertyChangeListener
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Deployment_Options_for_Components#Component_Registration
+DESCR:WritingUNO - Deployment Options for Components - null - Component Registration
+REF:
+com.sun.star.loader.SharedLibrary
+com.sun.star.io.Pipe
+TOPIC:
+
+LINK:Documentation/DevGuide/UCB/Content_Provider_Proxies
+DESCR:UCB - Content Provider Proxies
+REF:
+com.sun.star.ucb.XContentProviderManager
+TOPIC:
+com.sun.star.ucb.XContentProviderManager
+
+LINK:Documentation/DevGuide/OfficeDev/Implementing_a_Thesaurus
+DESCR:OfficeDev - Implementing a Thesaurus
+REF:
+com.sun.star.lang.XServiceInfo
+com.sun.star.linguistic2.XThesaurus
+com.sun.star.lang.XComponent
+com.sun.star.lang.XInitialization
+com.sun.star.lang.XServiceDisplayName
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Models#XModel
+DESCR:OfficeDev - Component - Models - XModel
+REF:
+com.sun.star.view.XSelectionSupplier
+com.sun.star.lang.XComponent
+com.sun.star.document.MediaDescriptor
+com.sun.star.frame.XModel
+TOPIC:
+com.sun.star.frame.XModel
+
+LINK:Documentation/DevGuide/FirstSteps/Sequence
+DESCR:FirstSteps - Sequence
+REF:
+com.sun.star.frame.XStorable
+com.sun.star.document.MediaDescriptor
+com.sun.star.container.XEnumeration
+TOPIC:
+
+LINK:Documentation/DevGuide/Drawings/Page_Formatting
+DESCR:Drawings - Page Formatting
+REF:
+com.sun.star.view.PaperOrientation
+com.sun.star.drawing.GenericDrawPage
+TOPIC:
+com.sun.star.drawing.GenericDrawPage
+
+LINK:Documentation/DevGuide/Database/The_SDBC_Driver_for_Flat_File_Formats
+DESCR:Database - The SDBC Driver for Flat File Formats
+REF:
+com.sun.star.sdbc.FLATConnectionProperties
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/Setting_Dialog_Properties
+DESCR:GUI - Setting Dialog Properties
+REF:
+com.sun.star.awt.UnoControlDialogModel
+com.sun.star.beans.XPropertySet
+com.sun.star.awt.UnoControlDialogElement
+com.sun.star.awt.UnoControlModel
+com.sun.star.beans.XMultiPropertySet
+TOPIC:
+
+LINK:Documentation/DevGuide/Drawings/Custom_Slide_Show
+DESCR:Drawings - Custom Slide Show
+REF:
+com.sun.star.presentation.CustomPresentation
+com.sun.star.container.XNamed
+com.sun.star.lang.XSingleServiceFactory
+com.sun.star.presentation.CustomPresentationAccess
+com.sun.star.presentation.XCustomPresentationSupplier
+com.sun.star.container.XNameContainer
+com.sun.star.container.XIndexContainer
+TOPIC:
+com.sun.star.presentation.CustomPresentationAccess
+com.sun.star.presentation.XCustomPresentationSupplier
+
+LINK:Documentation/DevGuide/Config/Using_a_Data_Source
+DESCR:Config - Using a Data Source
+REF:
+com.sun.star.configuration.ConfigurationUpdateAccess
+com.sun.star.configuration.ConfigurationAccess
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/Property_Propagation_Between_Model_and_Control
+DESCR:GUI - Property Propagation Between Model and Control
+REF:
+com.sun.star.awt
+TOPIC:
+
+LINK:Documentation/DevGuide/Charts/Stock_Charts
+DESCR:Charts - Stock Charts
+REF:
+com.sun.star.chart.StockDiagram
+TOPIC:
+com.sun.star.chart.StockDiagram
+
+LINK:Documentation/DevGuide/Text/Editing_Text#Control_Characters
+DESCR:Text - Editing Text - Control Characters
+REF:
+com.sun.star.text.ControlCharacter
+TOPIC:
+com.sun.star.text.ControlCharacter
+
+LINK:Documentation/DevGuide/OfficeDev/Frames#Linking_Components_and_Windows
+DESCR:OfficeDev - Frames - Linking Components and Windows
+REF:
+com.sun.star.frame.XFrames
+com.sun.star.frame.XController
+com.sun.star.awt.XWindow
+com.sun.star.awt.XTopWindow
+com.sun.star.frame.XFramesSupplier
+TOPIC:
+com.sun.star.frame.XFrames
+com.sun.star.awt.XWindow
+com.sun.star.awt.XTopWindow
+com.sun.star.frame.Frame
+com.sun.star.frame.XFrame
+
+LINK:Documentation/DevGuide/Config/Connecting_to_a_Data_Source
+DESCR:Config - Connecting to a Data Source
+REF:
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.configuration.ConfigurationProvider
+com.sun.star.lang.ServiceManager
+TOPIC:
+com.sun.star.configuration.ConfigurationProvider
+
+LINK:Documentation/DevGuide/Spreadsheets/Creating_a_New_DataPilot_Table
+DESCR:Spreadsheets - Creating a New DataPilot Table
+REF:
+com.sun.star.table.CellRangeAddress
+com.sun.star.sheet.DataPilotFieldOrientation
+com.sun.star.sheet.SheetFilterDescriptor
+com.sun.star.sheet.DataPilotDescriptor
+com.sun.star.sheet.DataPilotFields
+com.sun.star.sheet.XDataPilotDescriptor
+com.sun.star.sheet.XDataPilotTables
+com.sun.star.sheet.DataPilotField
+TOPIC:
+com.sun.star.sheet.DataPilotFieldOrientation
+com.sun.star.sheet.DataPilotDescriptor
+com.sun.star.sheet.DataPilotField
+
+LINK:Documentation/DevGuide/Spreadsheets/Range_Selection
+DESCR:Spreadsheets - Range Selection
+REF:
+com.sun.star.sheet.XRangeSelectionListener
+com.sun.star.sheet.XRangeSelectionChangeListener
+com.sun.star.sheet.RangeSelectionEvent
+com.sun.star.sheet.XRangeSelection
+com.sun.star.sheet.RangeSelectionArguments
+TOPIC:
+com.sun.star.sheet.XRangeSelectionChangeListener
+com.sun.star.sheet.XRangeSelection
+com.sun.star.sheet.RangeSelectionArguments
+
+LINK:Documentation/DevGuide/Text/Overall_Document_Features#Character_Styles
+DESCR:Text - Overall Document Features - Styles - Character Styles
+REF:
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.style.CharacterPropertiesAsian
+com.sun.star.style.CharacterProperties
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Page_Layout
+DESCR:Text - Page Layout
+REF:
+com.sun.star.style.PageProperties
+com.sun.star.style.PageStyleLayout
+com.sun.star.text.Text
+TOPIC:
+com.sun.star.style.PageProperties
+
+LINK:Documentation/DevGuide/GUI/Combo_Box
+DESCR:GUI - Combo Box
+REF:
+com.sun.star.awt.XTextListener
+com.sun.star.awt.UnoControlEdit
+com.sun.star.awt.UnoControlComboBoxModel
+com.sun.star.awt.UnoControlComboBox
+com.sun.star.awt.XComboBox
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Columns
+DESCR:Text - Columns
+REF:
+com.sun.star.text.TextColumns
+com.sun.star.text.TextColumn
+com.sun.star.text.XTextColumns
+TOPIC:
+com.sun.star.text.TextColumns
+
+LINK:Documentation/DevGuide/Database/The_DataSource_Service
+DESCR:Database - The DataSource Service
+REF:
+com.sun.star.document.OfficeDocument
+com.sun.star.sdb.XCompletedConnection
+com.sun.star.sdb.XQueryDefinitionsSupplier
+com.sun.star.sdb.XReportDocumentsSupplier
+com.sun.star.sdb.XFormDocumentsSupplier
+com.sun.star.sdb.DataSource
+com.sun.star.util.XFlushable
+com.sun.star.sdb.XBookmarksSupplier
+com.sun.star.sdb.OfficeDatabaseDocument
+com.sun.star.util.XNumberFormatsSupplier
+TOPIC:
+com.sun.star.sdb.DataSource
+
+LINK:Documentation/DevGuide/Accessibility/Content_Information
+DESCR:Accessibility - Content Information
+REF:
+com.sun.star.accessibility.XAccessible
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Java/Mapping_of_Exception_Types
+DESCR:ProUNO - Java - Mapping of Exception Types
+REF:
+com.sun.star.uno.Exception
+com.sun.star.uno.RuntimeException
+TOPIC:
+com.sun.star.uno.Exception
+com.sun.star.uno.RuntimeException
+
+LINK:Documentation/DevGuide/GUI/Group_Box
+DESCR:GUI - Group Box
+REF:
+com.sun.star.awt.UnoControlGroupBox
+TOPIC:
+
+LINK:Documentation/DevGuide/AdvUNO/XInvocation_Bridge#Implementing_UNO_objects
+DESCR:AdvUNO - XInvocation Bridge - Implementing UNO objects
+REF:
+com.sun.star.loader.XImplementationLoader
+com.sun.star.script.InvocationAdapterFactory
+com.sun.star.io.XInputStream
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Defining_an_Interface#Methods
+DESCR:WritingUNO - Defining an Interface - Methods
+REF:
+com.sun.star.uno.RuntimeException
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Storing_Documents
+DESCR:OfficeDev - Storing Documents
+REF:
+com.sun.star.frame.XStorable
+com.sun.star.util.XModifiable
+com.sun.star.drawing.XDrawPagesSupplier
+com.sun.star.text.XTextDocument
+com.sun.star.document.OfficeDocument
+com.sun.star.sheet.XSpreadsheetDocument
+com.sun.star.frame.XModel
+TOPIC:
+com.sun.star.frame.XStorable
+
+LINK:Documentation/DevGuide/WritingUNO/C++/Storing_the_Service_Manager_for_Further_Use
+DESCR:WritingUNO - C++ - Storing the Service Manager for Further Use
+REF:
+com.sun.star.uno.XComponentContext
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Models#XPrintable
+DESCR:OfficeDev - Component - Models - XPrintable
+REF:
+com.sun.star.view.XPrintable
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/Graphical_User_Interfaces
+DESCR:GUI - Graphical User Interfaces
+REF:
+com.sun.star.awt
+TOPIC:
+
+LINK:Documentation/DevGuide/AppendixC/The_FTP_Content_Provider#Creation_of_New_FTP_Content
+DESCR:AppendixC - The FTP Content Provider - Creation of New FTP Content
+REF:
+com.sun.star.ucb.XContentCreator
+com.sun.star.io.XInputStream
+TOPIC:
+com.sun.star.ucb.XContentCreator
+
+LINK:Documentation/DevGuide/OfficeDev/Using_Thesaurus
+DESCR:OfficeDev - Using Thesaurus
+REF:
+com.sun.star.linguistic2.XThesaurus
+com.sun.star.linguistic2.LinguProperties
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/Roadmap_Control
+DESCR:GUI - Roadmap Control
+REF:
+com.sun.star.awt.UnoControlRoadmapModel
+com.sun.star.awt.RoadmapItem
+com.sun.star.awt.UnoControlRoadmap
+com.sun.star.container.XIndexContainer
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Java_Window_Integration#More_Remote_Problems
+DESCR:OfficeDev - Java Window Integration - More Remote Problems - Resizing
+REF:
+com.sun.star.lang.DisposedException
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleHyperlink
+DESCR:Accessibility - XAccessibleHyperlink
+REF:
+com.sun.star.accessibility.XAccessibleHyperlink
+com.sun.star.accessibility.XAccessibleAction
+TOPIC:
+com.sun.star.accessibility.XAccessibleHyperlink
+
+LINK:Documentation/DevGuide/UCB/Setting_Content_Properties
+DESCR:UCB - Setting Content Properties
+REF:
+com.sun.star.beans.PropertyValue
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/XServiceInfo
+DESCR:WritingUNO - XServiceInfo
+REF:
+com.sun.star.lang.XServiceInfo
+TOPIC:
+com.sun.star.lang.XServiceInfo
+
+LINK:Documentation/DevGuide/Database/Stored_Procedures
+DESCR:Database - Stored Procedures
+REF:
+com.sun.star.sdbc.XRow
+com.sun.star.sdbc.XOutParameters
+com.sun.star.sdbc.XConnection
+com.sun.star.sdbc.DataType
+com.sun.star.sdbc.CallableStatement
+com.sun.star.sdbcx.PreparedStatement
+TOPIC:
+com.sun.star.sdbc.XOutParameters
+
+LINK:Documentation/DevGuide/Database/Connections#Operation_on_Application_Level
+DESCR:Database - Connections - Understanding Connections - Operation on Application Level
+REF:
+com.sun.star.sdb.XSQLQueryComposerFactory
+com.sun.star.sdb.XCommandPreparation
+com.sun.star.container.XChild
+com.sun.star.sdb.DataSource
+com.sun.star.sdb.XQueriesSupplier
+com.sun.star.sdb.CommandType
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Frames#XStatusIndicatorFactory
+DESCR:OfficeDev - Component - Frames - XStatusIndicatorFactory
+REF:
+com.sun.star.task.XStatusIndicator
+com.sun.star.task.XStatusIndicatorFactory
+TOPIC:
+com.sun.star.task.XStatusIndicatorFactory
+
+LINK:Documentation/DevGuide/Spreadsheets/Saving_Spreadsheet_Documents#Storing
+DESCR:Spreadsheets - Saving Spreadsheet Documents - Storing
+REF:
+com.sun.star.frame.XStorable
+TOPIC:
+com.sun.star.frame.XStorable
+
+LINK:Documentation/DevGuide/Text/Overall_Document_Features#Frame_Styles
+DESCR:Text - Overall Document Features - Styles - Frame Styles
+REF:
+com.sun.star.text.BaseFrame
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.text.BaseFrameProperties
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Necessary_Steps
+DESCR:OfficeDev - Necessary Steps
+REF:
+com.sun.star.document.ExtendedTypeDetection
+TOPIC:
+
+LINK:Documentation/DevGuide/AdvUNO/XInvocation_Bridge#Exception_Handling
+DESCR:AdvUNO - XInvocation Bridge - Scripting Existing UNO Objects - Exception Handling
+REF:
+com.sun.star.script.CannotConvertException
+com.sun.star.reflection.InvocationTargetException
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Custom_Functions
+DESCR:Spreadsheets - Custom Functions
+REF:
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Intercepting_Context_Menus#Notification
+DESCR:WritingUNO - Intercepting Context Menus - Writing an Interceptor - Notification
+REF:
+com.sun.star.view.XSelectionSupplier
+com.sun.star.ui.ContextMenuExecuteEvent
+com.sun.star.ui.XContextMenuInterceptor
+com.sun.star.awt.XWindow
+com.sun.star.ui.ActionTriggerContainer
+com.sun.star.container.XIndexContainer
+com.sun.star.awt.Point
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/Roadmap_Control#Roadmap_Item
+DESCR:GUI - Roadmap Control - Roadmap Item
+REF:
+com.sun.star.awt.RoadmapItem
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Java/Mapping_of_Services
+DESCR:ProUNO - Java - Mapping of Services
+REF:
+com.sun.star.uno.XComponentContext
+com.sun.star.uno.DeploymentException
+com.sun.star.lang.XMultiComponentFactory
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Event_Model
+DESCR:ProUNO - Event Model
+REF:
+com.sun.star.lang.XEventListener
+com.sun.star.lang.EventObject
+TOPIC:
+com.sun.star.lang.XEventListener
+
+LINK:Documentation/DevGuide/Text/Iterating_over_Text
+DESCR:Text - Iterating over Text
+REF:
+com.sun.star.container.XContentEnumerationAccess
+com.sun.star.text.TextField
+com.sun.star.text.ControlCharacter
+com.sun.star.text.Text
+com.sun.star.container.XEnumerationAccess
+com.sun.star.text.Paragraph
+com.sun.star.text.TextPortion
+com.sun.star.text.TextTable
+com.sun.star.text.XTextContent
+com.sun.star.container.XEnumeration
+com.sun.star.text.TextRange
+TOPIC:
+com.sun.star.container.XContentEnumerationAccess
+com.sun.star.container.XEnumerationAccess
+com.sun.star.text.Paragraph
+com.sun.star.text.TextPortion
+
+LINK:Documentation/DevGuide/Spreadsheets/Database_Operations
+DESCR:Spreadsheets - Database Operations
+REF:
+TOPIC:
+com.sun.star.sheet.DatabaseRange
+com.sun.star.sheet.DatabaseRanges
+
+LINK:Documentation/DevGuide/Spreadsheets/Properties_of_SheetCell
+DESCR:Spreadsheets - Properties of SheetCell
+REF:
+com.sun.star.sheet.SheetCell
+com.sun.star.table.Cell
+com.sun.star.sheet.FormulaResult
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Java/Mapping_of_Interface_Types
+DESCR:ProUNO - Java - Mapping of Interface Types
+REF:
+com.sun.star.uno.XInterface
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Closing_Documents
+DESCR:OfficeDev - Closing Documents
+REF:
+com.sun.star.lang.XComponent
+com.sun.star.lang.XEventListener
+TOPIC:
+com.sun.star.util.XCloseListener
+com.sun.star.lang.XComponent
+com.sun.star.util.XCloseable
+
+LINK:Documentation/DevGuide/Forms/Committing_Controls
+DESCR:Forms - Committing Controls
+REF:
+com.sun.star.form.FormController
+com.sun.star.form.XUpdateBroadcaster
+com.sun.star.form.XBoundComponent
+TOPIC:
+com.sun.star.form.XBoundComponent
+
+LINK:Documentation/DevGuide/OfficeDev/Using_Spellchecker
+DESCR:OfficeDev - Using Spellchecker
+REF:
+com.sun.star.linguistic2.XSpellChecker
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Creating_Statements
+DESCR:Database - Creating Statements
+REF:
+com.sun.star.sdbc.XMultipleResults
+com.sun.star.sdbc.XConnection
+com.sun.star.sdbc.XStatement
+com.sun.star.sdbc.Statement
+TOPIC:
+com.sun.star.sdbc.Statement
+
+LINK:Documentation/DevGuide/Database/Connections#Understanding_Connections
+DESCR:Database - Connections - Understanding Connections
+REF:
+com.sun.star.sdb.XSQLQueryComposerFactory
+com.sun.star.sdbc.Connection
+com.sun.star.sdb.Connection
+com.sun.star.sdb.XCommandPreparation
+com.sun.star.container.XChild
+com.sun.star.sdbcx.DatabaseDefinition
+com.sun.star.sdb.XQueriesSupplier
+TOPIC:
+com.sun.star.sdb.Connection
+
+LINK:Documentation/DevGuide/ProUNO/C++/Type_Mappings#Mapping_of_Type
+DESCR:ProUNO - C++ - Type Mappings - Mapping of Simple Types - Mapping of Type
+REF:
+com.sun.star.uno.TypeClass
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Spreadsheet#Page_Breaks
+DESCR:Spreadsheets - Spreadsheet - Page Breaks
+REF:
+com.sun.star.sheet.TablePageBreakData
+com.sun.star.sheet.XSheetPageBreak
+com.sun.star.table.TableColumn
+com.sun.star.table.TableRow
+TOPIC:
+com.sun.star.sheet.TablePageBreakData
+com.sun.star.sheet.XSheetPageBreak
+
+LINK:Documentation/DevGuide/Config/Configuration_Data_Sources
+DESCR:Config - Configuration Data Sources
+REF:
+com.sun.star.configuration.ConfigurationUpdateAccess
+com.sun.star.configuration.ConfigurationProvider
+com.sun.star.configuration.ConfigurationAccess
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Removing_a_DataPilot_Table
+DESCR:Spreadsheets - Removing a DataPilot Table
+REF:
+com.sun.star.sheet.XDataPilotTables
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Indexes_and_Index_Marks#Index_marks
+DESCR:Text - Indexes and Index Marks - Index marks
+REF:
+com.sun.star.text.DocumentIndexMark
+com.sun.star.text.TextContent
+com.sun.star.beans.XPropertySet
+com.sun.star.text.UserIndexMark
+com.sun.star.text.XDocumentIndexMark
+com.sun.star.text.ContentIndexMark
+com.sun.star.text.BaseIndexMark
+TOPIC:
+com.sun.star.text.XDocumentIndexMark
+com.sun.star.text.BaseIndexMark
+
+LINK:Documentation/DevGuide/OfficeDev/Implementing_a_New_Locale#XTransliteration
+DESCR:OfficeDev - Implementing a New Locale - XTransliteration
+REF:
+com.sun.star.i18n.XTransliteration
+com.sun.star.i18n.TransliterationModulesNew
+com.sun.star.i18n.TransliterationModules
+TOPIC:
+com.sun.star.i18n.TransliterationModulesNew
+com.sun.star.i18n.TransliterationModules
+
+LINK:Documentation/DevGuide/WritingUNO/Protocol_Handler#Overview
+DESCR:WritingUNO - Protocol Handler - Overview
+REF:
+com.sun.star.frame.ContentHandler
+com.sun.star.frame.FrameLoader
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Special_Service_Manager_Configurations
+DESCR:WritingUNO - Special Service Manager Configurations
+REF:
+com.sun.star.lang.XServiceInfo
+com.sun.star.lang.XSingleServiceFactory
+com.sun.star.container.XSet
+com.sun.star.lang.XSingleComponentFactory
+TOPIC:
+
+LINK:Documentation/DevGuide/UCB/UCP_Registration_Information
+DESCR:UCB - UCP Registration Information
+REF:
+com.sun.star.ucb.XContentIdentifier
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/Dialogs_and_Controls
+DESCR:GUI - Dialogs and Controls
+REF:
+com.sun.star.awt.XWindow2
+com.sun.star.awt.XWindow
+com.sun.star.beans.XPropertySet
+com.sun.star.awt.XWindowPeer
+com.sun.star.awt.UnoControl
+com.sun.star.awt.UnoControlModel
+com.sun.star.awt.UnoControlEditModel
+com.sun.star.awt.XControl
+com.sun.star.awt.XView
+com.sun.star.awt
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/Check_Box
+DESCR:GUI - Check Box
+REF:
+com.sun.star.awt.XItemListener
+com.sun.star.awt.UnoControlCheckBoxModel
+TOPIC:
+
+LINK:Documentation/DevGuide/Drawings/Rotating_and_Shearing
+DESCR:Drawings - Rotating and Shearing
+REF:
+com.sun.star.drawing.RotationDescriptor
+TOPIC:
+com.sun.star.drawing.RotationDescriptor
+
+LINK:Documentation/DevGuide/Drawings/Moving_and_Scaling
+DESCR:Drawings - Moving and Scaling
+REF:
+com.sun.star.drawing.XShape
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Implementing_a_New_Locale#XLocaleData
+DESCR:OfficeDev - Implementing a New Locale - XLocaleData
+REF:
+com.sun.star.i18n.Calendar
+com.sun.star.i18n.Currency
+com.sun.star.i18n.ForbiddenCharacters
+com.sun.star.i18n.LanguageCountryInfo
+com.sun.star.i18n.XLocaleData
+com.sun.star.i18n.reservedWords
+com.sun.star.i18n.FormatElement
+com.sun.star.beans.PropertyValues
+com.sun.star.i18n.NumberFormatIndex
+com.sun.star.container.XIndexAccess
+com.sun.star.text.XDefaultNumberingProvider
+com.sun.star.i18n.LocaleDataItem
+com.sun.star.i18n.Implementation
+TOPIC:
+com.sun.star.i18n.XLocaleData
+
+LINK:Documentation/DevGuide/UCB/Unconfigured_UCBs
+DESCR:UCB - Unconfigured UCBs
+REF:
+com.sun.star.ucb.XContentProviderManager
+com.sun.star.ucb.ContentProviderInfo
+com.sun.star.ucb.UniversalContentBroker
+TOPIC:
+com.sun.star.ucb.XContentProviderManager
+
+LINK:Documentation/DevGuide/Database/Adding_a_Group
+DESCR:Database - Adding a Group
+REF:
+com.sun.star.sdbcx.GroupDescriptor
+TOPIC:
+com.sun.star.sdbcx.GroupDescriptor
+
+LINK:Documentation/DevGuide/AdvUNO/XInvocation_Bridge#Property_Support
+DESCR:AdvUNO - XInvocation Bridge - Scripting Existing UNO Objects - Property Support
+REF:
+com.sun.star.script.Invocation
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Using_Prepared_Statements
+DESCR:Database - Using Prepared Statements
+REF:
+com.sun.star.sdbc.Statement
+TOPIC:
+
+LINK:Documentation/DevGuide/AppendixC/The_Package_Content_Provider#Commands_and_Properties
+DESCR:AppendixC - The Package Content Provider - Commands and Properties
+REF:
+com.sun.star.ucb.XContent
+com.sun.star.lang.XServiceInfo
+com.sun.star.ucb.XContentCreator
+com.sun.star.lang.XComponent
+com.sun.star.container.XChild
+com.sun.star.ucb.XCommandInfoChangeNotifier
+com.sun.star.beans.XPropertySetInfoChangeNotifier
+com.sun.star.beans.XPropertiesChangeNotifier
+com.sun.star.beans.XPropertyContainer
+com.sun.star.ucb.XCommandProcessor
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Settings#Document_Properties
+DESCR:Text - Settings - Document Properties
+REF:
+com.sun.star.document.RedlineDisplayType
+com.sun.star.lang.Locale
+com.sun.star.beans.XPropertySet
+com.sun.star.i18n.ForbiddenCharacters
+com.sun.star.text.TextDocument
+TOPIC:
+com.sun.star.text.TextDocument
+
+LINK:Documentation/DevGuide/GUI/Horizontal_Vertical_Line_Control
+DESCR:GUI - Horizontal Vertical Line Control
+REF:
+com.sun.star.awt.UnoControlFixedLine
+com.sun.star.awt.UnoControlFixedLineModel
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/XDatabaseMetaData_Interface
+DESCR:Database - XDatabaseMetaData Interface
+REF:
+com.sun.star.sdbc.XDatabaseMetaData
+TOPIC:
+com.sun.star.sdbc.XDatabaseMetaData
+
+LINK:Documentation/DevGuide/OfficeDev/Managing_Number_Formats#NumberFormats_Service
+DESCR:OfficeDev - Managing Number Formats - NumberFormats Service
+REF:
+com.sun.star.util.XNumberFormatTypes
+com.sun.star.util.XNumberFormats
+com.sun.star.util.NumberFormats
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Managing_Number_Formats#XNumberFormatTypes
+DESCR:OfficeDev - Managing Number Formats - NumberFormats Service - XNumberFormatTypes
+REF:
+com.sun.star.util.NumberFormat
+com.sun.star.util.XNumberFormatTypes
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Inserting_Tables
+DESCR:Text - Inserting Tables
+REF:
+com.sun.star.text.XTextTable
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.text.XText
+com.sun.star.text.XTextContent
+TOPIC:
+
+LINK:Documentation/DevGuide/JavaBean/API_Overview
+DESCR:JavaBean - API Overview
+REF:
+com.sun.star.frame.Controller
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.frame.XDesktop
+com.sun.star.frame.Frame
+com.sun.star.model.OfficeDocument
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/Dialog_Controls
+DESCR:GUI - Dialog Controls
+REF:
+com.sun.star.awt.Size
+com.sun.star.beans.XPropertySet
+com.sun.star.awt.UnoControlDialogElement
+com.sun.star.awt.UnoControlModel
+com.sun.star.awt.XLayoutConstrains
+com.sun.star.beans.XMultiPropertySet
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Creating_Frames_Manually#Assigning_Windows_to_Frames
+DESCR:OfficeDev - Creating Frames Manually - Assigning Windows to Frames
+REF:
+com.sun.star.awt.XWindow
+com.sun.star.awt.Toolkit
+com.sun.star.awt.XTopWindow
+com.sun.star.awt.WindowDescriptor
+com.sun.star.frame.Frame
+com.sun.star.awt
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/Label_Field
+DESCR:Basic - Label Field
+REF:
+com.sun.star.awt.UnoControlFixedText
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Events
+DESCR:OfficeDev - Events
+REF:
+com.sun.star.linguistic2.DictionaryListEvent
+com.sun.star.linguistic2.XLinguServiceEventListener
+com.sun.star.linguistic2.XDictionaryListEventListener
+com.sun.star.linguistic2.XLinguServiceEventBroadcaster
+com.sun.star.linguistic2.LinguServiceEvent
+com.sun.star.linguistic2.XDictionary
+com.sun.star.linguistic2.DictionaryEvent
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Understanding_the_API_Reference
+DESCR:ProUNO - Understanding the API Reference
+REF:
+com.sun.star.frame.XComponentLoader
+com.sun.star.text.TextFrame
+com.sun.star.text.TextDocument
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Models#XEventBroadcaster
+DESCR:OfficeDev - Component - Models - XEventBroadcaster
+REF:
+com.sun.star.document.EventObject
+com.sun.star.document.XEventBroadcaster
+com.sun.star.document.Events
+TOPIC:
+com.sun.star.document.XEventBroadcaster
+
+LINK:Documentation/DevGuide/AppendixA/Events#Usage
+DESCR:AppendixA - Events - null - Usage
+REF:
+com.sun.star.lang.XEventListener
+com.sun.star.lang.EventObject
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Editing_Text#Strings
+DESCR:Text - Editing Text - Strings
+REF:
+com.sun.star.text.XSentenceCursor
+com.sun.star.text.XWordCursor
+com.sun.star.text.XParagraphCursor
+TOPIC:
+com.sun.star.text.XSimpleText
+
+LINK:Documentation/DevGuide/Basic/Check_Box
+DESCR:Basic - Check Box
+REF:
+com.sun.star.awt.XCheckBox
+com.sun.star.awt.UnoControlCheckBox
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Models#XModifiable
+DESCR:OfficeDev - Component - Models - XModifiable
+REF:
+com.sun.star.util.XModifiable
+TOPIC:
+com.sun.star.util.XModifiable
+
+LINK:Documentation/DevGuide/Drawings/Bezier_Shapes
+DESCR:Drawings - Bezier Shapes
+REF:
+com.sun.star.drawing.PolyPolygonBezierDescriptor
+com.sun.star.drawing.PolyPolygonBezierCoords
+com.sun.star.drawing.PolygonKind
+TOPIC:
+com.sun.star.drawing.PolyPolygonBezierDescriptor
+
+LINK:Documentation/DevGuide/OfficeDev/Filtering_Process#ExtendedTypeDetection
+DESCR:OfficeDev - Filtering Process - ExtendedTypeDetection
+REF:
+com.sun.star.document.ExtendedTypeDetection
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Overview_and_Using_the_API#XExtendedIndexEntrySupplier
+DESCR:OfficeDev - Overview and Using the API - XExtendedIndexEntrySupplier
+REF:
+com.sun.star.i18n.XIndexEntrySupplier
+com.sun.star.i18n.XInputSequenceChecker
+com.sun.star.i18n.XExtendedIndexEntrySupplier
+TOPIC:
+com.sun.star.i18n.XInputSequenceChecker
+com.sun.star.i18n.XExtendedIndexEntrySupplier
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/The_Bridge_Services
+DESCR:ProUNO - Bridge - The Bridge Services
+REF:
+com.sun.star.bridge.XBridgeSupplier2
+com.sun.star.lang.XMultiServiceFactory
+TOPIC:
+com.sun.star.bridge.oleautomation.Factory
+com.sun.star.bridge.oleautomation.BridgeSupplier
+com.sun.star.bridge.oleautomation.ApplicationRegistration
+
+LINK:Documentation/DevGuide/Config/Reading_Configuration_Data
+DESCR:Config - Reading Configuration Data
+REF:
+com.sun.star.beans.XPropertySet
+com.sun.star.container.XContainer
+com.sun.star.beans.XMultiHierarchicalPropertySet
+com.sun.star.beans.XHierarchicalPropertySet
+com.sun.star.container.XNameAccess
+com.sun.star.configuration.ConfigurationAccess
+com.sun.star.container.XHierarchicalName
+com.sun.star.util.XChangesNotifier
+com.sun.star.container.XNamed
+com.sun.star.configuration.XTemplateContainer
+com.sun.star.container.XChild
+com.sun.star.container.XHierarchicalNameAccess
+com.sun.star.beans.XPropertySetInfo
+com.sun.star.beans.XMultiPropertySet
+TOPIC:
+com.sun.star.configuration.ConfigurationAccess
+
+LINK:Documentation/DevGuide/Drawings/Other_Drawing_Specific_View_Settings
+DESCR:Drawings - Other Drawing Specific View Settings
+REF:
+com.sun.star.document.XViewDataSupplier
+com.sun.star.drawing.XDrawPage
+com.sun.star.beans.PropertyValue
+com.sun.star.drawing.DrawingDocumentDrawView
+TOPIC:
+com.sun.star.document.XViewDataSupplier
+com.sun.star.drawing.DrawingDocumentDrawView
+
+LINK:Documentation/DevGuide/Spreadsheets/Dimensions
+DESCR:Spreadsheets - Dimensions
+REF:
+com.sun.star.sheet.DataPilotSourceDimension
+com.sun.star.container.XNamed
+com.sun.star.beans.XPropertySet
+com.sun.star.util.XCloneable
+com.sun.star.sheet.DataPilotFieldOrientation
+com.sun.star.sheet.DataPilotSourceDimensions
+TOPIC:
+com.sun.star.sheet.DataPilotSourceDimensions
+
+LINK:Documentation/DevGuide/Text/Text_Fields
+DESCR:Text - Text Fields
+REF:
+com.sun.star.text.BibliographyDataField
+com.sun.star.text.textfield.User
+com.sun.star.text.textfield.docinfo.EditTime
+com.sun.star.text.textfield.ReferencePageSet
+com.sun.star.container.XNameAccess
+com.sun.star.text.textfield.Annotation
+com.sun.star.text.textfield.docinfo.PrintAuthor
+com.sun.star.text.textfield.GraphicObjectCount
+com.sun.star.text.textfield.Database
+com.sun.star.text.textfield.docinfo.CreateDateTime
+com.sun.star.text.textfield.ConditionalText
+com.sun.star.text.TextFields
+com.sun.star.text.textfield.Bibliography
+com.sun.star.text.textfield.Chapter
+com.sun.star.text.textfield.Input
+com.sun.star.text.textfield.SetExpression
+com.sun.star.text.FieldMaster.Database
+com.sun.star.text.FieldMaster.User
+com.sun.star.text.textfield.ReferencePageGet
+com.sun.star.text.textfield.ParagraphCount
+com.sun.star.text.textfield.Author
+com.sun.star.text.textfield.DatabaseNumberOfSet
+com.sun.star.text.textfield.docinfo.Info2
+com.sun.star.text.XTextFieldsSupplier
+com.sun.star.text.XDependentTextField
+com.sun.star.text.textfield.InputUser
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.text.textfield.HiddenParagraph
+com.sun.star.text.XTextField
+com.sun.star.text.textfield.docinfo.ChangeAuthor
+com.sun.star.text.textfield.DateTime
+com.sun.star.text.textfield.docinfo.Title
+com.sun.star.text.textfield.docinfo.Info0
+com.sun.star.text.textfield.Macro
+com.sun.star.container.XEnumerationAccess
+com.sun.star.text.TextFieldMasters
+com.sun.star.text.textfield.EmbeddedObjectCount
+com.sun.star.text.textfield.DatabaseName
+com.sun.star.text.textfield.docinfo.Info3
+com.sun.star.util.XUpdatable
+com.sun.star.text.TextContent
+com.sun.star.text.textfield.DatabaseSetNumber
+com.sun.star.text.FieldMaster.SetExpression
+com.sun.star.text.textfield.ExtendedUser
+com.sun.star.text.FieldMaster.DDE
+com.sun.star.text.textfield.docinfo.CreateAuthor
+com.sun.star.text.textfield.docinfo.Subject
+com.sun.star.text.textfield.PageNumber
+com.sun.star.text.textfield.TableFormula
+com.sun.star.text.textfield.docinfo.Keywords
+com.sun.star.text.FieldMaster.Bibliography
+com.sun.star.text.textfield.GetReference
+com.sun.star.text.textfield.WordCount
+com.sun.star.text.textfield.DDE
+com.sun.star.text.textfield.docinfo.Revision
+com.sun.star.text.textfield.GetExpression
+com.sun.star.text.textfield.Script
+com.sun.star.util.XRefreshable
+com.sun.star.text.textfield.TableCount
+com.sun.star.text.textfield.CharacterCount
+com.sun.star.text.textfield.TemplateName
+com.sun.star.text.textfield.docinfo.ChangeDateTime
+com.sun.star.text.textfield.FileName
+com.sun.star.text.textfield.CombinedCharacters
+com.sun.star.text.textfield.JumpEdit
+com.sun.star.text.textfield.PageCount
+com.sun.star.text.textfield.HiddenText
+com.sun.star.text.textfield.docinfo.Description
+com.sun.star.text.textfield.docinfo.Info1
+com.sun.star.text.textfield.DatabaseNextSet
+com.sun.star.text.textfield.docinfo.PrintDateTime
+TOPIC:
+com.sun.star.text.FieldMaster
+com.sun.star.text.TextField
+com.sun.star.text.XTextField
+
+LINK:Documentation/DevGuide/Forms/Model-View_Interaction
+DESCR:Forms - Model-View Interaction
+REF:
+com.sun.star.form.component.TextField
+com.sun.star.beans.XPropertyChangeListener
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/Option_Button
+DESCR:Basic - Option Button
+REF:
+com.sun.star.awt.UnoControlRadioButton
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Using_Spellchecker#Relevant_properties
+DESCR:OfficeDev - Using Spellchecker - Relevant properties
+REF:
+com.sun.star.linguistic2.XSpellAlternatives
+com.sun.star.linguistic2.LinguProperties
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Using_UNO_Interfaces
+DESCR:ProUNO - Using UNO Interfaces
+REF:
+com.sun.star.frame.XComponentLoader
+com.sun.star.drawing.Text
+com.sun.star.bridge.XUnoUrlResolver
+com.sun.star.uno.XInterface
+com.sun.star.bridge.UnoUrlResolver
+TOPIC:
+com.sun.star.uno.XInterface
+
+LINK:Documentation/DevGuide/Database/Piggyback_Connections
+DESCR:Database - Piggyback Connections
+REF:
+com.sun.star.sdb.RowSet
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Service_Names
+DESCR:Spreadsheets - Service Names
+REF:
+com.sun.star.lang.XServiceInfo
+com.sun.star.sheet.AddIn
+com.sun.star.lang.XServiceName
+TOPIC:
+com.sun.star.lang.XServiceInfo
+
+LINK:Documentation/DevGuide/Text/Editing_Text#Text_Contents_Other_Than_Strings
+DESCR:Text - Editing Text - Text Contents Other Than Strings
+REF:
+com.sun.star.text.TextContent
+com.sun.star.lang.XComponent
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.text.textfield.JumpEdit
+com.sun.star.lang.XEventListener
+com.sun.star.text.XTextRange
+com.sun.star.text.XText
+com.sun.star.text.TextContentAnchorType
+com.sun.star.text.WrapTextMode
+com.sun.star.text.XTextContent
+TOPIC:
+com.sun.star.text.TextContent
+com.sun.star.text.XText
+
+LINK:Documentation/DevGuide/WritingUNO/C++/Implementing_without_Helpers#Providing_a_Single_Factory
+DESCR:WritingUNO - C++ - Implementing without Helpers - Providing a Single Factory
+REF:
+com.sun.star.uno.XComponentContext
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/XInitialization
+DESCR:WritingUNO - XInitialization
+REF:
+com.sun.star.lang.XInitialization
+TOPIC:
+com.sun.star.lang.XInitialization
+
+LINK:Documentation/DevGuide/AppendixC/The_Hierarchy_Content_Provider#Creation_of_New_HCP_Content
+DESCR:AppendixC - The Hierarchy Content Provider - Creation of New HCP Content
+REF:
+com.sun.star.ucb.XContentCreator
+TOPIC:
+com.sun.star.ucb.XContentCreator
+
+LINK:Documentation/DevGuide/Text/Accessing_Existing_Tables
+DESCR:Text - Accessing Existing Tables
+REF:
+com.sun.star.text.XTextTablesSupplier
+com.sun.star.text.TextTables
+com.sun.star.container.XIndexAccess
+com.sun.star.container.XNameAccess
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Forms_as_Row_Sets
+DESCR:Forms - Forms as Row Sets
+REF:
+com.sun.star.sdb.RowSet
+com.sun.star.form.component.DataForm
+TOPIC:
+com.sun.star.sdb.RowSet
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleSelection
+DESCR:Accessibility - XAccessibleSelection
+REF:
+com.sun.star.accessibility.XAccessibleTable
+com.sun.star.accessibility.XAccessibleContext
+com.sun.star.accessibility.XAccessibleText
+com.sun.star.accessibility.XAccessibleSelection
+TOPIC:
+com.sun.star.accessibility.XAccessibleSelection
+
+LINK:Documentation/DevGuide/AdvUNO/UNO_Reflection_API#XTypeDescription
+DESCR:AdvUNO - UNO Reflection API - CoreReflection Service - XTypeDescription
+REF:
+com.sun.star.reflection.XEnumTypeDescription
+com.sun.star.reflection.TypeDescriptionManager
+com.sun.star.reflection.XInterfaceMemberTypeDescription
+com.sun.star.reflection.XInterfaceTypeDescription
+com.sun.star.reflection.XInterfaceMethodTypeDescription
+com.sun.star.reflection.XIndirectTypeDescription
+com.sun.star.reflection.XUnionTypeDescription
+com.sun.star.reflection.TypeDescriptionProvider
+com.sun.star.reflection.XInterfaceAttributeTypeDescription
+com.sun.star.reflection.XTypeDescription
+com.sun.star.reflection.XCompoundTypeDescription
+com.sun.star.container.XHierarchicalNameAccess
+com.sun.star.reflection.XArrayTypeDescription
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Controllers#XSelectionSupplier
+DESCR:OfficeDev - Component - Controllers - XSelectionSupplier
+REF:
+com.sun.star.view.XSelectionSupplier
+com.sun.star.frame.XModel
+TOPIC:
+com.sun.star.view.XSelectionSupplier
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleComponent
+DESCR:Accessibility - XAccessibleComponent
+REF:
+com.sun.star.accessibility.XAccessibleComponent
+com.sun.star.accessibility.XAccessibleContext
+TOPIC:
+com.sun.star.accessibility.XAccessibleComponent
+
+LINK:Documentation/DevGuide/ProUNO/Basic/Getting_Information_about_UNO_Objects#Inspecting_properties_during_debugging
+DESCR:ProUNO - Basic - Getting Information about UNO Objects - Inspecting properties during debugging
+REF:
+com.sun.star.beans.XPropertySet
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Control_Models_as_Bound_Components
+DESCR:Forms - Control Models as Bound Components
+REF:
+com.sun.star.form.component.TextField
+com.sun.star.form.component.NumericField
+com.sun.star.form.component.DataForm
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Capabilities_of_SheetCellRanges_Container
+DESCR:Spreadsheets - Capabilities of SheetCellRanges Container
+REF:
+com.sun.star.sheet.XSheetCellRangeContainer
+com.sun.star.sheet.XCellRangesQuery
+com.sun.star.sheet.SheetCellRanges
+com.sun.star.container.XNameContainer
+com.sun.star.container.XEnumerationAccess
+com.sun.star.container.XIndexAccess
+com.sun.star.container.XNameAccess
+com.sun.star.sheet.SheetRangesQuery
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Database_Import
+DESCR:Spreadsheets - Database Import
+REF:
+com.sun.star.util.XImportable
+TOPIC:
+com.sun.star.sheet.DatabaseImportDescriptor
+
+LINK:Documentation/DevGuide/AppendixA/Special_Cases#Collection_Interfaces
+DESCR:AppendixA - Special Cases - Collection Interfaces
+REF:
+com.sun.star.text.TextDocument
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Variable_Results
+DESCR:Spreadsheets - Variable Results
+REF:
+com.sun.star.sheet.XVolatileResult
+com.sun.star.sheet.VolatileResult
+com.sun.star.sheet.ResultEvent
+com.sun.star.sheet.XResultListener
+TOPIC:
+com.sun.star.sheet.XVolatileResult
+
+LINK:Documentation/DevGuide/AdvUNO/UNO_Reflection_API#Converter_Service
+DESCR:AdvUNO - UNO Reflection API - Converter Service
+REF:
+com.sun.star.script.XTypeConverter
+com.sun.star.uno.TypeClass
+com.sun.star.script.Converter
+com.sun.star.script.CannotConvertException
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/The_SQLQueryComposer
+DESCR:Database - The SQLQueryComposer
+REF:
+com.sun.star.sdb.SingleSelectQueryComposer
+com.sun.star.sdb.XSQLQueryComposerFactory
+com.sun.star.sdb.Connection
+com.sun.star.sdbcx.XTablesSupplier
+com.sun.star.sdb.DataColumn
+com.sun.star.sdbcx.XColumnsSupplier
+com.sun.star.sdb.XSQLQueryComposer
+com.sun.star.sdb.SQLQueryComposer
+TOPIC:
+com.sun.star.sdb.SQLQueryComposer
+
+LINK:Documentation/DevGuide/GUI/Roadmap_Control#Roadmap
+DESCR:GUI - Roadmap Control - null - Roadmap
+REF:
+com.sun.star.awt.XItemEventBroadcaster
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Absolute_Address
+DESCR:Spreadsheets - Absolute Address
+REF:
+com.sun.star.sheet.XCellRangeAddressable
+com.sun.star.table.CellRangeAddress
+TOPIC:
+com.sun.star.sheet.XCellRangeAddressable
+
+LINK:Documentation/DevGuide/AppendixC/The_FTP_Content_Provider#Commands_and_Properties
+DESCR:AppendixC - The FTP Content Provider - Commands and Properties
+REF:
+com.sun.star.ucb.XContent
+com.sun.star.lang.XServiceInfo
+com.sun.star.ucb.XContentCreator
+com.sun.star.lang.XComponent
+com.sun.star.container.XChild
+com.sun.star.ucb.XCommandInfoChangeNotifier
+com.sun.star.beans.XPropertySetInfoChangeNotifier
+com.sun.star.beans.XPropertiesChangeNotifier
+com.sun.star.beans.XPropertyContainer
+com.sun.star.ucb.XCommandProcessor
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Manipulating_the_Data
+DESCR:Database - Manipulating the Data
+REF:
+com.sun.star.sdb.RowSet
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Overview_and_Using_the_API#XNativeNumberSupplier
+DESCR:OfficeDev - Overview and Using the API - XNativeNumberSupplier
+REF:
+com.sun.star.i18n.XNativeNumberSupplier
+TOPIC:
+com.sun.star.i18n.XNativeNumberSupplier
+
+LINK:Documentation/DevGuide/Database/Retrieving_Values_from_Result_Sets
+DESCR:Database - Retrieving Values from Result Sets
+REF:
+com.sun.star.sdb.RowSet
+com.sun.star.sdb.ResultSet
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleStateSet
+DESCR:Accessibility - XAccessibleStateSet
+REF:
+com.sun.star.accessibility.AccessibleStateType
+com.sun.star.accessibility.XAccessibleStateSet
+TOPIC:
+com.sun.star.accessibility.AccessibleStateType
+com.sun.star.accessibility.XAccessibleStateSet
+
+LINK:Documentation/DevGuide/Database/Database_Design#Retrieving_Information_about_a_Database
+DESCR:Database - Database Design - Retrieving Information about a Database
+REF:
+com.sun.star.sdbc.XDatabaseMetaData
+TOPIC:
+com.sun.star.sdbc.XDatabaseMetaData
+
+LINK:Documentation/DevGuide/Spreadsheets/Cell_Ranges
+DESCR:Spreadsheets - Cell Ranges
+REF:
+com.sun.star.sheet.SheetCellRange
+TOPIC:
+com.sun.star.sheet.SheetCellRange
+
+LINK:Documentation/DevGuide/WritingUNO/Writing_the_Specification
+DESCR:WritingUNO - Writing the Specification
+REF:
+com.sun.star.bridge.XUnoUrlResolver
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Connecting_Through_a_DataSource
+DESCR:Database - Connecting Through a DataSource
+REF:
+com.sun.star.sdbc.XDataSource
+com.sun.star.sdb.InteractionHandler
+com.sun.star.sdb.XCompletedConnection
+TOPIC:
+com.sun.star.sdbc.XDataSource
+
+LINK:Documentation/DevGuide/GUI/Date_Field
+DESCR:GUI - Date Field
+REF:
+com.sun.star.awt.UnoControlDateField
+com.sun.star.awt.UnoControlDateFieldModel
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Opening_a_Connection
+DESCR:ProUNO - Opening a Connection
+REF:
+com.sun.star.connection.Acceptor
+com.sun.star.connection.Connector
+com.sun.star.connection.XConnector
+com.sun.star.connection.XConnection
+com.sun.star.connection.XAcceptor
+TOPIC:
+com.sun.star.connection.Acceptor
+com.sun.star.bridge.XBridgeFactory
+com.sun.star.connection.Connector
+com.sun.star.connection.XConnector
+com.sun.star.bridge.BridgeFactory
+com.sun.star.connection.XAcceptor
+
+LINK:Documentation/DevGuide/Database/Connection_Service
+DESCR:Database - Connection Service
+REF:
+com.sun.star.sdbc.Connection
+com.sun.star.sdbc.XDatabaseMetaData
+com.sun.star.sdbc.PreparedStatement
+com.sun.star.sdbc.XWarningsSupplier
+com.sun.star.lang.XComponent
+com.sun.star.sdbc.XConnection
+com.sun.star.sdbc.CallableStatement
+com.sun.star.sdbc.Statement
+TOPIC:
+com.sun.star.sdbc.Connection
+
+LINK:Documentation/DevGuide/OfficeDev/Managing_Number_Formats
+DESCR:OfficeDev - Managing Number Formats
+REF:
+com.sun.star.sdb.DatabaseEnvironment
+com.sun.star.beans.XPropertySet
+com.sun.star.awt.UnoControlFormattedFieldModel
+com.sun.star.sdb.DataSource
+com.sun.star.util.NumberFormats
+com.sun.star.sdb.DatabaseAccess
+com.sun.star.util.XNumberFormatsSupplier
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Bookmarks
+DESCR:Text - Bookmarks
+REF:
+com.sun.star.text.TextContent
+com.sun.star.container.XNamed
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.text.XTextRange
+com.sun.star.container.XIndexAccess
+com.sun.star.text.XBookmarksSupplier
+com.sun.star.text.XTextContent
+com.sun.star.container.XNameAccess
+com.sun.star.text.Bookmarks
+TOPIC:
+com.sun.star.text.Bookmark
+
+LINK:Documentation/DevGuide/Database/Connections#Communication
+DESCR:Database - Connections - Understanding Connections - Communication
+REF:
+com.sun.star.sdbc.Connection
+com.sun.star.sdbc.SQLWarning
+com.sun.star.sdbc.XWarningsSupplier
+com.sun.star.sdbc.XConnection
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Overview_and_Using_the_API#XExtendedCalendar
+DESCR:OfficeDev - Overview and Using the API - XExtendedCalendar
+REF:
+com.sun.star.i18n.XExtendedCalendar
+com.sun.star.i18n.XCalendar
+TOPIC:
+com.sun.star.i18n.XExtendedCalendar
+
+LINK:Documentation/DevGuide/Drawings/Glue_Points_and_Connectors
+DESCR:Drawings - Glue Points and Connectors
+REF:
+com.sun.star.drawing.ConnectorShape
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Columns_and_Rows
+DESCR:Spreadsheets - Columns and Rows
+REF:
+com.sun.star.table.XTableColumns
+com.sun.star.container.XNamed
+com.sun.star.beans.XPropertySet
+com.sun.star.table.XTableRows
+com.sun.star.container.XEnumerationAccess
+com.sun.star.container.XIndexAccess
+com.sun.star.table.XCellRange
+com.sun.star.container.XNameAccess
+com.sun.star.table.TableColumns
+com.sun.star.table.TableColumn
+com.sun.star.table.TableRow
+com.sun.star.table.TableRows
+TOPIC:
+com.sun.star.table.TableColumns
+com.sun.star.table.TableRows
+
+LINK:Documentation/DevGuide/Database/User_Service
+DESCR:Database - User Service
+REF:
+com.sun.star.sdbcx.XAuthorizable
+com.sun.star.sdbcx.User
+com.sun.star.sdbcx.XUser
+TOPIC:
+com.sun.star.sdbcx.XUser
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/Exceptions_and_Errorcodes
+DESCR:ProUNO - Bridge - Exceptions and Errorcodes
+REF:
+com.sun.star.lang.IllegalArgumentException
+com.sun.star.beans.UnknownPropertyException
+com.sun.star.uno.RuntimeException
+com.sun.star.script.CannotConvertException
+com.sun.star.reflection.InvocationTargetException
+com.sun.star.script.Invocation
+TOPIC:
+com.sun.star.uno.Exception
+com.sun.star.uno.RuntimeException
+com.sun.star.script.CannotConvertException
+com.sun.star.reflection.InvocationTargetException
+
+LINK:Documentation/DevGuide/OfficeDev/Desktop_Environment
+DESCR:OfficeDev - Desktop Environment
+REF:
+com.sun.star.document.TypeDetection
+com.sun.star.lang.XComponent
+com.sun.star.frame.XDesktop
+com.sun.star.frame.Desktop
+TOPIC:
+com.sun.star.frame.Desktop
+
+LINK:Documentation/DevGuide/GUI/Roadmap_Control#Roadmap_Controlmodel
+DESCR:GUI - Roadmap Control - null - Roadmap Controlmodel
+REF:
+com.sun.star.awt.UnoControlRoadmapModel
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/C++/Using_Weak_References
+DESCR:ProUNO - C++ - Using Weak References
+REF:
+com.sun.star.lang.XEventListener
+com.sun.star.uno.XWeak
+TOPIC:
+com.sun.star.uno.XWeak
+
+LINK:Documentation/DevGuide/ProUNO/Basic/Getting_Information_about_UNO_Objects#Inspecting_Methods_During_Debugging
+DESCR:ProUNO - Basic - Getting Information about UNO Objects - Inspecting Methods During Debugging
+REF:
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/Formatted_Field
+DESCR:Basic - Formatted Field
+REF:
+com.sun.star.awt.UnoControlFormattedField
+TOPIC:
+
+LINK:Documentation/DevGuide/AdvUNO/Implementing_UNO_Language_Bindings#Bootstrapping
+DESCR:AdvUNO - Implementing UNO Language Bindings - Overview of Language Bindings and Bridges - Bootstrapping
+REF:
+com.sun.star.bridge.UnoUrlResolver
+TOPIC:
+com.sun.star.bridge.UnoUrlResolver
+com.sun.star.lang.ServiceManager
+
+LINK:Documentation/DevGuide/AppendixA/Services#Naming
+DESCR:AppendixA - Services - Naming
+REF:
+com.sun.star.text.TextDocument
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/Default_Mappings
+DESCR:ProUNO - Bridge - Default Mappings
+REF:
+com.sun.star.bridge.oleautomation.SCode
+com.sun.star.uno.XInterface
+com.sun.star.script.XInvocation
+com.sun.star.bridge.oleautomation.Date
+com.sun.star.bridge.oleautomation.Currency
+com.sun.star.bridge.oleautomation.Decimal
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Validation
+DESCR:Forms - Validation
+REF:
+com.sun.star.form.component.TextField
+com.sun.star.form.validation.XValidator
+com.sun.star.xforms
+com.sun.star.form.validation.XValidatable
+com.sun.star.form.validation.ValidatableControlModel
+com.sun.star.xforms.Binding
+com.sun.star.form.validation.XValidatableFormComponent
+com.sun.star.form.validation.XFormComponentValidityListener
+com.sun.star.form.component.DateField
+TOPIC:
+com.sun.star.form.validation.XValidatable
+
+LINK:Documentation/DevGuide/Forms/Form_Components
+DESCR:Forms - Form Components
+REF:
+com.sun.star.form
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/Image_Control
+DESCR:Basic - Image Control
+REF:
+com.sun.star.awt.UnoControlImageControl
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/C++/Establishing_Interprocess_Connections
+DESCR:ProUNO - C++ - Establishing Interprocess Connections
+REF:
+com.sun.star.lang.XMultiServiceFactory
+TOPIC:
+com.sun.star.uno.XComponentContext
+com.sun.star.bridge.XUnoUrlResolver
+com.sun.star.lang.DisposedException
+com.sun.star.bridge.UnoUrlResolver
+com.sun.star.lang.XMultiComponentFactory
+com.sun.star.lang.ServiceManager
+
+LINK:Documentation/DevGuide/WritingUNO/Intercepting_Context_Menus#Register_and_Remove_an_Interceptor
+DESCR:WritingUNO - Intercepting Context Menus - Register and Remove an Interceptor
+REF:
+com.sun.star.ui.XContextMenuInterception
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Understanding_the_API_Reference#Object_Composition
+DESCR:ProUNO - Understanding the API Reference - Object Composition
+REF:
+com.sun.star.uno.XInterface
+com.sun.star.text.XText
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Using_Hyphenator
+DESCR:OfficeDev - Using Hyphenator
+REF:
+com.sun.star.linguistic2.XHyphenator
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Conditional_Formats
+DESCR:Spreadsheets - Conditional Formats
+REF:
+com.sun.star.sheet.XSheetConditionalEntry
+com.sun.star.sheet.XSheetCondition
+com.sun.star.sheet.ConditionOperator
+com.sun.star.sheet.XSheetConditionalEntries
+com.sun.star.sheet.XSpreadsheet
+com.sun.star.beans.PropertyValue
+com.sun.star.sheet.TableConditionalFormat
+com.sun.star.table.CellAddress
+com.sun.star.sheet.TableConditionalEntry
+TOPIC:
+com.sun.star.sheet.ConditionOperator
+com.sun.star.sheet.XSheetConditionalEntries
+com.sun.star.sheet.TableConditionalFormat
+
+LINK:Documentation/DevGuide/UCB/Creating
+DESCR:UCB - Creating
+REF:
+com.sun.star.ucb.XContentCreator
+com.sun.star.ucb.ContentInfo
+com.sun.star.ucb.InsertCommandArgument
+TOPIC:
+com.sun.star.ucb.XContentCreator
+com.sun.star.ucb.ContentInfo
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/Mapping_of_Interfaces_and_Structures
+DESCR:ProUNO - Bridge - Mapping of Interfaces and Structures
+REF:
+com.sun.star.script.XInvocation
+com.sun.star.uno.XInterface
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Capabilities_of_SheetCellRange
+DESCR:Spreadsheets - Capabilities of SheetCellRange
+REF:
+com.sun.star.sheet.XCellRangesQuery
+com.sun.star.table.XColumnRowRange
+com.sun.star.sheet.XSheetCellRange
+com.sun.star.sheet.XCellRangeData
+com.sun.star.table.CellRangeAddress
+com.sun.star.sheet.XCellSeries
+com.sun.star.util.XImportable
+com.sun.star.sheet.XUniqueCellFormatRangesSupplier
+com.sun.star.sheet.XSheetFilterableEx
+com.sun.star.sheet.XArrayFormulaRange
+com.sun.star.sheet.SheetRangesQuery
+com.sun.star.util.XMergeable
+com.sun.star.util.XIndent
+com.sun.star.chart.XChartDataArray
+com.sun.star.sheet.XCellFormatRangesSupplier
+com.sun.star.sheet.SheetCellRange
+com.sun.star.sheet.XSheetOperation
+com.sun.star.sheet.XSubTotalCalculatable
+com.sun.star.util.XSortable
+com.sun.star.util.XSearchable
+com.sun.star.sheet.XMultipleOperation
+com.sun.star.table.XAutoFormattable
+com.sun.star.sheet.XSheetFilterable
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Frames#Frame_Setup
+DESCR:OfficeDev - Component - Frames - XFrame - Frame Setup
+REF:
+com.sun.star.frame.XFrame
+TOPIC:
+com.sun.star.frame.XFrame
+
+LINK:Documentation/DevGuide/Drawings/Setting_the_Current_Page
+DESCR:Drawings - Setting the Current Page
+REF:
+com.sun.star.view.XSelectionSupplier
+com.sun.star.frame.XController
+com.sun.star.drawing.XDrawView
+com.sun.star.beans.XPropertySet
+com.sun.star.frame.XDispatchProvider
+com.sun.star.ui.XContextMenuInterception
+com.sun.star.task.XStatusIndicatorSupplier
+com.sun.star.drawing.DrawingDocumentDrawView
+TOPIC:
+com.sun.star.view.XSelectionSupplier
+com.sun.star.drawing.DrawingDocumentDrawView
+
+LINK:Documentation/DevGuide/Spreadsheets/Sheet_Outline
+DESCR:Spreadsheets - Sheet Outline
+REF:
+com.sun.star.sheet.XSheetOutline
+com.sun.star.table.TableOrientation
+TOPIC:
+com.sun.star.sheet.XSheetOutline
+
+LINK:Documentation/DevGuide/Text/Example:_Visible_Cursor_Position
+DESCR:Text - Example: Visible Cursor Position
+REF:
+com.sun.star.frame.Desktop
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Driver_Service
+DESCR:Database - Driver Service
+REF:
+com.sun.star.sdbc.XDriver
+com.sun.star.sdbc.Driver
+TOPIC:
+com.sun.star.sdbc.Driver
+
+LINK:Documentation/DevGuide/Database/The_Descriptor_Pattern
+DESCR:Database - The Descriptor Pattern
+REF:
+com.sun.star.sdbcx.XDataDescriptorFactory
+com.sun.star.sdbcx.TableDescriptor
+com.sun.star.beans.XPropertySet
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Sheet_Links
+DESCR:Spreadsheets - Sheet Links
+REF:
+com.sun.star.beans.XPropertySet
+com.sun.star.sheet.SheetLink
+com.sun.star.sheet.SheetLinkMode
+com.sun.star.container.XNameAccess
+com.sun.star.sheet.SheetLinks
+com.sun.star.sheet.XSheetLinkable
+com.sun.star.util.XRefreshable
+TOPIC:
+com.sun.star.sheet.SheetLink
+com.sun.star.sheet.SheetLinks
+com.sun.star.sheet.XSheetLinkable
+
+LINK:Documentation/DevGuide/Spreadsheets/Levels
+DESCR:Spreadsheets - Levels
+REF:
+com.sun.star.sheet.MemberResultFlags
+com.sun.star.sheet.GeneralFunction
+com.sun.star.sheet.MemberResult
+com.sun.star.beans.XPropertySet
+com.sun.star.sheet.DataPilotSourceLevel
+com.sun.star.sheet.XDataPilotMemberResults
+TOPIC:
+com.sun.star.sheet.DataPilotSourceLevel
+
+LINK:Documentation/DevGuide/Forms/Form_Layer_Views#Locating_Controls
+DESCR:Forms - Form Layer Views - Locating Controls
+REF:
+com.sun.star.view.XControlAccess
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Java/Mapping_of_Singletons
+DESCR:ProUNO - Java - Mapping of Singletons
+REF:
+com.sun.star.uno.XComponentContext
+com.sun.star.uno.DeploymentException
+TOPIC:
+
+LINK:Documentation/DevGuide/FirstSteps/First_Contact#Failed_Connections
+DESCR:FirstSteps - First Contact - Getting Started - Failed Connections
+REF:
+com.sun.star.lang.DisposedException
+TOPIC:
+com.sun.star.lang.DisposedException
+
+LINK:Documentation/DevGuide/Spreadsheets/Fill_Series
+DESCR:Spreadsheets - Fill Series
+REF:
+com.sun.star.sheet.FillDateMode
+com.sun.star.sheet.XCellSeries
+com.sun.star.sheet.FillDirection
+com.sun.star.sheet.FillMode
+TOPIC:
+com.sun.star.sheet.XCellSeries
+
+LINK:Documentation/DevGuide/ProUNO/Exceptions
+DESCR:ProUNO - Exceptions
+REF:
+com.sun.star.uno.Exception
+com.sun.star.uno.XInterface
+com.sun.star.uno.RuntimeException
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Other_Table_Operations#Charts
+DESCR:Spreadsheets - Other Table Operations - Charts
+REF:
+com.sun.star.table.XTableCharts
+com.sun.star.container.XNamed
+com.sun.star.container.XEnumerationAccess
+com.sun.star.container.XIndexAccess
+com.sun.star.table.TableCharts
+com.sun.star.document.XEmbeddedObjectSupplier
+com.sun.star.table.XTableChart
+com.sun.star.table.TableChart
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Inserting_a_Paragraph_where_no_Cursor_can_go
+DESCR:Text - Inserting a Paragraph where no Cursor can go
+REF:
+com.sun.star.text.Text
+com.sun.star.text.Paragraph
+com.sun.star.text.TextTable
+com.sun.star.text.TextSection
+com.sun.star.text.XRelativeTextContentInsert
+TOPIC:
+com.sun.star.text.XRelativeTextContentInsert
+
+LINK:Documentation/DevGuide/WritingUNO/Create_Instance_with_Arguments
+DESCR:WritingUNO - Create Instance with Arguments
+REF:
+com.sun.star.lang.XSingleServiceFactory
+com.sun.star.lang.XInitialization
+com.sun.star.lang.XSingleComponentFactory
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Value_Bindings
+DESCR:Forms - Value Bindings
+REF:
+com.sun.star.form.binding.XBindableValue
+com.sun.star.form.binding.XValueBinding
+com.sun.star.util.XModifyListener
+com.sun.star.form.binding.IncompatibleTypesException
+com.sun.star.util.XModifyBroadcaster
+com.sun.star.form.binding.ValueBinding
+com.sun.star.beans.XPropertyChangeListener
+TOPIC:
+com.sun.star.form.binding.XBindableValue
+com.sun.star.form.binding.XValueBinding
+
+LINK:Documentation/DevGuide/Scripting/Integration_with_Extension_Manager
+DESCR:Scripting - Integration with Extension Manager
+REF:
+com.sun.star.deployment.PackageRegistryBackend
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Logical_Forms
+DESCR:Forms - Logical Forms
+REF:
+com.sun.star.form.FormComponent
+com.sun.star.form.FormComponents
+com.sun.star.form.component.Form
+TOPIC:
+com.sun.star.form.component.Form
+
+LINK:Documentation/DevGuide/AdvUNO/XInvocation_Bridge#Argument_Conversion
+DESCR:AdvUNO - XInvocation Bridge - Scripting Existing UNO Objects - Argument Conversion
+REF:
+com.sun.star.beans.XMaterialHolder
+com.sun.star.reflection.CoreReflection
+com.sun.star.script.Invocation
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Protecting_Spreadsheets
+DESCR:Spreadsheets - Protecting Spreadsheets
+REF:
+com.sun.star.util.XProtectable
+com.sun.star.document.XActionLockable
+TOPIC:
+com.sun.star.util.XProtectable
+com.sun.star.document.XActionLockable
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleValue
+DESCR:Accessibility - XAccessibleValue
+REF:
+com.sun.star.accessibility.XAccessibleValue
+TOPIC:
+com.sun.star.accessibility.XAccessibleValue
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Controllers#XContextMenuInterception
+DESCR:OfficeDev - Component - Controllers - XContextMenuInterception
+REF:
+com.sun.star.ui.XContextMenuInterception
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/HTML_Forms
+DESCR:Forms - HTML Forms
+REF:
+com.sun.star.form.XReset
+com.sun.star.form.XSubmit
+com.sun.star.form.component.HTMLForm
+TOPIC:
+com.sun.star.form.component.HTMLForm
+
+LINK:Documentation/DevGuide/Spreadsheets/Cell_and_Cell_Range_Access
+DESCR:Spreadsheets - Cell and Cell Range Access
+REF:
+com.sun.star.sheet.XSheetCellRange
+com.sun.star.sheet.XSpreadsheet
+com.sun.star.table.XCellRange
+TOPIC:
+com.sun.star.sheet.XSheetCellRange
+com.sun.star.sheet.SheetCellRange
+com.sun.star.table.XCellRange
+
+LINK:Documentation/DevGuide/ProUNO/CLI/Important_Interfaces_and_Implementations
+DESCR:ProUNO - CLI - Important Interfaces and Implementations
+REF:
+com.sun.star.lang.XComponent
+com.sun.star.beans.XPropertySet
+com.sun.star.lang.XEventListener
+com.sun.star.uno.XWeak
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Printing_Text_Documents#Printer_and_Print_Job_Settings
+DESCR:Text - Printing Text Documents - Printer and Print Job Settings
+REF:
+com.sun.star.awt.Size
+com.sun.star.view.PaperOrientation
+com.sun.star.view.PrintOptions
+com.sun.star.view.PrinterDescriptor
+com.sun.star.view.XPrintable
+com.sun.star.view.PaperFormat
+TOPIC:
+com.sun.star.view.XPrintable
+
+LINK:Documentation/DevGuide/Forms/Control_Models_Forms
+DESCR:Forms - Control Models Forms
+REF:
+com.sun.star.lang.XServiceInfo
+com.sun.star.form.XFormComponent
+com.sun.star.form.FormControlModel
+com.sun.star.form.component.Form
+com.sun.star.form.XForm
+com.sun.star.awt.XTabControllerModel
+com.sun.star.form.component.DataForm
+com.sun.star.form.component.HTMLForm
+TOPIC:
+com.sun.star.form.component.Form
+com.sun.star.form.XForm
+com.sun.star.awt.XTabControllerModel
+com.sun.star.form.component.HTMLForm
+
+LINK:Documentation/DevGuide/GUI/Events#Mouse_Listeners
+DESCR:GUI - Events - Mouse Listeners
+REF:
+com.sun.star.awt.XMouseListener
+com.sun.star.awt.XMouseMotionListener
+com.sun.star.awt.MenuEvent
+TOPIC:
+
+LINK:Documentation/DevGuide/AdvUNO/UNO_Reflection_API#InvocationAdapterFactory
+DESCR:AdvUNO - UNO Reflection API - CoreReflection Service - InvocationAdapterFactory
+REF:
+com.sun.star.script.XInvocationAdapterFactory2
+com.sun.star.script.XInvocationAdapterFactory
+com.sun.star.script.InvocationAdapterFactory
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Merging_Cell_Ranges_into_a_Single_Cell
+DESCR:Spreadsheets - Merging Cell Ranges into a Single Cell
+REF:
+com.sun.star.util.XMergeable
+TOPIC:
+com.sun.star.util.XMergeable
+
+LINK:Documentation/DevGuide/Database/Group_Service
+DESCR:Database - Group Service
+REF:
+com.sun.star.sdbcx.XAuthorizable
+com.sun.star.sdbcx.Group
+com.sun.star.sdbcx.XUsersSupplier
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Table_Service
+DESCR:Database - Table Service
+REF:
+com.sun.star.sdbcx.XDataDescriptorFactory
+com.sun.star.sdbcx.XKeysSupplier
+com.sun.star.sdbcx.XColumnsSupplier
+com.sun.star.sdbcx.XIndexesSupplier
+com.sun.star.sdbcx.XAlterTable
+com.sun.star.sdbcx.XRename
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Accessing_Dialogs
+DESCR:WritingUNO - Accessing Dialogs
+REF:
+com.sun.star.awt.XDialogProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Handling_Documents#Target_Frame
+DESCR:OfficeDev - Handling Documents - Loading Documents - Target Frame
+REF:
+com.sun.star.frame.XComponentLoader
+com.sun.star.lang.XComponent
+com.sun.star.frame.FrameSearchFlag
+com.sun.star.frame.XFrame
+com.sun.star.frame.XModel
+TOPIC:
+com.sun.star.frame.FrameSearchFlag
+
+LINK:Documentation/DevGuide/GUI/Instantiation_of_a_Dialog
+DESCR:GUI - Instantiation of a Dialog
+REF:
+com.sun.star.awt.XControlContainer
+com.sun.star.container.XNameContainer
+com.sun.star.awt.XControl
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Operations
+DESCR:Spreadsheets - Operations
+REF:
+com.sun.star.sheet.GeneralFunction
+com.sun.star.sheet.CellFlags
+com.sun.star.sheet.XSheetOperation
+TOPIC:
+com.sun.star.sheet.XSheetOperation
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Controllers#XDispatchProvider
+DESCR:OfficeDev - Component - Controllers - XDispatchProvider
+REF:
+com.sun.star.frame.XDispatchProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/FormComponents_Service
+DESCR:Forms - FormComponents Service
+REF:
+com.sun.star.form.FormComponents
+TOPIC:
+com.sun.star.form.FormComponents
+
+LINK:Documentation/DevGuide/Spreadsheets/Compatibility_Names
+DESCR:Spreadsheets - Compatibility Names
+REF:
+com.sun.star.sheet.XCompatibilityNames
+TOPIC:
+com.sun.star.sheet.XCompatibilityNames
+
+LINK:Documentation/DevGuide/Text/Printing_Text_Documents#Printing_Multiple_Pages_on_one_Page
+DESCR:Text - Printing Text Documents - Printing Multiple Pages on one Page
+REF:
+com.sun.star.text.XPagePrintable
+com.sun.star.beans.PropertyValue
+com.sun.star.text.PagePrintSettings
+TOPIC:
+com.sun.star.text.XPagePrintable
+
+LINK:Documentation/DevGuide/Database/Database_Design#SQL_Objects_and_their_Attributes
+DESCR:Database - Database Design - Retrieving Information about a Database - SQL Objects and their Attributes
+REF:
+com.sun.star.sdbc.XDatabaseMetaData
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Intercepting_Context_Menus
+DESCR:WritingUNO - Intercepting Context Menus
+REF:
+com.sun.star.frame.Controller
+com.sun.star.ui.XContextMenuInterception
+TOPIC:
+com.sun.star.ui.XContextMenuInterception
+
+LINK:Documentation/DevGuide/AdvUNO/UNO_Reflection_API#XTypeProvider_Interface
+DESCR:AdvUNO - UNO Reflection API - XTypeProvider Interface
+REF:
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/AdvUNO/XInvocation_Bridge#Proxying_a_UNO_Object
+DESCR:AdvUNO - XInvocation Bridge - Scripting Existing UNO Objects - Proxying a UNO Object
+REF:
+com.sun.star.lang.XSingleServiceFactory
+com.sun.star.script.XInvocation
+com.sun.star.bridge.UnoUrlResolver
+com.sun.star.script.Invocation
+TOPIC:
+
+LINK:Documentation/DevGuide/UCB/Folders#Accessing_the_Children_of_a_Folder
+DESCR:UCB - Folders - Accessing the Children of a Folder
+REF:
+com.sun.star.sdbc.XRow
+com.sun.star.ucb.XContentAccess
+com.sun.star.ucb.OpenCommandArgument2
+com.sun.star.ucb.DynamicResultSet
+com.sun.star.beans.Property
+com.sun.star.ucb.XDynamicResultSet
+com.sun.star.sdbc.XResultSet
+TOPIC:
+com.sun.star.ucb.OpenCommandArgument2
+com.sun.star.ucb.DynamicResultSet
+
+LINK:Documentation/DevGuide/WritingUNO/Jobs/Returning_Results
+DESCR:WritingUNO - Jobs - Returning Results
+REF:
+com.sun.star.beans.NamedValue
+com.sun.star.frame.DispatchResultEvent
+com.sun.star.task.XJobListener
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Line_Numbering_and_Outline_Numbering#Number_Formats
+DESCR:Text - Line Numbering and Outline Numbering - Number Formats
+REF:
+com.sun.star.util.XNumberFormatsSupplier
+TOPIC:
+com.sun.star.util.XNumberFormatsSupplier
+
+LINK:Documentation/DevGuide/OfficeDev/XML_Based_Filter_Development#Introduction
+DESCR:OfficeDev - XML Based Filter Development - Introduction
+REF:
+com.sun.star.document.XFilter
+com.sun.star.xml.sax.XDocumentHandler
+TOPIC:
+com.sun.star.document.XFilter
+
+LINK:Documentation/DevGuide/ProUNO/Collections_and_Containers
+DESCR:ProUNO - Collections and Containers
+REF:
+com.sun.star.container.XContainer
+com.sun.star.container
+com.sun.star.container.XEnumerationAccess
+com.sun.star.container.XIndexAccess
+com.sun.star.container.XElementAccess
+com.sun.star.container.XIndexReplace
+com.sun.star.container.XNameAccess
+com.sun.star.container.XContainerListener
+com.sun.star.container.XIndexContainer
+TOPIC:
+com.sun.star.container.XNameContainer
+com.sun.star.container.XEnumerationAccess
+com.sun.star.container.XIndexAccess
+com.sun.star.container.XNameAccess
+com.sun.star.container.XIndexContainer
+
+LINK:Documentation/DevGuide/WritingUNO/C++/Create_Instance_with_Arguments
+DESCR:WritingUNO - C++ - Create Instance with Arguments
+REF:
+com.sun.star.lang.XInitialization
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/Date_Field
+DESCR:Basic - Date Field
+REF:
+com.sun.star.awt.UnoControlDateField
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/UNO_Interprocess_Connections
+DESCR:ProUNO - UNO Interprocess Connections
+REF:
+TOPIC:
+com.sun.star.uno.XComponentContext
+com.sun.star.bridge.XUnoUrlResolver
+com.sun.star.lang.DisposedException
+com.sun.star.bridge.UnoUrlResolver
+com.sun.star.lang.XMultiComponentFactory
+com.sun.star.lang.ServiceManager
+
+LINK:Documentation/DevGuide/OfficeDev/Writing_the_Filtering_Component#XExportFilter
+DESCR:OfficeDev - Writing the Filtering Component - XExportFilter
+REF:
+com.sun.star.xml.XExportFilter
+TOPIC:
+
+LINK:Documentation/DevGuide/AdvUNO/Implementation_Loader#Shared_Library_Loader
+DESCR:AdvUNO - Implementation Loader - Shared Library Loader
+REF:
+com.sun.star.loader.SharedLibrary
+TOPIC:
+com.sun.star.loader.SharedLibrary
+
+LINK:Documentation/DevGuide/Database/The_SDBC_Driver_for_ADO
+DESCR:Database - The SDBC Driver for ADO
+REF:
+com.sun.star.sdbcx.Driver
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Closing_a_Connection
+DESCR:ProUNO - Closing a Connection
+REF:
+com.sun.star.lang.XEventListener
+com.sun.star.lang.DisposedException
+com.sun.star.uno.RuntimeException
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Hierarchies
+DESCR:Spreadsheets - Hierarchies
+REF:
+com.sun.star.sheet.DataPilotSourceDimension
+com.sun.star.sheet.DataPilotSourceHierarchy
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Properties_of_a_FrameLoader
+DESCR:OfficeDev - Properties of a FrameLoader
+REF:
+com.sun.star.document.FilterFactory
+com.sun.star.frame.SynchronousFrameLoader
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.container.XNameAccess
+com.sun.star.frame.FrameLoaderFactory
+com.sun.star.frame.FrameLoader
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Connecting_Using_the_DriverManager_and_a_Database_URL
+DESCR:Database - Connecting Using the DriverManager and a Database URL
+REF:
+com.sun.star.sdbc.XDriverManager
+com.sun.star.sdbc.DriverManager
+com.sun.star.beans.PropertyValue
+TOPIC:
+com.sun.star.sdbc.DriverManager
+
+LINK:Documentation/DevGuide/UCB/Obtaining_Content_Properties
+DESCR:UCB - Obtaining Content Properties
+REF:
+com.sun.star.sdbc.XRow
+com.sun.star.ucb.Command
+com.sun.star.beans.Property
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Defining_an_Interface#Attributes
+DESCR:WritingUNO - Defining an Interface - Attributes
+REF:
+com.sun.star.awt.Size
+com.sun.star.uno.XInterface
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/Usage_of_Types#Structs
+DESCR:ProUNO - Bridge - Usage of Types - Structs
+REF:
+com.sun.star.reflection.XIdlClass
+com.sun.star.reflection.CoreReflection
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/Getting_the_Dialog_Model
+DESCR:Basic - Getting the Dialog Model
+REF:
+com.sun.star.awt.XControl
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Overall_Document_Features#Page_Styles
+DESCR:Text - Overall Document Features - Styles - Page Styles
+REF:
+com.sun.star.style.PageStyle
+com.sun.star.lang.XMultiServiceFactory
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/Common_Properties
+DESCR:GUI - Common Properties
+REF:
+com.sun.star.awt.XWindow
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/Using_the_Accessibility_API
+DESCR:Accessibility - Using the Accessibility API
+REF:
+com.sun.star.accessibility.XAccessibleEventListener
+com.sun.star.awt.XTopWindowListener
+com.sun.star.awt.XExtendedToolkit
+com.sun.star.accessibility.AccessibleEventObject
+com.sun.star.accessibility.XAccessibleContext
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Cell_Ranges_and_Cells_Container
+DESCR:Spreadsheets - Cell Ranges and Cells Container
+REF:
+com.sun.star.sheet.SheetCellRanges
+com.sun.star.sheet.SheetRangesQuery
+TOPIC:
+com.sun.star.sheet.SheetCellRanges
+
+LINK:Documentation/DevGuide/Drawings/Presentation_Settings
+DESCR:Drawings - Presentation Settings
+REF:
+com.sun.star.presentation.Presentation
+com.sun.star.presentation.XPresentation
+com.sun.star.presentation.XPresentationSupplier
+TOPIC:
+com.sun.star.presentation.XPresentation
+
+LINK:Documentation/DevGuide/WritingUNO/XComponent
+DESCR:WritingUNO - XComponent
+REF:
+com.sun.star.lang.XComponent
+com.sun.star.lang.XEventListener
+TOPIC:
+com.sun.star.lang.XComponent
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Controllers#XController
+DESCR:OfficeDev - Component - Controllers - XController
+REF:
+com.sun.star.frame.XController
+com.sun.star.lang.XComponent
+com.sun.star.frame.XFrame
+com.sun.star.frame.XModel
+TOPIC:
+com.sun.star.frame.Controller
+
+LINK:Documentation/DevGuide/Spreadsheets/Overall_Document_Features#Styles
+DESCR:Spreadsheets - Overall Document Features - Styles
+REF:
+com.sun.star.style.XStyleFamiliesSupplier
+TOPIC:
+com.sun.star.style.XStyleFamiliesSupplier
+
+LINK:Documentation/DevGuide/OfficeDev/Command_URL
+DESCR:OfficeDev - Command URL
+REF:
+com.sun.star.util.URL
+TOPIC:
+com.sun.star.util.URL
+
+LINK:Documentation/DevGuide/AppendixA/General_Design_Rules#Inheritance
+DESCR:AppendixA - General Design Rules - Inheritance
+REF:
+com.sun.star.uno.XInterface
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Dispatch_Process#Getting_a_Dispatch_Object
+DESCR:OfficeDev - Dispatch Process - Getting a Dispatch Object
+REF:
+com.sun.star.frame.XDispatchProvider
+com.sun.star.frame.XDispatch
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Weak_Objects_and_References
+DESCR:ProUNO - Weak Objects and References
+REF:
+com.sun.star.uno.XAdapter
+com.sun.star.uno.XReference
+com.sun.star.uno.XWeak
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Indexes_and_Index_Marks
+DESCR:Text - Indexes and Index Marks
+REF:
+TOPIC:
+com.sun.star.text.BaseIndex
+com.sun.star.text.XDocumentIndex
+
+LINK:Documentation/DevGuide/WritingUNO/The_UNO_Executable
+DESCR:WritingUNO - The UNO Executable
+REF:
+com.sun.star.lang.XMain
+TOPIC:
+com.sun.star.lang.XMain
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Window_Interfaces#XTopWindow
+DESCR:OfficeDev - Component - Window Interfaces - XTopWindow
+REF:
+com.sun.star.awt.WindowEvent
+com.sun.star.awt.XMenuBar
+com.sun.star.awt.XTopWindow
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/Progress_Bar
+DESCR:Basic - Progress Bar
+REF:
+com.sun.star.awt.UnoControlProgressBar
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Processing_Chain
+DESCR:OfficeDev - Processing Chain
+REF:
+com.sun.star.frame.FeatureStateEvent
+com.sun.star.frame.XDispatchProviderInterception
+com.sun.star.frame.XDispatchProvider
+com.sun.star.util.URL
+com.sun.star.util.URLTransformer
+com.sun.star.frame.XDispatch
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Filtering_Process#TypeDetection
+DESCR:OfficeDev - Filtering Process - TypeDetection
+REF:
+com.sun.star.document.TypeDetection
+com.sun.star.frame.FrameLoaderFactory
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Update
+DESCR:Database - Update
+REF:
+com.sun.star.sdbc.XRowUpdate
+com.sun.star.sdbc.XResultSetUpdate
+TOPIC:
+com.sun.star.sdbc.XRowUpdate
+
+LINK:Documentation/DevGuide/Spreadsheets/Equally_Formatted_Cell_Ranges#Cell_Format_Ranges
+DESCR:Spreadsheets - Equally Formatted Cell Ranges - Cell Format Ranges
+REF:
+com.sun.star.sheet.CellFormatRanges
+TOPIC:
+com.sun.star.sheet.CellFormatRanges
+
+LINK:Documentation/DevGuide/Database/Creating_a_User
+DESCR:Database - Creating a User
+REF:
+com.sun.star.sdbcx.UserDescriptor
+com.sun.star.sdbcx.XDataDescriptorFactory
+TOPIC:
+com.sun.star.sdbcx.UserDescriptor
+
+LINK:Documentation/DevGuide/Database/The_DataSource_Service#Adding_and_Editing_Datasources
+DESCR:Database - The DataSource Service - Adding and Editing Datasources
+REF:
+com.sun.star.frame.XStorable
+com.sun.star.beans.XPropertySet
+com.sun.star.lang.XSingleServiceFactory
+com.sun.star.container.XContainer
+com.sun.star.container.XNameAccess
+com.sun.star.uno.XNamingService
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Predefined_Variables
+DESCR:OfficeDev - Predefined Variables
+REF:
+com.sun.star.util.PathSubstitution
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/Listeners_and_Broadcasters
+DESCR:Accessibility - Listeners and Broadcasters
+REF:
+com.sun.star.accessibility.XAccessibleEventListener
+com.sun.star.accessibility.XAccessibleEventBroadcaster
+com.sun.star.accessibility.AccessibleEventObject
+com.sun.star.accessibility.AccessibleEventId
+TOPIC:
+com.sun.star.accessibility.XAccessibleEventListener
+com.sun.star.accessibility.XAccessibleEventBroadcaster
+
+LINK:Documentation/DevGuide/GUI/Label_Field
+DESCR:GUI - Label Field
+REF:
+com.sun.star.awt.UnoControlFixedTextModel
+com.sun.star.awt.UnoControlFixedText
+TOPIC:
+
+LINK:Documentation/DevGuide/Drawings/Working_with_Presentation_Documents
+DESCR:Drawings - Working with Presentation Documents
+REF:
+com.sun.star.presentation.DrawPage
+com.sun.star.drawing.XDrawPagesSupplier
+com.sun.star.presentation.XPresentation
+TOPIC:
+com.sun.star.presentation.DrawPage
+com.sun.star.presentation.XPresentation
+
+LINK:Documentation/DevGuide/OfficeDev/Filter
+DESCR:OfficeDev - Filter
+REF:
+com.sun.star.document.FilterFactory
+com.sun.star.document.XFilter
+com.sun.star.container.XNamed
+com.sun.star.document.XImporter
+com.sun.star.lang.XInitialization
+com.sun.star.beans.PropertyValue
+com.sun.star.document.ImportFilter
+com.sun.star.document.XExporter
+com.sun.star.document.ExportFilter
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Linguistics
+DESCR:OfficeDev - Linguistics
+REF:
+TOPIC:
+com.sun.star.linguistic2.Hyphenator
+com.sun.star.linguistic2.SpellChecker
+com.sun.star.linguistic2.LinguServiceManager
+com.sun.star.linguistic2.DictionaryList
+com.sun.star.linguistic2.LinguProperties
+com.sun.star.linguistic2.Thesaurus
+
+LINK:Documentation/DevGuide/WritingUNO/Write_Registration_Info_Using_a_Helper_Method
+DESCR:WritingUNO - Write Registration Info Using a Helper Method
+REF:
+com.sun.star.registry.XRegistryKey
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/The_SDBC_Driver_for_ODBC
+DESCR:Database - The SDBC Driver for ODBC
+REF:
+com.sun.star.sdbc.ODBCConnectionProperties
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Using_Dialogs_in_Components#Instantiate_and_display_a_dialog
+DESCR:WritingUNO - Using Dialogs in Components - Instantiate and display a dialog
+REF:
+com.sun.star.uno.XComponentContext
+com.sun.star.awt.XDialog
+com.sun.star.awt.XDialogProvider2
+com.sun.star.awt.DialogProvider2
+com.sun.star.awt.DialogProvider
+com.sun.star.frame.XModel
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Handling_Documents#Loading_Documents
+DESCR:OfficeDev - Handling Documents - Loading Documents
+REF:
+com.sun.star.frame.XComponentLoader
+com.sun.star.document.MediaDescriptor
+com.sun.star.frame.Desktop
+TOPIC:
+com.sun.star.frame.XComponentLoader
+
+LINK:Documentation/DevGuide/Spreadsheets/Function_Handling#Calculating_Function_Results
+DESCR:Spreadsheets - Function Handling - Calculating Function Results
+REF:
+com.sun.star.sheet.XFunctionAccess
+com.sun.star.sheet.FunctionAccess
+TOPIC:
+com.sun.star.sheet.FunctionAccess
+
+LINK:Documentation/DevGuide/GUI/File_Control
+DESCR:GUI - File Control
+REF:
+com.sun.star.awt.UnoControlEdit
+com.sun.star.awt.UnoControlFileControl
+com.sun.star.ui.dialogs.FilePicker
+com.sun.star.awt
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/Other_Common_Properties
+DESCR:GUI - Other Common Properties
+REF:
+com.sun.star.util.Color
+com.sun.star.awt.VisualEffect
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/The_RowSet_Service
+DESCR:Database - The RowSet Service
+REF:
+com.sun.star.sdb.RowSet
+com.sun.star.sdb.ResultSet
+TOPIC:
+com.sun.star.sdb.RowSet
+
+LINK:Documentation/DevGuide/Spreadsheets/Indentation
+DESCR:Spreadsheets - Indentation
+REF:
+com.sun.star.util.XIndent
+TOPIC:
+com.sun.star.util.XIndent
+
+LINK:Documentation/DevGuide/GUI/Displaying_Dialogs
+DESCR:GUI - Displaying Dialogs
+REF:
+com.sun.star.awt.XDialog
+com.sun.star.awt.XWindow
+com.sun.star.awt.XWindowPeer
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Result_Sets
+DESCR:Database - Result Sets
+REF:
+com.sun.star.sdbcx.Container
+com.sun.star.sdbc.XRow
+com.sun.star.sdbcx.Column
+com.sun.star.sdbcx.ResultSet
+com.sun.star.sdbc.ResultSet
+com.sun.star.sdb.ColumnSettings
+com.sun.star.sdbcx.XColumnsSupplier
+com.sun.star.sdbcx.XRowLocate
+com.sun.star.sdb.ResultSet
+com.sun.star.sdb.ResultColumn
+com.sun.star.sdbcx.XDeleteRows
+TOPIC:
+com.sun.star.sdbcx.ResultSet
+com.sun.star.sdbc.ResultSet
+com.sun.star.sdb.ResultSet
+
+LINK:Documentation/DevGuide/Basic/Command_Button
+DESCR:Basic - Command Button
+REF:
+com.sun.star.awt.XButton
+com.sun.star.awt.UnoControlButton
+TOPIC:
+
+LINK:Documentation/DevGuide/Drawings/Slide_Transition
+DESCR:Drawings - Slide Transition
+REF:
+com.sun.star.presentation.DrawPage
+com.sun.star.presentation.AnimationSpeed
+com.sun.star.presentation.FadeEffect
+TOPIC:
+com.sun.star.presentation.DrawPage
+com.sun.star.presentation.FadeEffect
+
+LINK:Documentation/DevGuide/ProUNO/Services#Referencing_Interfaces
+DESCR:ProUNO - Services - Referencing Interfaces
+REF:
+com.sun.star.text.TextDocument
+TOPIC:
+
+LINK:Documentation/DevGuide/Glossary/Glossary
+DESCR:Glossary - Glossary
+REF:
+com.sun.star.frame.XComponentLoader
+com.sun.star.sdbc.XDriverManager
+com.sun.star.lang.XComponent
+com.sun.star.lang.XInitialization
+com.sun.star.lang.EventObject
+com.sun.star.uno.XInterface
+com.sun.star.container.XEnumerationAccess
+com.sun.star.bridge.UnoUrlResolver
+com.sun.star.text.HoriOrientation
+com.sun.star.container.XEnumeration
+com.sun.star.awt
+com.sun.star.lang.ServiceManager
+TOPIC:
+
+LINK:Documentation/DevGuide/Charts/Setting_the_Chart_Type
+DESCR:Charts - Setting the Chart Type
+REF:
+com.sun.star.chart.XChartDocument
+com.sun.star.chart.XYDiagram
+TOPIC:
+com.sun.star.chart.XYDiagram
+com.sun.star.chart.Diagram
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleImage
+DESCR:Accessibility - XAccessibleImage
+REF:
+com.sun.star.accessibility.XAccessibleImage
+com.sun.star.accessibility.XAccessibleContext
+TOPIC:
+com.sun.star.accessibility.XAccessibleImage
+
+LINK:Documentation/DevGuide/GUI/Time_Field
+DESCR:GUI - Time Field
+REF:
+com.sun.star.awt.UnoControlTimeFieldModel
+com.sun.star.awt.UnoControlTimeField
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/View_Service
+DESCR:Database - View Service
+REF:
+com.sun.star.sdbcx.CheckOption
+TOPIC:
+
+LINK:Documentation/DevGuide/Charts/Working_With_Charts#Document_Structure
+DESCR:Charts - Working With Charts - Document Structure
+REF:
+com.sun.star.chart.XChartDocument
+com.sun.star.lang.XComponent
+com.sun.star.chart
+com.sun.star.beans.XPropertySet
+com.sun.star.chart.ChartDataArray
+com.sun.star.chart.ChartData
+com.sun.star.chart.ChartArea
+com.sun.star.chart.ChartDocument
+com.sun.star.drawing.XShape
+TOPIC:
+com.sun.star.table.XTableChartsSupplier
+com.sun.star.chart.ChartDataArray
+com.sun.star.chart.ChartData
+com.sun.star.drawing.OLE2Shape
+com.sun.star.chart.ChartDocument
+
+LINK:Documentation/DevGuide/ProUNO/C++/Mapping_of_Services
+DESCR:ProUNO - C++ - Mapping of Services
+REF:
+com.sun.star.uno.XComponentContext
+com.sun.star.uno.DeploymentException
+com.sun.star.lang.XMultiComponentFactory
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/Showing_a_Dialog
+DESCR:Basic - Showing a Dialog
+REF:
+com.sun.star.awt.XDialog
+com.sun.star.io.XInputStreamProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/File_Control
+DESCR:Basic - File Control
+REF:
+com.sun.star.awt.UnoControlFileControl
+com.sun.star.ui.dialogs.FilePicker
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/Accessing_Libraries_from_Basic#Library_Container_API
+DESCR:Basic - Accessing Libraries from Basic - Library Container API
+REF:
+com.sun.star.script.XLibraryContainer2
+com.sun.star.container.XNameContainer
+com.sun.star.script.XLibraryContainer
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Object_Identity
+DESCR:ProUNO - Object Identity
+REF:
+com.sun.star.lang.XComponent
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleKeyBinding
+DESCR:Accessibility - XAccessibleKeyBinding
+REF:
+com.sun.star.accessibility.XAccessibleKeyBinding
+com.sun.star.awt.KeyStroke
+TOPIC:
+com.sun.star.accessibility.XAccessibleKeyBinding
+
+LINK:Documentation/DevGuide/FirstSteps/Element_Access#Name_Access
+DESCR:FirstSteps - Element Access - Name Access
+REF:
+com.sun.star.sheet.XSpreadsheets
+com.sun.star.container.XNameAccess
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Character_and_Paragraph_Format
+DESCR:Spreadsheets - Character and Paragraph Format
+REF:
+com.sun.star.table.XCell
+com.sun.star.style.ParagraphProperties
+com.sun.star.style.CharacterPropertiesComplex
+com.sun.star.style.CharacterPropertiesAsian
+com.sun.star.style.CharacterProperties
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Frames#Communication_through_Dispatch_Framework
+DESCR:OfficeDev - Frames - Communication through Dispatch Framework
+REF:
+com.sun.star.frame.XDispatchProvider
+com.sun.star.frame.XFrame
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Spreadsheet#Properties_of_Spreadsheet
+DESCR:Spreadsheets - Spreadsheet - Properties of Spreadsheet
+REF:
+com.sun.star.sheet.Spreadsheet
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Configuration
+DESCR:WritingUNO - Configuration
+REF:
+com.sun.star.frame.ProtocolHandler
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Using_DBMS_Features#Transaction_Handling
+DESCR:Database - Using DBMS Features - Transaction Handling
+REF:
+com.sun.star.sdbc.TransactionIsolation
+com.sun.star.sdbc.XConnection
+TOPIC:
+com.sun.star.sdbc.TransactionIsolation
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/Automation_Objects_with_UNO_Interfaces
+DESCR:ProUNO - Bridge - Automation Objects with UNO Interfaces
+REF:
+TOPIC:
+com.sun.star.lang.XEventListener
+
+LINK:Documentation/DevGuide/ProUNO/Exception_Handling
+DESCR:ProUNO - Exception Handling
+REF:
+com.sun.star.uno.Exception
+TOPIC:
+com.sun.star.uno.Exception
+com.sun.star.uno.RuntimeException
+
+LINK:Documentation/DevGuide/ProUNO/Java/Mapping_of_Enum_Types
+DESCR:ProUNO - Java - Mapping of Enum Types
+REF:
+com.sun.star.uno.TypeClass
+TOPIC:
+
+LINK:Documentation/DevGuide/AppendixC/The_Hierarchy_Content_Provider#Commands_and_Properties
+DESCR:AppendixC - The Hierarchy Content Provider - Commands and Properties
+REF:
+com.sun.star.ucb.XContent
+com.sun.star.lang.XServiceInfo
+com.sun.star.ucb.XContentCreator
+com.sun.star.lang.XComponent
+com.sun.star.container.XChild
+com.sun.star.ucb.XCommandInfoChangeNotifier
+com.sun.star.beans.XPropertySetInfoChangeNotifier
+com.sun.star.beans.XPropertiesChangeNotifier
+com.sun.star.beans.XPropertyContainer
+com.sun.star.ucb.XCommandProcessor
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Tables#Table_Architecture
+DESCR:Text - Tables - Table Architecture
+REF:
+com.sun.star.chart.XChartDataArray
+com.sun.star.text.XTextTable
+com.sun.star.text.TextContent
+com.sun.star.container.XNamed
+com.sun.star.table.XCellRange
+com.sun.star.text.TextTable
+com.sun.star.text.XTextContent
+com.sun.star.util.XSortable
+com.sun.star.table.XAutoFormattable
+TOPIC:
+com.sun.star.text.TextTable
+
+LINK:Documentation/DevGuide/Drawings/Exporting
+DESCR:Drawings - Exporting
+REF:
+com.sun.star.document.XFilter
+com.sun.star.document.XMimeTypeInfo
+com.sun.star.drawing.GraphicExportFilter
+com.sun.star.document.XExporter
+TOPIC:
+com.sun.star.drawing.GraphicExportFilter
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Getting_Frames%2C_Controllers_and_Models_from_Each_Other
+DESCR:OfficeDev - Component - Getting Frames, Controllers and Models from Each Other
+REF:
+com.sun.star.frame.XController
+com.sun.star.lang.XComponent
+com.sun.star.awt.XWindow
+com.sun.star.frame.XModel
+TOPIC:
+com.sun.star.frame.XController
+com.sun.star.frame.XFrame
+com.sun.star.frame.XModel
+
+LINK:Documentation/DevGuide/Database/Adding_and_Editing_Predefined_Queries
+DESCR:Database - Adding and Editing Predefined Queries
+REF:
+com.sun.star.sdb.DefinitionContainer
+com.sun.star.lang.XSingleServiceFactory
+com.sun.star.sdb.XQueryDefinitionsSupplier
+com.sun.star.container.XEnumerationAccess
+com.sun.star.container.XIndexAccess
+com.sun.star.container.XNameContainer
+com.sun.star.sdb.QueryDefinition
+com.sun.star.util.XRefreshable
+TOPIC:
+com.sun.star.sdb.DefinitionContainer
+
+LINK:Documentation/DevGuide/Database/Clones_of_the_RowSet_Service
+DESCR:Database - Clones of the RowSet Service
+REF:
+com.sun.star.sdb.XResultSetAccess
+com.sun.star.sdb.ResultSet
+TOPIC:
+com.sun.star.sdb.XResultSetAccess
+com.sun.star.sdb.ResultSet
+
+LINK:Documentation/DevGuide/OfficeDev/Using_the_Desktop
+DESCR:OfficeDev - Using the Desktop
+REF:
+com.sun.star.frame.XStorable
+com.sun.star.frame.XComponentLoader
+com.sun.star.util.XModifiable
+com.sun.star.document.EventObject
+com.sun.star.frame.XFrames
+com.sun.star.document.XEventBroadcaster
+com.sun.star.container.XEnumerationAccess
+com.sun.star.frame.XFramesSupplier
+com.sun.star.frame.XTerminateListener
+com.sun.star.document.Events
+com.sun.star.frame.XModel
+com.sun.star.frame.XDispatchProviderInterception
+com.sun.star.lang.XComponent
+com.sun.star.frame.XDispatchProvider
+com.sun.star.container.XIndexAccess
+com.sun.star.frame.XDesktop
+com.sun.star.frame.Desktop
+com.sun.star.frame.Frame
+com.sun.star.frame.XFrame
+TOPIC:
+com.sun.star.frame.XComponentLoader
+com.sun.star.frame.XFrames
+com.sun.star.document.XEventBroadcaster
+com.sun.star.frame.XDesktop
+com.sun.star.frame.Desktop
+
+LINK:Documentation/DevGuide/OfficeDev/Dispatch_Process#Listening_for_Context_Changes
+DESCR:OfficeDev - Dispatch Process - Listening for Context Changes
+REF:
+com.sun.star.frame.FrameActionEvent
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/The_Service_Manager_Component#From_UNO_Objects_to_Automation_Objects
+DESCR:ProUNO - Bridge - The Service Manager Component - From UNO Objects to Automation Objects
+REF:
+com.sun.star.bridge.oleautomation.BridgeSupplier
+TOPIC:
+
+LINK:Documentation/DevGuide/Drawings/Filter_Options
+DESCR:Drawings - Filter Options
+REF:
+com.sun.star.document.MediaDescriptor
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Inserting_Text_Files
+DESCR:Text - Inserting Text Files
+REF:
+com.sun.star.document.MediaDescriptor
+com.sun.star.document.XDocumentInsertable
+TOPIC:
+com.sun.star.document.XDocumentInsertable
+
+LINK:Documentation/DevGuide/OfficeDev/Implementing_a_New_Locale#XCollator
+DESCR:OfficeDev - Implementing a New Locale - XCollator
+REF:
+com.sun.star.i18n.XCollator
+TOPIC:
+com.sun.star.i18n.XCollator
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/Using_Automation_Objects_from_UNO
+DESCR:ProUNO - Bridge - Using Automation Objects from UNO
+REF:
+com.sun.star.script.XInvocation
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/acquire()_and_release()
+DESCR:ProUNO - acquire() and release()
+REF:
+com.sun.star.uno.XInterface
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Settings#Creating_Default_Settings
+DESCR:Text - Settings - Creating Default Settings
+REF:
+com.sun.star.text.Defaults
+com.sun.star.lang.XMultiServiceFactory
+TOPIC:
+com.sun.star.text.Defaults
+
+LINK:Documentation/DevGuide/Database/Using_DDL_to_Change_the_Database_Design
+DESCR:Database - Using DDL to Change the Database Design
+REF:
+com.sun.star.sdbc.XStatement
+com.sun.star.sdbc.DataType
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/CLI/Writing_Client_Programs
+DESCR:ProUNO - CLI - Writing Client Programs
+REF:
+com.sun.star.bridge.UnoUrlResolver
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Storing_Documents#Printing_Documents
+DESCR:OfficeDev - Storing Documents - Printing Documents
+REF:
+com.sun.star.view.XPrintable
+TOPIC:
+com.sun.star.view.XPrintable
+
+LINK:Documentation/DevGuide/Drawings/Ordering
+DESCR:Drawings - Ordering
+REF:
+com.sun.star.drawing.Shape
+TOPIC:
+
+LINK:Documentation/DevGuide/AppendixC/The_File_Content_Provider#Creation_of_New_File_Contents
+DESCR:AppendixC - The File Content Provider - Creation of New File Contents
+REF:
+com.sun.star.ucb.XContentCreator
+com.sun.star.io.XInputStream
+TOPIC:
+com.sun.star.ucb.XContentCreator
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/Mapping_of_Hyper_and_Decimal
+DESCR:ProUNO - Bridge - Mapping of Hyper and Decimal
+REF:
+com.sun.star.bridge.oleautomation.Decimal
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/DDE_Links
+DESCR:Spreadsheets - DDE Links
+REF:
+com.sun.star.sheet.XDDELink
+com.sun.star.sheet.DDELink
+com.sun.star.container.XNameAccess
+com.sun.star.util.XRefreshable
+TOPIC:
+com.sun.star.sheet.DDELink
+
+LINK:Documentation/DevGuide/Basic/Dialog_Properties
+DESCR:Basic - Dialog Properties
+REF:
+com.sun.star.awt.XDialog
+com.sun.star.beans.XPropertySet
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Detective
+DESCR:Spreadsheets - Detective
+REF:
+com.sun.star.sheet.XSheetAuditing
+TOPIC:
+com.sun.star.sheet.XSheetAuditing
+
+LINK:Documentation/DevGuide/WritingUNO/Jobs/Initialization
+DESCR:WritingUNO - Jobs - Initialization
+REF:
+com.sun.star.beans.NamedValue
+com.sun.star.frame.XFrame
+com.sun.star.frame.XModel
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Closing_Documents#XCloseable
+DESCR:OfficeDev - Closing Documents - XCloseable
+REF:
+com.sun.star.frame.XStorable
+com.sun.star.util.XCloseListener
+com.sun.star.util.XModifiable
+com.sun.star.frame.XController
+com.sun.star.util.XCloseBroadcaster
+com.sun.star.util.CloseVetoException
+com.sun.star.util.XCloseable
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Overview_and_Using_the_API#XBreakIterator
+DESCR:OfficeDev - Overview and Using the API - XBreakIterator
+REF:
+com.sun.star.i18n.XLocaleData
+com.sun.star.linguistic2.XHyphenator
+com.sun.star.i18n.XBreakIterator
+TOPIC:
+com.sun.star.i18n.XBreakIterator
+
+LINK:Documentation/DevGuide/Basic/Technical_Background
+DESCR:Basic - Technical Background
+REF:
+com.sun.star.resource
+com.sun.star.resource.StringResource
+com.sun.star.resource.XStringResourceSupplier
+com.sun.star.resource.XStringResourceResolver
+com.sun.star.resource.XStringResourceManager
+com.sun.star.resource.StringResourceWithStorage
+com.sun.star.resource.StringResourceWithLocation
+TOPIC:
+
+LINK:Documentation/DevGuide/Scripting/Writing_a_LanguageScriptProvider_UNO_Component_From_Scratch
+DESCR:Scripting - Writing a LanguageScriptProvider UNO Component From Scratch
+REF:
+com.sun.star.script.provider.LanguageScriptProvider
+com.sun.star.script.browse.BrowseNode
+com.sun.star.script.provider.XScript
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/C++/Transparent_Use_of_Office_UNO_Components
+DESCR:ProUNO - C++ - Transparent Use of Office UNO Components
+REF:
+TOPIC:
+com.sun.star.uno.XComponentContext
+com.sun.star.lang.XMultiComponentFactory
+
+LINK:Documentation/DevGuide/Text/Table_Naming%2C_Sorting%2C_Charting_and_Autoformatting
+DESCR:Text - Table Naming, Sorting, Charting and Autoformatting
+REF:
+com.sun.star.chart.XChartDataArray
+com.sun.star.chart.XChartData
+com.sun.star.container.XNamed
+com.sun.star.text.TextSortDescriptor
+com.sun.star.beans.PropertyValue
+com.sun.star.sheet.TableAutoFormats
+com.sun.star.table.XAutoFormattable
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Printing_Spreadsheet_Documents#Print_Areas
+DESCR:Spreadsheets - Printing Spreadsheet Documents - Print Areas
+REF:
+com.sun.star.sheet.XPrintAreas
+com.sun.star.table.CellRangeAddress
+TOPIC:
+com.sun.star.sheet.XPrintAreas
+
+LINK:Documentation/DevGuide/Spreadsheets/Equally_Formatted_Cell_Ranges#Unique_Cell_Format_Ranges
+DESCR:Spreadsheets - Equally Formatted Cell Ranges - Unique Cell Format Ranges
+REF:
+com.sun.star.sheet.SheetCellRanges
+com.sun.star.sheet.UniqueCellFormatRanges
+com.sun.star.sheet.CellFormatRanges
+TOPIC:
+com.sun.star.sheet.UniqueCellFormatRanges
+
+LINK:Documentation/DevGuide/GUI/Numeric_Field
+DESCR:GUI - Numeric Field
+REF:
+com.sun.star.awt.UnoControlNumericField
+com.sun.star.awt.UnoControlNumericFieldModel
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Text_Document_Controller
+DESCR:Text - Text Document Controller
+REF:
+com.sun.star.frame.XController
+com.sun.star.ui.XContextMenuInterceptor
+com.sun.star.frame.XDispatchProvider
+com.sun.star.frame.XModel
+TOPIC:
+com.sun.star.frame.Controller
+com.sun.star.document.XViewDataSupplier
+com.sun.star.frame.XModel
+
+LINK:Documentation/DevGuide/Database/Example:_Querying_the_Bibliography_Database
+DESCR:Database - Example: Querying the Bibliography Database
+REF:
+com.sun.star.sdb.RowSet
+TOPIC:
+com.sun.star.sdb.RowSet
+
+LINK:Documentation/DevGuide/ProUNO/Children_of_the_XEventListener_Interface
+DESCR:ProUNO - Children of the XEventListener Interface
+REF:
+com.sun.star.lang.XEventListener
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/XUnoTunnel
+DESCR:WritingUNO - XUnoTunnel
+REF:
+com.sun.star.lang.XUnoTunnel
+TOPIC:
+com.sun.star.lang.XUnoTunnel
+
+LINK:Documentation/DevGuide/OfficeDev/General_Notes
+DESCR:OfficeDev - General Notes
+REF:
+com.sun.star.beans.PropertyValue
+TOPIC:
+
+LINK:Documentation/DevGuide/Drawings/Navigating
+DESCR:Drawings - Navigating
+REF:
+com.sun.star.container.XNamed
+TOPIC:
+com.sun.star.container.XNamed
+
+LINK:Documentation/DevGuide/Forms/Scripting_and_Events
+DESCR:Forms - Scripting and Events
+REF:
+com.sun.star.awt.XItemListener
+com.sun.star.script.XEventAttacherManager
+com.sun.star.awt.XRadioButton
+com.sun.star.script.ScriptEventDescriptor
+com.sun.star.script.XScriptListener
+com.sun.star.form.FormComponents
+com.sun.star.awt.XCheckBox
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/Implementing_Accessible_Objects#Services
+DESCR:Accessibility - Implementing Accessible Objects - Services
+REF:
+com.sun.star.accessibility.XAccessibleEventBroadcaster
+com.sun.star.accessibility.Accessible
+com.sun.star.accessibility.AccessibleContext
+com.sun.star.accessibility.XAccessibleContext
+com.sun.star.accessibility.XAccessible
+TOPIC:
+com.sun.star.accessibility.AccessibleContext
+com.sun.star.accessibility.XAccessible
+
+LINK:Documentation/DevGuide/Text/TextViewCursor
+DESCR:Text - TextViewCursor
+REF:
+com.sun.star.view.XViewCursor
+com.sun.star.text.TextViewCursor
+com.sun.star.beans.XPropertySet
+com.sun.star.view.XLineCursor
+com.sun.star.text.XPageCursor
+com.sun.star.text.XTextViewCursorSupplier
+com.sun.star.view.XScreenCursor
+TOPIC:
+com.sun.star.text.TextViewCursor
+
+LINK:Documentation/DevGuide/GUI/Progress_Bar
+DESCR:GUI - Progress Bar
+REF:
+com.sun.star.awt.XReschedule
+com.sun.star.awt.XProgressBar
+com.sun.star.awt.UnoControlProgressBar
+com.sun.star.awt.UnoControlProgressBarModel
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Applying_Number_Formats#XNumberformatPreviewer
+DESCR:OfficeDev - Applying Number Formats - NumberFormatter Service - XNumberformatPreviewer
+REF:
+com.sun.star.util.XNumberFormatPreviewer
+com.sun.star.util.NumberFormats
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Service_Manager
+DESCR:ProUNO - Service Manager
+REF:
+com.sun.star.lang.ServiceManager
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Overall_Document_Features#Page_Styles
+DESCR:Spreadsheets - Overall Document Features - Styles - Page Styles
+REF:
+com.sun.star.style.PageStyle
+com.sun.star.sheet.HeaderFooterContent
+com.sun.star.text.XText
+com.sun.star.sheet.XHeaderFooterContent
+com.sun.star.sheet.TablePageStyle
+TOPIC:
+com.sun.star.sheet.TablePageStyle
+
+LINK:Documentation/DevGuide/Basic/Group_Box
+DESCR:Basic - Group Box
+REF:
+com.sun.star.awt.UnoControlGroupBox
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Parameters
+DESCR:Forms - Parameters
+REF:
+com.sun.star.sdbc.XParameters
+com.sun.star.sdb.RowSet
+com.sun.star.form.XDatabaseParameterListener
+com.sun.star.form.XDatabaseParameterBroadcaster
+com.sun.star.form.component.DataForm
+TOPIC:
+com.sun.star.form.XDatabaseParameterListener
+com.sun.star.form.XDatabaseParameterBroadcaster
+
+LINK:Documentation/DevGuide/WritingUNO/XInterface
+DESCR:WritingUNO - XInterface
+REF:
+com.sun.star.uno.TypeClass
+com.sun.star.uno.XInterface
+TOPIC:
+com.sun.star.uno.XInterface
+
+LINK:Documentation/DevGuide/FirstSteps/Objects%2C_Interfaces%2C_and_Services#Interfaces
+DESCR:FirstSteps - Objects, Interfaces, and Services - Interfaces
+REF:
+com.sun.star.resource.XResourceBundle
+com.sun.star.container.XNameAccess
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Applying_Number_Formats#XNumberformatter
+DESCR:OfficeDev - Applying Number Formats - NumberFormatter Service - XNumberformatter
+REF:
+com.sun.star.util.XNumberFormatter
+TOPIC:
+
+LINK:Documentation/DevGuide/Config/Object_Model
+DESCR:Config - Object Model
+REF:
+com.sun.star.configuration.ConfigurationUpdateAccess
+com.sun.star.configuration.ConfigurationProvider
+com.sun.star.configuration.ConfigurationAccess
+TOPIC:
+com.sun.star.configuration.ConfigurationUpdateAccess
+com.sun.star.configuration.ConfigurationProvider
+com.sun.star.configuration.ConfigurationAccess
+
+LINK:Documentation/DevGuide/Text/Formatting
+DESCR:Text - Formatting
+REF:
+com.sun.star.style.LineSpacing
+com.sun.star.style.CaseMap
+com.sun.star.table.CellRange
+com.sun.star.style.ParagraphProperties
+com.sun.star.beans.XPropertySet
+com.sun.star.style.TabStop
+com.sun.star.text.Shape
+com.sun.star.awt.FontSlant
+com.sun.star.style.CharacterProperties
+com.sun.star.beans.XVetoableChangeListener
+com.sun.star.lang.Locale
+com.sun.star.table.ShadowFormat
+com.sun.star.text.TextCursor
+com.sun.star.awt.FontFamily
+com.sun.star.beans.PropertyValue
+com.sun.star.style.CharacterPropertiesComplex
+com.sun.star.text.FontEmphasis
+com.sun.star.style.ParagraphPropertiesAsian
+com.sun.star.beans.XPropertyChangeListener
+com.sun.star.awt.FontWeight
+com.sun.star.util.Color
+com.sun.star.text.TextTableCursor
+com.sun.star.awt.FontType
+com.sun.star.awt.FontPitch
+com.sun.star.awt.FontStrikeout
+com.sun.star.container.XIndexReplace
+com.sun.star.style.BreakType
+com.sun.star.text.TextDocument
+com.sun.star.style.CharacterPropertiesAsian
+com.sun.star.awt.FontUnderline
+com.sun.star.style.GraphicLocation
+com.sun.star.text.XLineNumberingProperties
+com.sun.star.text.Paragraph
+com.sun.star.container.XNameContainer
+com.sun.star.text.TextPortion
+com.sun.star.awt.CharSet
+com.sun.star.style.DropCapFormat
+TOPIC:
+com.sun.star.text.TextTableCursor
+com.sun.star.text.TextCursor
+com.sun.star.style.ParagraphProperties
+com.sun.star.text.Paragraph
+com.sun.star.text.TextPortion
+com.sun.star.text.Shape
+com.sun.star.style.CharacterPropertiesComplex
+com.sun.star.style.BreakType
+com.sun.star.text.TextDocument
+com.sun.star.style.CharacterPropertiesAsian
+com.sun.star.style.CharacterProperties
+
+LINK:Documentation/DevGuide/ProUNO/Basic/Handling_UNO_Objects#Accessing_UNO_Services
+DESCR:ProUNO - Basic - Handling UNO Objects - Accessing UNO Services
+REF:
+com.sun.star.beans.XPropertySet
+com.sun.star.container.XNameContainer
+com.sun.star.container.XNameAccess
+com.sun.star.container.XNameReplace
+com.sun.star.beans.Introspection
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Initializing_Bound_Controls
+DESCR:Forms - Initializing Bound Controls
+REF:
+com.sun.star.form.XReset
+com.sun.star.form.component.DateField
+TOPIC:
+
+LINK:Documentation/DevGuide/FirstSteps/Element_Access
+DESCR:FirstSteps - Element Access
+REF:
+com.sun.star.container.XNameContainer
+com.sun.star.sheet.Spreadsheets
+com.sun.star.sheet.XSpreadsheetDocument
+com.sun.star.sheet.XSpreadsheets
+com.sun.star.container.XEnumeration
+com.sun.star.container.XIndexContainer
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Saving_Text_Documents#Storing
+DESCR:Text - Saving Text Documents - Storing
+REF:
+com.sun.star.frame.XStorable
+TOPIC:
+com.sun.star.frame.XStorable
+
+LINK:Documentation/DevGuide/Drawings/Working_with_Drawing_Documents#Document_Structure
+DESCR:Drawings - Working with Drawing Documents - Document Structure
+REF:
+com.sun.star.drawing.DrawPage
+com.sun.star.drawing.Layer
+com.sun.star.drawing.LayerManager
+com.sun.star.drawing.MasterPage
+TOPIC:
+com.sun.star.drawing.DrawPage
+
+LINK:Documentation/DevGuide/Drawings/Settings
+DESCR:Drawings - Settings
+REF:
+com.sun.star.beans.PropertySet
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.presentation.DocumentSettings
+com.sun.star.document.Settings
+com.sun.star.drawing.DocumentSettings
+TOPIC:
+com.sun.star.beans.PropertySet
+
+LINK:Documentation/DevGuide/OfficeDev/Handling_Documents#URL_Parameter
+DESCR:OfficeDev - Handling Documents - Loading Documents - URL Parameter
+REF:
+TOPIC:
+com.sun.star.util.URLTransformer
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/Using_Automation_Objects_from_UNO#Accessing_Automation_Objects
+DESCR:ProUNO - Bridge - Using Automation Objects from UNO - Instantiation - Accessing Automation Objects
+REF:
+com.sun.star.script.XInvocation
+TOPIC:
+
+LINK:Documentation/DevGuide/Extensions/Adding_a_Leaf_to_an_Existing_Node
+DESCR:Extensions - Adding a Leaf to an Existing Node
+REF:
+com.sun.star.container.XHierarchicalNameAccess
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/TextView
+DESCR:Text - TextView
+REF:
+com.sun.star.text.ViewSettings
+com.sun.star.text.XRubySelection
+com.sun.star.view.XSelectionSupplier
+com.sun.star.view.XViewSettingsSupplier
+com.sun.star.text.XTextViewCursorSupplier
+com.sun.star.drawing.ShapeCollection
+com.sun.star.uno.XInterface
+com.sun.star.container.XIndexAccess
+com.sun.star.view.XControlAccess
+com.sun.star.view.DocumentZoomType
+TOPIC:
+com.sun.star.view.XSelectionSupplier
+
+LINK:Documentation/DevGuide/OfficeDev/Overview_and_Using_the_API#XCharacterClassification
+DESCR:OfficeDev - Overview and Using the API - XCharacterClassification
+REF:
+com.sun.star.i18n.XLocaleData
+com.sun.star.i18n.XCharacterClassification
+TOPIC:
+com.sun.star.i18n.XCharacterClassification
+
+LINK:Documentation/DevGuide/Text/Ruby
+DESCR:Text - Ruby
+REF:
+com.sun.star.text.XRubySelection
+com.sun.star.style.CharacterProperties
+TOPIC:
+com.sun.star.text.XRubySelection
+com.sun.star.style.CharacterProperties
+
+LINK:Documentation/DevGuide/WritingUNO/Jobs/Execution_Environment
+DESCR:WritingUNO - Jobs - Execution Environment
+REF:
+com.sun.star.util.XCloseListener
+com.sun.star.document.OfficeDocument
+com.sun.star.frame.Frame
+com.sun.star.frame.Desktop
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Exception_Handling#Runtime_Exceptions
+DESCR:ProUNO - Exception Handling - Runtime Exceptions
+REF:
+com.sun.star.lang.XComponent
+com.sun.star.uno.Exception
+com.sun.star.uno.RuntimeException
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Windows
+DESCR:OfficeDev - Windows
+REF:
+com.sun.star.awt.XWindow
+com.sun.star.awt.XWindowPeer
+TOPIC:
+com.sun.star.awt.XWindow
+com.sun.star.awt.XWindowPeer
+com.sun.star.awt.XTopWindow
+
+LINK:Documentation/DevGuide/OfficeDev/Path_Variables
+DESCR:OfficeDev - Path Variables
+REF:
+com.sun.star.util.PathSubstitution
+TOPIC:
+
+LINK:Documentation/DevGuide/Charts/Creating_a_Chart_OLE_Object_in_Draw_and_Impress
+DESCR:Charts - Creating a Chart OLE Object in Draw and Impress
+REF:
+com.sun.star.drawing.XDrawPagesSupplier
+com.sun.star.drawing.XDrawPageSupplier
+com.sun.star.container.XIndexAccess
+com.sun.star.sheet.Spreadsheet
+TOPIC:
+com.sun.star.drawing.XDrawPagesSupplier
+
+LINK:Documentation/DevGuide/OfficeDev/XML_Filter_Detection
+DESCR:OfficeDev - XML Filter Detection
+REF:
+com.sun.star.document.ExtendedTypeDetection
+TOPIC:
+com.sun.star.document.ExtendedTypeDetection
+
+LINK:Documentation/DevGuide/JavaBean/OfficeWindow_Interface
+DESCR:JavaBean - OfficeWindow Interface
+REF:
+com.sun.star.awt.XWindowPeer
+TOPIC:
+com.sun.star.awt.XWindowPeer
+
+LINK:Documentation/DevGuide/ProUNO/Services#Service_Constructors
+DESCR:ProUNO - Services - Service Constructors
+REF:
+com.sun.star.uno.XComponentContext
+com.sun.star.uno.DeploymentException
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/XMain
+DESCR:WritingUNO - XMain
+REF:
+com.sun.star.lang.XMain
+TOPIC:
+com.sun.star.lang.XMain
+
+LINK:Documentation/DevGuide/Drawings/Shape_Types
+DESCR:Drawings - Shape Types
+REF:
+com.sun.star.drawing.LineShape
+com.sun.star.drawing.CircleKind
+com.sun.star.drawing.GroupShape
+com.sun.star.drawing.TextShape
+com.sun.star.drawing.XShapeGroup
+com.sun.star.drawing.PolyPolygonBezierShape
+com.sun.star.drawing.TextProperties
+com.sun.star.drawing.LineProperties
+com.sun.star.drawing.PluginShape
+com.sun.star.frame.XModel
+com.sun.star.drawing.ConnectorShape
+com.sun.star.drawing.Shape
+com.sun.star.drawing.PageShape
+com.sun.star.drawing.Text
+com.sun.star.drawing.XControlShape
+com.sun.star.drawing.ColorMode
+com.sun.star.drawing.ControlShape
+com.sun.star.drawing.MeasureProperties
+com.sun.star.beans.PropertyValue
+com.sun.star.drawing.RectangleShape
+com.sun.star.drawing.MeasureShape
+com.sun.star.drawing.GraphicObjectShape
+com.sun.star.drawing.FillProperties
+com.sun.star.drawing.XShape
+com.sun.star.drawing.XShapes
+com.sun.star.drawing.EllipseShape
+com.sun.star.awt.XBitmap
+com.sun.star.drawing.PolyPolygonBezierDescriptor
+com.sun.star.drawing.ConnectorProperties
+com.sun.star.drawing.PolyPolygonShape
+com.sun.star.drawing.OpenBezierShape
+com.sun.star.drawing.RotationDescriptor
+com.sun.star.drawing
+com.sun.star.container.XIndexContainer
+com.sun.star.awt.Point
+com.sun.star.drawing.ShadowProperties
+com.sun.star.drawing.PolyPolygonDescriptor
+com.sun.star.drawing.ClosedBezierShape
+com.sun.star.text.XText
+com.sun.star.drawing.PolyLineShape
+com.sun.star.drawing.OLE2Shape
+TOPIC:
+com.sun.star.drawing.Shape
+
+LINK:Documentation/DevGuide/UCB/Universal_Content_Broker#Capabilities
+DESCR:UCB - Universal Content Broker - Capabilities
+REF:
+com.sun.star.frame.Desktop
+TOPIC:
+com.sun.star.frame.Desktop
+com.sun.star.ucb.UniversalContentBroker
+
+LINK:Documentation/DevGuide/WritingUNO/C++/Implementing_without_Helpers#XTypeProvider_Implementation
+DESCR:WritingUNO - C++ - Implementing without Helpers - XTypeProvider Implementation
+REF:
+com.sun.star.uno.XInterface
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Dispatch_Interception
+DESCR:OfficeDev - Dispatch Interception
+REF:
+com.sun.star.frame.FeatureStateEvent
+com.sun.star.frame.XDispatchProviderInterception
+com.sun.star.frame.XDispatchProviderInterceptor
+com.sun.star.frame.XDispatchProvider
+com.sun.star.frame.XDispatch
+TOPIC:
+com.sun.star.frame.XDispatchProviderInterceptor
+
+LINK:Documentation/DevGuide/GUI/Creating_Menus#Accessibility
+DESCR:GUI - Creating Menus - Accessibility
+REF:
+com.sun.star.awt.XVclWindowPeer
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Subtotals
+DESCR:Spreadsheets - Subtotals
+REF:
+com.sun.star.sheet.SubTotalColumn
+com.sun.star.sheet.SubTotalDescriptor
+com.sun.star.container.XIndexAccess
+com.sun.star.sheet.XSubTotalCalculatable
+com.sun.star.sheet.XSubTotalDescriptor
+com.sun.star.sheet.XSubTotalField
+TOPIC:
+com.sun.star.sheet.SubTotalColumn
+com.sun.star.sheet.SubTotalDescriptor
+com.sun.star.sheet.SubTotalField
+com.sun.star.sheet.XSubTotalCalculatable
+
+LINK:Documentation/DevGuide/FirstSteps/How_do_I_know_Which_Type_I_Have?
+DESCR:FirstSteps - How do I know Which Type I Have?
+REF:
+com.sun.star.lang.XComponent
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Modifiable_Result_Sets
+DESCR:Database - Modifiable Result Sets
+REF:
+com.sun.star.sdbc.XRowUpdate
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Members
+DESCR:Spreadsheets - Members
+REF:
+com.sun.star.beans.XPropertySet
+com.sun.star.sheet.DataPilotSourceMember
+TOPIC:
+com.sun.star.sheet.DataPilotSourceMember
+
+LINK:Documentation/DevGuide/OfficeDev/Linguistics#Services_Overview
+DESCR:OfficeDev - Linguistics - Services Overview
+REF:
+com.sun.star.linguistic2.XSupportedLocales
+com.sun.star.linguistic2.Hyphenator
+com.sun.star.linguistic2.SpellChecker
+com.sun.star.linguistic2.LinguServiceManager
+com.sun.star.linguistic2.DictionaryList
+com.sun.star.linguistic2.LinguProperties
+com.sun.star.linguistic2.XLinguServiceManager
+com.sun.star.linguistic2.Thesaurus
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Overview_and_Using_the_API#XCollator
+DESCR:OfficeDev - Overview and Using the API - XCollator
+REF:
+com.sun.star.i18n.XLocaleData
+com.sun.star.i18n.XTransliteration
+com.sun.star.i18n.XCollator
+TOPIC:
+com.sun.star.i18n.XCollator
+
+LINK:Documentation/DevGuide/Database/Tables_and_Columns
+DESCR:Database - Tables and Columns
+REF:
+com.sun.star.sdb.Connection
+com.sun.star.sdbcx.Column
+com.sun.star.sdbcx.Privilege
+com.sun.star.beans.XPropertySet
+com.sun.star.util.XNumberFormatter
+com.sun.star.sdb.XCommandPreparation
+com.sun.star.sdb.ColumnSettings
+com.sun.star.sdbcx.XColumnsSupplier
+com.sun.star.sdbc.DataType
+com.sun.star.sdbcx.Container
+com.sun.star.sdbcx.XTablesSupplier
+com.sun.star.sdb.Column
+com.sun.star.sdbc.XColumnLocate
+com.sun.star.sdbc.XResultSetMetaData
+com.sun.star.sdb.RowSet
+com.sun.star.sdbcx.Table
+com.sun.star.sdbc.ColumnValue
+com.sun.star.awt.FontDescriptor
+com.sun.star.sdb.Table
+com.sun.star.sdb.DataSettings
+TOPIC:
+com.sun.star.sdb.Column
+com.sun.star.sdb.Table
+
+LINK:Documentation/DevGuide/ProUNO/CLI/Type_Mappings#XInterface
+DESCR:ProUNO - CLI - Type Mappings - XInterface
+REF:
+com.sun.star.uno.XInterface
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/The_Toolkit_Service#Dockable_Windows
+DESCR:GUI - The Toolkit Service - Dockable Windows
+REF:
+com.sun.star.awt.XDockableWindow
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Example:_Editing_Spreadsheet_Cells
+DESCR:Spreadsheets - Example: Editing Spreadsheet Cells
+REF:
+com.sun.star.table.XCellRange
+com.sun.star.sheet.XSpreadsheet
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Handling_Spreadsheet_Documents_Files#Creating_and_Loading_Spreadsheet_Documents
+DESCR:Spreadsheets - Handling Spreadsheet Documents Files - Creating and Loading Spreadsheet Documents
+REF:
+com.sun.star.frame.XComponentLoader
+com.sun.star.lang.XComponent
+com.sun.star.document.MediaDescriptor
+com.sun.star.frame.Desktop
+TOPIC:
+com.sun.star.frame.XComponentLoader
+
+LINK:Documentation/DevGuide/GUI/File_Picker
+DESCR:GUI - File Picker
+REF:
+com.sun.star.ui.dialogs.FilePicker
+com.sun.star.ui.dialogs.FolderPicker
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Connections#Data_Definition
+DESCR:Database - Connections - Understanding Connections - Data Definition
+REF:
+com.sun.star.sdbcx.DatabaseDefinition
+TOPIC:
+com.sun.star.sdbcx.DatabaseDefinition
+
+LINK:Documentation/DevGuide/GUI/Graphical_User_Interfaces#Implementation_Details
+DESCR:GUI - Graphical User Interfaces - Implementation Details
+REF:
+com.sun.star.awt
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/CLI/Lifetime_Management_and_Obtaining_Interfaces
+DESCR:ProUNO - CLI - Lifetime Management and Obtaining Interfaces
+REF:
+com.sun.star.uno.XInterface
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Core_Interfaces_to_Implement
+DESCR:WritingUNO - Core Interfaces to Implement
+REF:
+com.sun.star.lang.XServiceInfo
+com.sun.star.uno.XAggregation
+com.sun.star.lang.XComponent
+com.sun.star.lang.XInitialization
+com.sun.star.uno.XInterface
+com.sun.star.lang.XUnoTunnel
+com.sun.star.lang.XMain
+com.sun.star.uno.XWeak
+com.sun.star.lang.XTypeProvider
+TOPIC:
+com.sun.star.lang.XServiceInfo
+com.sun.star.uno.XAggregation
+com.sun.star.lang.XComponent
+com.sun.star.lang.XInitialization
+com.sun.star.uno.XInterface
+com.sun.star.lang.XUnoTunnel
+com.sun.star.lang.XMain
+com.sun.star.uno.XWeak
+com.sun.star.lang.XTypeProvider
+
+LINK:Documentation/DevGuide/Spreadsheets/Spreadsheet_Document_Controller#Spreadsheet_View
+DESCR:Spreadsheets - Spreadsheet Document Controller - Spreadsheet View
+REF:
+com.sun.star.frame.Controller
+com.sun.star.sheet.SheetCell
+com.sun.star.frame.XController
+com.sun.star.sheet.SheetCellRanges
+com.sun.star.sheet.XSpreadsheetView
+com.sun.star.ui.XContextMenuInterception
+com.sun.star.sheet.XViewSplitable
+com.sun.star.drawing.Shapes
+com.sun.star.sheet.XRangeSelection
+com.sun.star.sheet.SpreadsheetViewPane
+com.sun.star.sheet.SpreadsheetView
+com.sun.star.drawing.Shape
+com.sun.star.view.XSelectionSupplier
+com.sun.star.sheet.SheetCellRange
+com.sun.star.sheet.XViewFreezable
+com.sun.star.frame.XDispatchProvider
+com.sun.star.container.XIndexAccess
+TOPIC:
+com.sun.star.sheet.SpreadsheetView
+
+LINK:Documentation/DevGuide/WritingUNO/Defining_a_Struct
+DESCR:WritingUNO - Defining a Struct
+REF:
+com.sun.star.lang.EventObject
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Applying_Number_Formats#NumberFormatter_Service
+DESCR:OfficeDev - Applying Number Formats - NumberFormatter Service
+REF:
+com.sun.star.util.XNumberFormatter
+com.sun.star.util.XNumberFormatPreviewer
+com.sun.star.util.NumberFormatter
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Validation_and_Bindings
+DESCR:Forms - Validation and Bindings
+REF:
+com.sun.star.form.binding.XBindableValue
+com.sun.star.form.binding.XValueBinding
+com.sun.star.form.validation.ValidatableControlModel
+com.sun.star.form.binding.BindableControlModel
+com.sun.star.form.validation.ValidatableBindableControlModel
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/Time_Field
+DESCR:Basic - Time Field
+REF:
+com.sun.star.awt.UnoControlDateField
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Example:_Fields_in_a_Template
+DESCR:Text - Example: Fields in a Template
+REF:
+com.sun.star.text.textfield.User
+com.sun.star.text.XTextFieldsSupplier
+com.sun.star.text.XTextRange
+com.sun.star.text.XBookmarksSupplier
+com.sun.star.container.XNameAccess
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Standalone_Use_Case
+DESCR:WritingUNO - Standalone Use Case
+REF:
+com.sun.star.uno.XComponentContext
+com.sun.star.lang.XInitialization
+com.sun.star.bridge.XBridge
+com.sun.star.lang.XMain
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Filter_Options
+DESCR:OfficeDev - Filter Options
+REF:
+com.sun.star.beans.XPropertyAccess
+com.sun.star.ui.dialogs.FilterOptionsDialog
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Using_Hyphenator#Relevant_properties
+DESCR:OfficeDev - Using Hyphenator - Relevant properties
+REF:
+com.sun.star.linguistic2.XHyphenatedWord
+com.sun.star.linguistic2.XPossibleHyphens
+com.sun.star.linguistic2.LinguProperties
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Implementing_a_New_Locale#XIndexEntrySupplier
+DESCR:OfficeDev - Implementing a New Locale - XIndexEntrySupplier
+REF:
+com.sun.star.i18n.XIndexEntrySupplier
+TOPIC:
+com.sun.star.i18n.XIndexEntrySupplier
+
+LINK:Documentation/DevGuide/Extensions/Saving_and_Reading_Data_for_the_Options_Page
+DESCR:Extensions - Saving and Reading Data for the Options Page
+REF:
+com.sun.star.awt.XWindow
+com.sun.star.awt.XContainerWindowEventHandler
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Scrollable_Result_Sets
+DESCR:Database - Scrollable Result Sets
+REF:
+com.sun.star.sdbc.ResultSetType
+com.sun.star.sdbc.ResultSetConcurrency
+com.sun.star.sdbc.XResultSet
+TOPIC:
+com.sun.star.sdbc.XResultSet
+
+LINK:Documentation/DevGuide/Spreadsheets/Capabilities_of_Spreadsheet
+DESCR:Spreadsheets - Capabilities of Spreadsheet
+REF:
+com.sun.star.table.XTableChartsSupplier
+com.sun.star.sheet.XSheetPageBreak
+com.sun.star.drawing.XDrawPageSupplier
+com.sun.star.sheet.Spreadsheet
+com.sun.star.sheet.XCellRangeMovement
+com.sun.star.sheet.XSheetAuditing
+com.sun.star.util.XProtectable
+com.sun.star.container.XNamed
+com.sun.star.sheet.SheetCellRange
+com.sun.star.sheet.XSheetAnnotationsSupplier
+com.sun.star.sheet.XPrintAreas
+com.sun.star.sheet.XSheetOutline
+com.sun.star.sheet.XScenariosSupplier
+com.sun.star.sheet.XDataPilotTablesSupplier
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Server_Use_Case
+DESCR:WritingUNO - Server Use Case
+REF:
+com.sun.star.io.Pipe
+com.sun.star.io.XInputStream
+com.sun.star.io.XOutputStream
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Required_Files
+DESCR:WritingUNO - Required Files
+REF:
+com.sun.star.lang.XMain
+TOPIC:
+
+LINK:Documentation/DevGuide/AdvUNO/UNO_Reflection_API
+DESCR:AdvUNO - UNO Reflection API
+REF:
+TOPIC:
+com.sun.star.reflection.CoreReflection
+com.sun.star.script.Converter
+com.sun.star.script.InvocationAdapterFactory
+com.sun.star.beans.XIntrospection
+com.sun.star.reflection.XTypeDescription
+com.sun.star.script.Invocation
+com.sun.star.beans.Introspection
+com.sun.star.lang.XTypeProvider
+
+LINK:Documentation/DevGuide/ProUNO/C++/Mapping_of_Struct_Types
+DESCR:ProUNO - C++ - Mapping of Struct Types
+REF:
+com.sun.star.beans.Optional
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Text_Table_Properties
+DESCR:Text - Text Table Properties
+REF:
+com.sun.star.text.TableColumnSeparator
+com.sun.star.table.ShadowFormat
+com.sun.star.style.GraphicLocation
+com.sun.star.text.TextTable
+com.sun.star.text.HoriOrientation
+com.sun.star.style.BreakType
+com.sun.star.table.TableBorder
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/C++/Building_and_Testing_C++_Components#Test_Registration_and_Use
+DESCR:WritingUNO - C++ - Building and Testing C++ Components - Test Registration and Use
+REF:
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/External_Value_Suppliers
+DESCR:Forms - External Value Suppliers
+REF:
+com.sun.star.form.binding
+TOPIC:
+
+LINK:Documentation/DevGuide/UCB/Documents#Reading_a_Document_Content
+DESCR:UCB - Documents - Reading a Document Content
+REF:
+com.sun.star.ucb.OpenCommandArgument2
+com.sun.star.io.XInputStream
+com.sun.star.io.XOutputStream
+com.sun.star.io.XActiveDataSink
+TOPIC:
+
+LINK:Documentation/DevGuide/Scripting/Writing_a_LanguageScriptProvider_UNO_Component_using_the_Java_Helper_Classes
+DESCR:Scripting - Writing a LanguageScriptProvider UNO Component using the Java Helper Classes
+REF:
+com.sun.star.script.provider.XScript
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Text_Frames
+DESCR:Text - Text Frames
+REF:
+com.sun.star.text.BaseFrame
+com.sun.star.text.Text
+com.sun.star.text.XTextFrame
+com.sun.star.text.XTextRangeMover
+com.sun.star.text.ChainedTextFrame
+com.sun.star.text.XTextContent
+com.sun.star.text.TextFrame
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/Pattern_Field
+DESCR:Basic - Pattern Field
+REF:
+com.sun.star.awt.UnoControlPatternField
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Cells_Absolute_Address
+DESCR:Spreadsheets - Cells Absolute Address
+REF:
+com.sun.star.sheet.XCellAddressable
+com.sun.star.table.CellAddress
+TOPIC:
+com.sun.star.sheet.XCellAddressable
+
+LINK:Documentation/DevGuide/ProUNO/Service_Manager#XContentEnumerationAccess_Interface
+DESCR:ProUNO - Service Manager - XContentEnumerationAccess Interface
+REF:
+com.sun.star.container.XContentEnumerationAccess
+com.sun.star.lang.XSingleServiceFactory
+com.sun.star.container.XEnumeration
+TOPIC:
+com.sun.star.container.XContentEnumerationAccess
+
+LINK:Documentation/DevGuide/Database/Runtime_Settings_For_Predefined_Queries
+DESCR:Database - Runtime Settings For Predefined Queries
+REF:
+com.sun.star.sdbcx.Container
+com.sun.star.sdb.Query
+com.sun.star.sdb.Column
+com.sun.star.sdbcx.XDataDescriptorFactory
+com.sun.star.sdbcx.XColumnsSupplier
+com.sun.star.sdb.RowSet
+com.sun.star.sdbcx.XAppend
+com.sun.star.awt.FontDescriptor
+com.sun.star.sdb.QueryDefinition
+com.sun.star.sdb.XQueriesSupplier
+com.sun.star.sdbcx.XRename
+com.sun.star.sdb.DataSettings
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Applying_Number_Formats
+DESCR:OfficeDev - Applying Number Formats
+REF:
+com.sun.star.util.XNumberFormatter
+com.sun.star.util.NumberFormatter
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Access_to_Formulas%2C_Values_and_Errors
+DESCR:Spreadsheets - Access to Formulas, Values and Errors
+REF:
+com.sun.star.table.XCell
+com.sun.star.table.CellContentType
+com.sun.star.table.XCellRange
+TOPIC:
+
+LINK:Documentation/DevGuide/GUI/Formatted_Field
+DESCR:GUI - Formatted Field
+REF:
+com.sun.star.awt.XSpinListener
+com.sun.star.awt.UnoControlFormattedField
+com.sun.star.awt.UnoControlFormattedFieldModel
+com.sun.star.util.XNumberFormatsSupplier
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Line_Numbering_and_Outline_Numbering#Line_Numbering
+DESCR:Text - Line Numbering and Outline Numbering - Line Numbering
+REF:
+com.sun.star.text.XLineNumberingProperties
+com.sun.star.text.LineNumberingProperties
+TOPIC:
+com.sun.star.text.LineNumberingProperties
+
+LINK:Documentation/DevGuide/Scripting/Implementation
+DESCR:Scripting - Implementation
+REF:
+com.sun.star.script.provider.XScriptProvider
+com.sun.star.script.browse.BrowseNodeTypes
+com.sun.star.script.provider.LanguageScriptProvider
+com.sun.star.beans.XPropertySet
+com.sun.star.script.browse.BrowseNode
+com.sun.star.script.XInvocation
+com.sun.star.script.browse.XBrowseNode
+com.sun.star.script.provider.XScript
+com.sun.star.script.provider.XScriptContext
+TOPIC:
+
+LINK:Documentation/DevGuide/FirstSteps/Element_Access#Index_Access
+DESCR:FirstSteps - Element Access - Index Access
+REF:
+com.sun.star.container.XIndexAccess
+com.sun.star.sheet.Spreadsheet
+com.sun.star.sheet.XSpreadsheets
+TOPIC:
+
+LINK:Documentation/DevGuide/Charts/Pie_Charts
+DESCR:Charts - Pie Charts
+REF:
+com.sun.star.chart.ChartPieSegmentProperties
+TOPIC:
+com.sun.star.chart.ChartPieSegmentProperties
+
+LINK:Documentation/DevGuide/GUI/Creating_Menus
+DESCR:GUI - Creating Menus
+REF:
+com.sun.star.awt.XMenu
+com.sun.star.awt.XMenuBar
+com.sun.star.awt.XTopWindow
+com.sun.star.awt.MenuItemStyle
+com.sun.star.awt.MenuEvent
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Form_Layer_Views#Focusing_Controls
+DESCR:Forms - Form Layer Views - Focusing Controls
+REF:
+com.sun.star.awt.XWindow
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Spreadsheet_Add-Ins
+DESCR:Spreadsheets - Spreadsheet Add-Ins
+REF:
+com.sun.star.sheet.AddIn
+TOPIC:
+com.sun.star.sheet.AddIn
+
+LINK:Documentation/DevGuide/GUI/Creating_Menus#Rendering
+DESCR:GUI - Creating Menus - Rendering
+REF:
+com.sun.star.awt.XDevice
+com.sun.star.awt.RasterOperation
+com.sun.star.awt.XRegion
+com.sun.star.awt.XFont
+com.sun.star.awt.XGraphics
+com.sun.star.awt
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/FormComponent_Service
+DESCR:Forms - FormComponent Service
+REF:
+com.sun.star.lang.XComponent
+com.sun.star.form.FormComponent
+com.sun.star.container.XChild
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/XTypeProvider
+DESCR:WritingUNO - XTypeProvider
+REF:
+com.sun.star.lang.XTypeProvider
+TOPIC:
+com.sun.star.lang.XTypeProvider
+
+LINK:Documentation/DevGuide/AdvUNO/XInvocation_Bridge#Scripting_Existing_UNO_Objects
+DESCR:AdvUNO - XInvocation Bridge - Scripting Existing UNO Objects
+REF:
+com.sun.star.script.Invocation
+TOPIC:
+com.sun.star.script.Invocation
+
+LINK:Documentation/DevGuide/ProUNO/Basic/Mapping_of_Enums_and_Constant_Groups
+DESCR:ProUNO - Basic - Mapping of Enums and Constant Groups
+REF:
+com.sun.star.beans.PropertyState
+com.sun.star.beans.XPropertySet
+com.sun.star.beans.PropertyConcept
+TOPIC:
+
+LINK:Documentation/DevGuide/AppendixC/The_WebDAV_Content_Provider#Commands_and_Properties
+DESCR:AppendixC - The WebDAV Content Provider - Commands and Properties
+REF:
+com.sun.star.ucb.XContent
+com.sun.star.lang.XServiceInfo
+com.sun.star.ucb.XContentCreator
+com.sun.star.lang.XComponent
+com.sun.star.container.XChild
+com.sun.star.ucb.XCommandInfoChangeNotifier
+com.sun.star.beans.XPropertySetInfoChangeNotifier
+com.sun.star.beans.XPropertiesChangeNotifier
+com.sun.star.beans.XPropertyContainer
+com.sun.star.ucb.XCommandProcessor
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/Config/Updating_Configuration_Data
+DESCR:Config - Updating Configuration Data
+REF:
+com.sun.star.beans.NamedValue
+com.sun.star.beans.XPropertyState
+com.sun.star.configuration.SetAccess
+com.sun.star.sdb.DatabaseContext
+com.sun.star.beans.XPropertySet
+com.sun.star.beans.XPropertyWithState
+com.sun.star.configuration.SetUpdate
+com.sun.star.beans.XMultiHierarchicalPropertySet
+com.sun.star.configuration.ConfigurationProvider
+com.sun.star.container.XNameReplace
+com.sun.star.beans.XMultiPropertyStates
+com.sun.star.configuration.ConfigurationAccess
+com.sun.star.configuration.ConfigurationUpdateAccess
+com.sun.star.lang.XSingleServiceFactory
+com.sun.star.beans.XPropertySetInfo
+com.sun.star.container.XNameContainer
+com.sun.star.configuration.GroupUpdate
+com.sun.star.configuration.SetElement
+com.sun.star.util.XChangesBatch
+com.sun.star.beans.Property
+TOPIC:
+com.sun.star.configuration.ConfigurationUpdateAccess
+
+LINK:Documentation/DevGuide/Text/Line_Numbering_and_Outline_Numbering#Paragraph_and_Outline_Numbering
+DESCR:Text - Line Numbering and Outline Numbering - Paragraph and Outline Numbering
+REF:
+com.sun.star.text.NumberingRules
+com.sun.star.style.ParagraphProperties
+com.sun.star.text.VertOrientation
+com.sun.star.beans.PropertyValue
+com.sun.star.container.XIndexReplace
+com.sun.star.text.ChapterNumberingRule
+com.sun.star.text.NumberingLevel
+com.sun.star.style.NumberingType
+com.sun.star.text.HoriOrientation
+com.sun.star.text.XChapterNumberingSupplier
+TOPIC:
+
+LINK:Documentation/DevGuide/Drawings/Handling_Presentation_Document_Files#Creating_and_Loading_Presentation_Documents
+DESCR:Drawings - Handling Presentation Document Files - Creating and Loading Presentation Documents
+REF:
+com.sun.star.document.MediaDescriptor
+TOPIC:
+
+LINK:Documentation/DevGuide/AdvUNO/Implementation_Loader
+DESCR:AdvUNO - Implementation Loader
+REF:
+com.sun.star.registry.ImplementationRegistration
+com.sun.star.loader.XImplementationLoader
+com.sun.star.lang.XSingleComponentFactory
+com.sun.star.lang.ServiceManager
+TOPIC:
+com.sun.star.loader.XImplementationLoader
+
+LINK:Documentation/DevGuide/OfficeDev/Writing_the_Filtering_Component#XDocumentHandler
+DESCR:OfficeDev - Writing the Filtering Component - XDocumentHandler
+REF:
+com.sun.star.xml.sax.XDocumentHandler
+TOPIC:
+com.sun.star.xml.sax.XDocumentHandler
+
+LINK:Documentation/DevGuide/OfficeDev/Implementing_a_Spell_Checker
+DESCR:OfficeDev - Implementing a Spell Checker
+REF:
+com.sun.star.lang.XServiceInfo
+com.sun.star.lang.XComponent
+com.sun.star.linguistic2.LinguServiceEvent
+com.sun.star.linguistic2.XLinguServiceEventBroadcaster
+com.sun.star.lang.XInitialization
+com.sun.star.linguistic2.XSpellChecker
+com.sun.star.lang.XServiceDisplayName
+com.sun.star.linguistic2.SpellFailure
+com.sun.star.lang.XTypeProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Service_Manager#XSet_Interface
+DESCR:ProUNO - Service Manager - XSet Interface
+REF:
+com.sun.star.lang.XServiceInfo
+com.sun.star.lang.XSingleServiceFactory
+com.sun.star.container.XSet
+com.sun.star.lang.XSingleComponentFactory
+TOPIC:
+
+LINK:Documentation/DevGuide/UCB/Executing_Content_Commands
+DESCR:UCB - Executing Content Commands
+REF:
+com.sun.star.ucb.Content
+com.sun.star.ucb.XCommandEnvironment
+com.sun.star.ucb.Command
+com.sun.star.task.XInteractionHandler
+com.sun.star.ucb.XCommandProcessor
+TOPIC:
+com.sun.star.ucb.Command
+com.sun.star.ucb.XCommandProcessor
+
+LINK:Documentation/DevGuide/OfficeDev/Handling_Documents#MediaDescriptor
+DESCR:OfficeDev - Handling Documents - Loading Documents - MediaDescriptor
+REF:
+com.sun.star.document.TypeDetection
+com.sun.star.task.XStatusIndicator
+com.sun.star.frame.XStorable
+com.sun.star.document.XViewDataSupplier
+com.sun.star.task.InteractionHandler
+com.sun.star.document.MacroExecMode
+com.sun.star.document.ExtendedTypeDetection
+com.sun.star.io.IOException
+com.sun.star.document.UpdateDocMode
+com.sun.star.beans.PropertyValue
+com.sun.star.io.XSeekable
+com.sun.star.document.MediaDescriptor
+TOPIC:
+com.sun.star.document.MediaDescriptor
+
+LINK:Documentation/DevGuide/WritingUNO/Jobs/Jobs
+DESCR:WritingUNO - Jobs - Jobs
+REF:
+com.sun.star.task.JobExecutor
+TOPIC:
+com.sun.star.task.JobExecutor
+
+LINK:Documentation/DevGuide/Database/Data_Sources_in_OpenOffice.org_API#DatabaseContext
+DESCR:Database - Data Sources in OpenOffice.org API - DatabaseContext
+REF:
+com.sun.star.sdb.Connection
+com.sun.star.sdb.DatabaseContext
+com.sun.star.sdb.XCompletedConnection
+com.sun.star.sdb.DataSource
+com.sun.star.container.XNameAccess
+com.sun.star.container.XEnumeration
+TOPIC:
+com.sun.star.sdb.DatabaseContext
+
+LINK:Documentation/DevGuide/Text/Working_with_Text_Documents#Word_Processing
+DESCR:Text - Working with Text Documents - Word Processing
+REF:
+com.sun.star.text.Text
+TOPIC:
+com.sun.star.text.Text
+
+LINK:Documentation/DevGuide/Database/Forms_and_Reports
+DESCR:Database - Forms and Reports
+REF:
+com.sun.star.frame.XComponentLoader
+com.sun.star.container.XHierarchicalNameContainer
+com.sun.star.sdb.XFormDocumentsSupplier
+com.sun.star.container.XEnumerationAccess
+com.sun.star.sdb.DataSource
+com.sun.star.text.TextDocument
+com.sun.star.sdbcx.XRename
+com.sun.star.sdb.Forms
+com.sun.star.sdb.DocumentDefinition
+com.sun.star.sdb.DocumentContainer
+com.sun.star.sdbc.XConnection
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.sdb.XReportDocumentsSupplier
+com.sun.star.container.XNameContainer
+com.sun.star.container.XHierarchicalNameAccess
+com.sun.star.container.XIndexAccess
+com.sun.star.beans.PropertyValue
+com.sun.star.sdb.Reports
+TOPIC:
+com.sun.star.sdb.XReportDocumentsSupplier
+com.sun.star.sdb.XFormDocumentsSupplier
+
+LINK:Documentation/DevGuide/OfficeDev/Document_API_Filter_Development#Introduction
+DESCR:OfficeDev - Document API Filter Development - Introduction
+REF:
+com.sun.star.document.MediaDescriptor
+com.sun.star.document.ImportFilter
+com.sun.star.document.ExportFilter
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Models#XDocumentInfoSupplier
+DESCR:OfficeDev - Component - Models - XDocumentInfoSupplier
+REF:
+com.sun.star.document.XDocumentInfoSupplier
+TOPIC:
+com.sun.star.document.XDocumentInfoSupplier
+
+LINK:Documentation/DevGuide/FirstSteps/Struct
+DESCR:FirstSteps - Struct
+REF:
+com.sun.star.reflection.CoreReflection
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/Automation_Objects_with_UNO_Interfaces#Examples
+DESCR:ProUNO - Bridge - Automation Objects with UNO Interfaces - null - Examples
+REF:
+com.sun.star.lang.XEventListener
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleTable
+DESCR:Accessibility - XAccessibleTable
+REF:
+com.sun.star.accessibility.XAccessibleTable
+com.sun.star.accessibility.XAccessibleContext
+TOPIC:
+com.sun.star.accessibility.XAccessibleTable
+
+LINK:Documentation/DevGuide/Forms/The_Model-View_Paradigm
+DESCR:Forms - The Model-View Paradigm
+REF:
+com.sun.star.beans.XPropertySet
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/C++/Class_Definition_with_Helper_Template_Classes#XServiceInfo
+DESCR:WritingUNO - C++ - Class Definition with Helper Template Classes - XServiceInfo
+REF:
+com.sun.star.lang.XServiceInfo
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Dispatch_Process#Listening_for_Status_Information
+DESCR:OfficeDev - Dispatch Process - Listening for Status Information
+REF:
+com.sun.star.frame.FeatureStateEvent
+com.sun.star.frame.XStatusListener
+TOPIC:
+
+LINK:Documentation/DevGuide/Drawings/Working_with_Drawing_Documents#Page_Handling
+DESCR:Drawings - Working with Drawing Documents - Page Handling
+REF:
+com.sun.star.drawing.XDrawPagesSupplier
+com.sun.star.drawing.XMasterPageTarget
+com.sun.star.drawing.XDrawPages
+com.sun.star.drawing.XDrawPageDuplicator
+com.sun.star.container.XIndexAccess
+TOPIC:
+com.sun.star.drawing.XDrawPages
+com.sun.star.drawing.XDrawPageDuplicator
+
+LINK:Documentation/DevGuide/Spreadsheets/Table_Auto_Formats
+DESCR:Spreadsheets - Table Auto Formats
+REF:
+com.sun.star.sheet.TableAutoFormatField
+com.sun.star.container.XIndexAccess
+com.sun.star.sheet.TableAutoFormat
+com.sun.star.sheet.TableAutoFormats
+com.sun.star.table.XAutoFormattable
+TOPIC:
+com.sun.star.sheet.TableAutoFormatField
+com.sun.star.sheet.TableAutoFormat
+com.sun.star.table.XAutoFormattable
+
+LINK:Documentation/DevGuide/Database/Using_the_getXXX_Methods
+DESCR:Database - Using the getXXX Methods
+REF:
+com.sun.star.sdbc.XRow
+com.sun.star.util.Date
+com.sun.star.sdbc.DataType
+TOPIC:
+com.sun.star.sdbc.XRow
+
+LINK:Documentation/DevGuide/AppendixA/Exceptions#Naming
+DESCR:AppendixA - Exceptions - Naming
+REF:
+com.sun.star.lang.IllegalArgumentException
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleHypertext
+DESCR:Accessibility - XAccessibleHypertext
+REF:
+com.sun.star.accessibility.XAccessibleHypertext
+com.sun.star.accessibility.XAccessibleHyperlink
+com.sun.star.accessibility.XAccessibleText
+TOPIC:
+com.sun.star.accessibility.XAccessibleHypertext
+
+LINK:Documentation/DevGuide/WritingUNO/Intercepting_Context_Menus#Finishing_Interception
+DESCR:WritingUNO - Intercepting Context Menus - Writing an Interceptor - Finishing Interception
+REF:
+com.sun.star.ui.XContextMenuInterceptor
+com.sun.star.ui.ContextMenuInterceptorAction
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Java_Window_Integration#Legal_Solution
+DESCR:OfficeDev - Java Window Integration - Using the Window Handle - Legal Solution
+REF:
+com.sun.star.awt.XWindow
+com.sun.star.awt.Toolkit
+com.sun.star.awt.XSystemChildFactory
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Access_to_Text_Content
+DESCR:Spreadsheets - Access to Text Content
+REF:
+com.sun.star.text.Text
+com.sun.star.text.XTextFieldsSupplier
+com.sun.star.container.XEnumerationAccess
+com.sun.star.text.XText
+com.sun.star.text.textfield.URL
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Dispatch_Framework
+DESCR:OfficeDev - Dispatch Framework
+REF:
+com.sun.star.frame.XDispatchProviderInterception
+com.sun.star.frame.XDispatchProvider
+TOPIC:
+com.sun.star.frame.XDispatchProvider
+
+LINK:Documentation/DevGuide/OfficeDev/Common_Application_Features#Copying_Data
+DESCR:OfficeDev - Common Application Features - Clipboard - Using the Clipboard - Copying Data
+REF:
+com.sun.star.datatransfer.XTransferable
+com.sun.star.datatransfer.clipboard.XClipboardOwner
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Importing_a_UNO_Object
+DESCR:ProUNO - Importing a UNO Object
+REF:
+com.sun.star.bridge.XUnoUrlResolver
+com.sun.star.bridge.UnoUrlResolver
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/Deployment_Options_for_Components
+DESCR:WritingUNO - Deployment Options for Components
+REF:
+com.sun.star.reflection.TypeDescriptionProvider
+com.sun.star.registry.SimpleRegistry
+TOPIC:
+
+LINK:Documentation/DevGuide/Database/Adding_an_Index
+DESCR:Database - Adding an Index
+REF:
+com.sun.star.sdbcx.XDataDescriptorFactory
+com.sun.star.sdbc.SQLException
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Cell_Ranges_and_Cells_Container#Access_to_Single_Cell_Ranges_in_SheetCellRanges_Container
+DESCR:Spreadsheets - Cell Ranges and Cells Container - Access to Single Cell Ranges in SheetCellRanges Container
+REF:
+com.sun.star.sheet.XSheetCellRangeContainer
+com.sun.star.chart.XChartDataArray
+com.sun.star.sheet.XSheetCellRanges
+com.sun.star.container.XNameContainer
+com.sun.star.container.XIndexAccess
+com.sun.star.container.XEnumerationAccess
+com.sun.star.sheet.XSheetOperation
+com.sun.star.util.XReplaceable
+com.sun.star.sheet.SheetRangesQuery
+com.sun.star.sheet.Cells
+com.sun.star.util.XIndent
+TOPIC:
+com.sun.star.sheet.Cells
+
+LINK:Documentation/DevGuide/OfficeDev/XML_Filter_Detection#The_ExtendedTypeDetection_Service_Implementation
+DESCR:OfficeDev - XML Filter Detection - The ExtendedTypeDetection Service Implementation
+REF:
+com.sun.star.document.XExtendedFilterDetection
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Models
+DESCR:OfficeDev - Component - Models
+REF:
+com.sun.star.document.OfficeDocument
+com.sun.star.frame.XModel
+TOPIC:
+com.sun.star.frame.XModel
+
+LINK:Documentation/DevGuide/Spreadsheets/Data_Array
+DESCR:Spreadsheets - Data Array
+REF:
+com.sun.star.sheet.XCellRangeData
+TOPIC:
+com.sun.star.sheet.XCellRangeData
+
+LINK:Documentation/DevGuide/GUI/Events
+DESCR:GUI - Events
+REF:
+com.sun.star.awt.MouseEvent
+com.sun.star.awt.FocusEvent
+com.sun.star.awt.XWindow
+com.sun.star.lang.XEventListener
+com.sun.star.lang.EventObject
+com.sun.star.awt.XControl
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Control_Models
+DESCR:Forms - Control Models
+REF:
+com.sun.star.form.component.TextField
+com.sun.star.lang.XServiceInfo
+com.sun.star.beans.XPropertyState
+com.sun.star.form.FormComponentType
+com.sun.star.form.FormComponent
+com.sun.star.form.component.FormattedField
+com.sun.star.awt.UnoControlModel
+com.sun.star.awt.XControlModel
+com.sun.star.form.FormControlModel
+com.sun.star.awt
+TOPIC:
+com.sun.star.beans.XPropertyState
+com.sun.star.form.FormComponent
+com.sun.star.awt.UnoControlModel
+com.sun.star.form.FormControlModel
+
+LINK:Documentation/DevGuide/Basic/Dialog_as_Control_Container
+DESCR:Basic - Dialog as Control Container
+REF:
+com.sun.star.awt.UnoControlDialogModel
+com.sun.star.awt.XControlContainer
+com.sun.star.awt.UnoControlDialog
+com.sun.star.container.XNameContainer
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Label_Ranges
+DESCR:Spreadsheets - Label Ranges
+REF:
+com.sun.star.sheet.LabelRanges
+com.sun.star.sheet.XLabelRanges
+com.sun.star.sheet.XLabelRange
+com.sun.star.sheet.LabelRange
+TOPIC:
+com.sun.star.sheet.LabelRanges
+
+LINK:Documentation/DevGuide/WritingUNO/Defining_a_Service
+DESCR:WritingUNO - Defining a Service
+REF:
+com.sun.star.document.XFilter
+com.sun.star.beans.XPropertySet
+com.sun.star.beans.XPropertySetInfo
+com.sun.star.beans.PropertyValue
+com.sun.star.document.MediaDescriptor
+com.sun.star.text.TextDocument
+com.sun.star.beans.XPropertyContainer
+com.sun.star.beans.XPropertyChangeListener
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Cell_Annotations
+DESCR:Spreadsheets - Cell Annotations
+REF:
+com.sun.star.sheet.CellAnnotations
+com.sun.star.sheet.CellAnnotation
+com.sun.star.sheet.XSheetAnnotationsSupplier
+com.sun.star.sheet.XSheetAnnotations
+com.sun.star.container.XEnumerationAccess
+com.sun.star.container.XIndexAccess
+com.sun.star.text.XSimpleText
+com.sun.star.container.XChild
+com.sun.star.sheet.XSheetAnnotation
+com.sun.star.sheet.CellAnnotationsEnumeration
+com.sun.star.sheet.XSheetAnnotationAnchor
+TOPIC:
+com.sun.star.sheet.CellAnnotation
+com.sun.star.sheet.XSheetAnnotation
+com.sun.star.sheet.XSheetAnnotationAnchor
+
+LINK:Documentation/DevGuide/OfficeDev/Using_the_Dispatch_Framework
+DESCR:OfficeDev - Using the Dispatch Framework
+REF:
+TOPIC:
+com.sun.star.frame.XDispatchProviderInterceptor
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/Calling_Functions_and_Accessing_Properties
+DESCR:ProUNO - Bridge - Calling Functions and Accessing Properties
+REF:
+com.sun.star.beans.XPropertySet
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Footnotes_and_Endnotes
+DESCR:Text - Footnotes and Endnotes
+REF:
+com.sun.star.text.TextContent
+com.sun.star.beans.XPropertySet
+com.sun.star.container.XIndexAccess
+com.sun.star.text.XFootnote
+com.sun.star.text.XText
+com.sun.star.text.XTextContent
+com.sun.star.text.Footnote
+com.sun.star.text.XFootnotesSupplier
+com.sun.star.text.FootnoteSettings
+com.sun.star.text.XEndnotesSupplier
+TOPIC:
+com.sun.star.text.Footnote
+
+LINK:Documentation/DevGuide/Charts/Creating_and_Adding_a_Chart_to_a_Spreadsheet
+DESCR:Charts - Creating and Adding a Chart to a Spreadsheet
+REF:
+com.sun.star.table.XTableChartsSupplier
+com.sun.star.sheet.XSpreadsheet
+com.sun.star.sheet.Spreadsheet
+TOPIC:
+com.sun.star.table.XTableChartsSupplier
+
+LINK:Documentation/DevGuide/Spreadsheets/Cell_Cursor#Used_Area
+DESCR:Spreadsheets - Cell Cursor - Used Area
+REF:
+com.sun.star.sheet.XSpreadsheet
+com.sun.star.sheet.XUsedAreaCursor
+TOPIC:
+com.sun.star.sheet.XUsedAreaCursor
+
+LINK:Documentation/DevGuide/Spreadsheets/Database_Ranges
+DESCR:Spreadsheets - Database Ranges
+REF:
+com.sun.star.sheet.XDatabaseRanges
+com.sun.star.sheet.SpreadsheetDocument
+com.sun.star.sheet.XDatabaseRange
+com.sun.star.sheet.DatabaseRange
+com.sun.star.table.CellRangeAddress
+com.sun.star.sheet.XCellRangeReferrer
+com.sun.star.container.XNameAccess
+TOPIC:
+com.sun.star.sheet.XDatabaseRanges
+
+LINK:Documentation/DevGuide/Database/Seeing_Changes_in_Result_Sets
+DESCR:Database - Seeing Changes in Result Sets
+REF:
+com.sun.star.sdbc.XDatabaseMetaData
+TOPIC:
+
+LINK:Documentation/DevGuide/Forms/Programmatic_Assignment_of_Scripts_to_Events
+DESCR:Forms - Programmatic Assignment of Scripts to Events
+REF:
+com.sun.star.awt.XItemListener
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/CLI/Type_Mappings#exception
+DESCR:ProUNO - CLI - Type Mappings - exception
+REF:
+com.sun.star.uno.Exception
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Capabilities_of_Columns_and_Rows
+DESCR:Spreadsheets - Capabilities of Columns and Rows
+REF:
+com.sun.star.table.XTableColumns
+com.sun.star.table.XColumnRowRange
+com.sun.star.table.XTableRows
+com.sun.star.container.XNameAccess
+com.sun.star.table.TableColumns
+com.sun.star.table.TableColumn
+com.sun.star.table.TableRow
+com.sun.star.table.TableRows
+TOPIC:
+
+LINK:Documentation/DevGuide/AdvUNO/Example_Python_Bridge_PyUNO
+DESCR:AdvUNO - Example Python Bridge PyUNO
+REF:
+com.sun.star.script.Converter
+com.sun.star.script.Invocation
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Printing_Spreadsheet_Documents#Printer_and_Print_Job_Settings
+DESCR:Spreadsheets - Printing Spreadsheet Documents - Printer and Print Job Settings
+REF:
+com.sun.star.awt.Size
+com.sun.star.view.PaperOrientation
+com.sun.star.view.PrintOptions
+com.sun.star.view.PrinterDescriptor
+com.sun.star.view.XPrintable
+com.sun.star.view.PaperFormat
+TOPIC:
+com.sun.star.view.PrintOptions
+com.sun.star.view.PrinterDescriptor
+com.sun.star.view.XPrintable
+
+LINK:Documentation/DevGuide/WritingUNO/XServiceInfo#Supported_Service_Names
+DESCR:WritingUNO - XServiceInfo - Supported Service Names
+REF:
+com.sun.star.container.XContentEnumerationAccess
+com.sun.star.lang.XSingleServiceFactory
+com.sun.star.lang.XSingleComponentFactory
+TOPIC:
+
+LINK:Documentation/DevGuide/Drawings/Animations_and_Interactions
+DESCR:Drawings - Animations and Interactions
+REF:
+com.sun.star.presentation.AnimationSpeed
+com.sun.star.presentation.Shape
+com.sun.star.presentation.ClickAction
+com.sun.star.presentation.AnimationEffect
+TOPIC:
+com.sun.star.presentation.Shape
+com.sun.star.presentation.AnimationEffect
+
+LINK:Documentation/DevGuide/GUI/Events#Keyboard_Listener
+DESCR:GUI - Events - Keyboard Listener
+REF:
+com.sun.star.awt.XKeyListener
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Using_the_Component_Framework
+DESCR:OfficeDev - Using the Component Framework
+REF:
+com.sun.star.frame.Controller
+com.sun.star.lang.XComponent
+com.sun.star.document.OfficeDocument
+com.sun.star.drawing.DrawingDocumentDrawView
+com.sun.star.sheet.SpreadsheetView
+com.sun.star.frame.XModel
+TOPIC:
+com.sun.star.lang.XComponent
+
+LINK:Documentation/DevGuide/Text/Settings#General_Document_Information
+DESCR:Text - Settings - General Document Information
+REF:
+com.sun.star.document.DocumentInfo
+com.sun.star.document.XDocumentInfoSupplier
+TOPIC:
+com.sun.star.document.XDocumentInfoSupplier
+
+LINK:Documentation/DevGuide/Text/Sorting_Text
+DESCR:Text - Sorting Text
+REF:
+com.sun.star.text.TextSortDescriptor
+com.sun.star.beans.PropertyValue
+com.sun.star.util.XSortable
+TOPIC:
+com.sun.star.util.XSortable
+
+LINK:Documentation/DevGuide/ProUNO/Java/Mapping_of_Struct_Types
+DESCR:ProUNO - Java - Mapping of Struct Types
+REF:
+com.sun.star.beans.Optional
+com.sun.star.beans.Ambiguous
+com.sun.star.uno.XInterface
+com.sun.star.beans.PropertyValue
+TOPIC:
+
+LINK:Documentation/DevGuide/UCB/Instantiating_the_UCB
+DESCR:UCB - Instantiating the UCB
+REF:
+com.sun.star.ucb.UniversalContentBroker
+TOPIC:
+com.sun.star.ucb.UniversalContentBroker
+
+LINK:Documentation/DevGuide/AppendixC/The_Package_Content_Provider#Creation_of_New_PCP_Contents
+DESCR:AppendixC - The Package Content Provider - Creation of New PCP Contents
+REF:
+com.sun.star.ucb.XContentCreator
+com.sun.star.io.XInputStream
+TOPIC:
+com.sun.star.ucb.XContentCreator
+
+LINK:Documentation/DevGuide/Text/Overall_Document_Features#Styles
+DESCR:Text - Overall Document Features - Styles
+REF:
+com.sun.star.style.Style
+com.sun.star.container.XNamed
+com.sun.star.style.XStyleFamiliesSupplier
+com.sun.star.style.StyleFamilies
+com.sun.star.container.XNameContainer
+com.sun.star.container.XIndexAccess
+com.sun.star.style.XStyle
+com.sun.star.container.XNameAccess
+com.sun.star.uno.RuntimeException
+com.sun.star.style.XStyleLoader
+com.sun.star.style.StyleFamily
+TOPIC:
+com.sun.star.style.Style
+com.sun.star.style.StyleFamilies
+com.sun.star.style.XStyle
+com.sun.star.style.StyleFamily
+
+LINK:Documentation/DevGuide/Basic/Combo_Box
+DESCR:Basic - Combo Box
+REF:
+com.sun.star.awt.UnoControlComboBox
+com.sun.star.awt.XComboBox
+TOPIC:
+
+LINK:Documentation/DevGuide/Extensions/Creating_the_GUI_of_the_Options_Page
+DESCR:Extensions - Creating the GUI of the Options Page
+REF:
+com.sun.star.awt.ContainerWindowProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Function_Handling#Information_about_Functions
+DESCR:Spreadsheets - Function Handling - Information about Functions
+REF:
+com.sun.star.sheet.FunctionArgument
+com.sun.star.sheet.FunctionDescriptions
+com.sun.star.sheet.RecentFunctions
+com.sun.star.sheet.XFunctionDescriptions
+com.sun.star.container.XIndexAccess
+com.sun.star.sheet.FunctionAccess
+com.sun.star.beans.PropertyValue
+com.sun.star.container.XNameAccess
+com.sun.star.sheet.FunctionDescription
+TOPIC:
+com.sun.star.sheet.FunctionDescriptions
+com.sun.star.sheet.FunctionDescription
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Models#XStorable
+DESCR:OfficeDev - Component - Models - XStorable
+REF:
+com.sun.star.frame.XStorable
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleAction
+DESCR:Accessibility - XAccessibleAction
+REF:
+com.sun.star.accessibility.XAccessibleKeyBinding
+com.sun.star.accessibility.XAccessibleAction
+TOPIC:
+com.sun.star.accessibility.XAccessibleAction
+
+LINK:Documentation/DevGuide/Text/Editing_Text
+DESCR:Text - Editing Text
+REF:
+com.sun.star.text.XText
+TOPIC:
+com.sun.star.text.XText
+
+LINK:Documentation/DevGuide/Database/The_SingleSelectQueryComposer
+DESCR:Database - The SingleSelectQueryComposer
+REF:
+com.sun.star.sdb.SingleSelectQueryAnalyzer
+com.sun.star.sdb.SingleSelectQueryComposer
+com.sun.star.sdb.Connection
+com.sun.star.sdbcx.XTablesSupplier
+com.sun.star.sdb.DataColumn
+com.sun.star.sdbcx.XColumnsSupplier
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.sdb.XParametersSupplier
+com.sun.star.sdb.XSingleSelectQueryAnalyzer
+com.sun.star.sdb.SQLQueryComposer
+TOPIC:
+com.sun.star.sdb.SingleSelectQueryComposer
+
+LINK:Documentation/DevGuide/OfficeDev/Closing_Documents#How_to_Trigger_Closing
+DESCR:OfficeDev - Closing Documents - How to Trigger Closing
+REF:
+com.sun.star.util.XModifiable
+com.sun.star.util.XCloseable
+TOPIC:
+
+LINK:Documentation/DevGuide/Charts/Chart_Document_Controller
+DESCR:Charts - Chart Document Controller
+REF:
+com.sun.star.frame.XModel
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Implementing_a_New_Locale#XNativeNumberSupplier
+DESCR:OfficeDev - Implementing a New Locale - XNativeNumberSupplier
+REF:
+com.sun.star.i18n.NativeNumberMode
+com.sun.star.i18n.XNativeNumberSupplier
+TOPIC:
+com.sun.star.i18n.XNativeNumberSupplier
+
+LINK:Documentation/DevGuide/OfficeDev/Creating_Frames_Manually#Setting_Components_into_Frame_Hierarchies
+DESCR:OfficeDev - Creating Frames Manually - Setting Components into Frame Hierarchies
+REF:
+TOPIC:
+com.sun.star.frame.XFramesSupplier
+
+LINK:Documentation/DevGuide/Spreadsheets/Sorting#Table_Sort_Descriptor
+DESCR:Spreadsheets - Sorting - Table Sort Descriptor
+REF:
+com.sun.star.sheet.GlobalSheetSettings
+com.sun.star.sheet.SheetSortDescriptor2
+com.sun.star.table.TableSortDescriptor2
+com.sun.star.table.TableSortField
+com.sun.star.util.SortDescriptor2
+com.sun.star.util.XSortable
+com.sun.star.i18n.Collator
+TOPIC:
+com.sun.star.sheet.SheetSortDescriptor2
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Frames#XDispatchProvider_and_XDispatchProviderInterception
+DESCR:OfficeDev - Component - Frames - XDispatchProvider and XDispatchProviderInterception
+REF:
+com.sun.star.frame.XDispatchProviderInterception
+com.sun.star.frame.XDispatchProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Basic/Case_Sensitivity
+DESCR:ProUNO - Basic - Case Sensitivity
+REF:
+com.sun.star.container.XNameAccess
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Drawing_Shapes
+DESCR:Text - Drawing Shapes
+REF:
+com.sun.star.drawing.HomogenMatrix
+com.sun.star.text.XTextRange
+com.sun.star.text.XTextFrame
+com.sun.star.container.XNameContainer
+com.sun.star.text.TextContentAnchorType
+com.sun.star.text.Shape
+com.sun.star.style.XStyle
+com.sun.star.drawing.Shape
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Overview_and_Using_the_API#XTransliteration
+DESCR:OfficeDev - Overview and Using the API - XTransliteration
+REF:
+com.sun.star.i18n.XLocaleData
+com.sun.star.i18n.XTransliteration
+TOPIC:
+com.sun.star.i18n.XTransliteration
+
+LINK:Documentation/DevGuide/Drawings/Working_with_Drawing_Documents#Page_Partitioning
+DESCR:Drawings - Working with Drawing Documents - Page Partitioning
+REF:
+com.sun.star.view.PaperOrientation
+com.sun.star.drawing.GenericDrawPage
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Basic/Listeners
+DESCR:ProUNO - Basic - Listeners
+REF:
+com.sun.star.container.ContainerEvent
+com.sun.star.lang.XEventListener
+com.sun.star.lang.EventObject
+com.sun.star.container.XContainerListener
+TOPIC:
+com.sun.star.lang.XEventListener
+
+LINK:Documentation/DevGuide/Spreadsheets/Filter_Options
+DESCR:Spreadsheets - Filter Options
+REF:
+com.sun.star.beans.PropertyValue
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Framework_API
+DESCR:OfficeDev - Framework API
+REF:
+com.sun.star.awt
+TOPIC:
+
+LINK:Documentation/DevGuide/Basic/HorizontalVertical_Scroll_Bar
+DESCR:Basic - HorizontalVertical Scroll Bar
+REF:
+com.sun.star.awt.UnoControlScrollBar
+com.sun.star.awt.AdjustmentEvent
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Controllers
+DESCR:OfficeDev - Controllers
+REF:
+com.sun.star.frame.XController
+com.sun.star.sheet.XSpreadsheetView
+com.sun.star.text.XTextViewCursorSupplier
+TOPIC:
+com.sun.star.frame.Controller
+com.sun.star.frame.XController
+
+LINK:Documentation/DevGuide/AppendixC/The_Help_Content_Provider#Module_Content
+DESCR:AppendixC - The Help Content Provider - Properties and Commands - Module Content
+REF:
+com.sun.star.ucb.XDynamicResultSet
+TOPIC:
+
+LINK:Documentation/DevGuide/AdvUNO/UNO_Reflection_API#CoreReflection_Service
+DESCR:AdvUNO - UNO Reflection API - CoreReflection Service
+REF:
+com.sun.star.reflection.XIdlClass
+com.sun.star.reflection.CoreReflection
+com.sun.star.reflection.XIdlReflection
+com.sun.star.reflection.XIdlField2
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Spreadsheet
+DESCR:Spreadsheets - Spreadsheet
+REF:
+com.sun.star.sheet.Spreadsheet
+TOPIC:
+
+LINK:Documentation/DevGuide/Text/Reference_Marks
+DESCR:Text - Reference Marks
+REF:
+com.sun.star.container.XNamed
+com.sun.star.text.textfield.GetReference
+com.sun.star.container.XIndexAccess
+com.sun.star.text.XReferenceMarksSupplier
+com.sun.star.container.XNameAccess
+com.sun.star.text.ReferenceMarks
+com.sun.star.text.XTextContent
+TOPIC:
+com.sun.star.text.ReferenceMark
+
+LINK:Documentation/DevGuide/Database/Database_Design#Retrieving_General_Information
+DESCR:Database - Database Design - Retrieving Information about a Database - Retrieving General Information
+REF:
+com.sun.star.sdbc.XDatabaseMetaData
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Service_Manager#XMultiServiceFactory_Interface
+DESCR:ProUNO - Service Manager - XMultiServiceFactory Interface
+REF:
+com.sun.star.lang.XInitialization
+com.sun.star.lang.XMultiServiceFactory
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Bridge/Type_Mappings
+DESCR:ProUNO - Bridge - Type Mappings
+REF:
+com.sun.star.script.XInvocation
+TOPIC:
+
+LINK:Documentation/DevGuide/Drawings/Overall_Document_Features#Graphics_Styles
+DESCR:Drawings - Overall Document Features - Styles - Graphics Styles
+REF:
+com.sun.star.drawing.ShadowProperties
+com.sun.star.drawing.ConnectorProperties
+com.sun.star.style.XStyleFamiliesSupplier
+com.sun.star.style.ParagraphProperties
+com.sun.star.drawing.MeasureProperties
+com.sun.star.container.XNameContainer
+com.sun.star.style.XStyle
+com.sun.star.container.XNameAccess
+com.sun.star.drawing.TextProperties
+com.sun.star.drawing.LineProperties
+com.sun.star.drawing.FillProperties
+com.sun.star.style.CharacterProperties
+TOPIC:
+com.sun.star.style.XStyle
+
+LINK:Documentation/DevGuide/WritingUNO/Jobs/Using_the_vnd.sun.star.jobs:_URL_Schema
+DESCR:WritingUNO - Jobs - Using the vnd.sun.star.jobs: URL Schema
+REF:
+com.sun.star.task.XAsyncJob
+com.sun.star.task.XJob
+com.sun.star.task.Job
+com.sun.star.task.AsyncJob
+TOPIC:
+
+LINK:Documentation/DevGuide/WritingUNO/XAggregation
+DESCR:WritingUNO - XAggregation
+REF:
+com.sun.star.uno.XAggregation
+TOPIC:
+com.sun.star.uno.XAggregation
+
+LINK:Documentation/DevGuide/OfficeDev/Component/Frames#Frame_Hierarchies
+DESCR:OfficeDev - Component - Frames - XFrame - Frame Hierarchies
+REF:
+com.sun.star.frame.XFrames
+com.sun.star.frame.FrameSearchFlag
+com.sun.star.frame.XFramesSupplier
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Component_Context#Compatibility_Issues_and_Migration_Path
+DESCR:ProUNO - Component Context - Compatibility Issues and Migration Path
+REF:
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.lang.XMultiComponentFactory
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Java/Handling_Interfaces
+DESCR:ProUNO - Java - Handling Interfaces
+REF:
+com.sun.star.lang.XMultiServiceFactory
+com.sun.star.uno.XInterface
+TOPIC:
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleEventListener
+DESCR:Accessibility - XAccessibleEventListener
+REF:
+com.sun.star.accessibility.XAccessibleEventListener
+com.sun.star.accessibility.AccessibleEventObject
+com.sun.star.accessibility.XAccessibleContext
+com.sun.star.accessibility.AccessibleEventId
+com.sun.star.accessibility.XAccessible
+TOPIC:
+com.sun.star.accessibility.XAccessibleEventListener
+
+LINK:Documentation/DevGuide/ProUNO/Java/Transparent_Use_of_Office_UNO_Components
+DESCR:ProUNO - Java - Transparent Use of Office UNO Components
+REF:
+TOPIC:
+com.sun.star.uno.XComponentContext
+com.sun.star.lang.XMultiComponentFactory
+
+LINK:Documentation/DevGuide/GUI/Command_Button
+DESCR:GUI - Command Button
+REF:
+com.sun.star.awt.XActionListener
+com.sun.star.awt.PushButtonType
+com.sun.star.awt.ImageAlign
+com.sun.star.awt.UnoControlButton
+com.sun.star.awt.UnoControlButtonModel
+TOPIC:
+
+LINK:Documentation/DevGuide/ProUNO/Singletons
+DESCR:ProUNO - Singletons
+REF:
+com.sun.star.uno.XComponentContext
+com.sun.star.uno.DeploymentException
+TOPIC:
+
+LINK:Documentation/DevGuide/Charts/Common_Parts_of_all_Chart_Types#Diagram
+DESCR:Charts - Common Parts of all Chart Types - Diagram
+REF:
+com.sun.star.chart.ChartStatistics
+com.sun.star.chart.BarDiagram
+com.sun.star.chart.Dim3DDiagram
+com.sun.star.chart.StackableDiagram
+com.sun.star.chart.PieDiagram
+com.sun.star.chart.LineDiagram
+com.sun.star.chart.AreaDiagram
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/View_Panes
+DESCR:Spreadsheets - View Panes
+REF:
+com.sun.star.sheet.XViewPane
+com.sun.star.table.CellRangeAddress
+com.sun.star.sheet.XCellRangeReferrer
+com.sun.star.view.XControlAccess
+com.sun.star.sheet.SpreadsheetViewPane
+TOPIC:
+com.sun.star.sheet.SpreadsheetViewPane
+
+LINK:Documentation/DevGuide/ProUNO/Creating_the_Bridge
+DESCR:ProUNO - Creating the Bridge
+REF:
+com.sun.star.lang.XComponent
+com.sun.star.bridge.XBridgeFactory
+com.sun.star.lang.XEventListener
+com.sun.star.bridge.XBridge
+com.sun.star.bridge.BridgeFactory
+com.sun.star.bridge.XInstanceProvider
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Dispatch_Results
+DESCR:OfficeDev - Dispatch Results
+REF:
+com.sun.star.frame.DispatchResultEvent
+com.sun.star.frame.XNotifyingDispatch
+com.sun.star.frame.XDispatchResultListener
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Search_and_Replace
+DESCR:Spreadsheets - Search and Replace
+REF:
+com.sun.star.util.XReplaceable
+com.sun.star.util.XReplaceDescriptor
+com.sun.star.util.XSearchable
+TOPIC:
+com.sun.star.util.XReplaceable
+
+LINK:Documentation/DevGuide/Forms/Form_Controls_accepting_Value_Bindings
+DESCR:Forms - Form Controls accepting Value Bindings
+REF:
+com.sun.star.form.DataAwareControlModel
+com.sun.star.table.CellValueBinding
+com.sun.star.form.binding.BindableControlModel
+com.sun.star.form.binding.BindableDataAwareControlModel
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Spreadsheet_Documents
+DESCR:Spreadsheets - Spreadsheet Documents
+REF:
+com.sun.star.sheet.SheetCell
+com.sun.star.table
+com.sun.star.sheet
+com.sun.star.sheet.SheetCellRanges
+com.sun.star.table.CellRange
+com.sun.star.sheet.SheetCellRange
+com.sun.star.table.Cell
+com.sun.star.table.CellCursor
+com.sun.star.sheet.SheetCellCursor
+com.sun.star.sheet.Cells
+TOPIC:
+com.sun.star.sheet.SpreadsheetDocument
+
+LINK:Documentation/DevGuide/GUI/Currency_Field
+DESCR:GUI - Currency Field
+REF:
+com.sun.star.awt.UnoControlNumericField
+com.sun.star.awt.UnoControlCurrencyField
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Capabilities_of_SheetCell
+DESCR:Spreadsheets - Capabilities of SheetCell
+REF:
+com.sun.star.sheet.SheetCell
+com.sun.star.table.XCell
+com.sun.star.sheet.SheetCellRange
+com.sun.star.table.Cell
+com.sun.star.text.Text
+com.sun.star.text.XTextFieldsSupplier
+com.sun.star.text.XText
+com.sun.star.document.XActionLockable
+com.sun.star.table.CellAddress
+com.sun.star.sheet.XSheetAnnotationAnchor
+TOPIC:
+
+LINK:Documentation/DevGuide/OfficeDev/Frame-Controller-Model_Paradigm_in_OpenOffice.org
+DESCR:OfficeDev - Frame-Controller-Model Paradigm in OpenOffice.org
+REF:
+TOPIC:
+com.sun.star.frame.XController
+com.sun.star.frame.XFrame
+com.sun.star.frame.XModel
+
+LINK:Documentation/DevGuide/UCB/Documents#Storing_a_Document_Content
+DESCR:UCB - Documents - Storing a Document Content
+REF:
+com.sun.star.io.XInputStream
+com.sun.star.ucb.InsertCommandArgument
+TOPIC:
+
+LINK:Documentation/DevGuide/Spreadsheets/Other_Table_Operations#Data_Consolidation
+DESCR:Spreadsheets - Other Table Operations - Data Consolidation
+REF:
+com.sun.star.sheet.GeneralFunction
+com.sun.star.sheet.ConsolidationDescriptor
+com.sun.star.sheet.XConsolidatable
+com.sun.star.table.CellRangeAddress
+com.sun.star.sheet.XConsolidationDescriptor
+com.sun.star.table.CellAddress
+TOPIC:
+com.sun.star.sheet.XConsolidatable
+com.sun.star.sheet.XConsolidationDescriptor
+
+LINK:Documentation/DevGuide/Accessibility/XAccessibleText
+DESCR:Accessibility - XAccessibleText
+REF:
+com.sun.star.accessibility.XAccessibleText
+TOPIC:
+com.sun.star.accessibility.XAccessibleText
+
+LINK:Documentation/DevGuide/Scripting/Integration_with_Extension_Manager#Implementation_of_LanguageScriptProvider_with_support_for_Package_Manager
+DESCR:Scripting - Integration with Extension Manager - Overview of how ScriptingFramework integrates with the Extension Manager API - Implementation of LanguageScriptProvider with support for Package Manager
+REF:
+com.sun.star.deployment.XPackage
+com.sun.star.container.XNameContainer
+com.sun.star.container.XNameAccess
+TOPIC:
+
diff --git a/odk/pack/copying/makefile.mk b/odk/pack/copying/makefile.mk
new file mode 100644
index 000000000000..02471bd53638
--- /dev/null
+++ b/odk/pack/copying/makefile.mk
@@ -0,0 +1,262 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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
+#----------------------------------------------------------------
+
+IDLLIST:={$(subst,/,/ $(shell @$(FIND) $(IDLOUT)/com -type f))}
+DESTIDLLIST={$(subst,$(IDLOUT),$(DESTDIRIDL) $(IDLLIST))}
+
+DESTINCLUDELIST={$(subst,$(SOLARINCDIR),$(DESTDIRINC) $(INCLUDELIST))}
+DESTINCLUDELIST+=$(DESTDIRINC)/udkversion.mk
+
+DESTINCDIRLIST={$(subst,$(INCOUT),$(DESTDIRINC) $(INCLUDEDIRLIST))}
+
+IDL_DOCU_INDEX_FILE = $(DESTDIRGENIDLREF)/module-ix.html
+IDL_DOCU_CLEANUP_FLAG = $(MISC)/idl_docu_cleanup.flag
+
+IDL_CHAPTER_REFS=idl_chapter_refs.txt
+
+EXELIST = \
+ $(DESTDIRBIN)/cppumaker$(EXEPOSTFIX) \
+ $(DESTDIRBIN)/regcompare$(EXEPOSTFIX) \
+ $(DESTDIRBIN)/idlcpp$(EXEPOSTFIX) \
+ $(DESTDIRBIN)/idlc$(EXEPOSTFIX) \
+ $(DESTDIRBIN)/javamaker$(EXEPOSTFIX) \
+ $(DESTDIRBIN)/autodoc$(EXEPOSTFIX) \
+ $(DESTDIRBIN)/unoapploader$(EXEPOSTFIX) \
+ $(DESTDIRBIN)/uno-skeletonmaker$(EXEPOSTFIX)
+
+.IF "$(GUI)"=="WNT"
+EXELIST += \
+ $(DESTDIRBIN)/climaker$(EXEPOSTFIX)
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+CLILIST = \
+ $(DESTDIRCLI)/cli_basetypes.dll \
+ $(DESTDIRCLI)/cli_uretypes.dll \
+ $(DESTDIRCLI)/cli_oootypes.dll \
+ $(DESTDIRCLI)/cli_ure.dll \
+ $(DESTDIRCLI)/cli_cppuhelper.dll
+.ENDIF
+
+
+.IF "$(GUI)"=="WNT"
+LIBLIST = \
+ $(DESTDIRLIB)/istore.lib \
+ $(DESTDIRLIB)/ireg.lib \
+ $(DESTDIRLIB)/isal.lib \
+ $(DESTDIRLIB)/isalhelper.lib \
+ $(DESTDIRLIB)/icppu.lib \
+ $(DESTDIRLIB)/icppuhelper.lib \
+ $(DESTDIRLIB)/irmcxt.lib \
+ $(DESTDIRLIB)/ipurpenvhelper3MSC.lib
+
+.IF "$(COMEX)"=="8"
+ LIBLIST += $(DESTDIRLIB)/stlport_vc7.lib
+.ELIF "$(COMEX)"=="10" || "$(COMEX)"=="11" || "$(COMEX)"=="12"
+ LIBLIST += $(DESTDIRLIB)/stlport_vc71.lib
+.ELSE
+ LIBLIST += $(DESTDIRLIB)/stlport_vc6.lib
+.ENDIF
+.ENDIF
+
+.IF "$(OS)"=="LINUX"
+ LIBLIST = $(DESTDIRLIB)/libsalcpprt.a
+.ENDIF
+
+# note, that inner class files are copied implicitly
+DESTCLASSESLIST= \
+ $(DESTDIRJAR)/com/sun/star/lib/loader/Loader.class \
+ $(DESTDIRJAR)/com/sun/star/lib/loader/InstallationFinder.class \
+ $(DESTDIRJAR)/com/sun/star/lib/loader/WinRegKey.class \
+ $(DESTDIRJAR)/com/sun/star/lib/loader/WinRegKeyException.class
+# $(DESTDIRJAR)/com/sun/star/lib/loader/Loader$$CustomURLClassLoader.class \
+# $(DESTDIRJAR)/com/sun/star/lib/loader/InstallationFinder$$StreamGobbler.class \
+
+SETTINGSLIST= \
+ $(DESTDIRSETTINGS)/settings.mk \
+ $(DESTDIRSETTINGS)/std.mk \
+ $(DESTDIRSETTINGS)/stdtarget.mk \
+ $(DESTDIRSETTINGS)/dk.mk
+
+
+.IF "$(GUI)"=="WNT"
+SETTINGSLIST+=$(DESTDIRSETTINGS)/component.uno.def
+.ENDIF
+
+.IF "$(GUI)"=="UNX"
+SETTINGSLIST+=$(DESTDIRSETTINGS)/component.uno.map
+.ENDIF
+
+
+DOCUHTMLFILES+= \
+ $(DESTDIR)/index.html \
+ $(DESTDIRDOCU)/tools.html \
+ $(DESTDIRDOCU)/notsupported.html \
+ $(DESTDIRDOCU)/install.html \
+ $(DESTDIREXAMPLES)/examples.html \
+ $(DESTDIREXAMPLES)/DevelopersGuide/examples.html
+
+DOCUFILES= \
+ $(DOCUHTMLFILES) \
+ $(DESTDIRDOCU)/sdk_styles.css \
+ $(DESTDIRGENIDLREF)/idl.css \
+ $(DESTDIRDOCUIMAGES)/nada.gif \
+ $(DESTDIRDOCUIMAGES)/arrow-2.gif \
+ $(DESTDIRDOCUIMAGES)/bluball.gif \
+ $(DESTDIRDOCUIMAGES)/orc-main-app_32.png \
+ $(DESTDIRDOCUIMAGES)/ooo-main-app_32.png \
+ $(DESTDIRDOCUIMAGES)/odk-footer-logo.gif \
+ $(DESTDIRDOCUIMAGES)/arrow-1.gif \
+ $(DESTDIRDOCUIMAGES)/arrow-3.gif \
+ $(DESTDIRDOCUIMAGES)/bg_table.png \
+ $(DESTDIRDOCUIMAGES)/bg_table2.png \
+ $(DESTDIRDOCUIMAGES)/bg_table3.png \
+ $(DESTDIRDOCUIMAGES)/nav_down.png \
+ $(DESTDIRDOCUIMAGES)/nav_home.png \
+ $(DESTDIRDOCUIMAGES)/nav_left.png \
+ $(DESTDIRDOCUIMAGES)/nav_right.png \
+ $(DESTDIRDOCUIMAGES)/nav_up.png \
+ $(DESTDIRDOCUIMAGES)/sdk_head-1.png \
+ $(DESTDIRDOCUIMAGES)/sdk_head-2.png \
+ $(DESTDIRDOCUIMAGES)/sdk_line-1.gif \
+ $(DESTDIRDOCUIMAGES)/sdk_line-2.gif
+
+.IF "$(GUI)"=="UNX"
+INSTALLSCRIPT= \
+ $(DESTDIR)/config.guess \
+ $(DESTDIR)/config.sub \
+ $(DESTDIR)/configure.pl \
+ $(DESTDIR)/setsdkenv_unix \
+ $(DESTDIR)/setsdkenv_unix.sh.in \
+ $(DESTDIR)/setsdkenv_unix.csh.in
+.ELSE
+INSTALLSCRIPT= \
+ $(DESTDIR)/setsdkenv_windows.bat \
+ $(DESTDIR)/setsdkenv_windows.template \
+ $(DESTDIR)/setsdkname.bat \
+ $(DESTDIR)/cfgWin.js
+.ENDIF
+
+DIR_FILE_LIST=\
+ $(EXELIST) \
+ $(CLILIST) \
+ $(LIBLIST) \
+ $(SETTINGSLIST) \
+ $(DOCUFILES) \
+ $(INSTALLSCRIPT) \
+ $(DESTIDLLIST) \
+ $(DESTINCLUDELIST) \
+ $(DESTCLASSESLIST) \
+ $(IDL_DOCU_INDEX_FILE) \
+ $(CONVERTTAGFLAG)
+
+.IF "$(OS)"=="MACOSX"
+DIR_FILE_LIST += $(DESTDIRBIN)/addsym-macosx.sh
+.ENDIF
+
+.IF "$(SOLAR_JAVA)" != ""
+DIR_FILE_LIST += $(DESTDIRJAR)/win/unowinreg.dll
+.ENDIF
+
+DIR_DIRECTORY_LIST:=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG:=$(MISC)/copying_dirs_created.txt
+DIR_FILE_FLAG:=$(MISC)/copying_files.txt
+
+.IF "$(SOLAR_JAVA)" != ""
+# Special work for simple uno bootstrap mechanism
+# zip uno loader class files and winreg helper library for later
+# use in the build process (e.g. helper tools)
+MYZIPTARGET=$(BIN)/uno_loader_classes.zip
+MYZIPFLAGS=-u -r
+MYZIPDIR=$(DESTDIRJAR)
+MYZIPLIST=com/* win/*
+
+.ENDIF
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+
+.IF "$(L10N_framework)"==""
+
+all : CLEAN_DKVERSION_CHECK \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG) \
+
+.ENDIF
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)/util/odk_rules.pmk
+
+
+CLEANUP_DKVERSION_FILE=$(DESTDIRSETTINGS)/dk.mk
+
+
+CLEAN_DKVERSION_CHECK:
+ @@-rm -f $(CLEANUP_DKVERSION_FILE)
+
+$(DESTDIRBIN)/addsym-macosx.sh : addsym-macosx.sh
+ @@-rm -f $@
+ $(MY_TEXTCOPY) $(MY_TEXTCOPY_SOURCEPRE) $< $(MY_TEXTCOPY_TARGETPRE) $@
+ -chmod 755 $@
+
+$(DESTDIRSETTINGS)/dk.mk : dk.mk
+ @@-rm -f $@
+ -$(MKDIRHIER) $(@:d)
+ tr -d "\015" < dk.mk | sed -e 's/@@RELEASE@@/$(PRODUCT_RELEASE)/' -e 's/@@BUILDID@@/$(RSCREVISION)/'> $@
+
+$(CONVERTTAGFLAG) : $(DOCUHTMLFILES)
+# $(PERL) $(CONVERTTAGSCRIPT) 1 "$(TITLE)" "$(OFFICEPRODUCTNAME)" $(DOCUHTMLFILES)
+ @echo "tags converted" > $@
+
+$(IDL_DOCU_CLEANUP_FLAG) : $(IDL_CHAPTER_REFS) $(PRJ)/docs/common/ref/idl.css $(DESTIDLLIST)
+ @@-$(MY_DELETE_RECURSIVE) $(DESTDIRGENIDLREF)
+ $(TOUCH) $@
+
+$(IDL_DOCU_INDEX_FILE) : $(IDL_DOCU_CLEANUP_FLAG)
+ -$(MKDIRHIER) $(@:d)
+ $(MY_AUTODOC) -html $(DESTDIRGENIDLREF) -dvgroot "http://wiki.services.openoffice.org/wiki" \
+ -name $(IDLDOCREFNAME) -lg idl -dvgfile $(IDL_CHAPTER_REFS) -t $(DESTDIRIDL)
+ -rm $(@:d)/idl.css
+ $(MY_TEXTCOPY) $(MY_TEXTCOPY_SOURCEPRE) $(PRJ)/docs/common/ref/idl.css $(MY_TEXTCOPY_TARGETPRE) $(@:d:d)/idl.css
+
+
+.IF "$(SOLAR_JAVA)" != ""
+$(MYZIPTARGET) : $(BIN)/unowinreg.dll $(DESTCLASSESLIST)
+ cd $(MYZIPDIR) && zip $(MYZIPFLAGS) ../../../bin/$(MYZIPTARGET:b) $(MYZIPLIST)
+.ENDIF
diff --git a/odk/pack/gendocu/java/package-list b/odk/pack/gendocu/java/package-list
new file mode 100644
index 000000000000..fecd4d4ffb35
--- /dev/null
+++ b/odk/pack/gendocu/java/package-list
@@ -0,0 +1,135 @@
+java.applet
+java.awt
+java.awt.color
+java.awt.datatransfer
+java.awt.dnd
+java.awt.event
+java.awt.font
+java.awt.geom
+java.awt.im
+java.awt.im.spi
+java.awt.image
+java.awt.image.renderable
+java.awt.print
+java.beans
+java.beans.beancontext
+java.io
+java.lang
+java.lang.ref
+java.lang.reflect
+java.math
+java.net
+java.nio
+java.nio.channels
+java.nio.channels.spi
+java.nio.charset
+java.nio.charset.spi
+java.rmi
+java.rmi.activation
+java.rmi.dgc
+java.rmi.registry
+java.rmi.server
+java.security
+java.security.acl
+java.security.cert
+java.security.interfaces
+java.security.spec
+java.sql
+java.text
+java.util
+java.util.jar
+java.util.logging
+java.util.prefs
+java.util.regex
+java.util.zip
+javax.accessibility
+javax.crypto
+javax.crypto.interfaces
+javax.crypto.spec
+javax.imageio
+javax.imageio.event
+javax.imageio.metadata
+javax.imageio.plugins.jpeg
+javax.imageio.spi
+javax.imageio.stream
+javax.naming
+javax.naming.directory
+javax.naming.event
+javax.naming.ldap
+javax.naming.spi
+javax.net
+javax.net.ssl
+javax.print
+javax.print.attribute
+javax.print.attribute.standard
+javax.print.event
+javax.rmi
+javax.rmi.CORBA
+javax.security.auth
+javax.security.auth.callback
+javax.security.auth.kerberos
+javax.security.auth.login
+javax.security.auth.spi
+javax.security.auth.x500
+javax.security.cert
+javax.sound.midi
+javax.sound.midi.spi
+javax.sound.sampled
+javax.sound.sampled.spi
+javax.sql
+javax.swing
+javax.swing.border
+javax.swing.colorchooser
+javax.swing.event
+javax.swing.filechooser
+javax.swing.plaf
+javax.swing.plaf.basic
+javax.swing.plaf.metal
+javax.swing.plaf.multi
+javax.swing.table
+javax.swing.text
+javax.swing.text.html
+javax.swing.text.html.parser
+javax.swing.text.rtf
+javax.swing.tree
+javax.swing.undo
+javax.transaction
+javax.transaction.xa
+javax.xml.parsers
+javax.xml.transform
+javax.xml.transform.dom
+javax.xml.transform.sax
+javax.xml.transform.stream
+org.ietf.jgss
+org.omg.CORBA
+org.omg.CORBA.DynAnyPackage
+org.omg.CORBA.ORBPackage
+org.omg.CORBA.TypeCodePackage
+org.omg.CORBA.portable
+org.omg.CORBA_2_3
+org.omg.CORBA_2_3.portable
+org.omg.CosNaming
+org.omg.CosNaming.NamingContextExtPackage
+org.omg.CosNaming.NamingContextPackage
+org.omg.Dynamic
+org.omg.DynamicAny
+org.omg.DynamicAny.DynAnyFactoryPackage
+org.omg.DynamicAny.DynAnyPackage
+org.omg.IOP
+org.omg.IOP.CodecFactoryPackage
+org.omg.IOP.CodecPackage
+org.omg.Messaging
+org.omg.PortableInterceptor
+org.omg.PortableInterceptor.ORBInitInfoPackage
+org.omg.PortableServer
+org.omg.PortableServer.CurrentPackage
+org.omg.PortableServer.POAManagerPackage
+org.omg.PortableServer.POAPackage
+org.omg.PortableServer.ServantLocatorPackage
+org.omg.PortableServer.portable
+org.omg.SendingContext
+org.omg.stub.java.rmi
+org.w3c.dom
+org.xml.sax
+org.xml.sax.ext
+org.xml.sax.helpers
diff --git a/odk/pack/gendocu/makefile.mk b/odk/pack/gendocu/makefile.mk
new file mode 100644
index 000000000000..fc9abf1881b8
--- /dev/null
+++ b/odk/pack/gendocu/makefile.mk
@@ -0,0 +1,122 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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=gendocu
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+.IF "$(L10N_framework)"==""
+
+CPPDOCREFNAME="UDK $(UDK_MAJOR).$(UDK_MINOR).$(UDK_MICRO) C/C++ API Reference"
+JAVADOCREFNAME="UDK $(UDK_MAJOR).$(UDK_MINOR).$(UDK_MICRO) Java API Reference"
+
+CPP_DOCU_INDEX_FILE = $(DESTDIRGENCPPREF)$/index.html
+JAVA_DOCU_INDEX_FILE = $(DESTDIRGENJAVAREF)$/index.html
+
+CPP_DOCU_CLEANUP_FLAG = $(MISC)$/cpp_docu_cleanup.flag
+
+JAVA_SRC_DIR=$(MISC)$/java_src
+JAVA_PACKAGES=\
+ com.sun.star.comp.helper \
+ com.sun.star.lib.uno.helper \
+ com.sun.star.lib.unoloader \
+ com.sun.star.uno \
+ $(JAVA_SRC_DIR)$/com$/sun$/star$/lib$/util$/UrlToFileMapper.java
+# com.sun.star.beans \
+
+JAVA_SRC_FILES=\
+ $(JAVA_SRC_DIR)$/jurt_src.zip \
+ $(JAVA_SRC_DIR)$/juh_src.zip \
+ $(JAVA_SRC_DIR)$/ridl_src.zip \
+ $(JAVA_SRC_DIR)$/unoloader_src.zip
+
+JAVA_BEAN_SRC_FILES=\
+ $(JAVA_SRC_DIR)$/com$/sun$/star$/beans$/ContainerFactory.java \
+ $(JAVA_SRC_DIR)$/com$/sun$/star$/beans$/JavaWindowPeerFake.java \
+ $(JAVA_SRC_DIR)$/com$/sun$/star$/beans$/LocalOfficeConnection.java \
+ $(JAVA_SRC_DIR)$/com$/sun$/star$/beans$/LocalOfficeWindow.java \
+ $(JAVA_SRC_DIR)$/com$/sun$/star$/beans$/NativeConnection.java \
+ $(JAVA_SRC_DIR)$/com$/sun$/star$/beans$/NativeService.java \
+ $(JAVA_SRC_DIR)$/com$/sun$/star$/beans$/OfficeConnection.java \
+ $(JAVA_SRC_DIR)$/com$/sun$/star$/beans$/OfficeWindow.java
+
+AUTODOCPARAMS= -lg c++ \
+ -p sal $(INCOUT) -t sal -t osl -t rtl \
+ -p store $(INCOUT) -t store \
+ -p registry $(INCOUT) -t registry \
+ -p cppu $(INCOUT) -t cppu -t com -t typelib -t uno \
+ -p cppuhelper $(INCOUT) -t cppuhelper \
+ -p salhelper $(INCOUT) -t salhelper \
+ -p bridges $(INCOUT) -t bridges
+
+JAVADOCPARAMS= -use -splitindex -windowtitle "Java UNO Runtime Reference" -header $(JAVADOCREFNAME) -d $(DESTDIRGENJAVAREF) -sourcepath $(JAVA_SRC_DIR) -classpath $(SOLARBINDIR)$/ridl.jar -linkoffline ../../common/ref ./uno -linkoffline http://java.sun.com/j2se/1.4.1/docs/api ./java $(JAVA_PACKAGES)
+
+JAVADOCLOG = $(MISC)$/javadoc_log.txt
+
+.IF "$(SOLAR_JAVA)"!=""
+all: \
+ $(CPP_DOCU_INDEX_FILE) \
+ $(JAVA_DOCU_INDEX_FILE)
+
+.ELSE
+all: $(CPP_DOCU_INDEX_FILE)
+.ENDIF
+
+
+$(CPP_DOCU_CLEANUP_FLAG) : $(INCLUDELIST) $(PRJ)$/docs$/cpp$/ref$/cpp.css
+ @@-$(MY_DELETE_RECURSIVE) $(DESTDIRGENCPPREF)
+ $(TOUCH) $@
+
+$(CPP_DOCU_INDEX_FILE) : $(CPP_DOCU_CLEANUP_FLAG)
+ -$(MKDIRHIER) $(@:d)
+ $(MY_AUTODOC) -html $(DESTDIRGENCPPREF) -name $(CPPDOCREFNAME) $(AUTODOCPARAMS)
+ -rm $(@:d:d)$/cpp.css
+ $(MY_TEXTCOPY) $(MY_TEXTCOPY_SOURCEPRE) $(PRJ)$/docs$/cpp$/ref$/cpp.css $(MY_TEXTCOPY_TARGETPRE) $(@:d:d)$/cpp.css
+
+$(JAVA_SRC_FILES) : $(SOLARCOMMONBINDIR)$/$$(@:f)
+ -$(MKDIRHIER) $(@:d)
+ $(MY_COPY) $< $@
+ cd $(JAVA_SRC_DIR) && unzip -quo $(@:f)
+
+#$(JAVA_SRC_DIR)$/com$/sun$/star$/beans$/%.java : $(PRJ)$/source$/bean$/com$/sun$/star$/beans$/%.java
+# -$(MKDIRHIER) $(@:d)
+# $(MY_COPY) $< $@
+
+#$(JAVA_DOCU_INDEX_FILE) .SEQUENTIAL : $(JAVA_SRC_FILES) $(JAVA_BEAN_SRC_FILES)
+.IF "$(SOLAR_JAVA)"!=""
+$(JAVA_DOCU_INDEX_FILE) .SEQUENTIAL : $(JAVA_SRC_FILES)
+ -$(MKDIRHIER) $(@:d)
+ $(JAVADOC) -J-Xmx120m $(JAVADOCPARAMS) > $(JAVADOCLOG)
+.ENDIF
+
+.ELSE
+pseudo:
+.ENDIF
diff --git a/odk/pack/gendocu/uno/package-list b/odk/pack/gendocu/uno/package-list
new file mode 100644
index 000000000000..0e6766d932f2
--- /dev/null
+++ b/odk/pack/gendocu/uno/package-list
@@ -0,0 +1,53 @@
+com.sun.star.apitest
+com.sun.star.awt
+com.sun.star.beans
+com.sun.star.bridge
+com.sun.star.chart
+com.sun.star.configuration
+com.sun.star.connection
+com.sun.star.container
+com.sun.star.corba
+com.sun.star.datatransfer
+com.sun.star.document
+com.sun.star.drawing
+com.sun.star.form
+com.sun.star.formula
+com.sun.star.frame
+com.sun.star.i18n
+com.sun.star.installation
+com.sun.star.io
+com.sun.star.java
+com.sun.star.lang
+com.sun.star.linguistic2
+com.sun.star.loader
+com.sun.star.mozilla
+com.sun.star.plugin
+com.sun.star.presentation
+com.sun.star.qadev
+com.sun.star.reflection
+com.sun.star.registry
+com.sun.star.resource
+com.sun.star.scanner
+com.sun.star.script
+com.sun.star.sdb
+com.sun.star.sdbc
+com.sun.star.sdbcx
+com.sun.star.security
+com.sun.star.setup
+com.sun.star.sheet
+com.sun.star.stoc
+com.sun.star.style
+com.sun.star.svg
+com.sun.star.sync
+com.sun.star.sync2
+com.sun.star.system
+com.sun.star.table
+com.sun.star.task
+com.sun.star.test
+com.sun.star.text
+com.sun.star.ucb
+com.sun.star.ui
+com.sun.star.uno
+com.sun.star.util
+com.sun.star.view
+com.sun.star.xml
diff --git a/odk/pack/unzip_udk/deltree.txt b/odk/pack/unzip_udk/deltree.txt
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/odk/pack/unzip_udk/deltree.txt
diff --git a/odk/pack/unzip_udk/makefile.mk b/odk/pack/unzip_udk/makefile.mk
new file mode 100644
index 000000000000..1a06dd2b3606
--- /dev/null
+++ b/odk/pack/unzip_udk/makefile.mk
@@ -0,0 +1,46 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=odk
+TARGET=unzip_udk
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+all: ..$/misc$/deltree.txt
+
+..$/misc$/deltree.txt .SETDIR=$(OUT)$/bin : $(PRJ)$/pack$/unzip_udk$/deltree.txt
+ @@-$(MY_DELETE_RECURSIVE) $(PRODUCT_NAME)
+ @@-rm -f $(PRODUCT_NAME).zip
+ @@-$(MY_DELETE_RECURSIVE) $(PRODUCT_NAME2)
+ @@-rm -f odkidl.zip
+ @@-rm -f odk_ooidl.zip
+ @echo "" > ..$/misc$/deltree.txt
+
diff --git a/odk/prj/build.lst b/odk/prj/build.lst
new file mode 100644
index 000000000000..bbb8262780cf
--- /dev/null
+++ b/odk/prj/build.lst
@@ -0,0 +1,15 @@
+od odk :: cppuhelper jurt javaunohelper udkapi ridljar offapi autodoc unodevtools external NULL
+od odk usr1 - all od_mkout NULL
+od odk\inc nmake - all od_inc NULL
+od odk\source\com\sun\star\lib\loader nmake - all od_loader od_inc NULL
+od odk\source\unoapploader\win nmake - n od_unoapploaderwin od_inc NULL
+od odk\source\unoapploader\unx nmake - u od_unoapploaderunx od_inc NULL
+od odk\source\unowinreg\win nmake - all od_unowinreg od_inc NULL
+od odk\pack\unzip_udk nmake - all od_unzip_udk NULL
+od odk\pack\copying nmake - all od_copying od_unzip_udk od_loader od_unoapploaderwin.n od_unoapploaderunx.u od_unowinreg NULL
+od odk\pack\checkinc nmake - all od_checkinc od_copying NULL
+od odk\pack\checkinc2 nmake - all od_checkinc2 od_copying NULL
+od odk\pack\checkidl nmake - all od_checkidl od_copying NULL
+od odk\pack\gendocu nmake - all od_gendocu od_copying NULL
+od odk\pack\checkbin nmake - all od_checkbin od_copying od_gendocu NULL
+od odk\util nmake - all od_util od_checkbin od_checkinc od_checkinc2 od_checkidl NULL
diff --git a/odk/prj/d.lst b/odk/prj/d.lst
new file mode 100644
index 000000000000..0af13f2f0fb5
--- /dev/null
+++ b/odk/prj/d.lst
@@ -0,0 +1,5 @@
+..\%__SRC%\bin\odkcommon.zip %_DEST%\bin%_EXT%\odkcommon.zip
+
+..\%__SRC%\bin\uno_loader_classes.zip %_DEST%\bin%_EXT%\uno_loader_classes.zip
+
+..\%__SRC%\bin\odkexamples.zip %COMMON_DEST%\bin%_EXT%\odkexamples.zip
diff --git a/odk/setsdkenv_unix b/odk/setsdkenv_unix
new file mode 100644
index 000000000000..31e0200eb1b7
--- /dev/null
+++ b/odk/setsdkenv_unix
@@ -0,0 +1,67 @@
+#! /bin/sh
+
+OSTYPE=`uname -s`
+HOSTNAME=`hostname`
+CURRENTDIR=`/bin/pwd`
+SDKTMPDIR=`dirname $0`
+OO_SDK_HOME=`(cd $SDKTMPDIR && pwd && cd $CURRENTDIR) | head -n 1`
+OOVERSION=`cat $OO_SDK_HOME/settings/dk.mk | tail -2 | head -n 1 | cut -d"=" -f2 | cut -d"." -f1,2`
+if [ "$OSTYPE" = "Darwin" ]
+then
+ OO_SDK_NAME=`basename $OO_SDK_HOME`
+else
+ OO_SDK_NAME=openoffice.org${OOVERSION}_sdk
+fi
+
+export OO_SDK_HOME
+
+if [ "$1" = "--force-configure" ]
+then
+ if [ -r $HOME/$OO_SDK_NAME/$HOSTNAME/setsdkenv_unix.sh ]
+ then
+ rm $HOME/$OO_SDK_NAME/$HOSTNAME/setsdkenv_unix.sh
+ fi
+ if [ -r $HOME/$OO_SDK_NAME/$HOSTNAME/setsdkenv_unix.csh ]
+ then
+ rm $HOME/$OO_SDK_NAME/$HOSTNAME/setsdkenv_unix.csh
+ fi
+ shift
+elif [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ -n "$1" ]
+then
+ echo
+ echo " using: setsdkenv_unix [options]"
+ echo ""
+ echo " options:"
+ echo " --force-configure : force a new configuration of your SDK environment."
+ echo " Alternatively can you edit your SDK environment scripts directly:"
+ echo " $HOME/$OO_SDK_NAME/setsdkenv_unix.sh"
+ echo " $HOME/$OO_SDK_NAME/setsdkenv_unix.csh"
+ echo " -h, --help : print this help and exit"
+ echo
+ exit 1
+fi
+
+# source the prepared environment and start a new shell
+if [ -r $HOME/$OO_SDK_NAME/$HOSTNAME/setsdkenv_unix.sh ]
+then
+ . $HOME/$OO_SDK_NAME/$HOSTNAME/setsdkenv_unix.sh
+else
+ echo
+ echo " ************************************************************************"
+ echo " *"
+ echo " * You have to configure your SDK environment first before you can"
+ echo " * can use it! The configuration has to be done only once."
+ echo " *"
+ echo " ************************************************************************"
+ echo
+
+ perl $OO_SDK_HOME/configure.pl $HOSTNAME $OO_SDK_HOME $OO_SDK_NAME
+
+ . $HOME/$OO_SDK_NAME/$HOSTNAME/setsdkenv_unix.sh
+fi
+
+"$SHELL" "$@"
+echo Shell terminated.
+
+TERMHEAD=$HOSTNAME
+echo "]2;$TERMHEAD"
diff --git a/odk/setsdkenv_unix.csh.in b/odk/setsdkenv_unix.csh.in
new file mode 100644
index 000000000000..ef513d4ef515
--- /dev/null
+++ b/odk/setsdkenv_unix.csh.in
@@ -0,0 +1,313 @@
+#! /bin/csh
+
+# This script sets all enviroment variables, which are necessary for building
+# the examples of the Office Development Kit.
+# The Script was developed for the operating systems Solaris, Linux and MacOS.
+
+# The SDK name
+setenv OO_SDK_NAME @OO_SDK_NAME@
+
+# Installation directory of the Software Development Kit.
+# Example: setenv OO_SDK_HOME /opt/openoffice.org/basis3.0/sdk
+setenv OO_SDK_HOME '@OO_SDK_HOME@'
+
+# Office installation directory.
+# Example: set OFFICE_HOME=/opt/openoffice.org3
+set OFFICE_HOME='@OFFICE_HOME@'
+OFFICE_BASE_HOME='@OFFICE_BASE_HOME@'
+
+# URE installation directory.
+# Example: setenv OO_SDK_URE_HOME /opt/openoffice.org/ure
+setenv OO_SDK_URE_HOME '@OO_SDK_URE_HOME@'
+
+# Directory of the make command.
+# Example: setenv OO_SDK_MAKE_HOME /usr/bin
+setenv OO_SDK_MAKE_HOME @OO_SDK_MAKE_HOME@
+
+# Directory of the zip command.
+# Example: setenv OO_SDK_ZIP_HOME /usr/bin
+setenv OO_SDK_ZIP_HOME @OO_SDK_ZIP_HOME@
+
+# Directory of the C++ compiler.
+# Example: setenv OO_SDK_CPP_HOME /usr/bin
+setenv OO_SDK_CPP_HOME @OO_SDK_CPP_HOME@
+
+# Solaris only
+setenv OO_SDK_CC_55_OR_HIGHER @OO_SDK_CC_55_OR_HIGHER@
+
+# Directory of the Java SDK.
+# Example: setenv OO_SDK_JAVA_HOME "/usr/jdk/jdk1.6.0_10"
+setenv OO_SDK_JAVA_HOME @OO_SDK_JAVA_HOME@
+
+# Special output directory
+# Example: setenv OO_SDK_OUTPUT_DIR "$HOME"
+setenv OO_SDK_OUTPUT_DIR @OO_SDK_OUTPUT_DIR@
+
+# Environment variable to enable auto deployment of example components
+# Example: set SDK_AUTO_DEPLOYMENT=YES
+setenv SDK_AUTO_DEPLOYMENT @SDK_AUTO_DEPLOYMENT@
+
+# Get the operating system.
+set sdk_platform=`${OO_SDK_HOME}/config.guess | cut -d"-" -f3,4`
+
+# Set the directory name.
+set programdir=program
+set javadir=bin
+switch (${sdk_platform})
+ case "darwin*":
+ set programdir="Contents/MacOS"
+ set javacdir=Commands
+ breaksw
+endsw
+
+
+# Set office program path.
+if ( "${OFFICE_HOME}" != "" ) then
+ setenv OFFICE_PROGRAM_PATH "${OFFICE_HOME}/${programdir}"
+endif
+
+# Set office base program path.
+if ( "${OFFICE_BASE_HOME}" != "" ) then
+ setenv OFFICE_BASE_PROGRAM_PATH "${OFFICE_BASE_HOME}/program"
+endif
+
+
+# Set UNO path, necessary to ensure that the cpp examples using the
+# new UNO bootstrap mechanism use the configured office installation.
+if ( ${?OFFICE_PROGRAM_PATH} ) then
+ setenv UNO_PATH "${OFFICE_PROGRAM_PATH}"
+endif
+
+if ( "${OO_SDK_URE_HOME}" != "" ) then
+ setenv OO_SDK_URE_BIN_DIR "${OO_SDK_URE_HOME}/bin"
+ setenv OO_SDK_URE_LIB_DIR "${OO_SDK_URE_HOME}/lib"
+ setenv OO_SDK_URE_JAVA_DIR "${OO_SDK_URE_HOME}/share/java"
+else
+ setenv OO_SDK_URE_BIN_DIR "${OFFICE_PROGRAM_PATH}"
+ setenv OO_SDK_URE_LIB_DIR "${OFFICE_BASE_PROGRAM_PATH}"
+ setenv OO_SDK_URE_JAVA_DIR "${OFFICE_BASE_PROGRAM_PATH}/classes"
+endif
+
+# Set SDK example output directory
+setenv OO_SDK_OUT ${OO_SDK_HOME}
+if ( $?OO_SDK_OUTPUT_DIR ) then
+ setenv OO_SDK_OUT ${OO_SDK_OUTPUT_DIR}/${OO_SDK_NAME}
+endif
+
+# check platform and set appropriate variables
+switch (`${OO_SDK_HOME}/config.guess | cut -d"-" -f3,4`)
+ case "solaris*":
+ if ( `${OO_SDK_HOME}/config.guess | cut -d"-" -f1` == "sparc" ) then
+ set directoryname=solsparc
+ set platform=Solaris Sparc
+ else
+ set directoryname=solintel
+ set platform=Solaris Intel
+ endif
+ set comid=C52
+ set pltfrm=sunpro
+ set soext=so
+ set exampleout=SOLARISexample.out
+ set stldebug=_debug
+
+ # set LD_LIBRARY_PATH
+ if ( $?LD_LIBARY_PATH == 0) then
+ setenv LD_LIBRARY_PATH ${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.
+ else
+ setenv LD_LIBRARY_PATH ${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH}
+ endif
+ breaksw
+
+ case "linux-gnu":
+ if ( $?OO_SDK_CPP_HOME == 0) then
+ set sdk_gxx_include_path=`echo "#include <cstring>" | ${OO_SDK_CPP_HOME}/g++ -E -xc++ - | sed -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1`
+ setenv SDK_GXX_INCLUDE_PATH ${sdk_gxx_include_path}
+ endif
+
+ set directoryname=linux
+ set comid=gcc3
+ set pltfrm=gcc
+ set soext=so
+ set exampleout=LINUXexample.out
+ set platform=Linux
+ set stldebug=_stldebug
+
+ # set LD_LIBRARY_PATH
+ if ( $?LD_LIBARY_PATH == 0) then
+ setenv LD_LIBRARY_PATH ${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.
+ else
+ setenv LD_LIBRARY_PATH ${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH}
+ endif
+ breaksw
+
+ case "darwin*":
+ if ( $?OO_SDK_CPP_HOME == 0) then
+ set sdk_gxx_include_path=`echo "#include <cstring>" | ${OO_SDK_CPP_HOME}/g++ -E -xc++ - | sed -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1`
+ setenv SDK_GXX_INCLUDE_PATH ${sdk_gxx_include_path}
+ endif
+
+ set directoryname=macosx
+ set comid=gcc3
+ set pltfrm=gcc
+ set soext=dylib
+ set exampleout=MACOSXexample.out
+ set platform=MacOSX
+ set stldebug=_stldebug
+
+ # set DYLD_LIBRARY_PATH
+ if ( $?DYLD_LIBRARY_PATH == 0) then
+ setenv DYLD_LIBRARY_PATH ${OO_SDK_OUT}/${directoryname}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.
+ else
+ setenv DYLD_LIBRARY_PATH ${OO_SDK_OUT}/${directoryname}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${DYLD_LIBRARY_PATH}
+ endif
+ breaksw
+
+ case "freebsd*":
+ if ( $?OO_SDK_CPP_HOME == 0) then
+ set sdk_gxx_include_path=`echo "#include <cstring>" | ${OO_SDK_CPP_HOME}/g++ -E -xc++ - | sed -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1`
+ setenv SDK_GXX_INCLUDE_PATH ${sdk_gxx_include_path}
+ endif
+
+ set directoryname=freebsd
+ set comid=gcc3
+ set pltfrm=gcc
+ set soext=so
+ set exampleout=FREEBSDexample.out
+ set platform=FreeBSD
+ set stldebug=_stldebug
+
+ # set LD_LIBRARY_PATH
+ if ( $?LD_LIBARY_PATH == 0) then
+ setenv LD_LIBRARY_PATH ${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.
+ else
+ setenv LD_LIBRARY_PATH ${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH}
+ endif
+
+ if ( -e "/sbin/sysctl" ) then
+ set OSVERSION=`/sbin/sysctl -n kern.osreldate`
+ else
+ set OSVERSION=`/usr/sbin/sysctl -n kern.osreldate`
+ endif
+
+ if ( ${OSVERSION} < 500016 ) then
+ setenv PTHREAD_CFLAGS -D_THREAD_SAFE
+ setenv PTHREAD_LIBS -pthread
+ else if ( ${OSVERSION} < 502102 ) then
+ setenv PTHREAD_CFLAGS -D_THREAD_SAFE
+ setenv PTHREAD_LIBS -lc_r
+ else
+ setenv PTHREAD_LIBS -pthread
+ endif
+ breaksw
+endsw
+
+# set PATH
+if ( $?PATH == 0) then
+ setenv PATH ${OO_SDK_ZIP_HOME}:${OO_SDK_MAKE_HOME}:${OO_SDK_HOME}/bin:${OO_SDK_OUT}/${exampleout}:${OO_SDK_URE_BIN_DIR}:.
+else
+ setenv PATH ${OO_SDK_ZIP_HOME}:${OO_SDK_MAKE_HOME}:${OO_SDK_HOME}/bin:${OO_SDK_OUT}/${exampleout}:${OO_SDK_URE_BIN_DIR}:.:${PATH}
+endif
+
+# Set CLASSPATH
+if ( ${?OFFICE_PROGRAM_PATH} ) then
+ if ( ${?CLASSPATH} == 0 ) then
+ setenv CLASSPATH "${OFFICE_PROGRAM_PATH}/classes/unoil.jar"
+ else
+ setenv CLASSPATH "${OFFICE_PROGRAM_PATH}/classes/unoil.jar:${CLASSPATH}"
+ endif
+endif
+if ( $?CLASSPATH == 0) then
+ setenv CLASSPATH "${OO_SDK_URE_JAVA_DIR}/juh.jar:${OO_SDK_URE_JAVA_DIR}/jurt.jar:${OO_SDK_URE_JAVA_DIR}/ridl.jar:${OO_SDK_URE_JAVA_DIR}/unoloader.jar"
+else
+ setenv CLASSPATH "${OO_SDK_URE_JAVA_DIR}/juh.jar:${OO_SDK_URE_JAVA_DIR}/jurt.jar:${OO_SDK_URE_JAVA_DIR}/ridl.jar:${OO_SDK_URE_JAVA_DIR}/unoloader.jar:${CLASSPATH}"
+endif
+
+if ( $?OO_SDK_CPP_HOME == 0) then
+ setenv PATH ${OO_SDK_CPP_HOME}:${PATH}
+endif
+
+if ( $?OO_SDK_JAVA_HOME == 0) then
+ setenv PATH ${OO_SDK_JAVA_HOME}:${PATH}
+endif
+
+if ( -r "${OO_SDK_URE_LIB_DIR}/libstlport_${pltfrm}${stldebug}.${soext}" ) then
+ setenv STLDEBUG ${stldebug}
+else
+ setenv STLDEBUG ""
+endif
+
+
+if [ "${platform}" == "MacOSX" ] then
+# For URE, prepare symbolic links for libraries:
+# Only necessary on MacOSX, on other Unix systems the links are already prepared
+# in the SDK installation.
+
+# cleanup potential old links first
+ rm -f "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppu.so" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppuhelper${comid}.${soext}" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_sal.${soext}" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_salhelper${comid}.${soext}" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_purpenvhelper${comid}.${soext}"
+
+ if ( -e "${OO_SDK_OUT}/${directoryname}/lib/libstlport_${pltfrm}${STLDEBUG}.${soext}" ) then
+ rm -rf "${OO_SDK_OUT}/${directoryname}/lib/libstlport_${pltfrm}${STLDEBUG}.${soext}"
+ endif
+
+ if ( "${OO_SDK_URE_HOME}" != "" ) then
+ mkdir -p "${OO_SDK_OUT}/${directoryname}/lib"
+ ln -s "${OO_SDK_URE_LIB_DIR}/libuno_cppu.${soext}.3" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppu.${soext}"
+ ln -s "${OO_SDK_URE_LIB_DIR}/libuno_cppuhelper${comid}.${soext}.3" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppuhelper${comid}.${soext}"
+ ln -s "${OO_SDK_URE_LIB_DIR}/libuno_sal.${soext}.3" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_sal.${soext}"
+ ln -s "${OO_SDK_URE_LIB_DIR}/libuno_salhelper${comid}.${soext}.3" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_salhelper${comid}.${soext}"
+ ln -s "${OO_SDK_URE_LIB_DIR}/libuno_purpenvhelper${comid}.${soext}.3" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_purpenvhelper${comid}.${soext}"
+
+ if ( -r "${OO_SDK_URE_LIB_DIR}/libstlport_${pltfrm}${STLDEBUG}.${soext}" ) then
+ ln -s "${OO_SDK_URE_LIB_DIR}/libstlport_${pltfrm}${STLDEBUG}.${soext}" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libstlport_${pltfrm}${STLDEBUG}.${soext}"
+ endif
+ endif
+endif
+
+
+echo
+echo " ************************************************************************"
+echo " *"
+echo " * SDK environment is prepared for ${platform}"
+echo " *"
+echo " * SDK = ${OO_SDK_HOME}"
+echo " * Office = ${OFFICE_HOME}"
+echo " * Office Base = ${OFFICE_BASE_HOME}"
+echo " * URE = ${OO_SDK_URE_HOME}"
+echo " * Make = ${OO_SDK_MAKE_HOME}"
+echo " * Zip = ${OO_SDK_ZIP_HOME}"
+if ( $?OO_SDK_CPP_HOME == 0) then
+echo " * C++ Compiler = "
+else
+echo " * C++ Compiler = ${OO_SDK_CPP_HOME}"
+endif
+if ( $?OO_SDK_JAVA_HOME == 0) then
+echo " * Java = "
+else
+echo " * Java = ${OO_SDK_JAVA_HOME}"
+endif
+if ( $?OO_SDK_OUTPUT_DIR == 0) then
+echo " * Special Output directory = "
+else
+echo " * SDK Output directory = ${OO_SDK_OUT}"
+endif
+echo " * Auto deployment = ${SDK_AUTO_DEPLOYMENT}"
+echo " *"
+echo " ************************************************************************"
+
+unset sdkdir
+unset directoryname
+unset comid
+unset exampleout
+unset platform
+
+echo "]2;Shell prepared with the SDK environment"
diff --git a/odk/setsdkenv_unix.sh.in b/odk/setsdkenv_unix.sh.in
new file mode 100644
index 000000000000..96365481c104
--- /dev/null
+++ b/odk/setsdkenv_unix.sh.in
@@ -0,0 +1,343 @@
+#! /bin/sh
+
+# This script starts a new shell and sets all enviroment variables, which
+# are necessary for building the examples of the Office Development Kit.
+# The Script was developed for the operating systems Solaris, Linux and MacOS.
+
+# The SDK name
+OO_SDK_NAME=@OO_SDK_NAME@
+export OO_SDK_NAME
+
+# Installation directory of the Software Development Kit.
+# Example: OO_SDK_HOME=/opt/openoffice.org/basis3.0/sdk
+OO_SDK_HOME='@OO_SDK_HOME@'
+
+# Office installation directory.
+# Example: OFFICE_HOME=/opt/openoffice.org3
+OFFICE_HOME='@OFFICE_HOME@'
+OFFICE_BASE_HOME='@OFFICE_BASE_HOME@'
+
+# URE installation directory.
+# Example: OO_SDK_URE_HOME=/opt/openoffice.org/ure
+OO_SDK_URE_HOME='@OO_SDK_URE_HOME@'
+export OO_SDK_URE_HOME
+
+# Directory of the make command.
+# Example: OO_SDK_MAKE_HOME=/usr/bin
+OO_SDK_MAKE_HOME=@OO_SDK_MAKE_HOME@
+
+# Directory of the zip command.
+# Example: OO_SDK_ZIP_HOME=/usr/bin
+OO_SDK_ZIP_HOME=@OO_SDK_ZIP_HOME@
+
+# Directory of the C++ compiler.
+# Example: OO_SDK_CPP_HOME=/usr/bin
+OO_SDK_CPP_HOME=@OO_SDK_CPP_HOME@
+
+# Solaris only
+OO_SDK_CC_55_OR_HIGHER=@OO_SDK_CC_55_OR_HIGHER@
+
+# Directory of the Java SDK.
+# Example: OO_SDK_JAVA_HOME=/usr/jdk/jdk1.6.0_10
+OO_SDK_JAVA_HOME=@OO_SDK_JAVA_HOME@
+
+# Special output directory
+# Example: OO_SDK_OUTPUT_DIR=$HOME
+OO_SDK_OUTPUT_DIR=@OO_SDK_OUTPUT_DIR@
+
+# Environment variable to enable auto deployment of example components
+# Example: SDK_AUTO_DEPLOYMENT=YES
+SDK_AUTO_DEPLOYMENT=@SDK_AUTO_DEPLOYMENT@
+export SDK_AUTO_DEPLOYMENT
+
+# Check installation path for the OpenOffice Development Kit.
+if [ -z "${OO_SDK_HOME}" ]
+then
+ echo Error: Please insert a correct value for the variable OO_SDK_HOME.
+ exit 0
+fi
+
+export OO_SDK_HOME
+
+# Check installation path for the office.
+if [ -z "${OFFICE_HOME}" ] && [ -z "${OO_SDK_URE_HOME}" ]
+then
+ echo 'Error: Please set either the environment variable OFFICE_HOME or the'
+ echo 'environment variable OO_SDK_URE_HOME.'
+ exit 0
+fi
+
+# Get the operating system.
+sdk_platform=`${OO_SDK_HOME}/config.guess | cut -d"-" -f3,4`
+
+# Set the directory name.
+programdir=program
+javadir=bin
+case ${sdk_platform} in
+ darwin*)
+ programdir="Contents/MacOS"
+ javacdir=Commands
+ ;;
+esac
+
+# Set office program path (only set when using an Office).
+if [ "${OFFICE_HOME}" ]
+then
+ OFFICE_PROGRAM_PATH=${OFFICE_HOME}/${programdir}
+ export OFFICE_PROGRAM_PATH
+fi
+
+# Set office program path (only set when using an Office).
+if [ "${OFFICE_BASE_HOME}" ]
+then
+ OFFICE_BASE_PROGRAM_PATH=${OFFICE_BASE_HOME}/program
+ export OFFICE_BASE_PROGRAM_PATH
+fi
+
+
+# Set UNO path, necessary to ensure that the cpp examples using the
+# new UNO bootstrap mechanism use the configured office installation (only set
+# when using an Office).
+if [ "${OFFICE_HOME}" ]
+then
+ UNO_PATH=${OFFICE_PROGRAM_PATH}
+ export UNO_PATH
+fi
+
+if [ "${OO_SDK_URE_HOME}" ]
+then
+ OO_SDK_URE_BIN_DIR=${OO_SDK_URE_HOME}/bin
+ OO_SDK_URE_LIB_DIR=${OO_SDK_URE_HOME}/lib
+ OO_SDK_URE_JAVA_DIR=${OO_SDK_URE_HOME}/share/java
+else
+ OO_SDK_URE_BIN_DIR=${OFFICE_PROGRAM_PATH}
+ OO_SDK_URE_LIB_DIR=${OFFICE_BASE_PROGRAM_PATH}
+ OO_SDK_URE_JAVA_DIR=${OFFICE_BASE_PROGRAM_PATH}/classes
+fi
+export OO_SDK_URE_BIN_DIR
+export OO_SDK_URE_LIB_DIR
+export OO_SDK_URE_JAVA_DIR
+
+OO_SDK_OUT=$OO_SDK_HOME
+# Prepare appropriate output directory.
+if [ -n "${OO_SDK_OUTPUT_DIR}" ]
+then
+ OO_SDK_OUT=${OO_SDK_OUTPUT_DIR}/${OO_SDK_NAME}
+ export OO_SDK_OUT
+fi
+
+# Set the directory name.
+case ${sdk_platform} in
+ solaris*)
+ sdk_proctype=`${OO_SDK_HOME}/config.guess | cut -d"-" -f1`
+ if [ "${sdk_proctype}" = "sparc" ]
+ then
+ directoryname=solsparc
+ platform='Solaris Sparc'
+ else
+ directoryname=solintel
+ platform='Solaris x86'
+ fi
+ comid=C52
+ pltfrm=sunpro
+ soext=so
+ exampleout=SOLARISexample.out
+ stldebug=_debug
+ LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH}
+ export LD_LIBRARY_PATH
+ ;;
+
+ darwin*)
+ if [ -n "$OO_SDK_CPP_HOME" ]
+ then
+ SDK_GXX_INCLUDE_PATH=`echo "#include <cstring>" | ${OO_SDK_CPP_HOME}/g++ -E -xc++ - | sed -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1`
+ export SDK_GXX_INCLUDE_PATH
+ fi
+
+ directoryname=macosx
+ comid=gcc3
+ pltfrm=gcc
+ soext=dylib
+ exampleout=MACOSXexample.out
+ platform=MacOSX
+ stldebug=_stldebug
+ DYLD_LIBRARY_PATH=${OO_SDK_OUT}/${directoryname}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${DYLD_LIBRARY_PATH}
+ export DYLD_LIBRARY_PATH
+ ;;
+
+ linux-gnu)
+ if [ -n "$OO_SDK_CPP_HOME" ]
+ then
+ SDK_GXX_INCLUDE_PATH=`echo "#include <cstring>" | ${OO_SDK_CPP_HOME}/g++ -E -xc++ - | sed -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1`
+ export SDK_GXX_INCLUDE_PATH
+ fi
+
+ directoryname=linux
+ comid=gcc3
+ pltfrm=gcc
+ soext=so
+ exampleout=LINUXexample.out
+ platform=Linux
+ stldebug=_stldebug
+ LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH}
+ export LD_LIBRARY_PATH
+ ;;
+
+ freebsd*)
+ if [ -n "$OO_SDK_CPP_HOME" ]
+ then
+ SDK_GXX_INCLUDE_PATH=`echo "#include <cstring>" | ${OO_SDK_CPP_HOME}/g++ -E -xc++ - | sed -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1`
+ export SDK_GXX_INCLUDE_PATH
+ fi
+
+ directoryname=freebsd
+ comid=gcc3
+ pltfrm=gcc
+ soext=so
+ exampleout=FREEBSDexample.out
+ platform=FreeBSD
+ stldebug=_stldebug
+ LD_LIBRARY_PATH=${OO_SDK_HOME}/lib:${OO_SDK_OUT}/${exampleout}/lib:${OO_SDK_URE_LIB_DIR}:.:${LD_LIBRARY_PATH}
+ export LD_LIBRARY_PATH
+
+ if [ -e "/sbin/sysctl" ]
+ then
+ OSVERSION=`/sbin/sysctl -n kern.osreldate`
+ else
+ OSVERSION=`/usr/sbin/sysctl -n kern.osreldate`
+ fi
+ if [ $OSVERSION -lt 500016 ]
+ then
+ PTHREAD_CFLAGS=-D_THREAD_SAFE
+ PTHREAD_LIBS=-pthread
+ export PTHREAD_CFLAGS
+ export PTHREAD_LIBS
+ elif [ $OSVERSION -lt 502102 ]
+ then
+ PTHREAD_CFLAGS=-D_THREAD_SAFE
+ PTHREAD_LIBS=-lc_r
+ export PTHREAD_CFLAGS
+ export PTHREAD_LIBS
+ else
+ PTHREAD_LIBS=-pthread
+ export PTHREAD_LIBS
+ fi
+ ;;
+esac
+
+# Add directory of the SDK tools to the path.
+PATH=${OO_SDK_HOME}/bin:${OO_SDK_OUT}/${exampleout}/bin:${OO_SDK_URE_BIN_DIR}:${OFFICE_PROGRAM_PATH}:.:${PATH}
+
+# Set the classpath
+CLASSPATH=${OO_SDK_URE_JAVA_DIR}/juh.jar:${OO_SDK_URE_JAVA_DIR}/jurt.jar:${OO_SDK_URE_JAVA_DIR}/ridl.jar:${OO_SDK_URE_JAVA_DIR}/unoloader.jar:${OFFICE_BASE_PROGRAM_PATH}/classes/unoil.jar:${CLASSPATH}
+export CLASSPATH
+
+
+# Add directory of the command make to the path, if necessary.
+if [ -n "${OO_SDK_MAKE_HOME}" ]
+then
+ PATH=${OO_SDK_MAKE_HOME}:${PATH}
+ export OO_SDK_MAKE_HOME
+fi
+
+# Add directory of the zip tool to the path, if necessary.
+if [ -n "${OO_SDK_ZIP_HOME}" ]
+then
+ PATH=${OO_SDK_ZIP_HOME}:${PATH}
+ export OO_SDK_ZIP_HOME
+fi
+
+# Add directory of the C++ tools to the path, if necessary.
+if [ -n "${OO_SDK_CPP_HOME}" ]
+then
+ PATH=${OO_SDK_CPP_HOME}:${PATH}
+ export OO_SDK_CPP_HOME
+
+ if [ -n "${OO_SDK_CC_55_OR_HIGHER}" ]
+ then
+ export OO_SDK_CC_55_OR_HIGHER
+ fi
+fi
+
+# Add directory of the Java tools to the path, if necessary.
+if [ -n "${OO_SDK_JAVA_HOME}" ]
+then
+ PATH=${OO_SDK_JAVA_HOME}/${javadir}:${PATH}
+# JAVA_HOME=${OO_SDK_JAVA_HOME}
+# export JAVA_HOME
+ export OO_SDK_JAVA_HOME
+
+ export PATH
+fi
+
+export PATH
+
+if [ -r "${OO_SDK_URE_LIB_DIR}/libstlport_${pltfrm}${stldebug}.${soext}" ]
+then
+ STLDEBUG=${stldebug}
+ export STLDEBUG
+fi
+
+if [ "${platform}" = "MacOSX" ]
+then
+# For URE, prepare symbolic links for libraries:
+# Only necessary on MacOSX, on other Unix systems the links are already prepared
+# in the SDK installation.
+
+# cleanup potential old links first
+ rm -f "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppu.${soext}" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppuhelper${comid}.${soext}" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_sal.${soext}" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_salhelper${comid}.${soext}" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_purpenvhelper${comid}.${soext}"
+
+ if [ -L "${OO_SDK_OUT}/${directoryname}/lib/libstlport_${pltfrm}${STLDEBUG}.${soext}" ]
+ then
+ rm -rf "${OO_SDK_OUT}/${directoryname}/lib/libstlport_${pltfrm}${STLDEBUG}.${soext}"
+ fi
+
+# prepare links
+ if [ "${OO_SDK_URE_HOME}" ]
+ then
+ mkdir -p "${OO_SDK_OUT}/${directoryname}/lib"
+ ln -s "${OO_SDK_URE_LIB_DIR}/libuno_cppu.${soext}.3" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppu.${soext}"
+ ln -s "${OO_SDK_URE_LIB_DIR}/libuno_cppuhelper${comid}.${soext}.3" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_cppuhelper${comid}.${soext}"
+ ln -s "${OO_SDK_URE_LIB_DIR}/libuno_sal.${soext}.3" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_sal.${soext}"
+ ln -s "${OO_SDK_URE_LIB_DIR}/libuno_salhelper${comid}.${soext}.3" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_salhelper${comid}.${soext}"
+ ln -s "${OO_SDK_URE_LIB_DIR}/libuno_purpenvhelper${comid}.${soext}.3" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libuno_purpenvhelper${comid}.${soext}"
+
+ if [ -r "${OO_SDK_URE_LIB_DIR}/libstlport_${pltfrm}${STLDEBUG}.${soext}" ]
+ then
+ ln -s "${OO_SDK_URE_LIB_DIR}/libstlport_${pltfrm}${STLDEBUG}.${soext}" \
+ "${OO_SDK_OUT}/${directoryname}/lib/libstlport_${pltfrm}${STLDEBUG}.${soext}"
+ fi
+ fi
+fi
+
+
+# Prepare shell with all necessary environment variables.
+echo
+echo " ************************************************************************"
+echo " *"
+echo " * SDK environment is prepared for ${platform}"
+echo " *"
+echo " * SDK = $OO_SDK_HOME"
+echo " * Office = $OFFICE_HOME"
+echo " * Office Base = $OFFICE_BASE_HOME"
+echo " * URE = $OO_SDK_URE_HOME"
+echo " * Make = $OO_SDK_MAKE_HOME"
+echo " * Zip = $OO_SDK_ZIP_HOME"
+echo " * C++ Compiler = $OO_SDK_CPP_HOME"
+echo " * Java = $OO_SDK_JAVA_HOME"
+echo " * SDK Output directory = $OO_SDK_OUT"
+echo " * Auto deployment = $SDK_AUTO_DEPLOYMENT"
+echo " *"
+echo " ************************************************************************"
+
+echo "]2;Shell prepared with the SDK environment"
+
diff --git a/odk/setsdkenv_windows.bat b/odk/setsdkenv_windows.bat
new file mode 100755
index 000000000000..a6b7ea75d572
--- /dev/null
+++ b/odk/setsdkenv_windows.bat
@@ -0,0 +1,64 @@
+@echo off
+
+set SDK_DIR_TMP=%~dp0
+set SDK_DIR=%SDK_DIR_TMP:~0,-1%
+
+if "%@RIGHT[5,%SDK_DIR%]" EQU "~0,-1" (
+ set SDK_DIR=%@FULL[%0]
+ set /A LENGTH=%@LEN[%SDK_DIR%] - 22
+ set SDK_DIR=%@LEFT[%LENGTH%,%SDK_DIR%]
+ unset LENGTH
+)
+
+set OO_SDK_NAME=__SDKNAME__
+
+set OO_USER_SDK_DIR=%APPDATA%\%OO_SDK_NAME%
+set OO_USER_SDKENV_SCRIPT=%OO_USER_SDK_DIR%\setsdkenv_windows.bat
+
+if "%1" EQU "--force-configure" (
+ if exist "%OO_USER_ENV_SCRIPT%". (
+ del "%OO_USER_SDKENV_SCRIPT%"
+ )
+ goto start
+)
+
+if "%1" EQU "-h" goto printhelp
+if "%1" EQU "--help" goto printhelp
+if "%1" NEQ "" goto printhelp
+
+:start
+cls
+
+if not exist "%OO_USER_SDKENV_SCRIPT%". (
+ echo.
+ echo ******************************************************************
+ echo *
+ echo * You have to configure your SDK environment first before you can
+ echo * can use it! The configuration has to be done only once.
+ echo *
+ echo ******************************************************************
+ echo.
+
+ cscript //I //Nologo "%SDK_DIR%\cfgWin.js"
+ goto setenv
+)
+
+goto setenv
+
+:printhelp
+echo.
+echo using: setsdkenv_windows.bat [options]
+echo.
+echo options:
+echo --force-configure : force a new configuration of your SDK environment.
+echo Alternatively can you edit your SDK environment script directly:
+echo "%OO_USER_SDKENV_SCRIPT%"
+echo -h, --help : print this help and exit
+echo.
+goto end
+
+
+:setenv
+call "%OO_USER_SDKENV_SCRIPT%"
+
+:end \ No newline at end of file
diff --git a/odk/setsdkenv_windows.template b/odk/setsdkenv_windows.template
new file mode 100755
index 000000000000..41effdfcdbf3
--- /dev/null
+++ b/odk/setsdkenv_windows.template
@@ -0,0 +1,183 @@
+@echo off
+REM This script sets all enviroment variables, which
+REM are necessary for building the examples of the Office Development Kit.
+REM The Script was developed for the operating systems Windows.
+REM The SDK name
+REM Example: set OO_SDK_NAME=openoffice3.0_sdk
+set OO_SDK_NAME=openoffice.org3.0_sdk
+
+REM Installation directory of the Software Development Kit.
+REM Example: set OO_SDK_HOME=C:\Program Files\OpenOffice.org\Basic 3.0\sdk
+set OO_SDK_HOME=
+
+REM Office installation directory.
+REM Example: set OFFICE_HOME=C:\Program Files\OpenOffice.org 3
+set OFFICE_HOME=
+
+REM Example: set OFFICE_HOME=C:\Program Files\OpenOffice.org\Basis 3.0
+set OFFICE_BASE_HOME=
+
+REM URE installation directory.
+REM Example: set OO_SDK_URE_HOME=C:\Program Files\OpenOffice.org\URE
+set OO_SDK_URE_HOME=
+
+REM Directory of the make command.
+REM Example: set OO_SDK_MAKE_HOME=D:\NextGenerationMake\make
+set OO_SDK_MAKE_HOME=
+
+REM Directory of the zip tool.
+REM Example: set OO_SDK_ZIP_HOME=D:\infozip\bin
+set OO_SDK_ZIP_HOME=
+
+REM Directory of the C++ compiler.
+REM Example:set OO_SDK_CPP_HOME=C:\Program Files\Microsoft Visual Studio 9.0\VC\bin
+REM Example:set CPP_WINDOWS_SDK=C:\Program Files\\Microsoft SDKs\Windows\v6.0A\
+set OO_SDK_CPP_HOME=
+set CPP_VC8=
+set CPP_WINDOWS_SDK=
+
+REM Directory of the C# and VB.NET compilers.
+REM Example:set OO_SDK_CLI_HOME=C:\WINXP\Microsoft.NET\Framework\v1.0.3705
+set OO_SDK_CLI_HOME=
+
+REM Java SDK installation directory.
+REM Example: set OO_SDK_JAVA_HOME=C:\Program Files\Java\jdk1.6.0_05
+set OO_SDK_JAVA_HOME=
+
+REM Special output directory
+REM Example: set OO_SDK_OUT=C:\openoffice.org3.0_sdk
+set OO_SDK_OUT=
+
+REM Automatic deployment
+REM Example: set SDK_AUTO_DEPLOYMENT=YES
+set SDK_AUTO_DEPLOYMENT=YES
+
+set STLDEBUG=
+REM check stlport lib in 4NT shell
+REM if exist "%OO_SDK_HOME%\windows\lib\stlport_vc71_stldebug.lib". (
+REM set STLDEBUG=_stldebug
+REM )
+
+REM Check installation path for the StarOffice Development Kit.
+if not defined OO_SDK_HOME (
+ echo Error: the variable OO_SDK_HOME is missing!
+ goto :error
+ )
+
+REM Check installation path for the office.
+REM if not defined OFFICE_HOME (
+REM if not defined OO_SDK_URE_HOME (
+REM echo Error: either of the variables OFFICE_HOME and
+REM echo OO_SDK_URE_HOME is missing!
+REM goto :error
+REM )
+REM )
+
+REM Check installation path for GNU make.
+if not defined OO_SDK_MAKE_HOME (
+ echo Error: the variable OO_SDK_MAKE_HOME is missing!
+ goto :error
+ )
+
+REM Check installation path for the zip tool.
+if not defined OO_SDK_ZIP_HOME (
+ echo Error: the variable OO_SDK_ZIP_HOME is missing!
+ goto :error
+ )
+
+REM Set library path.
+set LIB=%OO_SDK_HOME%\lib;%LIB%
+if defined CPP_WINDOWS_SDK (
+ set LIB=%LIB%;%CPP_WINDOWS_SDK%\lib
+ )
+
+REM Set office program path.
+if defined OFFICE_HOME (
+ set OFFICE_PROGRAM_PATH=%OFFICE_HOME%\program
+ )
+
+REM Set office program path.
+if defined OFFICE_BASE_HOME (
+ set OFFICE_BASE_PROGRAM_PATH=%OFFICE_BASE_HOME%\program
+ )
+
+REM Set UNO path, necessary to ensure that the cpp examples using the
+REM new UNO bootstrap mechanism use the configured office installation
+REM (only set when using an Office).
+if defined OFFICE_HOME (
+ set UNO_PATH=%OFFICE_PROGRAM_PATH%
+ )
+
+REM if defined OO_SDK_URE_HOME (
+set OO_SDK_URE_BIN_DIR=%OO_SDK_URE_HOME%\bin
+set OO_SDK_URE_LIB_DIR=%OO_SDK_URE_HOME%\bin
+set OO_SDK_URE_JAVA_DIR=%OO_SDK_URE_HOME%\java
+REM ) else (
+set OO_SDK_OFFICE_BIN_DIR=%OFFICE_PROGRAM_PATH%
+set OO_SDK_OFFICE_LIB_DIR=%OFFICE_BASE_PROGRAM_PATH%
+set OO_SDK_OFFICE_JAVA_DIR=%OFFICE_BASE_PROGRAM_PATH%\classes
+REM )
+
+REM Set classpath
+set CLASSPATH=%OO_SDK_URE_JAVA_DIR%\juh.jar;%OO_SDK_URE_JAVA_DIR%\jurt.jar;%OO_SDK_URE_JAVA_DIR%\ridl.jar;%OO_SDK_URE_JAVA_DIR%\unoloader.jar;%OO_SDK_OFFICE_JAVA_DIR%\unoil.jar
+REM if defined OFFICE_HOME (
+REM set CLASSPATH=%CLASSPATH%;%OO_SDK_OFFICE_JAVA_DIR%\unoil.jar
+REM )
+
+REM Add directory of the SDK tools to the path.
+set PATH=%OO_SDK_HOME%\bin;%OO_SDK_URE_BIN_DIR%;%OO_SDK_OFFICE_BIN_DIR%;%OO_SDK_HOME%\WINexample.out\bin;%PATH%
+
+REM Set PATH appropriate to the output directory
+if defined OO_SDK_OUT (
+ set PATH=%OO_SDK_OUT%\WINexample.out\bin;%PATH%
+ ) else (
+ set PATH=%OO_SDK_HOME%\WINexample.out\bin;%PATH%
+ )
+
+REM Add directory of the command make to the path, if necessary.
+if defined OO_SDK_MAKE_HOME set PATH=%OO_SDK_MAKE_HOME%;%PATH%
+
+REM Add directory of the zip tool to the path, if necessary.
+if defined OO_SDK_ZIP_HOME set PATH=%OO_SDK_ZIP_HOME%;%PATH%
+
+REM Add directory of the C++ compiler to the path, if necessary.
+if defined OO_SDK_CPP_HOME set PATH=%OO_SDK_CPP_HOME%;%PATH%
+
+REM Add directory of the C# and VB.NET compilers to the path, if necessary.
+if defined OO_SDK_CLI_HOME set PATH=%OO_SDK_CLI_HOME%;%PATH%
+
+REM Add directory of the Java tools to the path, if necessary.
+if defined OO_SDK_JAVA_HOME set PATH=%OO_SDK_JAVA_HOME%\bin;%OO_SDK_JAVA_HOME%\jre\bin;%PATH%
+
+REM Set environment for C++ compiler tools, if necessary.
+if defined OO_SDK_CPP_HOME call "%OO_SDK_CPP_HOME%\VCVARS32.bat"
+
+REM Set tilte to identify the prepared shell.
+title Shell prepared for SDK
+
+REM Prepare shell with all necessary environment variables.
+echo.
+echo ******************************************************************
+echo *
+echo * SDK environment is prepared for Windows
+echo *
+echo * SDK = %OO_SDK_HOME%
+echo * Office = %OFFICE_HOME%
+echo * Office Base = %OFFICE_BASE_HOME%
+echo * URE = %OO_SDK_URE_HOME%
+echo * Make = %OO_SDK_MAKE_HOME%
+echo * Zip = %OO_SDK_ZIP_HOME%
+echo * C++ Compiler = %OO_SDK_CPP_HOME%
+echo * C# and VB.NET compilers = %OO_SDK_CLI_HOME%
+echo * Java = %OO_SDK_JAVA_HOME%
+echo * Special Output directory = %OO_SDK_OUT%
+echo * Auto deployment = %SDK_AUTO_DEPLOYMENT%
+echo *
+echo ******************************************************************
+echo.
+goto end
+
+ :error
+Error: Please insert the necessary environment variables into the batch file.
+
+ :end
diff --git a/odk/setsdkname.bat b/odk/setsdkname.bat
new file mode 100755
index 000000000000..2404708147d6
--- /dev/null
+++ b/odk/setsdkname.bat
@@ -0,0 +1,3 @@
+@echo off
+
+set OO_SDK_NAME=%~n1
diff --git a/odk/settings/component.uno.def b/odk/settings/component.uno.def
new file mode 100644
index 000000000000..72a4eb2fa96d
--- /dev/null
+++ b/odk/settings/component.uno.def
@@ -0,0 +1,4 @@
+EXPORTS
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/odk/settings/settings.mk b/odk/settings/settings.mk
new file mode 100644
index 000000000000..188ff880255e
--- /dev/null
+++ b/odk/settings/settings.mk
@@ -0,0 +1,607 @@
+# Global settings file for the minimal build environment of the SDK
+# This file have to updated/extended for other platforms.
+
+# test for the platform
+PLATFORM := $(shell $(PRJ)/config.guess | cut -d"-" -f3,4)
+
+# config.guess is missing for windows. We rely on getting "" in this case.
+ifeq "$(PLATFORM)" ""
+PLATFORM = windows
+endif
+
+# debug option, default is no debug
+DEBUG=no
+ifeq "$(MAKECMDGOALS)" "debug"
+DEBUG=yes
+endif
+
+###########################################################################
+#
+# Java settings
+#
+###########################################################################
+JAVAC_FLAGS=
+
+ifeq "$(DEBUG)" "yes"
+JAVAC_FLAGS+=-g
+endif
+
+JAVABIN=bin
+
+###########################################################################
+#
+# Windows specific settings
+#
+###########################################################################
+ifeq "$(PLATFORM)" "windows"
+# Settings for Windows using Microsoft compiler/linker
+
+OS=WIN
+PS=\\
+ICL=$$
+CC=cl
+LINK=link
+BUILDLIB=lib
+ECHO=@echo
+MKDIR=mkdir
+MV=move
+CAT=type
+OBJ_EXT=obj
+EXE_EXT=.exe
+COPY=copy
+SHAREDLIB_EXT=dll
+SHAREDLIB_OUT=$(OUT_BIN)
+PACKAGE_LIB_DIR=windows.plt
+UNOPKG_PLATFORM=Windows
+
+OSEP=^<
+CSEP=^>
+QUOTE=
+QM=
+SQM=
+ECHOLINE=@echo.
+P2BG=
+
+DEL=del
+DELRECURSIVE=rd /S /Q
+URLPREFIX=file:///
+
+SALLIB=isal.lib
+CPPULIB=icppu.lib
+CPPUHELPERLIB=icppuhelper.lib
+SALHELPERLIB=isalhelper.lib
+REGLIB=ireg.lib
+STORELIB=istore.lib
+STLPORTLIB=stlport_vc71$(STLDEBUG).lib
+
+BLANK=
+EMPTYSTRING=
+PATH_SEPARATOR=;
+
+# use this for release version
+CC_FLAGS=-c -MT -Zm500 -Zc:forScope,wchar_t- -wd4251 -wd4275 -wd4290 -wd4675 -wd4786 -wd4800 -Zc:forScope -GR -EHa
+ifeq "$(CPP_MANIFEST)" "true"
+#CC_FLAGS+=-EHa -Zc:wchar_t-
+LINK_MANIFEST=mt -manifest $@.manifest "-outputresource:$@;2"
+else
+#CC_FLAGS+=
+LINK_MANIFEST=
+endif
+ifeq "$(DEBUG)" "yes"
+CC_FLAGS+=-Zi
+endif
+
+CC_INCLUDES=-I. -I$(OUT)/inc -I$(OUT)/inc/examples -I$(PRJ)/include
+STL_INCLUDES=-I"$(OO_SDK_HOME)/include/stl"
+SDK_JAVA_INCLUDES = -I"$(OO_SDK_JAVA_HOME)/include" -I"$(OO_SDK_JAVA_HOME)/include/win32"
+
+# define for used compiler necessary for UNO
+# -DCPPU_ENV=msci -- windows msvc 4.x - 7.x
+
+CC_DEFINES=-DWIN32 -DWNT -D_DLL -DCPPU_ENV=msci
+CC_OUTPUT_SWITCH=-Fo
+
+LIBRARY_LINK_FLAGS=/NODEFAULTLIB /DLL /DEBUGTYPE:cv
+COMP_LINK_FLAGS=$(LIBRARY_LINK_FLAGS) /DEF:$(PRJ)/settings/component.uno.def
+EXE_LINK_FLAGS=/MAP /OPT:NOREF /SUBSYSTEM:CONSOLE /BASE:0x1b000000 /DEBUGTYPE:cv /NODEFAULTLIB msvcrt.lib kernel32.lib
+ifeq "$(DEBUG)" "yes"
+LIBRARY_LINK_FLAGS+=/DEBUG
+EXE_LINK_FLAGS+=/DEBUG
+endif
+
+LINK_JAVA_LIBS=/LIBPATH:"$(OO_SDK_JAVA_HOME)/lib"
+
+ifneq "$(OO_SDK_URE_HOME)" ""
+URE_MISC=$(OO_SDK_URE_HOME)\misc
+endif
+
+# use this for release version
+#EXE_LINK_FLAGS=/MAP /OPT:NOREF /SUBSYSTEM:CONSOLE /BASE:0x1100000
+#LIBRARY_LINK_FLAGS=/NODEFAULTLIB /DLL
+endif
+
+
+
+###########################################################################
+#
+# Solaris specific settings
+#
+###########################################################################
+ifneq (,$(findstring solaris,$(PLATFORM)))
+# Settings for Solaris using Sun Workshop compiler
+
+PROCTYPE := $(shell $(PRJ)/config.guess | cut -d"-" -f1)$(shell /usr/ccs/bin/elfdump -e "$(OO_SDK_URE_HOME)/lib/libuno_sal.so.3" | /usr/xpg4/bin/grep -q -w ELFCLASS64 && echo 64)
+
+ifeq "$(PROCTYPE)" "sparc"
+PLATFORM=solsparc
+PACKAGE_LIB_DIR=solaris_sparc.plt
+UNOPKG_PLATFORM=Solaris_SPARC
+JAVA_PROC_TYPE=sparc
+else
+ifeq "$(PROCTYPE)" "sparc64"
+PLATFORM=solsparc
+PACKAGE_LIB_DIR=solaris_sparc64.plt
+UNOPKG_PLATFORM=Solaris_SPARC64
+JAVA_PROC_TYPE=sparcv9
+else
+PLATFORM=solintel
+PACKAGE_LIB_DIR=solaris_x86.plt
+UNOPKG_PLATFORM=Solaris_x86
+JAVA_PROC_TYPE=i386
+endif
+endif
+
+OS=SOLARIS
+PS=/
+ICL=\$$
+CC=CC
+LINK=CC
+LIB=CC
+ECHO=@echo
+MKDIR=mkdir -p
+CAT=cat
+OBJ_EXT=o
+SHAREDLIB_EXT=so
+SHAREDLIB_PRE=lib
+SHAREDLIB_OUT=$(OUT_LIB)
+
+OSEP=\<
+CSEP=\>
+QUOTE=$(subst S,\,S)
+QM=\"
+SQM='
+ECHOLINE=@echo
+P2BG=&
+
+DEL=rm -f
+DELRECURSIVE=rm -rf
+COPY=cp
+URLPREFIX=file://
+
+# Include UDK version numbers
+include $(PRJ)/include/udkversion.mk
+
+SALLIB=-luno_sal
+CPPULIB=-luno_cppu
+CPPUHELPERLIB=-luno_cppuhelperC52
+SALHELPERLIB=-luno_salhelperC52
+REGLIB=-lreg
+STORELIB=-lstore
+ifeq "$(PROCTYPE)" "sparc64"
+STLPORTLIB=-library=stlport4
+else
+STLPORTLIB=-lstlport_sunpro$(STLDEBUG)
+endif
+
+EMPTYSTRING=
+PATH_SEPARATOR=:
+
+CC_FLAGS=-c -KPIC
+ifeq "$(DEBUG)" "yes"
+CC_FLAGS+=-g
+endif
+CC_INCLUDES=-I. -I$(OUT)/inc -I$(OUT)/inc/examples -I$(PRJ)/include
+STL_INCLUDES=-I"$(OO_SDK_HOME)/include/stl"
+SDK_JAVA_INCLUDES = -I"$(OO_SDK_JAVA_HOME)/include" -I"$(OO_SDK_JAVA_HOME)/include/solaris"
+
+# define for used compiler necessary for UNO
+# -DCPPU_ENV=sunpro5 -- sunpro cc 5.x solaris sparc/intel
+
+CC_DEFINES=-DUNX -DSOLARIS -DSPARC -DCPPU_ENV=sunpro5
+CC_OUTPUT_SWITCH=-o
+
+LIBRARY_LINK_FLAGS=-w -mt -z combreloc -PIC -temp=/tmp '-R $$ORIGIN' -z text -norunpath -G -Bdirect -Bdynamic -lpthread -lCrun -lc -lm
+# means if used CC is lower then version 5.5 use option -instance=static
+ifeq ($(OO_SDK_CC_55_OR_HIGHER),)
+LIBRARY_LINK_FLAGS+=-instances=static
+endif
+COMP_LINK_FLAGS=$(LIBRARY_LINK_FLAGS) -M $(PRJ)/settings/component.uno.map
+
+EXE_LINK_FLAGS=-w -mt -z combreloc -PIC -temp=/tmp -norunpath -Bdirect -z defs
+LINK_LIBS=-L"$(OUT)/lib" -L"$(OO_SDK_HOME)/lib" -L"$(OO_SDK_URE_LIB_DIR)"
+LINK_JAVA_LIBS=-L"$(OO_SDK_JAVA_HOME)/jre/lib/$(JAVA_PROC_TYPE)"
+
+ifeq "$(PROCTYPE)" "sparc64"
+CC_FLAGS+=-m64
+LIBRARY_LINK_FLAGS+=-m64
+EXE_LINK_FLAGS+=-m64
+endif
+
+ifneq "$(OO_SDK_URE_HOME)" ""
+URE_MISC=$(OO_SDK_URE_HOME)/share/misc
+endif
+
+endif
+
+
+
+###########################################################################
+#
+# Linux specific settings
+#
+###########################################################################
+ifneq (,$(findstring linux,$(PLATFORM)))
+# Settings for Linux using gcc compiler
+
+PROCTYPE := $(shell $(PRJ)/config.guess | cut -d "-" -f1 | sed -e 's/^i.86$$/i386/')
+PLATFORM=linux
+
+PACKAGE_LIB_DIR=linux_$(PROCTYPE).plt
+UNOPKG_PLATFORM=Linux_$(PROCTYPE)
+JAVA_PROC_TYPE=$(PROCTYPE)
+STLPORT=no
+
+ifeq "$(PROCTYPE)" "i386"
+PACKAGE_LIB_DIR=linux_x86.plt
+UNOPKG_PLATFORM=Linux_x86
+JAVA_PROC_TYPE=i386
+STLPORT=yes
+endif
+
+ifeq "$(PROCTYPE)" "powerpc"
+PACKAGE_LIB_DIR=linux_powerpc.plt
+UNOPKG_PLATFORM=Linux_PowerPC
+JAVA_PROC_TYPE=ppc
+STLPORT=yes
+endif
+
+ifeq "$(PROCTYPE)" "sparc"
+PACKAGE_LIB_DIR=linux_sparc.plt
+UNOPKG_PLATFORM=Linux_SPARC
+JAVA_PROC_TYPE=sparc
+STLPORT=yes
+endif
+
+ifeq "$(PROCTYPE)" "x86_64"
+JAVA_PROC_TYPE=amd64
+endif
+
+ifeq "$(PROCTYPE)" "powerpc64"
+JAVA_PROC_TYPE=ppc64
+endif
+
+OS=LINUX
+PS=/
+ICL=\$$
+CC=gcc
+LINK=g++
+LIB=g++
+ECHO=@echo
+MKDIR=mkdir -p
+CAT=cat
+OBJ_EXT=o
+SHAREDLIB_EXT=so
+SHAREDLIB_PRE=lib
+SHAREDLIB_OUT=$(OUT_LIB)
+
+GCC_VERSION=$(shell $(CC) -dumpversion)
+
+COMID=gcc3
+CPPU_ENV=gcc3
+
+OSEP=\<
+CSEP=\>
+QUOTE=$(subst S,\,S)
+QM=\"
+SQM='
+ECHOLINE=@echo
+P2BG=&
+
+DEL=rm -f
+DELRECURSIVE=rm -rf
+COPY=cp
+URLPREFIX=file://
+
+# Include UDK version numbers
+include $(PRJ)/include/udkversion.mk
+
+SALLIB=-luno_sal
+CPPULIB=-luno_cppu
+CPPUHELPERLIB=-luno_cppuhelper$(COMID)
+SALHELPERLIB=-luno_salhelper$(COMID)
+REGLIB=-lreg
+STORELIB=-lstore
+ifeq "$(STLPORT)" "yes"
+ifeq "$(STLPORT_VER)" "500"
+STLPORTLIB=-lstlport
+else
+STLPORTLIB=-lstlport_gcc$(STLDEBUG)
+endif
+else
+STLPORTLIB=
+endif
+
+EMPTYSTRING=
+PATH_SEPARATOR=:
+
+# -O is necessary for inlining (see gcc documentation)
+ifeq "$(DEBUG)" "yes"
+CC_FLAGS=-c -g -fpic
+else
+CC_FLAGS=-c -O -fpic
+endif
+
+ifeq "$(PROCTYPE)" "ppc"
+CC_FLAGS+=-fPIC
+endif
+
+SDK_JAVA_INCLUDES = -I"$(OO_SDK_JAVA_HOME)/include" -I"$(OO_SDK_JAVA_HOME)/include/linux"
+CC_INCLUDES=-I. -I$(OUT)/inc -I$(OUT)/inc/examples -I$(PRJ)/include
+STL_INCLUDES=-I"$(OO_SDK_HOME)/include/stl"
+CC_DEFINES=-DUNX -DGCC -DLINUX -DCPPU_ENV=$(CPPU_ENV) -DGXX_INCLUDE_PATH=$(SDK_GXX_INCLUDE_PATH)
+
+# define for used compiler necessary for UNO
+#-DCPPU_ENV=gcc2 -- gcc 2.91/2.95
+#-DCPPU_ENV=gcc3 -- gcc3 3.0
+
+CC_OUTPUT_SWITCH=-o
+
+LIBRARY_LINK_FLAGS=-shared '-Wl,-rpath,$$ORIGIN'
+
+ifeq "$(PROCTYPE)" "ppc"
+LIBRARY_LINK_FLAGS+=-fPIC
+endif
+COMP_LINK_FLAGS=$(LIBRARY_LINK_FLAGS) -Wl,--version-script,$(PRJ)/settings/component.uno.map
+
+#EXE_LINK_FLAGS=-Wl,--allow-shlib-undefined -Wl,-export-dynamic -Wl,-z,defs -Wl,--whole-archive -lsalcpprt -Wl,--no-whole-archive
+EXE_LINK_FLAGS=-Wl,--allow-shlib-undefined -Wl,-export-dynamic -Wl,-z,defs -Wl,--no-whole-archive
+LINK_LIBS=-L"$(OUT)/lib" -L"$(OO_SDK_HOME)/lib" -L"$(OO_SDK_URE_LIB_DIR)"
+LINK_JAVA_LIBS=-L"$(OO_SDK_JAVA_HOME)/jre/lib/$(JAVA_PROC_TYPE)"
+
+ifneq "$(OO_SDK_URE_HOME)" ""
+URE_MISC=$(OO_SDK_URE_HOME)/share/misc
+endif
+
+endif
+
+###########################################################################
+#
+# MacOSX/Darwin specific settings
+#
+###########################################################################
+ifneq (,$(findstring darwin,$(PLATFORM)))
+# Settings for MacOSX using gcc 4.0.1 compiler
+
+PROCTYPE := $(shell $(PRJ)/config.guess | cut -d"-" -f1)
+
+# Default is MacOSX on a Intel machine
+PLATFORM=macosx
+
+ifeq "$(PROCTYPE)" "i686"
+PACKAGE_LIB_DIR=macosx_x86.plt
+UNOPKG_PLATFORM=MacOSX_x86
+JAVA_PROC_TYPE=x86
+else
+PACKAGE_LIB_DIR=macosx_ppc.plt
+UNOPKG_PLATFORM=MacOSX_PowerPC
+JAVA_PROC_TYPE=ppc
+endif
+JAVABIN=Commands
+
+GCC_VERSION =$(shell gcc -dumpversion| cut -d"." -f1,2)
+ifeq "$(GCC_VERSION)" "4.2"
+GCC_ARCH_OPTION=-arch i386
+endif
+
+OS=MACOSX
+PS=/
+ICL=\$$
+CC=gcc-$(GCC_VERSION)
+LINK=g++-$(GCC_VERSION)
+LIB=g++-$(GCC_VERSION)
+ECHO=@echo
+MKDIR=mkdir -p
+CAT=cat
+OBJ_EXT=o
+SHAREDLIB_EXT=dylib
+SHAREDLIB_PRE=lib
+SHAREDLIB_OUT=$(OUT_LIB)
+
+COMID=gcc3
+CPPU_ENV=gcc3
+
+OSEP=\<
+CSEP=\>
+QUOTE=$(subst S,\,S)
+QM=\"
+SQM='
+ECHOLINE=@echo
+P2BG=&
+
+DEL=rm -f
+DELRECURSIVE=rm -rf
+COPY=cp
+URLPREFIX=file://
+
+# Include UDK version numbers
+include $(PRJ)/include/udkversion.mk
+
+SALLIB=-luno_sal
+CPPULIB=-luno_cppu
+CPPUHELPERLIB=-luno_cppuhelper$(COMID)
+SALHELPERLIB=-luno_salhelper$(COMID)
+REGLIB=-lreg
+STORELIB=-lstore
+
+SALDYLIB=-Wl,-dylib_file,@__________________________________________________URELIB/libuno_sal.dylib.3:'$(OO_SDK_URE_LIB_DIR)/libuno_sal.dylib'
+CPPUDYLIB=-Wl,-dylib_file,@__________________________________________________URELIB/libuno_cppu.dylib.3:'$(OO_SDK_URE_LIB_DIR)/libuno_cppu.dylib'
+CPPUHELPERDYLIB=-Wl,-dylib_file,@__________________________________________________URELIB/libuno_cppuhelper'$(COMID).dylib.3:$(OO_SDK_URE_LIB_DIR)/libuno_cppuhelper$(COMID).dylib'
+SALHELPERDYLIB=-Wl,-dylib_file,@__________________________________________________URELIB/libuno_salhelper$(COMID).dylib.3:'$(OO_SDK_URE_LIB_DIR)/libuno_salhelper$(COMID).dylib'
+REGDYLIB=-Wl,-dylib_file,@__________________________________________________URELIB/libreg.dylib.3:'$(OO_SDK_URE_LIB_DIR)/libreg.dylib'
+STOREDYLIB=-Wl,-dylib_file,@__________________________________________________URELIB/libstore.dylib.3:'$(OO_SDK_URE_LIB_DIR)/libstore.dylib'
+
+INSTALL_NAME_URELIBS=install_name_tool -change @__________________________________________________URELIB/libuno_sal.dylib.3 @executable_path/urelibs/libuno_sal.dylib.3 -change @__________________________________________________URELIB/libuno_cppu.dylib.3 @executable_path/urelibs/libuno_cppu.dylib.3 -change @__________________________________________________URELIB/libuno_cppuhelper$(COMID).dylib.3 @executable_path/urelibs/libuno_cppuhelper$(COMID).dylib.3 -change @__________________________________________________URELIB/libuno_salhelper$(COMID).dylib.3 @executable_path/urelibs/libuno_salhelper$(COMID).dylib.3 -change @__________________________________________________URELIB/libreg.dylib.3 @executable_path/urelibs/libreg.dylib.3 -change @__________________________________________________URELIB/libstore.dylib.3 @executable_path/urelibs/libstore.dylib.3
+
+INSTALL_NAME_URELIBS_BIN=install_name_tool -change @__________________________________________________URELIB/libuno_sal.dylib.3 libuno_sal.dylib.3 -change @__________________________________________________URELIB/libuno_cppu.dylib.3 libuno_cppu.dylib.3 -change @__________________________________________________URELIB/libuno_cppuhelper$(COMID).dylib.3 libuno_cppuhelper$(COMID).dylib.3 -change @__________________________________________________URELIB/libuno_salhelper$(COMID).dylib.3 libuno_salhelper$(COMID).dylib.3 -change @__________________________________________________URELIB/libreg.dylib.3 libreg.dylib.3 -change @__________________________________________________URELIB/libstore.dylib.3 libstore.dylib.3
+
+EMPTYSTRING=
+PATH_SEPARATOR=:
+
+# -O is necessary for inlining (see gcc documentation)
+ifeq "$(DEBUG)" "yes"
+CC_FLAGS=-malign-natural -c -g -fPIC -fno-common $(GCC_ARCH_OPTION)
+else
+CC_FLAGS=-malign-natural -c -O -fPIC -fno-common $(GCC_ARCH_OPTION)
+endif
+
+SDK_JAVA_INCLUDES = -I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers -I/System/Library/Frameworks/JavaVM.framework/Headers
+CC_INCLUDES=-I. -I$(OUT)/inc -I$(OUT)/inc/examples -I$(PRJ)/include
+STL_INCLUDES=-I"$(OO_SDK_HOME)/include/stl"
+CC_DEFINES=-DUNX -DGCC -DMACOSX -DCPPU_ENV=$(CPPU_ENV) -DGXX_INCLUDE_PATH=$(SDK_GXX_INCLUDE_PATH)
+
+CC_OUTPUT_SWITCH=-o
+
+LIBRARY_LINK_FLAGS=-dynamiclib -single_module -Wl,-multiply_defined,suppress $(GCC_ARCH_OPTION)
+#-fPIC -fno-common
+
+# install_name '@executable_path$/(@:f)'
+COMP_LINK_FLAGS=$(LIBRARY_LINK_FLAGS) -Wl,-exported_symbols_list $(COMP_MAPFILE)
+
+EXE_LINK_FLAGS=$(GCC_ARCH_OPTION) -Wl,-multiply_defined,suppress
+LINK_LIBS=-L$(OUT)/lib -L$(OO_SDK_OUT)/$(PLATFORM)/lib -L"$(OO_SDK_URE_LIB_DIR)"
+LINK_JAVA_LIBS=-framework JavaVM
+#LINK_JAVA_LIBS=-L"$(OO_SDK_JAVA_HOME)/Libraries"
+
+ifneq "$(OO_SDK_URE_HOME)" ""
+URE_MISC=$(OO_SDK_URE_HOME)/share/misc
+endif
+
+endif
+
+###########################################################################
+#
+# FreeBSD specific settings
+#
+###########################################################################
+ifneq (,$(findstring freebsd,$(PLATFORM)))
+# Settings for FreeBSD using gcc compiler
+
+PROCTYPE := $(shell $(PRJ)/config.guess | cut -d"-" -f1)
+
+ifeq (kfreebsd,$(findstring kfreebsd,$(PLATFORM)))
+PLATFORM=kfreebsd
+ifeq "$(PROCTYPE)" "x86_64"
+PACKAGE_LIB_DIR=kfreebsd_x86_64.plt
+UNOPKG_PLATFORM=kFreeBSD_x86_64
+else
+PACKAGE_LIB_DIR=kfreebsd_x86.plt
+UNOPKG_PLATFORM=kFreeBSD_x86
+endif
+else
+PLATFORM=freebsd
+ifeq "$(PROCTYPE)" "x86_64"
+PACKAGE_LIB_DIR=freebsd_x86_64.plt
+UNOPKG_PLATFORM=FreeBSD_x86_64
+else
+PACKAGE_LIB_DIR=freebsd_x86.plt
+UNOPKG_PLATFORM=FreeBSD_x86
+endif
+endif
+
+ifeq "$(PROCTYPE)" "x86_64"
+JAVA_PROC_TYPE=amd64
+else
+JAVA_PROC_TYPE=i386
+endif
+
+ifeq (kfreebsd,$(findstring kfreebsd,$(PLATFORM)))
+OS=LINUX
+else
+OS=FREEBSD
+endif
+PS=/
+ICL=\$$
+CC=gcc
+LINK=g++
+LIB=g++
+ECHO=@echo
+MKDIR=mkdir -p
+CAT=cat
+OBJ_EXT=o
+SHAREDLIB_EXT=so
+SHAREDLIB_PRE=lib
+SHAREDLIB_OUT=$(OUT_LIB)
+
+GCC_VERSION=$(shell $(CC) -dumpversion)
+
+COMID=gcc3
+CPPU_ENV=gcc3
+
+OSEP=\<
+CSEP=\>
+QUOTE=$(subst S,\,S)
+QM=\"
+SQM='
+ECHOLINE=@echo
+P2BG=&
+
+DEL=rm -f
+DELRECURSIVE=rm -rf
+COPY=cp
+URLPREFIX=file://
+
+# Include UDK version numbers
+include $(PRJ)/include/udkversion.mk
+
+SALLIB=-luno_sal
+CPPULIB=-luno_cppu
+CPPUHELPERLIB=-luno_cppuhelper$(COMID)
+SALHELPERLIB=-luno_salhelper$(COMID)
+REGLIB=-lreg
+STORELIB=-lstore
+ifeq "$(STLPORT_VER)" "500"
+STLPORTLIB=-lstlport
+else
+STLPORTLIB=-lstlport_gcc$(STLDEBUG)
+endif
+
+EMPTYSTRING=
+PATH_SEPARATOR=:
+
+# -O is necessary for inlining (see gcc documentation)
+ifeq "$(DEBUG)" "yes"
+CC_FLAGS=-c -g -fPIC -DPIC $(PTHREAD_CFLAGS)
+else
+CC_FLAGS=-c -O -fPIC -DPIC $(PTHREAD_CFLAGS)
+endif
+
+SDK_JAVA_INCLUDES = -I"$(OO_SDK_JAVA_HOME)/include" -I"$(OO_SDK_JAVA_HOME)/include/freebsd"
+CC_INCLUDES=-I. -I$(OUT)/inc -I$(OUT)/inc/examples -I$(PRJ)/include
+STL_INCLUDES=-I"$(OO_SDK_HOME)/include/stl"
+CC_DEFINES=-DUNX -DGCC -DFREEBSD -DCPPU_ENV=$(CPPU_ENV) -DGXX_INCLUDE_PATH=$(SDK_GXX_INCLUDE_PATH)
+
+CC_OUTPUT_SWITCH=-o
+
+LIBRARY_LINK_FLAGS=-shared '-Wl,-rpath,$$ORIGIN'
+COMP_LINK_FLAGS=$(LIBRARY_LINK_FLAGS) -Wl,--version-script,$(PRJ)/settings/component.uno.map
+
+EXE_LINK_FLAGS=-Wl,--allow-shlib-undefined
+#EXE_LINK_FLAGS+=-Wl,-export-dynamic -Wl,-z,defs
+LINK_LIBS=-L"$(OUT)/lib" -L"$(OO_SDK_HOME)/lib" -L"$(OO_SDK_URE_LIB_DIR)" $(PTHREAD_LIBS)
+LINK_JAVA_LIBS=-L"$(OO_SDK_JAVA_HOME)/jre/lib/$(JAVA_PROC_TYPE)"
+
+ifneq "$(OO_SDK_URE_HOME)" ""
+URE_MISC=$(OO_SDK_URE_HOME)/share/misc
+endif
+
+endif
diff --git a/odk/settings/std.mk b/odk/settings/std.mk
new file mode 100644
index 000000000000..6deb065f9dc1
--- /dev/null
+++ b/odk/settings/std.mk
@@ -0,0 +1,63 @@
+ifneq "$(OO_SDK_OUT)" ""
+OUT=$(subst \,/,$(OO_SDK_OUT))/$(OS)example.out
+else
+OUT=$(PRJ)/$(OS)example.out
+endif
+
+UNOPKG_EXT=uno.pkg
+UNOOXT_EXT=oxt
+
+OUT_BIN=$(OUT)/bin
+OUT_INC=$(OUT)/inc
+OUT_SLO=$(OUT)/slo
+OUT_LIB=$(OUT)/lib
+OUT_SLB=$(OUT)/slb
+OUT_MISC=$(OUT)/misc
+OUT_OBJ=$(OUT)/obj
+OUT_CLASS=$(OUT)/class
+IDL_DIR=$(PRJ)/idl
+BIN_DIR=$(PRJ)/bin
+CLASSES_DIR=$(PRJ)/classes
+URE_CLASSES_DIR=$(subst \,/,$(OO_SDK_URE_JAVA_DIR))
+OFFICE_CLASSES_DIR=$(subst \,/,$(OFFICE_BASE_PROGRAM_PATH))/classes
+COMP_PACKAGE_DIR=$(subst /,$(PS),$(OUT_BIN))
+
+SDKTYPEFLAG=$(OUT_MISC)/oosdk_cpp_types.flag
+
+URE_TYPES="$(subst \,/,$(URE_MISC)$(PS)types.rdb)"
+URE_SERVICES=$(subst \\,\,$(URE_MISC)$(PS)services.rdb)
+
+OFFICE_TYPES="$(subst \,/,$(OFFICE_BASE_PROGRAM_PATH)$(PS)offapi.rdb)"
+OFFICE_SERVICES=$(subst \\,\,$(OFFICE_BASE_PROGRAM_PATH)$(PS)services.rdb)
+
+OFFICE_TYPE_LIBRARY="$(OFFICE_TYPES)"
+
+JAVA_OPTIONS=
+ifneq "$(OO_SDK_JAVA_HOME)" ""
+JAVA_BITS := $(shell $(OO_SDK_JAVA_HOME)/$(JAVABIN)/java -version 2>&1 | tail -1 | cut -d " " -f3)
+ifeq "$(JAVA_BITS)" "64-Bit"
+JAVA_OPTIONS=-d32
+endif
+endif
+
+DEPLOYTOOL="$(OFFICE_PROGRAM_PATH)$(PS)unopkg" add -f
+SDK_JAVA="$(OO_SDK_JAVA_HOME)/$(JAVABIN)/java" $(JAVA_OPTIONS)
+SDK_JAVAC="$(OO_SDK_JAVA_HOME)/$(JAVABIN)/javac"
+SDK_JAR="$(OO_SDK_JAVA_HOME)/$(JAVABIN)/jar"
+SDK_ZIP="$(OO_SDK_ZIP_HOME)/zip"
+IDLC="$(OO_SDK_HOME)/bin/idlc"
+CPPUMAKER="$(OO_SDK_HOME)/bin/cppumaker"
+JAVAMAKER="$(OO_SDK_HOME)/bin/javamaker"
+REGMERGE="$(OO_SDK_URE_HOME)/bin/regmerge"
+REGCOMP="$(OO_SDK_URE_HOME)/bin/regcomp"
+
+SDK_JAVA_UNO_BOOTSTRAP_FILES=\
+ -C $(CLASSES_DIR) $(SQM)com/sun/star/lib/loader/Loader.class$(SQM) \
+ -C $(CLASSES_DIR) $(SQM)com/sun/star/lib/loader/Loader$$Drain.class$(SQM) \
+ -C $(CLASSES_DIR) $(SQM)com/sun/star/lib/loader/Loader$$CustomURLClassLoader.class$(SQM) \
+ -C $(CLASSES_DIR) $(SQM)com/sun/star/lib/loader/Loader$$Drain.class$(SQM) \
+ -C $(CLASSES_DIR) $(SQM)com/sun/star/lib/loader/InstallationFinder.class$(SQM) \
+ -C $(CLASSES_DIR) $(SQM)com/sun/star/lib/loader/InstallationFinder$$StreamGobbler.class$(SQM) \
+ -C $(CLASSES_DIR) $(SQM)com/sun/star/lib/loader/WinRegKey.class$(SQM) \
+ -C $(CLASSES_DIR) $(SQM)com/sun/star/lib/loader/WinRegKeyException.class$(SQM) \
+ -C $(CLASSES_DIR) $(SQM)win/unowinreg.dll$(SQM)
diff --git a/odk/settings/stdtarget.mk b/odk/settings/stdtarget.mk
new file mode 100644
index 000000000000..ba99722d11fe
--- /dev/null
+++ b/odk/settings/stdtarget.mk
@@ -0,0 +1,16 @@
+.SUFFIXES:
+
+.SECONDARY:
+
+ifeq "$(DEBUG)" "yes"
+debug : ALL
+endif
+
+.PHONY: install
+install: $(REGISTERFLAG)
+
+$(SDKTYPEFLAG): #$(URE_TYPES) $(OFFICE_TYPES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SDKTYPEFLAG)))
+ $(CPPUMAKER) -Gc -BUCR -O$(OUT_INC) $(URE_TYPES) $(OFFICE_TYPES)
+ echo flagged > $@
diff --git a/odk/source/com/sun/star/lib/loader/InstallationFinder.java b/odk/source/com/sun/star/lib/loader/InstallationFinder.java
new file mode 100644
index 000000000000..6c3343dcf594
--- /dev/null
+++ b/odk/source/com/sun/star/lib/loader/InstallationFinder.java
@@ -0,0 +1,584 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.loader;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+/**
+ * This class finds a UNO installation on the system.
+ *
+ * <p>A UNO installation can be specified by the user by either setting the
+ * com.sun.star.lib.loader.unopath system property or by setting the
+ * UNO_PATH environment variable to the program directory of a UNO
+ * installation.
+ * Note, that Java 1.3.1 and Java 1.4 don't support environment variables
+ * (System.getenv() throws java.lang.Error) and therefore setting the UNO_PATH
+ * enviroment variable won't work with those Java versions.
+ * If no UNO installation is specified by the user, the default installation
+ * on the system will be returned.</p>
+ *
+ * <p>On the Windows platform the default installation is read from the Windows
+ * Registry.</p>
+ *
+ * <p>On the Unix/Linux platforms the default installation is found from the
+ * PATH environment variable. Note, that for Java 1.3.1 and Java 1.4 the
+ * default installation is found by using the 'which' command, because
+ * environment variables are not supported with those Java versions.
+ * Both methods require that the 'soffice' executable or a symbolic
+ * link is in one of the directories listed in the PATH environment variable.
+ * For older versions than OOo 2.0 the above described methods may fail.
+ * In this case the default installation is taken from the .sversionrc file in
+ * the user's home directory. Note, that the .sversionrc file will be omitted
+ * for OOo 2.0</p>
+ */
+final class InstallationFinder {
+
+ private static final String SYSPROP_NAME =
+ "com.sun.star.lib.loader.unopath";
+ private static final String ENVVAR_NAME = "UNO_PATH";
+ private static final String SOFFICE = "soffice"; // Unix/Linux only
+
+ private InstallationFinder() {} // do not instantiate
+
+ /**
+ * Gets the path of a UNO installation.
+ *
+ * @return the installation path or <code>null</code>, if no installation
+ * was specified or found, or if an error occured
+ */
+ public static String getPath() {
+
+ String path = null;
+
+ // get the installation path from the Java system property
+ // com.sun.star.lib.loader.unopath
+ // (all platforms)
+ path = getPathFromProperty( SYSPROP_NAME );
+ if ( path == null ) {
+ // get the installation path from the UNO_PATH environment variable
+ // (all platforms, not working for Java 1.3.1 and Java 1.4)
+ path = getPathFromEnvVar( ENVVAR_NAME );
+ if ( path == null ) {
+ String osname = null;
+ try {
+ osname = System.getProperty( "os.name" );
+ } catch ( SecurityException e ) {
+ // if a SecurityException was thrown,
+ // return <code>null</code>
+ return null;
+ }
+ if ( osname != null ) {
+ if ( osname.startsWith( "Windows" ) ) {
+ // get the installation path from the Windows Registry
+ // (Windows platform only)
+ path = getPathFromWindowsRegistry();
+ } else {
+ // get the installation path from the PATH environment
+ // variable (Unix/Linux platforms only, not working for
+ // Java 1.3.1 and Java 1.4)
+ path = getPathFromPathEnvVar();
+ if ( path == null ) {
+ // get the installation path from the 'which'
+ // command (Unix/Linux platforms only)
+ path = getPathFromWhich();
+ if ( path == null ) {
+ // get the installation path from the
+ // .sversionrc file (Unix/Linux platforms only,
+ // for older versions than OOo 2.0)
+ path = getPathFromSVersionFile();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return path;
+ }
+
+ /**
+ * Gets the installation path from a Java system property.
+ *
+ * <p>This method is called on all platforms.
+ * The Java system property can be passed into the application by using
+ * the -D flag, e.g.
+ * java -D<property name>=<installation path> -jar application.jar.</p>
+ *
+ * @return the installation path or <code>null</code>, if no installation
+ * was specified in the Java system property or if an error occured
+ */
+ private static String getPathFromProperty( String prop ) {
+
+ String path = null;
+
+ try {
+ path = System.getProperty( prop );
+ } catch ( SecurityException e ) {
+ // if a SecurityException was thrown, return <code>null</code>
+ }
+
+ return path;
+ }
+
+ /**
+ * Gets the installation path from an environment variable.
+ *
+ * <p>This method is called on all platforms.
+ * Note, that in Java 1.3.1 and Java 1.4 System.getenv() throws
+ * java.lang.Error and therefore this method returns null for those
+ * Java versions.</p>
+ *
+ * @return the installation path or <code>null</code>, if no installation
+ * was specified in the environment variable or if an error occured
+ */
+ private static String getPathFromEnvVar( String var ) {
+
+ String path = null;
+
+ try {
+ path = System.getenv( var );
+ } catch ( SecurityException e ) {
+ // if a SecurityException was thrown, return <code>null</code>
+ } catch ( java.lang.Error err ) {
+ // System.getenv() throws java.lang.Error in Java 1.3.1 and
+ // Java 1.4
+ }
+
+ return path;
+ }
+
+ /**
+ * Gets the installation path from the Windows Registry.
+ *
+ * <p>This method is called on the Windows platform only.</p>
+ *
+ * @return the installation path or <code>null</code>, if no installation
+ * was found or if an error occured
+ */
+ private static String getPathFromWindowsRegistry() {
+
+ final String SUBKEYNAME = "Software\\OpenOffice.org\\UNO\\InstallPath";
+
+ String path = null;
+
+ try {
+ // read the key's default value from HKEY_CURRENT_USER
+ WinRegKey key = new WinRegKey( "HKEY_CURRENT_USER", SUBKEYNAME );
+ path = key.getStringValue( "" ); // default
+ } catch ( WinRegKeyException e ) {
+ try {
+ // read the key's default value from HKEY_LOCAL_MACHINE
+ WinRegKey key = new WinRegKey( "HKEY_LOCAL_MACHINE",
+ SUBKEYNAME );
+ path = key.getStringValue( "" ); // default
+ } catch ( WinRegKeyException we ) {
+ System.err.println( "com.sun.star.lib.loader." +
+ "InstallationFinder::getPathFromWindowsRegistry: " +
+ "reading key from Windows Registry failed: " + we );
+ }
+ }
+
+ return path;
+ }
+
+ /**
+ * Gets the installation path from the PATH environment variable.
+ *
+ * <p>This method is called on Unix/Linux platforms only.
+ * An installation is found, if the executable 'soffice' or a symbolic link
+ * is in one of the directories listed in the PATH environment variable.
+ * Note, that in Java 1.3.1 and Java 1.4 System.getenv() throws
+ * java.lang.Error and therefore this method returns null for those
+ * Java versions.</p>
+ *
+ * @return the installation path or <code>null</code>, if no installation
+ * was found or if an error occured
+ */
+ private static String getPathFromPathEnvVar() {
+
+ final String PATH_ENVVAR_NAME = "PATH";
+
+ String path = null;
+ String str = null;
+
+ try {
+ str = System.getenv( PATH_ENVVAR_NAME );
+ } catch ( SecurityException e ) {
+ // if a SecurityException was thrown, return <code>null</code>
+ return null;
+ } catch ( java.lang.Error err ) {
+ // System.getenv() throws java.lang.Error in Java 1.3.1 and
+ // Java 1.4
+ return null;
+ }
+
+ if ( str != null ) {
+ StringTokenizer tokens = new StringTokenizer(
+ str, File.pathSeparator );
+ while ( tokens.hasMoreTokens() ) {
+ File file = new File( tokens.nextToken(), SOFFICE );
+ try {
+ if ( file.exists() ) {
+ try {
+ // resolve symlink
+ path = file.getCanonicalFile().getParent();
+ if ( path != null )
+ break;
+ } catch ( IOException e ) {
+ // if an I/O exception is thrown, ignore this
+ // path entry and try the next one
+ System.err.println( "com.sun.star.lib.loader." +
+ "InstallationFinder::getPathFromEnvVar: " +
+ "bad path: " + e );
+ }
+ }
+ } catch ( SecurityException e ) {
+ // if a SecurityException was thrown, ignore this path
+ // entry and try the next one
+ }
+ }
+ }
+
+ return path;
+ }
+
+ /**
+ * Gets the installation path from the 'which' command on Unix/Linux
+ * platforms.
+ *
+ * <p>This method is called on Unix/Linux platforms only.
+ * An installation is found, if the executable 'soffice' or a symbolic link
+ * is in one of the directories listed in the PATH environment variable.</p>
+ *
+ * @return the installation path or <code>null</code>, if no installation
+ * was found or if an error occured
+ */
+ private static String getPathFromWhich() {
+
+ final String WHICH = "which";
+
+ String path = null;
+
+ // start the which process
+ String[] cmdArray = new String[2];
+ cmdArray[0] = WHICH;
+ cmdArray[1] = SOFFICE;
+ Process proc = null;
+ Runtime rt = Runtime.getRuntime();
+ try {
+ proc = rt.exec( cmdArray );
+ } catch ( SecurityException e ) {
+ return null;
+ } catch ( IOException e ) {
+ // if an I/O exception is thrown, return <code>null</null>
+ System.err.println( "com.sun.star.lib.loader." +
+ "InstallationFinder::getPathFromWhich: " +
+ "which command failed: " + e );
+ return null;
+ }
+
+ // empty standard error stream in a seperate thread
+ StreamGobbler gobbler = new StreamGobbler( proc.getErrorStream() );
+ gobbler.start();
+
+ // read the which output from standard input stream
+ BufferedReader br = new BufferedReader(
+ new InputStreamReader( proc.getInputStream() ) );
+ String line = null;
+ try {
+ while ( ( line = br.readLine() ) != null ) {
+ if ( path == null ) {
+ // get the path from the which output
+ int index = line.lastIndexOf( SOFFICE );
+ if ( index != -1 ) {
+ int end = index + SOFFICE.length();
+ for ( int i = 0; i <= index; i++ ) {
+ File file = new File( line.substring( i, end ) );
+ try {
+ if ( file.exists() ) {
+ // resolve symlink
+ path = file.getCanonicalFile().getParent();
+ if ( path != null )
+ break;
+ }
+ } catch ( SecurityException e ) {
+ return null;
+ }
+ }
+ }
+ }
+ }
+ } catch ( IOException e ) {
+ // if an I/O exception is thrown, return <code>null</null>
+ System.err.println( "com.sun.star.lib.loader." +
+ "InstallationFinder::getPathFromWhich: " +
+ "reading which command output failed: " + e );
+ return null;
+ } finally {
+ if ( br != null ) {
+ try {
+ br.close();
+ } catch ( IOException e ) {
+ // closing standard input stream failed, ignore
+ }
+ }
+ }
+
+ try {
+ // wait until the which process has terminated
+ proc.waitFor();
+ } catch ( InterruptedException e ) {
+ // the current thread was interrupted by another thread,
+ // kill the which process
+ proc.destroy();
+ // set the interrupted status
+ Thread.currentThread().interrupt();
+ }
+
+ return path;
+ }
+
+ /**
+ * Gets the installation path from the .sverionrc file in the user's home
+ * directory.
+ *
+ * <p>This method is called on Unix/Linux platforms only.
+ * The .sversionrc file is written during setup and will be omitted for
+ * OOo 2.0.</p>
+ *
+ * @return the installation path or <code>null</code>, if no installation
+ * was found or if an error occured
+ */
+ private static String getPathFromSVersionFile() {
+
+ final String SVERSION = ".sversionrc"; // Unix/Linux only
+ final String VERSIONS = "[Versions]";
+
+ String path = null;
+
+ try {
+ File fSVersion = new File(
+ System.getProperty( "user.home" ) ,SVERSION );
+ if ( fSVersion.exists() ) {
+ Vector lines = new Vector();
+ BufferedReader br = null;
+ try {
+ br = new BufferedReader( new InputStreamReader(
+ new FileInputStream( fSVersion ), "UTF-8" ) );
+ String line = null;
+ while ( ( line = br.readLine() ) != null &&
+ ( line.equals( VERSIONS ) ) != true ) {
+ // read lines until [Versions] is found
+ }
+ while ( ( line = br.readLine() ) != null &&
+ line.length() != 0 ) {
+ if ( !line.startsWith( ";" ) )
+ lines.add( line );
+ }
+ } catch ( IOException e ) {
+ // if an I/O exception is thrown, try to analyze the lines
+ // read so far
+ System.err.println( "com.sun.star.lib.loader." +
+ "InstallationFinder::getPathFromSVersionFile: " +
+ "reading .sversionrc file failed: " + e );
+ } finally {
+ if ( br != null ) {
+ try {
+ br.close();
+ } catch ( IOException e ) {
+ // closing .sversionrc failed, ignore
+ }
+ }
+ }
+ for ( int i = lines.size() - 1; i >= 0; i-- ) {
+ StringTokenizer tokens = new StringTokenizer(
+ (String)lines.elementAt( i ), "=" );
+ if ( tokens.countTokens() != 2 )
+ continue;
+ String key = tokens.nextToken();
+ String url = tokens.nextToken();
+ path = getCanonicalPathFromFileURL( url );
+ if ( path != null )
+ break;
+ }
+ }
+ } catch ( SecurityException e ) {
+ return null;
+ }
+
+ return path;
+ }
+
+ /**
+ * Translates an OOo-internal absolute file URL reference (encoded using
+ * UTF-8) into a Java canonical pathname.
+ *
+ * @param oooUrl any URL reference; any fragment part is ignored
+ *
+ * @return if the given URL is a valid absolute, local (that is, the host
+ * part is empty or equal to "localhost", ignoring case) file URL, it is
+ * converted into an absolute canonical pathname; otherwise,
+ * <code>null</code> is returned
+ */
+ private static String getCanonicalPathFromFileURL( String oooUrl ) {
+
+ String prefix = "file://";
+ if (oooUrl.length() < prefix.length()
+ || !oooUrl.substring(0, prefix.length()).toLowerCase().equals(
+ prefix))
+ {
+ return null;
+ }
+ StringBuffer buf = new StringBuffer(prefix);
+ int n = oooUrl.indexOf('/', prefix.length());
+ if (n < 0) {
+ n = oooUrl.length();
+ }
+ String host = oooUrl.substring(prefix.length(), n);
+ if (host.length() != 0 && !host.toLowerCase().equals("localhost")) {
+ return null;
+ }
+ buf.append(host);
+ if (n == oooUrl.length()) {
+ buf.append('/');
+ } else {
+ loop:
+ while (n < oooUrl.length()) {
+ buf.append('/');
+ ++n;
+ int n2 = oooUrl.indexOf('/', n);
+ if (n2 < 0) {
+ n2 = oooUrl.length();
+ }
+ while (n < n2) {
+ char c = oooUrl.charAt(n);
+ switch (c) {
+ case '%':
+ byte[] bytes = new byte[(n2 - n) / 3];
+ int len = 0;
+ while (oooUrl.length() - n > 2
+ && oooUrl.charAt(n) == '%')
+ {
+ int d1 = Character.digit(oooUrl.charAt(n + 1), 16);
+ int d2 = Character.digit(oooUrl.charAt(n + 2), 16);
+ if (d1 < 0 || d2 < 0) {
+ break;
+ }
+ int d = 16 * d1 + d2;
+ if (d == '/') {
+ return null;
+ }
+ bytes[len++] = (byte) d;
+ n += 3;
+ }
+ String s;
+ try {
+ s = new String(bytes, 0, len, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ return null;
+ }
+ buf.append(s);
+ break;
+
+ case '#':
+ break loop;
+
+ default:
+ buf.append(c);
+ ++n;
+ break;
+ }
+ }
+ }
+ }
+ URL url;
+ try {
+ url = new URL(buf.toString());
+ } catch (MalformedURLException e) {
+ return null;
+ }
+ String path = url.getFile();
+ String fragment = url.getRef();
+ if (fragment != null) {
+ path += '#' + fragment;
+ }
+ String ret = null;
+ File file = new File( path, SOFFICE );
+ try {
+ if ( file.isAbsolute() && file.exists() ) {
+ try {
+ // resolve symlink
+ ret = file.getCanonicalFile().getParent();
+ } catch ( IOException e ) {
+ return null;
+ }
+ }
+ } catch ( SecurityException e ) {
+ return null;
+ }
+
+ return ret;
+ }
+
+ /**
+ This class is used for emptying any stream which is passed into it in
+ a separate thread.
+ */
+ private static final class StreamGobbler extends Thread {
+
+ InputStream m_istream;
+
+ StreamGobbler( InputStream istream ) {
+ m_istream = istream;
+ }
+
+ public void run() {
+ try {
+ BufferedReader br = new BufferedReader(
+ new InputStreamReader( m_istream ) );
+ // read from input stream
+ while ( br.readLine() != null ) {
+ // don't handle line content
+ }
+ br.close();
+ } catch ( IOException e ) {
+ // stop reading from input stream
+ }
+ }
+ }
+}
diff --git a/odk/source/com/sun/star/lib/loader/Loader.java b/odk/source/com/sun/star/lib/loader/Loader.java
new file mode 100644
index 000000000000..c4ef7fee6e81
--- /dev/null
+++ b/odk/source/com/sun/star/lib/loader/Loader.java
@@ -0,0 +1,385 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.loader;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Enumeration;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+/**
+ * This class can be used as a loader for application classes which use UNO.
+ *
+ * <p>The Loader class detects a UNO installation on the system and adds the
+ * UNO jar files to the search path of a customized class loader, which is used
+ * for loading the application classes.</p>
+ */
+public final class Loader {
+
+ private static ClassLoader m_Loader = null;
+
+ /**
+ * do not instantiate
+ */
+ private Loader() {}
+
+ /**
+ * The main method instantiates a customized class loader with the
+ * UNO jar files added to the search path and loads the application class,
+ * which is specified in the Main-Class attribute of the
+ * com/sun/star/lib/Loader.class entry of the manifest file or
+ * as first parameter in the argument list.
+ */
+ public static void main( String[] arguments ) throws Exception {
+
+ // get the name of the class to be loaded from the manifest
+ String className = null;
+ Class clazz = Loader.class;
+ ClassLoader loader = clazz.getClassLoader();
+ Vector res = new Vector();
+ try {
+ Enumeration en = loader.getResources( "META-INF/MANIFEST.MF" );
+ while ( en.hasMoreElements() ) {
+ res.add( (URL) en.nextElement() );
+ }
+ // the jarfile with the com/sun/star/lib/loader/Loader.class
+ // per-entry attribute is most probably the last resource in the
+ // list, therefore search backwards
+ for ( int i = res.size() - 1; i >= 0; i-- ) {
+ URL jarurl = (URL) res.elementAt( i );
+ try {
+ JarURLConnection jarConnection =
+ (JarURLConnection) jarurl.openConnection();
+ Manifest mf = jarConnection.getManifest();
+ Attributes attrs = (Attributes) mf.getAttributes(
+ "com/sun/star/lib/loader/Loader.class" );
+ if ( attrs != null ) {
+ className = attrs.getValue( "Application-Class" );
+ if ( className != null )
+ break;
+ }
+ } catch ( IOException e ) {
+ // if an I/O error occurs when opening a new
+ // JarURLConnection, ignore this manifest file
+ System.err.println( "com.sun.star.lib.loader.Loader::" +
+ "main: bad manifest file: " + e );
+ }
+ }
+ } catch ( IOException e ) {
+ // if an I/O error occurs when getting the manifest resources,
+ // try to get the name of the class to be loaded from the argument
+ // list
+ System.err.println( "com.sun.star.lib.loader.Loader::" +
+ "main: cannot get manifest resources: " + e );
+ }
+
+ // if no manifest entry was found, get the name of the class
+ // to be loaded from the argument list
+ String[] args;
+ if ( className == null ) {
+ if ( arguments.length > 0 ) {
+ className = arguments[0];
+ args = new String[arguments.length - 1];
+ System.arraycopy( arguments, 1, args, 0, args.length );
+ } else {
+ throw new IllegalArgumentException(
+ "The name of the class to be loaded must be either " +
+ "specified in the Main-Class attribute of the " +
+ "com/sun/star/lib/loader/Loader.class entry " +
+ "of the manifest file or as a command line argument." );
+ }
+ } else {
+ args = arguments;
+ }
+
+ // load the class with the customized class loader and
+ // invoke the main method
+ if ( className != null ) {
+ ClassLoader cl = getCustomLoader();
+ Thread.currentThread().setContextClassLoader(cl);
+ Class c = cl.loadClass( className );
+ Method m = c.getMethod( "main", new Class[] { String[].class } );
+ m.invoke( null, new Object[] { args } );
+ }
+ }
+
+ /**
+ * Gets the customized class loader with the UNO jar files added to the
+ * search path.
+ *
+ * @return the customized class loader
+ */
+ public static synchronized ClassLoader getCustomLoader() {
+
+ final String CLASSESDIR = "classes";
+ final String JUHJAR = "juh.jar";
+
+ if ( m_Loader == null ) {
+
+ // get the urls from which to load classes and resources
+ // from the class path
+ Vector vec = new Vector();
+ String classpath = null;
+ try {
+ classpath = System.getProperty( "java.class.path" );
+ } catch ( SecurityException e ) {
+ // don't add the class path entries to the list of class
+ // loader URLs
+ System.err.println( "com.sun.star.lib.loader.Loader::" +
+ "getCustomLoader: cannot get system property " +
+ "java.class.path: " + e );
+ }
+ if ( classpath != null ) {
+ addUrls(vec, classpath, File.pathSeparator);
+ }
+
+ // get the urls from which to load classes and resources
+ // from the UNO installation
+ String path = InstallationFinder.getPath();
+ if ( path != null ) {
+ File fClassesDir = new File( path, CLASSESDIR );
+ File fJuh = new File( fClassesDir, JUHJAR );
+ if ( fJuh.exists() ) {
+ URL[] clurls = new URL[1];
+ try {
+ clurls[0] = fJuh.toURL();
+ ClassLoader cl = new CustomURLClassLoader( clurls );
+ Class c = cl.loadClass(
+ "com.sun.star.comp.helper.UnoInfo" );
+ Method m = c.getMethod( "getJars", (Class[]) null );
+ URL[] jarurls = (URL[]) m.invoke(
+ null, (Object[]) null );
+ for ( int i = 0; i < jarurls.length; i++ ) {
+ vec.add( jarurls[i] );
+ }
+ } catch ( MalformedURLException e ) {
+ // don't add the UNO jar files to the list of class
+ // loader URLs
+ System.err.println( "com.sun.star.lib.loader.Loader::" +
+ "getCustomLoader: cannot add UNO jar files: " + e );
+ } catch ( ClassNotFoundException e ) {
+ // don't add the UNO jar files to the list of class
+ // loader URLs
+ System.err.println( "com.sun.star.lib.loader.Loader::" +
+ "getCustomLoader: cannot add UNO jar files: " + e );
+ } catch ( NoSuchMethodException e ) {
+ // don't add the UNO jar files to the list of class
+ // loader URLs
+ System.err.println( "com.sun.star.lib.loader.Loader::" +
+ "getCustomLoader: cannot add UNO jar files: " + e );
+ } catch ( IllegalAccessException e ) {
+ // don't add the UNO jar files to the list of class
+ // loader URLs
+ System.err.println( "com.sun.star.lib.loader.Loader::" +
+ "getCustomLoader: cannot add UNO jar files: " + e );
+ } catch ( InvocationTargetException e ) {
+ // don't add the UNO jar files to the list of class
+ // loader URLs
+ System.err.println( "com.sun.star.lib.loader.Loader::" +
+ "getCustomLoader: cannot add UNO jar files: " + e );
+ }
+ } else {
+ callUnoinfo(path, vec);
+ }
+ } else {
+ System.err.println( "com.sun.star.lib.loader.Loader::" +
+ "getCustomLoader: no UNO installation found!" );
+ }
+
+ // copy urls to array
+ URL[] urls = new URL[vec.size()];
+ vec.toArray( urls );
+
+ // instantiate class loader
+ m_Loader = new CustomURLClassLoader( urls );
+ }
+
+ return m_Loader;
+ }
+
+ private static void addUrls(Vector urls, String data, String delimiter) {
+ StringTokenizer tokens = new StringTokenizer( data, delimiter );
+ while ( tokens.hasMoreTokens() ) {
+ try {
+ urls.add( new File( tokens.nextToken() ).toURL() );
+ } catch ( MalformedURLException e ) {
+ // don't add this class path entry to the list of class loader
+ // URLs
+ System.err.println( "com.sun.star.lib.loader.Loader::" +
+ "getCustomLoader: bad pathname: " + e );
+ }
+ }
+ }
+
+ private static void callUnoinfo(String path, Vector urls) {
+ Process p;
+ try {
+ p = Runtime.getRuntime().exec(
+ new String[] { new File(path, "unoinfo").getPath(), "java" });
+ } catch (IOException e) {
+ System.err.println(
+ "com.sun.star.lib.loader.Loader::getCustomLoader: exec" +
+ " unoinfo: " + e);
+ return;
+ }
+ new Drain(p.getErrorStream()).start();
+ int code;
+ byte[] buf = new byte[1000];
+ int n = 0;
+ try {
+ InputStream s = p.getInputStream();
+ code = s.read();
+ for (;;) {
+ if (n == buf.length) {
+ if (n > Integer.MAX_VALUE / 2) {
+ System.err.println(
+ "com.sun.star.lib.loader.Loader::getCustomLoader:" +
+ " too much unoinfo output");
+ return;
+ }
+ byte[] buf2 = new byte[2 * n];
+ for (int i = 0; i < n; ++i) {
+ buf2[i] = buf[i];
+ }
+ buf = buf2;
+ }
+ int k = s.read(buf, n, buf.length - n);
+ if (k == -1) {
+ break;
+ }
+ n += k;
+ }
+ } catch (IOException e) {
+ System.err.println(
+ "com.sun.star.lib.loader.Loader::getCustomLoader: reading" +
+ " unoinfo output: " + e);
+ return;
+ }
+ int ev;
+ try {
+ ev = p.waitFor();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ System.err.println(
+ "com.sun.star.lib.loader.Loader::getCustomLoader: waiting for" +
+ " unoinfo: " + e);
+ return;
+ }
+ if (ev != 0) {
+ System.err.println(
+ "com.sun.star.lib.loader.Loader::getCustomLoader: unoinfo"
+ + " exit value " + n);
+ return;
+ }
+ String s;
+ if (code == '0') {
+ s = new String(buf);
+ } else if (code == '1') {
+ try {
+ s = new String(buf, "UTF-16LE");
+ } catch (UnsupportedEncodingException e) {
+ System.err.println(
+ "com.sun.star.lib.loader.Loader::getCustomLoader:" +
+ " transforming unoinfo output: " + e);
+ return;
+ }
+ } else {
+ System.err.println(
+ "com.sun.star.lib.loader.Loader::getCustomLoader: bad unoinfo"
+ + " output");
+ return;
+ }
+ addUrls(urls, s, "\0");
+ }
+
+ private static final class Drain extends Thread {
+ public Drain(InputStream stream) {
+ super("unoinfo stderr drain");
+ this.stream = stream;
+ }
+
+ public void run() {
+ try {
+ while (stream.read() != -1) {}
+ } catch (IOException e) { /* ignored */ }
+ }
+
+ private final InputStream stream;
+ }
+
+ /**
+ * A customized class loader which is used to load classes and resources
+ * from a search path of user-defined URLs.
+ */
+ private static final class CustomURLClassLoader extends URLClassLoader {
+
+ public CustomURLClassLoader( URL[] urls ) {
+ super( urls );
+ }
+
+ protected Class findClass( String name ) throws ClassNotFoundException {
+ // This is only called via this.loadClass -> super.loadClass ->
+ // this.findClass, after this.loadClass has already called
+ // super.findClass, so no need to call super.findClass again:
+ throw new ClassNotFoundException( name );
+ }
+
+ protected Class loadClass( String name, boolean resolve )
+ throws ClassNotFoundException
+ {
+ Class c = findLoadedClass( name );
+ if ( c == null ) {
+ try {
+ c = super.findClass( name );
+ } catch ( ClassNotFoundException e ) {
+ return super.loadClass( name, resolve );
+ } catch ( SecurityException e ) {
+ // A SecurityException "Prohibited package name: java.lang"
+ // may occur when the user added the JVM's rt.jar to the
+ // java.class.path:
+ return super.loadClass( name, resolve );
+ }
+ }
+ if ( resolve ) {
+ resolveClass( c );
+ }
+ return c;
+ }
+ }
+}
diff --git a/odk/source/com/sun/star/lib/loader/WinRegKey.java b/odk/source/com/sun/star/lib/loader/WinRegKey.java
new file mode 100644
index 000000000000..d9203b3b37c0
--- /dev/null
+++ b/odk/source/com/sun/star/lib/loader/WinRegKey.java
@@ -0,0 +1,200 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.loader;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+
+
+/**
+ * This class provides functionality for reading string values from the
+ * Windows Registry. It requires the native library unowinreg.dll.
+ */
+final class WinRegKey {
+
+ private String m_rootKeyName;
+ private String m_subKeyName;
+
+ // native methods to access the windows registry
+ private static native boolean winreg_RegOpenClassesRoot( long[] hkresult );
+ private static native boolean winreg_RegOpenCurrentConfig(
+ long[] hkresult );
+ private static native boolean winreg_RegOpenCurrentUser( long[] hkresult );
+ private static native boolean winreg_RegOpenLocalMachine( long[] hkresult );
+ private static native boolean winreg_RegOpenUsers( long[] hkresult );
+ private static native boolean winreg_RegOpenKeyEx( long parent, String name,
+ long[] hkresult );
+ private static native boolean winreg_RegCloseKey( long hkey );
+ private static native boolean winreg_RegQueryValueEx(
+ long hkey, String value, long[] type,
+ byte[] data, long[] size );
+ private static native boolean winreg_RegQueryInfoKey(
+ long hkey, long[] subkeys, long[] maxSubkeyLen,
+ long[] values, long[] maxValueNameLen,
+ long[] maxValueLen, long[] secDescriptor );
+
+ // load the native library unowinreg.dll
+ static {
+ try {
+ ClassLoader cl = WinRegKey.class.getClassLoader();
+ InputStream is = cl.getResourceAsStream( "win/unowinreg.dll" );
+ if ( is != null ) {
+ // generate a temporary name for lib file and write to temp
+ // location
+ BufferedInputStream istream = new BufferedInputStream( is );
+ File libfile = File.createTempFile( "unowinreg", ".dll" );
+ libfile.deleteOnExit(); // ensure deletion
+ BufferedOutputStream ostream = new BufferedOutputStream(
+ new FileOutputStream( libfile ) );
+ int bsize = 2048; int n = 0;
+ byte[] buffer = new byte[bsize];
+ while ( ( n = istream.read( buffer, 0, bsize ) ) != -1 ) {
+ ostream.write( buffer, 0, n );
+ }
+ istream.close();
+ ostream.close();
+ // load library
+ System.load( libfile.getPath() );
+ } else {
+ // If the library cannot be found as a class loader resource,
+ // try the global System.loadLibrary(). The JVM will look for
+ // it in the java.library.path.
+ System.loadLibrary( "unowinreg" );
+ }
+ } catch ( java.lang.Exception e ) {
+ System.err.println( "com.sun.star.lib.loader.WinRegKey: " +
+ "loading of native library failed!" + e );
+ }
+ }
+
+ /**
+ * Constructs a <code>WinRegKey</code>.
+ */
+ public WinRegKey( String rootKeyName, String subKeyName ) {
+ m_rootKeyName = rootKeyName;
+ m_subKeyName = subKeyName;
+ }
+
+ /**
+ * Reads a string value for the specified value name.
+ */
+ public String getStringValue( String valueName ) throws WinRegKeyException {
+ byte[] data = getValue( valueName );
+ // remove terminating null character
+ return new String( data, 0, data.length - 1 );
+ }
+
+ /**
+ * Reads a value for the specified value name.
+ */
+ private byte[] getValue( String valueName ) throws WinRegKeyException {
+
+ byte[] result = null;
+ long[] hkey = {0};
+
+ // open the specified registry key
+ boolean bRet = false;
+ long[] hroot = {0};
+ if ( m_rootKeyName.equals( "HKEY_CLASSES_ROOT" ) ) {
+ bRet = winreg_RegOpenClassesRoot( hroot );
+ } else if ( m_rootKeyName.equals( "HKEY_CURRENT_CONFIG" ) ) {
+ bRet = winreg_RegOpenCurrentConfig( hroot );
+ } else if ( m_rootKeyName.equals( "HKEY_CURRENT_USER" ) ) {
+ bRet = winreg_RegOpenCurrentUser( hroot );
+ } else if ( m_rootKeyName.equals( "HKEY_LOCAL_MACHINE" ) ) {
+ bRet = winreg_RegOpenLocalMachine( hroot );
+ } else if ( m_rootKeyName.equals( "HKEY_USERS" ) ) {
+ bRet = winreg_RegOpenUsers( hroot );
+ } else {
+ throw new WinRegKeyException( "unknown root registry key!");
+ }
+ if ( !bRet ) {
+ throw new WinRegKeyException( "opening root registry key " +
+ "failed!" );
+ }
+ if ( !winreg_RegOpenKeyEx( hroot[0], m_subKeyName, hkey ) ) {
+ if ( !winreg_RegCloseKey( hroot[0] ) ) {
+ throw new WinRegKeyException( "opening registry key and " +
+ "releasing root registry key handle failed!" );
+ }
+ throw new WinRegKeyException( "opening registry key failed!" );
+ }
+
+ // get the size of the longest data component among the key's values
+ long[] subkeys = {0};
+ long[] maxSubkeyLen = {0};
+ long[] values = {0};
+ long[] maxValueNameLen = {0};
+ long[] maxValueLen = {0};
+ long[] secDescriptor = {0};
+ if ( !winreg_RegQueryInfoKey( hkey[0], subkeys, maxSubkeyLen,
+ values, maxValueNameLen, maxValueLen, secDescriptor ) ) {
+ if ( !winreg_RegCloseKey( hkey[0] ) ||
+ !winreg_RegCloseKey( hroot[0] ) ) {
+ throw new WinRegKeyException( "retrieving information about " +
+ "the registry key and releasing registry key handles " +
+ "failed!" );
+ }
+ throw new WinRegKeyException( "retrieving information about " +
+ "the registry key failed!" );
+ }
+
+ // get the data for the specified value name
+ byte[] buffer = new byte[ (int) maxValueLen[0] ];
+ long[] size = new long[1];
+ size[0] = buffer.length;
+ long[] type = new long[1];
+ type[0] = 0;
+ if ( !winreg_RegQueryValueEx( hkey[0], valueName, type, buffer,
+ size ) ) {
+ if ( !winreg_RegCloseKey( hkey[0] ) ||
+ !winreg_RegCloseKey( hroot[0] ) ) {
+ throw new WinRegKeyException( "retrieving data for the " +
+ "specified value name and releasing registry key handles " +
+ "failed!" );
+ }
+ throw new WinRegKeyException( "retrieving data for the " +
+ "specified value name failed!" );
+ }
+
+ // release registry key handles
+ if ( !winreg_RegCloseKey( hkey[0] ) ||
+ !winreg_RegCloseKey( hroot[0] ) ) {
+ throw new WinRegKeyException( "releasing registry key handles " +
+ "failed!" );
+ }
+
+ result = new byte[ (int) size[0] ];
+ System.arraycopy( buffer, 0, result, 0, (int)size[0] );
+
+ return result;
+ }
+}
diff --git a/odk/source/com/sun/star/lib/loader/WinRegKeyException.java b/odk/source/com/sun/star/lib/loader/WinRegKeyException.java
new file mode 100644
index 000000000000..bd66f3e4b933
--- /dev/null
+++ b/odk/source/com/sun/star/lib/loader/WinRegKeyException.java
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.lib.loader;
+
+/**
+ * WinRegKeyException is a checked exception.
+ */
+final class WinRegKeyException extends java.lang.Exception {
+
+ /**
+ * Constructs a <code>WinRegKeyException</code>.
+ */
+ public WinRegKeyException() {
+ super();
+ }
+
+ /**
+ * Constructs a <code>WinRegKeyException</code> with the specified
+ * detail message.
+ *
+ * @param message the detail message
+ */
+ public WinRegKeyException( String message ) {
+ super( message );
+ }
+}
diff --git a/odk/source/com/sun/star/lib/loader/makefile.mk b/odk/source/com/sun/star/lib/loader/makefile.mk
new file mode 100644
index 000000000000..f44b6f55d1c1
--- /dev/null
+++ b/odk/source/com/sun/star/lib/loader/makefile.mk
@@ -0,0 +1,56 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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
+PACKAGE = com$/sun$/star$/lib$/loader
+TARGET = com_sun_star_lib_loader
+
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+.IF "$(SOLAR_JAVA)"==""
+nojava:
+ @echo "Not building javaunohelper because Java is disabled"
+.ENDIF
+
+# Files --------------------------------------------------------
+
+JAVAFILES= \
+ Loader.java\
+ InstallationFinder.java\
+ WinRegKey.java\
+ WinRegKeyException.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/odk/source/unoapploader/unx/makefile.mk b/odk/source/unoapploader/unx/makefile.mk
new file mode 100644
index 000000000000..56a5024d19c5
--- /dev/null
+++ b/odk/source/unoapploader/unx/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=odk
+TARGET=unoapploader
+LIBTARGET=NO
+
+LIBSALCPPRT=
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(COM)"=="GCC"
+LINK=$(CC)
+.ENDIF
+
+.IF "$(OS)"!="FREEBSD"
+STDLIB= -ldl
+.ENDIF
+
+
+APP1NOSAL=TRUE
+APP1RPATH=NONE
+
+APP1TARGET= $(TARGET)
+
+APP1OBJS= $(OBJ)$/unoapploader.obj $(SOLARLIBDIR)$/findsofficepath.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/odk/source/unoapploader/unx/unoapploader.c b/odk/source/unoapploader/unx/unoapploader.c
new file mode 100644
index 000000000000..bec148f20b08
--- /dev/null
+++ b/odk/source/unoapploader/unx/unoapploader.c
@@ -0,0 +1,301 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#ifdef LINUX
+#define __USE_GNU
+#endif
+#include <dlfcn.h>
+
+#include "cppuhelper/findsofficepath.h"
+#include "rtl/string.h"
+#include "sal/types.h"
+
+char const* getPath();
+char* createCommandName( char* argv0 );
+
+const int SEPARATOR = '/';
+const char* PATHSEPARATOR = ":";
+
+
+/*
+ * The main function implements a loader for applications which use UNO.
+ *
+ * <p>This code runs on the Unix/Linux platforms only.</p>
+ *
+ * <p>The main function detects a UNO installation on the system and adds the
+ * relevant directories of the installation to the LD_LIBRARY_PATH environment
+ * variable. After that, the application process is loaded and started, whereby
+ * the new process inherits the environment of the calling process, including
+ * the modified LD_LIBRARY_PATH environment variable. The application's
+ * executable name must be the same as the name of this executable, prefixed
+ * by '_'.</p>
+ * <p>On MACOSX DYLD_LIBRARY_PATH is used instead of LD_LIBRARY_PATH!<p>
+ *
+ * <p>A UNO installation can be specified by the user by setting the UNO_PATH
+ * environment variable to the program directory of the UNO installation.
+ * If no installation is specified by the user, the default installation on
+ * the system will be taken. The default installation is found from the
+ * PATH environment variable. This requires that the 'soffice' executable or
+ * a symbolic link is in one of the directories listed in the PATH environment
+ * variable.</p>
+ */
+int main( int argc, char *argv[] )
+{
+ char const* path;
+ char* cmdname;
+
+ (void) argc; /* avoid warning about unused parameter */
+
+ /* get the path of the UNO installation */
+ path = getPath();
+
+ if ( path != NULL )
+ {
+#ifdef MACOSX
+ static const char* ENVVARNAME = "DYLD_LIBRARY_PATH";
+#else
+ static const char* ENVVARNAME = "LD_LIBRARY_PATH";
+#endif
+ char * libpath;
+ int freeLibpath;
+
+ char* value;
+ char* envstr;
+ int size;
+
+ size_t pathlen = strlen(path);
+ struct stat stat;
+ int ret;
+ char * unoinfo = malloc(
+ pathlen + RTL_CONSTASCII_LENGTH("/unoinfo") + 1);
+ /*TODO: overflow */
+ if (unoinfo == NULL) {
+ fprintf(stderr, "Error: out of memory!\n");
+ exit(EXIT_FAILURE);
+ }
+ strcpy(unoinfo, path);
+ strcpy(
+ unoinfo + pathlen,
+ "/unoinfo" + (pathlen == 0 || path[pathlen - 1] != '/' ? 0 : 1));
+ ret = lstat(unoinfo, &stat);
+ free(unoinfo);
+
+ if (ret == 0) {
+ char * cmd = malloc(
+ 2 * pathlen + RTL_CONSTASCII_LENGTH("/unoinfo c++") + 1);
+ /*TODO: overflow */
+ char const * p;
+ char * q;
+ FILE * f;
+ size_t n = 1000;
+ size_t old = 0;
+ if (cmd == NULL) {
+ fprintf(stderr, "Error: out of memory!\n");
+ exit(EXIT_FAILURE);
+ }
+ p = path;
+ q = cmd;
+ while (*p != '\0') {
+ *q++ = '\\';
+ *q++ = *p++;
+ }
+ if (p == path || p[-1] != '/') {
+ *q++ = '/';
+ }
+ strcpy(q, "unoinfo c++");
+ f = popen(cmd, "r");
+ free(cmd);
+ if (f == NULL)
+ {
+ fprintf(stderr, "Error: calling unoinfo failed!\n");
+ exit(EXIT_FAILURE);
+ }
+ libpath = NULL;
+ for (;;) {
+ size_t m;
+ libpath = realloc(libpath, n);
+ if (libpath == NULL) {
+ fprintf(
+ stderr,
+ "Error: out of memory reading unoinfo output!\n");
+ exit(EXIT_FAILURE);
+ }
+ m = fread(libpath + old, 1, n - old - 1, f);
+ if (m != n - old - 1) {
+ if (ferror(f)) {
+ fprintf(stderr, "Error: cannot read unoinfo output!\n");
+ exit(EXIT_FAILURE);
+ }
+ libpath[old + m] = '\0';
+ break;
+ }
+ if (n >= SAL_MAX_SIZE / 2) {
+ fprintf(
+ stderr,
+ "Error: out of memory reading unoinfo output!\n");
+ exit(EXIT_FAILURE);
+ }
+ old = n - 1;
+ n *= 2;
+ }
+ if (pclose(f) != 0) {
+ fprintf(stderr, "Error: executing unoinfo failed!\n");
+ exit(EXIT_FAILURE);
+ }
+ freeLibpath = 1;
+ }
+ else
+ {
+ /* Assume an old OOo 2.x installation without unoinfo: */
+ libpath = (char *) path;
+ freeLibpath = 0;
+ }
+
+ value = getenv( ENVVARNAME );
+
+ size = strlen( ENVVARNAME ) + strlen( "=" ) + strlen( libpath ) + 1;
+ if ( value != NULL )
+ size += strlen( PATHSEPARATOR ) + strlen( value );
+ envstr = (char*) malloc( size );
+ strcpy( envstr, ENVVARNAME );
+ strcat( envstr, "=" );
+ strcat( envstr, libpath );
+ if ( freeLibpath != 0 )
+ {
+ free( libpath );
+ }
+ if ( value != NULL )
+ {
+ strcat( envstr, PATHSEPARATOR );
+ strcat( envstr, value );
+ }
+ putenv( envstr );
+ }
+ else
+ {
+ fprintf( stderr, "Warning: no UNO installation found!\n" );
+ fflush( stderr );
+ }
+
+ /* set the executable name for the application process */
+ cmdname = createCommandName( argv[0] );
+ argv[0] = cmdname;
+
+ /*
+ * create the application process;
+ * if successful, execvp doesn't return to the calling process
+ */
+ execvp( cmdname, argv );
+ fprintf( stderr, "Error: execvp failed!\n" );
+ fflush( stderr );
+
+ return 0;
+}
+
+/*
+ * Gets the path of a UNO installation.
+ *
+ * @return the installation path or NULL, if no installation was specified or
+ * found, or if an error occured
+ */
+char const* getPath()
+{
+ char const* path = cppuhelper_detail_findSofficePath();
+
+ if ( path == NULL )
+ {
+ fprintf( stderr, "Warning: getting path from PATH environment "
+ "variable failed!\n" );
+ fflush( stderr );
+ }
+
+ return path;
+}
+
+/*
+ * Creates the application's executable file name.
+ *
+ * <p>The application's executable file name is the name of this executable
+ * prefixed by '_'.</p>
+ *
+ * @param argv0 specifies the argv[0] parameter of the main function
+ *
+ * @return the application's executable file name or NULL, if an error occured
+ */
+char* createCommandName( char* argv0 )
+{
+ const char* CMDPREFIX = "_";
+ const char* prgname = NULL;
+
+ char* cmdname = NULL;
+ char* sep = NULL;
+ Dl_info dl_info;
+ int pos;
+
+ /* get the executable file name from argv0 */
+ prgname = argv0;
+
+ /*
+ * if argv0 doesn't contain an absolute path name, try to get the absolute
+ * path name from dladdr; note that this only works for Solaris, not for
+ * Linux
+ */
+ if ( argv0 != NULL && *argv0 != SEPARATOR &&
+ dladdr( (void*) &createCommandName, &dl_info ) &&
+ dl_info.dli_fname != NULL && *dl_info.dli_fname == SEPARATOR )
+ {
+ prgname = dl_info.dli_fname;
+ }
+
+ /* prefix the executable file name by '_' */
+ if ( prgname != NULL )
+ {
+ cmdname = (char*) malloc( strlen( prgname ) + strlen( CMDPREFIX ) + 1 );
+ sep = strrchr( prgname, SEPARATOR );
+ if ( sep != NULL )
+ {
+ pos = ++sep - prgname;
+ strncpy( cmdname, prgname, pos );
+ cmdname[ pos ] = '\0';
+ strcat( cmdname, CMDPREFIX );
+ strcat( cmdname, sep );
+ }
+ else
+ {
+ strcpy( cmdname, CMDPREFIX );
+ strcat( cmdname, prgname );
+ }
+ }
+
+ return cmdname;
+}
diff --git a/odk/source/unoapploader/win/makefile.mk b/odk/source/unoapploader/win/makefile.mk
new file mode 100644
index 000000000000..aae10c545880
--- /dev/null
+++ b/odk/source/unoapploader/win/makefile.mk
@@ -0,0 +1,57 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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=unoapploader
+TARGETTYPE=GUI
+LIBTARGET=NO
+
+DYNAMIC_CRT=
+UWINAPILIB=
+NO_DEFAULT_STL=true
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+APP1NOSAL=TRUE
+APP1RPATH=NONE
+
+APP1TARGET= $(TARGET)
+
+APP1OBJS= $(OBJ)$/unoapploader.obj $(SOLARLIBDIR)$/findsofficepath.obj
+
+APP1STDLIBS=\
+ $(ADVAPI32LIB)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/odk/source/unoapploader/win/unoapploader.c b/odk/source/unoapploader/win/unoapploader.c
new file mode 100644
index 000000000000..6512da32eb31
--- /dev/null
+++ b/odk/source/unoapploader/win/unoapploader.c
@@ -0,0 +1,423 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <process.h>
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#include "cppuhelper/findsofficepath.h"
+#include "sal/types.h"
+
+#define MY_LENGTH(s) (sizeof (s) / sizeof *(s) - 1)
+
+char const* getPath();
+char* createCommandLine( char* lpCmdLine );
+FILE* getErrorFile( int create );
+void writeError( const char* errstr );
+void closeErrorFile();
+
+/*
+ * The main function implements a loader for applications which use UNO.
+ *
+ * <p>This code runs on the Windows platform only.</p>
+ *
+ * <p>The main function detects a UNO installation on the system and adds the
+ * program directory of the UNO installation to the PATH environment variable.
+ * After that, the application process is loaded and started, whereby the
+ * new process inherits the environment of the calling process, including
+ * the modified PATH environment variable. The application's executable name
+ * must be the same as the name of this executable, prefixed by '_'.</p>
+ *
+ * <p>A UNO installation can be specified by the user by setting the UNO_PATH
+ * environment variable to the program directory of the UNO installation.
+ * If no installation is specified by the user, the default installation on
+ * the system will be taken. The default installation is read from the
+ * default value of the key "Software\OpenOffice.org\UNO\InstallPath" from the
+ * root key HKEY_CURRENT_USER in the Windows Registry. If this key is missing,
+ * the key is read from the root key HKEY_LOCAL_MACHINE.</p>
+ */
+int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine, int nCmdShow )
+{
+ const char* ENVVARNAME = "PATH";
+ const char* PATHSEPARATOR = ";";
+
+ char const* path = NULL;
+ char path2[MAX_PATH];
+ char* value = NULL;
+ char* envstr = NULL;
+ char* cmdline = NULL;
+ int size;
+ STARTUPINFO startup_info;
+ PROCESS_INFORMATION process_info;
+ BOOL bCreate;
+
+ (void) hInstance; /* unused */
+ (void) hPrevInstance; /* unused */
+ (void) nCmdShow; /* unused */
+
+ /* get the path of the UNO installation */
+ path = getPath();
+
+ if ( path != NULL )
+ {
+ wchar_t cmd[
+ MY_LENGTH(L"\"") + MAX_PATH +
+ MY_LENGTH(L"\\unoinfo.exe\" c++")];
+ /* hopefully does not overflow */
+ int pathsize;
+ SECURITY_ATTRIBUTES sec;
+ HANDLE temp;
+ HANDLE stdoutRead;
+ HANDLE stdoutWrite;
+ STARTUPINFOW startinfo;
+ PROCESS_INFORMATION procinfo;
+ int ret;
+ cmd[0] = L'"';
+ pathsize = MultiByteToWideChar(CP_ACP, 0, path, -1, cmd + 1, MAX_PATH);
+ if (pathsize == 0) {
+ writeError("Error: MultiByteToWideChar failed!\n");
+ closeErrorFile();
+ return 1;
+ }
+ if (wcschr(cmd + 1, L'"') != NULL) {
+ writeError("Error: bad characters in UNO installation path!\n");
+ closeErrorFile();
+ return 1;
+ }
+ wcscpy(
+ cmd + pathsize,
+ (L"\\unoinfo.exe\" c++" +
+ (pathsize == 1 || cmd[pathsize - 1] != L'\\' ? 0 : 1)));
+ sec.nLength = sizeof (SECURITY_ATTRIBUTES);
+ sec.lpSecurityDescriptor = NULL;
+ sec.bInheritHandle = TRUE;
+ if (CreatePipe(&temp, &stdoutWrite, &sec, 0) == 0 ||
+ DuplicateHandle(
+ GetCurrentProcess(), temp, GetCurrentProcess(), &stdoutRead, 0,
+ FALSE, DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS) == 0)
+ {
+ writeError("Error: CreatePipe/DuplicateHandle failed!\n");
+ closeErrorFile();
+ return 1;
+ }
+ memset(&startinfo, 0, sizeof (STARTUPINFOW));
+ startinfo.cb = sizeof (STARTUPINFOW);
+ startinfo.lpDesktop = L"";
+ startinfo.dwFlags = STARTF_USESTDHANDLES;
+ startinfo.hStdOutput = stdoutWrite;
+ ret = CreateProcessW(
+ NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &startinfo, &procinfo);
+ if (ret != 0) {
+ char * buf = NULL;
+ size_t n = 1000;
+ size_t k = 0;
+ DWORD exitcode;
+ int path2size;
+ CloseHandle(stdoutWrite);
+ CloseHandle(procinfo.hThread);
+ for (;;) {
+ DWORD m;
+ buf = realloc(buf, n);
+ if (buf == NULL) {
+ writeError(
+ "Error: out of memory reading unoinfo output!\n");
+ closeErrorFile();
+ return 1;
+ }
+ if (!ReadFile(stdoutRead, buf + k, n - k, &m, NULL))
+ {
+ DWORD err = GetLastError();
+ if (err == ERROR_HANDLE_EOF || err == ERROR_BROKEN_PIPE) {
+ break;
+ }
+ writeError("Error: cannot read unoinfo output!\n");
+ closeErrorFile();
+ return 1;
+ }
+ if (m == 0) {
+ break;
+ }
+ k += m;
+ if (k >= n) {
+ if (n >= SAL_MAX_SIZE / 2) {
+ writeError(
+ "Error: out of memory reading unoinfo output!\n");
+ closeErrorFile();
+ return 1;
+ }
+ n *= 2;
+ }
+ }
+ if ((k & 1) == 1) {
+ writeError("Error: bad unoinfo output!\n");
+ closeErrorFile();
+ return 1;
+ }
+ CloseHandle(stdoutRead);
+ if (!GetExitCodeProcess(procinfo.hProcess, &exitcode) ||
+ exitcode != 0)
+ {
+ writeError("Error: executing unoinfo failed!\n");
+ closeErrorFile();
+ return 1;
+ }
+ if (k == 0) {
+ path2size = 0;
+ } else {
+ path2size = WideCharToMultiByte(
+ CP_ACP, 0, (wchar_t *) buf, k / 2, path2, MAX_PATH - 1,
+ NULL, NULL);
+ if (path2size == 0) {
+ writeError("Error: converting unoinfo output failed!\n");
+ closeErrorFile();
+ return 1;
+ }
+ }
+ path2[path2size] = '\0';
+ path = path2;
+ } else {
+ if (GetLastError() != ERROR_FILE_NOT_FOUND) {
+ writeError("Error: calling unoinfo failed!\n");
+ closeErrorFile();
+ return 1;
+ }
+ CloseHandle(stdoutRead);
+ CloseHandle(stdoutWrite);
+ }
+
+ /* get the value of the PATH environment variable */
+ value = getenv( ENVVARNAME );
+
+ /*
+ * add the UNO installation path to the PATH environment variable;
+ * note that this only affects the environment variable of the current
+ * process, the command processor's environment is not changed
+ */
+ size = strlen( ENVVARNAME ) + strlen( "=" ) + strlen( path ) + 1;
+ if ( value != NULL )
+ size += strlen( PATHSEPARATOR ) + strlen( value );
+ envstr = (char*) malloc( size );
+ strcpy( envstr, ENVVARNAME );
+ strcat( envstr, "=" );
+ strcat( envstr, path );
+ if ( value != NULL )
+ {
+ strcat( envstr, PATHSEPARATOR );
+ strcat( envstr, value );
+ }
+ _putenv( envstr );
+ free( envstr );
+ }
+ else
+ {
+ writeError( "Warning: no UNO installation found!\n" );
+ }
+
+ /* create the command line for the application process */
+ cmdline = createCommandLine( lpCmdLine );
+ if ( cmdline == NULL )
+ {
+ writeError( "Error: cannot create command line!\n" );
+ closeErrorFile();
+ return 1;
+ }
+
+ /* create the application process */
+ memset( &startup_info, 0, sizeof( STARTUPINFO ) );
+ startup_info.cb = sizeof( STARTUPINFO );
+ bCreate = CreateProcess( NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL,
+ &startup_info, &process_info );
+ free( cmdline );
+ if ( !bCreate )
+ {
+ writeError( "Error: cannot create process!\n" );
+ closeErrorFile();
+ return 1;
+ }
+
+ /* close the error file */
+ closeErrorFile();
+
+ return 0;
+}
+
+/*
+ * Gets the path of a UNO installation.
+ *
+ * @return the installation path or NULL, if no installation was specified or
+ * found, or if an error occured
+ */
+char const* getPath()
+{
+ char const* path = cppuhelper_detail_findSofficePath();
+
+ if ( path == NULL )
+ writeError( "Warning: getting path from Windows Registry failed!\n" );
+
+ return path;
+}
+
+/*
+ * Creates the command line for the application process including the absolute
+ * path of the executable.
+ *
+ * <p>The application's executable file name is the name of this executable
+ * prefixed by '_'.</p>
+ *
+ * @param appendix specifies the command line for the application excluding
+ * the executable name
+ *
+ * @return the command line for the application process or NULL, if an error
+ * occured
+ */
+char* createCommandLine( char* appendix )
+{
+ const char* CMDPREFIX = "_";
+ const char* DQUOTE = "\"";
+ const char* SPACE = " ";
+
+ char* cmdline = NULL;
+
+ char cmdname[ _MAX_PATH ];
+ char drive[ _MAX_DRIVE ];
+ char dir[ _MAX_PATH ];
+ char base[ _MAX_FNAME ];
+ char newbase[ _MAX_FNAME ];
+ char ext[ _MAX_EXT ];
+
+ /* get the absolute path of the executable file */
+ if ( GetModuleFileName( NULL, cmdname, sizeof( cmdname ) ) )
+ {
+ /* prefix the executable file name by '_' */
+ _splitpath( cmdname, drive, dir, base, ext );
+ strcpy( newbase, CMDPREFIX );
+ strcat( newbase, base );
+ _makepath( cmdname, drive, dir, newbase, ext );
+
+ /* create the command line */
+ cmdline = (char*) malloc( strlen( DQUOTE ) + strlen( cmdname ) +
+ strlen ( DQUOTE ) + strlen( SPACE ) + strlen( appendix ) + 1 );
+ strcpy( cmdline, DQUOTE );
+ strcat( cmdline, cmdname );
+ strcat( cmdline, DQUOTE );
+ strcat( cmdline, SPACE );
+ strcat( cmdline, appendix );
+ }
+
+ return cmdline;
+}
+
+/*
+ * Gets the pointer to the error file.
+ *
+ * <p>The error file will only be created, if create != 0.</p>
+ *
+ * <p>The error file has the name <executable file name>-error.log and is
+ * created in the same directory as the executable file. If this fails,
+ * the error file is created in the directory designated for temporary files.
+ * </p>
+
+ * @param create specifies, if the error file should be created (create != 0)
+ *
+ * @return the pointer to the open error file or NULL, if no error file is
+ * open or can be created
+ */
+FILE* getErrorFile( int create )
+{
+ const char* MODE = "w";
+ const char* BASEPOSTFIX = "-error";
+ const char* EXTENSION = ".log";
+
+ static FILE* ferr = NULL;
+
+ char fname[ _MAX_PATH ];
+ char drive[ _MAX_DRIVE ];
+ char dir[ _MAX_PATH ];
+ char base[ _MAX_FNAME ];
+ char newbase[ _MAX_FNAME ];
+ char ext[ _MAX_EXT ];
+
+ if ( ferr == NULL && create )
+ {
+ /* get the absolute path of the executable file */
+ if ( GetModuleFileName( NULL, fname, sizeof( fname ) ) )
+ {
+ /* create error file in the directory of the executable file */
+ _splitpath( fname, drive, dir, base, ext );
+ strcpy( newbase, base );
+ strcat( newbase, BASEPOSTFIX );
+ _makepath( fname, drive, dir, newbase, EXTENSION );
+ ferr = fopen( fname, MODE );
+
+ if ( ferr == NULL )
+ {
+ /* create error file in the temp directory */
+ GetTempPath( sizeof( fname ), fname );
+ strcat( fname, newbase );
+ strcat( fname, EXTENSION );
+ ferr = fopen( fname, MODE );
+ }
+ }
+ }
+
+ return ferr;
+}
+
+/*
+ * Writes an error message to the error file.
+ *
+ * @param errstr specifies the error message
+ */
+void writeError( const char* errstr )
+{
+ FILE* ferr = getErrorFile( 1 );
+ if ( ferr != NULL )
+ {
+ fprintf( ferr, errstr );
+ fflush( ferr );
+ }
+}
+
+/*
+ * Closes the error file.
+ */
+void closeErrorFile()
+{
+ FILE* ferr = getErrorFile( 0 );
+ if ( ferr != NULL )
+ fclose( ferr );
+}
diff --git a/odk/source/unowinreg/win/makefile.mk b/odk/source/unowinreg/win/makefile.mk
new file mode 100644
index 000000000000..077d8aa60aac
--- /dev/null
+++ b/odk/source/unowinreg/win/makefile.mk
@@ -0,0 +1,114 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=odk
+TARGET=unowinreg
+ENABLE_EXCEPTIONS=TRUE
+
+NO_DEFAULT_STL=TRUE
+NO_BSYMBOLIC=TRUE
+USE_DEFFILE=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+JAVA_INCLUDES:= -I$(JAVA_HOME)/include
+
+# values taken from set_soenv.in
+.IF "$(OS)" == "LINUX"
+JAVA_INCLUDES+= -I$(JAVA_HOME)/include/linux
+.ELIF "$(OS)" == "FREEBSD"
+JAVA_INCLUDES+= -I$(JAVA_HOME)/include/freebsd
+JAVA_INCLUDES+= -I$(JAVA_HOME)/include/bsd
+JAVA_INCLUDES+= -I$(JAVA_HOME)/include/linux
+.ELIF "$(OS)" == "NETBSD"
+JAVA_INCLUDES+= -I$(JAVA_HOME)/include/netbsd
+.ENDIF
+
+.IF "$(SOLAR_JAVA)"==""
+nojava:
+ @echo "Not building javaunohelper because Java is disabled"
+.ENDIF
+
+.IF "$(OS)" != "WNT"
+
+.IF "$(BUILD_UNOWINREG)" == "YES"
+
+$(BIN)$/unowinreg.dll : unowinreg.cxx
+ $(MINGWCXX) -Wall -D_JNI_IMPLEMENTATION_ $(JAVA_INCLUDES) \
+ -I$(PRJ)/inc/pch -shared -o $(BIN)$/unowinreg.dll unowinreg.cxx \
+ -Wl,--kill-at -lkernel32 -ladvapi32
+ $(MINGWSTRIP) $(BIN)$/unowinreg.dll
+
+.ELSE
+
+$(BIN)$/unowinreg.dll : $(SOLARVERSION)$/$(INPATH)$/bin$(UPDMINOREXT)$/unowinreg.dll
+ @@-rm -f $@
+ $(GNUCOPY) $< $@
+
+.ENDIF
+
+.ELSE # "$(OS)" != "WNT"
+# Always build unowinreg.dll on windows
+
+# --- Files --------------------------------------------------------
+
+LINKFLAGS+=-MANIFEST:NO
+SLOFILES = \
+ $(SLO)$/unowinreg.obj
+SHL1TARGET=$(TARGET)
+SHL1LIBS=$(SLB)$/$(TARGET).lib
+
+#No default libraries
+STDSHL=
+.IF "$(COM)"=="GCC"
+SHL1STDLIBS += -lstdc++
+.IF "$(MINGW_GCCLIB_EH)"=="YES"
+SHL1STDLIBS += -lgcc_eh
+.ENDIF
+SHL1STDLIBS += -lgcc -lmingw32 -lmoldname -lmsvcrt
+.ENDIF
+
+SHL1STDLIBS +=\
+ $(KERNEL32LIB)\
+ $(ADVAPI32LIB)
+
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=$(TARGET).dxp
+DEF1DES=unowinreg
+
+.ENDIF # "$(OS)" != "WNT"
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/odk/source/unowinreg/win/unowinreg.cxx b/odk/source/unowinreg/win/unowinreg.cxx
new file mode 100644
index 000000000000..f2f7239f1432
--- /dev/null
+++ b/odk/source/unowinreg/win/unowinreg.cxx
@@ -0,0 +1,185 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_odk.hxx"
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#include <jni.h>
+
+extern "C" BOOL __stdcall _DllMainCRTStartup(HINSTANCE, DWORD, LPVOID)
+{
+ return TRUE;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL
+ Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenClassesRoot(
+ JNIEnv *env, jclass, jlongArray hkresult)
+{
+ jboolean ret = JNI_FALSE;
+ PHKEY phkey = (PHKEY)env->GetLongArrayElements(hkresult, 0);
+ if (RegOpenKeyEx(HKEY_CLASSES_ROOT, NULL, 0, KEY_READ, phkey)
+ == ERROR_SUCCESS)
+ ret = JNI_TRUE;
+ env->ReleaseLongArrayElements(hkresult, (jlong *)phkey, 0);
+ return ret;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL
+ Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenCurrentConfig(
+ JNIEnv *env, jclass, jlongArray hkresult)
+{
+ jboolean ret = JNI_FALSE;
+ PHKEY phkey = (PHKEY)env->GetLongArrayElements(hkresult, 0);
+ if (RegOpenKeyEx(HKEY_CURRENT_CONFIG, NULL, 0, KEY_READ, phkey)
+ == ERROR_SUCCESS)
+ ret = JNI_TRUE;
+ env->ReleaseLongArrayElements(hkresult, (jlong *)phkey, 0);
+ return ret;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL
+ Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenCurrentUser(
+ JNIEnv *env, jclass, jlongArray hkresult)
+{
+ jboolean ret = JNI_FALSE;
+ PHKEY phkey = (PHKEY)env->GetLongArrayElements(hkresult, 0);
+ if (RegOpenKeyEx(HKEY_CURRENT_USER, NULL, 0, KEY_READ, phkey)
+ == ERROR_SUCCESS)
+ ret = JNI_TRUE;
+ env->ReleaseLongArrayElements(hkresult, (jlong *)phkey, 0);
+ return ret;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL
+ Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenLocalMachine(
+ JNIEnv *env, jclass, jlongArray hkresult)
+{
+ jboolean ret = JNI_FALSE;
+ PHKEY phkey = (PHKEY)env->GetLongArrayElements(hkresult, 0);
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, NULL, 0, KEY_READ, phkey)
+ == ERROR_SUCCESS)
+ ret = JNI_TRUE;
+ env->ReleaseLongArrayElements(hkresult, (jlong *)phkey, 0);
+ return ret;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL
+ Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenUsers(
+ JNIEnv *env, jclass, jlongArray hkresult)
+{
+ jboolean ret = JNI_FALSE;
+ PHKEY phkey = (PHKEY)env->GetLongArrayElements(hkresult, 0);
+ if (RegOpenKeyEx(HKEY_USERS, NULL, 0, KEY_READ, phkey) == ERROR_SUCCESS)
+ ret = JNI_TRUE;
+ env->ReleaseLongArrayElements(hkresult, (jlong *)phkey, 0);
+ return ret;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL
+ Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenKeyEx(
+ JNIEnv *env, jclass, jlong parent, jstring name, jlongArray hkresult)
+{
+ jboolean ret = JNI_FALSE;
+ const char *namestr = env->GetStringUTFChars(name, 0);
+ PHKEY phkey = (PHKEY)env->GetLongArrayElements(hkresult, 0);
+ if (RegOpenKeyEx((HKEY)parent, namestr, 0, KEY_READ, phkey)
+ == ERROR_SUCCESS)
+ ret = JNI_TRUE;
+ env->ReleaseStringUTFChars(name, namestr);
+ env->ReleaseLongArrayElements(hkresult, (jlong *)phkey, 0);
+ return ret;
+}
+
+
+extern "C" JNIEXPORT jboolean JNICALL
+ Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegCloseKey(
+ JNIEnv *, jclass, jlong hkey)
+{
+ jboolean ret = JNI_FALSE;
+ if (RegCloseKey((HKEY)hkey) == ERROR_SUCCESS)
+ ret = JNI_TRUE;
+ return ret;
+}
+
+extern "C" JNIEXPORT jboolean
+ JNICALL Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegQueryValueEx(
+ JNIEnv *env, jclass, jlong hkey, jstring value, jlongArray type,
+ jbyteArray data, jlongArray size)
+{
+ jboolean ret = JNI_FALSE;
+ const char* valuestr = env->GetStringUTFChars(value, 0);
+ LPDWORD ptype = (LPDWORD)env->GetLongArrayElements(type, 0);
+ LPBYTE pdata = (LPBYTE)env->GetByteArrayElements(data, 0);
+ LPDWORD psize = (LPDWORD)env->GetLongArrayElements(size, 0);
+ if (RegQueryValueEx((HKEY)hkey, valuestr, NULL, ptype, pdata, psize)
+ == ERROR_SUCCESS)
+ ret = JNI_TRUE;
+ env->ReleaseStringUTFChars(value, valuestr);
+ env->ReleaseLongArrayElements(type, (jlong *)ptype, 0);
+ env->ReleaseByteArrayElements(data, (jbyte *)pdata, 0);
+ env->ReleaseLongArrayElements(size, (jlong *)psize, 0);
+ return ret;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL
+ Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegQueryInfoKey(
+ JNIEnv *env, jclass, jlong hkey, jlongArray subkeys,
+ jlongArray maxSubkeyLen, jlongArray values, jlongArray maxValueNameLen,
+ jlongArray maxValueLen, jlongArray secDescriptor)
+{
+ jboolean ret = JNI_FALSE;
+ LPDWORD psubkeys = (LPDWORD)env->GetLongArrayElements(subkeys, 0);
+ LPDWORD pmaxSubkeyLen =
+ (LPDWORD)env->GetLongArrayElements(maxSubkeyLen, 0);
+ LPDWORD pvalues = (LPDWORD)env->GetLongArrayElements(values, 0);
+ LPDWORD pmaxValueNameLen =
+ (LPDWORD)env->GetLongArrayElements(maxValueNameLen, 0);
+ LPDWORD pmaxValueLen =
+ (LPDWORD)env->GetLongArrayElements(maxValueLen, 0);
+ LPDWORD psecDescriptor =
+ (LPDWORD)env->GetLongArrayElements(secDescriptor, 0);
+ FILETIME ft;
+ if (RegQueryInfoKey((HKEY)hkey, NULL, NULL, NULL, psubkeys, pmaxSubkeyLen,
+ NULL, pvalues, pmaxValueNameLen, pmaxValueLen,
+ psecDescriptor, &ft) == ERROR_SUCCESS)
+ ret = JNI_TRUE;
+ env->ReleaseLongArrayElements(subkeys, (jlong*)psubkeys, 0);
+ env->ReleaseLongArrayElements(maxSubkeyLen, (jlong*)pmaxSubkeyLen, 0);
+ env->ReleaseLongArrayElements(values, (jlong*)pvalues, 0);
+ env->ReleaseLongArrayElements(maxValueNameLen, (jlong*)pmaxValueNameLen, 0);
+ env->ReleaseLongArrayElements(maxValueLen, (jlong*)pmaxValueLen, 0);
+ env->ReleaseLongArrayElements(secDescriptor, (jlong*)psecDescriptor, 0);
+ return ret;
+}
diff --git a/odk/source/unowinreg/win/unowinreg.dxp b/odk/source/unowinreg/win/unowinreg.dxp
new file mode 100644
index 000000000000..af44919d42a9
--- /dev/null
+++ b/odk/source/unowinreg/win/unowinreg.dxp
@@ -0,0 +1,9 @@
+Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenClassesRoot
+Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenCurrentConfig
+Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenCurrentUser
+Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenLocalMachine
+Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenUsers
+Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenKeyEx
+Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegCloseKey
+Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegQueryValueEx
+Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegQueryInfoKey
diff --git a/odk/util/check.pl b/odk/util/check.pl
new file mode 100644
index 000000000000..6bf3fdd62b2f
--- /dev/null
+++ b/odk/util/check.pl
@@ -0,0 +1,485 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+#
+# check - a perl script to check some files and directories if they exists
+# A first simple check if the SDK was built completely.
+#
+#use IO::File;
+
+$return = 0;
+
+$StartDir = "$ARGV[0]";
+$OperatingSystem = "$ARGV[1]";
+$ExePrefix = "$ARGV[2]";
+
+print "Check for $OperatingSystem\n";
+
+if (-d "$StartDir") {
+ # check binaries
+ print "check binaries: ";
+ if (-d "$StartDir/bin") {
+ my @binarylist = ( "idlc","idlcpp","cppumaker","javamaker",
+ "regcompare","autodoc",
+ "unoapploader", "uno-skeletonmaker" );
+
+ foreach $i (@binarylist)
+ {
+ if (! -e "$StartDir/bin/$i$ExePrefix") {
+ $return++;
+ print "\nERROR: \"$StartDir/bin/$i$ExePrefix\" is missing\n";
+ } else {
+ print "+";
+ }
+ }
+
+ if ($OperatingSystem eq "windows" || $OperatingSystem eq "mingw") {
+ if ($OperatingSystem eq "windows" && ! -e "$StartDir/bin/climaker.exe") {
+ $return++;
+ print "\nERROR: \"$StartDir/bin/climaker.exe\" is missing\n";
+ } else {
+ print "+";
+ }
+ }
+ if ($OperatingSystem eq "macosx") {
+ if (! -e "$StartDir/bin/addsym-macosx.sh") {
+ $return++;
+ print "\nERROR: \"$StartDir/bin/addsym-macosx.sh\" is missing\n";
+ } else {
+ print "+";
+ }
+ }
+ } else {
+ $return++;
+ }
+ print "\n";
+
+ # packaging files
+ print "check packaging files: ";
+ if (-d "$StartDir/docs") {
+ my @filelist = ( "install.html",
+ "notsupported.html","sdk_styles.css","tools.html",
+ "images/arrow-1.gif", "images/arrow-3.gif",
+ "images/odk-footer-logo.gif",
+ "images/bg_table.png","images/bg_table2.png",
+ "images/bg_table3.png", "images/nav_down.png",
+ "images/nav_home.png","images/nav_left.png",
+ "images/nav_right.png","images/nav_up.png",
+ "images/sdk_head-1.png", "images/sdk_head-2.png",
+ "images/sdk_line-1.gif", "images/sdk_line-2.gif",
+ "common/ref/idl.css", "images/nada.gif",
+ "images/arrow-2.gif", "images/bluball.gif",
+ "images/orc-main-app_32.png", "images/ooo-main-app_32.png");
+
+ foreach $i (@filelist)
+ {
+ if (! -e "$StartDir/docs/$i") {
+ $return++;
+ print "\nERROR: \"$StartDir/docs/$i\" is missing\n";
+ } else {
+ print "+";
+ }
+ }
+ } else {
+ $return++;
+ }
+ print "\n";
+
+ #check configure files
+ print "check config files: ";
+ if ($OperatingSystem eq "windows" || $OperatingSystem eq "mingw") {
+ if (! -e "$StartDir/setsdkenv_windows.bat") {
+ print "\nERROR: \"$StartDir/setsdkenv_windows.bat\" is missing\n";
+ $return++;
+ }
+ if (! -e "$StartDir/setsdkenv_windows.template") {
+ print "\nERROR: \"$StartDir/setsdkenv_windows.template\" is missing\n";
+ $return++;
+ }
+ if (! -e "$StartDir/cfgWin.js") {
+ print "\nERROR: \"$StartDir/cfgWin.js\" is missing\n";
+ $return++;
+ }
+ } else {
+ if (! -e "$StartDir/configure.pl") {
+ print "\nERROR: \"$StartDir/configure.pl\" is missing\n";
+ $return++;
+ }
+ if (! -e "$StartDir/config.guess") {
+ print "\nERROR: \"$StartDir/config.guess\" is missing\n";
+ $return++;
+ }
+ if (! -e "$StartDir/config.sub") {
+ print "\nERROR: \"$StartDir/config.sub\" is missing\n";
+ $return++;
+ }
+ if (! -e "$StartDir/setsdkenv_unix") {
+ print "\nERROR: \"$StartDir/setsdkenv_unix\" is missing\n";
+ $return++;
+ }
+ if (! -e "$StartDir/setsdkenv_unix.sh.in") {
+ print "\nERROR: \"$StartDir/setsdkenv_unix.sh.in\" is missing\n";
+ $return++;
+ }
+ if (! -e "$StartDir/setsdkenv_unix.csh.in") {
+ print "\nERROR: \"$StartDir/setsdkenv_unix.csh.in\" is missing\n";
+ $return++;
+ }
+ }
+ print "\n";
+
+ #check setting files
+ print "check setting files: ";
+ if (-d "$StartDir/settings") {
+ if (! -e "$StartDir/settings/settings.mk") {
+ print "\nERROR: \"$StartDir/settings/settings.mk\" is missing\n";
+ $return++;
+ }
+ if (! -e "$StartDir/settings/std.mk") {
+ print "\nERROR: \"$StartDir/settings/std.mk\" is missing\n";
+ $return++;
+ }
+ if (! -e "$StartDir/settings/stdtarget.mk") {
+ print "\nERROR: \"$StartDir/settings/stdtarget.mk\" is missing\n";
+ $return++;
+ }
+ } else {
+ $return++;
+ }
+ print "\n";
+
+ #check cpp docu, it is only a first and simple check
+ # improvement required
+ print "check cpp docu: ";
+ if (-d "$StartDir/docs/cpp/ref") {
+ if (! -e "$StartDir/docs/cpp/ref/index.html") {
+ print "\nERROR: \"$StartDir/docs/cpp/ref/index.html\" is missing\n";
+ $return++;
+ }
+ if (! -d "$StartDir/docs/cpp/ref/index-files") {
+ print "\nERROR: \"$StartDir/docs/cpp/ref/index-files\" is missing\n";
+ $return++;
+ }
+ if (! -e "$StartDir/docs/cpp/ref/index-files/index-10.html") {
+ print "\nERROR: \"$StartDir/docs/cpp/ref/index-files/index-10.html\" is missing\n";
+ $return++;
+ }
+
+ my @dir_list = ( "com","com/sun","com/sun/star","com/sun/star/uno",
+ "com/sun/star/uno/Any","com/sun/star/uno/Type",
+ "com/sun/star/uno/Array","com/sun/star/uno/WeakReferenceHelper",
+ "com/sun/star/uno/Reference","com/sun/star/uno/WeakReference",
+ "com/sun/star/uno/Environment","com/sun/star/uno/Sequence",
+ "com/sun/star/uno/BaseReference","com/sun/star/uno/Mapping",
+ "com/sun/star/uno/ContextLayer","com/sun/star/uno/TypeDescription",
+ "osl","osl/File","osl/Pipe","osl/FileStatus","osl/FileBase",
+ "osl/Guard","osl/Mutex","osl/VolumeInfo","osl/GetGlobalMutex",
+ "osl/Security","osl/Profile","osl/DatagramSocket","osl/SocketAddr",
+ "osl/StreamPipe","osl/ResettableGuard","osl/AcceptorSocket",
+ "osl/ClearableGuard","osl/VolumeDevice","rtl","rtl/Uri","rtl/math",
+ "rtl/OUStringHash","rtl/MalformedUriException","rtl/OUStringBuffer",
+ "rtl/OUString","rtl/Reference","rtl/ByteSequence","rtl/OLocale",
+ "rtl/Logfile","rtl/OString","rtl/IReference","rtl/OStringBuffer",
+ "rtl/OStringHash","_typelib_CompoundTypeDescription","cppu",
+ "cppu/ContextEntry_Init","cppu/ImplInheritanceHelper10",
+ "cppu/ImplInheritanceHelper11","cppu/ImplInheritanceHelper12",
+ "cppu/WeakAggImplHelper1","cppu/WeakAggImplHelper2",
+ "cppu/WeakAggImplHelper3","cppu/WeakAggImplHelper4",
+ "cppu/WeakAggImplHelper5","cppu/WeakAggImplHelper6",
+ "cppu/WeakAggImplHelper7","cppu/WeakAggImplHelper8",
+ "cppu/WeakAggImplHelper9",
+ "cppu/OMultiTypeInterfaceContainerHelperInt32","cppu/AccessControl",
+ "cppu/OPropertyArrayHelper","cppu/ImplHelper1","cppu/ImplHelper2",
+ "cppu/ImplHelper3","cppu/ImplHelper4","cppu/ImplHelper5",
+ "cppu/ImplHelper6","cppu/ImplHelper7","cppu/ImplHelper8",
+ "cppu/ImplHelper9","cppu/WeakComponentImplHelper10",
+ "cppu/WeakComponentImplHelper11","cppu/WeakComponentImplHelper12",
+ "cppu/UnoUrl","cppu/WeakComponentImplHelper1",
+ "cppu/WeakComponentImplHelper2","cppu/WeakComponentImplHelper3",
+ "cppu/WeakComponentImplHelper4","cppu/WeakComponentImplHelper5",
+ "cppu/WeakComponentImplHelper6","cppu/WeakComponentImplHelper7",
+ "cppu/WeakComponentImplHelper8","cppu/WeakComponentImplHelper9",
+ "cppu/OInterfaceIteratorHelper",
+ "cppu/OMultiTypeInterfaceContainerHelper","cppu/UnoUrlDescriptor",
+ "cppu/IPropertyArrayHelper","cppu/OBroadcastHelperVar",
+ "cppu/OComponentHelper","cppu/OWeakAggObject",
+ "cppu/ImplementationEntry","cppu/WeakImplHelper10",
+ "cppu/WeakImplHelper11","cppu/WeakImplHelper12",
+ "cppu/OPropertySetHelper","cppu/ImplHelper10","cppu/ImplHelper11",
+ "cppu/ImplHelper12","cppu/WeakAggImplHelper10",
+ "cppu/WeakAggImplHelper11","cppu/WeakAggImplHelper12",
+ "cppu/ImplInheritanceHelper1","cppu/ImplInheritanceHelper2",
+ "cppu/ImplInheritanceHelper3","cppu/ImplInheritanceHelper4",
+ "cppu/ImplInheritanceHelper5","cppu/ImplInheritanceHelper6",
+ "cppu/ImplInheritanceHelper7","cppu/ImplInheritanceHelper8",
+ "cppu/ImplInheritanceHelper9","cppu/OTypeCollection",
+ "cppu/WeakAggComponentImplHelper10",
+ "cppu/WeakAggComponentImplHelper11",
+ "cppu/WeakAggComponentImplHelper12",
+ "cppu/WeakAggComponentImplHelper1",
+ "cppu/WeakAggComponentImplHelper2",
+ "cppu/WeakAggComponentImplHelper3",
+ "cppu/WeakAggComponentImplHelper4",
+ "cppu/WeakAggComponentImplHelper5",
+ "cppu/WeakAggComponentImplHelper6",
+ "cppu/WeakAggComponentImplHelper7",
+ "cppu/WeakAggComponentImplHelper8",
+ "cppu/WeakAggComponentImplHelper9",
+ "cppu/OMultiTypeInterfaceContainerHelperVar",
+ "cppu/OInterfaceContainerHelper","cppu/OImplementationId",
+ "cppu/AggImplInheritanceHelper1","cppu/AggImplInheritanceHelper2",
+ "cppu/AggImplInheritanceHelper3","cppu/AggImplInheritanceHelper4",
+ "cppu/AggImplInheritanceHelper5","cppu/AggImplInheritanceHelper6",
+ "cppu/AggImplInheritanceHelper7","cppu/AggImplInheritanceHelper8",
+ "cppu/AggImplInheritanceHelper9","cppu/AggImplInheritanceHelper10",
+ "cppu/AggImplInheritanceHelper11","cppu/AggImplInheritanceHelper12",
+ "cppu/WeakImplHelper1","cppu/WeakImplHelper2","cppu/WeakImplHelper3",
+ "cppu/WeakImplHelper4","cppu/WeakImplHelper5","cppu/WeakImplHelper6",
+ "cppu/WeakImplHelper7","cppu/WeakImplHelper8","cppu/WeakImplHelper9",
+ "cppu/OWeakObject","__store_FindData","_rtl_StandardModuleCount",
+ "RTUik","RTConstValue","_typelib_TypeDescriptionReference",
+ "_typelib_InterfaceMethodTypeDescription","store","RegistryKey",
+ "_typelib_Union_Init","_sal_Sequence","_typelib_Parameter_Init",
+ "_typelib_TypeDescription","_uno_Environment",
+ "_typelib_InterfaceAttributeTypeDescription",
+ "_rtl_ModuleCount","_uno_ExtEnvironment",
+ "_typelib_IndirectTypeDescription",
+ "Registry_Api","_oslFileStatus",
+ "_typelib_InterfaceMemberTypeDescription","RegistryValueList",
+ "RegistryTypeWriter_Api","_rtl_TextEncodingInfo",
+ "namespace_anonymous_1",
+ "_oslVolumeInfo","_uno_Interface",
+ "_typelib_InterfaceTypeDescription","_uno_Mapping","Registry",
+ "RegistryTypeReader_Api","_typelib_Uik",
+ "_typelib_ArrayTypeDescription",
+ "RegistryKeyArray","RegistryTypeReader","RegistryKeyNames",
+ "RTConstValueUnion","_typelib_UnionTypeDescription","_uno_Any",
+ "RegistryTypeWriter","_rtl_Locale","_typelib_CompoundMember_Init",
+ "_typelib_EnumTypeDescription","_typelib_MethodParameter");
+
+ foreach $i (@dir_list)
+ {
+ if (! -d "$StartDir/docs/cpp/ref/names/$i") {
+ $return++;
+ print "\nERROR: \"$StartDir/docs/cpp/ref/names/$i\" is missing\n";
+ } else {
+ print "+";
+ }
+ }
+ } else {
+ $return++;
+ }
+ print "\n";
+
+ #check java docu, it is only a first and simple check
+ # improvement required
+ my $solar_java = $ENV{"SOLAR_JAVA"};
+ my $JDK = $ENV{"JDK"};
+ if (defined($solar_java) && $solar_java ne "" && (!defined($JDK) || $JDK ne "gcj")) {
+ print "check java docu: ";
+ if (-d "$StartDir/docs/java/ref") {
+ if (! -e "$StartDir/docs/java/ref/index.html") {
+ print "\nERROR: \"$StartDir/docs/java/ref/index.html\" is missing\n";
+ $return++;
+ }
+
+ my @dir_list = ( "lib","lib/uno","lib/uno/helper","lib/uno/helper/class-use",
+ "uno","uno/class-use","comp","comp/helper",
+ "comp/helper/class-use");
+
+ foreach $i (@dir_list)
+ {
+ if (! -d "$StartDir/docs/java/ref/com/sun/star/$i") {
+ $return++;
+ print "\nERROR: \"$StartDir/docs/java/ref/com/sun/star/$i\" is missing\n";
+ } else {
+ print "+";
+ }
+ }
+ } else {
+ $return++;
+ }
+ print "\n";
+ }
+
+ #check idl docu, it is only a first and simple check
+ # improvement required
+ print "check idl docu: ";
+ if (-d "$StartDir/docs/common/ref") {
+ if (! -e "$StartDir/docs/common/ref/module-ix.html") {
+ print "\nERROR: \"$StartDir/docs/common/ref/module-ix.html\" is missing\n";
+ $return++;
+ }
+ if (! -d "$StartDir/docs/common/ref/index-files") {
+ print "\nERROR: \"$StartDir/docs/common/ref/index-files\" is missing\n";
+ $return++;
+ }
+ if (! -e "$StartDir/docs/common/ref/index-files/index-10.html") {
+ print "\nERROR: \"$StartDir/docs/common/ref/index-files/index-10.html\" is missing\n";
+ $return++;
+ }
+
+ my @idl_dirlist = ( "accessibility",
+ "animations",
+ "auth",
+ "awt",
+ "awt/tree",
+ "beans",
+ "bridge",
+ "bridge/oleautomation",
+ "chart",
+ "chart2",
+ "chart2/data",
+ "configuration",
+ "configuration/backend",
+ "configuration/backend/xml",
+ "configuration/bootstrap",
+ "connection",
+ "container",
+ "datatransfer",
+ "datatransfer/clipboard",
+ "datatransfer/dnd",
+ "deployment",
+ "deployment/ui",
+ "document",
+ "drawing",
+ "drawing/framework",
+ "embed",
+ "form",
+ "form/binding",
+ "form/component",
+ "form/control",
+ "form/inspection",
+ "form/runtime",
+ "form/submission",
+ "form/validation",
+ "formula",
+ "frame",
+ "frame/status",
+ "gallery",
+ "geometry",
+ "graphic",
+ "i18n",
+ "image",
+ "inspection",
+ "installation",
+ "io",
+ "java",
+ "lang",
+ "ldap",
+ "linguistic2",
+ "loader",
+ "logging",
+ "mail",
+ "media",
+ "mozilla",
+ "packages",
+ "packages/manifest",
+ "packages/zip",
+ "plugin",
+ "presentation",
+ "reflection",
+ "registry",
+ "rendering",
+ "report",
+ "report/inspection",
+ "resource",
+ "scanner",
+ "script",
+ "script/browse",
+ "script/provider",
+ "sdb",
+ "sdb/application",
+ "sdb/tools",
+ "sdbc",
+ "sdbcx",
+ "security",
+ "setup",
+ "sheet",
+ "smarttags",
+ "style",
+ "svg",
+ "sync",
+ "sync2",
+ "system",
+ "table",
+ "task",
+ "test",
+ "test/bridge",
+ "test/performance",
+ "text",
+ "text/fieldmaster",
+ "text/textfield",
+ "text/textfield/docinfo",
+ "ucb",
+ "ui",
+ "ui/dialogs",
+ "uno",
+ "uri",
+ "util",
+ "util/logging",
+ "view",
+ "xforms",
+ "xml",
+ "xml/crypto",
+ "xml/crypto/sax",
+ "xml/csax",
+ "xml/dom",
+ "xml/dom/events",
+ "xml/dom/views",
+ "xml/input",
+ "xml/sax",
+ "xml/wrapper",
+ "xml/xpath",
+ "xsd" );
+
+ foreach $i (@idl_dirlist)
+ {
+ if (! -d "$StartDir/docs/common/ref/com/sun/star/$i") {
+ $return++;
+ print "\nERROR: \"$StartDir/docs/common/ref/com/sun/star/$i\" is missing\n";
+ } else {
+ print "+";
+ }
+ }
+ } else {
+ $return++;
+ }
+ print "\n";
+
+} else {
+ $return++;
+}
+
+if( $return != 0 )
+{
+ print "ERROR\n";
+ unlink "$ARGV[3]";
+} else {
+ print "OK\n";
+}
+exit $return;
diff --git a/odk/util/checkdiff.pl b/odk/util/checkdiff.pl
new file mode 100644
index 000000000000..33d38ff80f32
--- /dev/null
+++ b/odk/util/checkdiff.pl
@@ -0,0 +1,62 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+#
+# checkit - a perl script to check the output of 'dircmp'
+#
+
+$return = 0;
+$possible_error = 0;
+$possible_error_descript = "";
+while( <STDIN> )
+{
+ if( /^diff/ )
+ {
+ $possible_error = 1;
+ $possible_error_descript = $_;
+ }
+ elsif( /^Binary/ )
+ {
+ print STDERR "ERROR : $_";
+ $return++;
+ }
+ elsif( /^[0-9]/ && $possible_error == 1 )
+ {
+ print STDERR "ERROR : diff ".$possible_error_descript;
+ $return++;
+ $possible_error = 0;
+ }
+ else
+ {
+ $possible_error = 0;
+ }
+}
+if( $return != 0 )
+{
+ unlink "$ARGV[0]";
+}
+exit $return;
diff --git a/odk/util/delzip b/odk/util/delzip
new file mode 100644
index 000000000000..8b137891791f
--- /dev/null
+++ b/odk/util/delzip
@@ -0,0 +1 @@
+
diff --git a/odk/util/makefile.mk b/odk/util/makefile.mk
new file mode 100644
index 000000000000..7f6517ed42a8
--- /dev/null
+++ b/odk/util/makefile.mk
@@ -0,0 +1,58 @@
+PRJ=..
+PRJNAME=odk
+TARGET=odk
+
+# ------------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: makefile.pmk
+# ------------------------------------------------------------------
+.IF "$(L10N_framework)"==""
+
+ZIP1TARGET=odkexamples
+ZIP1FLAGS=-u -r
+ZIP1DIR=$(PRJ)
+ZIP1LIST=examples -x "*.svn*" -x "*CVS*" -x "*makefile.mk" -x "*Inspector*" -x "*Container1*" -x "*Storage*" -x "*register_component*" -x "*examples.html" -x "*ConverterServlet*" -x "*NotesAccess*" -x "*delphi*"
+
+.ENDIF
+
+.INCLUDE : target.mk
+.IF "$(L10N_framework)"==""
+ALLTAR:\
+ $(BIN)$/$(PRODUCTZIPFILE)
+# $(BIN)$/odk_oo.zip
+.ENDIF
+
+$(BIN)$/$(PRODUCTZIPFILE) : $(SDK_CONTENT_CHECK_FILES) $(SDK_CHECK_FLAGS)
+ cd $(BIN)$/$(PRODUCT_NAME) && zip -urq ..$/$(PRODUCTZIPFILE) . $(CHECKZIPRESULT)
+ $(PERL) -w $(SOLARENV)$/bin$/cleanzip.pl $@
+# cd $(BIN)$/$(PRODUCT_NAME) && zip -urq ..$/$(PRODUCTZIPFILE) . -x "idl/*" $(CHECKZIPRESULT)
+# cd $(BIN)$/$(PRODUCT_NAME) && zip -urq ..$/odkidl.zip idl/* $(CHECKZIPRESULT)
+
+ODK_OO_FILES=\
+ $(PRJ)$/index.html \
+ $(PRJ)$/docs$/tools.html \
+ $(PRJ)$/docs$/notsupported.html \
+ $(PRJ)$/docs$/install.html \
+ $(PRJ)$/docs$/sdk_styles.css \
+ $(PRJ)$/docs$/images$/arrow-1.gif \
+ $(PRJ)$/docs$/images$/arrow-3.gif \
+ $(PRJ)$/docs$/images$/bg_table.gif \
+ $(PRJ)$/docs$/images$/bg_table2.gif \
+ $(PRJ)$/docs$/images$/bg_table3.gif \
+ $(PRJ)$/docs$/images$/nav_down.png \
+ $(PRJ)$/docs$/images$/nav_home.png \
+ $(PRJ)$/docs$/images$/nav_left.png \
+ $(PRJ)$/docs$/images$/nav_right.png \
+ $(PRJ)$/docs$/images$/nav_up.png \
+ $(PRJ)$/docs$/images$/sdk_head-1.gif \
+ $(PRJ)$/docs$/images$/sdk_head-2.gif \
+ $(PRJ)$/docs$/images$/sdk_head-3.gif \
+ $(PRJ)$/docs$/images$/sdk_line-1.gif \
+ $(PRJ)$/docs$/images$/sdk_line-2.gif \
+ $(PRJ)$/examples$/examples.html \
+ $(PRJ)$/examples$/DevelopersGuide$/examples.html
+
+
+$(BIN)$/odk_oo.zip : $(ODK_OO_FILES)
+ cd $(PRJ) && zip -urq $(subst,$(PRJ)$/, $(BIN)$/odk_oo.zip) $(subst,$(PRJ)$/, $<) $(CHECKZIPRESULT)
+
diff --git a/odk/util/makefile.pmk b/odk/util/makefile.pmk
new file mode 100644
index 000000000000..deb4e6d62c5e
--- /dev/null
+++ b/odk/util/makefile.pmk
@@ -0,0 +1,223 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+# used for sdk common files
+PRODUCT_RELEASE=3.3
+OFFICENAME=OpenOffice.org
+SDKDIRNAME=openoffice.org$(PRODUCT_RELEASE)_sdk
+OFFICEPRODUCTNAME=$(OFFICENAME) $(PRODUCT_RELEASE)
+TITLE=$(OFFICENAME) $(PRODUCT_RELEASE) SDK
+IDLDOCREFNAME="$(OFFICENAME) $(PRODUCT_RELEASE) API"
+
+
+PRODUCT_NAME=odkcommon
+PRODUCTZIPFILE=$(PRODUCT_NAME).zip
+
+DESTDIR=$(OUT)/bin/$(PRODUCT_NAME)
+DESTDIRBIN=$(DESTDIR)/bin
+DESTDIRLIB=$(DESTDIR)/lib
+DESTDIRDLL=$(DESTDIRLIB)
+DESTDIRIDL=$(DESTDIR)/idl
+DESTDIRINC=$(DESTDIR)/include
+DESTDIRJAR=$(DESTDIR)/classes
+DESTDIRXML=$(DESTDIR)/xml
+DESTDIRSETTINGS=$(DESTDIR)/settings
+DESTDIREXAMPLES=$(DESTDIR)/examples
+DESTDIRINC=$(DESTDIR)/include
+DESTDIRCLASSES=$(DESTDIR)/classes
+DESTDIRDOCU=$(DESTDIR)/docs
+DESTDIRCOMMONDOCU=$(DESTDIRDOCU)/common
+DESTDIRGENIDLREF=$(DESTDIRCOMMONDOCU)/ref
+DESTDIRDOCUIMAGES=$(DESTDIRDOCU)/images
+DESTDIRCPPDOCU=$(DESTDIRDOCU)/cpp
+DESTDIRGENCPPREF=$(DESTDIRDOCU)/cpp/ref
+DESTDIRJAVADOCU=$(DESTDIRDOCU)/java
+DESTDIRGENJAVAREF=$(DESTDIRDOCU)/java/ref
+
+BINOUT=$(SOLARBINDIR)
+INCOUT=$(SOLARINCDIR)
+IDLOUT=$(SOLARIDLDIR)
+XMLOUT=$(SOLARXMLDIR)
+LIBOUT=$(SOLARLIBDIR)
+
+CONVERTTAGSCRIPT=$(SOLARENV)/bin/converttags.pl
+CONVERTTAGFLAGNAME=converttags_html_files.flag
+CONVERTTAGFLAG = $(MISC)/$(CONVERTTAGFLAGNAME)
+
+MY_AUTODOC=$(AUGMENT_LIBRARY_PATH) $(WRAPCMD) $(SOLARBINDIR)/autodoc
+
+.IF "$(OS)"=="FREEBSD" || "$(OS)"=="NETBSD"
+MY_COPY=$(GNUCOPY)
+MY_COPY_RECURSIVE=$(GNUCOPY) -r
+.ELSE
+.IF "$(OS)"=="MACOSX"
+MY_COPY=$(GNUCOPY)
+MY_COPY_RECURSIVE=$(GNUCOPY) -r
+.ELSE
+MY_COPY=$(GNUCOPY) -u
+MY_COPY_RECURSIVE=$(GNUCOPY) -urf
+.ENDIF
+.ENDIF
+
+MY_DELETE_RECURSIVE=rm -rf
+MY_TEXTCOPY=@cp
+
+.IF "$(GUI)"=="WNT"
+#--------------------
+# WNT ONLY
+#--------------------
+#MY_DELETE_RECURSIVE=+del /sxyf
+#MY_TEXTCOPY=cat
+
+MY_DLLPREFIX=
+MY_DLLPOSTFIX=.dll
+MY_DLLOUT=$(OUT)/bin
+EXEPOSTFIX=.exe
+DLLOUT=$(SOLARBINDIR)
+DESTDIRCPPEXAMPLES=$(DESTDIR)/examples/cpp
+
+.IF "$(COM)"=="GCC"
+DESTPLATFROM=mingw
+.ELSE
+DESTPLATFROM=windows
+.ENDIF
+DESTDIRDLL=$(DESTDIRBIN)
+DESTDIRCLI=$(DESTDIR)/cli
+
+.ELSE
+#--------------------
+# UNX ONLYDESTDIRCPPEXAMPLES=$(DESTDIR)/examples/cpp
+
+#--------------------
+#MY_DELETE_RECURSIVE=rm -rf
+#MY_TEXTCOPY= tr -d "\015"
+
+MY_DLLPREFIX=lib
+.IF "$(OS)"=="MACOSX"
+MY_DLLPOSTFIX=.dylib
+.ELSE
+MY_DLLPOSTFIX=.so
+.ENDIF
+MY_DLLOUT=$(OUT)/lib
+DLLOUT=$(SOLARLIBDIR)
+
+.IF "$(OS)$(CPU)"=="SOLARISS"
+##############
+# SOLARIS SPARC
+##############
+DESTPLATFROM=solsparc
+
+.ELIF "$(OS)$(CPU)"=="SOLARISU"
+##############
+# SOLARIS SPARC 64
+##############
+DESTPLATFROM=solsparc64
+
+.ELIF "$(OS)$(CPU)"=="SOLARISI"
+##########
+# SOLARIS INTEL
+##########
+DESTPLATFROM=solintel
+
+.ELIF "$(OS)"=="LINUX"
+###########
+# LINUX
+###########
+DESTPLATFROM=linux
+
+.ELIF "$(OS)"=="NETBSD"
+###########
+# NETBSD
+###########
+DESTPLATFROM=netbsd
+
+.ELIF "$(OS)"=="FREEBSD"
+###########
+# FREEBSD
+###########
+DESTPLATFROM=freebsd
+
+.ELIF "$(OS)"=="MACOSX"
+###########
+# MACOSX
+###########
+DESTPLATFROM=macosx
+.ENDIF
+
+#DESTDIRBIN=$(DESTDIR)/$(DESTPLATFROM)/bin
+#DESTDIRLIB=$(DESTDIR)/$(DESTPLATFROM)/lib
+#DESTDIRDLL=$(DESTDIRLIB)
+
+.ENDIF
+
+#MY_TEXTCOPY_SOURCEPRE=<
+#MY_TEXTCOPY_TARGETPRE=>
+
+
+INCLUDETOPDIRLIST= \
+ $(INCOUT)/sal \
+ $(INCOUT)/salhelper \
+ $(INCOUT)/rtl \
+ $(INCOUT)/osl \
+ $(INCOUT)/store \
+ $(INCOUT)/typelib \
+ $(INCOUT)/uno \
+ $(INCOUT)/cppu \
+ $(INCOUT)/cppuhelper \
+ $(INCOUT)/registry \
+ $(INCOUT)/stl
+
+.IF "$(GUI)"=="WNT"
+INCLUDETOPDIRLIST += $(INCOUT)/systools
+.ENDIF
+
+INCLUDEDIRLIST:={$(subst,/,/ $(shell @$(FIND) $(INCLUDETOPDIRLIST) -type d -print))}
+
+INCLUDEFILELIST=\
+ $(INCOUT)/com/sun/star/uno/Any.h \
+ $(INCOUT)/com/sun/star/uno/Any.hxx \
+ $(INCOUT)/com/sun/star/uno/genfunc.h \
+ $(INCOUT)/com/sun/star/uno/genfunc.hxx \
+ $(INCOUT)/com/sun/star/uno/Reference.h \
+ $(INCOUT)/com/sun/star/uno/Reference.hxx \
+ $(INCOUT)/com/sun/star/uno/Sequence.h \
+ $(INCOUT)/com/sun/star/uno/Sequence.hxx \
+ $(INCOUT)/com/sun/star/uno/Type.h \
+ $(INCOUT)/com/sun/star/uno/Type.hxx
+
+INCLUDELIST:=\
+ {$(shell @$(FIND) $(INCLUDETOPDIRLIST) -type f ! \( -name "*~" -o -name "*build.lst" -o -name "*deliver.log" \) -print)} \
+ $(INCLUDEFILELIST)
+
+SDK_CONTENT_CHECK_FILES= \
+ $(MISC)/copying_files.txt
+
+SDK_CHECK_FLAGS= \
+ $(MISC)/checkbin.txt \
+ $(MISC)/checkidl.txt \
+ $(MISC)/checkinc.txt \
+ $(MISC)/checkinc2.txt
diff --git a/odk/util/odk_rules.pmk b/odk/util/odk_rules.pmk
new file mode 100644
index 000000000000..bb62664053f1
--- /dev/null
+++ b/odk/util/odk_rules.pmk
@@ -0,0 +1,193 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+
+$(DESTDIRDOCU)/%.html : $(PRJ)/docs/%.html
+ @@-rm -f $@
+ tr -d "\015" < $< | sed -e 's/%PRODUCT_RELEASE%/$(PRODUCT_RELEASE)/g' > $@
+
+$(DESTDIREXAMPLES)/%.html : $(PRJ)/examples/%.html
+ @@-rm -f $@
+ tr -d "\015" < $< | sed -e 's/%PRODUCT_RELEASE%/$(PRODUCT_RELEASE)/g' > $@
+
+$(DESTDIR)/index.html : $(PRJ)/index.html
+ @@-rm -f $@
+ tr -d "\015" < $< | sed -e 's/%PRODUCT_RELEASE%/$(PRODUCT_RELEASE)/g' > $@
+
+$(DESTDIRDOCU)/%.css : $(PRJ)/docs/%.css
+ @@-rm -f $@
+ $(MY_TEXTCOPY) $< $@
+
+$(DESTDIRDOCUIMAGES)/% : $(PRJ)/docs/images/%
+ @@-rm -f $@
+ $(MY_COPY) $< $@
+
+$(DESTDIR)/configure : $(PRJ)/configure
+ @@-rm -f $@
+ $(MY_TEXTCOPY) $(PRJ)/configure $@
+
+$(DESTDIR)/configure.pl : $(PRJ)/configure.pl
+ @@-rm -f $@
+ $(MY_TEXTCOPY) $(PRJ)/configure.pl $@
+
+$(DESTDIR)/config.guess : $(SRC_ROOT)/config.guess
+ @@-rm -f $@
+ $(MY_TEXTCOPY) $(SRC_ROOT)/config.guess $@
+
+$(DESTDIR)/config.sub : $(SRC_ROOT)/config.sub
+ @@-rm -f $@
+ $(MY_TEXTCOPY) $(SRC_ROOT)/config.sub $@
+
+$(DESTDIR)/setsdkenv_unix : $(PRJ)/setsdkenv_unix
+ @@-rm -f $@
+ $(MY_TEXTCOPY) $< $@
+
+$(DESTDIR)/setsdkenv_unix.%.in : $(PRJ)/setsdkenv_unix.%.in
+ @@-rm -f $@
+ $(MY_TEXTCOPY) $< $@
+
+$(DESTDIR)/setsdkenv_windows.bat : $(PRJ)/setsdkenv_windows.bat
+ @@-rm -f $@
+ $(TYPE) $< | $(SED) 's#__SDKNAME__#$(SDKDIRNAME)#' > $@
+
+$(DESTDIR)/%.bat : $(PRJ)/%.bat
+ @@-rm -f $@
+ $(MY_TEXTCOPY) $< $@
+
+$(DESTDIR)/setsdkenv_windows.template : $(PRJ)/setsdkenv_windows.template
+ @@-rm -f $@
+ $(MY_TEXTCOPY) $< $@
+
+$(DESTDIR)/cfgWin.js : $(PRJ)/cfgWin.js
+ @@-rm -f $@
+ $(MY_TEXTCOPY) $(PRJ)/cfgWin.js $@
+
+$(DESTDIRSETTINGS)/%.mk : $(PRJ)/settings/%.mk
+ @@-rm -f $@
+.IF "$(COMEX)"=="7"
+ $(MY_TEXTCOPY) $< | $(SED) -e 's/stlport_vc7/stlport_vc6/' $@
+.ELSE
+ $(MY_TEXTCOPY) $< $@
+.ENDIF
+
+$(DESTDIRXML)/module-description.dtd : $(XMLOUT)/module-description.dtd
+ @@-rm -f $@
+ $(MY_TEXTCOPY) $(XMLOUT)/module-description.dtd $@
+$(DESTDIRXML)/%.xml : $(XMLOUT)/%.xml
+ @@-rm -f $@
+ $(MY_TEXTCOPY) $< $@
+
+$(DESTDIRBIN)/%$(EXEPOSTFIX) : $(BINOUT)/%$(EXEPOSTFIX)
+ @@-rm -f $@
+ $(GNUCOPY) $(BINOUT)/$(@:f) $@
+
+$(DESTDIRBIN)/%.bin : $(BINOUT)/%.bin
+ @@-rm -f $@
+ $(GNUCOPY) $(BINOUT)/$(@:f) $@
+
+$(DESTDIRBIN)/regcomp : $(BINOUT)/regcomp
+ @@-rm -f $@
+ $(MY_TEXTCOPY) $< $@
+
+$(DESTDIRBIN)/unoapploader$(EXEPOSTFIX) : $(BIN)/unoapploader$(EXEPOSTFIX)
+ @@-rm -f $@
+ $(GNUCOPY) $(BIN)/$(@:f) $@
+
+# special rule for special Java UNO native library
+# (used for all platforms but built only under windows;
+# otherwise provided in external)
+$(DESTDIRJAR)/win/unowinreg.dll : $(BIN)/unowinreg.dll
+ @@-rm -f $@
+ $(GNUCOPY) $< $@
+
+$(DESTDIRCLI)/%.dll : $(BINOUT)/%.dll
+ @@-rm -f $@
+ $(GNUCOPY) $< $@
+
+$(DESTDIRDLL)/%$(MY_DLLPOSTFIX) : $(DLLOUT)/%$(MY_DLLPOSTFIX)
+ @@-rm -f $@
+ $(GNUCOPY) $(DLLOUT)/$(@:f) $@
+
+$(DESTDIRJAR)/com/sun/star/lib/loader/%.class : $(CLASSDIR)/com/sun/star/lib/loader/%.class
+ @@-$(RM) $(@:db).class
+ $(COPY) $(<:db).class $(@:d)
+# deal with subclasses
+ @@-$(RM) $(@:db)$(EMQ)$$*.class
+ -$(COPY) $(<:db)$(EMQ)$$*.class $(@:d)
+
+$(DESTDIRIDL)/% : $(IDLOUT)/%
+ $(MY_TEXTCOPY) $< $@
+# @touch $(IDL_DOCU_CLEANUP_FLAG)
+
+$(DESTDIRINC)/udkversion.mk :
+ @@-rm -f $@
+ @echo #UDK version number > $@
+ @echo #major >> $@
+ @echo UDK_MAJOR=$(UDK_MAJOR) >> $@
+ @echo #minor >> $@
+ @echo UDK_MINOR=$(UDK_MINOR) >> $@
+ @echo #micro >> $@
+ @echo UDK_MICRO=$(UDK_MICRO) >> $@
+
+$(DESTDIRINC)/% : $(INCOUT)/%
+ $(MY_TEXTCOPY) $< $@
+
+$(DESTDIRLIB)/%.lib : $(LIBOUT)/%.lib
+ @@-rm -f $@
+ $(GNUCOPY) $(LIBOUT)/$(@:f) $@
+
+$(DESTDIRLIB)/%.a : $(LIBOUT)/%.a
+ @@-rm -f $@
+ $(GNUCOPY) $(LIBOUT)/$(@:f) $@
+
+$(DIR_CREATE_FLAG) :
+ $(TYPE) $(mktmp $(DIR_DIRECTORY_LIST)) | xargs -n 20 $(MKDIRHIER) && echo "dirs created" > $@ && touch $@
+ $(DELAY) 2
+
+$(DESTDIRSETTINGS)/component.uno.def : $(PRJ)/settings/component.uno.def
+ @@-rm -f $@
+ $(MY_TEXTCOPY) $< $@
+
+$(DESTDIRSETTINGS)/component.uno.map : $(SOLARENV)/bin/addsym.awk $(SOLARENV)/src/component.map
+ @@-$(RM) -f $@
+.IF "$(COMID)"=="gcc3"
+ tr -d "\015" < $(SOLARENV)/src/component.map | $(AWK) -f $(SOLARENV)/bin/addsym.awk > $@
+.IF "$(OS)"=="MACOSX"
+ tr -d "\015" < $(SOLARENV)/src/component.map | tail -n +3 | head -3 | sed -e 's/.*component/_component/g' -e 's/;[ ]*//' > $@
+.ENDIF
+.ELSE # "$(COMID)"=="gcc3"
+ tr -d "\015" < $(SOLARENV)/src/component.map > $@
+.ENDIF # "$(COMID)"=="gcc3"
+ @chmod 664 $@
+
+$(DIR_FILE_LIST) : $(DIR_CREATE_FLAG)
+
+$(DIR_FILE_FLAG) : $(DIR_FILE_LIST)
+ @echo "must be zipped" > $@
+
+
+