1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> 2<!-- 3#************************************************************** 4# 5# Licensed to the Apache Software Foundation (ASF) under one 6# or more contributor license agreements. See the NOTICE file 7# distributed with this work for additional information 8# regarding copyright ownership. The ASF licenses this file 9# to you under the Apache License, Version 2.0 (the 10# "License"); you may not use this file except in compliance 11# with the License. You may obtain a copy of the License at 12# 13# http://www.apache.org/licenses/LICENSE-2.0 14# 15# Unless required by applicable law or agreed to in writing, 16# software distributed under the License is distributed on an 17# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18# KIND, either express or implied. See the License for the 19# specific language governing permissions and limitations 20# under the License. 21# 22#************************************************************** 23 --> 24<html> 25<head> 26 <title>Apache OpenOffice %PRODUCT_RELEASE% SDK - Examples</title> 27 <link rel="stylesheet" type="text/css" href="../docs/sdk_styles.css"> 28 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 29 <meta name="author" content="Jürgen Schmidt"> 30 <meta name="created" content="2004-12-14"> 31</head> 32 33<body class="sdkbody"><a name="examples"/> 34<table class="table1" cellpadding=0> 35 <tr style="background-image:url(../docs/images/sdk_head-2.png); backgorund-position: bottom; "> 36 <td class="background" colspan="3" align="left"><img src="../docs/images/sdk_head-1.png" width="800" height="120" usemap="#Map" border="0"></td> 37 </tr> 38 <tr> 39 <td colspan="3"><img class="nothing10" src="../docs/images/nada.gif"></td> 40 </tr> 41 <tr> 42 <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td> 43 <td> 44 <table class="table2"> 45 <tr> 46 <td colspan="3"><img class="nothing1" src="../docs/images/nada.gif"></td> 47 </tr> 48 <tr> 49 <td> 50 <table class="table3"> 51 <tr> 52 <td colspan="2" class="head1">Examples</td> 53 <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> 54 </tr> 55 </table> 56 </td> 57 </tr> 58 <tr> 59 <td> 60 <table class="table3"> 61 <tr> 62 <td colspan="3"> 63 <p>The SDK provides a rich set of examples in different programming 64 languages (Java, C++, Apache OpenOffice %PRODUCT_RELEASE% Basic, OLE) to illustrate the use 65 of the API and demonstrate how to benefit from the included word 66 processor, spreadsheet, presentation software, graphics program and 67 database of Apache OpenOffice %PRODUCT_RELEASE%.<br> 68 Some fo the examples need a running office instance listening on a 69 port. If this is necessary you will get further information in the 70 makefiles.</p> 71 <p>Every makefile contains at least one run target to execute an 72 running example, please see the makefile output in the different 73 example directories. Some of the examples which create a component have 74 no run target. In these cases a document is provided which instantiates 75 and runs the component (see the makefile output). Also the Basic 76 examples provide documents which use and shows the implemented 77 functionality.</p> 78 </td> 79 </tr> 80 <tr> 81 <td><img class="line" src="../docs/images/sdk_line-1.gif"></td> 82 </tr> 83 </table> 84 </tr> 85 <tr> 86 <td> 87 <table class="table3"> 88 <tr valign="top"> 89 <td class="content3"><img src="../docs/images/arrow-1.gif"></td> 90 <td><a href="DevelopersGuide/examples.html" title="link to the Developer's Guide examples overview page">Developer's Guide examples</a></td> 91 <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 92 with a rich set of examples which demonstrate the use of the API in 93 the different application areas.</td> 94 </tr> 95 <tr valign="top"> 96 <td class="content3"><img src="../docs/images/arrow-1.gif"></td> 97 <td><a href="#Java_examples" title="link to the Java examples section">Java examples</a></td> 98 <td class="content75">Set of simple and more complex examples which 99 shows the use of the API from Java.</td> 100 </tr> 101 <tr valign="top"> 102 <td class="content3"><img src="../docs/images/arrow-1.gif"></td> 103 <td><a href="#Cpp_examples" title="link to the C++ examples section">C++ examples</a></td> 104 <td class="content75">Small set of examples which shows the use of 105 the API from C++.</td> 106 </tr> 107 <tr valign="top"> 108 <td class="content3"><img src="../docs/images/arrow-1.gif"></td> 109 <td><a href="#Basic_examples" title="link to the Apache OpenOffice %PRODUCT_RELEASE% Basic examples section">Apache OpenOffice %PRODUCT_RELEASE% Basic examples</a></td> 110 <td class="content75">Small set of examples which shows the use of 111 the API from Apache OpenOffice %PRODUCT_RELEASE% Basic.</td> 112 </tr> 113 <tr valign="top"> 114 <td class="content3"><img src="../docs/images/arrow-1.gif"></td> 115 <td><a href="#OLE_examples" title="link to the OLE examples section">Object Linking and Embedding (OLE) examples</a></td> 116 <td class="content75">Examples which show the use of the API from 117 OLE.</td> 118 </tr> 119 <tr valign="top"> 120 <td class="content3"><img src="../docs/images/arrow-1.gif"></td> 121 <td><a href="#CLI_examples" title="link to the CLI examples section">Common Language Infrastructure (CLI) examples</a></td> 122 <td class="content75">Examples which show the use of the API from 123 the CLI.</td> 124 </tr> 125 </table> 126 </tr> 127 </table> 128 </td> 129 <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td> 130 </tr> 131 <tr> 132 <td colspan="3"><img class="line" src="../docs/images/sdk_line-1.gif"></td> 133 </tr> 134 <tr> 135 <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td> 136 <td> 137 <table class="table2"> 138 <tr> 139 <td> 140 <table class="table3"> 141 <tr> 142 <td colspan="2" class="head1"><a name="Java_examples">Java examples</td> 143 <td align="right"> 144 <a href="#examples" title="link to the examples overview"><img class="navigate" src="../docs/images/nav_up.png"></a> 145 <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="../docs/images/nav_home.png"></a> 146 </td> 147 </tr> 148 </table> 149 </td> 150 </tr> 151 <tr> 152 <td> 153 <table class="table4"> 154 <tbody> 155 <tr class="thead"> 156 <td class="cell20">Text Document Examples</td> 157 <td class="cell80">Description</td> 158 </tr> 159 <tr> 160 <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">BookmarkInsertion</a></td> 161 <td class="cell80">This application connects to the office server and 162 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 163 and an example text will be entered. Afterwards, some bookmarks will be 164 inserted.</td> 165 </tr> 166 <tr> 167 <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">HardFormatting</a></td> 168 <td class="cell80">This program connects to the office server and gets 169 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 170 opened, an example text will be entered, some text attributes will be 171 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> 172 </tr> 173 <tr> 174 <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">SWriter</a></td> 175 <td class="cell80">The program connects to the office server and gets the 176 <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 177 text will be entered, and a text table, a colored text, and text frame 178 will be inserted.</td> 179 </tr> 180 <tr> 181 <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">StyleCreation</a></td> 182 <td class="cell80">The example connects to the office server and gets the 183 <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 184 paragraph style will be created, and applied.</td> 185 </tr> 186 <tr> 187 <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">StyleInitialization</a></td> 188 <td class="cell80">The program connects to the office server and gets the 189 <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 190 opened and an example text will be entered. The paragraph collection will 191 be used, in order to apply a different paragraph style on the 192 paragraphs.</td> 193 </tr> 194 <tr> 195 <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">TextDocumentStructure</a></td> 196 <td class="cell80">The application connects to the office server and gets 197 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 198 enumeration of all paragraphs and an enumeration of all text portions 199 will be created.</td> 200 </tr> 201 <tr> 202 <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">TextReplace</a></td> 203 <td class="cell80">The example connects to the office server and gets the 204 <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 205 example text will be inserted, and some English spelled words will be 206 replaced with US spelled words.</td> 207 </tr> 208 <tr> 209 <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">GraphicsInserter</a></td> 210 <td class="cell80">The GraphicsInserter creates a graphics object on an 211 empty text document by setting its position, width, height, and URL.</td> 212 </tr> 213 <tr> 214 <td class="cell20"><a href="java/Text/" title="link to the source directory of the Java Text examples">WriterSelector</a></td> 215 <td class="cell80">This class gives you information on the selected 216 objects (text range, text frame, or graphics) at an Apache OpenOffice 217 Server.</td> 218 </tr> 219 <tbody> 220 </table> 221 </td> 222 </tr> 223 <tr> 224 <td> 225 <table class="table4"> 226 <tbody> 227 <tr class="thead"> 228 <td class="cell20">Spreadsheet Document Examples</td> 229 <td class="cell80">Description</td> 230 </tr> 231 <tr> 232 <td class="cell20"><a href="java/Spreadsheet/" title="link to the source directory of the Java Spreadsheet examples">CalcAddins</a></td> 233 <td class="cell80">This component adds new functions to the spreadsheet 234 application. After registering the component, the inserted functions can 235 be found with help of the functions autopilot. The new functions are 236 assigned to the category <i>Add-in</i>.</td> 237 </tr> 238 <tr> 239 <td class="cell20"><a href="java/Spreadsheet/" title="link to the source directory of the Java Spreadsheet examples">ChartTypeChange</a></td> 240 <td class="cell80">This class loads an Apache OpenOffice %PRODUCT_RELEASE% Calc document and 241 changes the type of the embedded chart.</td> 242 </tr> 243 <tr> 244 <td class="cell20"><a href="java/Spreadsheet/" title="link to the source directory of the Java Spreadsheet examples">EuroAdaption</a></td> 245 <td class="cell80">The application connects to the office server and gets 246 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 247 example text, sets the number format to DM, changes the number format to 248 EUR (Euro), and uses the DM/EUR factor on each cell with content.</td> 249 </tr> 250 <tr> 251 <td class="cell20"><a href="java/Spreadsheet/" title="link to the source directory of the Java Spreadsheet examples">SCalc</a></td> 252 <td class="cell80">The program connects to the office server and gets the 253 <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, 254 cell styles will be created, some data will be inserted into the sheets, 255 and the created cell styles will be applied. Finally, a 3D chart will be 256 inserted.</td> 257 </tr> 258 <tbody> 259 </table> 260 </td> 261 </tr> 262 <tr> 263 <td> 264 <table class="table4"> 265 <tbody> 266 <tr class="thead"> 267 <td class="cell20">Drawing Document Examples</td> 268 <td class="cell80">Description</td> 269 </tr> 270 <tr> 271 <td class="cell20"><a href="java/Drawing/" title="link to the source directory of the Java Drawing examples">SDraw</a></td> 272 <td class="cell80">This program connects to the office server and gets 273 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 274 be created and some shapes will be inserted on the draw page.</td> 275 </tr> 276 <tbody> 277 </table> 278 </td> 279 </tr> 280 <tr> 281 <td> 282 <table class="table4"> 283 <tbody> 284 <tr class="thead"> 285 <td class="cell20">Document Handling Examples</td> 286 <td class="cell80">Description</td> 287 </tr> 288 <tr> 289 <td class="cell20"><a href="java/DocumentHandling/" title="link to the source directory of the Java DocumentHandling examples">DocumentConverter</a></td> 290 <td class="cell80">The program offers a service that converts arbitrary 291 documents to a favored document type.</td> 292 </tr> 293 <tr> 294 <td class="cell20"><a href="java/DocumentHandling/" title="link to the source directory of the Java DocumentHandling examples">DocumentLoader</a></td> 295 <td class="cell80">The <i>DocumentLoader</i> can open a new or an 296 existing document.</td> 297 </tr> 298 <tr> 299 <td class="cell20"><a href="java/DocumentHandling/" title="link to the source directory of the Java DocumentHandling examples">DocumentPrinter</a></td> 300 <td class="cell80">The <i>DocumentPrinter</i> allows you to print the 301 favored pages of a specified document on your favored printer.</td> 302 </tr> 303 <tr> 304 <td class="cell20"><a href="java/DocumentHandling/" title="link to the source directory of the Java DocumentHandling examples">DocumentSaver</a></td> 305 <td class="cell80">The DocumentSaver shows how to save a document and 306 how you can change the type of your document.</td> 307 </tr> 308 <tbody> 309 </table> 310 </td> 311 </tr> 312 <tr> 313 <td> 314 <table class="table4"> 315 <tbody> 316 <tr class="thead"> 317 <td class="cell20">UNO Component Examples</td> 318 <td class="cell80">Description</td> 319 </tr> 320 <tr> 321 <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> 322 <td class="cell80">The Object Inspector is primarily an auxiliary tool 323 for the developer, which can present information about an object of the 324 Apache OpenOffice %PRODUCT_RELEASE% API at run-time. Depending on the object to be inspected, 325 appropriate methods, interfaces, services, and attributes can be displayed 326 to the developer. The methods, interfaces, services and attributes are 327 represented in a predictable tree. If the attributes contained in an 328 object are to be examined, the appropriate nodes in the tree can be 329 expanded with the help of the mouse. For each non primitive object, five 330 categories are offered to the user, as long as those are available with 331 that object. The Object Inspector is currently available as a NetBeans project 332 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> 333 </tr> 334 <tr> 335 <td class="cell20"><a href="java/MinimalComponent/" title="link to the source directory of the Java MinimalComponent example">MinimalComponent</a></td> 336 <td class="cell80">This class provides a minimal UNO component. You can 337 take this class as a base for your own components. By extensions of this 338 class it is possible to also extend the function range of the Office.</td> 339 </tr> 340 <tr> 341 <td class="cell20"><a href="java/PropertySet/" title="link to the source directory of the Java PropertySet example">PropTest</a></td> 342 <td class="cell80">Contains a component that provides property set 343 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> 344 </tr> 345 <tr> 346 <td class="cell20"><a href="java/ToDo/" title="link to the source directory of the Java ToDo example">ToDo</a></td> 347 <td class="cell80">For every to-do listed in a spreadsheet document, this 348 component calculates the start date, day of week of the start date, the 349 end date, and the day of week of the end date. All calculations are 350 dependent upon the values of "Needed Days", "Due Date" 351 and "Status". The columns "Needed Days" and 352 "Status" are mandatory. The first to-do should be placed in 353 row nine. The date to start the calculation should be placed in cell C6. 354 The private holidays should be placed in cell K4/K5 and below.<br> 355 All rows will be calculated up to the first empty cell in the first 356 column. If a cell in the column "Due Date" is colored red, 357 you should take a look at your entries.</td> 358 </tr> 359 <tr> 360 <td class="cell20"><a href="java/EmbedDocument/EmbeddedObject" title="link to the source directory of the Java EmbeddedObject example">EmbeddedObject</a></td> 361 <td class="cell80">Contains a component that provides an example of embedded object implementation.</td> 362 </tr> 363 <tbody> 364 </table> 365 </td> 366 </tr> 367 <tr> 368 <td> 369 <table class="table3"> 370 <tr> 371 <td colspan="3"> 372 <p>Additional information:</p> 373 <p> 374 <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/Simple_Component_in_Java" title="link to the "Simple component in Java" chapter in the Developer's Guide">How to write a UNO component in Java</a><br> 375 <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Java/Java_Language_Binding" title="link to the "Java UNO Language Bnding" chapter in the Developer's Guide">Java UNO Language Binding</a><br> 376 <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/Debugging" title="link to the "Debugging Java components" chapter in the Developer's Guide">Debugging Java components</a><br> 377 </p> 378 </td> 379 </tr> 380 </table> 381 </td> 382 </tr> 383 </table> 384 </td> 385 <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td> 386 </tr> 387 <tr> 388 <td colspan="3"><img class="line" src="../docs/images/sdk_line-1.gif"></td> 389 </tr> 390 <tr> 391 <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td> 392 <td> 393 <table class="table2"> 394 <tr> 395 <td> 396 <table class="table3"> 397 <tr> 398 <td colspan="2" class="head1"><a name="Cpp_examples">C++ examples</td> 399 <td align="right"> 400 <a href="#examples" title="link to the examples overview"><img class="navigate" src="../docs/images/nav_up.png"></a> 401 <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="../docs/images/nav_home.png"></a> 402 </td> 403 </tr> 404 <tr> 405 <td colspan="3"> 406 The DocumentLoader example needs a running office server, before 407 running this program you should invoke the office with the following 408 command: 409 <blockquote> 410 <code>soffice "-accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager"</code> 411 </blockquote> 412 You can also customize the mentioned host and port to your needs. 413 </td> 414 </tr> 415 </table> 416 </td> 417 </tr> 418 <tr> 419 <td> 420 <table class="table4"> 421 <tbody> 422 <tr class="thead"> 423 <td class="cell20">Example</td> 424 <td class="cell80">Description</td> 425 </tr> 426 <tr> 427 <td class="cell20"><a href="cpp/DocumentLoader/" title="link to the source directory of the C++ DocumentLoader example">DocumentLoader</a></td> 428 <td class="cell80">This component works the same as the appropriate Java 429 example, but is implemented in C++.</td> 430 </tr> 431 <tr> 432 <td class="cell20"><a href="cpp/counter/" title="link to the source directory of the C++ counter example">Counter</a></td> 433 <td class="cell80">This demo shows how to implement a very simple UNO 434 component and how to access the UNO component from an executable.</td> 435 </tr> 436 <tr> 437 <td class="cell20"><a href="cpp/remoteclient/" title="link to the source directory of the C++ remoteclient example">Remote client</a></td> 438 <td class="cell80">The 'uno' program is used to export an arbitrary 439 service to other processes. In this example the com.sun.star.uno.Pipe 440 service (which is built in io-module) is exported. The client component 441 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"> 442 com.sun.star.lang.XMain</a> interface. In the run method, it connects to 443 the servers process and retrieves an instance and does some calls on the 444 instance.</td> 445 </tr> 446 <tr> 447 <td class="cell20"><a href="cpp/complextoolbarcontrols/" title="link to the source directory of the C++ complextoolbarcontrols example">complextoolbarcontrols</a></td> 448 <td class="cell80">This example shows how to create a toolbar add-on with complex toolbar controls. 449 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> 450 </tr> 451 <tr> 452 <td class="cell20"><a href="cpp/StatusbarController/" title="link to the source directory of the C++ StatusbarController example">StatusbarController</a></td> 453 <td class="cell80">These examples show how to implement a StatusbarController to add functionality in the status bar.</td> 454 </tr> 455 <tbody> 456 </table> 457 </td> 458 </tr> 459 <tr> 460 <td> 461 <table class="table3"> 462 <tr> 463 <td colspan="3"> 464 <p>Additional information:</p> 465 <p> 466 <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/C%2B%2B/C%2B%2B_Component" title="link to the "How to write a UNO component in C++" chapter in the Developer's Guide">How to write a UNO component in C++</a><br> 467 <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/C%2B%2B/C%2B%2B_Language_Binding" title="link to the "C++ UNO Language Binding" chapter in the Developer's Guide">C++ UNO Language Binding</a><br> 468 <a href="../docs/cpp/ref/index.html" title="link to the C++ API reference">C++ reference</a> 469 </p> 470 </td> 471 </tr> 472 </table> 473 </td> 474 </tr> 475 </table> 476 </td> 477 <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td> 478 </tr> 479 <tr> 480 <td colspan="3"><img class="line" src="../docs/images/sdk_line-1.gif"></td> 481 </tr> 482 <tr> 483 <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td> 484 <td> 485 <table class="table2"> 486 <tr> 487 <td> 488 <table class="table3"> 489 <tr> 490 <td colspan="2" class="head1"><a name="Basic_examples">Apache OpenOffice %PRODUCT_RELEASE% Basic examples</td> 491 <td align="right"> 492 <a href="#examples" title="link to the examples overview"><img class="navigate" src="../docs/images/nav_up.png"></a> 493 <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="../docs/images/nav_home.png"></a> 494 </td> 495 </tr> 496 <tr> 497 <td colspan="3"> 498 <p>The example programs are embedded in Apache OpenOffice %PRODUCT_RELEASE% documents in the 499 samples directory. To view or edit the Apache OpenOffice %PRODUCT_RELEASE% Basic source, 500 select the appropriate document and then select Tools->Macro.</p> 501 <p>Most of the examples are stand-alone, but two of them (Creating an 502 Index and Import/Export of ASCII Files) have an associated data file 503 identified by a .txt file name suffix).</p> 504 <p>Some of the examples are also available in Java, you can find them in 505 the <a href="#Java_examples" title="link to the Java examples section"> 506 Java section</a>.</p> 507 </td> 508 </tr> 509 </table> 510 </td> 511 </tr> 512 <tr> 513 <td> 514 <table class="table4"> 515 <tbody> 516 <tr class="thead"> 517 <td class="cell20">Example</td> 518 <td class="cell80">Description</td> 519 </tr> 520 <tr> 521 <td class="cell20"><a href="basic/text/modifying_text_automatically/" title="link to the source directory of the Apache OpenOffice %PRODUCT_RELEASE% Basic text/modifying_text_automatically examples">Changing Appearance</a></td> 522 <td class="cell80"> To change the style used for certain words, you can 523 start with the following example. This code searches for the regular 524 expression <code>the[a-z]</code>, which stands for the text portion the 525 followed by exactly one lowercase letter. All occurrences of these four 526 letters are then changed to bold characters. The same happens in the next 527 part of the program, this time changing the appearance of 528 <code>all[a-z]</code> to italic. In order for this example to work, you 529 must execute it from an open text document.</td> 530 </tr> 531 <tr> 532 <td class="cell20"><a href="basic/text/modifying_text_automatically/" title="link to the source directory of the Apache OpenOffice %PRODUCT_RELEASE% Basic text/modifying_text_automatically examples">Replacing Text</a></td> 533 <td class="cell80">If you regularly receive documents from other people 534 for editing, you might want to make sure that certain words are always 535 written the same. The next example illustrates this by forcing certain 536 words to be spelled in American English.<br> 537 In order for this example to work, you must execute it from an open text 538 document. For a real world application, it is a good idea to read the 539 words from an external file.</td> 540 </tr> 541 <tr> 542 <td class="cell20"><a href="basic/text/modifying_text_automatically/" title="link to the source directory of the Apache OpenOffice %PRODUCT_RELEASE% Basic text/modifying_text_automatically examples">Using Regular Expressions</a></td> 543 <td class="cell80">Another application of automatic text modification is 544 related to stylistic questions. Suppose your company’s policy is to 545 avoid the use of certain words. You want to replace these words, but you 546 cannot do that automatically because you have to find the appropriate 547 replacement, which depends on the context. So instead of deleting or 548 replacing the offending words automatically, you change their color to 549 make them stand out during a subsequent manual review process.<br> 550 The following example handles two kinds of unwanted wordings: those 551 which are absolutely forbidden and must be replaced by something else, 552 and those which are considered bad style. A subroutine is responsible 553 for the changes. It can be used to make all words in a list appear in a 554 certain color in the text document. To keep the lists short, we use 555 regular expressions which provide for the variants of the words 556 (plural, adjective etc.).</td> 557 </tr> 558 <tr> 559 <td class="cell20"><a href="basic/text/modifying_text_automatically/" title="link to the source directory of the Apache OpenOffice %PRODUCT_RELEASE% Basic text/modifying_text_automatically examples">Inserting Bookmarks</a></td> 560 <td class="cell80"> 561 <p>The next example does something very similar. This time, however, we 562 do not change the color of the words but insert a bookmark at each of 563 them. You can thus use the StarOffice navigator to jump directly from 564 word to word. Bookmarks must first be created using 565 <code>createInstance()</code>. They are then inserted with 566 <code>insertTextContent()</code> at the current text range.</p> 567 <p>The main difference to the preceding example is the For loop in 568 <code>markList()</code>. Instead of changing the color of the current 569 word, it creates a new bookmark, oBookmark, whose name is the current 570 word with an integer appended. It then inserts this bookmark at the 571 word.</td> 572 </tr> 573 <tr> 574 <td class="cell20"><a href="basic/text/creating_an_index/" title="link to the source directory of the Apache OpenOffice %PRODUCT_RELEASE% Basic text/create_index example">Creating an Index</a></td> 575 <td class="cell80">Indices for text documents can be created manually in 576 Apache OpenOffice %PRODUCT_RELEASE% Writer by clicking on the words that should appear in the 577 index. If the document is large, or if you have to generate indices for 578 several documents, this task should be automated.</td> 579 </tr> 580 <tr> 581 <td class="cell20"><a href="basic/sheet/" title="link to the source directory of the Apache OpenOffice %PRODUCT_RELEASE% Basic sheet example">Adapting to Euroland</a></td> 582 <td class="cell80">Most of the members of the European Union will abandon 583 their old currency in favor of the new Euro in 2001. This requires 584 modifications to all programs using the old currencies. Since the exchange 585 rates for the old currencies have been fixed at the end of 1999, one can 586 already convert old data. The following program does this for all values 587 in a table that are formatted with the currency string DM.</td> 588 </tr> 589 <tr> 590 <td class="cell20"><a href="basic/drawing/" title="link to the source directory of the Apache OpenOffice %PRODUCT_RELEASE% Basic drawing example">Import/Export of ASCII Files</a></td> 591 <td class="cell80">You can use the drawing facilities of StarOffice API 592 to generate a picture from ASCII input. One application would be a 593 hierarchical representation of a directory listing, based on textual 594 data.</td> 595 </tr> 596 <tr> 597 <td class="cell20"><a href="basic/stock_quotes_updater/" title="link to the source directory of the Apache OpenOffice %PRODUCT_RELEASE% Basic stock_quotes_updater example">Stock Quotes Updater</a></td> 598 <td class="cell80">If you want to display stock charts for certain 599 companies, you can open up your browser every day, go to a search engine, 600 look up the quote and copy it by hand into a table. Or you can use a 601 program that does all this automatically. The following example relies on 602 the sheet module. It uses URLs to obtain the current stock quotes. The 603 quotes are displayed in sheets, one for each company. We show a line 604 diagram and the numerical values for this company on every sheet. The 605 functionality is hidden in the three subroutines <code>GetValue()</code>, 606 <code>UpdateValue()</code>, and <code>UpdateChart()</code>.</td> 607 </tr> 608 <tr> 609 <td class="cell20"><a href="basic/forms_and_controls/" title="link to the source directory of the Apache OpenOffice %PRODUCT_RELEASE% Basic forms_and_controls example">Forms and Controls</a></td> 610 <td class="cell80">The example document Burger Factory offers some forms 611 and controls, which you can use to order your desired burger type, 612 beverage, topping, and sauce. By hitting the button 613 "Order now!", your order will be placed.</td> 614 </tr> 615 <tbody> 616 </table> 617 </td> 618 </tr> 619 <tr> 620 <td> 621 <table class="table3"> 622 <tr> 623 <td colspan="3"> 624 Additional information: <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Basic/OpenOffice.org_Basic" title="link to the "OpenOffice.org %PRODUCT_RELEASE% Basic language binding" chapter in the Developer's Guide">OpenOffice.org %PRODUCT_RELEASE% Basic language binding</a> 625 </td> 626 </tr> 627 </table> 628 </td> 629 </tr> 630 </table> 631 </td> 632 <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td> 633 </tr> 634 <tr> 635 <td colspan="3"><img class="line" src="../docs/images/sdk_line-1.gif"></td> 636 </tr> 637 <tr> 638 <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td> 639 <td> 640 <table class="table2"> 641 <tr> 642 <td> 643 <table class="table3"> 644 <tr> 645 <td colspan="2" class="head1"><a name="OLE_examples">Object Linking and Embedding (OLE) examples</td> 646 <td align="right"> 647 <a href="#examples" title="link to the examples overview"><img class="navigate" src="../docs/images/nav_up.png"></a> 648 <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="../docs/images/nav_home.png"></a> 649 </td> 650 </tr> 651 </table> 652 </td> 653 </tr> 654 <tr> 655 <td> 656 <table class="table4"> 657 <tbody> 658 <tr class="thead"> 659 <td class="cell20">Example</td> 660 <td class="cell80">Description</td> 661 </tr> 662 <tr> 663 <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> 664 <td class="cell80">The ActiveX control shows an example of access to UNO 665 through COM technology. It requires a properly installed StarOffice 666 version 6.0 or OpenOffice 1.0 or newer. This is a Lite ActiveX control 667 so it can be used only in containers that allow the use of such controls. 668 It can be activated with an <OBJECT> tag from a html-page to embed 669 a document. Without any parameters a new writer document will be opened 670 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> 671 Note: This example works only under windows and if you don't use the MS 672 .Net C++ compiler please check the makefile and take notice of the 673 comments.</td> 674 </tr> 675 <tr> 676 <td class="cell20"><a href="OLE/vbscript/" title="link to the source directory of the VBScript example using the OLE bridge">WriterDemo</a></td> 677 <td class="cell80">This Visual Basic Script creates an empty text 678 document and inserts text, a table, and a text frame.</td> 679 </tr> 680 <tbody> 681 </table> 682 </td> 683 </tr> 684 <tr> 685 <td> 686 <table class="table3"> 687 <tr> 688 <td colspan="3"> 689 Additional information: <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Bridge/Automation_Bridge" title="link to the "Automation Language Binding" chapter in the Developer's Guide">Automation Language Binding</a> 690 </td> 691 </tr> 692 </table> 693 </td> 694 </tr> 695 </table> 696 </td> 697 <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td> 698 </tr> 699 <tr> 700 <td colspan="3"><img class="line" src="../docs/images/sdk_line-1.gif"></td> 701 </tr> 702 <tr> 703 <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td> 704 <td> 705 <table class="table2"> 706 <tr> 707 <td> 708 <table class="table3"> 709 <tr> 710 <td colspan="2" class="head1"><a name="CLI_examples">Common Language Infrastructure (CLI) examples</td> 711 <td align="right"> 712 <a href="#examples" title="link to the examples overview"><img class="navigate" src="../docs/images/nav_up.png"></a> 713 <a href="../index.html" title="link to the SDK start page"><img class="navigate" src="../docs/images/nav_home.png"></a> 714 </td> 715 </tr> 716 </table> 717 </td> 718 </tr> 719 <tr> 720 <td> 721 <table class="table4"> 722 <tbody> 723 <tr class="thead"> 724 <td class="cell20">Example</td> 725 <td class="cell80">Description</td> 726 </tr> 727 <tr> 728 <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> 729 <td class="cell80">This example is written in C# and shows how Spreadsheet 730 documents are created and filled with content. This example actually 731 consists of three separate executables, SpreadsheetSample.exe, 732 GeneralTableSample.exe, ViewSample.exe.</td> 733 </tr> 734 <tr> 735 <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> 736 <td class="cell80">This example is written in VB.NET. It creates a text 737 document and inserts text, a table, and a text frame.</td> 738 </tr> 739 <tbody> 740 </table> 741 </td> 742 </tr> 743 <tr> 744 <td> 745 <table class="table3"> 746 <tr> 747 <td colspan="3"> 748 Additional information: <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/CLI/CLI_Language_Binding" title="link to the "CLI-UNO Language Binding" chapter in the Developer's Guide">CLI-UNO Language Binding</a> 749 </td> 750 </tr> 751 </table> 752 </td> 753 </tr> 754 </table> 755 </td> 756 <td class="content1"><img class="nothing8" src="../docs/images/nada.gif"></td> 757 </tr> 758 <tr> 759 <td colspan="3"><img class="nothing30" src="../docs/images/nada.gif"></td> 760 </tr> 761 <tr> 762 <td colspan="3"><img class="line" src="../docs/images/sdk_line-1.gif"></td> 763 </tr> 764 <tr> 765 <td colspan="3"> 766 <div class="centertext"> 767 <p><img class="apachelogo" src="../docs/images/odk-footer-logo.gif" title="Apache Feather" alt="Apache Feather" /> 768 Copyright © 2011-2023 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache, the Apache feather logo, Apache OpenOffice and OpenOffice.org are trademarks of The Apache Software Foundation. Other names may be trademarks of their respective owners.<p> 769 </div> 770 </td> 771 </tr> 772</table> 773<map name="Map"> 774 <area shape="rect" coords="10,68,400,105" href="http://www.openoffice.org"> 775</map> 776</body> 777</html> 778