1*b1cdbd2cSJim Jagielski/**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski *   http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_script_Converter_idl__
24*b1cdbd2cSJim Jagielski#define __com_sun_star_script_Converter_idl__
25*b1cdbd2cSJim Jagielski
26*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_script_XTypeConverter_idl__
27*b1cdbd2cSJim Jagielski#include <com/sun/star/script/XTypeConverter.idl>
28*b1cdbd2cSJim Jagielski#endif
29*b1cdbd2cSJim Jagielski
30*b1cdbd2cSJim Jagielski
31*b1cdbd2cSJim Jagielski//=============================================================================
32*b1cdbd2cSJim Jagielski
33*b1cdbd2cSJim Jagielski module com {  module sun {  module star {  module script {
34*b1cdbd2cSJim Jagielski
35*b1cdbd2cSJim Jagielski//=============================================================================
36*b1cdbd2cSJim Jagielski
37*b1cdbd2cSJim Jagielski/** This service provides a widening converter converting from one type to another,
38*b1cdbd2cSJim Jagielski    if possible.
39*b1cdbd2cSJim Jagielski
40*b1cdbd2cSJim Jagielski	<p>What is possible?
41*b1cdbd2cSJim Jagielski    <ul>
42*b1cdbd2cSJim Jagielski	<li>byte: byte, (short *1), (long *1), (hyper *1), (float *1), (double *1), (enum *2), (any *3), boolean, (char *4), (string *5)</li>
43*b1cdbd2cSJim Jagielski	<li>short: byte, short, (long *1), (hyper *1), (float *7), (double *7), (enum *2), (any *3), boolean, char, (string *5)</li>
44*b1cdbd2cSJim Jagielski	<li>long: byte, short, long, (hyper *1), (float *7), (double *7), enum, (any *3), boolean, char, (string *5)</li>
45*b1cdbd2cSJim Jagielski	<li>hyper: byte, short, long, hyper, (float *7), (double *7), enum, (any *3), boolean, char, (string *5)</li>
46*b1cdbd2cSJim Jagielski	<li>float: byte, short, long, hyper, float, (double *7), (enum *8), (any *3), boolean, char, (string *5)</li>
47*b1cdbd2cSJim Jagielski	<li>double: byte, short, long, hyper, float, double, enum, (any *3), boolean, char, (string *5)</li>
48*b1cdbd2cSJim Jagielski	<li>enum: (byte *9), (short *9), (long *9), (hyper *9), (float *9), (double *9), (enum *10), (any *3), (string *11)</li>
49*b1cdbd2cSJim Jagielski	<li>void: ok for all types</li>
50*b1cdbd2cSJim Jagielski	<li>any: ok for all types</li>
51*b1cdbd2cSJim Jagielski	<li>boolean: byte, short, long, hyper, float, double, (any *3), boolean, char, (string *12). 0 => false, != 0 => true</li>
52*b1cdbd2cSJim Jagielski	<li>char: byte, short, (long *1), (hyper *1), (float *7), (double *7), enum, (any *3), boolean, char, (string *13)</li>
53*b1cdbd2cSJim Jagielski	<li>string: byte, short, long, hyper, float, double, enum, (any *3), boolean, char, string</li>
54*b1cdbd2cSJim Jagielski	<li>struct: (any *3), (struct *14)</li>
55*b1cdbd2cSJim Jagielski	<li>interface: (any *3), (struct *14)</li>
56*b1cdbd2cSJim Jagielski	<li>exception: (any *3), (exception *14)</li>
57*b1cdbd2cSJim Jagielski	<li>union: (any *3), (union *14)</li>
58*b1cdbd2cSJim Jagielski	<li>sequence: (any *3), (sequence *15)</li>
59*b1cdbd2cSJim Jagielski	</ul>
60*b1cdbd2cSJim Jagielski    rules:
61*b1cdbd2cSJim Jagielski    <ul>
62*b1cdbd2cSJim Jagielski	<li>1: only converts if the value is in the range of the target type.</li>
63*b1cdbd2cSJim Jagielski	<li>2: only converts if the value, not the position, of the enum is in the range of the target type.</li>
64*b1cdbd2cSJim Jagielski	<li>3: get value until it is not an any. Then convert it with the other rules.</li>
65*b1cdbd2cSJim Jagielski	<li>4: only converts if the value of the character is between 0 - 255.</li>
66*b1cdbd2cSJim Jagielski	<li>5: only converts if the value represents a decimal, hexadecimal (0x...) or a floating point number.
67*b1cdbd2cSJim Jagielski	Examples: 10, 0x10, 10.045, 10,555, +10, +10.6e10, -10.6e-10, .16.</li>
68*b1cdbd2cSJim Jagielski	<li>7: only converts if the value is in the range of the target type.
69*b1cdbd2cSJim Jagielski	The value is rounded to an integer.</li>
70*b1cdbd2cSJim Jagielski	<li>8: only converts if the float can be converted back to the same enum value.</li>
71*b1cdbd2cSJim Jagielski	<li>9: only converts if the number is one of the enumeration type values. Normally you need
72*b1cdbd2cSJim Jagielski	reflection information of the enum type.</li>
73*b1cdbd2cSJim Jagielski	<li>10: only converts if it is the same enumeration type.</li>
74*b1cdbd2cSJim Jagielski	<li>11: only converts if the string contains the name of an enumeration type value. Normally you need
75*b1cdbd2cSJim Jagielski	core reflection information of the enum type.</li>
76*b1cdbd2cSJim Jagielski	<li>12: only converts if the value of the string is "1", "true" or "0", "false". The comparision
77*b1cdbd2cSJim Jagielski	is case insensitive.</li>
78*b1cdbd2cSJim Jagielski	<li>13: only converts if the length of the string is 1 or 0.</li>
79*b1cdbd2cSJim Jagielski	<li>14: only converts if the types are equal or the source type is derived from the destination
80*b1cdbd2cSJim Jagielski	type.</li>
81*b1cdbd2cSJim Jagielski	<li>15: only converts if each element of the source sequence can be converted to an element
82*b1cdbd2cSJim Jagielski	of the destination sequence.</li>
83*b1cdbd2cSJim Jagielski    </ul>
84*b1cdbd2cSJim Jagielski*/
85*b1cdbd2cSJim Jagielskipublished service Converter
86*b1cdbd2cSJim Jagielski{
87*b1cdbd2cSJim Jagielski    /** Conversion interface.
88*b1cdbd2cSJim Jagielski    */
89*b1cdbd2cSJim Jagielski	interface com::sun::star::script::XTypeConverter;
90*b1cdbd2cSJim Jagielski
91*b1cdbd2cSJim Jagielski};
92*b1cdbd2cSJim Jagielski
93*b1cdbd2cSJim Jagielski//=============================================================================
94*b1cdbd2cSJim Jagielski
95*b1cdbd2cSJim Jagielski}; }; }; };
96*b1cdbd2cSJim Jagielski
97*b1cdbd2cSJim Jagielski/*=============================================================================
98*b1cdbd2cSJim Jagielski
99*b1cdbd2cSJim Jagielski=============================================================================*/
100*b1cdbd2cSJim Jagielski#endif
101