To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=64915
                  Issue #:|64915
                  Summary:|OooBasic Null character at end of the string of a
                          |cursor
                Component:|Word processor
                  Version:|OOo 2.0
                 Platform:|PC
                      URL:|
               OS/Version:|All
                   Status:|UNCONFIRMED
        Status whiteboard:|
                 Keywords:|
               Resolution:|
               Issue type:|DEFECT
                 Priority:|P3
             Subcomponent:|code
              Assigned to:|mru
              Reported by:|douxenfant





------- Additional comments from [EMAIL PROTECTED] Sun Apr 30 00:43:57 -0700 
2006 -------
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

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to