21.08.2013 Views

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The Structure of Text Documents 95<br />

FileNo = Freefile<br />

Open Filename For Output As #FileNo<br />

Print #FileNo, ""<br />

Doc = StarDesktop.CurrentComponent<br />

Enum1 = Doc.Text.createEnumeration<br />

' loop over all paragraphs<br />

While Enum1.hasMoreElements<br />

TextElement = Enum1.nextElement<br />

If TextElement.supportsService("com.sun.star.text.Paragraph") Then<br />

Enum2 = TextElement.createEnumeration<br />

CurLine = ""<br />

' loop over all paragraph portions<br />

While Enum2.hasMoreElements<br />

TextPortion = Enum2.nextElement<br />

If TextPortion.CharWeight = com.sun.star.awt.FontWeight.BOLD THEN<br />

CurLine = CurLine & "" & TextPortion.String<br />

& ""<br />

Else<br />

CurLine = CurLine & TextPortion.String<br />

End If<br />

Wend<br />

' output the line<br />

CurLine = CurLine & ""<br />

Print #FileNo, CurLine<br />

End If<br />

Wend<br />

' write HTML footer<br />

Print #FileNo, ""<br />

Close #FileNo<br />

The basic structure of the example is oriented towards the examples for running though the<br />

paragraph portions of a text already discussed previously. The functions for writing the<br />

HTML file, as well as a test code that checks the font weight of the corresponding text<br />

portions and provides paragraph portions in bold type with a corresponding HTML tag,<br />

have been added.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!