Issue 64915 - OooBasic Null character at end of the string of a cursor
Summary: OooBasic Null character at end of the string of a cursor
Status: CLOSED FIXED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC All
: P3 Trivial
Target Milestone: ---
Assignee: chne
QA Contact: issues@api
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-30 08:43 UTC by douxenfant
Modified: 2013-02-24 21:07 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Demo of long string bug (9.22 KB, application/vnd.sun.xml.writer)
2006-04-30 09:37 UTC, bmarcelly
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description douxenfant 2006-04-30 08:43:57 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
Comment 1 bmarcelly 2006-04-30 09:37:02 UTC
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.
Comment 2 bmarcelly 2006-04-30 09:37:54 UTC
Created attachment 36159 [details]
Demo of long string bug
Comment 3 michael.ruess 2006-05-02 08:15:20 UTC
Reassigned to JSK.
Comment 4 joerg.skottke 2006-05-02 13:28:36 UTC
Forward to cn -> this is API
Comment 5 chne 2006-05-03 07:29:46 UTC
cn->tl: I could reproduce this.
Comment 6 chne 2006-05-03 07:46:33 UTC
cn->tl: I could reproduce this.
Comment 7 thomas.lange 2006-05-18 09:50:57 UTC
.
Comment 8 thomas.lange 2006-05-18 09:52:03 UTC
Fixed in CWS tl21.

Files changed:
- sw/source/core/unocore/unoobj.cxx
- sw/source/core/edit/edglss.cxx
Comment 9 thomas.lange 2006-06-16 09:47:38 UTC
.

re-open issue and reassign to cn@openoffice.org
Comment 10 thomas.lange 2006-06-16 09:47:41 UTC
reassign to cn@openoffice.org
Comment 11 thomas.lange 2006-06-16 09:47:45 UTC
reset resolution to FIXED
Comment 12 chne 2006-06-26 16:20:13 UTC
ok in tl14
Comment 13 chne 2006-08-10 08:38:17 UTC
ok in src680_m181