summaryrefslogtreecommitdiff
path: root/wizards/source/access2base/Field.xba
blob: 871133f2eba6fc354d352a36122f0b15ccee55a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Field" script:language="StarBasic">REM =======================================================================================================================
REM ===					The Access2Base library is a part of the LibreOffice project.									===
REM ===					Full documentation is available on http://www.access2base.com									===
REM =======================================================================================================================

Option Compatible
Option ClassModule

Option Explicit

REM -----------------------------------------------------------------------------------------------------------------------
REM --- CLASS ROOT FIELDS 								        														---
REM -----------------------------------------------------------------------------------------------------------------------

Private	_Type					As String				&apos;	Must be FIELD
Private _Name					As String
Private _ParentName				As String
Private _ParentType				As String
Private _ParentDatabase			As Object
Private Column					As Object				&apos;	com.sun.star.sdb.OTableColumnWrapper
											&apos;			or	org.openoffice.comp.dbaccess.OQueryColumn
											&apos;			or	com.sun.star.sdb.ODataColumn

REM -----------------------------------------------------------------------------------------------------------------------
REM --- CONSTRUCTORS / DESTRUCTORS						        														---
REM -----------------------------------------------------------------------------------------------------------------------
Private Sub Class_Initialize()
	_Type = OBJFIELD
	_Name = &quot;&quot;
	_ParentName = &quot;&quot;
	_ParentType = &quot;&quot;
	Set Column = Nothing
End Sub		&apos;	Constructor

REM -----------------------------------------------------------------------------------------------------------------------
&apos;Private Sub Class_Terminate()

REM -----------------------------------------------------------------------------------------------------------------------
REM --- CLASS GET/LET/SET PROPERTIES					        														---
REM -----------------------------------------------------------------------------------------------------------------------

Property Get DataType() As Long		&apos;	AOO/LibO type
	DataType = _PropertyGet(&quot;DataType&quot;)
End Property		&apos;	DataType (get)

Property Get DataUpdatable() As Boolean
	DataUpdatable = _PropertyGet(&quot;DataUpdatable&quot;)
End Property		&apos;	DataUpdatable (get)

REM -----------------------------------------------------------------------------------------------------------------------
Property Get DbType() As Long		&apos;	MSAccess type
	DbType = _PropertyGet(&quot;DbType&quot;)
End Property		&apos;	DbType (get)

REM -----------------------------------------------------------------------------------------------------------------------
Property Get DefaultValue() As Variant
	DefaultValue = _PropertyGet(&quot;DefaultValue&quot;)
End Property		&apos;	DefaultValue (get)

Property Let DefaultValue(ByVal pvDefaultValue As Variant)
	Call _PropertySet(&quot;DefaultValue&quot;, pvDefaultValue)
End Property		&apos;	DefaultValue (set)

REM -----------------------------------------------------------------------------------------------------------------------
Property Get Description() As Variant
	Description = _PropertyGet(&quot;Description&quot;)
End Property		&apos;	Description (get)

Property Let Description(ByVal pvDescription As Variant)
	Call _PropertySet(&quot;Description&quot;, pvDescription)
End Property		&apos;	Description (set)

REM -----------------------------------------------------------------------------------------------------------------------
Property Get FieldSize() As Long
	FieldSize = _PropertyGet(&quot;FieldSize&quot;)
End Property		&apos;	FieldSize (get)

REM -----------------------------------------------------------------------------------------------------------------------
Property Get Name() As String
	Name = _PropertyGet(&quot;Name&quot;)
End Property		&apos;	Name (get)

REM -----------------------------------------------------------------------------------------------------------------------
Property Get ObjectType() As String
	ObjectType = _PropertyGet(&quot;ObjectType&quot;)
End Property		&apos;	ObjectType (get)

REM -----------------------------------------------------------------------------------------------------------------------
Property Get Size() As Long
	Size = _PropertyGet(&quot;Size&quot;)
End Property		&apos;	Size (get)

REM -----------------------------------------------------------------------------------------------------------------------
Property Get SourceField() As String
	SourceField = _PropertyGet(&quot;SourceField&quot;)
End Property		&apos;	SourceField (get)

REM -----------------------------------------------------------------------------------------------------------------------
Property Get SourceTable() As String
	SourceTable = _PropertyGet(&quot;SourceTable&quot;)
End Property		&apos;	SourceTable (get)

REM -----------------------------------------------------------------------------------------------------------------------
Property Get TypeName() As String
	TypeName = _PropertyGet(&quot;TypeName&quot;)
End Property		&apos;	TypeName (get)

REM -----------------------------------------------------------------------------------------------------------------------
Property Get Value() As Variant
	Value = _PropertyGet(&quot;Value&quot;)
End Property		&apos;	Value (get)

