Commit de899687 authored by ElenaSubbotina's avatar ElenaSubbotina

DocFormatReader - дешифрование + поддержка формата 95 года

parent 0d261b87
......@@ -47,8 +47,6 @@
#include "utf8.h"
using namespace std;
#if defined(_WIN32) || defined(_WIN64)
#include <atlbase.h>
#include <atlstr.h>
......@@ -59,8 +57,10 @@ using namespace std;
#include "../../DesktopEditor/common/Types.h"
#include "../../Common/DocxFormat/Source/XML/stringcommon.h"
#include "../../Common/DocxFormat/Source/Base/unicode_util.h"
#include "../../UnicodeConverter/UnicodeConverter.h"
namespace ASCDocFormatUtils
namespace DocFormatUtils
{
typedef unsigned char Bool8;
typedef unsigned short Bool16;
......@@ -94,17 +94,16 @@ namespace ASCDocFormatUtils
}
};
typedef enum Encoding
{
ENCODING_INVALID_VALUE = 0x00000000,
ENCODING_WINDOWS_1251 = 0x00000001,
ENCODING_UNICODE = 0x00000002,
} Encoding;
typedef pair <int, int> Int_Pair;
typedef std::pair <int, int> Int_Pair;
static const int gc_nZeroWidth = 222;
#define ENCODING_UTF16 1200
#define ENCODING_WINDOWS_1250 1250
#define ENCODING_UTF8 65001
class FormatUtils
{
public:
......@@ -280,46 +279,46 @@ namespace ASCDocFormatUtils
return ( c <= 31 ) ? ( true ) : ( false );
}
static inline wstring GetXMLSymbol( const wchar_t c )
static inline std::wstring GetXMLSymbol( const wchar_t c )
{
wstring result;
std::wstring result;
switch ( c )
{
case _T( '&' ):
{
result = wstring( _T( "&amp;" ) );
result = std::wstring( _T( "&amp;" ) );
}
break;
case _T( '<' ):
{
result = wstring( _T( "&lt;" ) );
result = std::wstring( _T( "&lt;" ) );
}
break;
case _T( '>' ):
{
result = wstring( _T( "&gt;" ) );
result = std::wstring( _T( "&gt;" ) );
}
break;
case _T( '\"' ):
{
result = wstring( _T( "&quot;" ) );
result = std::wstring( _T( "&quot;" ) );
}
break;
case _T( '\'' ):
{
result = wstring( _T( "&apos;" ) );
result = std::wstring( _T( "&apos;" ) );
}
break;
default:
{
wchar_t res[2] = { c, 0 };
result = wstring( res );
result = std::wstring( res );
}
break;
}
......@@ -487,17 +486,108 @@ namespace ASCDocFormatUtils
return wcharSymbol;
}
template<class T> static bool GetSTLCollectionFromBytes( T *STLCollection, unsigned char *bytes, int size, Encoding encoding )
template<class T> static bool GetSTLCollectionFromLocale( T *STLCollection, unsigned char *bytes, int size)
{
if ( ( STLCollection == NULL ) || ( bytes == NULL ) )
{
return false;
}
std::locale loc("");
std::ctype<wchar_t> const &facet = std::use_facet<std::ctype<wchar_t> >(loc);
std::wstring result;
result.resize(size);
facet.widen((char*)bytes, (char*)bytes + size, &result[0]);
for (long i=0; i < result.length(); i++)
{
STLCollection->push_back(result[i]);
}
}
template<class T> static bool GetSTLCollectionFromUtf8( T *STLCollection, unsigned char *bytes, int size)
{
if ( ( STLCollection == NULL ) || ( bytes == NULL ) )
{
return false;
}
if (sizeof(wchar_t) == 2)//utf8 -> utf16
{
unsigned int nLength = size;
UTF16 *pStrUtf16 = new UTF16 [nLength+1];
memset ((void *) pStrUtf16, 0, sizeof (UTF16) * (nLength+1));
UTF8 *pStrUtf8 = (UTF8 *) bytes;
// this values will be modificated
const UTF8 *pStrUtf8_Conv = pStrUtf8;
UTF16 *pStrUtf16_Conv = pStrUtf16;
ConversionResult eUnicodeConversionResult = ConvertUTF8toUTF16 (&pStrUtf8_Conv, &pStrUtf8[nLength]
, &pStrUtf16_Conv, &pStrUtf16 [nLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf16;
return GetSTLCollectionFromLocale(STLCollection, bytes,size);
}
for (long i=0; i < nLength; i++)
{
STLCollection->push_back(pStrUtf16[i]);
}
delete [] pStrUtf16;
return true;
}
else //utf8 -> utf32
{
unsigned int nLength = size;
UTF32 *pStrUtf32 = new UTF32 [nLength+1];
memset ((void *) pStrUtf32, 0, sizeof (UTF32) * (nLength+1));
UTF8 *pStrUtf8 = (UTF8 *) bytes;
// this values will be modificated
const UTF8 *pStrUtf8_Conv = pStrUtf8;
UTF32 *pStrUtf32_Conv = pStrUtf32;
ConversionResult eUnicodeConversionResult = ConvertUTF8toUTF32 (&pStrUtf8_Conv, &pStrUtf8[nLength]
, &pStrUtf32_Conv, &pStrUtf32 [nLength]
, strictConversion);
if (conversionOK != eUnicodeConversionResult)
{
delete [] pStrUtf32;
return GetSTLCollectionFromLocale(STLCollection, bytes, size);
}
for (long i=0; i < nLength; i++)
{
STLCollection->push_back(pStrUtf32[i]);
}
delete [] pStrUtf32;
return true;
}
}
int i = 0;
template<class T> static bool GetSTLCollectionFromBytes( T *STLCollection, unsigned char *bytes, int size, int code_page )
{
if ( ( STLCollection == NULL ) || ( bytes == NULL ) )
{
return false;
}
if ( encoding == ENCODING_UNICODE )
if (code_page == ENCODING_UTF8)
{
return GetSTLCollectionFromUtf8(STLCollection, bytes, size);
}
else if (code_page == ENCODING_UTF16)
{
int i = 0;
#if !defined(_WIN32) && !defined(_WIN64)
size /= 2;
ConversionResult eUnicodeConversionResult;
......@@ -532,23 +622,42 @@ namespace ASCDocFormatUtils
i += 2;
}
#endif
return true;
}
else if ( encoding == ENCODING_WINDOWS_1251 )
else if (code_page == ENCODING_WINDOWS_1250)
{
wchar_t wch = 0;
int i = 0;
while ( i < size )
{
wch = MapByteToWChar( bytes[i++] );
STLCollection->push_back( wch );
}
}
else
{
std::string sCodePage;
for (int i = 0; i < UNICODE_CONVERTER_ENCODINGS_COUNT; ++i)
{
if (code_page == NSUnicodeConverter::Encodings[i].WindowsCodePage)
{
sCodePage = NSUnicodeConverter::Encodings[i].Name;
break;
}
}
if (sCodePage.empty())
sCodePage = "CP1250"/* + std::to_string(code_page)*/;
return true;
NSUnicodeConverter::CUnicodeConverter oConverter;
std::wstring unicode_string = oConverter.toUnicode((char*)bytes, size, sCodePage.c_str());
for (long i=0; i < unicode_string.size(); i++)
{
STLCollection->push_back(unicode_string[i]);
}
}
return false;
return true;
}
static int BitmaskToInt( int value, int mask )
......@@ -556,7 +665,7 @@ namespace ASCDocFormatUtils
int ret = value & mask;
//shift for all trailing zeros
bitset<sizeof(int)*8> bits( mask );
std::bitset<sizeof(int)*8> bits( mask );
for ( unsigned int i = 0; i < bits.size(); i++ )
{
......@@ -657,7 +766,7 @@ namespace ASCDocFormatUtils
return bytes;
}
static inline wstring IntToWideString(int value)
static inline std::wstring IntToWideString(int value)
{
CString strValue;
strValue.Format(_T("%d"), value);
......@@ -673,7 +782,7 @@ namespace ASCDocFormatUtils
return std::wstring(src.str());
}
static inline string IntToString(int value, int radix = 10)
static inline std::string IntToString(int value, int radix = 10)
{
const int size = 33;
......@@ -681,10 +790,10 @@ namespace ASCDocFormatUtils
itoa(value, strValue, radix);
return string(strValue);
return std::string(strValue);
}
static inline string DoubleToString(double value)
static inline std::string DoubleToString(double value)
{
std::stringstream src;
......@@ -693,17 +802,17 @@ namespace ASCDocFormatUtils
return std::string(src.str());
}
static inline wstring MapValueToWideString( unsigned int value, const wchar_t* mapArray, unsigned int size1, unsigned int size2 )
static inline std::wstring MapValueToWideString( unsigned int value, const wchar_t* mapArray, unsigned int size1, unsigned int size2 )
{
wstring out;
std::wstring out;
if ( mapArray == NULL )
{
out = wstring( _T( "" ) );
out = std::wstring( _T( "" ) );
}
if ( value < size1 )
{
out = wstring( &mapArray[size2*value] );
out = std::wstring( &mapArray[size2*value] );
}
else
{
......@@ -712,7 +821,7 @@ namespace ASCDocFormatUtils
return out;
}
static inline wstring IntToFormattedWideString( int value, const wchar_t* format )
static inline std::wstring IntToFormattedWideString( int value, const wchar_t* format )
{
// const int size = 33;
......@@ -728,9 +837,9 @@ namespace ASCDocFormatUtils
return string2std_string( format_str );
}
static inline wstring DoubleToFormattedWideString( double value, wchar_t* format )
static inline std::wstring DoubleToFormattedWideString( double value, wchar_t* format )
{
wstring wstr;
std::wstring wstr;
if ( format != NULL )
{
......@@ -783,9 +892,9 @@ namespace ASCDocFormatUtils
}
}
static wstring UTF8Decode( const string& text )
static std::wstring UTF8Decode( const std::string& text )
{
wstring wstrText( text.size(), 0 );
std::wstring wstrText( text.size(), 0 );
utf8_decode( text.begin(), text.end(), wstrText.begin() );
......@@ -882,4 +991,4 @@ namespace ASCDocFormatUtils
};
}
using namespace ASCDocFormatUtils;
using namespace DocFormatUtils;
#pragma once
/* GLOBAL.H - RSAREF types and constants
*/
/* PROTOTYPES should be set to one if and only if the compiler supports
function argument prototyping.
The following makes PROTOTYPES default to 0 if it has not already
been defined with C compiler flags.
*/
#include "../../../DesktopEditor/common/Types.h"
#ifdef _WIN32
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../../DesktopEditor/common/ASCVariant.h"
#include "../../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#ifndef PROTOTYPES
#define PROTOTYPES 1
#endif
/* POINTER defines a generic pointer type */
typedef unsigned char *POINTER;
/* UINT2 defines a two unsigned char word */
typedef unsigned short int UINT2;
/* UINT4 defines a four unsigned char word */
typedef unsigned long int UINT4;
/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
returns an empty list.
*/
#if PROTOTYPES
#define PROTO_LIST(list) list
#else
#define PROTO_LIST(list) ()
#endif
#pragma once
#include <vector>
#include "md4c.h"
class MD4
{
public:
MD4(const void* _message = NULL, unsigned int _messageSize = 0) : message(NULL), messageSize(_messageSize)
{
SetMessage(_message, _messageSize);
memset(md4, 0, sizeof(md4));
}
MD4(const MD4& _md4) : message(NULL), messageSize(_md4.messageSize)
{
memset( this->md4, 0, sizeof(this->md4) );
memcpy( this->md4, _md4.md4, sizeof(this->md4) );
if ( _md4.message != NULL )
{
this->message = new unsigned char[this->messageSize];
if ( this->message != NULL )
{
memset( this->message, 0, this->messageSize );
memcpy( this->message, _md4.message, this->messageSize );
}
}
}
~MD4 ()
{
if (message)
{
delete []message;
message = NULL;
}
}
inline void SetMessage (const void* pMessage, unsigned int nMessageSize)
{
if ( ( pMessage != NULL ) && ( 0 != nMessageSize ) )
{
if (message)
{
delete []message;
message = NULL;
}
messageSize = 0;
messageSize = nMessageSize;
message = new unsigned char [ messageSize ];
if ( message )
{
memset ( message, 0, messageSize );
memcpy ( message, pMessage, messageSize );
}
}
}
inline std::vector<unsigned char> GetMD4Bytes() const
{
std::vector<unsigned char> md4Bytes;
MD4_CTX context;
MD4Init( &context );
MD4Update( &context, this->message, this->messageSize );
MD4Final( (unsigned char*)this->md4, &context );
for ( unsigned int i = 0; i < md4Size; i++ )
{
md4Bytes.push_back( this->md4[i] );
}
return md4Bytes;
}
private:
static const unsigned char md4Size = 16;
unsigned char* message;
unsigned int messageSize;
unsigned char md4[md4Size];
};
\ No newline at end of file

