A small typo, as I have not reloaded my XML my addition was missing:

<text:section text:display="true" text:name="myTest"
text:style-name="ac3c190">
<text:p>This is a paragraph...</text:p>
<text:list text:style-name="l6a4c3d" xml:id="list73387982">
<text:list-item>
<text:p text:style-name="ae1b664">this is the first item</text:p>
</text:list-item>
<text:list-item>
<text:p text:style-name="ae1b664">this is the second item</text:p>
</text:list-item>
<text:list-item>
<text:p text:style-name="P4">this is the third item More content!<text:span
text:style-name="Text"> More Span!</text:span>
</text:p>
</text:list-item>
</text:list>
</text:section>

On Fri, Oct 30, 2015 at 12:22 PM, Svante Schubert <[email protected]
> wrote:

> Hi Georg,
>
> I never worked on or with the simple API, which was once donated by IBM to
> the toolkit, but I took a quick look into your problem.
> As usual I have pasted your code example into one of the existing tests,
> in this case in the simple API list regression tests of package
> org.odftoolkit.simple.text.list
>
> The short answer, there is no high level (simple) API for format of list
> items aside of their numbering style. You need to add it to the simple API
> or go back to the lower level ODFDOM API. To go lower you go back to the
> XML level, you receive on the simple API list item its XML representation
> via
> item.getOdfElement()
>
> and receive its paragraph children via
> NodeList nodeList = item.getOdfElement().getElementsByTagName("text:p");
>
> during creation of the typed XML DOM tree their is still the high level
> ODFDOM paragraph class being used
> org.odftoolkit.odfdom.doc.text.OdfTextParagraph
> which you might want to use, but there should be other ways for instance
> to enhance Simple API..
>
> What it is in general missing in the current ODF Toolkit version but was
> added by the open-xchange fork, are high level positions of user objects
> within the document. Allowing not only to append some styles or search for
> some special content string, but point to a position to format. See an
> example of an ODF document with its representation as a list of changes (in
> JSON) in my mail to the OASIS ODF working group -
> https://lists.oasis-open.org/archives/office-collab/201507/msg00003.html
>
>
>
> Your example in full within the test of :
> org.odftoolkit.simple.text.list.ListItemTest
>
>     @Test
>     public void testFormatTextContent() {
>         try {
> TextDocument odtdoc = (TextDocument)
> TextDocument.loadDocument(ResourceUtilities
>     .getTestResourceAsStream(SAMPLE_LIST_DOCUMENT));
>
> Section s1 = odtdoc.appendSection("myTest");
> Paragraph p2 = s1.addParagraph("This is a paragraph...");
>
> List list = s1.addList();
> list.setDecorator(new NumberDecorator(odtdoc));
> ListItem item = list.addItem("this is the first item");
> item = list.addItem("this is the second item");
> item = list.addItem("this is the third item");
> NodeList nodeList = item.getOdfElement().getElementsByTagName("text:p");
> if(nodeList.getLength() > 0){
>     TextPElement textP = (TextPElement) nodeList.item(0);
>     if(textP instanceof OdfTextParagraph){
>         String styleName = "P4";
>         String content = " More content!";
>         String spanStyleName = "Text";
>         String spanContent = " More Span!";
>             ((OdfTextParagraph) textP).addStyledContent(styleName,
> content).addStyledSpan(
> spanStyleName, spanContent);
>     }
> }
>
>
> odtdoc.save(ResourceUtilities.getTestOutputFolder().concat("myExampleList.odt"));
>
> }
>
> The new XML being generated:
>
> <text:section text:display="true" text:name="myTest"
> text:style-name="a9a60a2">
> <text:p>This is a paragraph...</text:p>
> <text:list text:style-name="l4bd2d4" xml:id="list65104419">
> <text:list-item>
> <text:p text:style-name="a7af3c1">this is the first item</text:p>
> </text:list-item>
> <text:list-item>
> <text:p text:style-name="a7af3c1">this is the second item</text:p>
> </text:list-item>
> <text:list-item>
> <text:p text:style-name="a7af3c1">this is the third item</text:p>
> </text:list-item>
> </text:list>
> </text:section>
>
> For the XML handling of ODF, I usually like to use JEdit application on
> desktop with the Archive extension allowing to open the content.xml within
> the ODT file and to edit and save it back (strangely works not for MS
> Office created ODT) and the XML JEdit extension to indent the XML with some
> key shortcut..
>
> Hope it helps,
> Svante
>
>
> On Thu, Oct 29, 2015 at 11:07 AM, Georg Füchsle <[email protected]>
> wrote:
>
>> Hallo,
>>
>> I create list Items by:
>>
>>         Paragraph p2 = s1.addParagraph("This is a paragraph...");
>>
>>         List list = s1.addList();
>>         list.setDecorator(new NumberDecorator(target));
>>         ListItem item = list.addItem("this is the first item");
>>         item = list.addItem("this is the second item");
>>         item = list.addItem("this is the third item");
>>
>> How can I format the content of a list item? I tried to retieve a
>> TextSelection of the list item but i did not succeed.
>>
>> Thanks in advance.
>>
>> Gio
>>
>
>

Reply via email to