| <!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> |
| <!-- |
| CodeSnippet DTD |
| --> |
| <!ELEMENT snippet ( keywords, authors, versions?, operating-systems?, question, answer, changelog ) > |
| <!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 > |
| |
| |
| <!-- |
| Put as many sensible keywords into this secion as possible, each keyword in a separate element. |
| --> |
| <!ELEMENT keywords <a href="#3">[3]</a> ( keyword+ ) > |
| <!ELEMENT keyword (#PCDATA)> |
| |
| |
| <!-- |
| 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. |
| --> |
| <!ELEMENT authors ( author+ ) > <a href="#4">[4]</a> |
| <!ELEMENT author (#PCDATA)> |
| <!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> |
| |
| <!-- |
| 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>. |
| --> |
| <!ELEMENT question <a href="#9">[9]</a> (#PCDATA|p|listing)*> |
| <!ATTLIST question |
| heading <a href="#10">[10]</a> CDATA #REQUIRED> |
| |
| <!-- |
| The answer to the question |
| --> |
| <!ELEMENT answer <a href="#11">[11]</a> ( p|listing )+> |
| |
| <!-- |
| The answer in english |
| --> |
| <!ELEMENT p ( #PCDATA|a|b|ul|code )*> |
| |
| <!ELEMENT listing <a href="#12">[12]</a> ( #PCDATA )* > |
| |
| <!-- |
| The changelog holds all changes made to the snippet including |
| the initial release |
| --> |
| <!ELEMENT changelog ( change+ )> |
| |
| <!-- |
| The change itself |
| --> |
| <!ELEMENT change <a href="#13">[13]</a> ( #PCDATA ) > |
| <!ATTLIST change |
| author-id <a href="#14">[14]</a> IDREF #REQUIRED |
| date <a href="#15">[15]</a> CDATA #REQUIRED> |
| |
| <!-- |
| a link to an external resource |
| --> |
| <!ELEMENT a (#PCDATA)> |
| <!ATTLIST a |
| href CDATA #REQUIRED> |
| |
| <!ELEMENT versions (version+)> |
| |
| <!ELEMENT version <a href="#16">[16]</a> EMPTY> |
| <!ATTLIST version |
| number <a href="#17">[17]</a> CDATA #REQUIRED |
| status <a href="#18">[18]</a> (tested|untested|may_work|can_not_work)> |
| |
| <!ELEMENT operating-systems (operating-system+)> |
| <!ATTLIST operating-system |
| name <a href="#19">[19]</a> (Win32|Linux|Solaris|MacOSX|All)> |
| |
| <!-- |
| make something bold |
| --> |
| <!ELEMENT b (#PCDATA)> |
| |
| <!ELEMENT ul (li+)> |
| |
| <!ELEMENT li (#PCDATA)> |
| |
| <!ELEMENT code (#PCDATA)> |
| </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. "OOBasic", "Java", "Cpp", |
| "Python", ... |
| </dd> |
| |
| <dt><a name=2></a>[2] - Application</dt> |
| <dd>Name the OOo application to which the code snippet applies, here. |
| E.g. "Writer", "Calc", "Impress", |
| "Draw", "Office", "Database". |
| Use "Office" 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="... |
| " 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 <question>...</question> element. |
| For further explanation you can use child elements, like <p>...</p> or <listing>...</listing>. |
| </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 <p>...</p>. You could use as many <p>'s as you want, nesting of <p>-Tags is not allowed. |
| </dd> |
| |
| <dt><a name=12></a>[12] - Code Listing</dt> |
| <dd>Use <listing>...</listing> for your code listing itself. |
| This tag will include <pre>, 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 |
| "tested", "untested", "may_work", |
| "can_not_work" |
| </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 "Win32", "Linux", |
| "Solaris", "MacOSX", "All". |
| </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> |
| |