Property Let Value(ByVal pvValue As Variant)
	Call _PropertySet(&quot;Value&quot;, pvValue)
End Property		&apos;	Value (set)

REM -----------------------------------------------------------------------------------------------------------------------
REM --- CLASS METHODS	 								        														---
REM -----------------------------------------------------------------------------------------------------------------------

REM -----------------------------------------------------------------------------------------------------------------------
Public Function getProperty(Optional ByVal pvProperty As Variant) As Variant
&apos;	Return property value of psProperty property name

Const cstThisSub = &quot;Field.getProperty&quot;
	Utils._SetCalledSub(cstThisSub)
	If IsMissing(pvProperty) Then Call _TraceArguments()
	getProperty = _PropertyGet(pvProperty)
	Utils._ResetCalledSub(cstThisSub)
	
End Function		&apos;	getProperty

REM -----------------------------------------------------------------------------------------------------------------------
Public Function hasProperty(ByVal Optional pvProperty As Variant) As Boolean
&apos;	Return True if object has a valid property called pvProperty (case-insensitive comparison !)

Const cstThisSub = &quot;Field.hasProperty&quot;
	Utils._SetCalledSub(cstThisSub)
	If IsMissing(pvProperty) Then hasProperty = PropertiesGet._hasProperty(_Type, _PropertiesList()) Else hasProperty = PropertiesGet._hasProperty(_Type, _PropertiesList(), pvProperty)
	Utils._ResetCalledSub(cstThisSub)
	Exit Function
	
End Function	&apos;	hasProperty

REM -----------------------------------------------------------------------------------------------------------------------
Public Function Properties(ByVal Optional pvIndex As Variant) As Variant
&apos;	Return
&apos;		a Collection object if pvIndex absent
&apos;		a Property object otherwise

Dim vProperty As Variant, vPropertiesList() As Variant, sObject As String, sName As String
Const cstThisSub = &quot;Field.Properties&quot;
	Utils._SetCalledSub(cstThisSub)
	vPropertiesList = _PropertiesList()
	sObject = Utils._PCase(_Type)
	sName = _ParentType &amp; &quot;/&quot; &amp; _ParentName &amp; &quot;/&quot; &amp; _Name
	If IsMissing(pvIndex) Then
		vProperty = PropertiesGet._Properties(sObject, sName, vPropertiesList)
	Else
		vProperty = PropertiesGet._Properties(sObject, sName, vPropertiesList, pvIndex)
		vProperty._Value = _PropertyGet(vPropertiesList(pvIndex))
	End If
	Set vProperty._ParentDatabase = _ParentDatabase
	
Exit_Function:
	Set Properties = vProperty
	Utils._ResetCalledSub(cstThisSub)
	Exit Function
End Function	&apos;	Properties

REM -----------------------------------------------------------------------------------------------------------------------
Public Function ReadAllBytes(ByVal Optional pvFile As Variant) As Boolean
&apos;	Read the whole content of a file into Long Binary Field object

Const cstThisSub = &quot;Field.ReadAllBytes&quot;
	Utils._SetCalledSub(cstThisSub)
	If Not Utils._CheckArgument(pvFile, 1, vbString) Then Goto Exit_Function
	ReadAllBytes = _ReadAll(pvFile, &quot;ReadAllBytes&quot;)

Exit_Function:
	Utils._ResetCalledSub(cstThisSub)
	Exit Function
End Function		&apos;	ReadAllBytes

REM -----------------------------------------------------------------------------------------------------------------------
Public Function ReadAllText(ByVal Optional pvFile As Variant) As Boolean
&apos;	Read the whole content of a file into a Long Char Field object

Const cstThisSub = &quot;Field.ReadAllText&quot;
	Utils._SetCalledSub(cstThisSub)
	If Not Utils._CheckArgument(pvFile, 1, vbString) Then Goto Exit_Function
	ReadAllText = _ReadAll(pvFile, &quot;ReadAllText&quot;)

Exit_Function:
	Utils._ResetCalledSub(cstThisSub)
	Exit Function
End Function		&apos;	ReadAllText

REM -----------------------------------------------------------------------------------------------------------------------
Public Function setProperty(ByVal Optional psProperty As String, ByVal Optional pvValue As Variant) As Boolean
&apos;	Return True if property setting OK
Const cstThisSub = &quot;Field.setProperty&quot;
	Utils._SetCalledSub(cstThisSub)
	setProperty = _PropertySet(psProperty, pvValue)
	Utils._ResetCalledSub(cstThisSub)
End Function

REM -----------------------------------------------------------------------------------------------------------------------
Public Function WriteAllBytes(ByVal Optional pvFile As Variant) As Boolean
&apos;	Write the whole content of a Long Binary Field object to a file

