Uploaded image for project: 'ODF Toolkit'
  1. ODF Toolkit
  2. ODFTOOLKIT-435

the call of TextSelection.createSpanElement() adds invalide line-breaks

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.6.2-incubating
    • simple api
    • None

    Description

      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.

      I attach a path-file including a JUnit test (SpanTest.testCreateSpanElement) that demonstrates this behavior.
      The path also includes a manipulated function
      TextSelection.createSpanElementInclLineBreak()
      that itself calls again a manipulated function
      TextSelection.deleteInclLineBreak(int fromIndex, int leftLength, Node pNode)
      instead of TextSelection.delete (...). With this function the test will succeed.

      What I do not have in track:
      1. May the function delete(...) be replaced in everey circumstances?
      2. Should also other tags than 'line-break' be considered as well? (for example 'tab') ?

      Attachments

        1. SpanTest.diff
          2 kB
          Georg Füchsle
        2. TextSelection.diff
          0.6 kB
          Georg Füchsle

        Activity

          People

            svanteschubert Svante Schubert
            giofyxle Georg Füchsle
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: