Commit 5888bfe8 authored by Ivan.Shulga's avatar Ivan.Shulga Committed by Alexander Trofimov

ubuntu build (not finished)

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@57633 954022d7-b5bf-4e40-9824-e11837661b57
parent e4e174fe
This source diff could not be displayed because it is too large. You can view the blob instead.
#pragma once
#ifdef _WIN32
#pragma warning( disable : 4996 )
......@@ -46,20 +47,45 @@
#define _ATL_ALL_WARNINGS
#endif
#include <windows.h>
#include <atlbase.h>
#include <atlcoll.h>
#include <atlstr.h>
#include <atltypes.h>
//#include <windows.h>
//#include <atlbase.h>
//#include <atlcoll.h>
//#include <atlstr.h>
//#include <atltypes.h>
#include "..\..\..\ASCUtils.h"
#include "../../../ASCUtils.h"
using namespace ATL;
#else
#include "ASCString.h"
#include "stdint.h"
typedef int BOOL;
static const BOOL TRUE = 1;
static const BOOL FALSE = 0;
typedef int HRESULT;
static const HRESULT S_OK = 0;
static const HRESULT S_FALSE = -1;
typedef unsigned char BYTE;
typedef unsigned short USHORT;
typedef short SHORT;
typedef long LONG;
typedef unsigned long ULONG;
typedef unsigned int DWORD;
typedef unsigned long long ULONG64;
typedef long long LONG64;
typedef wchar_t WCHAR;
#endif // #ifdef _WIN32
#ifndef AVSINLINE
#if defined(_MSC_VER)
#define AVSINLINE __forceinline
#else
#define AVSINLINE inline
#endif
#endif
\ No newline at end of file
#endif
This diff is collapsed.
#ifndef UNICODEUTIL_H
#define UNICODEUTIL_H
/*
* Copyright 2001-2004 Unicode, Inc.
*
* Disclaimer
*
* This source code is provided as is by Unicode, Inc. No claims are
* made as to fitness for any particular purpose. No warranties of any
* kind are expressed or implied. The recipient agrees to determine
* applicability of information provided. If this file has been
* purchased on magnetic or optical media from Unicode, Inc., the
* sole remedy for any claim will be exchange of defective media
* within 90 days of receipt.
*
* Limitations on Rights to Redistribute This Code
*
* Unicode, Inc. hereby grants the right to freely use the information
* supplied in this file in the creation of products supporting the
* Unicode Standard, and to make copies of this file in any form
* for internal or external distribution as long as this notice
* remains attached.
*/
/* ---------------------------------------------------------------------
Conversions between UTF32, UTF-16, and UTF-8. Header file.
Several funtions are included here, forming a complete set of
conversions between the three formats. UTF-7 is not included
here, but is handled in a separate source file.
Each of these routines takes pointers to input buffers and output
buffers. The input buffers are const.
Each routine converts the text between *sourceStart and sourceEnd,
putting the result into the buffer between *targetStart and
targetEnd. Note: the end pointers are *after* the last item: e.g.
*(sourceEnd - 1) is the last item.
The return result indicates whether the conversion was successful,
and if not, whether the problem was in the source or target buffers.
(Only the first encountered problem is indicated.)
After the conversion, *sourceStart and *targetStart are both
updated to point to the end of last text successfully converted in
the respective buffers.
Input parameters:
sourceStart - pointer to a pointer to the source buffer.
The contents of this are modified on return so that
it points at the next thing to be converted.
targetStart - similarly, pointer to pointer to the target buffer.
sourceEnd, targetEnd - respectively pointers to the ends of the
two buffers, for overflow checking only.
These conversion functions take a ConversionFlags argument. When this
flag is set to strict, both irregular sequences and isolated surrogates
will cause an error. When the flag is set to lenient, both irregular
sequences and isolated surrogates are converted.
Whether the flag is strict or lenient, all illegal sequences will cause
an error return. This includes sequences such as: <F4 90 80 80>, <C0 80>,
or <A0> in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code
must check for illegal sequences.
When the flag is set to lenient, characters over 0x10FFFF are converted
to the replacement character; otherwise (when the flag is set to strict)
they constitute an error.
Output parameters:
The value "sourceIllegal" is returned from some routines if the input
sequence is malformed. When "sourceIllegal" is returned, the source
value will point to the illegal value that caused the problem. E.g.,
in UTF-8 when a sequence is malformed, it points to the start of the
malformed sequence.
Author: Mark E. Davis, 1994.
Rev History: Rick McGowan, fixes & updates May 2001.
Fixes & updates, Sept 2001.
------------------------------------------------------------------------ */
/* ---------------------------------------------------------------------
The following 4 definitions are compiler-specific.
The C standard does not guarantee that wchar_t has at least
16 bits, so wchar_t is no less portable than unsigned short!
All should be unsigned values to avoid sign extension during
bit mask & shift operations.
------------------------------------------------------------------------ */
//typedef unsigned long UTF32; /* at least 32 bits */
typedef unsigned int UTF32; /* at least 32 bits */
typedef unsigned short UTF16; /* at least 16 bits */
typedef unsigned char UTF8; /* typically 8 bits */
typedef unsigned char Boolean; /* 0 or 1 */
/* Some fundamental constants */
#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
#define UNI_MAX_BMP (UTF32)0x0000FFFF
#define UNI_MAX_UTF16 (UTF32)0x0010FFFF
#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF
#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF
typedef enum {
conversionOK, /* conversion successful */
sourceExhausted, /* partial character in source, but hit end */
targetExhausted, /* insuff. room in target for conversion */
sourceIllegal /* source sequence is illegal/malformed */
} ConversionResult;
typedef enum {
strictConversion = 0,
lenientConversion
} ConversionFlags;
/* This is for C++ and does no harm in C */
#ifdef __cplusplus
extern "C" {
#endif
ConversionResult ConvertUTF8toUTF16 (
const UTF8** sourceStart, const UTF8* sourceEnd,
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF16toUTF8 (
const UTF16** sourceStart, const UTF16* sourceEnd,
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF8toUTF32 (
const UTF8** sourceStart, const UTF8* sourceEnd,
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF32toUTF8 (
const UTF32** sourceStart, const UTF32* sourceEnd,
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF16toUTF32 (
const UTF16** sourceStart, const UTF16* sourceEnd,
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF32toUTF16 (
const UTF32** sourceStart, const UTF32* sourceEnd,
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd);
#ifdef __cplusplus
}
#endif
/* --------------------------------------------------------------------- */
#endif // UNICODEUTIL_H
#include "Utils.h"
#include "../XML/XmlUtils.h"
#include "../XML/xmlutils.h"
void Common::readAllShapeTypes(const OOX::CPath& oPath, CSimpleArray<CString>& aShapetypes)
void Common::readAllShapeTypes(const OOX::CPath& oPath, std::vector<CString>& aShapetypes)
{
XmlUtils::CXmlLiteReader oReader;
......@@ -16,7 +16,7 @@ void Common::readAllShapeTypes(const OOX::CPath& oPath, CSimpleArray<CString>& a
{
CString sXml = oReader.GetOuterXml();
if(false == sXml.IsEmpty())
aShapetypes.Add(sXml);
aShapetypes.push_back(sXml);
}
}
}
\ No newline at end of file
}
......@@ -2,11 +2,12 @@
#ifndef COMMON_UTILS_INCLUDE_H_
#define COMMON_UTILS_INCLUDE_H_
#include "..\SystemUtility\SystemUtility.h"
#include "../SystemUtility/SystemUtility.h"
#include <vector>
namespace Common
{
void readAllShapeTypes(const OOX::CPath& oPath, CSimpleArray<CString>& aShapetypes);
void readAllShapeTypes(const OOX::CPath& oPath, std::vector<CString>& aShapetypes);
} // namespace Common
#endif // COMMON_UTILS_INCLUDE_H_
\ No newline at end of file
#endif // COMMON_UTILS_INCLUDE_H_
#pragma once
#ifdef _WIN32
#pragma comment(lib, "libxml2.lib")
#include "win_build/Config.h"
#include "./win_build/config.h"
#include "XML/include/libxml/xmlreader.h"
#include <windows.h>
......@@ -293,7 +294,314 @@ namespace XmlUtils
LONG64 m_lFilePosition;
};
}
#else //#ifdef _WIN32
#include "XML/include/libxml/xmlreader.h"
#include "../../Base/Base.h"
#include <stdlib.h>
#include <stdio.h>
#include "assert.h"
namespace NSFile
{
class CFile
{
public:
CFile()
{
m_pFileHandle = NULL;
m_lFileSize = 0;
m_lFilePosition = 0;
}
virtual ~CFile()
{
CloseFile();
}
virtual HRESULT OpenFile(CString FileName)
{
CloseFile();
#ifdef _WIN32
m_pFileHandle = _wfopen(FileName.c_str(), L"rb");
#else
std::string aMutliByteName = stringWstingToUtf8String (FileName);
m_pFileHandle = fopen(aMutliByteName.c_str(), "rb");
#endif
if (NULL == m_pFileHandle)
{
throw std::exception();
}
// get buffer size
fseek(m_pFileHandle, 0, SEEK_END);
m_lFileSize = ftell(m_pFileHandle);
fseek(m_pFileHandle, 0, SEEK_SET);
return S_OK;
}
/*
virtual HRESULT OpenFileRW(CString FileName)
{
CloseFile();
HRESULT hRes = S_OK;
DWORD AccessMode = GENERIC_READ | GENERIC_WRITE;
DWORD ShareMode = FILE_SHARE_READ;
DWORD Disposition = OPEN_EXISTING;
m_hFileHandle = ::CreateFile(FileName, AccessMode, ShareMode, NULL, Disposition, 0, 0);
if (NULL == m_hFileHandle || INVALID_HANDLE_VALUE == m_hFileHandle)
{
hRes = S_FALSE;
}
else
{
ULARGE_INTEGER nTempSize;
nTempSize.LowPart = ::GetFileSize(m_hFileHandle, &nTempSize.HighPart);
m_lFileSize = nTempSize.QuadPart;
SetPosition(0);
}
return hRes;
}
*/
HRESULT ReadFile(BYTE* pData, DWORD nBytesToRead)
{
if(NULL == pData)
return S_FALSE;
if(m_pFileHandle && (pData))
{
fseek(m_pFileHandle, m_lFilePosition, SEEK_SET);
size_t res = fread (pData, 1, nBytesToRead, m_pFileHandle);
m_lFilePosition += res;
if (res != nBytesToRead)
{
return S_FALSE;
}
}
return S_OK;
}
HRESULT ReadFile2(BYTE* pData, DWORD nBytesToRead)
{
if(NULL == pData)
return S_FALSE;
if (m_pFileHandle && (pData))
{
fseek(m_pFileHandle, m_lFilePosition, SEEK_SET);
size_t res = fread (pData, 1, nBytesToRead, m_pFileHandle);
m_lFilePosition += res;
for (size_t index = 0; index < nBytesToRead / 2; ++index)
{
BYTE temp = pData[index];
pData[index] = pData[nBytesToRead - index - 1];
pData[nBytesToRead - index - 1] = temp;
}
}
return S_OK;
}
HRESULT ReadFile3(void* pData, DWORD nBytesToRead)
{
if(NULL == pData)
return S_FALSE;
if (m_pFileHandle && (pData))
{
fseek(m_pFileHandle, m_lFilePosition, SEEK_SET);
size_t res = fread (pData, 1, nBytesToRead, m_pFileHandle);
m_lFilePosition += res;
}
return S_OK;
}
HRESULT WriteFile(void* pData, DWORD nBytesToWrite)
{
DWORD dwWritten = 0;
if (m_pFileHandle)
{
dwWritten = fwrite (pData, 1, nBytesToWrite, m_pFileHandle);
m_lFilePosition += nBytesToWrite;
}
return (dwWritten == nBytesToWrite) ? S_OK : S_FALSE;
}
HRESULT WriteFile2(void* pData, DWORD nBytesToWrite)
{
DWORD dwWritten = 0;
if(m_pFileHandle)
{
BYTE* mem = new BYTE[nBytesToWrite];
memcpy(mem, pData, nBytesToWrite);
for (size_t index = 0; index < nBytesToWrite / 2; ++index)
{
BYTE temp = mem[index];
mem[index] = mem[nBytesToWrite - index - 1];
mem[nBytesToWrite - index - 1] = temp;
}
dwWritten = fwrite (pData, 1, nBytesToWrite, m_pFileHandle);
m_lFilePosition += nBytesToWrite;
delete [] mem;
}
return (dwWritten == nBytesToWrite) ? S_OK : S_FALSE;
}
HRESULT CreateFile(CString strFileName)
{
CloseFile();
#ifdef _WIN32
m_pFileHandle = _wfopen(strFileName.c_str(), L"w");
#else
std::string aMutliByteName = stringWstingToUtf8String (strFileName);
m_pFileHandle = fopen(aMutliByteName.c_str(), "w");
#endif
return SetPosition(0);
}
HRESULT SetPosition( ULONG64 nPos )
{
if (m_pFileHandle && nPos < (ULONG)m_lFileSize)
{
fseek(m_pFileHandle, nPos, SEEK_SET);
m_lFilePosition = nPos;
return S_OK;
}
else
{
return (NULL == m_pFileHandle) ? S_FALSE : S_OK;
}
}
LONG64 GetPosition()
{
return m_lFilePosition;
}
HRESULT SkipBytes(ULONG64 nCount)
{
return SetPosition(m_lFilePosition + nCount);
}
HRESULT CloseFile()
{
m_lFileSize = 0;
m_lFilePosition = 0;
if (NULL != m_pFileHandle)
{
fclose (m_pFileHandle);
}
return S_OK;
}
ULONG64 GetFileSize()
{
return m_lFileSize;
}
HRESULT WriteReserved(DWORD dwCount)
{
BYTE* buf = new BYTE[dwCount];
memset(buf, 0, (size_t)dwCount);
HRESULT hr = WriteFile(buf, dwCount);
delete [] buf;
return hr;
}
HRESULT WriteReserved2(DWORD dwCount)
{
BYTE* buf = new BYTE[dwCount];
memset(buf, 0xFF, (size_t)dwCount);
HRESULT hr = WriteFile(buf, dwCount);
delete [] buf;
return hr;
}
HRESULT WriteReservedTo(DWORD dwPoint)
{
if (m_lFilePosition >= dwPoint)
return S_OK;
DWORD dwCount = dwPoint - (DWORD)m_lFilePosition;
BYTE* buf = new BYTE[dwCount];
memset(buf, 0, (size_t)dwCount);
HRESULT hr = WriteFile(buf, dwCount);
delete [] buf;
return hr;
}
HRESULT SkipReservedTo(DWORD dwPoint)
{
if (m_lFilePosition >= dwPoint)
return S_OK;
DWORD dwCount = dwPoint - (DWORD)m_lFilePosition;
return SkipBytes(dwCount);
}
LONG GetProgress()
{
if (0 >= m_lFileSize)
return -1;
double dVal = (double)(100 * m_lFilePosition);
LONG lProgress = (LONG)(dVal / m_lFileSize);
return lProgress;
}
void WriteStringUTF8(CString& strXml)
{
std::string utf8_str;
#ifdef UNICODE
// Encoding Unicode to UTF-8
utf8_str = stringWstingToUtf8String (strXml);
#else
utf8_str = strXml;
/*
wchar_t* pWStr = new wchar_t[nLength + 1];
if (!pWStr)
return;
// set end string
pWStr[nLength] = 0;
// Encoding ASCII to Unicode
MultiByteToWideChar(CP_ACP, 0, strXml, nLength, pWStr, nLength);
int nLengthW = (int)wcslen(pWStr);
// Encoding Unicode to UTF-8
WideCharToMultiByte(CP_UTF8, 0, pWStr, nLengthW + 1, saStr.GetBuffer(nLengthW*3 + 1), nLengthW*3, NULL, NULL);
saStr.ReleaseBuffer();
delete[] pWStr;
*/
#endif
WriteFile((void*)utf8_str.c_str(), utf8_str.size());
}
protected:
FILE *m_pFileHandle;
long m_lFileSize;
long m_lFilePosition;
};
}
#endif //#ifdef _WIN32
typedef
enum XmlNodeType
......@@ -809,4 +1117,4 @@ namespace XmlUtils
};
}
#endif
\ No newline at end of file
#endif
#pragma once
#ifdef _WIN32
#import <msxml3.dll> rename_namespace("XML")
#ifdef _USE_XMLLITE_READER_
......@@ -2773,7 +2775,9 @@ __forceinline const bool operator!=(const wchar_t* cwsStr1, const CWCharWrapper&
return false;
}
//#define _USE_LIBXML2_READER_
#endif // #ifdef _WIN32
#define _USE_LIBXML2_READER_
#ifdef _USE_LIBXML2_READER_
......@@ -3536,4 +3540,4 @@ namespace XmlUtils
}
#endif
#endif
\ No newline at end of file
#endif
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