Const cstThisSub = &quot;Field.WriteAllBytes&quot;
	Utils._SetCalledSub(cstThisSub)
	If Not Utils._CheckArgument(pvFile, 1, vbString) Then Goto Exit_Function
	WriteAllBytes = _WriteAll(pvFile, &quot;WriteAllBytes&quot;)

Exit_Function:
	Utils._ResetCalledSub(cstThisSub)
	Exit Function
End Function		&apos;	WriteAllBytes

REM -----------------------------------------------------------------------------------------------------------------------
Public Function WriteAllText(ByVal Optional pvFile As Variant) As Boolean
&apos;	Write the whole content of a Long Char Field object to a file

Const cstThisSub = &quot;Field.WriteAllText&quot;
	Utils._SetCalledSub(cstThisSub)
	If Not Utils._CheckArgument(pvFile, 1, vbString) Then Goto Exit_Function
	WriteAllText = _WriteAll(pvFile, &quot;WriteAllText&quot;)

Exit_Function:
	Utils._ResetCalledSub(cstThisSub)
	Exit Function
End Function		&apos;	WriteAllText

REM -----------------------------------------------------------------------------------------------------------------------
REM --- PRIVATE FUNCTIONS 								        														---
REM -----------------------------------------------------------------------------------------------------------------------

REM -----------------------------------------------------------------------------------------------------------------------
Private Function _PropertiesList() As Variant

	Select Case _ParentType
		Case OBJTABLEDEF
			_PropertiesList =Array(&quot;DataType&quot;, &quot;dbType&quot;, &quot;DefaultValue&quot; _
								, &quot;Description&quot;, &quot;Name&quot;, &quot;ObjectType&quot;, &quot;Size&quot;, &quot;SourceField&quot;, &quot;SourceTable&quot; _
								, &quot;TypeName&quot; _
								)
		Case OBJQUERYDEF
			_PropertiesList = Array(&quot;DataType&quot;, &quot;dbType&quot;, &quot;DefaultValue&quot; _
								, &quot;Description&quot;, &quot;Name&quot;, &quot;ObjectType&quot;, &quot;Size&quot;, &quot;SourceField&quot;, &quot;SourceTable&quot; _
								, &quot;TypeName&quot; _
								)
		Case OBJRECORDSET
			_PropertiesList = Array(&quot;DataType&quot;, &quot;DataUpdatable&quot;,  &quot;dbType&quot;, &quot;DefaultValue&quot; _
								, &quot;Description&quot; , &quot;FieldSize&quot;, &quot;Name&quot;, &quot;ObjectType&quot; _
								, &quot;Size&quot;, &quot;SourceTable&quot;, &quot;TypeName&quot;, &quot;Value&quot; _
								)
	End Select

End Function	&apos;	_PropertiesList

REM -----------------------------------------------------------------------------------------------------------------------
Private Function _PropertyGet(ByVal psProperty As String) As Variant
&apos;	Return property value of the psProperty property name

	If _ErrorHandler() Then On Local Error Goto Error_Function
Dim cstThisSub As String
	cstThisSub = &quot;Field.get&quot; &amp; psProperty
	Utils._SetCalledSub(cstThisSub)

	If Not hasProperty(psProperty) Then Goto Trace_Error

