You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openoffice.apache.org by bu...@apache.org on 2013/09/29 16:22:04 UTC

[Bug 123385] New: getString and setString lack symmetry : CR --> CRLF

https://issues.apache.org/ooo/show_bug.cgi?id=123385

            Bug ID: 123385
        Issue Type: DEFECT
           Summary: getString and setString lack symmetry : CR --> CRLF
           Product: Writer
           Version: 4.0.0
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: programming
          Assignee: issues@openoffice.apache.org
          Reporter: j.tronel@hotmail.fr
                CC: issues@openoffice.apache.org

Created attachment 81675
  --> https://issues.apache.org/ooo/attachment.cgi?id=81675&action=edit
GetString converts CR to CRLF

Hi,

Appended file uses following (very basic!) macro :

Sub Main
    doc = ThisComponent
    source = doc.CurrentSelection(0)
    dest = doc.Text.End
    dest.SetString(source.GetString)
End Sub

Selecting entire text and pushing button ought to append a second copy.

But a linefeed is added after each end of paragraph.

Seems that GetString converts CR to CRLF, but SetString does not reverse the
process.

Not deadly indeed, but annoying for anybody unaware of the problem.

A possible workaround :

Sub Main
    doc = ThisComponent
    source = doc.CurrentSelection(0)
    dest = doc.Text.End
    dest.SetString(Join(Split(source.GetString,Chr(13)&Chr(10)),Chr(13)))
End Sub

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Bug 123385] getString and setString lack symmetry : CR --> CRLF

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123385

Casey Doran <cd...@my.fit.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cdoran2011@my.fit.edu

--- Comment #1 from Casey Doran <cd...@my.fit.edu> ---
Created attachment 81764
  --> https://issues.apache.org/ooo/attachment.cgi?id=81764&action=edit
Replication of bug 123385 on Windows 8.

Hi,

I was able to replicate the bug you described on Windows 8 x64 in 400m3 (build
9702). As line endings on Win8 are CR/LF as opposed to a single character (your
description implies you are probably on a different platform- mac/linux?), I
was not expecting to be able to replicate, but lo and behold, when using your
test document, selecting all and clicking the macro button actually doubles up
the CR/LFs. I've pasted the state of the document after macro execution into
notepad++ so that the linefeed characters are visible. A screenshot of this is
attached as 123385replication_win8.png

I've also verified that your workaround macro works as intended on Windows 8.

I tried to run your macro with the ascii characters 0 to 32 (to see if any
other control codes were being messed up), and nothing but the line feeds were
doubled.

This is a very headache-inducing bug, as having to craft such a workaround is
lots of extra work for a novice programmer working on some office automation.
This behavior is also not noted on the documentation page for this function:
http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/XTextRange.html#setString


Regards,

Casey Doran

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Issue 123385] getString returns LF (Chr(10)) instead of CR (Chr(13)) for a paragraph break

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123385

mroe <mr...@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|getString and setString     |getString returns LF
                   |lack symmetry : CR --> CRLF |(Chr(10)) instead of CR
                   |                            |(Chr(13)) for a paragraph
                   |                            |break

--- Comment #2 from mroe <mr...@gmx.net> ---
Remember: Writer <> (simple) Texteditor!

An end of a paragraph is not represented by a character like Chr( 13 ) rather
than as format entry like in HTML: <p>My text.</p>

Changing the given code to:

Option Explicit
Sub Main
 Dim doc As Object
 Dim source As Object
 Dim dest As Object
 Dim s As String
 Dim s1 As String
 Dim c As String
 Dim i As Integer
 doc = ThisComponent
 source = doc.CurrentSelection(0)
 s = source.GetString
 For i = 1 To Len( s )
   c = Mid( s, i, 1 )
   s1 = s1 & c & " : " & ASC( c ) & Chr( 10 )
 Next i
 dest = doc.Text.End
 dest.SetString( s )
End Sub

With this code you will see that a paragraph break is shown only as line feed
Chr( 10 ). (The empty line is the representation of the line break ASC( Chr( 10
))!)

If one select
end.</p><p>Next paragraph
source.getString() should return
"end." & Chr(13) & "Next paragraph"
and not
"end." & Chr(10) & "Next paragraph"

like at this time.

-- 
You are receiving this mail because:
You are on the CC list for the issue.
You are the assignee for the issue.
You are watching all issue changes.

[Bug 123385] getString and setString lack symmetry : CR --> CRLF

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123385

j.tronel@hotmail.fr changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Latest|---                         |4.0.1
    Confirmation on|                            |

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Issue 123385] getString and setString lack symmetry : CR --> CRLF

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123385

Edwin Sharp <el...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |needhelp
                 CC|                            |elish@apache.org

-- 
You are receiving this mail because:
You are on the CC list for the issue.
You are the assignee for the issue.
You are watching all issue changes.