1*cdf0e10cSrcweir/************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir#ifndef __com_sun_star_script_Converter_idl__ 28*cdf0e10cSrcweir#define __com_sun_star_script_Converter_idl__ 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir#ifndef __com_sun_star_script_XTypeConverter_idl__ 31*cdf0e10cSrcweir#include <com/sun/star/script/XTypeConverter.idl> 32*cdf0e10cSrcweir#endif 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir//============================================================================= 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir module com { module sun { module star { module script { 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir//============================================================================= 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir/** This service provides a widening converter converting from one type to another, 42*cdf0e10cSrcweir if possible. 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir <p>What is possible? 45*cdf0e10cSrcweir <ul> 46*cdf0e10cSrcweir <li>byte: byte, (short *1), (long *1), (hyper *1), (float *1), (double *1), (enum *2), (any *3), boolean, (char *4), (string *5)</li> 47*cdf0e10cSrcweir <li>short: byte, short, (long *1), (hyper *1), (float *7), (double *7), (enum *2), (any *3), boolean, char, (string *5)</li> 48*cdf0e10cSrcweir <li>long: byte, short, long, (hyper *1), (float *7), (double *7), enum, (any *3), boolean, char, (string *5)</li> 49*cdf0e10cSrcweir <li>hyper: byte, short, long, hyper, (float *7), (double *7), enum, (any *3), boolean, char, (string *5)</li> 50*cdf0e10cSrcweir <li>float: byte, short, long, hyper, float, (double *7), (enum *8), (any *3), boolean, char, (string *5)</li> 51*cdf0e10cSrcweir <li>double: byte, short, long, hyper, float, double, enum, (any *3), boolean, char, (string *5)</li> 52*cdf0e10cSrcweir <li>enum: (byte *9), (short *9), (long *9), (hyper *9), (float *9), (double *9), (enum *10), (any *3), (string *11)</li> 53*cdf0e10cSrcweir <li>void: ok for all types</li> 54*cdf0e10cSrcweir <li>any: ok for all types</li> 55*cdf0e10cSrcweir <li>boolean: byte, short, long, hyper, float, double, (any *3), boolean, char, (string *12). 0 => false, != 0 => true</li> 56*cdf0e10cSrcweir <li>char: byte, short, (long *1), (hyper *1), (float *7), (double *7), enum, (any *3), boolean, char, (string *13)</li> 57*cdf0e10cSrcweir <li>string: byte, short, long, hyper, float, double, enum, (any *3), boolean, char, string</li> 58*cdf0e10cSrcweir <li>struct: (any *3), (struct *14)</li> 59*cdf0e10cSrcweir <li>interface: (any *3), (struct *14)</li> 60*cdf0e10cSrcweir <li>exception: (any *3), (exception *14)</li> 61*cdf0e10cSrcweir <li>union: (any *3), (union *14)</li> 62*cdf0e10cSrcweir <li>sequence: (any *3), (sequence *15)</li> 63*cdf0e10cSrcweir </ul> 64*cdf0e10cSrcweir rules: 65*cdf0e10cSrcweir <ul> 66*cdf0e10cSrcweir <li>1: only converts if the value is in the range of the target type.</li> 67*cdf0e10cSrcweir <li>2: only converts if the value, not the position, of the enum is in the range of the target type.</li> 68*cdf0e10cSrcweir <li>3: get value until it is not an any. Then convert it with the other rules.</li> 69*cdf0e10cSrcweir <li>4: only converts if the value of the character is between 0 - 255.</li> 70*cdf0e10cSrcweir <li>5: only converts if the value represents a decimal, hexadecimal (0x...) or a floating point number. 71*cdf0e10cSrcweir Examples: 10, 0x10, 10.045, 10,555, +10, +10.6e10, -10.6e-10, .16.</li> 72*cdf0e10cSrcweir <li>7: only converts if the value is in the range of the target type. 73*cdf0e10cSrcweir The value is rounded to an integer.</li> 74*cdf0e10cSrcweir <li>8: only converts if the float can be converted back to the same enum value.</li> 75*cdf0e10cSrcweir <li>9: only converts if the number is one of the enumeration type values. Normally you need 76*cdf0e10cSrcweir reflection information of the enum type.</li> 77*cdf0e10cSrcweir <li>10: only converts if it is the same enumeration type.</li> 78*cdf0e10cSrcweir <li>11: only converts if the string contains the name of an enumeration type value. Normally you need 79*cdf0e10cSrcweir core reflection information of the enum type.</li> 80*cdf0e10cSrcweir <li>12: only converts if the value of the string is "1", "true" or "0", "false". The comparision 81*cdf0e10cSrcweir is case insensitive.</li> 82*cdf0e10cSrcweir <li>13: only converts if the length of the string is 1 or 0.</li> 83*cdf0e10cSrcweir <li>14: only converts if the types are equal or the source type is derived from the destination 84*cdf0e10cSrcweir type.</li> 85*cdf0e10cSrcweir <li>15: only converts if each element of the source sequence can be converted to an element 86*cdf0e10cSrcweir of the destination sequence.</li> 87*cdf0e10cSrcweir </ul> 88*cdf0e10cSrcweir*/ 89*cdf0e10cSrcweirpublished service Converter 90*cdf0e10cSrcweir{ 91*cdf0e10cSrcweir /** Conversion interface. 92*cdf0e10cSrcweir */ 93*cdf0e10cSrcweir interface com::sun::star::script::XTypeConverter; 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir}; 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir//============================================================================= 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir}; }; }; }; 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir/*============================================================================= 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir=============================================================================*/ 104*cdf0e10cSrcweir#endif 105