Dim vEMPTY As Variant, bCond1 As Boolean, bCond2 As Boolean, vValue As Variant, oValue As Object, sValue As String
Dim oSize As Object, lSize As Long, bNullable As Boolean, bNull As Boolean
Const cstMaxTextLength = 65535
	_PropertyGet = vEMPTY
	
	Select Case UCase(psProperty)
		Case UCase(&quot;DataType&quot;)
			_PropertyGet = Column.Type
		Case UCase(&quot;DbType&quot;)
			With com.sun.star.sdbc.DataType
				Select Case Column.Type
					Case .BIT				:	_PropertyGet = dbUndefined
					Case .TINYINT			:	_PropertyGet = dbInteger
					Case .SMALLINT			:	_PropertyGet = dbLong
					Case .INTEGER			:	_PropertyGet = dbLong
					Case .BIGINT			:	_PropertyGet = dbBigInt
					Case .FLOAT				:	_PropertyGet = dbFloat
					Case .REAL				:	_PropertyGet = dbSingle
					Case .DOUBLE			:	_PropertyGet = dbDouble
					Case .NUMERIC			:	_PropertyGet = dbNumeric
					Case .DECIMAL			:	_PropertyGet = dbDecimal
					Case .CHAR				:	_PropertyGet = dbText
					Case .VARCHAR			:	_PropertyGet = dbChar
					Case .LONGVARCHAR		:	_PropertyGet = dbMemo
					Case .DATE				:	_PropertyGet = dbDate
					Case .TIME				:	_PropertyGet = dbTime
					Case .TIMESTAMP			:	_PropertyGet = dbTimeStamp
					Case .BINARY			:	_PropertyGet = dbBinary
					Case .VARBINARY			:	_PropertyGet = dbVarBinary
					Case .LONGVARBINARY		:	_PropertyGet = dbLongBinary
					Case .BOOLEAN			:	_PropertyGet = dbBoolean
					Case Else				:	_PropertyGet = dbUndefined
				End Select
			End With
		Case UCase(&quot;DataUpdatable&quot;)
			If Utils._hasUNOProperty(Column, &quot;IsWritable&quot;) Then
				_PropertyGet = Column.IsWritable
			ElseIf Utils._hasUNOProperty(Column, &quot;IsReadOnly&quot;) Then
				_PropertyGet = Not Column.IsReadOnly
			ElseIf Utils._hasUNOProperty(Column, &quot;IsDefinitelyWritable&quot;) Then
				_PropertyGet = Column.IsDefinitelyWritable
			Else
				_PropertyGet = False
			End If
			If Utils._hasUNOProperty(Column, &quot;IsAutoIncrement&quot;) Then
				If Column.IsAutoIncrement Then _PropertyGet = False			&apos;	Forces False if auto-increment (MSAccess)
			End If
		Case UCase(&quot;DefaultValue&quot;)
			If Utils._hasUNOProperty(Column, &quot;DefaultValue&quot;) Then			&apos;	Default value in database set via SQL statement
				_PropertyGet = Column.DefaultValue
			ElseIf Utils._hasUNOProperty(Column, &quot;ControlDefault&quot;) Then		&apos;	Default value set in Base via table edition
			 	If IsEmpty(Column.ControlDefault) Then _PropertyGet = &quot;&quot; Else _PropertyGet = Column.ControlDefault
			Else
			 	_PropertyGet = &quot;&quot;
			End If
		Case UCase(&quot;Description&quot;)
			bCond1 = Utils._hasUNOProperty(Column, &quot;Description&quot;)
			bCond2 = Utils._hasUNOProperty(Column, &quot;HelpText&quot;)
			Select Case True
				Case ( bCond1 And bCond2 )
					If IsEmpty(Column.HelpText) Then _PropertyGet = Column.Description Else _PropertyGet = Column.HelpText
				Case ( bCond1 And ( Not bCond2 ) )
					_PropertyGet = Column.Description
				Case ( ( Not bCond1 ) And bCond2 )
					_PropertyGet = Column.HelpText
				Case Else
					_PropertyGet = &quot;&quot;
			End Select
		Case UCase(&quot;FieldSize&quot;)					&apos;	Probably physical size = 2 * unicode string length
			With com.sun.star.sdbc.DataType
				Select Case Column.Type
					Case .LONGVARCHAR
						Set oSize = Column.getCharacterStream
					Case .LONGVARBINARY, .VARBINARY, .BINARY
						Set oSize = Column.getBinaryStream
					Case Else
						Set oSize = Nothing
				End Select
			End With
			If Not IsNull(oSize) Then
				bNullable = ( Column.IsNullable = com.sun.star.sdbc.ColumnValue.NULLABLE )
				If bNullable Then
					If Column.wasNull() Then _PropertyGet = 0 Else _PropertyGet = CLng(oSize.getLength())
				Else
					_PropertyGet = CLng(oSize.getLength())
				End If
				oSize.closeInput()
			Else
				_PropertyGet = vEMPTY
			End If
		Case UCase(&quot;Name&quot;)
			_PropertyGet = _Name
		Case UCase(&quot;ObjectType&quot;)
			_PropertyGet = _Type
		Case UCase(&quot;Size&quot;)
			With com.sun.star.sdbc.DataType
				Select Case Column.Type
					Case .LONGVARCHAR, .LONGVARBINARY
						_PropertyGet = 0											&apos;	Always 0 (MSAccess)
					Case Else
						If Utils._hasUNOProperty(Column, &quot;Precision&quot;) Then _PropertyGet = Column.Precision Else _PropertyGet = 0
				End Select
			End With
		Case UCase(&quot;SourceField&quot;)
			Select Case _ParentType
				Case OBJTABLEDEF
					_PropertyGet = _Name
				Case OBJQUERYDEF				&apos;	RealName = not documented ?!?
					If Utils._hasUNOProperty(Column, &quot;RealName&quot;) Then _PropertyGet = Column.RealName Else _PropertyGet = _Name
			End Select
		Case UCase(&quot;SourceTable&quot;)
			Select Case _ParentType
				Case OBJTABLEDEF
					_PropertyGet = _ParentName
				Case OBJQUERYDEF, OBJRECORDSET
					_PropertyGet = Column.TableName
			End Select
		Case UCase(&quot;TypeName&quot;)
			_PropertyGet = Column.TypeName
		Case UCase(&quot;Value&quot;)
			bNullable = ( Column.IsNullable = com.sun.star.sdbc.ColumnValue.NULLABLE )
			bNull = False
			With com.sun.star.sdbc.DataType
				Select Case Column.Type
					Case .BIT, .BOOLEAN		:	vValue = Column.getBoolean()			&apos;	vbBoolean
					Case .TINYINT			:	vValue = Column.getShort()				&apos;	vbInteger			
					Case .SMALLINT, .INTEGER:	vValue = Column.getInt()				&apos;	vbLong
					Case .BIGINT			:	vValue = Column.getLong()				&apos;	vbBigint
					Case .FLOAT				:	vValue = Column.getFloat()				&apos;	vbSingle
					Case .REAL, .DOUBLE		:	vValue = Column.getDouble()				&apos;	vbDouble
					Case .NUMERIC, .DECIMAL
						If Utils._hasUNOProperty(Column, &quot;Scale&quot;) Then
							If Column.Scale &gt; 0 Then
								vValue = Column.getDouble()
							Else		&apos;	CLng checks local decimal point, getString does not !
								sValue = Join(Split(Column.getString(), &quot;.&quot;), Utils._DecimalPoint())
								vValue = CLng(sValue)		&apos;	CDec disappeared from LO ?!?
							End If
						Else
							vValue = CDec(Column.getString())
						End If
					Case .CHAR				:	vValue = Column.getString()
					Case .VARCHAR			:	vValue = Column.getString()				&apos;	vbString
					Case .LONGVARCHAR
						Set oValue = Column.getCharacterStream()
						If bNullable Then bNull = Column.wasNull()
						If Not bNull Then
							lSize = CLng(oValue.getLength())
							oValue.closeInput()
							If lSize &gt; cstMaxTextLength Then Goto Trace_Length
							vValue = Column.getString()									&apos;	vbString
						Else
							oValue.closeInput()
						End If
					Case .DATE				:	Set oValue = Column.getDate()			&apos;	vbObject with members VarType Unsigned Short = 18
												If bNullable Then bNull = Column.wasNull()
												If Not bNull Then vValue = DateSerial(CInt(oValue.Year), CInt(oValue.Month), CInt(oValue.Day))
					Case .TIME				:	Set oValue = Column.getTime()			&apos;	vbObject with members VarType Unsigned Short = 18
												If bNullable Then bNull = Column.wasNull()
												If Not bNull Then vValue = TimeSerial(oValue.Hours, oValue.Minutes, oValue.Seconds)&apos;, oValue.HundredthSeconds)
					Case .TIMESTAMP			:	Set oValue = Column.getTimeStamp()
												If bNullable Then bNull = Column.wasNull()
												If Not bNull Then vValue = DateSerial(CInt(oValue.Year), CInt(oValue.Month), CInt(oValue.Day)) _
															+ TimeSerial(oValue.Hours, oValue.Minutes, oValue.Seconds)&apos;, oValue.HundredthSeconds)
					Case .BINARY, .VARBINARY, .LONGVARBINARY
						Set oValue = Column.getBinaryStream()
						If bNullable Then bNull = Column.wasNull()
						If Not bNull Then vValue = CLng(oValue.getLength())								&apos;	vbLong =&gt; equivalent to FieldSize
						oValue.closeInput()
					Case .BLOB				:	vValue = Column.getBlob()				&apos;	TBC HSQLDB 2.0 ?
					Case .CLOB				:	vValue = Column.getClob()
						&apos;getArray
						&apos;getRef
					Case Else
						vValue = Column.getString()							&apos;GIVE STRING A TRY
						If IsNumeric(vValue) Then vValue = Val(vValue)		&apos;Required when type = &quot;&quot;, sometimes numeric fields are returned as strings (query/MSAccess)
				End Select
				If bNullable Then
					If Column.wasNull() Then vValue = Nothing				&apos;getXXX must precede wasNull()
				End If
			End With
			_PropertyGet = vValue
		Case Else
			Goto Trace_Error
	End Select
	
