Takashi Ono wrote:
Hi,

Although the use of string classes in tools project is commented as depreciated, they are still used in many codes.

They have constructors with one numeric argument to generate string of one character. To protect the misuse of these constructors, the class definition includes some other constructors with one numeric argument of different sizes and the are not implemented so as to detect misuse at link time. (I think it better to declare them as private so that any misuse can be detected at compilation.)

(Yes, see issue <http://www.openoffice.org/issues/show_bug.cgi?id=28230> for making them private.)

However, there still exist some misuses of the constructor with one numeric character. For example, in toolkit/source/awt/vclxprinter.cxx, the function VCLXPrinterPropertySet::getFormDescriptions includes the following fragment.

for ( sal_uInt16 n = 0; n < nPaperBinCount; n++ ) { // Format: <DisplayFormName;FormNameId;DisplayPaperBinName;PaperBinNameId;DisplayPaperName;Pa
perNameId>
                String aDescr( RTL_CONSTASCII_USTRINGPARAM( "*;*;" ) );
                aDescr += GetPrinter()->GetPaperBinName( n );
                aDescr += ';';
                aDescr += n;
                aDescr.AppendAscii( ";*;*", 4 );

                aDescriptions.getArray()[n] = aDescr;
        }

I suspect that it is a misuse of String(sal_Unicode).

IMHO, even though we have to have some cumbersome work to rewrite existing codes, these constructors with one numeric argument should be declared as explicit to avoid silly misuses completely.

Making constructors explicit would not help in the above case, where

  String::operator +=(sal_Unicode)

is mis-used in "aDescr += n".

-Stephan

tono (Takashi Ono)

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to