Re: [api-dev] Mapping of the UNO type hyper in StarBasic
Bonjour Christian Junker Message du 2006-06-27 21:58: There is no possibility as I see it, because you cannot directly convert a decimal to hyper, at least I can't (again I would be happy if you prove me wrong with a code snippet). But if you do it with a conversion to an whole number before, you cannot avoid a possible loss of data, which would make the use of Decimal useless in this case. I don't say it is _currently_ possible to convert from decimal to hyper. I say that designing a mapping from Basic decimal to UNO hyper is feasible. Bernard - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Mapping of the UNO type hyper in StarBasic
Hi all, it seems that we have to find a better solution for hyper in Basic because hyper is a valid type in our API and in fact of this we should extend the typeset of Basic at least to support all the simple base types of our API. Andreas, what do you think? What would be the best solution to support hyper in Basic? Juergen Bernard Marcelly wrote: Bonjour Paolo Mantovani Message du 2006-06-19 02:23: oUcb = createUnoService(com.sun.star.ucb.SimpleFileAccess) oFile = oUcb.OpenFileReadWrite(file:///home/paolo/img.png) oInputStream = createUnoService(com.sun.star.io.DataInputStream) oInputStream.setInputStream(oFile.getInputStream()) ' print oFile.getLenght 'error!!! ' oFile.seek(5) 'error!!! oFile.seek(CreateUnoValue(hyper, 5)) 'No problem.. oInputStream.closeInput I found a solution to this example. Tested on a 50Mbytes file. dim oUcb as object, oFile as object, oInputStream as object dim hx as variant, hxb as variant, p as variant oUcb = createUnoService(com.sun.star.ucb.SimpleFileAccess) oFile = oUcb.OpenFileReadWrite(convertToURL(D:\Music\Haendel235.wav)) oInputStream = createUnoService(com.sun.star.io.DataInputStream) oInputStream.setInputStream(oFile.getInputStream()) hx = oFile.getLength hxb = CLng(hx) ' convert to a usable Basic type print hxb hxb = hxb -4879123 ' compute a related position print hxb oFile.seek(CreateUnoValue(hyper, hxb) p = oFile.getPosition print CLng(p) ' confirmation oInputStream.closeInput Bernard - 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]
Re: [api-dev] Mapping of the UNO type hyper in StarBasic
Hi Jürgen, it seems that we have to find a better solution for hyper in Basic because hyper is a valid type in our API and in fact of this we should extend the typeset of Basic at least to support all the simple base types of our API. Andreas, what do you think? What would be the best solution to support hyper in Basic? You're right, but after my fix of i66765 the only problem I still see is how hyper/int64 can be declared and how the cor- responding literals can be handled (i66770). Bernard's workaround (see below) is not even necessary after the fix of i66765 as the hyper comes from UNO and so has not to be declared explicitely. sub TestHyper dim oUcb as object, oFile as object dim hx as variant oUcb = createUnoService(com.sun.star.ucb.SimpleFileAccess) oFile = oUcb.OpenFileReadWrite(convertToURL( _ D:\temp\OOo_2.0.3_060623_Win32Intel_install.exe)) ' Size: 96.444.912 bytes hx = oFile.getLength print hx hx = hx - 2000 ' compute a related position print hx oFile.seek(hx) print oFile.getPosition oFile.closeInput end sub Besides this the values do not extend the long range anyway, so long could be used without problems here (after the fix). Regards Andreas I found a solution to this example. Tested on a 50Mbytes file. dim oUcb as object, oFile as object, oInputStream as object dim hx as variant, hxb as variant, p as variant oUcb = createUnoService(com.sun.star.ucb.SimpleFileAccess) oFile = oUcb.OpenFileReadWrite(convertToURL(D:\Music\Haendel235.wav)) oInputStream = createUnoService(com.sun.star.io.DataInputStream) oInputStream.setInputStream(oFile.getInputStream()) hx = oFile.getLength hxb = CLng(hx) ' convert to a usable Basic type print hxb hxb = hxb -4879123 ' compute a related position print hxb oFile.seek(CreateUnoValue(hyper, hxb) p = oFile.getPosition print CLng(p) ' confirmation oInputStream.closeInput Bernard - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Mapping of the UNO type hyper in StarBasic
Hi Andreas, Alle 10:32, martedì 27 giugno 2006, Andreas Bregas ha scritto: Hi Paolo, sorry, I did not discover this thread and after a colleague told me about it yesterday, we had severe mail problems. I think we have to split this problem. 1. hyper as return type: This is no problem. In your example: ... oInputStream.setInputStream(oFile.getInputStream()) ' print oFile.getLenght 'error!!! ' oFile.seek(5) 'error!!! oFile.seek(CreateUnoValue(hyper, 5)) 'No problem.. ... getLength simply has a typo. That's why your next example posted later worked without problems. OOOPPZZZ.. Yes, this explains why I wasn't able to reproduce the problem This reveals also that sometimes I'd better go to bed earlier :-) Sorry for the waste of time. 2. Passing 5 (or any other smaller typed value) as hyper: I could reproduce this and it's simply a bug. Converting a smaller int type to a bigger one should always work. CreateUnoValue() is a workaround but it's ment for a com- pletely different situation (if the target value is unknown because it's declared as Any in IDL). The good news. While evaluating the bug, I've already fixed it as the problem was really obvious. See i66765. Great! 3. hyper as declarable type In general this is not so difficult as internally the type already exists. The biggest problem is to chose a reasonable name. ;-) But that's not the point: If we had the type, we still would need the corresponding literals. That's why the example: CreateUnoValue(hyper, 9223372036854775806) fails. The number is too big to be a long and int64 is not supported by the parser. So it's handled as double but this also fails somehow. I will have to evaluate this: i66770 Are any problems left now? AFAIK no Thank you very much Paolo Mantovani - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Mapping of the UNO type hyper in StarBasic
Hi Paolo, getLength simply has a typo. That's why your next example posted later worked without problems. OOOPPZZZ.. Yes, this explains why I wasn't able to reproduce the problem This reveals also that sometimes I'd better go to bed earlier :-) Sorry for the waste of time. no problem, I did not really spent much time on this special aspect of the problem... :-) Regards Andreas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Mapping of the UNO type hyper in StarBasic
Then how would you want to convert it to hyper from Decimal? I believe there is no working way to do this, but I would be happy if you prove me wrong. 2006/6/27, Bernard Marcelly [EMAIL PROTECTED]: Bonjour Andreas Bregas Message du 2006-06-27 12:51: You're right, but after my fix of i66765 the only problem I still see is how hyper/int64 can be declared and how the cor- responding literals can be handled (i66770). Suggestion : use the unofficial Basic type Decimal to convert from/to hyper. I found it can handle up to 29 digits and supports arithmetic operators. dim v as variant v = CDec(9223372036854775806) print typename(v), v Of course it would be better if we could define: dim v as Decimal v = 9223372036854775806 Note : CDec is currently bugged (IZ 64348) Bernard - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Best Regards Christian Junker - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Mapping of the UNO type hyper in StarBasic
There is no possibility as I see it, because you cannot directly convert a decimal to hyper, at least I can't (again I would be happy if you prove me wrong with a code snippet). But if you do it with a conversion to an whole number before, you cannot avoid a possible loss of data, which would make the use of Decimal useless in this case. 2006/6/27, Bernard Marcelly [EMAIL PROTECTED]: Bonjour Christian Junker Message du 2006-06-27 16:46: Then how would you want to convert it to hyper from Decimal? I believe there is no working way to do this, but I would be happy if you prove me wrong. I don't see your point. Hyper is a signed 64 bits integer, and it fits inside a Decimal range. When converting from Decimal to Hyper, of course the Decimal value must be an integer value within the range of Hyper. And the conversion from Decimal internal representation to Hyper should not pose big problems: Basic already can convert from Decimal to Long. Bernard - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Best Regards Christian Junker - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Mapping of the UNO type hyper in StarBasic
Bonjour Paolo Mantovani Message du 2006-06-19 02:23: oUcb = createUnoService(com.sun.star.ucb.SimpleFileAccess) oFile = oUcb.OpenFileReadWrite(file:///home/paolo/img.png) oInputStream = createUnoService(com.sun.star.io.DataInputStream) oInputStream.setInputStream(oFile.getInputStream()) ' print oFile.getLenght 'error!!! ' oFile.seek(5) 'error!!! oFile.seek(CreateUnoValue(hyper, 5)) 'No problem.. oInputStream.closeInput I found a solution to this example. Tested on a 50Mbytes file. dim oUcb as object, oFile as object, oInputStream as object dim hx as variant, hxb as variant, p as variant oUcb = createUnoService(com.sun.star.ucb.SimpleFileAccess) oFile = oUcb.OpenFileReadWrite(convertToURL(D:\Music\Haendel235.wav)) oInputStream = createUnoService(com.sun.star.io.DataInputStream) oInputStream.setInputStream(oFile.getInputStream()) hx = oFile.getLength hxb = CLng(hx) ' convert to a usable Basic type print hxb hxb = hxb -4879123 ' compute a related position print hxb oFile.seek(CreateUnoValue(hyper, hxb) p = oFile.getPosition print CLng(p) ' confirmation oInputStream.closeInput Bernard - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Mapping of the UNO type hyper in StarBasic
Hi Andrew, Alle 07:06, mercoledì 21 giugno 2006, Andrew Douglas Pitonyak ha scritto: [] I only want to add that using CreateUnoValue is a workaround if you have to pass an hyper to an API method, but does not helps when you must get an hyper. I've also tried with the css.script.Converter but without any result, so any suggestions are welcome Are you saying that you do not know how to convert the returned value to something that is usable when it is returned? Yes I've had problems with 2.0.2 but after reading your msg I repeated my tests and I've seen that the problem is not easily reproducible. Anyway This is the testing code: oUcb = createUnoService(com.sun.star.ucb.SimpleFileAccess) oFile = oUcb.OpenFileRead(file:///boot/vmlinuz) oFile.seek(createUnoValue(hyper, 5)) print TypeName(oFile.getLength) ' Int64 print oFile.Position Ayway is intersting to notice that UNO hyper is mapped to an int64 in StarBasic. If the int64 would be declarable I think we coluld avoid the createUnoValue() function in order to pass hyper values to API methods. I noticed that some other types could not be created using any other method... I think that Byte was one of them... yes, this should be already fixed http://www.openoffice.org/issues/show_bug.cgi?id=17825 Thank you Paolo Mantovani - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Mapping of the UNO type hyper in StarBasic
Hi Meanwhile I encountered that you can't have/use a number that is outside int32 range but still inside the int64 range, for example Sub hyper x = CreateUnoValue(hyper, 9223372036854775806) End Sub will give an error, yet the numeric constant is still inside the range a variable of type hyper can take. the question now is: What happens with such big numbers (as above) that are transfered from a UNO function to Starbasic, like the getLength() function for ucb file objects. perharps a dummy question what about double type or currency one ? does it cover ? not sure they are compliant though Laurent -- Laurent Godard [EMAIL PROTECTED] - Ingénierie OpenOffice.org Indesko http://www.indesko.com Nuxeo CPS http://www.nuxeo.com - http://www.cps-project.org Livre Programmation OpenOffice.org, Eyrolles 2004 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Mapping of the UNO type hyper in StarBasic
Hi Christian, Alle 14:27, venerdì 23 giugno 2006, Christian Junker ha scritto: Meanwhile I encountered that you can't have/use a number that is outside int32 range but still inside the int64 range, for example Sub hyper x = CreateUnoValue(hyper, 9223372036854775806) End Sub will give an error, yet the numeric constant is still inside the range a variable of type hyper can take. I couldn't reproduce the error (Tested with OOo680_m163) ciao Paolo M - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Mapping of the UNO type hyper in StarBasic
Paolo Mantovani wrote: Hi Christian, sorry for my previous message. Alle 09:20, martedì 20 giugno 2006, Christian Junker ha scritto: Hi Paolo, I have the same problems as you have here. I guess there is no other way than using CreateUnoValue. [...] 2) using CreateUnoValue might be too difficult for some to see or use at first sight, thus making hyper a real type as single, double etc. would make things more comfortable for the programmer. Would be good to hear what Andreas Bregas thinks about that. I only want to add that using CreateUnoValue is a workaround if you have to pass an hyper to an API method, but does not helps when you must get an hyper. I've also tried with the css.script.Converter but without any result, so any suggestions are welcome thank you Paolo Are you saying that you do not know how to convert the returned value to something that is usable when it is returned? I noticed that some other types could not be created using any other method... I think that Byte was one of them... -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Mapping of the UNO type hyper in StarBasic
Hi Paolo, I have the same problems as you have here. I guess there is no other way than using CreateUnoValue. There are two things I want to comment on at this time: 1) numeric constants like 5 should raise *no* errors when being passed to functions that expect arguments of UNO type 'hyper'. It could be avoided by typecasting in the various implementations (I guess hyper is nothing else than the C99 long long int), so that no error occurs. Maybe the Basic runtime throws those errors before the implementation function is even called. All that needs to be investigated. 2) using CreateUnoValue might be too difficult for some to see or use at first sight, thus making hyper a real type as single, double etc. would make things more comfortable for the programmer. Would be good to hear what Andreas Bregas thinks about that. 2006/6/19, Paolo Mantovani [EMAIL PROTECTED]: Hi all, as from subject: how does it is mapped the hyper UNO type in StarBasic? The question is because I ever had problems in basic when working with css.io.XSeekable methods (that takes or gets hyper values) Example: REM * BASIC * Sub TestUCB oUcb = createUnoService(com.sun.star.ucb.SimpleFileAccess) oFile = oUcb.OpenFileReadWrite(file:///home/paolo/img.png) oInputStream = createUnoService(com.sun.star.io.DataInputStream) oInputStream.setInputStream(oFile.getInputStream()) ' print oFile.getLenght 'error!!! ' oFile.seek(5) 'error!!! oFile.seek(CreateUnoValue(hyper, 5)) 'No problem.. oInputStream.closeInput End Sub thank you Paolo M - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Best Regards Christian Junker - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Mapping of the UNO type hyper in StarBasic
Alle 09:20, martedì 20 giugno 2006, Christian Junker ha scritto: Hi Paolo, I have the same problems as you have here. I guess there is no other way than using CreateUnoValue. There are two things I want to comment on at this time: 1) numeric constants like 5 should raise *no* errors when being passed to functions that expect arguments of UNO type 'hyper'. It could be avoided by typecasting in the various implementations (I guess hyper is nothing else than the C99 long long int), so that no error occurs. Maybe the Basic runtime throws those errors before the implementation function is even called. All that needs to be investigated. 2) using CreateUnoValue might be too difficult for some to see or use at first sight, thus making hyper a real type as single, double etc. would make things more comfortable for the programmer. Would be good to hear what Andreas Bregas thinks about that. 2006/6/19, Paolo Mantovani [EMAIL PROTECTED]: Hi all, as from subject: how does it is mapped the hyper UNO type in StarBasic? The question is because I ever had problems in basic when working with css.io.XSeekable methods (that takes or gets hyper values) Example: REM * BASIC * Sub TestUCB oUcb = createUnoService(com.sun.star.ucb.SimpleFileAccess) oFile = oUcb.OpenFileReadWrite(file:///home/paolo/img.png) oInputStream = createUnoService(com.sun.star.io.DataInputStream) oInputStream.setInputStream(oFile.getInputStream()) ' print oFile.getLenght 'error!!! ' oFile.seek(5) 'error!!! oFile.seek(CreateUnoValue(hyper, 5)) 'No problem.. oInputStream.closeInput End Sub thank you Paolo M - 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]
Re: [api-dev] Mapping of the UNO type hyper in StarBasic
Hi Christian, sorry for my previous message. Alle 09:20, martedì 20 giugno 2006, Christian Junker ha scritto: Hi Paolo, I have the same problems as you have here. I guess there is no other way than using CreateUnoValue. [...] 2) using CreateUnoValue might be too difficult for some to see or use at first sight, thus making hyper a real type as single, double etc. would make things more comfortable for the programmer. Would be good to hear what Andreas Bregas thinks about that. I only want to add that using CreateUnoValue is a workaround if you have to pass an hyper to an API method, but does not helps when you must get an hyper. I've also tried with the css.script.Converter but without any result, so any suggestions are welcome thank you Paolo - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]