Hi k. misha, On Thu, Apr 04, 2013 at 11:20:04AM +0300, k.misha wrote: > Hi! > > > > I have some problems using UNO API! I have this example: > > > > Int x = 0; > > Int y = 1; > > Char * fontName = "Corbel";
Defined this way, fontName is a pointer > Reference< XSpreadsheet > rSpSheet (rSheet, UNO_QUERY); > > Reference< XCell > rCell = rSpSheet->getCellByPosition(x, y); > > Reference< XPropertySet > xPropSet(rCell, UNO_QUERY); > > > > OUString sstring = OUString(RTL_CONSTASCII_USTRINGPARAM(fontName)); The macro RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) expands to constAsciiStr, ((sal_Int32)(sizeof(constAsciiStr)-1)), RTL_TEXTENCODING_ASCII_US so that sizeof( pointer ) - 1 is 4 - 1 (in 32 bit arch.) or 8 - 1 (in 64 bit arch.) > xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CharFontNam > e")), makeAny(sstring)); > > > > But when I look into a cacl document, there is wrong value in cell(0,1). I's > "Cor". But must be "Corbel". Your OS is 32 bits: (sizeof( pointer ) - 1) is 3, thus "Cor". > Can you help me and show where I'm wrong? Define the string literal as an array: const char fontName[] = "Corbel"; or simply avoid all these temporal variables: xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CharFontName")), makeAny(OUString(RTL_CONSTASCII_USTRINGPARAM("Corbel")))); Regards -- Ariel Constenla-Haile La Plata, Argentina
pgp8F0gaTmsIz.pgp
Description: PGP signature