I implemented the code, thanks.

At the beginning of the class I put this code:

Original Code
String aName( aEdtName.GetText() );

I've replaced with
::rtl::OUString aName2( aEdtName.GetText() );

The concatenation. This is fine

 std::stringstream aS;
            aS <<
                 "This"
                 << ::rtl::OUStringToOString(aName2,
RTL_TEXTENCODING_ASCII_US).getStr()
                 << std::endl;

I convert from stringstream to string

std::string s = aS.str();
        _STL::cout << s;

Now I want to replace aName with s, in the following code fragment:

if (eCM != CM_RGB)

            ConvertColorValues (aAktuellColor, CM_RGB);
        pEntry = new XColorEntry( aAktuellColor, aName );
<---------------------- Original code
        pEntry = new XColorEntry( aAktuellColor, s );
<----------------------
Would be like this

        pColorTab->Insert( pColorTab->Count(), pEntry );

        aLbColor.Append( pEntry );
        aValSetColorTable.InsertItem( aValSetColorTable.GetItemCount() + 1,
                pEntry->GetColor(), pEntry->GetName() );

        aLbColor.SelectEntryPos( aLbColor.GetEntryCount() - 1 );

But this does not work, in building generates error:
http://imagebin.org/254616

It could be the type of variable?
How is the conversion from stringstream to string, is ok?


2013/4/18 Andre Fischer <awf....@gmail.com>

> On 18.04.2013 04:51, jorge ivan poot diaz wrote:
>
>> Hello,
>>
>> Thanks you,  I have already changed the string as you said me. This is the
>> result:
>> ::rtl::OUString aName ( aEdtName.GetText() );
>>
>> And then I put this code
>>
>> std::stringstream aStrStream;
>>              aStrStream << "\nThis is " << aName << " and " << aName << "
>> genial!" <<std::endl;
>>              _STL::cout << aStrStream.str();
>>
>> The building was successful, but does not print whole aStrStream. Only
>> this
>> part:
>> This is
>> http://imagebin.org/254440
>>
>
> OUString is a UTF-16 string.  That means that when it is created from an
> ASCII string then every second byte is '\0'.  That means that
>
>             aStrStream << "\nThis is " << aName << ...
>
> is basically equivalent to
>
>             aStrStream << "\nThis is " << '\0' << ...
>
> Therfore everything after "\nThis is " is cut off.  To fix this you have
> to replace
>     << aName <<
>
> with
>
>   << ::rtl::OUStringToOString(**aName, RTL_TEXTENCODING_ASCII_US).**getStr()
> <<
>
> You may want to use a small method to make this more readable:
>
>   namespace
>   {
>       sal_Char* o2a (const ::rtl::OUString& rsText)
>      {
>       return ::rtl::OUStringToOString(**rsText,
> RTL_TEXTENCODING_ASCII_US).**getStr();
>      }
>   }
>
> and then
>
>     aStrStream << "\nThis is " << o2a(aName) << ...
>
> [I did not compile this, there may be typos in this]
>
>
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> dev-unsubscribe@openoffice.**apache.org<dev-unsubscr...@openoffice.apache.org>
> For additional commands, e-mail: dev-h...@openoffice.apache.org
>
>

Reply via email to