Exit_Function:
	Utils._ResetCalledSub(cstThisSub)
	Exit Function
Trace_Error:
	TraceError(TRACEWARNING, ERRPROPERTY, Utils._CalledSub(), 0, , psProperty)
	_PropertyGet = vEMPTY
	Goto Exit_Function
Trace_Length:
	TraceError(TRACEFATAL, ERRMEMOLENGTH, Utils._CalledSub(), 0, , lSize)
	_PropertyGet = vEMPTY
	Goto Exit_Function
Error_Function:
	TraceError(TRACEABORT, Err, cstThisSub, Erl)
	_PropertyGet = vEMPTY
	GoTo Exit_Function
End Function		&apos;	_PropertyGet	V1.1.0

REM -----------------------------------------------------------------------------------------------------------------------
Private Function _PropertySet(ByVal psProperty As String, ByVal pvValue As Variant) As Boolean
&apos;	Return True if property setting OK

	If _ErrorHandler() Then On Local Error Goto Error_Function
Dim cstThisSub As String
	cstThisSub = &quot;Field.set&quot; &amp; psProperty
	Utils._SetCalledSub(cstThisSub)
	_PropertySet = True
Dim iArgNr As Integer, vTemp As Variant
Dim oParent As Object

	Select Case UCase(_A2B_.CalledSub)
		Case UCase(&quot;setProperty&quot;)			:	iArgNr = 3
		Case UCase(&quot;Field.setProperty&quot;)		:	iArgNr = 2
		Case UCase(cstThisSub)				:	iArgNr = 1
	End Select
	
	If Not hasProperty(psProperty) Then Goto Trace_Error

	Select Case UCase(psProperty)
		Case UCase(&quot;DefaultValue&quot;)
			If _ParentType &lt;&gt; OBJTABLEDEF Then Goto Trace_Error
			If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
			If Utils._hasUNOProperty(Column, &quot;ControlDefault&quot;) Then			&apos;	Default value set in Base via table edition
			 	Column.ControlDefault = pvValue
			End If
		Case UCase(&quot;Description&quot;)
			If _ParentType &lt;&gt; OBJTABLEDEF Then Goto Trace_Error
			If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
			Column.HelpText = pvValue
		Case UCase(&quot;Value&quot;)
			If _ParentType &lt;&gt; OBJRECORDSET Then Goto Trace_Error		&apos;	Not on table- or querydefs ... !
			If Not Column.IsWritable Then Goto Trace_Error_Updatable
			If Column.IsReadOnly Then Goto Trace_Error_Updatable
			If _ParentDatabase.Recordsets(_ParentName)._EditMode = dbEditNone Then Goto Trace_Error_Update
			With com.sun.star.sdbc.DataType
				If IsNull(pvValue) Then
					If Column.IsNullable = com.sun.star.sdbc.ColumnValue.NULLABLE Then Column.updateNull() Else Goto Trace_Null
				End If
				Select Case Column.Type
					Case .BIT, .BOOLEAN
						If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
						Column.updateBoolean(pvValue)
					Case .TINYINT
						If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
						If pvValue &lt; -128 Or pvValue &gt; +127 Then Goto Trace_Error_Value
						Column.updateShort(CInt(pvValue))
					Case .SMALLINT
						If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
						If pvValue &lt; -32768 Or pvValue &gt; 32767 Then Goto trace_Error_Value
						Column.updateInt(CLng(pvValue))
					Case .INTEGER
						If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
						If pvValue &lt; -2147483648 Or pvValue &gt; 2147483647 Then Goto trace_Error_Value
						Column.updateInt(CLng(pvValue))
					Case .BIGINT
						If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
						Column.updateLong(pvValue)		&apos;	No proper type conversion for HYPER data type
					Case .FLOAT
						If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
						If Abs(pvValue) &lt; 3.402823E38 And Abs(pvValue) &gt; 1.401298E-45 Then Column.updateFloat(CSng(pvValue)) Else Goto trace_Error_Value
					Case .REAL, .DOUBLE
						If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
						&apos;If Abs(pvValue) &lt; 1.79769313486232E308 And Abs(pvValue) &gt; 4.94065645841247E-307 Then Column.updateDouble(CDbl(pvValue)) Else Goto trace_Error_Value
						Column.updateDouble(CDbl(pvValue))
					Case .NUMERIC, .DECIMAL
						If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
						If Utils._hasUNOProperty(Column, &quot;Scale&quot;) Then
							If Column.Scale &gt; 0 Then
								&apos;If Abs(pvValue) &lt; 1.79769313486232E308 And Abs(pvValue) &gt; 4.94065645841247E-307 Then Column.updateDouble(CDbl(pvValue)) Else Goto trace_Error_Value
								Column.updateDouble(CDbl(pvValue))
							Else
								Column.updateString(CStr(pvValue))
							End If
						Else
							Column.updateString(CStr(pvValue))
						End If
					Case .CHAR, .VARCHAR, .LONGVARCHAR
						If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
						Column.updateString(pvValue)						&apos;	vbString
					Case .DATE
						If Not Utils._CheckArgument(pvValue, iArgNr, vbDate, , False) Then Goto Trace_Error_Value
						vTemp = New com.sun.star.util.Date
						With vTemp
							.Day = Day(pvValue)
							.Month = Month(pvValue)
							.Year = Year(pvValue)
						End With
						Column.updateDate(vTemp)
					Case .TIME
						If Not Utils._CheckArgument(pvValue, iArgNr, vbDate, , False) Then Goto Trace_Error_Value
						vTemp = New com.sun.star.util.Time
						With vTemp
							.Hours = Hour(pvValue)
							.Minutes = Minute(pvValue)
							.Seconds = Second(pvValue)
							&apos;.HundredthSeconds = 0		&apos;	replaced with Long nanoSeconds in LO 4.1 ??
						End With
						Column.updateTime(vTemp)
					Case .TIMESTAMP
						If Not Utils._CheckArgument(pvValue, iArgNr, vbDate, , False) Then Goto Trace_Error_Value
						vTemp = New com.sun.star.util.DateTime
						With vTemp
							.Day = Day(pvValue)
							.Month = Month(pvValue)
							.Year = Year(pvValue)
							.Hours = Hour(pvValue)
							.Minutes = Minute(pvValue)
							.Seconds = Second(pvValue)
							&apos;.HundredthSeconds = 0
						End With
						Column.updateTimestamp(vTemp)
