Commit 4a2b0f0f authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

linux build

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@59499 954022d7-b5bf-4e40-9824-e11837661b57
parent 6aa57fb2
......@@ -406,15 +406,55 @@ namespace NSBinPptxRW
void CBinaryFileWriter::WriteStringW(const WCHAR* sBuffer)
{
LONG lSize = __wstrlen(sBuffer);
LONG lSizeMem = lSize * sizeof(wchar_t);
if (lSize < 1) return;
LONG lSizeMem =0;
if (sizeof (sBuffer[0]) == 4)
{
lSizeMem = lSize * sizeof(UTF16);
CheckBufferSize(ULONG_SIZEOF + lSizeMem);
*((ULONG*)m_pStreamCur) = lSizeMem;
m_lPosition += ULONG_SIZEOF;
m_pStreamCur += ULONG_SIZEOF;
UTF16* pStrUtf16 = (UTF16 *) m_pStreamCur;
UTF32 *pStrUtf32 = (UTF32 *) sBuffer;
// this values will be modificated
UTF16 *pStrUtf16_Conv = pStrUtf16;
const UTF32 *pStrUtf32_Conv = pStrUtf32;
ConversionResult eUnicodeConversionResult =
ConvertUTF32toUTF16 (&pStrUtf32_Conv
, &pStrUtf32[lSize]
, &pStrUtf16_Conv
, &pStrUtf16 [lSize]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
return;
}
}
else
{
lSizeMem = lSize * sizeof(wchar_t);
CheckBufferSize(ULONG_SIZEOF + lSizeMem);
*((ULONG*)m_pStreamCur) = lSizeMem;
m_lPosition += ULONG_SIZEOF;
m_pStreamCur += ULONG_SIZEOF;
memcpy(m_pStreamCur, sBuffer, lSizeMem);
}
m_lPosition += lSizeMem;
m_pStreamCur += lSizeMem;
}
......@@ -451,9 +491,19 @@ namespace NSBinPptxRW
WriteStringW(pChars);
}
void CBinaryFileWriter::WriteStringW2(const WCHAR* sBuffer)
{
if (sizeof(wchar_t) == 4)
{
WriteStringW2_4(sBuffer);
}else
{
WriteStringW2_2(sBuffer);
}
}
void CBinaryFileWriter::WriteStringW2_2(const WCHAR* sBuffer)
{
LONG lSize = __wstrlen(sBuffer);
LONG lSizeMem = lSize * sizeof(wchar_t);
LONG lSizeMem = lSize * sizeof(UTF16);
CheckBufferSize(ULONG_SIZEOF + lSizeMem);
......@@ -464,14 +514,59 @@ namespace NSBinPptxRW
memcpy(m_pStreamCur, sBuffer, lSizeMem);
m_lPosition += lSizeMem;
m_pStreamCur += lSizeMem;
}
void CBinaryFileWriter::WriteStringW2_4(const WCHAR* sBuffer)
{
LONG lSize = __wstrlen(sBuffer);
LONG lSizeMem = lSize * sizeof(wchar_t);
CheckBufferSize(ULONG_SIZEOF + lSizeMem);
*((ULONG*)m_pStreamCur) = lSize;
m_lPosition += ULONG_SIZEOF;
m_pStreamCur += ULONG_SIZEOF;
UTF16* pStrUtf16 = (UTF16 *) m_pStreamCur;
UTF32 *pStrUtf32 = (UTF32 *) sBuffer;
// this values will be modificated
UTF16 *pStrUtf16_Conv = pStrUtf16;
const UTF32 *pStrUtf32_Conv = pStrUtf32;
ConversionResult eUnicodeConversionResult =
ConvertUTF32toUTF16 (&pStrUtf32_Conv
, &pStrUtf32[lSize]
, &pStrUtf16_Conv
, &pStrUtf16 [lSize]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
return;
}
m_lPosition += lSizeMem;
m_pStreamCur += lSizeMem;
}
void CBinaryFileWriter::WriteStringW2(CString& sBuffer)
{
WriteStringW2(sBuffer.GetBuffer());
}
void CBinaryFileWriter::WriteStringW3(const WCHAR* sBuffer)
{
if (sizeof(wchar_t) == 4)
{
WriteStringW3_4(sBuffer);
}else
{
WriteStringW3_2(sBuffer);
}
}
void CBinaryFileWriter::WriteStringW3_2(const WCHAR* sBuffer)
{
LONG lSize = __wstrlen(sBuffer);
LONG lSizeMem = lSize * sizeof(wchar_t);
CheckBufferSize(lSizeMem);
......@@ -480,6 +575,36 @@ namespace NSBinPptxRW
m_lPosition += lSizeMem;
m_pStreamCur += lSizeMem;
}
void CBinaryFileWriter::WriteStringW3_4(const WCHAR* sBuffer)
{
LONG lSize = __wstrlen(sBuffer);
LONG lSizeMem = lSize * sizeof(UTF16);
CheckBufferSize(lSizeMem);
UTF16* pStrUtf16 = (UTF16 *) m_pStreamCur;
UTF32 *pStrUtf32 = (UTF32 *) sBuffer;
// this values will be modificated
UTF16 *pStrUtf16_Conv = pStrUtf16;
const UTF32 *pStrUtf32_Conv = pStrUtf32;
ConversionResult eUnicodeConversionResult =
ConvertUTF32toUTF16 (&pStrUtf32_Conv
, &pStrUtf32[lSize]
, &pStrUtf16_Conv
, &pStrUtf16 [lSize]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
return;
}
m_lPosition += lSizeMem;
m_pStreamCur += lSizeMem;
}
void CBinaryFileWriter::WriteStringW3(CString& sBuffer)
{
WriteStringW3(sBuffer.GetBuffer());
......@@ -553,15 +678,41 @@ namespace NSBinPptxRW
BYTE bType = (BYTE)type;
WriteBYTE(bType);
ULONG len = (ULONG)val.GetLength();
WriteULONG(len);
ULONG lSize = (ULONG)val.GetLength() , len = lSize;
WriteULONG(lSize);
len <<= 1;
CString* s = const_cast<CString*>(&val);
CheckBufferSize(len);
WCHAR *buffer = s->GetBuffer();
if (sizeof(buffer[0]) == 4)
{
UTF16* pStrUtf16 = (UTF16 *) m_pStreamCur;
UTF32 *pStrUtf32 = (UTF32 *) buffer;
// this values will be modificated
UTF16 *pStrUtf16_Conv = pStrUtf16;
const UTF32 *pStrUtf32_Conv = pStrUtf32;
ConversionResult eUnicodeConversionResult =
ConvertUTF32toUTF16 (&pStrUtf32_Conv
, &pStrUtf32[lSize]
, &pStrUtf16_Conv
, &pStrUtf16 [lSize]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
return;
}
}else
{
memcpy(m_pStreamCur, s->GetBuffer(), len);
}
m_pStreamCur += len;
m_lPosition += len;
}
......@@ -572,7 +723,7 @@ namespace NSBinPptxRW
}
void CBinaryFileWriter::WriteString(const CString& val)
{
ULONG len = (ULONG)val.GetLength();
ULONG lSize = (ULONG)val.GetLength() , len = lSize;
WriteULONG(len);
len <<= 1;
......@@ -580,7 +731,33 @@ namespace NSBinPptxRW
CString* s = const_cast<CString*>(&val);
CheckBufferSize(len);
WCHAR *buffer = s->GetBuffer();
if (sizeof(buffer[0]) == 4)
{
UTF16* pStrUtf16 = (UTF16 *) m_pStreamCur;
UTF32 *pStrUtf32 = (UTF32 *) buffer;
// this values will be modificated
UTF16 *pStrUtf16_Conv = pStrUtf16;
const UTF32 *pStrUtf32_Conv = pStrUtf32;
ConversionResult eUnicodeConversionResult =
ConvertUTF32toUTF16 (&pStrUtf32_Conv
, &pStrUtf32[lSize]
, &pStrUtf16_Conv
, &pStrUtf16 [lSize]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
return;
}
}else
{
memcpy(m_pStreamCur, s->GetBuffer(), len);
}
m_pStreamCur += len;
m_lPosition += len;
}
......
......@@ -229,9 +229,13 @@ namespace NSBinPptxRW
void WriteStringA(CStringA& sBuffer);
void WriteStringW(CString& sBuffer);
void WriteStringW2(const WCHAR* sBuffer);
void WriteStringW2_2(const WCHAR* sBuffer);
void WriteStringW2_4(const WCHAR* sBuffer);
void WriteStringW2(CString& sBuffer);
void WriteStringW3(const WCHAR* sBuffer);
void WriteStringW3(CString& sBuffer);
void WriteStringW3_2(const WCHAR* sBuffer);
void WriteStringW3_4(const WCHAR* sBuffer);
// --------------------------------------------------------
public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment