Thank you Bernard!

I will try detecting form controls,
Elena


On Fri, Aug 22, 2014 at 10:32 AM, Bernard Marcelly <
marce...@club-internet.fr> wrote:

> Hello Elena,
>
> When OpenOffice opens a text document, it looks the same from the API, be
> it a .rtf or .doc or .odt document. There is no "RTF parsing" available
> from the API, the job is done by the import filter during loading of the
> document.
>
> With the API you can load a .rtf document and find if it contains a form
> and if the form contains controls of the type you want.
> The explanations in the Developer's Guide are indeed very abstract
> (chapter Forms). In fact it is simply embedded containers.
> - a text document has a DrawPage
> - the Drawpage "contains" shapes, and gives access to a container of Forms.
> - the container of Forms may contain one form, rarely several forms.
> - a Form is a container of controls
> - each type of control supports a specific service.
>
> So you can explore your document and find the controls it contains.
> Here is an example in OpenOffice Basic (I don't practice Java). It may
> help understand the Java examples of the Developer's Guide.
>
> Dim aDoc As Object, aPage As Object
> Dim allForms As Object, allControls As Object
> Dim aForm As Object, aControl As Object
> Dim x As Long, y As Long
> Dim nbCheckBox As Long, nbTextF As Long, nbCtrl As Long
>
> nbCheckBox = 0
> nbTextF = 0
> nbCtrl = 0
> aDoc = ThisComponent
>
> aPage = aDoc.getDrawpage()
> allForms = aPage.getForms()
> for x = 0 to allForms.getCount() -1
>   aForm = allForms.getByIndex(x)
>   nbCtrl = nbCtrl +aForm.getCount()
>   for y = 0 to aForm.getCount() -1
>     aControl = aForm.getByIndex(y)
>     if aControl.supportsService("com.sun.star.form.component.CheckBox")
> then
>       nbCheckBox = nbCheckBox +1
>     end if
>     if aControl.supportsService("com.sun.star.form.component.TextField")
> then
>       nbTextF = nbTextF +1
>     end if
>   next
> next
>
> MsgBox("Number of controls : " & nbCtrl & chr(13) & _
>   "CheckBoxes : " & nbCheckBox & "  TextFields : " & nbTextF)
>
>
> Regards
>   Bernard
>
> Message de Elena Sergienko  date 2014-08-21 16:49 :
>
>  Dear OpenOffice API community,
>>
>> I have a set of RTF files. My project is to write a Java program to
>> identify which of those files contain form elements like checkboxes and
>> edit fields. Upon my long hours of researching online on how to do it I
>> was
>> not able to find an obvious way to parse RTF file structure and identify
>> its elements besides the plain text. I installed OOo 4.1.0 and OOo SDK
>> 4.1.0 hoping that it offers RTF parsing.
>> Please confirm whether OOo has the relative to my problem solution, and if
>> so I am hoping you can point me in the right direction.
>>
>> Thank you,
>> Elena
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org
> For additional commands, e-mail: api-h...@openoffice.apache.org
>
>


-- 
Elena Sergienko
Green Filing, LLC

Web: www.greenfiling.com
Phone: (801) 448-7268
Cell: (765) 277-3173

Reply via email to