n_xls_data.sru 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. $PBExportHeader$n_xls_data.sru
  2. forward
  3. global type n_xls_data from nonvisualobject
  4. end type
  5. end forward
  6. global type n_xls_data from nonvisualobject
  7. end type
  8. global n_xls_data n_xls_data
  9. type variables
  10. PUBLIC INTEGER ii_fnum = 1
  11. PROTECTED UINT ii_max_current_size = 4048
  12. PROTECTED BLOB ib_arr[]
  13. PROTECTED ULONG il_count
  14. PROTECTED ULONG il_total_size
  15. PROTECTED UINT ii_current_size = 4048
  16. end variables
  17. forward prototypes
  18. protected function integer of_add_item ()
  19. public function integer of_append (ref blob ab_data)
  20. public function integer of_write (olestream ai_stream)
  21. end prototypes
  22. protected function integer of_add_item ();integer li_ret = 1
  23. il_count ++
  24. ii_current_size = 0
  25. return li_ret
  26. end function
  27. public function integer of_append (ref blob ab_data);INTEGER li_ret = 1
  28. ULONG ll_size
  29. UINT li_right_size
  30. BLOB lb_part
  31. ll_size = LEN(ab_data)
  32. DO While ll_size > 0
  33. IF ii_current_size = ii_max_current_size THEN
  34. of_add_item()
  35. END IF
  36. IF ll_size <= ii_max_current_size - ii_current_size THEN
  37. IF ii_current_size = 0 THEN
  38. ib_arr[il_count] = ab_data
  39. ELSE
  40. ib_arr[il_count] = ib_arr[il_count] + ab_data
  41. END IF
  42. ii_current_size = ii_current_size + ll_size
  43. il_total_size += ll_size
  44. ll_size = 0
  45. ELSE
  46. li_right_size = ii_max_current_size - ii_current_size
  47. lb_part = BLOBMID(ab_data, 1, li_right_size)
  48. ab_data = BLOBMID(ab_data, li_right_size + 1, ll_size - li_right_size)
  49. ll_size -= li_right_size
  50. IF ii_current_size = 0 THEN
  51. ib_arr[il_count] = lb_part
  52. ELSE
  53. ib_arr[il_count] = ib_arr[il_count] + lb_part
  54. END IF
  55. ii_current_size += li_right_size
  56. il_total_size += li_right_size
  57. END IF
  58. LOOP
  59. RETURN li_ret
  60. end function
  61. public function integer of_write (olestream ai_stream);INTEGER li_ret = 1
  62. ULONG ll_i
  63. BLOB lb_emp[]
  64. FOR ll_i = 1 TO il_count
  65. IF ll_i = il_count THEN
  66. ai_stream.WRITE(BLOBMID(ib_arr[ll_i], 1, ii_current_size))
  67. ELSE
  68. ai_stream.WRITE(BLOBMID(ib_arr[ll_i], 1, ii_max_current_size))
  69. END IF
  70. NEXT
  71. ib_arr = lb_emp
  72. RETURN li_ret
  73. end function
  74. on n_xls_data.create
  75. call super::create
  76. TriggerEvent( this, "constructor" )
  77. end on
  78. on n_xls_data.destroy
  79. TriggerEvent( this, "destructor" )
  80. call super::destroy
  81. end on