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