&apos;					Case .BINARY, .VARBINARY, .LONGVARBINARY
&apos;					Case .BLOB
&apos;					Case .CLOB
					Case Else
						Goto trace_Error
				End Select
			End With
		Case Else
			Goto Trace_Error
	End Select
	
Exit_Function:
	Utils._ResetCalledSub(cstThisSub)
	Exit Function
Trace_Error:
	TraceError(TRACEFATAL, ERRPROPERTY, Utils._CalledSub(), 0, , psProperty)
	_PropertySet = False
	Goto Exit_Function
Trace_Error_Value:
	TraceError(TRACEFATAL, ERRPROPERTYVALUE, Utils._CalledSub(), 0, 1, Array(pvValue, psProperty))
	_PropertySet = False
	Goto Exit_Function
Trace_Null:
	TraceError(TRACEFATAL, ERRNOTNULLABLE, Utils._CalledSub(), 0, 1, _Name)
	_PropertySet = False
	Goto Exit_Function
Trace_Error_Update:
	TraceError(TRACEFATAL, ERRUPDATESEQUENCE, Utils._CalledSub(), 0, 1)
	_PropertySet = False
	Goto Exit_Function
Trace_Error_Updatable:
	TraceError(TRACEFATAL, ERRNOTUPDATABLE, Utils._CalledSub(), 0, 1)
	_PropertySet = False
	Goto Exit_Function
