blob: 6049554ebfb05f0b8f2d3d1be25054f2fdd5338f [file] [log] [blame]
<!DOCTYPE html>
<html><head>
<title>Code Snippets</title>
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
</head>
<body>
<h1>Code Snippets</h1>
<p>This is a collection of code snippets collected mostly from questions and answers from the mailing list dev@api.openoffice.org.</p>
<h2>Categories</h2>
<p>We have already collected several code snippets and under the <a href="http://codesnippets.services.openoffice.org/" title="Code Snippet Base">Code Snippet Base</a> you can see the for what the snippets are good for!</p>
<h2>How to Contribute</h2>
<p>We strongly encourage everybody who asks a question on dev@api.openoffice.org and who gets sufficient answers to summarize the answers either with the <a href="SnippetCreator-20060320.uno.pkg">snippet creator</a> or manually in the following template and send the xml code snippet (<a href="../../Examples/Snippets/CodeSnippet.dtd" title="Codesnippet DTD">DTD for validation</a>) to dev@api.openoffice.org:</p>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr><td>
<pre>
&lt;!--
CodeSnippet DTD
--&gt;
&lt;!ELEMENT snippet ( keywords, authors, versions?, operating-systems?, question, answer, changelog ) &gt;
&lt;!ATTLIST snippet
language <a href="#1">[1]</a> ( OOBasic|Java|Cpp|Python|OLE ) #REQUIRED
application <a href="#2">[2]</a> ( Writer|Calc|Impress|Draw|Office|Database ) #REQUIRED &gt;
&lt;!--
Put as many sensible keywords into this secion as possible, each keyword in a separate element.
--&gt;
&lt;!ELEMENT keywords <a href="#3">[3]</a> ( keyword+ ) &gt;
&lt;!ELEMENT keyword (#PCDATA)&gt;
&lt;!--
List the initial writers in this form (with initial="true"). Initial Writers is a term from the PDL (License).
If one of these authors assined copyright to somebody else, e.g. the company they are working for, use the attribute copyright="..."
and name the copyright holder.
--&gt;
&lt;!ELEMENT authors ( author+ ) > <a href="#4">[4]</a>
&lt;!ELEMENT author (#PCDATA)&gt;
&lt;!ATTLIST author
id <a href="#5">[5]</a> ID #REQUIRED
initial <a href="#6">[6]</a> CDATA #IMPLIED
email <a href="#7">[7]</a> CDATA #REQUIRED
copyright <a href="#8">[8]</a> CDATA #IMPLIED&gt;
&lt;!--
Put the part of the question which should be part of the overview index, as a direct child of the <question>...</question>
element. For further explanation you can use child elements, like <p>...</p>.
--&gt;
&lt;!ELEMENT question <a href="#9">[9]</a> (#PCDATA|p|listing)*&gt;
&lt;!ATTLIST question
heading <a href="#10">[10]</a> CDATA #REQUIRED&gt;
&lt;!--
The answer to the question
--&gt;
&lt;!ELEMENT answer <a href="#11">[11]</a> ( p|listing )+&gt;
&lt;!--
The answer in english
--&gt;
&lt;!ELEMENT p ( #PCDATA|a|b|ul|code )*&gt;
&lt;!ELEMENT listing <a href="#12">[12]</a> ( #PCDATA )* &gt;
&lt;!--
The changelog holds all changes made to the snippet including
the initial release
--&gt;
&lt;!ELEMENT changelog ( change+ )&gt;
&lt;!--
The change itself
--&gt;
&lt;!ELEMENT change <a href="#13">[13]</a> ( #PCDATA ) &gt;
&lt;!ATTLIST change
author-id <a href="#14">[14]</a> IDREF #REQUIRED
date <a href="#15">[15]</a> CDATA #REQUIRED&gt;
&lt;!--
a link to an external resource
--&gt;
&lt;!ELEMENT a (#PCDATA)&gt;
&lt;!ATTLIST a
href CDATA #REQUIRED&gt;
&lt;!ELEMENT versions (version+)&gt;
&lt;!ELEMENT version <a href="#16">[16]</a> EMPTY&gt;
&lt;!ATTLIST version
number <a href="#17">[17]</a> CDATA #REQUIRED
status <a href="#18">[18]</a> (tested|untested|may_work|can_not_work)&gt;
&lt;!ELEMENT operating-systems (operating-system+)&gt;
&lt;!ATTLIST operating-system
name <a href="#19">[19]</a> (Win32|Linux|Solaris|MacOSX|All)&gt;
&lt;!--
make something bold
--&gt;
&lt;!ELEMENT b (#PCDATA)&gt;
&lt;!ELEMENT ul (li+)&gt;
&lt;!ELEMENT li (#PCDATA)&gt;
&lt;!ELEMENT code (#PCDATA)&gt;
</pre>
</td></tr>
</table>
<p>
<dl>
<dt><a name=1></a>[1] - Programming Language</dt>
<dd>Name the programming language which is used for this code snipped, here.
E.g. &quot;OOBasic&quot;, &quot;Java&quot;, &quot;Cpp&quot;,
&quot;Python&quot;, ...
</dd>
<dt><a name=2></a>[2] - Application</dt>
<dd>Name the OOo application to which the code snippet applies, here.
E.g. &quot;Writer&quot;, &quot;Calc&quot;, &quot;Impress&quot;,
&quot;Draw&quot;, &quot;Office&quot;, &quot;Database&quot;.
Use &quot;Office&quot; if it is generic.
</dd>
<dt><a name=3></a>[3] - Keywords</dt>
<dd>Put as many sensible keywords into this section as possible, each keyword in a separate element.
</dd>
<dt><a name=4></a>[4] - List of authors/contributors </dt>
<dd>Use for each author/contributor a separatr element.
</dd>
<dt><a name=5></a>[5] - Id</dt>
<dd>Use your OpenOffice user name here.
</dd>
<dt><a name=6></a>[6] - Initial</dt>
<dd>List the initial writers in this form (with initial="true").
Initial Writers is a term from the PDL (License).
If one of these authors assigned copyright to somebody else, e.g.
the company they are working for, use the attribute copyright=&quot;...
&quot; and name the copyright holder.
</dd>
<dt><a name=7></a>[7] - Email</dt>
<dd>Use your email address here.
</dd>
<dt><a name=8></a>[8] - Copyright</dt>
<dd>Insert here your copyright if necessary.
</dd>
<dt><a name=9></a>[9] - Question</dt>
<dd>Put the part of the question which should be part of the overview index, as a direct child of the &lt;question&gt;...&lt;/question&gt; element.
For further explanation you can use child elements, like &lt;p&gt;...&lt;/p&gt; or &lt;listing&gt;...&lt;/listing&gt;.
</dd>
<dt><a name=10></a>[10] - Heading</dt>
<dd>Insert a short heading (abstract) here to identify the snippet (e.g. in the navigation overview).
</dd>
<dt><a name=11></a>[11] - Answer</dt>
<dd>Put the answer below this tag enclosed into &lt;p&gt;...&lt;/p&gt;. You could use as many &lt;p&gt;'s as you want, nesting of &lt;p&gt;-Tags is not allowed.
</dd>
<dt><a name=12></a>[12] - Code Listing</dt>
<dd>Use &lt;listing&gt;...&lt;/listing&gt; for your code listing itself.
This tag will include &lt;pre&gt;, thus line breaks in the source will be interpreted as such.
</dd>
<dt><a name=13></a>[13] - Change</dt>
<dd>Use this element to show changes.
</dd>
<dt><a name=14></a>[14] - Author-id</dt>
<dd>The ID of the author who has mamde the change.
</dd>
<dt><a name=15></a>[15] - Date</dt>
<dd>The date of the change.
</dd>
<dt><a name=16></a>[16] - Version</dt>
<dd>Use one or more version elements to show history.
</dd>
<dt><a name=17></a>[17] - Number</dt>
<dd>Used for the verison number
</dd>
<dt><a name=18></a>[18] - Status</dt>
<dd>Used to show the status of this version. Valid entires are
&quot;tested&quot;, &quot;untested&quot;, &quot;may_work&quot;,
&quot;can_not_work&quot;
</dd>
<dt><a name=20></a>[20] - Platform</dt>
<dd>Used to idnetiy the platform. Ideally the snippet contains no platform
specific code. Valid platforms are &quot;Win32&quot;, &quot;Linux&quot;,
&quot;Solaris&quot;, &quot;MacOSX&quot;, &quot;All&quot;.
</dd>
</dl>
</p>
<p>Open-Source-Software is <i>free</i> as in <i>free speech</i>, not necessary <i>free</i> as in <i>free beer</i>.
Thus, please <i>pay</i> those community members who answer your questions by contributing the summary.
If most community members support this system of collecting code snippets, we soon will have a great collection of such.
<p>Of course, if you answer a question, you are welcome to use the template as well.
</body>
</html>