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,18 +406,58 @@ namespace NSBinPptxRW ...@@ -406,18 +406,58 @@ namespace NSBinPptxRW
void CBinaryFileWriter::WriteStringW(const WCHAR* sBuffer) void CBinaryFileWriter::WriteStringW(const WCHAR* sBuffer)
{ {
LONG lSize = __wstrlen(sBuffer); LONG lSize = __wstrlen(sBuffer);
LONG lSizeMem = lSize * sizeof(wchar_t);
CheckBufferSize(ULONG_SIZEOF + lSizeMem); if (lSize < 1) return;
*((ULONG*)m_pStreamCur) = lSizeMem; LONG lSizeMem =0;
m_lPosition += ULONG_SIZEOF;
m_pStreamCur += ULONG_SIZEOF;
memcpy(m_pStreamCur, sBuffer, lSizeMem); if (sizeof (sBuffer[0]) == 4)
m_lPosition += lSizeMem; {
m_pStreamCur += lSizeMem; 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;
}
void CBinaryFileWriter::WriteBYTEArray(const BYTE* pBuffer, size_t len) void CBinaryFileWriter::WriteBYTEArray(const BYTE* pBuffer, size_t len)
{ {
CheckBufferSize(len); CheckBufferSize(len);
...@@ -450,7 +490,34 @@ namespace NSBinPptxRW ...@@ -450,7 +490,34 @@ namespace NSBinPptxRW
WCHAR* pChars = sBuffer.GetBuffer(); WCHAR* pChars = sBuffer.GetBuffer();
WriteStringW(pChars); WriteStringW(pChars);
} }
void CBinaryFileWriter::WriteStringW2(const WCHAR* sBuffer) 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(UTF16);
CheckBufferSize(ULONG_SIZEOF + lSizeMem);
*((ULONG*)m_pStreamCur) = lSize;
m_lPosition += ULONG_SIZEOF;
m_pStreamCur += ULONG_SIZEOF;
memcpy(m_pStreamCur, sBuffer, lSizeMem);
m_lPosition += lSizeMem;
m_pStreamCur += lSizeMem;
}
void CBinaryFileWriter::WriteStringW2_4(const WCHAR* sBuffer)
{ {
LONG lSize = __wstrlen(sBuffer); LONG lSize = __wstrlen(sBuffer);
LONG lSizeMem = lSize * sizeof(wchar_t); LONG lSizeMem = lSize * sizeof(wchar_t);
...@@ -461,8 +528,25 @@ namespace NSBinPptxRW ...@@ -461,8 +528,25 @@ namespace NSBinPptxRW
m_lPosition += ULONG_SIZEOF; m_lPosition += ULONG_SIZEOF;
m_pStreamCur += ULONG_SIZEOF; m_pStreamCur += ULONG_SIZEOF;
memcpy(m_pStreamCur, sBuffer, lSizeMem); UTF16* pStrUtf16 = (UTF16 *) m_pStreamCur;
m_lPosition += lSizeMem; 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; m_pStreamCur += lSizeMem;
} }
void CBinaryFileWriter::WriteStringW2(CString& sBuffer) void CBinaryFileWriter::WriteStringW2(CString& sBuffer)
...@@ -470,17 +554,58 @@ namespace NSBinPptxRW ...@@ -470,17 +554,58 @@ namespace NSBinPptxRW
WriteStringW2(sBuffer.GetBuffer()); WriteStringW2(sBuffer.GetBuffer());
} }
void CBinaryFileWriter::WriteStringW3(const WCHAR* sBuffer) void CBinaryFileWriter::WriteStringW3(const WCHAR* sBuffer)
{ {
LONG lSize = __wstrlen(sBuffer); if (sizeof(wchar_t) == 4)
LONG lSizeMem = lSize * sizeof(wchar_t); {
WriteStringW3_4(sBuffer);
}else
{
WriteStringW3_2(sBuffer);
}
}
void CBinaryFileWriter::WriteStringW3_2(const WCHAR* sBuffer)
{
LONG lSize = __wstrlen(sBuffer);
CheckBufferSize(lSizeMem); LONG lSizeMem = lSize * sizeof(wchar_t);
memcpy(m_pStreamCur, sBuffer, lSizeMem); CheckBufferSize(lSizeMem);
m_lPosition += lSizeMem;
m_pStreamCur += lSizeMem; memcpy(m_pStreamCur, sBuffer, lSizeMem);
} m_lPosition += lSizeMem;
void CBinaryFileWriter::WriteStringW3(CString& sBuffer) 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()); WriteStringW3(sBuffer.GetBuffer());
} }
...@@ -553,15 +678,41 @@ namespace NSBinPptxRW ...@@ -553,15 +678,41 @@ namespace NSBinPptxRW
BYTE bType = (BYTE)type; BYTE bType = (BYTE)type;
WriteBYTE(bType); WriteBYTE(bType);
ULONG len = (ULONG)val.GetLength(); ULONG lSize = (ULONG)val.GetLength() , len = lSize;
WriteULONG(len); WriteULONG(lSize);
len <<= 1; len <<= 1;
CString* s = const_cast<CString*>(&val); CString* s = const_cast<CString*>(&val);
CheckBufferSize(len); CheckBufferSize(len);
memcpy(m_pStreamCur, s->GetBuffer(), 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_pStreamCur += len;
m_lPosition += len; m_lPosition += len;
} }
...@@ -572,15 +723,41 @@ namespace NSBinPptxRW ...@@ -572,15 +723,41 @@ namespace NSBinPptxRW
} }
void CBinaryFileWriter::WriteString(const CString& val) void CBinaryFileWriter::WriteString(const CString& val)
{ {
ULONG len = (ULONG)val.GetLength(); ULONG lSize = (ULONG)val.GetLength() , len = lSize;
WriteULONG(len); WriteULONG(len);
len <<= 1; len <<= 1;
CString* s = const_cast<CString*>(&val); CString* s = const_cast<CString*>(&val);
CheckBufferSize(len); CheckBufferSize(len);
memcpy(m_pStreamCur, s->GetBuffer(), 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_pStreamCur += len;
m_lPosition += len; m_lPosition += len;
} }
......
...@@ -229,9 +229,13 @@ namespace NSBinPptxRW ...@@ -229,9 +229,13 @@ namespace NSBinPptxRW
void WriteStringA(CStringA& sBuffer); void WriteStringA(CStringA& sBuffer);
void WriteStringW(CString& sBuffer); void WriteStringW(CString& sBuffer);
void WriteStringW2(const WCHAR* sBuffer); void WriteStringW2(const WCHAR* sBuffer);
void WriteStringW2_2(const WCHAR* sBuffer);
void WriteStringW2_4(const WCHAR* sBuffer);
void WriteStringW2(CString& sBuffer); void WriteStringW2(CString& sBuffer);
void WriteStringW3(const WCHAR* sBuffer); void WriteStringW3(const WCHAR* sBuffer);
void WriteStringW3(CString& sBuffer); void WriteStringW3(CString& sBuffer);
void WriteStringW3_2(const WCHAR* sBuffer);
void WriteStringW3_4(const WCHAR* sBuffer);
// -------------------------------------------------------- // --------------------------------------------------------
public: 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