Hallo Svante; thanks for you reply :-) I will create the JIIRA issue on tuesday. I am not in office for the weekend...
See you! Georg 2016-05-26 17:45 GMT+02:00 Svante Schubert <[email protected]>: > Hello Georg, > > it sounds indeed like an issue of the Simple API. > > The best you can do, is to open an issue and most important provide your > use case as source code that may become a later regression test, so someone > can jump start to easily debug your scenario in general and the delete > method in special. > Look at the existing tests, the class org.odftoolkit.simple.text.SpanTest > looks most suitable to me. > > PS: Only speaking for myself, but if there is an existing test, I am much > more motivated to invest some time to debug. Otherwise we might be cross > talking and the set up eats all my spare time.. > > Regards, > Svante > > > 2016-05-24 16:54 GMT+02:00 Georg Füchsle <[email protected]>: > > > 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 > > >
