Apache OpenOffice (AOO) Bugzilla – Issue 64915
OooBasic Null character at end of the string of a cursor
Last modified: 2013-02-24 21:07:09 UTC
In a macro of OoooBasic, a cursor has size 32767 (i.e. covers 32767 characters, counting a paragraph end as one character). The last character of the string of this cursor is said to have Asc 0. The macro is short, so I take leave to copy it here : Sub NullCharacterAtEndOfCursor() Dim ourDocument As Object Dim ourViewCursor As Object Dim i As Long Dim specialChar As Integer Dim ourText As Object Dim ourCursor As Object Dim ourString As String Dim noFileProp() ourDocument = StarDesktop.LoadComponentFromURL ("private:factory/swriter", "_blank", 0, noFileProp) ourViewCursor = ThisComponent.CurrentController.getViewCursor() ourText = ourViewCursor.getText() specialChar = com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK For i = 1 To 2048 ourText.insertString(ourViewCursor, "abcdefghijklmno", False) ourText.insertControlCharacter(ourViewCursor, specialChar, False) Next ' The document has thus 2048 X 16 = 32768 characters, ' if we count a paragraph end as one character. ourCursor = ourText.createTextCursor() ' Is at the start of the text. ourCursor.goRight(32767, True) ' With the following command, we verify that ourCursor ends just before the last character ' (paragraph end) which was inserted by the macro. ourViewCursor.goToRange(ourCursor.getEnd(), False) ' OK. ' Even one cursor position can correspond to ' two string characters (Chr(13) & Chr(10)), 32767 positions give at most ' 65534 string characters, thus ourCursor.getString() puts no problem. ourString = ourCursor.getString() '''''''''''''''''' MsgBox "The last character of ourString, given by Right(..., 1) has Asc : " & Asc(Right(ourString, 1)) ' The preceding MsgBox says that the Asc is 0. ??? MsgBox "The length (Len) of ourString is " & Len(ourString) ' The preceding MsgBox says that the length of ourString is 34815. ' Since there are 32767 "screen characters" and therein 2047 paragraph ends, ' one would expect 32767 + 2047 = 34814 characters in the string. End Sub
The bug appears when retrieving more than 10327 characters with an API .getString() method. Same behaviour appears in version 1.1.4. (tested with Win XP SP2). Next attachment demonstrates this easily.
Created attachment 36159 [details] Demo of long string bug
Reassigned to JSK.
Forward to cn -> this is API
cn->tl: I could reproduce this.
.
Fixed in CWS tl21. Files changed: - sw/source/core/unocore/unoobj.cxx - sw/source/core/edit/edglss.cxx
. re-open issue and reassign to cn@openoffice.org
reassign to cn@openoffice.org
reset resolution to FIXED
ok in tl14
ok in src680_m181