You are viewing a plain text version of this content. The canonical link for it is here.
Posted to api@openoffice.apache.org by Andrea Pescetti <pe...@apache.org> on 2014/05/01 18:21:58 UTC

Re: problem with chinese language

Forwarding Herbert's answer in case the original poster did not get it. 
Andrea

On 29/04/2014 Herbert Duerr wrote:
> On 29.04.2014 14:15, K. Misha wrote:
>> Our company has developed LibOpenOffice
>> <http://4k.com.ua/products/others/libopenoffice?lang=en>  library for
>> OpenOffice automation. Our clients from China said that this code doesn't
>> work with chinese file path:
>>
>> bool exportToUrl(char *url) {
>>
>>        try {
>>
>>              int nLenOfWideCharStr =
>> MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,url,-1,NULL,0);
>>
>>              wchar_t *uval = (PWSTR)HeapAlloc(GetProcessHeap(), 0,
>> nLenOfWideCharStr * sizeof(WCHAR));
>>
>>
>> MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,url,-1,uval,nLenOfWideCharStr);
>>
>>
>>
>>              Reference<XStorable> xStore (xCalcComponent, UNO_QUERY);
>>
>>              Sequence<PropertyValue> storeProps(1);
>>
>>              storeProps[0].Name = OUString::createFromAscii(
>> "FilterName" );
>>
>>              storeProps[0].Value <<= OUString::createFromAscii( "MS
>> Excel 97"
>> );
>>
>>              xStore->storeToURL( OUString::OUString(uval), storeProps );
>
> Use a line such as
>
> xStore->storeToURL( OUString::OUString(uval,nLenOfWideCharStr),
> storeProps );
>
> instead. This sets the string length explicitly instead of relying on
> finding a trailing zero.
>
> Hope that helps.
>
> Herbert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
> For additional commands, e-mail: api-help@openoffice.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
For additional commands, e-mail: api-help@openoffice.apache.org


RE: problem with chinese language

Posted by "K. Misha" <km...@mail.ru>.
Hi!<неи<неиIf I'm using this code ExportToUrl function doesn't
work.<неи<неи> xStore->storeToURL(
OUString::OUString(uval,nLenOfWideCharStr),<неи> storeProps );<неи<неиHave
you some ideas?<неи<неиRegards!<неи<неи-----Original Message-----<неиFrom:
Andrea Pescetti [mailto:pescetti@apache.org] <неиSent: Thursday, May 01,
2014 7:22 PM<неиTo: api@openoffice.apache.org<неиCc:
kmi_4k@mail.ru<неиSubject: Re: problem with chinese
language<неи<неиForwarding Herbert's answer in case the original poster did
not get it. <неиAndrea<неи<неиOn 29/04/2014 Herbert Duerr wrote:<неи> On
29.04.2014 14:15, K. Misha wrote:<неи>> Our company has developed
LibOpenOffice<неи>> <http://4k.com.ua/products/others/libopenoffice?lang=en>
library for<неи>> OpenOffice automation. Our clients from China said that
this code doesn't<неи>> work with chinese file path:<неи>><неи>> bool
exportToUrl(char *url) {<неи>><неи>>        try {<неи>><неи>>
int nLenOfWideCharStr =<неи>>
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,url,-1,NULL,0);<неи>><неи>>
wchar_t *uval = (PWSTR)HeapAlloc(GetProcessHeap(), 0,<неи>>
nLenOfWideCharStr * sizeof(WCHAR));<неи>><неи>><неи>>
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,url,-1,uval,nLenOfWideCharStr);<не
и>><неи>><неи>><неи>>              Reference<XStorable> xStore
(xCalcComponent, UNO_QUERY);<неи>><неи>>
Sequence<PropertyValue> storeProps(1);<неи>><неи>>
storeProps[0].Name = OUString::createFromAscii(<неи>> "FilterName"
);<неи>><неи>>              storeProps[0].Value <<=
OUString::createFromAscii( "MS<неи>> Excel 97"<неи>> );<неи>><неи>>
xStore->storeToURL( OUString::OUString(uval), storeProps );<неи><неи> Use a
line such as<неи><неи> xStore->storeToURL(
OUString::OUString(uval,nLenOfWideCharStr),<неи> storeProps );<неи><неи>
instead. This sets the string length explicitly instead of relying on<неи>
finding a trailing zero.<неи><неи> Hope that helps.<неи><неи>
Herbert<неи><неи>
---------------------------------------------------------------------<неи>
To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org<неи> For
additional commands, e-mail: api-help@openoffice.apache.org<неи><неи><неи


---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
For additional commands, e-mail: api-help@openoffice.apache.org