Error_Function:
	TraceError(TRACEABORT, Err, cstThisSub, Erl)
	_PropertySet = False
	GoTo Exit_Function
End Function			&apos;	_PropertySet

REM -----------------------------------------------------------------------------------------------------------------------
Public Function _ReadAll(ByVal psFile As String, ByVal psMethod As String) As Boolean
&apos;	Write the whole content of a file into a stream object

	If _ErrorHandler() Then On Local Error Goto Error_Function
	_ReadAll = False

	If _ParentType &lt;&gt; OBJRECORDSET Then Goto Trace_Error		&apos;	Not on table- or querydefs ... !
	If Not Column.IsWritable Then Goto Trace_Error_Updatable
	If Column.IsReadOnly Then Goto Trace_Error_Updatable
	If _ParentDatabase.Recordsets(_ParentName)._EditMode = dbEditNone Then Goto Trace_Error_Update

Dim sFile As String, oSimpleFileAccess As Object, sMethod As String, oStream As Object
Dim lFileLength As Long, sBuffer As String, sMemo As String, iFile As Integer
Const cstMaxLength = 64000
	sFile = ConvertToURL(psFile)

	oSimpleFileAccess = CreateUnoService(&quot;com.sun.star.ucb.SimpleFileAccess&quot;)
	If Not oSimpleFileAccess.exists(sFile) Then Goto Trace_File

	With com.sun.star.sdbc.DataType
		Select Case Column.Type
			Case .BINARY, .VARBINARY, .LONGVARBINARY
				If psMethod &lt;&gt; &quot;ReadAllBytes&quot; Then Goto Trace_Error
				Set oStream = oSimpleFileAccess.openFileRead(sFile)
				lFileLength = oStream.getLength()
				If lFileLength = 0 Then Goto Trace_File
				Column.updateBinaryStream(oStream, lFileLength)
				oStream.closeInput()
			Case .LONGVARCHAR
				If psMethod &lt;&gt; &quot;ReadAllText&quot; Then Goto Trace_Error
				sMemo = &quot;&quot;
				lFileLength = 0
				iFile = FreeFile()
				Open sFile For Input Access Read Shared As iFile
				Do While Not Eof(iFile)
					Line Input #iFile, sBuffer
					lFileLength = lFileLength + Len(sBuffer) + 1
					If lFileLength &gt; cstMaxLength Then Exit Do
					sMemo = sMemo &amp; sBuffer &amp; Chr(10)
				Loop
				If lFileLength = 0 Or lFileLength &gt; cstMaxLength Then
					Close #iFile
					Goto Trace_File
				End If
				sMemo = Left(sMemo, lFileLength - 1)
				Column.updateString(sMemo)				
				&apos;Column.updateCharacterStream(oStream, lFileLength)		&apos;	DOES NOT WORK ?!?
			Case Else
				Goto Trace_Error
		End Select
	End With

	_ReadAll = True
	
