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;
}
int i = 0;
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));
if ( encoding == ENCODING_UNICODE )
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;
}
}
template<class T> static bool GetSTLCollectionFromBytes( T *STLCollection, unsigned char *bytes, int size, int code_page )
{
if ( ( STLCollection == NULL ) || ( bytes == NULL ) )
{
return false;
}
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;
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
if (doc->listTable)
{
NumberingMapping numberingMapping( &context );
doc->listTable->Convert( &numberingMapping );
}
if ( progress != NULL )
{
......@@ -85,8 +103,11 @@ namespace DocFileFormat
}
//Write styles.xml
if (doc->Styles)
{
StyleSheetMapping styleSheetMapping( &context );
doc->Styles->Convert( &styleSheetMapping );
}
if ( progress != NULL )
{
......@@ -102,8 +123,11 @@ namespace DocFileFormat
}
//Write fontTable.xml
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
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,9 +72,12 @@ 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();
if (!reader->olderVersion)
{
//read the 10 bytes panose
newObject->panoseSize = 10;
newObject->panose = reader->ReadBytes( newObject->panoseSize, true );
......@@ -86,18 +89,24 @@ namespace DocFileFormat
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,16 +114,16 @@ 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();
......@@ -122,8 +131,14 @@ namespace DocFileFormat
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();
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,7 +52,7 @@ namespace DocFileFormat
/*========================================================================================================*/
FormattedDiskPageCHPX::FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset ):
FormattedDiskPageCHPX::FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset, bool oldVersion ):
FormattedDiskPage(), rgb(NULL), grpchpxSize(NULL), grpchpx(NULL)
{
Type = Character;
......@@ -81,8 +81,8 @@ namespace DocFileFormat
}
//create arrays
rgb = new unsigned char[crun];
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,19 +125,49 @@ 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];
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;
if (fib->m_bOlderVersion)
{
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;
//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 )
{
......@@ -148,7 +178,8 @@ namespace DocFileFormat
int offset = fkpnr * 512;
//parse the FKP and add it to the list
CHPXlist->push_back( new FormattedDiskPageCHPX( wordStream, offset ) );
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,7 +52,7 @@ namespace DocFileFormat
/*========================================================================================================*/
FormattedDiskPagePAPX::FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream ):
FormattedDiskPagePAPX::FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, bool oldVersion):
FormattedDiskPage(), rgbx(NULL), grppapxSize(0), grppapx(NULL)
{
Type = Paragraph;
......@@ -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,19 +150,58 @@ 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];
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
int n = ( ( (int)fib->m_FibWord97.lcbPlcfBtePapx - 4 ) / 8 ) + 1;
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 )
{
......@@ -173,7 +212,9 @@ namespace DocFileFormat
int offset = fkpnr * 512;
//parse the FKP and add it to the list
PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream ) );
PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_bOlderVersion) );
}
}
RELEASEARRAYOBJECTS( binTablePapx );
......@@ -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;
......
......@@ -64,11 +64,11 @@ namespace DocFileFormat
if ( this->fSimpleList )
{
this->rglvl = new vector<ListLevel*>( 1 );
this->rglvl = new std::vector<ListLevel*>( 1 );
}
else
{
this->rglvl = new vector<ListLevel*>( 9 );
this->rglvl = new std::vector<ListLevel*>( 9 );
}
this->fRestartHdn = FormatUtils::BitmaskToBool( flag, 0x02 );
......
......@@ -47,7 +47,7 @@ namespace DocFileFormat
int tplc;
/// Array of shorts containing the istd‘s linked to each level of the list,
/// or ISTD_NIL (4095) if no style is linked.
vector<short> rgistd;
std::vector<short> rgistd;
/// True if this is a simple (one-level) list.
/// False if this is a multilevel (nine-level) list.
bool fSimpleList;
......@@ -62,7 +62,7 @@ namespace DocFileFormat
/// When true, list is a hybrid multilevel/simple (UI=simple, internal=multilevel)
bool fHybrid;
/// Array of ListLevel describing the several levels of the list.
vector<ListLevel*>* rglvl;
std::vector<ListLevel*>* rglvl;
/// A grfhic that specifies HTML incompatibilities of the list.
unsigned char grfhic;
unsigned char* _rawBytes;
......
......@@ -58,7 +58,7 @@ namespace DocFileFormat
/// A grfhic that specifies HTML incompatibilities.
unsigned char grfhic;
/// Array of all levels whose format is overridden
vector<ListFormatOverrideLevel*> rgLfoLvl;
std::vector<ListFormatOverrideLevel*> rgLfoLvl;
public:
/// Parses the given Stream Reader to retrieve a ListFormatOverride
......@@ -76,7 +76,7 @@ namespace DocFileFormat
if ( this->clfolvl != 0 )
{
this->rgLfoLvl = vector<ListFormatOverrideLevel*>( this->clfolvl );
this->rgLfoLvl = std::vector<ListFormatOverrideLevel*>( this->clfolvl );
}
reader->Seek( startPos, 0/*STREAM_SEEK_SET*/ );
......@@ -85,7 +85,7 @@ namespace DocFileFormat
virtual ~ListFormatOverride()
{
for ( vector<ListFormatOverrideLevel*>::iterator iter = this->rgLfoLvl.begin(); iter != this->rgLfoLvl.end(); iter++ )
for ( std::vector<ListFormatOverrideLevel*>::iterator iter = this->rgLfoLvl.begin(); iter != this->rgLfoLvl.end(); iter++ )
{
RELEASEOBJECT( *iter );
}
......
......@@ -37,19 +37,21 @@
namespace DocFileFormat
{
class ListFormatOverrideTable: public vector<ListFormatOverride*>
class ListFormatOverrideTable: public std::vector<ListFormatOverride*>
{
private:
static const int LFO_LENGTH = 16;
static const int LFOLVL_LENGTH = 6;
vector<unsigned int> cps;
std::vector<unsigned int> cps;
public:
ListFormatOverrideTable( FileInformationBlock* fib, POLE::Stream* tableStream )
{
if ( fib->m_FibWord97.lcbPlfLfo > 0 )
{
VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLfo );
VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLfo, fib->m_bOlderVersion);
if (fib->m_FibWord97.fcPlfLfo > reader.GetSize()) return;
//read the count of LFOs
int count = reader.ReadInt32();
......
......@@ -82,14 +82,16 @@ namespace DocFileFormat
//read the group of papx sprms
//this papx has no istd, so use PX to parse it
unsigned char *bytes = reader->ReadBytes( this->cbGrpprlPapx, true );
PropertyExceptions* px = new PropertyExceptions( bytes, this->cbGrpprlPapx );
PropertyExceptions* px = new PropertyExceptions( bytes, this->cbGrpprlPapx, reader->olderVersion);
this->grpprlPapx = new ParagraphPropertyExceptions( *(px->grpprl) );
RELEASEOBJECT( px );
RELEASEARRAYOBJECTS( bytes );
//read the group of chpx sprms
bytes = reader->ReadBytes( this->cbGrpprlChpx, true );
this->grpprlChpx = new CharacterPropertyExceptions( bytes, this->cbGrpprlChpx );
this->grpprlChpx = new CharacterPropertyExceptions( bytes, this->cbGrpprlChpx, reader->olderVersion );
RELEASEARRAYOBJECTS( bytes );
//read the number text
......@@ -97,7 +99,7 @@ namespace DocFileFormat
if (strLen > 0)//file(14).doc
{
bytes = reader->ReadBytes( ( strLen * 2 ), true );
FormatUtils::GetSTLCollectionFromBytes<wstring>( &(this->xst), bytes, ( strLen * 2 ), ENCODING_UNICODE );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(this->xst), bytes, ( strLen * 2 ), ENCODING_UTF16 );
RELEASEARRAYOBJECTS( bytes );
}
......
......@@ -80,7 +80,7 @@ namespace DocFileFormat
/// The XST contains place holders for any paragraph numbers contained in the text of the number,
/// and the place holder contains the ilvl of the inherited number,
/// so lvl.xst[lvl.rgbxchNums[0]] == the level of the first inherited number in this level.
vector<unsigned char> rgbxchNums;
std::vector<unsigned char> rgbxchNums;
/// The type of character following the number text for the paragraph.
FollowingChar ixchFollow;
/// Word 6.0 compatibility option: equivalent to anld.dxaSpace (see ANLD).
......@@ -99,7 +99,7 @@ namespace DocFileFormat
unsigned char grfhic;
ParagraphPropertyExceptions* grpprlPapx;
CharacterPropertyExceptions* grpprlChpx;
wstring xst;
std::wstring xst;
unsigned char* _rawBytes;
......
......@@ -45,7 +45,9 @@ namespace DocFileFormat
{
if ( fib->m_FibWord97.lcbPlfLst > 0 )
{
VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLst );
VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLst, fib->m_bOlderVersion);
if (fib->m_FibWord97.fcPlfLst > reader.GetSize()) return;
//the ListTable is not a real plex:
//it starts with a count, followed by the array of LSTF structs,
......@@ -61,7 +63,7 @@ namespace DocFileFormat
}
//read the LVLF structs
for ( list<ListData*>::iterator iter = listData.begin(); iter != listData.end(); iter++ )
for ( std::list<ListData*>::iterator iter = listData.begin(); iter != listData.end(); iter++ )
{
for ( unsigned int j = 0; j < (*iter)->rglvl->size(); j++ )
{
......
......@@ -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 );
......
......@@ -80,7 +80,11 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeBegin( _T("w:body"), FALSE );
// Convert the document
_lastValidPapx = NULL;
if (m_document->AllPapxFkps->empty() == false)
{
_lastValidPapx = (*(m_document->AllPapxFkps->begin()))->grppapx[0];
}
int cp = 0;
int fc = 0;
......@@ -96,6 +100,7 @@ namespace DocFileFormat
while (cp < countText)
{
fc = m_document->FindFileCharPos(cp);
if (fc < 0) break;
papx = findValidPapx(fc);
......@@ -120,40 +125,15 @@ namespace DocFileFormat
else
{
//There are no paragraphs, only text
//start paragraph
m_pXmlWriter->WriteNodeBegin( _T( "w:p" ) );
//start run
m_pXmlWriter->WriteNodeBegin( _T( "w:r" ) );
int fc = m_document->FindFileCharPos(0);
int fc = m_document->FindFileCharPos(cp);
int fcEnd = m_document->FindFileCharPos(countTextRel);
if (fc < 0 || fcEnd < 0) break;
// Read the chars
vector<wchar_t>* chpxChars = m_document->m_PieceTable->GetEncodingChars (fc, fcEnd, m_document->WordDocumentStream); //<! NEED OPTIMIZE
wstring text (chpxChars->begin(), chpxChars->end());
//open a new w:t element
m_pXmlWriter->WriteNodeBegin( _T( "w:t" ), TRUE );
//if (text.find(_T("\x20")) != text.npos)
{
m_pXmlWriter->WriteAttribute( _T( "xml:space" ), _T( "preserve" ) );
}
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
// Write text
m_pXmlWriter->WriteString(text.c_str());
RELEASEOBJECT(chpxChars);
//if (fc < 0 || fcEnd < 0) break;
//
//// Read the chars
//std::vector<wchar_t>* chars = m_document->GetChars (fc, fcEnd, fc);
//close previous w:t ...
m_pXmlWriter->WriteNodeEnd( _T( "w:t" ) );
//close previous w:r ...
m_pXmlWriter->WriteNodeEnd( _T( "w:r" ) );
//close previous w:p ...
m_pXmlWriter->WriteNodeEnd( _T( "w:p" ) );
writeParagraph(cp, countTextRel, false, true );
cp = m_document->FIB->m_RgLw97.ccpText;
}
......@@ -182,7 +162,7 @@ namespace DocFileFormat
{
int lastSepxCp = 0;
for (map<int, SectionPropertyExceptions*>::iterator iter = m_document->AllSepx->begin(); iter != m_document->AllSepx->end(); ++iter)
for (std::map<int, SectionPropertyExceptions*>::iterator iter = m_document->AllSepx->begin(); iter != m_document->AllSepx->end(); ++iter)
lastSepxCp = iter->first;
SectionPropertyExceptions* lastSepx = m_document->AllSepx->operator []( lastSepxCp );
......@@ -198,6 +178,6 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( _T( "w:body" ) );
m_pXmlWriter->WriteNodeEnd( _T( "w:document" ) );
m_context->_docx->DocumentXML = wstring(m_pXmlWriter->GetXmlString());
m_context->_docx->DocumentXML = std::wstring(m_pXmlWriter->GetXmlString());
}
}
\ No newline at end of file
......@@ -79,7 +79,7 @@ namespace DocFileFormat
int i = 0;
for (list<ListData*>::iterator iter = rglst->listData.begin(); iter != rglst->listData.end(); ++iter, ++i)
for (std::list<ListData*>::iterator iter = rglst->listData.begin(); iter != rglst->listData.end(); ++iter, ++i)
{
//start abstractNum
m_pXmlWriter->WriteNodeBegin( _T( "w:abstractNum" ), TRUE );
......@@ -143,7 +143,7 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString( index ).c_str() );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
for (vector<ListFormatOverrideLevel*>::const_iterator iter = lfo->rgLfoLvl.begin(); iter != lfo->rgLfoLvl.end(); ++iter)
for (std::vector<ListFormatOverrideLevel*>::const_iterator iter = lfo->rgLfoLvl.begin(); iter != lfo->rgLfoLvl.end(); ++iter)
{
m_pXmlWriter->WriteNodeBegin( _T( "w:lvlOverride" ), TRUE );
......@@ -171,12 +171,12 @@ namespace DocFileFormat
}
}
int NumberingMapping::FindIndexbyId(const list<ListData*>& listData, int id)
int NumberingMapping::FindIndexbyId(const std::list<ListData*>& listData, int id)
{
int ret = -1;
int i = 0;
for (list<ListData*>::const_iterator iter = listData.begin(); iter != listData.end(); ++iter, ++i)
for (std::list<ListData*>::const_iterator iter = listData.begin(); iter != listData.end(); ++iter, ++i)
{
if ((*iter)->lsid == id)
{
......@@ -224,7 +224,7 @@ namespace DocFileFormat
std::wstring::const_iterator newResult = lvl->xst.begin();
newResult = find_if(lvl->xst.begin(), lvl->xst.end(), &NumberingMapping::IsPlaceholder);
ret = wstring(lvl->xst.begin(), newResult);
ret = std::wstring(lvl->xst.begin(), newResult);
result = newResult;
while (result != lvl->xst.end())
......@@ -233,7 +233,7 @@ namespace DocFileFormat
ret += _T( "%" );
ret += FormatUtils::IntToWideString(*result + 1);
ret += wstring((result + 1), newResult);
ret += std::wstring((result + 1), newResult);
result = newResult;
}
}
......@@ -469,18 +469,18 @@ namespace DocFileFormat
void NumberingMapping::PictureBulletsMapping()
{
for (map<int, int>::const_iterator iter = m_document->PictureBulletsCPsMap.begin(); iter != m_document->PictureBulletsCPsMap.end(); ++iter)
for (std::map<int, int>::const_iterator iter = m_document->PictureBulletsCPsMap.begin(); iter != m_document->PictureBulletsCPsMap.end(); ++iter)
{
int fc = m_document->FindFileCharPos(iter->second);
int fcEnd = m_document->FindFileCharPos(iter->second + 1);
if (fc < 0 || fcEnd < 0 ) break;
list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fc, fcEnd);
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fc, fcEnd);
if ((chpxs != NULL) && (!chpxs->empty()))
{
PictureDescriptor pict(chpxs->front(), m_document->DataStream, fcEnd - fc);
PictureDescriptor pict(chpxs->front(), m_document->DataStream, fcEnd - fc, m_document->FIB->m_bOlderVersion);
if ((pict.mfp.mm > 98) && (pict.shapeContainer != NULL))
{
......@@ -516,7 +516,7 @@ namespace DocFileFormat
unsigned int cp = 0;
bool isPictureBullet = false;
for (list<SinglePropertyModifier>::const_iterator iter = grpprlChpx->grpprl->begin(); iter != grpprlChpx->grpprl->end(); ++iter)
for (std::list<SinglePropertyModifier>::const_iterator iter = grpprlChpx->grpprl->begin(); iter != grpprlChpx->grpprl->end(); ++iter)
{
if ((int)(iter->OpCode) == sprmCPbiIBullet)
{
......
......@@ -62,9 +62,9 @@ namespace DocFileFormat
public:
NumberingMapping(ConversionContext* ctx);
void Apply(IVisitable* visited);
static int FindIndexbyId(const list<ListData*>& listData, int id);
static int FindIndexbyId(const std::list<ListData*>& listData, int id);
/// Converts the number format code of the binary format.
static wstring GetNumberFormatWideString(int nfc);
static std::wstring GetNumberFormatWideString(int nfc);
virtual ~NumberingMapping();
private:
......
......@@ -59,7 +59,10 @@ namespace DocFileFormat
OfficeArtContent (const FileInformationBlock* pFIB, POLE::Stream* pStream): m_pDrawingGroupData(NULL)
{
VirtualStreamReader oStearmReader(pStream);
VirtualStreamReader oStearmReader(pStream, 0 , pFIB->m_bOlderVersion);
if (pFIB->m_FibWord97.fcDggInfo > oStearmReader.GetSize()) return;
oStearmReader.Seek (pFIB->m_FibWord97.fcDggInfo, 0/*STREAM_SEEK_SET*/);
if (pFIB->m_FibWord97.lcbDggInfo > 0)
......@@ -106,7 +109,7 @@ namespace DocFileFormat
{
RELEASEOBJECT (m_pDrawingGroupData);
for ( list<OfficeArtWordDrawing>::iterator iter = m_arrDrawings.begin(); iter != m_arrDrawings.end(); ++iter)
for ( std::list<OfficeArtWordDrawing>::iterator iter = m_arrDrawings.begin(); iter != m_arrDrawings.end(); ++iter)
RELEASEOBJECT(iter->container);
}
......@@ -114,7 +117,7 @@ namespace DocFileFormat
{
ShapeContainer* ret = NULL;
for (list<OfficeArtWordDrawing>::iterator iter = m_arrDrawings.begin(); iter != m_arrDrawings.end(); ++iter)
for (std::list<OfficeArtWordDrawing>::iterator iter = m_arrDrawings.begin(); iter != m_arrDrawings.end(); ++iter)
{
GroupContainer* group = iter->container->FirstChildWithType<GroupContainer>();
if (group)
......@@ -173,6 +176,6 @@ namespace DocFileFormat
private:
DrawingGroup* m_pDrawingGroupData;
list<OfficeArtWordDrawing> m_arrDrawings;
std::list<OfficeArtWordDrawing> m_arrDrawings;
};
}
......@@ -60,7 +60,7 @@ namespace DocFileFormat
_size.cx = Right - Left;
_size.cy = Bottom - Top;
rcgBounds = ASCDocFormatUtils::Rectangle (_point, _size);
rcgBounds = DocFormatUtils::Rectangle (_point, _size);
}
virtual ~ChildAnchor()
......@@ -75,7 +75,7 @@ namespace DocFileFormat
public:
/// Rectangle that describes the bounds of the anchor
ASCDocFormatUtils::Rectangle rcgBounds;
DocFormatUtils::Rectangle rcgBounds;
int Left;
int Top;
int Right;
......
......@@ -56,7 +56,7 @@ namespace DocFileFormat
unsigned int ShapesSavedCount; // Total number of shapes saved
unsigned int DrawingsSavedCount; // Total number of drawings saved
list<FileIdCluster> Clusters;
std::list<FileIdCluster> Clusters;
DrawingGroupRecord () : Record(), MaxShapeId(0), IdClustersCount(0), ShapesSavedCount(0), DrawingsSavedCount(0)
{
......
......@@ -64,7 +64,7 @@ namespace DocFileFormat
oSize.cx = ( right - left );
oSize.cy = ( bottom - top );
rcgBounds = ASCDocFormatUtils::Rectangle(oPoint,oSize);
rcgBounds = DocFormatUtils::Rectangle(oPoint,oSize);
}
virtual ~GroupShapeRecord()
......@@ -77,6 +77,6 @@ namespace DocFileFormat
return new GroupShapeRecord( _reader, bodySize, typeCode, version, instance );
}
ASCDocFormatUtils::Rectangle rcgBounds;
DocFormatUtils::Rectangle rcgBounds;
};
}
......@@ -161,7 +161,7 @@ namespace DocFileFormat
int cc = 0;
std::vector<PathSegment>::const_iterator end = m_arSegments.end();
for (vector<PathSegment>::const_iterator iter = m_arSegments.begin(); iter != end; ++iter, cc++)
for (std::vector<PathSegment>::const_iterator iter = m_arSegments.begin(); iter != end; ++iter, cc++)
{
try
{
......
......@@ -46,7 +46,7 @@ namespace DocFileFormat
virtual ~RegularContainer()
{
for (vector<Record*>::iterator iter = Children.begin(); iter != Children.end(); ++iter)
for (std::vector<Record*>::iterator iter = Children.begin(); iter != Children.end(); ++iter)
{
RELEASEOBJECT (*iter);
}
......@@ -84,7 +84,7 @@ namespace DocFileFormat
{
T* firstChildWithType = NULL;
for ( vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
{
if ( (*iter != NULL) && (typeid(T) == typeid(**iter)) )
{
......@@ -99,6 +99,6 @@ namespace DocFileFormat
public:
vector<Record*> Children;
std::vector<Record*> Children;
};
}
\ No newline at end of file
......@@ -58,7 +58,7 @@ namespace DocFileFormat
{
int ret = 0;
for ( vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
{
Shape* sh = dynamic_cast<Shape*>( *iter );
if (sh)
......@@ -80,18 +80,18 @@ namespace DocFileFormat
}
/// Searches all OptionEntry in the ShapeContainer and puts them into a list.
list<OptionEntry> ExtractOptions() const
std::list<OptionEntry> ExtractOptions() const
{
list<OptionEntry> ret;
std::list<OptionEntry> ret;
//build the list of all option entries of this shape
for ( vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
{
ShapeOptions* opt = dynamic_cast<ShapeOptions*>( *iter );
if ( opt != NULL )
{
for ( vector<OptionEntry>::iterator oeIter = opt->Options.begin(); oeIter != opt->Options.end(); oeIter++ )
for ( std::vector<OptionEntry>::iterator oeIter = opt->Options.begin(); oeIter != opt->Options.end(); oeIter++ )
{
ret.push_back( *oeIter );
}
......
......@@ -587,8 +587,8 @@ namespace DocFileFormat
static const unsigned short TYPE_CODE_0xF121 = 0xF121;
static const unsigned short TYPE_CODE_0xF122 = 0xF122;
vector<OptionEntry> Options;
map<PropertyId, OptionEntry> OptionsByID;
std::vector<OptionEntry> Options;
std::map<PropertyId, OptionEntry> OptionsByID;
ShapeOptions() : Record()
{
......@@ -596,7 +596,7 @@ namespace DocFileFormat
virtual ~ShapeOptions()
{
for (vector<OptionEntry>::iterator iter = Options.begin(); iter != Options.end(); ++iter)
for (std::vector<OptionEntry>::iterator iter = Options.begin(); iter != Options.end(); ++iter)
RELEASEARRAYOBJECTS( iter->opComplex );
}
......@@ -639,7 +639,7 @@ namespace DocFileFormat
Options[i].opComplex = Reader->ReadBytes( read_size, true );
}
OptionsByID.insert(pair<PropertyId, OptionEntry>(Options[i].pid, Options[i]));
OptionsByID.insert(std::pair<PropertyId, OptionEntry>(Options[i].pid, Options[i]));
}
Reader->Seek(( pos + size ), 0/*STREAM_SEEK_SET*/);
......
......@@ -51,18 +51,18 @@ namespace DocFileFormat
OnCall = 3
};
wstring ObjectId;
wstring ClassId;
std::wstring ObjectId;
std::wstring ClassId;
// CLSID ClassId;
/// The the value is true, the object is a linked object
bool fLinked;
/// Display name of the linked object or embedded object.
wstring UserType;
wstring ClipboardFormat;
wstring Link;
wstring Program;
std::wstring UserType;
std::wstring ClipboardFormat;
std::wstring Link;
std::wstring Program;
LinkUpdateOption updateMode;
wstring UpdateMode;
std::wstring UpdateMode;
bool isEquation;
bool isEmbedded;
......@@ -117,7 +117,7 @@ namespace DocFileFormat
}
private:
void processLinkInfoStream( const string& linkStream )
void processLinkInfoStream( const std::string& linkStream )
{
try
{
......@@ -129,7 +129,7 @@ namespace DocFileFormat
if ( pLinkStream )
{
VirtualStreamReader reader( pLinkStream );
VirtualStreamReader reader( pLinkStream, 0, false);
//there are two versions of the Link string, one contains ANSI characters, the other contains
//unicode characters.
......@@ -139,7 +139,7 @@ namespace DocFileFormat
//Read the ANSI version
short cch = reader.ReadInt16();
unsigned char* str = reader.ReadBytes( cch, true );
FormatUtils::GetSTLCollectionFromBytes<wstring>( &this->Link, str, cch, ENCODING_WINDOWS_1251 );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &this->Link, str, cch, ENCODING_WINDOWS_1250 );
RELEASEARRAYOBJECTS( str );
//skip the terminating zero of the ANSI string
......@@ -154,7 +154,7 @@ namespace DocFileFormat
cch = reader.ReadInt16();
str = reader.ReadBytes( ( cch * 2 ), true );
FormatUtils::GetSTLCollectionFromBytes<wstring>( &this->Link, str, ( cch * 2 ), ENCODING_UNICODE );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &this->Link, str, ( cch * 2 ), ENCODING_UTF16 );
RELEASEARRAYOBJECTS( str );
//skip the terminating zero of the Unicode string
......@@ -168,7 +168,7 @@ namespace DocFileFormat
}
}
void processEquationNativeStream( const string& eqStream )
void processEquationNativeStream( const std::string& eqStream )
{
try
{
......@@ -179,7 +179,7 @@ namespace DocFileFormat
if ( pCompStream )
{
VirtualStreamReader reader( pCompStream );
VirtualStreamReader reader( pCompStream, 0, false);
int sz = reader.GetSize();
......@@ -198,7 +198,7 @@ namespace DocFileFormat
}
}
void processCompObjStream( const string& compStream )
void processCompObjStream( const std::string& compStream )
{
try
{
......@@ -209,7 +209,7 @@ namespace DocFileFormat
if ( pCompStream )
{
VirtualStreamReader reader( pCompStream );
VirtualStreamReader reader( pCompStream, 0, false);
//skip the CompObjHeader
reader.ReadBytes( 28, false );
......@@ -237,7 +237,7 @@ namespace DocFileFormat
}
}
void processOleStream( const string& oleStreamName )
void processOleStream( const std::string& oleStreamName )
{
try
{
......@@ -248,7 +248,7 @@ namespace DocFileFormat
if ( pOleStream )
{
VirtualStreamReader reader( pOleStream );
VirtualStreamReader reader( pOleStream, 0, false );
//skip version
reader.ReadBytes( 4, false );
......@@ -288,9 +288,9 @@ namespace DocFileFormat
}
}
wstring getOleEntryName( const CharacterPropertyExceptions* chpx )
std::wstring getOleEntryName( const CharacterPropertyExceptions* chpx )
{
wstring ret;
std::wstring ret;
if ( chpx != NULL )
{
......
......@@ -31,7 +31,10 @@
*/
#pragma once
#include "ConversionContext.h"
#include "PictureDescriptor.h"
#include "OleObject.h"
#include "AbstractOpenXmlMapping.h"
#include "IMapping.h"
......@@ -40,8 +43,9 @@ namespace DocFileFormat
class OleObjectMapping: public AbstractOpenXmlMapping, public IMapping
{
public:
OleObjectMapping(XmlUtils::CXmlWriter* writer, ConversionContext* context, PictureDescriptor* pict, IMapping* caller, const wstring& shapeId)
: AbstractOpenXmlMapping(writer), m_context(NULL), _pict(NULL), _caller(NULL), _shapeId(shapeId)
OleObjectMapping(XmlUtils::CXmlWriter* writer, ConversionContext* context, PictureDescriptor* pict, IMapping* caller, const std::wstring& shapeId)
:
AbstractOpenXmlMapping(writer), m_context(NULL), _pict(NULL), _caller(NULL), _shapeId(shapeId)
{
m_context = context;
_pict = pict;
......@@ -70,7 +74,7 @@ namespace DocFileFormat
m_context->_docx->RegisterExternalOLEObject(_caller, ole->ClipboardFormat, ole->Link);
m_pXmlWriter->WriteAttribute( _T( "r:id" ), ( wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "r:id" ), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "Type" ), _T( "Link" ) );
m_pXmlWriter->WriteAttribute( _T( "UpdateMode" ), ole->UpdateMode.c_str() );
}
......@@ -83,7 +87,7 @@ namespace DocFileFormat
else
relID = m_context->_docx->RegisterOLEObject(_caller, ole->ClipboardFormat);
m_pXmlWriter->WriteAttribute( _T( "r:id" ), ( wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "r:id" ), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "Type" ), _T( "Embed" ) );
//copy the object
......@@ -108,9 +112,9 @@ namespace DocFileFormat
}
}
static wstring GetTargetExt(const wstring& objectType)
static std::wstring GetTargetExt(const std::wstring& objectType)
{
wstring objectExt = _T( ".bin" );
std::wstring objectExt = _T( ".bin" );
if ( objectType == _T( "Biff8" ) )
{
......@@ -135,9 +139,9 @@ namespace DocFileFormat
return objectExt;
}
static wstring GetContentType(const wstring& objectType)
static std::wstring GetContentType(const std::wstring& objectType)
{
wstring objectContentType = OpenXmlContentTypes::OleObject;
std::wstring objectContentType = OpenXmlContentTypes::OleObject;
if ( objectType == _T( "Biff8" ) )
{
......@@ -172,10 +176,10 @@ namespace DocFileFormat
//!!!TODO: There is issue with some Office OLE Objects. Word can't open *.xls object (Excel.Chart) with set CLSID and
//some Power Point Presentations, and Word Documents. Open Office CAN start this objects!!!
wstring clsid;
wstring exelChart = _T( "Excel.Chart" );
std::wstring clsid;
std::wstring exelChart = _T( "Excel.Chart" );
if ( search( ole->Program.begin(), ole->Program.end(), exelChart.begin(), exelChart.end() ) == ole->Program.end() )
if ( std::search( ole->Program.begin(), ole->Program.end(), exelChart.begin(), exelChart.end() ) == ole->Program.end() )
{//??
clsid = ole->ClassId;
}
......
......@@ -32,17 +32,16 @@
#include "OpenXmlPackage.h"
//#include "HeaderMapping.h"
//#include "FooterMapping.h"
//#include "MainDocumentMapping.h"
#include "Converter.h"
#include "OleObjectMapping.h"
#include "VMLPictureMapping.h"
#include "../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#include "../../DesktopEditor/common/File.h"
#include "../Common/XmlTools.h"
namespace DocFileFormat
......@@ -82,12 +81,12 @@ namespace DocFileFormat
this->WriteRelsFile( this->NumberingRelationshipsFile );
for ( list<RelationshipsFile>::const_iterator iter = this->HeaderRelationshipsFiles.begin(); iter != this->HeaderRelationshipsFiles.end(); iter++ )
for ( std::list<RelationshipsFile>::const_iterator iter = this->HeaderRelationshipsFiles.begin(); iter != this->HeaderRelationshipsFiles.end(); iter++ )
{
this->WriteRelsFile( *iter );
}
for ( list<RelationshipsFile>::const_iterator iter = this->FooterRelationshipsFiles.begin(); iter != this->FooterRelationshipsFiles.end(); iter++ )
for ( std::list<RelationshipsFile>::const_iterator iter = this->FooterRelationshipsFiles.begin(); iter != this->FooterRelationshipsFiles.end(); iter++ )
{
this->WriteRelsFile( *iter );
}
......@@ -317,7 +316,7 @@ namespace DocFileFormat
writer.WriteNodeEnd( _T( "" ), TRUE, FALSE );
for ( list<Relationship>::const_iterator iter = relationshipsFile.Relationships.begin(); iter != relationshipsFile.Relationships.end(); iter++ )
for ( std::list<Relationship>::const_iterator iter = relationshipsFile.Relationships.begin(); iter != relationshipsFile.Relationships.end(); iter++ )
{
writer.WriteNodeBegin( _T( "Relationship" ), TRUE );
writer.WriteAttribute( _T( "Id" ), iter->Id.c_str() );
......@@ -353,7 +352,7 @@ namespace DocFileFormat
writer.WriteNodeEnd( _T( "" ), TRUE, FALSE );
for ( map<wstring, std::wstring>::iterator iter = this->DocumentContentTypesFile._defaultTypes.begin(); iter != this->DocumentContentTypesFile._defaultTypes.end(); iter++ )
for ( std::map<std::wstring, std::wstring>::iterator iter = this->DocumentContentTypesFile._defaultTypes.begin(); iter != this->DocumentContentTypesFile._defaultTypes.end(); iter++ )
{
writer.WriteNodeBegin( _T( "Default" ), TRUE );
writer.WriteAttribute( _T( "Extension" ), iter->first.c_str() );
......@@ -361,7 +360,7 @@ namespace DocFileFormat
writer.WriteNodeEnd( _T( "" ), TRUE );
}
for ( map<wstring, std::wstring>::iterator iter = this->DocumentContentTypesFile._partOverrides.begin(); iter != this->DocumentContentTypesFile._partOverrides.end(); iter++ )
for ( std::map<std::wstring, std::wstring>::iterator iter = this->DocumentContentTypesFile._partOverrides.begin(); iter != this->DocumentContentTypesFile._partOverrides.end(); iter++ )
{
writer.WriteNodeBegin( _T( "Override" ), TRUE );
writer.WriteAttribute( _T( "PartName" ), iter->first.c_str() );
......@@ -380,8 +379,8 @@ namespace DocFileFormat
{
std::wstring fileName = ( std::wstring( _T( "media/image" ) ) + FormatUtils::IntToWideString( ++_imageCounter ) + VMLPictureMapping::GetTargetExt( blipType ) );
DocumentContentTypesFile._defaultTypes.insert( make_pair( VMLPictureMapping::GetTargetExt( blipType ).erase( 0, 1 ), VMLPictureMapping::GetContentType( blipType ) ) );
DocumentContentTypesFile._defaultTypes.insert( make_pair( std::wstring( _T( "vml" ) ), std::wstring( OpenXmlContentTypes::Vml ) ) );
DocumentContentTypesFile._defaultTypes.insert( std::make_pair( VMLPictureMapping::GetTargetExt( blipType ).erase( 0, 1 ), VMLPictureMapping::GetContentType( blipType ) ) );
DocumentContentTypesFile._defaultTypes.insert( std::make_pair( std::wstring( _T( "vml" ) ), std::wstring( OpenXmlContentTypes::Vml ) ) );
return AddPart( mapping, _T( "word" ), fileName, VMLPictureMapping::GetContentType( blipType ), OpenXmlRelationshipTypes::Image );
}
......@@ -390,7 +389,7 @@ namespace DocFileFormat
{
std::wstring fileName = ( std::wstring( _T( "embeddings/oleObject" ) ) + FormatUtils::IntToWideString( ++_oleCounter ) + OleObjectMapping::GetTargetExt(objectType));
DocumentContentTypesFile._defaultTypes.insert( make_pair( OleObjectMapping::GetTargetExt( objectType ).erase( 0, 1 ), OleObjectMapping::GetContentType(objectType)));
DocumentContentTypesFile._defaultTypes.insert( std::make_pair( OleObjectMapping::GetTargetExt( objectType ).erase( 0, 1 ), OleObjectMapping::GetContentType(objectType)));
return AddPart( mapping, _T( "word" ), fileName, OleObjectMapping::GetContentType( objectType ), OpenXmlRelationshipTypes::OleObject );
}
......@@ -398,7 +397,7 @@ namespace DocFileFormat
{
std::wstring fileName = ( std::wstring( _T( "embeddings/oleObject" ) ) + FormatUtils::IntToWideString( ++_oleCounter ) + OleObjectMapping::GetTargetExt(objectType));
DocumentContentTypesFile._defaultTypes.insert( make_pair( OleObjectMapping::GetTargetExt( objectType ).erase( 0, 1 ), OleObjectMapping::GetContentType(objectType)));
DocumentContentTypesFile._defaultTypes.insert( std::make_pair( OleObjectMapping::GetTargetExt( objectType ).erase( 0, 1 ), OleObjectMapping::GetContentType(objectType)));
return AddPart( mapping, _T( "word" ), fileName, OleObjectMapping::GetContentType( objectType ), OpenXmlRelationshipTypes::Package);
}
......@@ -407,7 +406,7 @@ namespace DocFileFormat
std::wstring fullUri = std::wstring(_T("file:///")) + uri;
std::wstring fileName = ReplaceString(fullUri, _T(" "), _T("%20"));
DocumentContentTypesFile._defaultTypes.insert(make_pair(OleObjectMapping::GetTargetExt(objectType).erase(0, 1), OleObjectMapping::GetContentType(objectType)));
DocumentContentTypesFile._defaultTypes.insert(std::make_pair(OleObjectMapping::GetTargetExt(objectType).erase(0, 1), OleObjectMapping::GetContentType(objectType)));
return AddPart(mapping, _T(""), fileName, OleObjectMapping::GetContentType(objectType), OpenXmlRelationshipTypes::OleObject, _T("External"));
}
......
......@@ -42,16 +42,16 @@ namespace DocFileFormat
{
struct Relationship
{
wstring Id;
wstring Type;
wstring Target;
wstring TargetMode;
std::wstring Id;
std::wstring Type;
std::wstring Target;
std::wstring TargetMode;
Relationship()
{
}
Relationship( const wstring& id, const wstring& type, const wstring& target, const wstring& targetMode = _T( "" ) ):
Relationship( const std::wstring& id, const std::wstring& type, const std::wstring& target, const std::wstring& targetMode = _T( "" ) ):
Id( id ), Type( type ), Target( target ), TargetMode( targetMode )
{
}
......@@ -59,8 +59,8 @@ namespace DocFileFormat
struct RelationshipsFile
{
wstring FileName;
list<Relationship> Relationships;
std::wstring FileName;
std::list<Relationship> Relationships;
int RelID;
RelationshipsFile():
......@@ -68,12 +68,12 @@ namespace DocFileFormat
{
}
RelationshipsFile( const wstring& fileName ):
RelationshipsFile( const std::wstring& fileName ):
RelID(0), FileName( fileName )
{
}
RelationshipsFile( int relID, const wstring& fileName, const list<Relationship>& relationships ):
RelationshipsFile( int relID, const std::wstring& fileName, const std::list<Relationship>& relationships ):
RelID(relID), FileName( fileName ), Relationships( relationships )
{
}
......@@ -81,8 +81,8 @@ namespace DocFileFormat
struct ContentTypesFile
{
map<wstring, wstring> _defaultTypes;
map<wstring, wstring> _partOverrides;
std::map<std::wstring, std::wstring> _defaultTypes;
std::map<std::wstring, std::wstring> _partOverrides;
};
struct ImageFileStructure
......@@ -92,7 +92,7 @@ namespace DocFileFormat
}
ImageFileStructure(const wstring& _ext, const vector<unsigned char>& _data, Global::BlipType _blipType = Global::msoblipUNKNOWN) : ext(_ext), data(_data), blipType(_blipType)
ImageFileStructure(const std::wstring& _ext, const std::vector<unsigned char>& _data, Global::BlipType _blipType = Global::msoblipUNKNOWN) : ext(_ext), data(_data), blipType(_blipType)
{
}
......@@ -113,7 +113,7 @@ namespace DocFileFormat
OleObjectFileStructure(){}
OleObjectFileStructure( const wstring& _ext, const wstring& _objectID, const wstring&/*REFCLSID*/ _clsid ):
OleObjectFileStructure( const std::wstring& _ext, const std::wstring& _objectID, const std::wstring&/*REFCLSID*/ _clsid ):
ext(_ext), objectID(_objectID), clsid(_clsid){}
};
......@@ -128,8 +128,9 @@ namespace DocFileFormat
RelationshipsFile EndnotesRelationshipsFile;
RelationshipsFile CommentsRelationshipsFile;
RelationshipsFile NumberingRelationshipsFile;
list<RelationshipsFile> HeaderRelationshipsFiles;
list<RelationshipsFile> FooterRelationshipsFiles;
std::list<RelationshipsFile> HeaderRelationshipsFiles;
std::list<RelationshipsFile> FooterRelationshipsFiles;
int relID;
......@@ -140,18 +141,18 @@ namespace DocFileFormat
const WordDocument* docFile;
int AddHeaderPart( const wstring& fileName, const wstring& relationshipType = _T( "" ), const wstring& targetMode = _T( "" ) );
int AddFooterPart( const wstring& fileName, const wstring& relationshipType = _T( "" ), const wstring& targetMode = _T( "" ) );
int AddFootnotesPart( const wstring& fileName, const wstring& relationshipType = _T( "" ), const wstring& targetMode = _T( "" ) );
int AddEndnotesPart( const wstring& fileName, const wstring& relationshipType = _T( "" ), const wstring& targetMode = _T( "" ) );
int AddCommentsPart( const wstring& fileName, const wstring& relationshipType = _T( "" ), const wstring& targetMode = _T( "" ) );
int AddNumberingPart( const wstring& fileName, const wstring& relationshipType = _T( "" ), const wstring& targetMode = _T( "" ) );
int AddHeaderPart( const std::wstring& fileName, const std::wstring& relationshipType = _T( "" ), const std::wstring& targetMode = _T( "" ) );
int AddFooterPart( const std::wstring& fileName, const std::wstring& relationshipType = _T( "" ), const std::wstring& targetMode = _T( "" ) );
int AddFootnotesPart( const std::wstring& fileName, const std::wstring& relationshipType = _T( "" ), const std::wstring& targetMode = _T( "" ) );
int AddEndnotesPart( const std::wstring& fileName, const std::wstring& relationshipType = _T( "" ), const std::wstring& targetMode = _T( "" ) );
int AddCommentsPart( const std::wstring& fileName, const std::wstring& relationshipType = _T( "" ), const std::wstring& targetMode = _T( "" ) );
int AddNumberingPart( const std::wstring& fileName, const std::wstring& relationshipType = _T( "" ), const std::wstring& targetMode = _T( "" ) );
void WriteRelsFile( const RelationshipsFile& relationshipsFile );
void WriteContentTypesFile( const ContentTypesFile& contentTypesFile );
int AddPart( const wstring& packageDir, const wstring& fileName, const wstring& contentType = _T( "" ), const wstring& relationshipType = _T( "" ), const wstring& targetMode = _T( "" ) );
int AddPart( const IMapping* mapping, const wstring& packageDir, const wstring& fileName, const wstring& contentType = _T( "" ), const wstring& relationshipType = _T( "" ), const wstring& targetMode = _T( "" ) );
int AddPart( const std::wstring& packageDir, const std::wstring& fileName, const std::wstring& contentType = _T( "" ), const std::wstring& relationshipType = _T( "" ), const std::wstring& targetMode = _T( "" ) );
int AddPart( const IMapping* mapping, const std::wstring& packageDir, const std::wstring& fileName, const std::wstring& contentType = _T( "" ), const std::wstring& relationshipType = _T( "" ), const std::wstring& targetMode = _T( "" ) );
protected:
......@@ -160,10 +161,10 @@ namespace DocFileFormat
OpenXmlPackage( const WordDocument* _docFile );
void WritePackage();
void SaveToFile( const wstring& outputDir, const wstring& fileName, const wstring& XMLContent );
void SaveToFile( const wstring& outputDir, const wstring& fileName, const void* buf, unsigned int size );
void SaveToFile( const std::wstring& outputDir, const std::wstring& fileName, const std::wstring& XMLContent );
void SaveToFile( const std::wstring& outputDir, const std::wstring& fileName, const void* buf, unsigned int size );
HRESULT SaveOLEObject ( const wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure );
HRESULT SaveOLEObject ( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure );
HRESULT SaveEmbeddedObject ( const std::wstring& fileName, const std::string& data );
int RegisterDocument();
......@@ -176,9 +177,9 @@ namespace DocFileFormat
int RegisterFootnotes();
int RegisterEndnotes();
int RegisterComments();
int RegisterImage( const IMapping* mapping, Global::BlipType blipType );
int RegisterOLEObject( const IMapping* mapping, const wstring& objectType );
int RegisterPackage(const IMapping* mapping, const std::wstring& objectType);
int RegisterExternalOLEObject( const IMapping* mapping, const wstring& objectType, const wstring& uri );
int RegisterImage ( const IMapping* mapping, Global::BlipType blipType );
int RegisterOLEObject ( const IMapping* mapping, const std::wstring& objectType );
int RegisterPackage ( const IMapping* mapping, const std::wstring& objectType);
int RegisterExternalOLEObject( const IMapping* mapping, const std::wstring& objectType, const std::wstring& uri );
};
}
......@@ -230,15 +230,15 @@ namespace DocFileFormat
case sprmPDxaLeft180:
{
short flValue = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
wstring flName;
std::wstring flName;
if ( flValue >= 0 )
{
flName = wstring( _T( "w:firstLine" ) );
flName = std::wstring( _T( "w:firstLine" ) );
}
else
{
flName = wstring( _T( "w:hanging" ) );
flName = std::wstring( _T( "w:hanging" ) );
flValue *= -1;
}
......
......@@ -34,8 +34,8 @@
namespace DocFileFormat
{
ParagraphPropertyExceptions::ParagraphPropertyExceptions( unsigned char* bytes, int size, POLE::Stream* dataStream ):
PropertyExceptions( ( bytes + 2 ), ( size - 2 ) )
ParagraphPropertyExceptions::ParagraphPropertyExceptions( unsigned char* bytes, int size, POLE::Stream* dataStream, bool oldVersion):
PropertyExceptions( ( bytes + 2 ), ( size - 2 ), oldVersion)
{
if ( size != 0 )
{
......@@ -46,14 +46,14 @@ namespace DocFileFormat
//There is a SPRM that points to an offset in the data stream,
//where a list of SPRM is saved.
for ( list<SinglePropertyModifier>::iterator iter = this->grpprl->begin(); iter != this->grpprl->end(); iter++ )
for ( std::list<SinglePropertyModifier>::iterator iter = this->grpprl->begin(); iter != this->grpprl->end(); iter++ )
{
SinglePropertyModifier sprm( *iter );
if( ( sprm.OpCode == sprmPHugePapx ) || ( (int)sprm.OpCode == 0x6646 ) )
{
unsigned int fc = FormatUtils::BytesToUInt32( sprm.Arguments, 0, sprm.argumentsSize );
reader = new VirtualStreamReader( dataStream, (int)fc );
reader = new VirtualStreamReader( dataStream, (int)fc, oldVersion);
//parse the size of the external grpprl
unsigned char* sizebytes = reader->ReadBytes( 2, true );
......@@ -65,11 +65,11 @@ namespace DocFileFormat
//parse the external grpprl
unsigned char* grpprlBytes = reader->ReadBytes( grpprlsize, true );
PropertyExceptions externalPx( grpprlBytes, grpprlsize );
PropertyExceptions externalPx( grpprlBytes, grpprlsize, oldVersion );
//assign the external grpprl
RELEASEOBJECT( this->grpprl );
this->grpprl = new list<SinglePropertyModifier>( *(externalPx.grpprl) );
this->grpprl = new std::list<SinglePropertyModifier>( *(externalPx.grpprl) );
//remove the sprmPHugePapx
this->grpprl->remove( sprm );
......
......@@ -45,12 +45,11 @@ namespace DocFileFormat
/// Creates a PAPX wich doesn't modify anything.
/// The grpprl list is empty
ParagraphPropertyExceptions():
PropertyExceptions(), istd(0)
ParagraphPropertyExceptions() : PropertyExceptions(), istd(0)
{
}
ParagraphPropertyExceptions( const list<SinglePropertyModifier>& grpprl ):
ParagraphPropertyExceptions( const std::list<SinglePropertyModifier>& grpprl ):
PropertyExceptions( grpprl ), istd(0)
{
}
......@@ -60,6 +59,6 @@ namespace DocFileFormat
}
/// Parses the bytes to retrieve a PAPX
ParagraphPropertyExceptions( unsigned char* bytes, int size, POLE::Stream* dataStream );
ParagraphPropertyExceptions( unsigned char* bytes, int size, POLE::Stream* dataStream, bool oldVersion);
};
}
......@@ -35,7 +35,8 @@
namespace DocFileFormat
{
/// Parses the CHPX for a fcPic an loads the PictureDescriptor at this offset
PictureDescriptor::PictureDescriptor(CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size) :
PictureDescriptor::PictureDescriptor(CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size, bool oldVersion)
:
dxaGoal(0), dyaGoal(0), mx(0), my(0), Type(jpg), Name( _T( "" ) ), mfp(), dxaCropLeft(0), dyaCropTop(0),
dxaCropRight(0), dyaCropBottom(0), brcTop(NULL), brcLeft(NULL), brcBottom(NULL), brcRight(NULL), dxaOrigin(0), dyaOrigin(0),
cProps(0), shapeContainer(NULL), blipStoreEntry(NULL)
......@@ -46,7 +47,7 @@ namespace DocFileFormat
if ( fc >= 0 )
{
parse( stream, fc, size );
parse( stream, fc, size, oldVersion);
}
}
......@@ -64,11 +65,11 @@ namespace DocFileFormat
RELEASEOBJECT(shapeContainer);
RELEASEOBJECT(blipStoreEntry);
}
void PictureDescriptor::parse(POLE::Stream* stream, int fc, int sz)
void PictureDescriptor::parse(POLE::Stream* stream, int fc, int sz, bool oldVersion)
{
Clear();
VirtualStreamReader reader(stream, fc);
VirtualStreamReader reader(stream, fc, oldVersion);
int sz_stream = reader.GetSize();
......@@ -99,7 +100,7 @@ namespace DocFileFormat
if (mfp.mm > 98)
{
unsigned char* bytes = reader.ReadBytes(14, true);
rcWinMf = vector<unsigned char>(bytes, (bytes + 14));
rcWinMf = std::vector<unsigned char>(bytes, (bytes + 14));
RELEASEARRAYOBJECTS(bytes);
//dimensions
......@@ -148,7 +149,7 @@ namespace DocFileFormat
if ( stPicName != NULL )
{
std::wstring picName;
FormatUtils::GetSTLCollectionFromBytes<wstring>( &picName, stPicName, cchPicName, ENCODING_WINDOWS_1251 );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &picName, stPicName, cchPicName, ENCODING_WINDOWS_1250 );
RELEASEARRAYOBJECTS(stPicName);
}
}
......@@ -181,7 +182,7 @@ namespace DocFileFormat
{
int ret = -1;
for ( list<SinglePropertyModifier>::const_iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); iter++ )
for ( std::list<SinglePropertyModifier>::const_iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); iter++ )
{
switch ( iter->OpCode )
{
......
......@@ -81,25 +81,22 @@ namespace DocFileFormat
public:
/// Parses the CHPX for a fcPic an loads the PictureDescriptor at this offset
PictureDescriptor( CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size = 0x7fffffff);
PictureDescriptor( CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size, bool oldVersion);
virtual ~PictureDescriptor();
private:
void parse( POLE::Stream* stream, int fc, int sz );
void parse( POLE::Stream* stream, int fc, int sz, bool oldVersion);
/// Returns the fcPic into the "data" stream, where the PIC begins.
/// Returns -1 if the CHPX has no fcPic.
static int GetFcPic( const CharacterPropertyExceptions* chpx );
private:
void Clear();
static const short MM_SHAPE = 0x0064; // Shape object
static const short MM_SHAPEFILE = 0x0066; // Shape file
/// Rectangle for window origin and extents when metafile is stored (ignored if 0).
vector<unsigned char> rcWinMf;
std::vector<unsigned char> rcWinMf;
/// Horizontal measurement in twips of the rectangle the picture should be imaged within.
short dxaGoal;
/// Vertical measurement in twips of the rectangle the picture should be imaged within.
......@@ -111,7 +108,7 @@ namespace DocFileFormat
/// The type of the picture
PictureType Type;
/// The name of the picture
wstring Name;
std::wstring Name;
/// The data of the windows metafile picture (WMF)
MetafilePicture mfp;
/// The amount the picture has been cropped on the left in twips
......
......@@ -41,7 +41,7 @@ namespace DocFileFormat
friend class PieceTable;
public:
/// Parses the bytes to retrieve a PieceDescriptor
PieceDescriptor(unsigned char *bytes, unsigned int size) : fc(0), encoding(ENCODING_INVALID_VALUE), cpStart(0), cpEnd(0)
PieceDescriptor(unsigned char *bytes, unsigned int size, int code_page_) : fc(0), code_page(code_page_), cpStart(0), cpEnd(0)
{
if (8 == size)
{
......@@ -57,20 +57,15 @@ namespace DocFileFormat
//find encoding and offset
if (flag)
{
this->encoding = ENCODING_WINDOWS_1251;
code_page = ENCODING_WINDOWS_1250;
this->fc = (unsigned int)( fcValue / 2 );
}
else
{
this->encoding = ENCODING_UNICODE;
code_page = ENCODING_UTF16;
this->fc = fcValue;
}
}
else
{
//!!!TODO!!!
//throw new ByteParseException("Cannot parse the struct PCD, the length of the struct doesn't match");
}
}
public:
......@@ -78,7 +73,7 @@ namespace DocFileFormat
/// This is relative to the beginning of the WordDocument stream.
unsigned int fc;
/// The encoding of the piece
ASCDocFormatUtils::Encoding encoding;
int code_page;
int cpStart;
int cpEnd;
};
......
......@@ -34,17 +34,22 @@
namespace DocFileFormat
{
PieceTable::PieceTable (FileInformationBlock *fib, POLE::Stream *tableStream)
PieceTable::PieceTable (FileInformationBlock *fib, POLE::Stream *tableStream, POLE::Stream* wordStream)
{
if (fib->m_FibWord97.lcbClx < 1/* || !fib->m_FibBase.fComplex*/) return;
// Read the bytes of complex file information
unsigned char* clx = new unsigned char[fib->m_FibWord97.lcbClx];
if (tableStream)
{
tableStream->seek(fib->m_FibWord97.fcClx);
tableStream->read(clx, (int)fib->m_FibWord97.lcbClx);
}
Pieces = list<PieceDescriptor>();
FileCharacterPositions = new map<int, int>();
CharacterPositions = new map<int, int>();
Pieces = std::list<PieceDescriptor>();
FileCharacterPositions = new std::map<int, int>();
CharacterPositions = new std::map<int, int>();
int pos = 0;
bool goon = true;
......@@ -87,7 +92,7 @@ namespace DocFileFormat
memcpy(pcdBytes, (piecetable + indexPcd), 8);
PieceDescriptor pcd(pcdBytes, 8);
PieceDescriptor pcd(pcdBytes, 8, fib->m_CodePage);
pcd.cpStart = cp;
pcd.cpEnd = cpNext;
......@@ -99,7 +104,7 @@ namespace DocFileFormat
int f = (int)pcd.fc;
int multi = 1;
if ( pcd.encoding == ENCODING_UNICODE )
if ( pcd.code_page == ENCODING_UTF16 )
{
multi = 2;
}
......@@ -144,7 +149,6 @@ namespace DocFileFormat
}
RELEASEARRAYOBJECTS(clx);
m_carriageIter = Pieces.begin();
}
......@@ -161,14 +165,14 @@ namespace DocFileFormat
{
std::vector<wchar_t> *piecePairs = new std::vector<wchar_t>();
for ( list<PieceDescriptor>::iterator iter = this->Pieces.begin(); iter != this->Pieces.end(); ++iter)
for ( std::list<PieceDescriptor>::iterator iter = this->Pieces.begin(); iter != this->Pieces.end(); ++iter)
{
//get the FC end of this piece
PieceDescriptor pcd = *iter;
int pcdFcEnd = pcd.cpEnd - pcd.cpStart;
if (pcd.encoding == ENCODING_UNICODE)
if (pcd.code_page == ENCODING_UTF16)
{
pcdFcEnd *= 2;
}
......@@ -184,7 +188,7 @@ namespace DocFileFormat
stream->seek(pcd.fc);
stream->read(bytes, cb);
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t> >(piecePairs, bytes, cb, pcd.encoding);
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t> >(piecePairs, bytes, cb, pcd.code_page);
RELEASEARRAYOBJECTS(bytes);
}
......@@ -196,14 +200,14 @@ namespace DocFileFormat
{
std::vector<wchar_t> *encodingChars = new std::vector<wchar_t>();
for (list<PieceDescriptor>::iterator iter = Pieces.begin(); iter != Pieces.end(); ++iter)
for (std::list<PieceDescriptor>::iterator iter = Pieces.begin(); iter != Pieces.end(); ++iter)
{
PieceDescriptor pcd = *iter;
//get the FC end of this piece
int pcdFcEnd = pcd.cpEnd - pcd.cpStart;
if ( pcd.encoding == ENCODING_UNICODE )
if ( pcd.code_page == ENCODING_UTF16 )
{
pcdFcEnd *= 2;
}
......@@ -230,7 +234,7 @@ namespace DocFileFormat
wordStream->read( bytes, cb);
//get the chars
FormatUtils::GetSTLCollectionFromBytes<vector<wchar_t>>( encodingChars, bytes, cb, pcd.encoding );
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t>>( encodingChars, bytes, cb, pcd.code_page );
RELEASEARRAYOBJECTS( bytes );
}
......@@ -249,7 +253,7 @@ namespace DocFileFormat
wordStream->read( bytes, cb);
//get the chars
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t>>( encodingChars, bytes, cb, pcd.encoding );
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t>>( encodingChars, bytes, cb, pcd.code_page );
RELEASEARRAYOBJECTS( bytes );
}
......@@ -268,7 +272,7 @@ namespace DocFileFormat
wordStream->read( bytes, cb);
//get the chars
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t>>(encodingChars, bytes, cb, pcd.encoding);
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t>>(encodingChars, bytes, cb, pcd.code_page);
RELEASEARRAYOBJECTS(bytes);
......@@ -291,7 +295,7 @@ namespace DocFileFormat
wordStream->read( bytes, cb );
//get the chars
FormatUtils::GetSTLCollectionFromBytes<vector<wchar_t>>( encodingChars, bytes, cb, pcd.encoding );
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t>>( encodingChars, bytes, cb, pcd.code_page );
RELEASEARRAYOBJECTS( bytes );
......@@ -318,21 +322,11 @@ namespace DocFileFormat
{
std::vector<wchar_t>* encodingChars = new std::vector<wchar_t>();
//if (fcStart >= fcEnd)
// return encodingChars;
#ifdef _DEBUG
//if (fcStart == 3296 && fcEnd == 3326)
//{
// int ccc = 0;
//}
#endif
int fcSize = fcEnd - fcStart;
bool read = true;
for (list<PieceDescriptor>::iterator iter = Pieces.begin(); iter != Pieces.end(); ++iter)
for (std::list<PieceDescriptor>::iterator iter = Pieces.begin(); iter != Pieces.end(); ++iter)
{
PieceDescriptor pcd = (*iter);
......@@ -341,7 +335,7 @@ namespace DocFileFormat
int pcdFcEnd = pcd.cpEnd - pcd.cpStart;
if (pcd.encoding == ENCODING_UNICODE)
if (pcd.code_page == ENCODING_UTF16)
{
pcdFcEnd *= 2;
}
......@@ -362,7 +356,7 @@ namespace DocFileFormat
if (cb < 0)
break;
if (!ReadSymbolsBuffer((int)fcStart, cb, pcd.encoding, word, encodingChars))
if (!ReadSymbolsBuffer((int)fcStart, cb, pcd.code_page, word, encodingChars))
break;
fcSize -= cb;
......@@ -382,7 +376,7 @@ namespace DocFileFormat
if (cb < 0)
break;
if (!ReadSymbolsBuffer((int)pcd.fc, cb, pcd.encoding, word, encodingChars))
if (!ReadSymbolsBuffer((int)pcd.fc, cb, pcd.code_page, word, encodingChars))
break;
fcSize -= cb;
......@@ -402,7 +396,7 @@ namespace DocFileFormat
if (cb <= 0)
break;
if (!ReadSymbolsBuffer((int)pcd.fc, cb, pcd.encoding, word, encodingChars))
if (!ReadSymbolsBuffer((int)pcd.fc, cb, pcd.code_page, word, encodingChars))
break;
if (read)
......@@ -423,7 +417,7 @@ namespace DocFileFormat
if (cb <= 0)
break;
if (!ReadSymbolsBuffer((int)fcStart, cb, pcd.encoding, word, encodingChars))
if (!ReadSymbolsBuffer((int)fcStart, cb, pcd.code_page, word, encodingChars))
break;
if (read)
......@@ -436,11 +430,6 @@ namespace DocFileFormat
}
else if (fcEnd < (int)pcd.fc) // this piece is beyond the requested range
{
#ifdef _DEBUG
//ATLTRACE(_T("PieceTable::GetChars() - fcEnd < (int)pcd.fc\n"));
#endif
// имеет место быть перескок по стриму, поэтому корректируем начальную позицию
//size_t count = encodingChars->size();
......@@ -461,11 +450,11 @@ namespace DocFileFormat
// int length = pcdFcEnd - pcd.fc;
// if (length > fcSize)
// {
// ReadSymbolsBuffer((int)pcd.fc, fcSize, pcd.encoding, word, encodingChars);
// ReadSymbolsBuffer((int)pcd.fc, fcSize, pcd.code_page, word, encodingChars);
// break;
// }
// ReadSymbolsBuffer((int)pcd.fc, length, pcd.encoding, word, encodingChars);
// ReadSymbolsBuffer((int)pcd.fc, length, pcd.code_page, word, encodingChars);
// fcSize -= length;
// continue;
......@@ -478,7 +467,7 @@ namespace DocFileFormat
return encodingChars;
}
inline bool PieceTable::ReadSymbolsBuffer(int pos, int size, Encoding encoding, POLE::Stream* word, std::vector<wchar_t>* encodingChars)
inline bool PieceTable::ReadSymbolsBuffer(int pos, int size, int coding, POLE::Stream* word, std::vector<wchar_t>* encodingChars)
{
unsigned char* bytes = new unsigned char[size];
if (NULL == bytes)
......@@ -488,7 +477,7 @@ namespace DocFileFormat
word->read(bytes, size);
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t>>(encodingChars, bytes, size, encoding);
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t>>(encodingChars, bytes, size, coding);
RELEASEARRAYOBJECTS(bytes);
......
......@@ -52,13 +52,14 @@ namespace DocFileFormat
public:
~PieceTable();
// Parses the pice table and creates a list of PieceDescriptors.
PieceTable(FileInformationBlock* fib, POLE::Stream* tableStream);
PieceTable(FileInformationBlock* fib, POLE::Stream* tableStream, POLE::Stream* wordStream);
std::vector<wchar_t>* GetAllEncodingText(POLE::Stream* wordStream);
std::vector<wchar_t>* GetEncodingChars(int fcStart, int fcEnd, POLE::Stream* wordStream);
std::vector<wchar_t>* GetChars (int fcStart, int fcEnd, int cp, POLE::Stream* word);
private:
bool ReadSymbolsBuffer(int pos, int size, ASCDocFormatUtils::Encoding encoding, POLE::Stream* word, std::vector<wchar_t>* encodingChars);
bool ReadSymbolsBuffer(int pos, int size, int coding, POLE::Stream* word, std::vector<wchar_t>* encodingChars);
public:
......
......@@ -44,16 +44,19 @@ namespace DocFileFormat
protected:
static const int CP_LENGTH = 4;
vector<int> CharacterPositions;
vector<ByteStructure*> Elements;
std::vector<int> CharacterPositions;
std::vector<ByteStructure*> Elements;
bool m_bIsValid;
public:
Plex(int structureLength, POLE::Stream* stream, unsigned int fc, unsigned int lcb) : m_bIsValid(false)
Plex(int structureLength, POLE::Stream* stream, unsigned int fc, unsigned int lcb, bool oldVersion)
: m_bIsValid(false)
{
if ((lcb > 0) && (NULL != stream))
{
VirtualStreamReader reader(stream, (ULONG)fc);
VirtualStreamReader reader(stream, (ULONG)fc, oldVersion);
if (fc > reader.GetSize()) return;
m_bIsValid = true;
......@@ -92,7 +95,7 @@ namespace DocFileFormat
~Plex()
{
for (vector<ByteStructure*>::iterator iter = Elements.begin(); iter != Elements.end(); ++iter)
for (std::vector<ByteStructure*>::iterator iter = Elements.begin(); iter != Elements.end(); ++iter)
{
RELEASEOBJECT(*iter);
}
......
......@@ -65,16 +65,16 @@ namespace DocFileFormat
void appendValueElement( XMLTools::XMLElement<wchar_t>* node, const wchar_t* elementName, unsigned char elementValue, bool unique );
void appendBorderAttributes( BorderCode* brc, XMLTools::XMLElement<wchar_t>* border );
void appendShading( XMLTools::XMLElement<wchar_t>* parent, const ShadingDescriptor& desc );
wstring getBorderType( unsigned char type );
wstring getShadingPattern( const ShadingDescriptor& shd );
std::wstring getBorderType( unsigned char type );
std::wstring getShadingPattern( const ShadingDescriptor& shd );
void appendDxaElement( XMLTools::XMLElement<wchar_t>* node, const wchar_t* elementName, const wchar_t* elementValue, bool unique );
void addOrSetBorder( XMLTools::XMLElement<wchar_t>* pBdr, const XMLTools::XMLElement<wchar_t>* border );
protected:
XmlUtils::CXmlWriter* m_pXmlWriter;
static map<unsigned char, wstring> brcTypeMap;
static std::map<unsigned char, std::wstring> brcTypeMap;
static ASCOfficeCriticalSection brcTypeMapLock;
};
}
......@@ -50,19 +50,19 @@ namespace DocFileFormat
/*========================================================================================================*/
PropertyExceptions::PropertyExceptions( const list<SinglePropertyModifier>& grpprl )
PropertyExceptions::PropertyExceptions( const std::list<SinglePropertyModifier>& grpprl )
{
this->grpprl = new list<SinglePropertyModifier>( grpprl );
this->grpprl = new std::list<SinglePropertyModifier>( grpprl );
}
/*========================================================================================================*/
PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size ): grpprl(NULL)
{
PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool oldVersion ): grpprl(NULL)
{
this->grpprl = new std::list<SinglePropertyModifier>();
if ( ( bytes != NULL ) && ( size != 0 ) )
{
if ( ( bytes == NULL ) || ( size == 0 ) ) return;
//read the sprms
int sprmStart = 0;
......@@ -154,5 +154,4 @@ namespace DocFileFormat
}
}
}
}
}
\ No newline at end of file
......@@ -48,6 +48,6 @@ namespace DocFileFormat
virtual ~PropertyExceptions();
PropertyExceptions();
PropertyExceptions( const std::list<SinglePropertyModifier>& grpprl );
PropertyExceptions( unsigned char* bytes, int size );
PropertyExceptions( unsigned char* bytes, int size, bool oldVersion );
};
}
......@@ -60,8 +60,8 @@ namespace DocFileFormat
unsigned char Alpha;
public:
wstring SixDigitHexCode;
wstring EightDigitHexCode;
std::wstring SixDigitHexCode;
std::wstring EightDigitHexCode;
RGBColor( int cv, ByteOrder order )
{
......
......@@ -51,7 +51,7 @@ namespace DocFileFormat
_ctx = pContext;
m_nSelectProperties = nSelectProperties;
_type = wstring (_T("nextPage"));
_type = std::wstring (_T("nextPage"));
}
// Creates a new SectionPropertiesMapping which appends the properties to a given node.
......@@ -70,7 +70,7 @@ namespace DocFileFormat
_ctx = pContext;
m_nSelectProperties = nSelectProperties;
_type = wstring (_T("nextPage"));
_type = std::wstring (_T("nextPage"));
}
SectionPropertiesMapping::~SectionPropertiesMapping()
......@@ -118,11 +118,11 @@ namespace DocFileFormat
WriteSectionStory (pTable->GetFirstFooters (m_nSelectProperties), std::wstring(L"footerReference"), std::wstring(L"first"));
}
//MUST be ignored if the section does not have page number restart enabled.([MS-DOC] Ч v20101113. стр 152)
//MUST be ignored if the section does not have page number restart enabled.([MS-DOC] v20101113. стр 152)
bool bWasSprmSFPgnRestart = false;
wstring wsSprmSPgnStart;
std::wstring wsSprmSPgnStart;
for (list<SinglePropertyModifier>::iterator iter = sepx->grpprl->begin(); iter != sepx->grpprl->end(); ++iter)
for (std::list<SinglePropertyModifier>::iterator iter = sepx->grpprl->begin(); iter != sepx->grpprl->end(); ++iter)
{
switch (iter->OpCode)
{
......@@ -556,7 +556,7 @@ namespace DocFileFormat
}
}
AppendRef (m_pXmlNode, StoryType.c_str(), Story.c_str(), ( wstring( _T( "rId" ) ) + FormatUtils::IntToWideString(nRelID) ).c_str() );
AppendRef (m_pXmlNode, StoryType.c_str(), Story.c_str(), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString(nRelID) ).c_str() );
return TRUE;
}
......
......@@ -142,7 +142,7 @@ namespace DocFileFormat
lncContinue = 0x02 // Line numbers continue from the preceding section, or start at 1 if this is the first section of the document.
};
static const wstring LineNumberRestart [] = // ST_LineNumberRestart
static const std::wstring LineNumberRestart [] = // ST_LineNumberRestart
{
WSTD (newPage),
WSTD (newSection),
......@@ -183,7 +183,7 @@ namespace DocFileFormat
bool isOwnSectPr;
//int _sectNr;
ConversionContext* _ctx;
wstring _type;
std::wstring _type;
short _pgWidth, _marLeft, _marRight;
};
......
......@@ -39,10 +39,10 @@ namespace DocFileFormat
{
public:
/// Parses the bytes to retrieve a SectionPropertyExceptions
SectionPropertyExceptions( unsigned char* bytes, int size ):
PropertyExceptions( bytes, size ), isBidi(false)
SectionPropertyExceptions( unsigned char* bytes, int size, bool oldVersion ):
PropertyExceptions( bytes, size, oldVersion ), isBidi(false)
{
for ( list<SinglePropertyModifier>::iterator iter = this->grpprl->begin(); iter != this->grpprl->end(); iter++ )
for ( std::list<SinglePropertyModifier>::iterator iter = this->grpprl->begin(); iter != this->grpprl->end(); iter++ )
{
SinglePropertyModifier sprm( *iter );
......
......@@ -175,7 +175,7 @@ namespace DocFileFormat
//close w:settings
m_oXmlWriter.WriteNodeEnd( _T( "w:settings" ) );
this->_ctx->_docx->SettingsXML = wstring( m_oXmlWriter.GetXmlString() );
this->_ctx->_docx->SettingsXML = std::wstring( m_oXmlWriter.GetXmlString() );
}
void SettingsMapping::writeRsidList()
......@@ -183,7 +183,7 @@ namespace DocFileFormat
//convert the rsid list
m_oXmlWriter.WriteNodeBegin( _T( "w:rsids" ) );
for ( set<wstring>::iterator iter = this->_ctx->AllRsids.begin(); iter != this->_ctx->AllRsids.end(); iter++ )
for ( std::set<std::wstring>::iterator iter = this->_ctx->AllRsids.begin(); iter != this->_ctx->AllRsids.end(); iter++ )
{
m_oXmlWriter.WriteNodeBegin( _T( "w:rsid" ), TRUE );
m_oXmlWriter.WriteAttribute( _T( "w:val" ), iter->c_str() );
......
......@@ -184,12 +184,12 @@ namespace DocFileFormat
/// An array of 16-bit signed integer that specifies horizontal distance in twips.
/// MUST be greater than or equal to -31680 and less than or equal to 31680.
vector<short> rgdxaCenter;
std::vector<short> rgdxaCenter;
/// An array of TC80 that specifies the default formatting for a cell in the table.
/// Each TC80 in the array corresponds to the equivalent column in the table.
/// If there are fewer TC80s than columns, the remaining columns are formatted with the default TC80 formatting.
/// If there are more TC80s than columns, the excess TC80s MUST be ignored.
vector<TC80> rgTc80;
std::vector<TC80> rgTc80;
};
}
\ No newline at end of file
......@@ -67,11 +67,11 @@ namespace DocFileFormat
{
if (( m_pStorage != NULL ) && ( path != NULL ))
{
*ppStream = //m_pStorage->stream(path);
new POLE::Stream(m_pStorage, path);
//result = m_pStorage->OpenStream (path, NULL, ( STGM_READ | STGM_DIRECT | STGM_SHARE_EXCLUSIVE ), NULL, ppStream );
*ppStream = new POLE::Stream(m_pStorage, path);
}
if (*ppStream) return true;
if ((*ppStream) && ((*ppStream)->size() > 0))
return true;
return false;
}
......
......@@ -40,7 +40,7 @@ namespace DocFileFormat
if ( NULL != Styles )
{
for ( vector<StyleSheetDescription*>::iterator iter = Styles->begin(); iter != Styles->end(); iter++ )
for ( std::vector<StyleSheetDescription*>::iterator iter = Styles->begin(); iter != Styles->end(); iter++ )
{
RELEASEOBJECT( *iter );
}
......@@ -54,7 +54,7 @@ namespace DocFileFormat
/// Parses the streams to retrieve a StyleSheet.
StyleSheet::StyleSheet (FileInformationBlock* fib, POLE::Stream* tableStream, POLE::Stream* dataStream) : stshi(NULL), Styles(NULL)
{
VirtualStreamReader tableReader( tableStream, fib->m_FibWord97.fcStshf );
VirtualStreamReader tableReader( tableStream, fib->m_FibWord97.fcStshf, fib->m_bOlderVersion);
//read size of the STSHI
int stshiLengthBytesSize = 2;
......@@ -71,7 +71,7 @@ namespace DocFileFormat
RELEASEARRAYOBJECTS( stshi );
//create list of STDs
this->Styles = new vector<StyleSheetDescription*>();
this->Styles = new std::vector<StyleSheetDescription*>();
for ( int i = 0; i < this->stshi->cstd; i++ )
{
......@@ -84,7 +84,7 @@ namespace DocFileFormat
unsigned char* std = tableReader.ReadBytes( cbStd, true );
//parse the STD bytes
this->Styles->push_back( new StyleSheetDescription( std, cbStd, (int)this->stshi->cbSTDBaseInFile, dataStream ) );
this->Styles->push_back( new StyleSheetDescription( std, cbStd, (int)this->stshi->cbSTDBaseInFile, dataStream, fib->m_bOlderVersion) );
RELEASEARRAYOBJECTS( std );
}
......
......@@ -51,6 +51,6 @@ namespace DocFileFormat
/// The StyleSheetInformation of the stylesheet.
StyleSheetInformation* stshi;
/// The list contains all styles.
vector<StyleSheetDescription*>* Styles;
std::vector<StyleSheetDescription*>* Styles;
};
}
\ No newline at end of file
......@@ -387,7 +387,7 @@ namespace DocFileFormat
private:
/// The name of the style
wstring xstzName;
std::wstring xstzName;
/// Invariant style identifier
StyleIdentifier sti;
/// spare field for any temporary use, always reset back to zero!
......@@ -455,6 +455,6 @@ namespace DocFileFormat
StyleSheetDescription();
virtual ~StyleSheetDescription();
/// Parses the bytes to retrieve a StyleSheetDescription
StyleSheetDescription( unsigned char* bytes, int size, int cbStdBase, POLE::Stream* dataStream );
StyleSheetDescription( unsigned char* bytes, int size, int cbStdBase, POLE::Stream* dataStream, bool older);
};
}
\ No newline at end of file
......@@ -53,8 +53,8 @@ namespace DocFileFormat
StyleSheetMapping( ConversionContext* ctx );
void Apply( IVisitable* visited );
/// Generates a style id for custom style names or returns the build-in identifier for build-in styles.
static wstring MakeStyleId( StyleSheetDescription* std );
static map<std::wstring, std::wstring> m_mapStyleId;
static std::wstring MakeStyleId( StyleSheetDescription* std );
static std::map<std::wstring, std::wstring> m_mapStyleId;
static ASCOfficeCriticalSection m_mapStyleIdLock;
virtual ~StyleSheetMapping();
......@@ -63,7 +63,7 @@ namespace DocFileFormat
void writeParagraphDefaults( StyleSheet* sheet );
/// Chooses the correct style name.
/// Word 2007 needs the identifier instead of the stylename for translating it into the UI language.
wstring getStyleName( StyleSheetDescription* std );
std::wstring getStyleName( StyleSheetDescription* std );
/// Writes the "NormalTable" default style
void writeNormalTableStyle();
};
......
......@@ -49,7 +49,7 @@ namespace DocFileFormat
{
if ( papx != NULL )
{
for ( list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ )
for ( std::list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ )
{
if ( iter->OpCode == sprmPFInTable )
{
......
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