Commit 81baa625 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

x2t linux build (Xls File fix)

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@64197 954022d7-b5bf-4e40-9824-e11837661b57
parent f801178d
...@@ -3,35 +3,6 @@ ...@@ -3,35 +3,6 @@
#include <string> #include <string>
#include <string.h> #include <string.h>
#include "../../../Common/DocxFormat/Source/Base/unicode_util.h"
static std::wstring convertUtf16ToWString(const UTF16 * Data, int nLength)
{
UTF32 *pStrUtf32 = new UTF32 [nLength + 1];
memset ((void *) pStrUtf32, 0, sizeof (UTF32) * (nLength + 1));
// this values will be modificated
const UTF16 *pStrUtf16_Conv = Data;
UTF32 *pStrUtf32_Conv = pStrUtf32;
ConversionResult eUnicodeConversionResult =
ConvertUTF16toUTF32 (&pStrUtf16_Conv,
&Data[nLength]
, &pStrUtf32_Conv
, &pStrUtf32 [nLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf32;
return std::wstring();
}
std::wstring wstr ((wchar_t *) pStrUtf32);
delete [] pStrUtf32;
return wstr;
}
namespace xml { namespace xml {
......
...@@ -160,6 +160,19 @@ void CFRecord::appendRawData(const char* raw_data, const size_t size) ...@@ -160,6 +160,19 @@ void CFRecord::appendRawData(const char* raw_data, const size_t size)
} }
void CFRecord::loadAnyData(wchar_t & val)
{
checkFitRead(2);
#if defined(_WIN32) || defined(_WIN64)
val = * getCurData<wchar_t>();
#else
unsigned short val_utf16 = * getCurData<unsigned short>();
val = val_utf16;
#endif
rdPtr += 2;
}
void CFRecord::insertDataFromRecordToBeginning(CFRecordPtr where_from) void CFRecord::insertDataFromRecordToBeginning(CFRecordPtr where_from)
{ {
const char* src_data = where_from->getData(); const char* src_data = where_from->getData();
...@@ -341,8 +354,35 @@ void CFRecord::storeLongData(const char* buf, const size_t size) ...@@ -341,8 +354,35 @@ void CFRecord::storeLongData(const char* buf, const size_t size)
size_ += size; size_ += size;
} }
} }
#if !defined(_WIN32) && !defined(_WIN64)
CFRecord& operator>>(CFRecord & record, std::string & str)
{
str.clear();
char symbol;
do
{
record.loadAnyData(symbol);
str += symbol;
} while (symbol);
return record;
}
CFRecord& operator>>(CFRecord & record, std::wstring & str)
{
std::vector<unsigned short> utf16;
str.clear();
unsigned short symbol;
do
{
record.loadAnyData(symbol);
utf16.push_back(symbol);
} while (symbol);
str = convertUtf16ToWString(utf16.data(),utf16.size());
utf16.clear();
return record;
}
#endif
} // namespace XLS } // namespace XLS
...@@ -8,10 +8,39 @@ ...@@ -8,10 +8,39 @@
#include <common.h> #include <common.h>
#include <Auxiliary/HelpFunc.h> #include <Auxiliary/HelpFunc.h>
#include "../../../Common/DocxFormat/Source/Base/unicode_util.h"
namespace XLS namespace XLS
{ {
static std::wstring convertUtf16ToWString(const UTF16 * Data, int nLength)
{
UTF32 *pStrUtf32 = new UTF32 [nLength + 1];
memset ((void *) pStrUtf32, 0, sizeof (UTF32) * (nLength + 1));
// this values will be modificated
const UTF16 *pStrUtf16_Conv = Data;
UTF32 *pStrUtf32_Conv = pStrUtf32;
ConversionResult eUnicodeConversionResult =
ConvertUTF16toUTF32 (&pStrUtf16_Conv,
&Data[nLength]
, &pStrUtf32_Conv
, &pStrUtf32 [nLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf32;
return std::wstring();
}
std::wstring wstr ((wchar_t *) pStrUtf32);
delete [] pStrUtf32;
return wstr;
}
// Binary representation of a record in BIFF8 // Binary representation of a record in BIFF8
class CFRecord class CFRecord
{ {
...@@ -100,6 +129,8 @@ public: ...@@ -100,6 +129,8 @@ public:
rdPtr += sizeof(T); rdPtr += sizeof(T);
} }
void loadAnyData(wchar_t & val);
template<class T> template<class T>
void storeAnyData(const T& val) void storeAnyData(const T& val)
{ {
...@@ -174,9 +205,12 @@ CFRecord& operator<<(CFRecord& record, std::vector<T>& vec) ...@@ -174,9 +205,12 @@ CFRecord& operator<<(CFRecord& record, std::vector<T>& vec)
} }
template<class T>
CFRecord& operator>>(CFRecord & record, std::basic_string<T, std::char_traits<T>, std::allocator<T> >& str) #if defined(_WIN32) || defined(_WIN64)
{
template<class T>
CFRecord& operator>>(CFRecord & record, std::basic_string<T, std::char_traits<T>, std::allocator<T> >& str)
{
str.clear(); str.clear();
T symbol; T symbol;
do do
...@@ -185,8 +219,12 @@ CFRecord& operator>>(CFRecord & record, std::basic_string<T, std::char_traits<T> ...@@ -185,8 +219,12 @@ CFRecord& operator>>(CFRecord & record, std::basic_string<T, std::char_traits<T>
str += symbol; str += symbol;
} while (symbol); } while (symbol);
return record; return record;
} }
#else
CFRecord& operator>>(CFRecord & record, std::string & str);
CFRecord& operator>>(CFRecord & record, std::wstring & str);
#endif
template<class T> template<class T>
CFRecord& operator<<(CFRecord & record, std::basic_string<T, std::char_traits<T>, std::allocator<T> >& str) CFRecord& operator<<(CFRecord & record, std::basic_string<T, std::char_traits<T>, std::allocator<T> >& str)
......
#include "FileMoniker.h" #include "FileMoniker.h"
#include <Binary/CFRecord.h> #include <Binary/CFRecord.h>
#include <utils.h>
namespace OSHARED namespace OSHARED
{ {
...@@ -46,7 +45,7 @@ void FileMoniker::load(XLS::CFRecord& record) ...@@ -46,7 +45,7 @@ void FileMoniker::load(XLS::CFRecord& record)
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
unicodePath = std::wstring(record.getCurData<wchar_t>(), cbUnicodePathBytes / 2); unicodePath = std::wstring(record.getCurData<wchar_t>(), cbUnicodePathBytes / 2);
#else #else
unicodePath = convertUtf16ToWString(record.getCurData<UTF16>(), cbUnicodePathBytes / 2); unicodePath = XLS::convertUtf16ToWString(record.getCurData<UTF16>(), cbUnicodePathBytes / 2);
#endif #endif
record.skipNunBytes(cbUnicodePathBytes); record.skipNunBytes(cbUnicodePathBytes);
} }
......
...@@ -35,21 +35,6 @@ XLS::BiffStructurePtr HyperlinkMoniker::clone() ...@@ -35,21 +35,6 @@ XLS::BiffStructurePtr HyperlinkMoniker::clone()
return XLS::BiffStructurePtr(new HyperlinkMoniker(*this)); return XLS::BiffStructurePtr(new HyperlinkMoniker(*this));
} }
//void HyperlinkMoniker::toXML(BiffStructurePtr & parent)
//{
// data->toXML(parent);
//}
//const bool HyperlinkMoniker::fromXML(BiffStructurePtr & parent)
//{
// data.reset(new URLMoniker);
// data->fromXML(parent, 1, true);
// return true;
//}
void HyperlinkMoniker::store(XLS::CFRecord& record) void HyperlinkMoniker::store(XLS::CFRecord& record)
{ {
_GUID_ clsid = URLMoniker_CLSID; _GUID_ clsid = URLMoniker_CLSID;
...@@ -60,9 +45,8 @@ void HyperlinkMoniker::store(XLS::CFRecord& record) ...@@ -60,9 +45,8 @@ void HyperlinkMoniker::store(XLS::CFRecord& record)
void HyperlinkMoniker::load(XLS::CFRecord& record) void HyperlinkMoniker::load(XLS::CFRecord& record)
{ {
_GUID_ clsid; _GUID_ clsid={};
record >> clsid; record >> clsid;
monikerClsid = STR::guid2bstr(clsid);
if(URLMoniker_CLSID == clsid) if(URLMoniker_CLSID == clsid)
{ {
......
#include "ItemMoniker.h" #include "ItemMoniker.h"
#include <Binary/CFRecord.h> #include <Binary/CFRecord.h>
#include <utils.h>
namespace OSHARED namespace OSHARED
{ {
...@@ -59,7 +58,7 @@ void ItemMoniker::load(XLS::CFRecord& record) ...@@ -59,7 +58,7 @@ void ItemMoniker::load(XLS::CFRecord& record)
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
delimiterUnicode = std::wstring(record.getCurData<wchar_t>(), sizeof_delimiterUnicode / 2); delimiterUnicode = std::wstring(record.getCurData<wchar_t>(), sizeof_delimiterUnicode / 2);
#else #else
delimiterUnicode = convertUtf16ToWString(record.getCurData<UTF16>(), sizeof_delimiterUnicode / 2); delimiterUnicode = XLS::convertUtf16ToWString(record.getCurData<UTF16>(), sizeof_delimiterUnicode / 2);
#endif #endif
record.skipNunBytes(sizeof_delimiterUnicode); record.skipNunBytes(sizeof_delimiterUnicode);
} }
...@@ -73,7 +72,7 @@ void ItemMoniker::load(XLS::CFRecord& record) ...@@ -73,7 +72,7 @@ void ItemMoniker::load(XLS::CFRecord& record)
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
itemUnicode = std::wstring(record.getCurData<wchar_t>(), sizeof_itemUnicode / 2); itemUnicode = std::wstring(record.getCurData<wchar_t>(), sizeof_itemUnicode / 2);
#else #else
itemUnicode = convertUtf16ToWString(record.getCurData<UTF16>(), sizeof_itemUnicode / 2); itemUnicode = XLS::convertUtf16ToWString(record.getCurData<UTF16>(), sizeof_itemUnicode / 2);
#endif #endif
record.skipNunBytes(sizeof_itemUnicode); record.skipNunBytes(sizeof_itemUnicode);
} }
......
...@@ -393,7 +393,7 @@ void anyString::ReadComplexData(XLS::CFRecord& record) ...@@ -393,7 +393,7 @@ void anyString::ReadComplexData(XLS::CFRecord& record)
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
string_ = std::wstring(record.getCurData<wchar_t>(), op); string_ = std::wstring(record.getCurData<wchar_t>(), op);
#else #else
string_ = convertUtf16ToWString(record.getCurData<UTF16>(), op); string_ = XLS::convertUtf16ToWString(record.getCurData<UTF16>(), op);
#endif #endif
record.skipNunBytes(op); record.skipNunBytes(op);
} }
......
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