You are viewing a plain text version of this content. The canonical link for it is here.
Posted to odf-users@incubator.apache.org by DevNews <De...@safir-wid.de> on 2018/07/06 16:57:01 UTC

relationship between OdfElement and Control

Hallo,

I am afraid, that I don‘t understand what are the scopes of OdfElements and Controls. Is there a possibility to get the corresponding Control from a OdfElement?
If someone can advice me something to read in order to understand the concept of OdfElement and Control, it would be great.


My concrete problem is:

I read a valid odt-document, that includes a marked <text:p>.
I find the OdfElement corresponding to the marked <text:p> by navigating through the document.

I can convert this OdfElement into a Paragraph by:
Paragraph paragraph = Paragraph.getInstanceof((TextParagraphElementBase)odfParagraph);

As the parent of this OdfElement actually includes a paragraph as a child it should be possible to convert the parent into a ParagraphContainer, isn’t it?

So I am looking for a function like:

ParagraphContainer  pcontainer = getParagraphContainer(paragraph.getOdfElement().getParentNode());

Can somebody give a hint, how to do this?

Or is there a function that gives me the Control from a OdfElement? (as I understood that the ParagraphContainer is a Control and not a OdfElement.)

Thanks in advance

Georg





________________________________
safir Wirtschaftsinformationsdienst GmbH
Sitz der Gesellschaft: Möllendorffstraße 49, 10367 Berlin
Geschäftsführer: Thilo Kind
Registergericht: Amtsgericht Berlin Charlottenburg, HRB 66681
USt-ID: DE 193584747
________________________________





-- 
This email was Malware checked by UTM 9. http://www.sophos.com

Re: relationship between OdfElement and Control

Posted by Svante Schubert <sv...@gmail.com>.
Dear ODF users,

here now the result from our call and the answer to Georg's question:

His user scenario:
Georg is providing for customers a template engine via ODF Toolkit.
The customer wants to divide their documents in a 2-dimensional hierarchy.
The upper document parts are called "area" and each "area" may have one or
more "fragments".
In the past, Georg solved the problem by providing nested sections for
areas and fragments, but now the customer would like to have an automatic
numeration for the areas.
Georg failed to add sections within lists and tried to work around this
problem.

In the call, I suggested continuing with his section approach but use
heading instead of lists to solve the numbering.
A quick prototype document created with LibreOffice using section and
heading was successful. (I manually enabling the numbering style for the
headings and afterwards quickly manipulating the content.xml to have nested
sections and some content within).

Problem solved, customer happy! :)

Cheers,
Svante


PS: Regarding his other general questions:

1) A good traversal routine for the DOM tree to copy & paste can always be
found in the toString() method of ODFElement. I added it in the very
beginning to have IDE tooltip support to show the content of the XML. :)

2) The general problem of where are the parents of paragraph (or any other
logical user objects) is something that is meant to be solved next winter
with an improved code generation from an ODF schema, which would get
additional user information of what XML elements are root elements of user
objects.

ᐧ

2018-07-09 15:32 GMT+02:00 Svante Schubert <sv...@gmail.com>:

> Hello Georg,
>
> I suggest you call me and provide additional information, like "How is the
> paragraph <text:p> being marked" during a dialogue and afterwards, I will
> write the answer for all to the list.
>
> Cheers,
> Svante
> ᐧ
>
> 2018-07-06 18:57 GMT+02:00 DevNews <De...@safir-wid.de>:
>
>> Hallo,
>>
>> I am afraid, that I don‘t understand what are the scopes of OdfElements
>> and Controls. Is there a possibility to get the corresponding Control from
>> a OdfElement?
>> If someone can advice me something to read in order to understand the
>> concept of OdfElement and Control, it would be great.
>>
>>
>> My concrete problem is:
>>
>> I read a valid odt-document, that includes a marked <text:p>.
>> I find the OdfElement corresponding to the marked <text:p> by navigating
>> through the document.
>>
>> I can convert this OdfElement into a Paragraph by:
>> Paragraph paragraph = Paragraph.getInstanceof((TextP
>> aragraphElementBase)odfParagraph);
>>
>> As the parent of this OdfElement actually includes a paragraph as a child
>> it should be possible to convert the parent into a ParagraphContainer,
>> isn’t it?
>>
>> So I am looking for a function like:
>>
>> ParagraphContainer  pcontainer = getParagraphContainer(paragrap
>> h.getOdfElement().getParentNode());
>>
>> Can somebody give a hint, how to do this?
>>
>> Or is there a function that gives me the Control from a OdfElement? (as I
>> understood that the ParagraphContainer is a Control and not a OdfElement.)
>>
>> Thanks in advance
>>
>> Georg
>>
>>
>>
>>
>>
>> ________________________________
>> safir Wirtschaftsinformationsdienst GmbH
>> Sitz der Gesellschaft: Möllendorffstraße 49, 10367 Berlin
>> Geschäftsführer: Thilo Kind
>> Registergericht: Amtsgericht Berlin Charlottenburg, HRB 66681
>> USt-ID: DE 193584747
>> ________________________________
>>
>>
>>
>>
>>
>> --
>> This email was Malware checked by UTM 9. http://www.sophos.com
>>
>
>

Re: relationship between OdfElement and Control

Posted by Svante Schubert <sv...@gmail.com>.
Hello Georg,

I suggest you call me and provide additional information, like "How is the
paragraph <text:p> being marked" during a dialogue and afterwards, I will
write the answer for all to the list.

Cheers,
Svante
ᐧ

2018-07-06 18:57 GMT+02:00 DevNews <De...@safir-wid.de>:

> Hallo,
>
> I am afraid, that I don‘t understand what are the scopes of OdfElements
> and Controls. Is there a possibility to get the corresponding Control from
> a OdfElement?
> If someone can advice me something to read in order to understand the
> concept of OdfElement and Control, it would be great.
>
>
> My concrete problem is:
>
> I read a valid odt-document, that includes a marked <text:p>.
> I find the OdfElement corresponding to the marked <text:p> by navigating
> through the document.
>
> I can convert this OdfElement into a Paragraph by:
> Paragraph paragraph = Paragraph.getInstanceof((TextParagraphElementBase)
> odfParagraph);
>
> As the parent of this OdfElement actually includes a paragraph as a child
> it should be possible to convert the parent into a ParagraphContainer,
> isn’t it?
>
> So I am looking for a function like:
>
> ParagraphContainer  pcontainer = getParagraphContainer(
> paragraph.getOdfElement().getParentNode());
>
> Can somebody give a hint, how to do this?
>
> Or is there a function that gives me the Control from a OdfElement? (as I
> understood that the ParagraphContainer is a Control and not a OdfElement.)
>
> Thanks in advance
>
> Georg
>
>
>
>
>
> ________________________________
> safir Wirtschaftsinformationsdienst GmbH
> Sitz der Gesellschaft: Möllendorffstraße 49, 10367 Berlin
> Geschäftsführer: Thilo Kind
> Registergericht: Amtsgericht Berlin Charlottenburg, HRB 66681
> USt-ID: DE 193584747
> ________________________________
>
>
>
>
>
> --
> This email was Malware checked by UTM 9. http://www.sophos.com
>