/* MD4C.C - RSA Data Security, Inc., MD4 message-digest algorithm
*/
/* Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD4 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD4 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
#include "md4.h"
/* Constants for MD4Transform routine.
*/
#define S11 3
#define S12 7
#define S13 11
#define S14 19
#define S21 3
#define S22 5
#define S23 9
#define S24 13
#define S31 3
#define S32 9
#define S33 11
#define S34 15
static void MD4Transform PROTO_LIST ((UINT4 [4], unsigned char [64]));
static void Encode PROTO_LIST
((unsigned char *, UINT4 *, unsigned int));
static void Decode PROTO_LIST
((UINT4 *, unsigned char *, unsigned int));
static void MD4_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int));
static void MD4_memset PROTO_LIST ((POINTER, int, unsigned int));
static unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* F, G and H are basic MD4 functions.
*/
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
/* ROTATE_LEFT rotates x left n bits.
*/
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* FF, GG and HH are transformations for rounds 1, 2 and 3 */
/* Rotation is separate from addition to prevent recomputation */
#define FF(a, b, c, d, x, s) { \
(a) += F ((b), (c), (d)) + (x); \
(a) = ROTATE_LEFT ((a), (s)); \
}
#define GG(a, b, c, d, x, s) { \
(a) += G ((b), (c), (d)) + (x) + (UINT4)0x5a827999; \
(a) = ROTATE_LEFT ((a), (s)); \
}
#define HH(a, b, c, d, x, s) { \
(a) += H ((b), (c), (d)) + (x) + (UINT4)0x6ed9eba1; \
(a) = ROTATE_LEFT ((a), (s)); \
}
/* MD4 initialization. Begins an MD4 operation, writing a new context.
*/
void MD4Init ( MD4_CTX *context /* context */ )
{
context->count[0] = context->count[1] = 0;
/* Load magic initialization constants.
*/
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
}
/* MD4 block update operation. Continues an MD4 message-digest
operation, processing another message block, and updating the
context.
*/
void MD4Update ( MD4_CTX *context /* context */, unsigned char *input /* input block */, unsigned int inputLen /* length of input block */ )
{
unsigned int i, index, partLen;
/* Compute number of bytes mod 64 */
index = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((UINT4)inputLen << 3))
< ((UINT4)inputLen << 3))
context->count[1]++;
context->count[1] += ((UINT4)inputLen >> 29);
partLen = 64 - index;
/* Transform as many times as possible.
*/
if (inputLen >= partLen) {
MD4_memcpy
((POINTER)&context->buffer[index], (POINTER)input, partLen);
MD4Transform (context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
MD4Transform (context->state, &input[i]);
index = 0;
}
else
i = 0;
/* Buffer remaining input */
MD4_memcpy
((POINTER)&context->buffer[index], (POINTER)&input[i],
inputLen-i);
}
/* MD4 finalization. Ends an MD4 message-digest operation, writing the
the message digest and zeroizing the context.
*/
void MD4Final ( unsigned char digest[16] /* message digest */, MD4_CTX *context /* context */ )
{
unsigned char bits[8];
unsigned int index, padLen;
/* Save number of bits */
Encode (bits, context->count, 8);
/* Pad out to 56 mod 64.
*/
index = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
MD4Update (context, PADDING, padLen);
/* Append length (before padding) */
MD4Update (context, bits, 8);
/* Store state in digest */
Encode (digest, context->state, 16);
/* Zeroize sensitive information.
*/
MD4_memset ((POINTER)context, 0, sizeof (*context));
}
/* MD4 basic transformation. Transforms state based on block.
*/
static void MD4Transform ( UINT4 state[4], unsigned char block[64] )
{
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
Decode (x, block, 64);
/* Round 1 */
FF (a, b, c, d, x[ 0], S11); /* 1 */
FF (d, a, b, c, x[ 1], S12); /* 2 */
FF (c, d, a, b, x[ 2], S13); /* 3 */
FF (b, c, d, a, x[ 3], S14); /* 4 */
FF (a, b, c, d, x[ 4], S11); /* 5 */
FF (d, a, b, c, x[ 5], S12); /* 6 */
FF (c, d, a, b, x[ 6], S13); /* 7 */
FF (b, c, d, a, x[ 7], S14); /* 8 */
FF (a, b, c, d, x[ 8], S11); /* 9 */
FF (d, a, b, c, x[ 9], S12); /* 10 */
FF (c, d, a, b, x[10], S13); /* 11 */
FF (b, c, d, a, x[11], S14); /* 12 */
FF (a, b, c, d, x[12], S11); /* 13 */
FF (d, a, b, c, x[13], S12); /* 14 */
FF (c, d, a, b, x[14], S13); /* 15 */
FF (b, c, d, a, x[15], S14); /* 16 */
/* Round 2 */
GG (a, b, c, d, x[ 0], S21); /* 17 */
GG (d, a, b, c, x[ 4], S22); /* 18 */
GG (c, d, a, b, x[ 8], S23); /* 19 */
GG (b, c, d, a, x[12], S24); /* 20 */
GG (a, b, c, d, x[ 1], S21); /* 21 */
GG (d, a, b, c, x[ 5], S22); /* 22 */
GG (c, d, a, b, x[ 9], S23); /* 23 */
GG (b, c, d, a, x[13], S24); /* 24 */
GG (a, b, c, d, x[ 2], S21); /* 25 */
GG (d, a, b, c, x[ 6], S22); /* 26 */
GG (c, d, a, b, x[10], S23); /* 27 */
GG (b, c, d, a, x[14], S24); /* 28 */
GG (a, b, c, d, x[ 3], S21); /* 29 */
GG (d, a, b, c, x[ 7], S22); /* 30 */
GG (c, d, a, b, x[11], S23); /* 31 */
GG (b, c, d, a, x[15], S24); /* 32 */
/* Round 3 */
HH (a, b, c, d, x[ 0], S31); /* 33 */
HH (d, a, b, c, x[ 8], S32); /* 34 */
HH (c, d, a, b, x[ 4], S33); /* 35 */
HH (b, c, d, a, x[12], S34); /* 36 */
HH (a, b, c, d, x[ 2], S31); /* 37 */
HH (d, a, b, c, x[10], S32); /* 38 */
HH (c, d, a, b, x[ 6], S33); /* 39 */
HH (b, c, d, a, x[14], S34); /* 40 */
HH (a, b, c, d, x[ 1], S31); /* 41 */
HH (d, a, b, c, x[ 9], S32); /* 42 */
HH (c, d, a, b, x[ 5], S33); /* 43 */
HH (b, c, d, a, x[13], S34); /* 44 */
HH (a, b, c, d, x[ 3], S31); /* 45 */
HH (d, a, b, c, x[11], S32); /* 46 */
HH (c, d, a, b, x[ 7], S33); /* 47 */
HH (b, c, d, a, x[15], S34); /* 48 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
/* Zeroize sensitive information.
*/
MD4_memset ((POINTER)x, 0, sizeof (x));
}
/* Encodes input (UINT4) into output (unsigned char). Assumes len is
a multiple of 4.
*/
static void Encode ( unsigned char *output, UINT4 *input, unsigned int len )
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4) {
output[j] = (unsigned char)(input[i] & 0xff);
output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
}
}
/* Decodes input (unsigned char) into output (UINT4). Assumes len is
a multiple of 4.
*/
static void Decode ( UINT4 *output, unsigned char *input, unsigned int len )
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
(((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
}
/* Note: Replace "for loop" with standard memcpy if possible.
*/
static void MD4_memcpy ( POINTER output, POINTER input, unsigned int len )
{
unsigned int i;
for (i = 0; i < len; i++)
output[i] = input[i];
}
/* Note: Replace "for loop" with standard memset if possible.
*/
static void MD4_memset ( POINTER output, int value, unsigned int len )
{
unsigned int i;
for (i = 0; i < len; i++)
((char *)output)[i] = (char)value;
}
#pragma once
/* MD4C.H - header file for MD4C.C
*/
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD4 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD4 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
#include "global.h"
/* MD4 context. */
typedef struct {
UINT4 state[4]; /* state (ABCD) */
UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} MD4_CTX;
void MD4Init PROTO_LIST ((MD4_CTX *));
void MD4Update PROTO_LIST
((MD4_CTX *, unsigned char *, unsigned int));
void MD4Final PROTO_LIST ((unsigned char [16], MD4_CTX *));
\ No newline at end of file
......@@ -35,8 +35,6 @@
#include <map>
#include <list>
using namespace std;
#if defined(_WIN32) || defined(_WIN64)
#include <atlbase.h>
#include <atlstr.h>
......@@ -67,8 +65,8 @@ namespace XMLTools
template <class T> class XMLAttribute
{
private:
basic_string<T> m_Name;
basic_string<T> m_Value;
std::basic_string<T> m_Name;
std::basic_string<T> m_Value;
public:
......@@ -99,33 +97,33 @@ namespace XMLTools
void SetValue( const T* value )
{
m_Value = basic_string<T>( value );
m_Value = std::basic_string<T>( value );
}
/*========================================================================================================*/
basic_string<T> GetName() const
std::basic_string<T> GetName() const
{
return m_Name;
}
/*========================================================================================================*/
basic_string<T> GetValue() const
std::basic_string<T> GetValue() const
{
return m_Value;
}
/*========================================================================================================*/
basic_string<T> GetXMLString()
std::basic_string<T> GetXMLString()
{
basic_string<T> xmlString( _T( "" ) );
std::basic_string<T> xmlString( _T( "" ) );
xmlString += m_Name;
xmlString += basic_string<T>( _T( "=\"" ) );
xmlString += std::basic_string<T>( _T( "=\"" ) );
xmlString += m_Value;
xmlString += basic_string<T>( _T( "\"" ) );
xmlString += std::basic_string<T>( _T( "\"" ) );
return xmlString;
}
......@@ -137,19 +135,19 @@ namespace XMLTools
template <class T> class XMLElement
{
typedef pair< basic_string<T>, basic_string<T> > AttributeValuePair;
typedef std::pair< std::basic_string<T>, std::basic_string<T> > AttributeValuePair;
private:
basic_string<T> m_Name;
basic_string<T> m_ElementText;
map<basic_string<T>, basic_string<T>> m_AttributeMap;
list<XMLElement<T>> m_Elements;
std::basic_string<T> m_Name;
std::basic_string<T> m_ElementText;
std::map<std::basic_string<T>, std::basic_string<T>> m_AttributeMap;
std::list<XMLElement<T>> m_Elements;
typedef typename list<XMLElement<T>>::iterator ElementsIterator;
typedef typename list<XMLElement<T>>::const_iterator ElementsIteratorConst;
typedef typename std::list<XMLElement<T>>::iterator ElementsIterator;
typedef typename std::list<XMLElement<T>>::const_iterator ElementsIteratorConst;
typedef typename map<basic_string<T>, basic_string<T>>::iterator AttMapIterator;
typedef typename map<basic_string<T>, basic_string<T>>::const_iterator AttMapIteratorConst;
typedef typename std::map<std::basic_string<T>, std::basic_string<T>>::iterator AttMapIterator;
typedef typename std::map<std::basic_string<T>, std::basic_string<T>>::const_iterator AttMapIteratorConst;
public:
......@@ -167,7 +165,7 @@ namespace XMLTools
/*========================================================================================================*/
XMLElement( const T* prefix, const T* localName ) : m_Name( basic_string<T>( prefix ) + basic_string<T>( _T( ":" ) ) + basic_string<T>( localName ) ), m_ElementText( _T( "" ) )
XMLElement( const T* prefix, const T* localName ) : m_Name( std::basic_string<T>( prefix ) + std::basic_string<T>( _T( ":" ) ) + std::basic_string<T>( localName ) ), m_ElementText( _T( "" ) )
{
}
......@@ -183,14 +181,14 @@ namespace XMLTools
void AppendText( const T* text )
{
m_ElementText = basic_string<T>( text );
m_ElementText = std::basic_string<T>( text );
}
/*========================================================================================================*/
void AppendTextSymbol( const T symbol )
{
m_ElementText += basic_string<T>( &symbol );
m_ElementText += std::basic_string<T>( &symbol );
}
/*========================================================================================================*/
......@@ -206,7 +204,7 @@ namespace XMLTools
void AppendAttribute( const T* name, const T* value )
{
AttributeValuePair p( basic_string<T>( const_cast<T*>( name ) ), basic_string<T>( const_cast<T*>( value ) ) );
AttributeValuePair p( std::basic_string<T>( const_cast<T*>( name ) ), std::basic_string<T>( const_cast<T*>( value ) ) );
m_AttributeMap.insert( p );
}
......@@ -252,7 +250,7 @@ namespace XMLTools
for ( ElementsIterator iter = m_Elements.begin(); iter != m_Elements.end(); iter++ )
{
if ( iter->m_Name == basic_string<T>( elementName ) )
if ( iter->m_Name == std::basic_string<T>( elementName ) )
{
result = true;
......@@ -265,7 +263,7 @@ namespace XMLTools
/*========================================================================================================*/
bool RemoveChildByName( const basic_string<T>& elementName )
bool RemoveChildByName( const std::basic_string<T>& elementName )
{
bool result = false;
......@@ -334,34 +332,34 @@ namespace XMLTools
/*========================================================================================================*/
basic_string<T> GetName() const
std::basic_string<T> GetName() const
{
return m_Name;
}
/*========================================================================================================*/
basic_string<T> GetXMLString()
std::basic_string<T> GetXMLString()
{
basic_string<T> xmlString( _T( "" ) );
std::basic_string<T> xmlString( _T( "" ) );
bool bIsNameExists = ( m_Name != basic_string<T>( _T( "" ) ) );
bool bIsTextExists = ( m_ElementText != basic_string<T>( _T( "" ) ) );
bool bIsNameExists = ( m_Name != std::basic_string<T>( _T( "" ) ) );
bool bIsTextExists = ( m_ElementText != std::basic_string<T>( _T( "" ) ) );
if ( bIsNameExists )
{
xmlString += basic_string<T>( _T( "<" ) ) + m_Name;
xmlString += std::basic_string<T>( _T( "<" ) ) + m_Name;
}
if ( ( bIsNameExists ) && ( m_AttributeMap.size() > 0 ) )
{
for ( AttMapIterator iter = m_AttributeMap.begin(); iter != m_AttributeMap.end(); iter++ )
{
xmlString += basic_string<T>( _T( " " ) );
xmlString += std::basic_string<T>( _T( " " ) );
xmlString += iter->first;
xmlString += basic_string<T>( _T( "=\"" ) );
xmlString += std::basic_string<T>( _T( "=\"" ) );
xmlString += iter->second;
xmlString += basic_string<T>( _T( "\"" ) );
xmlString += std::basic_string<T>( _T( "\"" ) );
}
}
......@@ -369,7 +367,7 @@ namespace XMLTools
{
if ( bIsNameExists )
{
xmlString += basic_string<T>( _T( ">" ) );
xmlString += std::basic_string<T>( _T( ">" ) );
}
for ( ElementsIterator iter = m_Elements.begin(); iter != m_Elements.end(); iter++ )
......@@ -384,16 +382,16 @@ namespace XMLTools
if ( bIsNameExists )
{
xmlString += basic_string<T>( _T( "</" ) );
xmlString += std::basic_string<T>( _T( "</" ) );
xmlString += m_Name;
xmlString += basic_string<T>( _T( ">" ) );
xmlString += std::basic_string<T>( _T( ">" ) );
}
}
else
{
if ( bIsNameExists )
{
xmlString += basic_string<T>( _T( "/>" ) );
xmlString += std::basic_string<T>( _T( "/>" ) );
}
}
......
......@@ -36,12 +36,15 @@
namespace DocFileFormat
{
class AnnotationOwnerList: public vector<wstring>
class AnnotationOwnerList: public std::vector<std::wstring>
{
public:
AnnotationOwnerList(FileInformationBlock* fib, POLE::Stream* tableStream) : std::vector<wstring>()
AnnotationOwnerList(FileInformationBlock* fib, POLE::Stream* tableStream) : std::vector<std::wstring>()
{
VirtualStreamReader reader(tableStream, fib->m_FibWord97.fcGrpXstAtnOwners);
VirtualStreamReader reader(tableStream, fib->m_FibWord97.fcGrpXstAtnOwners, fib->m_bOlderVersion);
if (fib->m_FibWord97.fcGrpXstAtnOwners > reader.GetSize()) return;
while (reader.GetPosition() < (fib->m_FibWord97.fcGrpXstAtnOwners + fib->m_FibWord97.lcbGrpXstAtnOwners))
{
push_back(reader.ReadXst());
......
......@@ -43,7 +43,7 @@ namespace DocFileFormat
unsigned char *chars = reader->ReadBytes(18, true);
FormatUtils::GetSTLCollectionFromBytes<wstring>( &(newObject->m_UserInitials), chars, ( cch * 2 ), ENCODING_UNICODE);
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(newObject->m_UserInitials), chars, ( cch * 2 ), ENCODING_UTF16);
newObject->m_AuthorIndex = reader->ReadUInt16();
......
......@@ -106,7 +106,7 @@ namespace DocFileFormat
unsigned char brcType;
/// The color of the Border.
/// Unused if cv is set.
wstring ico;
std::wstring ico;
/// Width of space to maintain between border and text within border
int dptSpace;
/// When true, border is drawn with shadow. Must be false when BRC is substructure of the TC
......@@ -134,7 +134,7 @@ namespace DocFileFormat
{
//it's a border code of Word 2000/2003
this->cv = FormatUtils::BytesToInt32( bytes, 0, size );
this->ico = wstring( Global::ColorIdentifier[0] );
this->ico = std::wstring( Global::ColorIdentifier[0] );
this->dptLineWidth = bytes[4];
this->brcType = bytes[5];
......
......@@ -115,7 +115,7 @@ namespace DocFileFormat
/*========================================================================================================*/
void CharacterPropertiesMapping::convertSprms( list<SinglePropertyModifier>* sprms, XMLTools::XMLElement<wchar_t>* parent )
void CharacterPropertiesMapping::convertSprms( std::list<SinglePropertyModifier>* sprms, XMLTools::XMLElement<wchar_t>* parent )
{
XMLTools::XMLElement<wchar_t> * rFonts = new XMLTools::XMLElement<wchar_t> ( _T( "w:rFonts" ) );
XMLTools::XMLElement<wchar_t> * color = new XMLTools::XMLElement<wchar_t> ( _T( "w:color" ) );
......@@ -292,7 +292,7 @@ namespace DocFileFormat
case sprmCFtcBi :
{//default from FontTable
SHORT nIndex = FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize);
if( nIndex < _doc->FontTable->cData )
if( nIndex < _doc->FontTable->Data.size() )
{
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
if (ffn)
......@@ -324,7 +324,7 @@ namespace DocFileFormat
case sprmCRgFtc0: // font family
{
int nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if( nIndex < _doc->FontTable->cData )
if( nIndex < _doc->FontTable->Data.size() )
{
XMLTools::XMLAttribute<wchar_t>* ascii = new XMLTools::XMLAttribute<wchar_t>( _T( "w:ascii" ) );
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
......@@ -337,7 +337,7 @@ namespace DocFileFormat
case sprmCRgFtc1:
{
int nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if( nIndex>=0 && nIndex < _doc->FontTable->cData )
if( nIndex>=0 && nIndex < _doc->FontTable->Data.size() )
{
XMLTools::XMLAttribute<wchar_t>* eastAsia = new XMLTools::XMLAttribute<wchar_t>( _T( "w:eastAsia" ) );
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
......@@ -352,7 +352,7 @@ namespace DocFileFormat
case 0x4A51:
{
int nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if( nIndex>=0 && nIndex < _doc->FontTable->cData )
if( nIndex>=0 && nIndex < _doc->FontTable->Data.size() )
{
XMLTools::XMLAttribute<wchar_t>* ansi = new XMLTools::XMLAttribute<wchar_t>( _T( "w:hAnsi" ) );
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
......@@ -527,9 +527,9 @@ namespace DocFileFormat
/*========================================================================================================*/
list<CharacterPropertyExceptions*> CharacterPropertiesMapping::buildHierarchy( const StyleSheet* styleSheet, unsigned short istdStart )
std::list<CharacterPropertyExceptions*> CharacterPropertiesMapping::buildHierarchy( const StyleSheet* styleSheet, unsigned short istdStart )
{
list<CharacterPropertyExceptions*> hierarchy;
std::list<CharacterPropertyExceptions*> hierarchy;
unsigned int istd = (unsigned int)istdStart;
bool goOn = true;
......
......@@ -63,8 +63,8 @@ namespace DocFileFormat
bool _webHidden;
bool _isRTL;
private:
void convertSprms( list<SinglePropertyModifier>* sprms, XMLTools::XMLElement<wchar_t>* parent );
list<CharacterPropertyExceptions*> buildHierarchy( const StyleSheet* styleSheet, unsigned short istdStart );
void convertSprms( std::list<SinglePropertyModifier>* sprms, XMLTools::XMLElement<wchar_t>* parent );
std::list<CharacterPropertyExceptions*> buildHierarchy( const StyleSheet* styleSheet, unsigned short istdStart );
bool applyToggleHierachy( const SinglePropertyModifier& sprm );
bool toogleValue( bool currentValue, unsigned char toggle );
......@@ -82,9 +82,8 @@ namespace DocFileFormat
RevisionData* _revisionData;
bool _styleChpx;
ParagraphPropertyExceptions* _currentPapx;
list<CharacterPropertyExceptions*> _hierarchy;
ParagraphPropertyExceptions* _currentPapx;
std::list<CharacterPropertyExceptions*> _hierarchy;
bool _isRunStyleNeeded;
bool _isOwnRPr;
......
......@@ -45,7 +45,8 @@ namespace DocFileFormat
}
/// Parses the bytes to retrieve a CHPX
CharacterPropertyExceptions( unsigned char* bytes, int size ): PropertyExceptions( bytes, size )
CharacterPropertyExceptions( unsigned char* bytes, int size, bool oldVersion) :
PropertyExceptions( bytes, size, oldVersion )
{
}
};
......
......@@ -51,7 +51,7 @@ namespace DocFileFormat
}
// Adds a new RSID to the set
inline void AddRsid(const wstring& rsid)
inline void AddRsid(const std::wstring& rsid)
{
if (AllRsids.find(rsid) == AllRsids.end())
AllRsids.insert(rsid);
......@@ -71,6 +71,6 @@ namespace DocFileFormat
WordprocessingDocument* _docx;
WordDocument* _doc;
/// A set thta contains all revision ids.
set<wstring> AllRsids;
std::set<std::wstring> AllRsids;
};
}
\ No newline at end of file
......@@ -32,6 +32,21 @@
#include "Converter.h"
#include "WordDocument.h"
#include "TableMapping.h"
#include "StyleSheetMapping.h"
#include "FontTableMapping.h"
#include "FootnotesMapping.h"
#include "EndnotesMapping.h"
#include "NumberingMapping.h"
#include "CommentsMapping.h"
#include "SettingsMapping.h"
#include "MainDocumentMapping.h"
#include "WordprocessingDocument.h"
#include "ConversionContext.h"
namespace DocFileFormat
{
......@@ -51,8 +66,11 @@ namespace DocFileFormat
ConversionContext context( doc, docx );
//Write numbering.xml
NumberingMapping numberingMapping( &context );
doc->listTable->Convert( &numberingMapping );
if (doc->listTable)
{
NumberingMapping numberingMapping( &context );
doc->listTable->Convert( &numberingMapping );
}
if ( progress != NULL )
{
......@@ -85,8 +103,11 @@ namespace DocFileFormat
}
//Write styles.xml
StyleSheetMapping styleSheetMapping( &context );
doc->Styles->Convert( &styleSheetMapping );
if (doc->Styles)
{
StyleSheetMapping styleSheetMapping( &context );
doc->Styles->Convert( &styleSheetMapping );
}
if ( progress != NULL )
{
......@@ -102,8 +123,11 @@ namespace DocFileFormat
}
//Write fontTable.xml
FontTableMapping fontTableMapping( &context );
doc->FontTable->Convert( &fontTableMapping );
if (doc->FontTable)
{
FontTableMapping fontTableMapping( &context );
doc->FontTable->Convert( &fontTableMapping );
}
if ( progress != NULL )
{
......@@ -170,8 +194,11 @@ namespace DocFileFormat
}
//write settings.xml at last because of the rsid list
SettingsMapping settingsMapping( &context );
doc->DocProperties->Convert( &settingsMapping );
if (doc->DocProperties)
{
SettingsMapping settingsMapping( &context );
doc->DocProperties->Convert( &settingsMapping );
}
if ( progress != NULL )
{
......@@ -189,16 +216,14 @@ namespace DocFileFormat
return S_OK;
}
long Converter::LoadAndConvert(const CString& strSrcFile, const CString& strDstDirectory, const ProgressCallback* progress)
long Converter::LoadAndConvert(const std::wstring& strSrcFile, const std::wstring& strDstDirectory, const std::wstring& password, const ProgressCallback* progress)
{
long result = S_FALSE;
WordDocument doc(strSrcFile);
WordDocument doc(progress, m_sTempFolder);
WordprocessingDocument docx(strDstDirectory, &doc);
result = doc.LoadDocument(progress);
result = doc.LoadDocument(strSrcFile, password);
if (result == S_OK)
{
......
......@@ -31,30 +31,25 @@
*/
#pragma once
#include "WordDocument.h"
#include <string>
#include "TableMapping.h"
#include "StyleSheetMapping.h"
#include "FontTableMapping.h"
#include "FootnotesMapping.h"
#include "EndnotesMapping.h"
#include "NumberingMapping.h"
#include "CommentsMapping.h"
#include "SettingsMapping.h"
#include "MainDocumentMapping.h"
#include "WordprocessingDocument.h"
#include "ConversionContext.h"
struct ProgressCallback;
namespace DocFileFormat
{
class WordDocument;
class WordprocessingDocument;
class Converter
{
public:
Converter();
~Converter();
long LoadAndConvert(const CString& strSrcFile, const CString& strDstDirectory, const ProgressCallback* progress);
std::wstring m_sTempFolder;
long LoadAndConvert(const std::wstring & strSrcFile, const std::wstring & strDstDirectory, const std::wstring & password, const ProgressCallback* progress);
private:
long Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress);
};
......
......@@ -56,8 +56,8 @@ namespace DocFileFormat
struct Symbol
{
wstring FontName;
wstring HexValue;
std::wstring FontName;
std::wstring HexValue;
};
class DocumentMapping: public AbstractOpenXmlMapping, public IMapping
......@@ -84,33 +84,35 @@ namespace DocFileFormat
int writeParagraph( int cp );
/// Writes a Paragraph that starts at the given cpStart and
/// ends at the given cpEnd
int writeParagraph( int initialCp, int cpEnd, bool sectionEnd );
int writeParagraph( int initialCp, int cpEnd, bool sectionEnd, bool lastBad = false );
/// Writes a Paragraph RSID
void writeParagraphRsid( const ParagraphPropertyExceptions* papx );
/// Writes a run with the given characters and CHPX
int writeRun( vector<wchar_t>* chars, CharacterPropertyExceptions* chpx, int initialCp );
int writeRun( std::vector<wchar_t>* chars, CharacterPropertyExceptions* chpx, int initialCp );
/// Writes the given text to the document
void writeText( vector<wchar_t>* chars, int initialCp, CharacterPropertyExceptions* chpx, bool writeDeletedText );
void writeTextElement( const wstring& text, const wstring& textType );
void writeTextStart( const wstring& textType, bool preserve_space);
void writeTextEnd( const wstring& textType );
void writeText( std::vector<wchar_t>* chars, int initialCp, CharacterPropertyExceptions* chpx, bool writeDeletedText );
void writeTextElement( const std::wstring& text, const std::wstring& textType );
void writeTextStart( const std::wstring& textType, bool preserve_space);
void writeTextEnd( const std::wstring& textType );
/// Searches for bookmarks in the list of characters.
vector<int> searchBookmarks( vector<wchar_t>* chars, int initialCp );
std::vector<int> searchBookmarks( std::vector<wchar_t>* chars, int initialCp );
ParagraphPropertyExceptions* findValidPapx( int fc );
/// Splits a list of characters into several lists
list<vector<wchar_t> >* splitCharList( vector<wchar_t>* chars, vector<int>* splitIndices );
std::list<std::vector<wchar_t> >* splitCharList( std::vector<wchar_t>* chars, std::vector<int>* splitIndices );
/// Writes the table starts at the given cp value
int writeTable( int initialCp, unsigned int nestingLevel );
/// Builds a list that contains the width of the several columns of the table.
vector<short>* buildTableGrid( int initialCp, unsigned int nestingLevel );
std::vector<short>* buildTableGrid( int initialCp, unsigned int nestingLevel );
/// Finds the FC of the next row end mark.
int findRowEndFc( int initialCp, int& rowEndCp, unsigned int nestingLevel );
/// Finds the FC of the next row end mark.
int findRowEndFc( int initialCp, unsigned int nestingLevel );
/// Writes the table row that starts at the given cp value and ends at the next row end mark
int writeTableRow( int initialCp, vector<short>* grid, unsigned int nestingLevel );
int writeTableRow( int initialCp, std::vector<short>* grid, unsigned int nestingLevel );
/// Writes the table cell that starts at the given cp value and ends at the next cell end mark
int writeTableCell( int initialCp, TablePropertyExceptions* tapx, vector<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel );
int writeTableCell( int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel );
int findCellEndCp( int initialCp, unsigned int nestingLevel );
bool writeBookmarks( int cp );
bool writeBookmarkStart( short id );
......@@ -120,7 +122,7 @@ namespace DocFileFormat
/// Finds the SEPX that is valid for the given CP.
SectionPropertyExceptions* findValidSepx( int cp );
/// Searches the given vector for the next FieldEnd character.
int searchNextTextMark( vector<wchar_t>* chars, int initialCp, wchar_t mark );
int searchNextTextMark( std::vector<wchar_t>* chars, int initialCp, wchar_t mark );
private:
Symbol getSymbol( const CharacterPropertyExceptions* chpx );
......
......@@ -65,9 +65,9 @@ namespace DocFileFormat
/// Length of rgxchLPunct
short cchLeadingPunct;
/// Array of characters that should never appear at the start of a line
wstring rgxchFPunct;
std::wstring rgxchFPunct;
/// Array of characters that should never appear at the end of a line
wstring rgxchLPunct;
std::wstring rgxchLPunct;
public:
virtual ~DocumentTypographyInfo()
......@@ -103,11 +103,11 @@ namespace DocFileFormat
unsigned char fpunctBytes[202];
memcpy( fpunctBytes, ( bytes + 6 ), 202 );
FormatUtils::GetSTLCollectionFromBytes<wstring>( &(this->rgxchFPunct), fpunctBytes, 202, ENCODING_UNICODE );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(this->rgxchFPunct), fpunctBytes, 202, ENCODING_UTF16 );
unsigned char lpunctBytes[102];
memcpy( lpunctBytes, ( bytes + 208 ), 102 );
FormatUtils::GetSTLCollectionFromBytes<wstring>( &(this->rgxchLPunct), lpunctBytes, 102, ENCODING_UNICODE );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(this->rgxchLPunct), lpunctBytes, 102, ENCODING_UTF16 );
}
else
{
......
......@@ -101,7 +101,7 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( _T( "w:endnotes" ) );
m_context->_docx->EndnotesXML = wstring( m_pXmlWriter->GetXmlString() );
m_context->_docx->EndnotesXML = std::wstring( m_pXmlWriter->GetXmlString() );
}
}
};
......
......@@ -72,32 +72,41 @@ namespace DocFileFormat
newObject->wWeight = reader->ReadInt16();
newObject->chs = reader->ReadByte();
//skip unsigned char 5
reader->ReadByte();
//int sz_fonts = 150; //.. нужно генерить уникальное todooo
int szAlt = reader->ReadByte();
//read the 10 bytes panose
newObject->panoseSize = 10;
newObject->panose = reader->ReadBytes( newObject->panoseSize, true );
//read the 24 bytes FontSignature
newObject->fs.UnicodeSubsetBitfield0 = reader->ReadUInt32();
newObject->fs.UnicodeSubsetBitfield1 = reader->ReadUInt32();
newObject->fs.UnicodeSubsetBitfield2 = reader->ReadUInt32();
newObject->fs.UnicodeSubsetBitfield3 = reader->ReadUInt32();
newObject->fs.CodePageBitfield0 = reader->ReadUInt32();
newObject->fs.CodePageBitfield1 = reader->ReadUInt32();
//read the next \0 terminated string
long strStart = reader->GetPosition();
long strEnd = searchTerminationZero( reader );
if (!reader->olderVersion)
{
//read the 10 bytes panose
newObject->panoseSize = 10;
newObject->panose = reader->ReadBytes( newObject->panoseSize, true );
//read the 24 bytes FontSignature
newObject->fs.UnicodeSubsetBitfield0 = reader->ReadUInt32();
newObject->fs.UnicodeSubsetBitfield1 = reader->ReadUInt32();
newObject->fs.UnicodeSubsetBitfield2 = reader->ReadUInt32();
newObject->fs.UnicodeSubsetBitfield3 = reader->ReadUInt32();
newObject->fs.CodePageBitfield0 = reader->ReadUInt32();
newObject->fs.CodePageBitfield1 = reader->ReadUInt32();
}
//read the next \0 terminated string
long strStart = reader->GetPosition();
long strEnd = searchTerminationZero( reader );
int sz_fonts = 150; //.. нужно генерить уникальное todooo
unsigned char *bytes = reader->ReadBytes( (int)( strEnd - strStart ), true );
FormatUtils::GetSTLCollectionFromBytes<wstring>( &(newObject->xszFtn), bytes, (int)( strEnd - strStart ), (Encoding)ENCODING_UNICODE );
if (reader->olderVersion)
{
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(newObject->xszFtn), bytes, (int)( strEnd - strStart ), ENCODING_WINDOWS_1250 );
}
else
{
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(newObject->xszFtn), bytes, (int)( strEnd - strStart ), ENCODING_UTF16 );
}
if (newObject->xszFtn.length() >0)
if (newObject->xszFtn.length() > 0)
{
if ((int) newObject->xszFtn.at(0) < 31) //DDToneWebService.doc
{
......@@ -105,25 +114,31 @@ namespace DocFileFormat
}
}
if (newObject->xszFtn.length() < 2)//programo.doc
if (newObject->xszFtn.length() < 2 && szAlt < 1)//programo.doc
{
newObject->xszFtn = _T("font") + FormatUtils::IntToWideString(++sz_fonts);
newObject->xszFtn = _T("font");
}
RELEASEARRAYOBJECTS( bytes );
long readBytes = reader->GetPosition() - startPos;
if( readBytes < length )
if( readBytes < length && szAlt > 0)
{
//read the next \0 terminated string
strStart = reader->GetPosition();
strEnd = searchTerminationZero( reader );
//read the next \0 terminated string
strStart = reader->GetPosition();
strEnd = searchTerminationZero( reader );
bytes = reader->ReadBytes( (int)( strEnd - strStart ), true );
FormatUtils::GetSTLCollectionFromBytes<wstring>( &(newObject->xszAlt), bytes, (int)( strEnd - strStart ), ENCODING_UNICODE );
if (reader->olderVersion)
{
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(newObject->xszAlt), bytes, (int)( strEnd - strStart ), ENCODING_WINDOWS_1250);
}
else
{
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(newObject->xszAlt), bytes, (int)( strEnd - strStart ), ENCODING_UTF16 );
}
RELEASEARRAYOBJECTS( bytes );
}
......@@ -136,10 +151,20 @@ namespace DocFileFormat
{
long strStart = reader->GetPosition();
while ( reader->ReadInt16() != 0 )
{
;
}
if (reader->olderVersion)
{//ansi string only
while ( reader->ReadByte() != 0 )
{
;
}
}
else
{//unicode string
while ( reader->ReadInt16() != 0 )
{
;
}
}
long pos = reader->GetPosition();
......
......@@ -65,9 +65,9 @@ namespace DocFileFormat
/// Pitch request
unsigned char prq;
/// Name of font
wstring xszFtn;
std::wstring xszFtn;
/// Alternative name of the font
wstring xszAlt;
std::wstring xszAlt;
/// Panose
unsigned char *panose;
/// Panose size
......
......@@ -61,7 +61,7 @@ namespace DocFileFormat
int sz_fonts = table->Data.size();
for ( vector<ByteStructure*>::iterator iter = table->Data.begin(); iter != table->Data.end(); iter++ )
for ( std::vector<ByteStructure*>::iterator iter = table->Data.begin(); iter != table->Data.end(); iter++ )
{
FontFamilyName* font = dynamic_cast<FontFamilyName*>( *iter );
......@@ -70,7 +70,7 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
//alternative name
if ( ( font->xszAlt != wstring( _T( "" ) ) ) && ( font->xszAlt.length() > 0 ) )
if ( ( font->xszAlt != std::wstring( _T( "" ) ) ) && ( font->xszAlt.length() > 0 ) )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:altName" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(font->xszAlt, true).c_str() );
......@@ -93,7 +93,7 @@ namespace DocFileFormat
//panose
m_pXmlWriter->WriteNodeBegin( _T("w:panose1"), TRUE );
wstring wstr( _T( "" ) );
std::wstring wstr( _T( "" ) );
for ( unsigned int i = 0; i < font->panoseSize; i++ )
{
......@@ -135,6 +135,6 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( _T("w:fonts") );
this->_ctx->_docx->FontTableXML = wstring( m_pXmlWriter->GetXmlString() );
this->_ctx->_docx->FontTableXML = std::wstring( m_pXmlWriter->GetXmlString() );
}
}
\ No newline at end of file
......@@ -90,6 +90,6 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( _T( "w:ftr" ) );
m_context->_docx->FooterXMLList.push_back( wstring( m_pXmlWriter->GetXmlString() ) );
m_context->_docx->FooterXMLList.push_back( std::wstring( m_pXmlWriter->GetXmlString() ) );
}
}
\ No newline at end of file
......@@ -101,7 +101,7 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( _T( "w:footnotes" ) );
m_context->_docx->FootnotesXML = wstring(m_pXmlWriter->GetXmlString());
m_context->_docx->FootnotesXML = std::wstring(m_pXmlWriter->GetXmlString());
}
}
};
......
......@@ -52,8 +52,8 @@ namespace DocFileFormat
/*========================================================================================================*/
FormattedDiskPageCHPX::FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset ):
FormattedDiskPage(), rgb(NULL), grpchpxSize(NULL), grpchpx(NULL)
FormattedDiskPageCHPX::FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset, bool oldVersion ):
FormattedDiskPage(), rgb(NULL), grpchpxSize(NULL), grpchpx(NULL)
{
Type = Character;
WordStream = wordStream;
......@@ -81,9 +81,9 @@ namespace DocFileFormat
}
//create arrays
rgb = new unsigned char[crun];
grpchpxSize = crun;
grpchpx = new CharacterPropertyExceptions*[grpchpxSize];
grpchpxSize = crun;
rgb = new unsigned char[crun];
grpchpx = new CharacterPropertyExceptions*[grpchpxSize];
j = 4 * ( crun + 1 );
......@@ -108,7 +108,7 @@ namespace DocFileFormat
memcpy( chpx, ( bytes + (wordOffset * 2) + 1 ), cb );
//parse CHPX and fill grpchpx
grpchpx[i] = new CharacterPropertyExceptions( chpx, cb );
grpchpx[i] = new CharacterPropertyExceptions( chpx, cb, oldVersion);
RELEASEARRAYOBJECTS( chpx );
}
......@@ -125,30 +125,61 @@ namespace DocFileFormat
/*========================================================================================================*/
/// Parses the 0Table (or 1Table) for FKP _entries containing CHPX
list<FormattedDiskPageCHPX*>* FormattedDiskPageCHPX::GetAllCHPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream )
std::list<FormattedDiskPageCHPX*>* FormattedDiskPageCHPX::GetAllCHPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream )
{
list<FormattedDiskPageCHPX*>* CHPXlist = new list<FormattedDiskPageCHPX*>();
std::list<FormattedDiskPageCHPX*>* CHPXlist = new std::list<FormattedDiskPageCHPX*>();
//get bintable for CHPX
unsigned char* binTableChpx = new unsigned char[fib->m_FibWord97.lcbPlcfBteChpx];
tableStream->seek( fib->m_FibWord97.fcPlcfBteChpx);
tableStream->read( binTableChpx, fib->m_FibWord97.lcbPlcfBteChpx);
if (tableStream)
{
tableStream->seek( fib->m_FibWord97.fcPlcfBteChpx);
tableStream->read( binTableChpx, fib->m_FibWord97.lcbPlcfBteChpx);
}
//there are n offsets and n-1 fkp's in the bin table
int n = ( ( (int)fib->m_FibWord97.lcbPlcfBteChpx - 4 ) / 8 ) + 1;
//Get the indexed CHPX FKPs
for ( unsigned int i = (n * 4); i < fib->m_FibWord97.lcbPlcfBteChpx; i += 4 )
if (fib->m_bOlderVersion)
{
//indexed FKP is the 6th 512byte page
int fkpnr = FormatUtils::BytesToInt32( binTableChpx, i, fib->m_FibWord97.lcbPlcfBteChpx );
int n = ( ( (int)fib->m_FibWord97.lcbPlcfBteChpx - 8 ) / 6 ) + 1;
unsigned int first = FormatUtils::BytesToInt32(binTableChpx, 0, fib->m_FibWord97.lcbPlcfBteChpx );
unsigned int last = FormatUtils::BytesToInt32(binTableChpx, 4, fib->m_FibWord97.lcbPlcfBteChpx );
int start_chpx = 8;
if (fib->m_FibWord97.lcbPlcfBteChpx - 8 > (n - 1) * 4)
{
start_chpx += ((n-1) * 4); //дублирование crun
}
//Get the indexed CHPX FKPs
for ( unsigned int i = start_chpx; i < fib->m_FibWord97.lcbPlcfBteChpx; i += 2 )
{
//indexed FKP is the 6th 512byte page
int fkpnr = FormatUtils::BytesToInt16( binTableChpx, i, fib->m_FibWord97.lcbPlcfBteChpx );
//so starts at:
int offset = fkpnr * 512;
//so starts at:
int offset = fkpnr * 512;
//parse the FKP and add it to the list
CHPXlist->push_back( new FormattedDiskPageCHPX( wordStream, offset ) );
//parse the FKP and add it to the list
CHPXlist->push_back( new FormattedDiskPageCHPX( wordStream, offset, fib->m_bOlderVersion ) );
}
}
else
{
int n = ( ( (int)fib->m_FibWord97.lcbPlcfBteChpx - 4 ) / 8 ) + 1;
//Get the indexed CHPX FKPs
for ( unsigned int i = (n * 4); i < fib->m_FibWord97.lcbPlcfBteChpx; i += 4 )
{
//indexed FKP is the 6th 512byte page
int fkpnr = FormatUtils::BytesToInt32( binTableChpx, i, fib->m_FibWord97.lcbPlcfBteChpx );
//so starts at:
int offset = fkpnr * 512;
//parse the FKP and add it to the list
CHPXlist->push_back( new FormattedDiskPageCHPX( wordStream, offset, fib->m_bOlderVersion ) );
}
}
RELEASEARRAYOBJECTS( binTableChpx );
......
......@@ -50,8 +50,8 @@ namespace DocFileFormat
public:
virtual ~FormattedDiskPageCHPX();
FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset );
FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset, bool oldVersion );
/// Parses the 0Table (or 1Table) for FKP _entries containing CHPX
static list<FormattedDiskPageCHPX*>* GetAllCHPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream );
static std::list<FormattedDiskPageCHPX*>* GetAllCHPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream );
};
}
\ No newline at end of file
......@@ -52,8 +52,8 @@ namespace DocFileFormat
/*========================================================================================================*/
FormattedDiskPagePAPX::FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream ):
FormattedDiskPage(), rgbx(NULL), grppapxSize(0), grppapx(NULL)
FormattedDiskPagePAPX::FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, bool oldVersion):
FormattedDiskPage(), rgbx(NULL), grppapxSize(0), grppapx(NULL)
{
Type = Paragraph;
WordStream = wordStream;
......@@ -68,9 +68,9 @@ namespace DocFileFormat
//get the count
crun = bytes[511];
//create and fill the array with the adresses
rgfcSize = crun + 1;
rgfc = new int[rgfcSize];
//create and fill the array with the adresses
rgfcSize = crun + 1;
rgfc = new int[rgfcSize];
int j = 0;
......@@ -131,7 +131,7 @@ namespace DocFileFormat
memcpy( papx, ( bytes + (bx.wordOffset * 2) + padbyte + 1 ), ( cw * 2 ) );
//parse PAPX and fill grppapx
grppapx[i] = new ParagraphPropertyExceptions( papx, ( cw * 2 ), dataStream );
grppapx[i] = new ParagraphPropertyExceptions( papx, ( cw * 2 ), dataStream, oldVersion );
RELEASEARRAYOBJECTS( papx );
}
......@@ -150,32 +150,73 @@ namespace DocFileFormat
/*========================================================================================================*/
/// Parses the 0Table (or 1Table) for FKP _entries containing PAPX
list<FormattedDiskPagePAPX*>* FormattedDiskPagePAPX::GetAllPAPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream)
std::list<FormattedDiskPagePAPX*>* FormattedDiskPagePAPX::GetAllPAPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream)
{
list<FormattedDiskPagePAPX*>* PAPXlist = new list<FormattedDiskPagePAPX*>();
std::list<FormattedDiskPagePAPX*>* PAPXlist = new std::list<FormattedDiskPagePAPX*>();
//get bintable for PAPX
unsigned char* binTablePapx = new unsigned char[fib->m_FibWord97.lcbPlcfBtePapx];
tableStream->seek( fib->m_FibWord97.fcPlcfBtePapx);
tableStream->read( binTablePapx, fib->m_FibWord97.lcbPlcfBtePapx);
//there are n offsets and n-1 fkp's in the bin table
int n = ( ( (int)fib->m_FibWord97.lcbPlcfBtePapx - 4 ) / 8 ) + 1;
if (tableStream)
{
tableStream->seek( fib->m_FibWord97.fcPlcfBtePapx);
tableStream->read( binTablePapx, fib->m_FibWord97.lcbPlcfBtePapx);
}
//there are n offsets and n-1 fkp's in the bin table
//Get the indexed PAPX FKPs
for ( unsigned int i = ( n * 4 ); i < fib->m_FibWord97.lcbPlcfBtePapx; i += 4 )
{
//indexed FKP is the xth 512byte page
int fkpnr = FormatUtils::BytesToInt32( binTablePapx, i, fib->m_FibWord97.lcbPlcfBtePapx );
if (fib->m_FibBase.fComplex == false)
{
int n = ( ( (int)fib->m_FibWord97.lcbPlcfBtePapx - 8 ) / 6 ) + 1;
unsigned int first = FormatUtils::BytesToInt32(binTablePapx, 0, fib->m_FibWord97.lcbPlcfBtePapx );
unsigned int last = FormatUtils::BytesToInt32(binTablePapx, 4, fib->m_FibWord97.lcbPlcfBtePapx );
int start_papx = 8;
if (fib->m_FibWord97.lcbPlcfBtePapx - 8 > (n - 1) * 4)
{
start_papx+= ((n-1) * 4); //дублирование crun
}
int offset = 0;
for ( unsigned int i = start_papx; i < fib->m_FibWord97.lcbPlcfBtePapx; i += 2 )
{
//indexed FKP is the xth 512byte page
int fkpnr = FormatUtils::BytesToInt16( binTablePapx, i, fib->m_FibWord97.lcbPlcfBtePapx );
//so starts at:
int offset = fkpnr * 512;
//parse the FKP and add it to the list
PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_bOlderVersion) );
}
//if (PAPXlist->back()->rgfc[PAPXlist->back()->rgfcSize-1] < last)
//{
// PAPXlist->back()->rgfc[PAPXlist->back()->rgfcSize-1] = last;
// //tableStream->read( binTablePapx, fib->m_FibWord97.lcbPlcfBtePapx);
// //offset+=512;
// //PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream ) );
//}
}
else
{
int n = ( ( (int)fib->m_FibWord97.lcbPlcfBtePapx - 4 ) / 8 ) + 1;
//Get the indexed PAPX FKPs
for ( unsigned int i = ( n * 4 ); i < fib->m_FibWord97.lcbPlcfBtePapx; i += 4 )
{
//indexed FKP is the xth 512byte page
int fkpnr = FormatUtils::BytesToInt32( binTablePapx, i, fib->m_FibWord97.lcbPlcfBtePapx );
//so starts at:
int offset = fkpnr * 512;
//so starts at:
int offset = fkpnr * 512;
//parse the FKP and add it to the list
PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream ) );
}
//parse the FKP and add it to the list
PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_bOlderVersion) );
}
}
RELEASEARRAYOBJECTS( binTablePapx );
return PAPXlist;
......@@ -184,7 +225,7 @@ namespace DocFileFormat
/*========================================================================================================*/
/// Returns a list of all PAPX FCs between they given boundaries.
list<int>* FormattedDiskPagePAPX::GetFileCharacterPositions
std::list<int>* FormattedDiskPagePAPX::GetFileCharacterPositions
(
int fcMin,
int fcMax,
......@@ -194,12 +235,12 @@ namespace DocFileFormat
POLE::Stream* dataStream
)
{
list<int>* cpList = new list<int>();
list<FormattedDiskPagePAPX*> *fkps = FormattedDiskPagePAPX::GetAllPAPXFKPs( fib, wordStream, tableStream, dataStream );
std::list<int>* cpList = new std::list<int>();
std::list<FormattedDiskPagePAPX*> *fkps = FormattedDiskPagePAPX::GetAllPAPXFKPs( fib, wordStream, tableStream, dataStream );
unsigned int i = 0;
FormattedDiskPagePAPX* fkp = NULL;
for ( list<FormattedDiskPagePAPX*>::iterator iter = fkps->begin(); iter != fkps->end(); iter++ )
for ( std::list<FormattedDiskPagePAPX*>::iterator iter = fkps->begin(); iter != fkps->end(); iter++ )
{
fkp = (*iter);
......@@ -233,7 +274,7 @@ namespace DocFileFormat
/// Returnes a list of all ParagraphPropertyExceptions which correspond to text
/// between the given offsets.
list<ParagraphPropertyExceptions*>* FormattedDiskPagePAPX::GetParagraphPropertyExceptions
std::list<ParagraphPropertyExceptions*>* FormattedDiskPagePAPX::GetParagraphPropertyExceptions
(
int fcMin,
int fcMax,
......@@ -243,11 +284,11 @@ namespace DocFileFormat
POLE::Stream* dataStream
)
{
list<ParagraphPropertyExceptions*>* ppxList = new list<ParagraphPropertyExceptions*>();
list<FormattedDiskPagePAPX*>* fkps = FormattedDiskPagePAPX::GetAllPAPXFKPs( fib, wordStream, tableStream, dataStream );
std::list<ParagraphPropertyExceptions*>* ppxList = new std::list<ParagraphPropertyExceptions*>();
std::list<FormattedDiskPagePAPX*>* fkps = FormattedDiskPagePAPX::GetAllPAPXFKPs( fib, wordStream, tableStream, dataStream );
FormattedDiskPagePAPX *fkp = NULL;
for ( list<FormattedDiskPagePAPX*>::iterator iter = fkps->begin(); iter != fkps->end(); iter++ )
for ( std::list<FormattedDiskPagePAPX*>::iterator iter = fkps->begin(); iter != fkps->end(); iter++ )
{
fkp = (*iter);
......
......@@ -63,14 +63,14 @@ namespace DocFileFormat
public:
virtual ~FormattedDiskPagePAPX();
FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream );
FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, bool oldVersion);
/// Parses the 0Table (or 1Table) for FKP _entries containing PAPX
static list<FormattedDiskPagePAPX*>* GetAllPAPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream);
static std::list<FormattedDiskPagePAPX*>* GetAllPAPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream);
/// Returns a list of all PAPX FCs between they given boundaries.
static list<int>* GetFileCharacterPositions( int fcMin, int fcMax, FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream );
static std::list<int>* GetFileCharacterPositions( int fcMin, int fcMax, FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream );
/// Returnes a list of all ParagraphPropertyExceptions which correspond to text
/// between the given offsets.
static list<ParagraphPropertyExceptions*>* GetParagraphPropertyExceptions( int fcMin, int fcMax, FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream );
static std::list<ParagraphPropertyExceptions*>* GetParagraphPropertyExceptions( int fcMin, int fcMax, FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream );
};
}
......
......@@ -38,9 +38,11 @@ namespace DocFileFormat
{
HeaderAndFooterTable::HeaderAndFooterTable (FileInformationBlock* fib, POLE::Stream* pTableStream)
{
VirtualStreamReader tableReader (pTableStream, fib->m_FibWord97.fcPlcfHdd);
VirtualStreamReader tableReader (pTableStream, fib->m_FibWord97.fcPlcfHdd, fib->m_bOlderVersion);
unsigned int tableSize = fib->m_FibWord97.lcbPlcfHdd / 4;
if (fib->m_FibWord97.fcPlcfHdd > tableReader.GetSize()) return;
unsigned int tableSize = fib->m_FibWord97.lcbPlcfHdd / (fib->m_bOlderVersion ? 1: 4);
if ( ( tableSize > 0 ) && ( fib->m_RgLw97.ccpHdr > 0 ) )
{
......@@ -121,6 +123,9 @@ namespace DocFileFormat
pos++;
if (pos > tableSize)
break;
//First Page Footers
if ( table[pos] == table[pos + 1] )
{
......
......@@ -90,6 +90,6 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( _T( "w:hdr" ) );
m_context->_docx->HeaderXMLList.push_back( wstring( m_pXmlWriter->GetXmlString() ) );
m_context->_docx->HeaderXMLList.push_back( std::wstring( m_pXmlWriter->GetXmlString() ) );
}
}
\ No newline at end of file
......@@ -57,7 +57,7 @@ namespace DocFileFormat
{
if ( dynamic_cast<LanguageId*>( lid )->Code != Nothing )
{
wstring langcode = getLanguageCode( dynamic_cast<LanguageId*>( lid ) );
std::wstring langcode = getLanguageCode( dynamic_cast<LanguageId*>( lid ) );
XMLTools::XMLAttribute<wchar_t>* att = NULL;
......@@ -102,7 +102,7 @@ namespace DocFileFormat
}
}
wstring LanguageIdMapping::getLanguageCode( LanguageId* lid )
std::wstring LanguageIdMapping::getLanguageCode( LanguageId* lid )
{
int intLCID = lid->Code;
std::wstring strLCID = msLCID2wstring(intLCID);
......
......@@ -53,7 +53,7 @@ namespace DocFileFormat
virtual ~LanguageIdMapping();
void Apply( IVisitable* lid );
static wstring getLanguageCode( LanguageId* lid );
static std::wstring getLanguageCode( LanguageId* lid );
private:
LanguageType _type;
......
......@@ -41,7 +41,7 @@ namespace DocFileFormat
class ListTable: public IVisitable
{
public:
list<ListData*> listData;
std::list<ListData*> listData;
virtual ~ListTable();
ListTable( FileInformationBlock* fib, POLE::Stream* tableStream );
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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