1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 3.2 Final//EN">
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 <title>LibreOffice %PRODUCT_RELEASE% SDK - Examples
</title>
22 <link rel=
"stylesheet" type=
"text/css" href=
"../docs/sdk_styles.css"/>
23 <meta http-equiv=
"Content-Type" content=
"text/html;charset=utf-8"/>
26 <a name=
"exapmles"></a>
27 <div id=
"BgContainer">
30 <a id=
"Logo" href=
"http://www.libreoffice.org/" title=
"Go to the Home of LibreOffice and the LibreOffice Community page"></a>
31 <p id=
"HeaderTagLine">
32 Software Development Kit %PRODUCT_RELEASE%
38 <div class=
"typography">
43 <table class=
"table1" cellpadding=
"0">
45 <td colspan=
"3"><img class=
"nothing10" src=
"../docs/images/nada.gif"/></td>
48 <td class=
"content1"><img class=
"nothing8" src=
"../docs/images/nada.gif"/></td>
50 <table class=
"table2">
52 <td colspan=
"3"><img class=
"nothing1" src=
"../docs/images/nada.gif"/></td>
56 <table class=
"table3">
59 <p>The SDK provides a rich set of examples in different programming
60 languages (Java, Python, C++, LibreOffice %PRODUCT_RELEASE% Basic, OLE) to illustrate the use
61 of the API and demonstrate how to benefit from the included word
62 processor, spreadsheet, presentation software, graphics program and
63 database of LibreOffice %PRODUCT_RELEASE%.
<br/>
64 Some fo the examples need a running office instance listening on a
65 port. If this is necessary you will get further information in the
67 <p>Every makefile contains at least one run target to execute an
68 running example, please see the makefile output in the different
69 example directories. Some of the examples which create a component have
70 no run target. In these cases a document is provided which instantiates
71 and runs the component (see the makefile output). Also the Basic
72 examples provide documents which use and shows the implemented
77 <td><img class=
"line" src=
"../docs/images/sdk_line-1.gif"/></td>
84 <table class=
"table3">
86 <td class=
"content3"><img src=
"../docs/images/arrow-1.gif"/></td>
87 <td><a href=
"DevelopersGuide/examples.html" title=
"link to the Developer's Guide examples overview page">Developer's Guide examples
</a></td>
88 <td class=
"content75">The
<a href=
"http://wiki.openoffice.org/wiki/Documentation/DevGuide/OpenOffice.org_Developers_Guide" title=
"link to the Developer's Guide in the Wiki">Developer's Guide
</a> comes
89 with a rich set of examples which demonstrate the use of the API in
90 the different application areas.
</td>
93 <td class=
"content3"><img src=
"../docs/images/arrow-1.gif"/></td>
94 <td><a href=
"#Java_examples" title=
"link to the Java examples section">Java examples
</a></td>
95 <td class=
"content75">Set of simple and more complex examples which
96 shows the use of the API from Java.
</td>
99 <td class=
"content3"><img src=
"../docs/images/arrow-1.gif"/></td>
100 <td><a href=
"#python_examples" title=
"link to the Python examples section">Python examples
</a></td>
101 <td class=
"content75">Small set of examples which shows the use of the API from Python.
</td>
104 <td class=
"content3"><img src=
"../docs/images/arrow-1.gif"/></td>
105 <td><a href=
"#Cpp_examples" title=
"link to the C++ examples section">C++ examples
</a></td>
106 <td class=
"content75">Small set of examples which shows the use of
107 the API from C++.
</td>
110 <td class=
"content3"><img src=
"../docs/images/arrow-1.gif"/></td>
111 <td><a href=
"#Basic_examples" title=
"link to the LibreOffice %PRODUCT_RELEASE% Basic examples section">LibreOffice %PRODUCT_RELEASE% Basic examples
</a></td>
112 <td class=
"content75">Small set of examples which shows the use of
113 the API from LibreOffice %PRODUCT_RELEASE% Basic.
</td>
116 <td class=
"content3"><img src=
"../docs/images/arrow-1.gif"/></td>
117 <td><a href=
"#OLE_examples" title=
"link to the OLE examples section">Object Linking and Embedding (OLE) examples
</a></td>
118 <td class=
"content75">Examples which show the use of the API from OLE.
</td>
121 <td class=
"content3"><img src=
"../docs/images/arrow-1.gif"/></td>
122 <td><a href=
"#CLI_examples" title=
"link to the CLI examples section">Common Language Infrastructure (CLI) examples
</a></td>
123 <td class=
"content75">Examples which show the use of the API from the CLI.
</td>
129 <td class=
"content1"><img class=
"nothing8" src=
"../docs/images/nada.gif"/></td>
132 <td colspan=
"3"><img class=
"line" src=
"../docs/images/sdk_line-1.gif"/></td>
135 <td class=
"content1"><img class=
"nothing8" src=
"../docs/images/nada.gif"/></td>
137 <table class=
"table2">
140 <table class=
"table3">
142 <td colspan=
"2" class=
"head1"><a name=
"Java_examples"/>Java examples
</td>
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>
153 <table class=
"table4">
156 <td class=
"cell20">Text Document Examples
</td>
157 <td class=
"cell80">Description
</td>
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=
"%DOXYGEN_PREFIX1%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XMultiComponentFactory.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
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=
"%DOXYGEN_PREFIX1%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XMultiComponentFactory.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=
"%DOXYGEN_PREFIX1%/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1beans.html#PropertyState" title=
"link into the IDL reference to the enum com.sun.star.beans.PropertyState"> PropertyState
</a> will be checked from the selection.
</td>
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=
"%DOXYGEN_PREFIX1%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XMultiComponentFactory.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>
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=
"%DOXYGEN_PREFIX1%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XMultiComponentFactory.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>
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=
"%DOXYGEN_PREFIX1%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XMultiComponentFactory.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
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=
"%DOXYGEN_PREFIX1%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XMultiComponentFactory.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>
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=
"%DOXYGEN_PREFIX1%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XMultiComponentFactory.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>
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>
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 a LibreOffice
225 <table class=
"table4">
228 <td class=
"cell20">Spreadsheet Document Examples
</td>
229 <td class=
"cell80">Description
</td>
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>
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 a LibreOffice %PRODUCT_RELEASE% Calc document and
241 changes the type of the embedded chart.
</td>
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=
"%DOXYGEN_PREFIX1%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XMultiComponentFactory.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>
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=
"%DOXYGEN_PREFIX1%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XMultiComponentFactory.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
264 <table class=
"table4">
267 <td class=
"cell20">Drawing Document Examples
</td>
268 <td class=
"cell80">Description
</td>
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=
"%DOXYGEN_PREFIX1%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XMultiComponentFactory.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>
282 <table class=
"table4">
285 <td class=
"cell20">Document Handling Examples
</td>
286 <td class=
"cell80">Description
</td>
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>
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>
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>
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>
314 <table class=
"table4">
317 <td class=
"cell20">UNO Component Examples
</td>
318 <td class=
"cell80">Description
</td>
321 <td class=
"cell20"><a href=
"http://wiki.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 LibreOffice %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.openoffice.org/wiki/Object_Inspector" title=
"link to the Object Inspector project page in the wiki">project page
</a> for further details.
</td>
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>
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=
"%JAVADOC_PREFIX1%/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>
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>
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>
369 <table class=
"table3">
372 <p>Additional information:
</p>
374 <a href=
"http://wiki.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.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.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/>
385 <td class=
"content1"><img class=
"nothing8" src=
"../docs/images/nada.gif"/></td>
388 <td colspan=
"3"><img class=
"line" src=
"../docs/images/sdk_line-1.gif"/></td>
391 <td class=
"content1"><img class=
"nothing8" src=
"../docs/images/nada.gif"/></td>
393 <table class=
"table2">
396 <table class=
"table3">
398 <td colspan=
"2" class=
"head1"><a name=
"python_examples"/>Python examples
</td>
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>
405 <td colspan=
"3"></td>
412 <table class=
"table4">
415 <td class=
"cell20">Example
</td>
416 <td class=
"cell80">Description
</td>
419 <td class=
"cell20"><a href=
"python/toolpanel/" title=
"link to the source directory of the ToolPanel python axample">ToolPanelPoc
</a></td>
420 <td class=
"cell80">This proof of concept extension illustrates how to create a ToolPanel in Calc.
</td>
428 <table class=
"table3">
431 <p>No Additional information
</p>
439 <td class=
"content1"><img class=
"nothing8" src=
"../docs/images/nada.gif"/></td>
442 <td colspan=
"3"><img class=
"line" src=
"../docs/images/sdk_line-1.gif"/></td>
445 <td class=
"content1"><img class=
"nothing8" src=
"../docs/images/nada.gif"/></td>
447 <table class=
"table2">
450 <table class=
"table3">
452 <td colspan=
"2" class=
"head1"><a name=
"Cpp_examples"/>C++ examples
</td>
454 <a href=
"#examples" title=
"link to the examples overview"><img class=
"navigate" src=
"../docs/images/nav_up.png"/></a>
455 <a href=
"../index.html" title=
"link to the SDK start page"><img class=
"navigate" src=
"../docs/images/nav_home.png"/></a>
460 The DocumentLoader example needs a running office server, before
461 running this program you should invoke the office with the following
464 <code>soffice
"--accept=socket,host=localhost,port=
2083;urp;StarOffice.ServiceManager
"</code>
466 You can also customize the mentioned host and port to your needs.
474 <table class=
"table4">
477 <td class=
"cell20">Example
</td>
478 <td class=
"cell80">Description
</td>
481 <td class=
"cell20"><a href=
"cpp/DocumentLoader/" title=
"link to the source directory of the C++ DocumentLoader example">DocumentLoader
</a></td>
482 <td class=
"cell80">This component works the same as the appropriate Java
483 example, but is implemented in C++.
</td>
486 <td class=
"cell20"><a href=
"cpp/counter/" title=
"link to the source directory of the C++ counter example">Counter
</a></td>
487 <td class=
"cell80">This demo shows how to implement a very simple UNO
488 component and how to access the UNO component from an executable.
</td>
491 <td class=
"cell20"><a href=
"cpp/remoteclient/" title=
"link to the source directory of the C++ remoteclient example">Remote client
</a></td>
492 <td class=
"cell80">The 'uno' program is used to export an arbitrary
493 service to other processes. In this example the com.sun.star.uno.Pipe
494 service (which is built in io-module) is exported. The client component
495 implements the
<a href=
"%DOXYGEN_PREFIX1%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XMain.html" title=
"link into the IDL reference to the interface com.sun.star.lang.XMain">
496 com.sun.star.lang.XMain
</a> interface. In the run method, it connects to
497 the servers process and retrieves an instance and does some calls on the
501 <td class=
"cell20"><a href=
"cpp/complextoolbarcontrols/" title=
"link to the source directory of the C++ complextoolbarcontrols example">complextoolbarcontrols
</a></td>
502 <td class=
"cell80">This example shows how to create a toolbar add-on with complex toolbar controls.
503 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>
511 <table class=
"table3">
514 <p>Additional information:
</p>
516 <a href=
"http://wiki.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/>
517 <a href=
"http://wiki.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/>
518 <a href=
"%DOXYGEN_PREFIX1%/docs/cpp/ref/index.html" title=
"link to the C++ API reference">C++ reference
</a>
527 <td class=
"content1"><img class=
"nothing8" src=
"../docs/images/nada.gif"/></td>
530 <td colspan=
"3"><img class=
"line" src=
"../docs/images/sdk_line-1.gif"/></td>
533 <td class=
"content1"><img class=
"nothing8" src=
"../docs/images/nada.gif"/></td>
535 <table class=
"table2">
538 <table class=
"table3">
540 <td colspan=
"2" class=
"head1"><a name=
"Basic_examples"/>LibreOffice %PRODUCT_RELEASE% Basic examples
</td>
542 <a href=
"#examples" title=
"link to the examples overview"><img class=
"navigate" src=
"../docs/images/nav_up.png"/></a>
543 <a href=
"../index.html" title=
"link to the SDK start page"><img class=
"navigate" src=
"../docs/images/nav_home.png"/></a>
548 <p>The example programs are embedded in LibreOffice %PRODUCT_RELEASE% documents in the
549 samples directory. To view or edit the LibreOffice %PRODUCT_RELEASE% Basic source,
550 select the appropriate document and then select Tools-
>Macro.
</p>
551 <p>Most of the examples are stand-alone, but two of them (Creating an
552 Index and Import/Export of ASCII Files) have an associated data file
553 identified by a .txt file name suffix).
</p>
554 <p>Some of the examples are also available in Java, you can find them in
555 the
<a href=
"#Java_examples" title=
"link to the Java examples section">
556 Java section
</a>.
</p>
564 <table class=
"table4">
567 <td class=
"cell20">Example
</td>
568 <td class=
"cell80">Description
</td>
571 <td class=
"cell20"><a href=
"basic/text/modifying_text_automatically/" title=
"link to the source directory of the LibreOffice %PRODUCT_RELEASE% Basic text/modifying_text_automatically examples">Changing Appearance
</a></td>
572 <td class=
"cell80"> To change the style used for certain words, you can
573 start with the following example. This code searches for the regular
574 expression
<code>the[a-z]
</code>, which stands for the text portion the
575 followed by exactly one lowercase letter. All occurrences of these four
576 letters are then changed to bold characters. The same happens in the next
577 part of the program, this time changing the appearance of
578 <code>all[a-z]
</code> to italic. In order for this example to work, you
579 must execute it from an open text document.
</td>
582 <td class=
"cell20"><a href=
"basic/text/modifying_text_automatically/" title=
"link to the source directory of the LibreOffice %PRODUCT_RELEASE% Basic text/modifying_text_automatically examples">Replacing Text
</a></td>
583 <td class=
"cell80">If you regularly receive documents from other people
584 for editing, you might want to make sure that certain words are always
585 written the same. The next example illustrates this by forcing certain
586 words to be spelled in American English.
<br/>
587 In order for this example to work, you must execute it from an open text
588 document. For a real world application, it is a good idea to read the
589 words from an external file.
</td>
592 <td class=
"cell20"><a href=
"basic/text/modifying_text_automatically/" title=
"link to the source directory of the LibreOffice %PRODUCT_RELEASE% Basic text/modifying_text_automatically examples">Using Regular Expressions
</a></td>
593 <td class=
"cell80">Another application of automatic text modification is
594 related to stylistic questions. Suppose your company
’s policy is to
595 avoid the use of certain words. You want to replace these words, but you
596 cannot do that automatically because you have to find the appropriate
597 replacement, which depends on the context. So instead of deleting or
598 replacing the offending words automatically, you change their color to
599 make them stand out during a subsequent manual review process.
<br/>
600 The following example handles two kinds of unwanted wordings: those
601 which are absolutely forbidden and must be replaced by something else,
602 and those which are considered bad style. A subroutine is responsible
603 for the changes. It can be used to make all words in a list appear in a
604 certain color in the text document. To keep the lists short, we use
605 regular expressions which provide for the variants of the words
606 (plural, adjective etc.).
</td>
609 <td class=
"cell20"><a href=
"basic/text/modifying_text_automatically/" title=
"link to the source directory of the LibreOffice %PRODUCT_RELEASE% Basic text/modifying_text_automatically examples">Inserting Bookmarks
</a></td>
611 <p>The next example does something very similar. This time, however, we
612 do not change the color of the words but insert a bookmark at each of
613 them. You can thus use the StarOffice navigator to jump directly from
614 word to word. Bookmarks must first be created using
615 <code>createInstance()
</code>. They are then inserted with
616 <code>insertTextContent()
</code> at the current text range.
</p>
617 <p>The main difference to the preceding example is the For loop in
618 <code>markList()
</code>. Instead of changing the color of the current
619 word, it creates a new bookmark, oBookmark, whose name is the current
620 word with an integer appended. It then inserts this bookmark at the
624 <td class=
"cell20"><a href=
"basic/text/creating_an_index/" title=
"link to the source directory of the LibreOffice %PRODUCT_RELEASE% Basic text/create_index example">Creating an Index
</a></td>
625 <td class=
"cell80">Indices for text documents can be created manually in
626 LibreOffice %PRODUCT_RELEASE% Writer by clicking on the words that should appear in the
627 index. If the document is large, or if you have to generate indices for
628 several documents, this task should be automated.
</td>
631 <td class=
"cell20"><a href=
"basic/sheet/" title=
"link to the source directory of the LibreOffice %PRODUCT_RELEASE% Basic sheet example">Adapting to Euroland
</a></td>
632 <td class=
"cell80">Most of the members of the European Union will abandon
633 their old currency in favor of the new Euro in
2001. This requires
634 modifications to all programs using the old currencies. Since the exchange
635 rates for the old currencies have been fixed at the end of
1999, one can
636 already convert old data. The following program does this for all values
637 in a table that are formatted with the currency string DM.
</td>
640 <td class=
"cell20"><a href=
"basic/drawing/" title=
"link to the source directory of the LibreOffice %PRODUCT_RELEASE% Basic drawing example">Import/Export of ASCII Files
</a></td>
641 <td class=
"cell80">You can use the drawing facilities of StarOffice API
642 to generate a picture from ASCII input. One application would be a
643 hierarchical representation of a directory listing, based on textual
647 <td class=
"cell20"><a href=
"basic/stock_quotes_updater/" title=
"link to the source directory of the LibreOffice %PRODUCT_RELEASE% Basic stock_quotes_updater example">Stock Quotes Updater
</a></td>
648 <td class=
"cell80">If you want to display stock charts for certain
649 companies, you can open up your browser every day, go to a search engine,
650 look up the quote and copy it by hand into a table. Or you can use a
651 program that does all this automatically. The following example relies on
652 the sheet module. It uses URLs to obtain the current stock quotes. The
653 quotes are displayed in sheets, one for each company. We show a line
654 diagram and the numerical values for this company on every sheet. The
655 functionality is hidden in the three subroutines
<code>GetValue()
</code>,
656 <code>UpdateValue()
</code>, and
<code>UpdateChart()
</code>.
</td>
659 <td class=
"cell20"><a href=
"basic/forms_and_controls/" title=
"link to the source directory of the LibreOffice %PRODUCT_RELEASE% Basic forms_and_controls example">Forms and Controls
</a></td>
660 <td class=
"cell80">The example document Burger Factory offers some forms
661 and controls, which you can use to order your desired burger type,
662 beverage, topping, and sauce. By hitting the button
663 "Order now!
", your order will be placed.
</td>
671 <table class=
"table3">
674 Additional information:
<a href=
"http://wiki.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>
682 <td class=
"content1"><img class=
"nothing8" src=
"../docs/images/nada.gif"/></td>
685 <td colspan=
"3"><img class=
"line" src=
"../docs/images/sdk_line-1.gif"/></td>
688 <td class=
"content1"><img class=
"nothing8" src=
"../docs/images/nada.gif"/></td>
690 <table class=
"table2">
693 <table class=
"table3">
695 <td colspan=
"2" class=
"head1"><a name=
"OLE_examples"/>Object Linking and Embedding (OLE) examples
</td>
697 <a href=
"#examples" title=
"link to the examples overview"><img class=
"navigate" src=
"../docs/images/nav_up.png"/></a>
698 <a href=
"../index.html" title=
"link to the SDK start page"><img class=
"navigate" src=
"../docs/images/nav_home.png"/></a>
706 <table class=
"table4">
709 <td class=
"cell20">Example
</td>
710 <td class=
"cell80">Description
</td>
713 <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>
714 <td class=
"cell80">The ActiveX control shows an example of access to UNO
715 through COM technology. It requires a properly installed StarOffice
716 version
6.0 or OpenOffice
1.0 or newer. This is a Lite ActiveX control
717 so it can be used only in containers that allow the use of such controls.
718 It can be activated with an
<OBJECT
> tag from a html-page to embed
719 a document. Without any parameters a new writer document will be opened
720 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/>
721 Note: This example works only under windows and if you don't use the MS
722 .Net C++ compiler please check the makefile and take notice of the
726 <td class=
"cell20"><a href=
"OLE/vbscript/" title=
"link to the source directory of the VBScript example using the OLE bridge">WriterDemo
</a></td>
727 <td class=
"cell80">This Visual Basic Script creates an empty text
728 document and inserts text, a table, and a text frame.
</td>
736 <table class=
"table3">
739 Additional information:
<a href=
"http://wiki.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>
747 <td class=
"content1"><img class=
"nothing8" src=
"../docs/images/nada.gif"/></td>
750 <td colspan=
"3"><img class=
"line" src=
"../docs/images/sdk_line-1.gif"/></td>
753 <td class=
"content1"><img class=
"nothing8" src=
"../docs/images/nada.gif"/></td>
755 <table class=
"table2">
758 <table class=
"table3">
760 <td colspan=
"2" class=
"head1"><a name=
"CLI_examples"/>Common Language Infrastructure (CLI) examples
</td>
762 <a href=
"#examples" title=
"link to the examples overview"><img class=
"navigate" src=
"../docs/images/nav_up.png"/></a>
763 <a href=
"../index.html" title=
"link to the SDK start page"><img class=
"navigate" src=
"../docs/images/nav_home.png"/></a>
771 <table class=
"table4">
774 <td class=
"cell20">Example
</td>
775 <td class=
"cell80">Description
</td>
778 <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>
779 <td class=
"cell80">This example is written in C# and shows how Spreadsheet
780 documents are created and filled with content. This example actually
781 consists of three separate executables, SpreadsheetSample.exe,
782 GeneralTableSample.exe, ViewSample.exe.
</td>
785 <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>
786 <td class=
"cell80">This example is written in VB.NET. It creates a text
787 document and inserts text, a table, and a text frame.
</td>
795 <table class=
"table3">
798 Additional information:
<a href=
"http://wiki.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>
806 <td class=
"content1"><img class=
"nothing8" src=
"../docs/images/nada.gif"/></td>
811 <div id=
"FooterText">
813 Copyright ©
2000,
2015 LibreOffice contributors. All rights reserved.
815 LibreOffice was created by The Document Foundation,
816 based on Apache OpenOffice, which is Copyright
2011
817 The Apache Software Foundation.
819 The Document Foundation acknowledges all community members, please find more info
<a href=
"https://www.libreoffice.org/about-us/credits/" target=
"_blank">at our website
</a>.
825 <a href=
"http://www.documentfoundation.org/privacy" target=
"_blank">Privacy Policy
</a> |
<a href=
"http://www.documentfoundation.org/imprint" target=
"_blank">Impressum (Legal Info)
</a>
826 | Copyright information: The source code of LibreOffice is licensed under the Mozilla Public License v2.0 (
<a href=
"http://www.libreoffice.org/download/license/" target=
"_blank">MPLv2
</a>).
"LibreOffice" and
"The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our
<a href=
"http://wiki.documentfoundation.org/TradeMark_Policy" target=
"_blank">trademark policy
</a>.