Skip to content

Commit

Permalink
Merge branch 'release/onlyoffice-documentbuilder-4.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
agolybev committed Sep 15, 2016
2 parents ee5e5da + 7d8c7f9 commit 61163c6
Show file tree
Hide file tree
Showing 221 changed files with 9,760 additions and 8,142 deletions.
110 changes: 53 additions & 57 deletions ASCOfficeDocFile/Common/FormatUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,23 @@
#include <set>
#include <map>


#include <limits.h>
#include <math.h>

#include "utf8.h"

#if defined(_WIN32) || defined(_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#include <windows.h>
#else
#include "../../DesktopEditor/common/ASCVariant.h"
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#include <string.h>
#endif

#include "../../DesktopEditor/common/Types.h"
#include "../../Common/DocxFormat/Source/XML/stringcommon.h"
#include "../../Common/DocxFormat/Source/Base/unicode_util.h"
#include "../../UnicodeConverter/UnicodeConverter.h"

#include <boost/format.hpp>

namespace DocFormatUtils
{
typedef unsigned char Bool8;
Expand Down Expand Up @@ -131,11 +129,11 @@ namespace DocFormatUtils
{
switch(data[pos])
{
case '&': buffer.append(_T("&amp;")); break;
case '\"': buffer.append(_T("&quot;")); break;
case '\'': buffer.append(_T("&apos;")); break;
case '<': buffer.append(_T("&lt;")); break;
case '>': buffer.append(_T("&gt;")); break;
case '&': buffer.append(L"&amp;"); break;
case '\"': buffer.append(L"&quot;"); break;
case '\'': buffer.append(L"&apos;"); break;
case '<': buffer.append(L"&lt;"); break;
case '>': buffer.append(L"&gt;"); break;
default:
{
if ( false == IsUnicodeSymbol( data[pos] ) )
Expand Down Expand Up @@ -163,11 +161,11 @@ namespace DocFormatUtils
{
switch(data[pos])
{
case '&': buffer.append(_T("&amp;")); break;
case '\"': buffer.append(_T("&quot;")); break;
case '\'': buffer.append(_T("&apos;")); break;
case '<': buffer.append(_T("&lt;")); break;
case '>': buffer.append(_T("&gt;")); break;
case '&': buffer.append(L"&amp;"); break;
case '\"': buffer.append(L"&quot;"); break;
case '\'': buffer.append(L"&apos;"); break;
case '<': buffer.append(L"&lt;"); break;
case '>': buffer.append(L"&gt;"); break;
default: buffer.append(&data[pos], 1); break;
}
}
Expand Down Expand Up @@ -285,33 +283,33 @@ namespace DocFormatUtils

switch ( c )
{
case _T( '&' ):
case L'&':
{
result = std::wstring( _T( "&amp;" ) );
result = std::wstring( L"&amp;" );
}
break;

case _T( '<' ):
case L'<':
{
result = std::wstring( _T( "&lt;" ) );
result = std::wstring( L"&lt;" );
}
break;

case _T( '>' ):
case L'>':
{
result = std::wstring( _T( "&gt;" ) );
result = std::wstring( L"&gt;" );
}
break;

case _T( '\"' ):
case L'\"':
{
result = std::wstring( _T( "&quot;" ) );
result = std::wstring( L"&quot;" );
}
break;

case _T( '\'' ):
case L'\'':
{
result = std::wstring( _T( "&apos;" ) );
result = std::wstring( L"&apos;" );
}
break;

Expand Down Expand Up @@ -768,10 +766,13 @@ namespace DocFormatUtils

static inline std::wstring IntToWideString(int value)
{
CString strValue;
strValue.Format(_T("%d"), value);

return string2std_string(strValue);
#if defined(_WIN32) || defined (_WIN64)
wchar_t buff[33] ={};
_itow(value, buff, 10);
return std::wstring(buff);
#else
return (std::to_wstring(value));
#endif
}
static inline std::wstring DoubleToWideString(double value)
{
Expand All @@ -782,17 +783,6 @@ namespace DocFormatUtils
return std::wstring(src.str());
}

static inline std::string IntToString(int value, int radix = 10)
{
const int size = 33;

char strValue[size];

itoa(value, strValue, radix);

return std::string(strValue);
}

static inline std::string DoubleToString(double value)
{
std::stringstream src;
Expand All @@ -807,7 +797,7 @@ namespace DocFormatUtils
std::wstring out;
if ( mapArray == NULL )
{
out = std::wstring( _T( "" ) );
out = std::wstring( L"" );
}

if ( value < size1 )
Expand All @@ -825,31 +815,37 @@ namespace DocFormatUtils
{
// const int size = 33;

// wchar_t strValue[size] = _T( "\0" );
// wchar_t strValue[size] = L"\0";

// if ( format != NULL )
// {
if ( format == NULL ) return L"";
// swprintf_s( strValue, size, format, value );
// }
CString format_str;
format_str.Format(format , value);
//// }
// CString format_str;
// format_str.Format(format , value);

return string2std_string( format_str );
std::wstringstream sstream;
sstream << boost::wformat(format) % value;
return sstream.str();
//return string2std_string( format_str );
}

static inline std::wstring DoubleToFormattedWideString( double value, wchar_t* format )
{
std::wstring wstr;
if ( format == NULL ) return L"";
//std::wstring wstr;

if ( format != NULL )
{
CString strValue;
strValue.Format(format, value);
//if ( format != NULL )
//{
// CString strValue;
// strValue.Format(format, value);

wstr = string2std_string( strValue );
}
// wstr = string2std_string( strValue );
//}

return wstr;
//return wstr;
std::wstringstream sstream;
sstream << boost::wformat(format) % value;
return sstream.str();
}

static inline void SetBytes( unsigned char *bytes, int value )
Expand Down
Loading

0 comments on commit 61163c6

Please sign in to comment.