Hallo,

the call of TextSelection.createSpanElement() adds invalide line-breaks to
the father paragraph if the paragraph has line-breaks included.

For example:
We use a Paragraph "para" that correspondes to following xml:

<text:p text:style-name="a4cb5f8">before
lb<text:line-break></text:line-break>after lb</text:p>

        Paragraph para =  ...
        TextSelection tSel = TextSelection.newTextSelection(null,
para.getTextContent().replaceAll("\r\n", "\n"), para.getOdfElement(),
0);
        TextSpanElement tspan = tSel.createSpanElement();

After the call " tSel.createSpanElement()" the text is wrapped into a span
but the span is followed by an additional line-break:

<text:p text:style-name="a4cb5f8"><text:span>before
lb<text:line-break></text:line-break>after
lb</text:span><text:line-break></text:line-break></text:p>


In our opinion the reason is in the function:
     private void TextSection.delete(int fromIndex, int leftLength, Node
pNode)
Here  the text is deleted from the Paragraph but the line-breaks will
remain. After the call of delete() the text is reentered into the new span.
In this way the line-break exits twice: Once inside the span once after the
span.


We expect to receive:
<text:p text:style-name="a4cb5f8"><text:span>before
lb<text:line-break></text:line-break>after lb</text:span></text:p>

What should we do?

thanks in advance,

Georg

Reply via email to