Exit_Function:
	Exit Function
Trace_Error:
	TraceError(TRACEFATAL, ERRMETHOD, Utils._CalledSub(), 0, , psMethod)
	Goto Exit_Function
Trace_File:
	TraceError(TRACEFATAL, ERRFILEACCESS, Utils._CalledSub(), 0, , sFile)
	If Not IsNull(oStream) Then oStream.closeInput()
	Goto Exit_Function
Trace_Error_Update:
	TraceError(TRACEFATAL, ERRUPDATESEQUENCE, Utils._CalledSub(), 0, 1)
	If Not IsNull(oStream) Then oStream.closeInput()
	Goto Exit_Function
Trace_Error_Updatable:
	TraceError(TRACEFATAL, ERRNOTUPDATABLE, Utils._CalledSub(), 0, 1)
	If Not IsNull(oStream) Then oStream.closeInput()
	Goto Exit_Function
Error_Function:
	TraceError(TRACEABORT, Err, _CalledSub, Erl)
	GoTo Exit_Function
End Function		&apos;	ReadAll

REM -----------------------------------------------------------------------------------------------------------------------
Public Function _WriteAll(ByVal psFile As String, ByVal psMethod As String) As Boolean
&apos;	Write the whole content of a stream object to a file

	If _ErrorHandler() Then On Local Error Goto Error_Function
	_WriteAll = False

Dim sFile As String, oSimpleFileAccess As Object, sMethod As String, oStream As Object
	sFile = ConvertToURL(psFile)

	oSimpleFileAccess = CreateUnoService(&quot;com.sun.star.ucb.SimpleFileAccess&quot;)
	With com.sun.star.sdbc.DataType
		Select Case Column.Type
			Case .BINARY, .VARBINARY, .LONGVARBINARY
				If psMethod &lt;&gt; &quot;WriteAllBytes&quot; Then Goto Trace_Error
				Set oStream = Column.getBinaryStream()
			Case .LONGVARCHAR
				If psMethod &lt;&gt; &quot;WriteAllText&quot; Then Goto Trace_Error
				Set oStream = Column.getCharacterStream()
			Case Else
				Goto Trace_Error
		End Select
	End With

	If Column.IsNullable = com.sun.star.sdbc.ColumnValue.NULLABLE Then
		If Column.wasNull() Then Goto Trace_Null
	End If
	If oStream.getLength() = 0 Then Goto Trace_Null
	On Local Error Goto Trace_File
	If oSimpleFileAccess.exists(sFile) Then oSimpleFileAccess.kill(sFile)
	oSimpleFileAccess.writeFile(sFile, oStream)
	On Local Error Goto Error_Function
	oStream.closeInput()

	_WriteAll = True
	
Exit_Function:
	Exit Function
Trace_Error:
	TraceError(TRACEFATAL, ERRMETHOD, Utils._CalledSub(), 0, , psMethod)
	Goto Exit_Function
Trace_File:
	TraceError(TRACEFATAL, ERRFILEACCESS, Utils._CalledSub(), 0, , sFile)
	If Not IsNull(oStream) Then oStream.closeInput()
	Goto Exit_Function
Trace_Null:
	TraceError(TRACEFATAL, ERRFIELDNULL, _CalledSub, 0)
	If Not IsNull(oStream) Then oStream.closeInput()
	Goto Exit_Function
Error_Function:
	TraceError(TRACEABORT, Err, _CalledSub, Erl)
	GoTo Exit_Function
End Function		&apos;	WriteAll

REM -----------------------------------------------------------------------------------------------------------------------
REM --- CLASS PROPERTY SETs								        														---
REM --- Workaround to bug https://www.libreoffice.org/bugzilla/show_bug.cgi?id=60752 (LibreOffice 4.0)					---
REM -----------------------------------------------------------------------------------------------------------------------

Property Set DefaultValue(ByVal pvDefaultValue As Variant)
	Call _PropertySet(&quot;DefaultValue&quot;, pvDefaultValue)
End Property		&apos;	DefaultValue (set)

Property Set Description(ByVal pvDescription As Variant)
	Call _PropertySet(&quot;Description&quot;, pvDescription)
End Property		&apos;	Description (set)

Property Set Value(ByVal pvValue As Variant)
	Call _PropertySet(&quot;Value&quot;, pvValue)
End Property		&apos;	Value (set)

</script:module>