Commit 809065e7 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@61916 954022d7-b5bf-4e40-9824-e11837661b57
parent 2c14c02d
......@@ -183,6 +183,17 @@ ASCImageStudio3/AVSImageView5/pdb_maker.exe svn_mime_002dtype=application%2Focte
ASCOfficeDjVuFile/Test/Test/bin/Debug/Interop.AVSOfficeDjVuFile.dll svn_mime_002dtype=application%2Foctet-stream
ASCOfficeDjVuFile/Test/Test/bin/Debug/Test.exe svn_mime_002dtype=application%2Foctet-stream
ASCOfficeDjVuFile/Test/Test/bin/Debug/Test.pdb svn_mime_002dtype=application%2Foctet-stream
ASCOfficeDocFile/DocDocxConverter/DocumentProperties.h svn_mime_002dtype=application%2Foctet-stream
ASCOfficeDocFile/DocFormatLib svnc_tsvn_003alogminsize=5
ASCOfficeDocFile/DocFormatLib/Linux svnc_tsvn_003alogminsize=5
ASCOfficeDocFile/DocFormatLib/Win32 svnc_tsvn_003alogminsize=5
ASCOfficeDocFile/Tests/DocFileTest/bin/Debug/DocFileTest.exe svn_mime_002dtype=application%2Foctet-stream
ASCOfficeDocFile/Tests/DocFileTest/bin/Debug/DocFileTest.pdb svn_mime_002dtype=application%2Foctet-stream
ASCOfficeDocFile/Tests/DocFileTest/bin/Debug/Interop.ASCDocFile.dll svn_mime_002dtype=application%2Foctet-stream
ASCOfficeDocFile/Tests/DocFileTest/bin/Debug/TestFile.docx svn_mime_002dtype=application%2Foctet-stream
ASCOfficeDocFile/Tests/DocFileTest/bin/Debug/test.doc svn_mime_002dtype=application%2Foctet-stream
ASCOfficeDocFile/pole svnc_tsvn_003alogminsize=5
ASCOfficeDocFile/pole/linux svnc_tsvn_003alogminsize=5
ASCOfficeEWSEditor/ASCOfficeEWSEditor/Editor/Charts svnc_bugtraq_003anumber=true
ASCOfficeFB2File/ASCOfficeFB2File/Resource/DocxTemplate.docx svn_mime_002dtype=application%2Foctet-stream
ASCOfficeFB2File/ASCOfficeFB2FileTest/ASCOfficeFB2FileTest/bin/Release/AVSOfficeFB2FileTest.exe svn_mime_002dtype=application%2Foctet-stream
......
#pragma once
#include "../../Common/DocxFormat/Source/Base/SmartPtr.h"
template <class T, class I> class Aggregat
{
public:
Aggregat()
{
}
Aggregat(T* _item) : m_item(_item)
{
}
T& operator* ()
{
*return m_item;
}
T* get()
{
return m_item.operator->();
}
const T* get() const
{
return m_item.operator->();
}
T* operator ->()
{
return m_item.operator->();
}
const T* operator ->() const
{
return m_item.operator->();
}
template <class A> const bool is() const
{
return (typeid(*this->m_item) == typeid(A));
}
template <class A> A& as()
{
return static_cast<A&>(*this->m_item);
}
template <class A> const A& as() const
{
return static_cast<const A&>(*this->m_item);
}
template <> const bool is<I>() const
{
return true;
}
template <> I& as<I>()
{
return static_cast<I&>(*this);
}
template <> const I& as<I>() const
{
return static_cast<const I&>(*this);
}
inline bool IsInit() const
{
return m_item.IsInit();
}
inline T* Get()
{
return m_item.operator->();
}
inline const T* Get() const
{
return m_item.operator->();
}
protected:
NSCommon::smart_ptr<T> m_item;
};
\ No newline at end of file
#pragma once
typedef void (*OnProgressCallbackDocFile)( LPVOID lpParam, long nID, long nPercent );
typedef void (*OnProgressExCallbackDocFile)( LPVOID lpParam, long nID, long nPercent, short* Cancel );
struct ProgressCallback
{
OnProgressCallbackDocFile OnProgress;
OnProgressExCallbackDocFile OnProgressEx;
LPVOID caller;
};
static const long DOC_ONPROGRESSEVENT_ID = 0;
This diff is collapsed.
#pragma once
struct IOperand
{
virtual operator unsigned char*() const = 0;
virtual operator const unsigned char*() const = 0;
virtual unsigned int Size() const = 0;
virtual ~IOperand() {}
};
#pragma once
struct IVirtualConstructor
{
virtual IVirtualConstructor* New() const = 0;
virtual IVirtualConstructor* Clone() const = 0;
virtual ~IVirtualConstructor() {}
};
#pragma once
namespace DocFileFormat
{
enum LanguageCode
{
Nothing = 1024,
Afrikaans = 1078,
Albanian = 1052,
Amharic = 1118,
ArabicAlgeria = 5121,
ArabicBahrain = 15361,
ArabicEgypt = 3073,
ArabicIraq = 2049,
ArabicJordan = 11265,
ArabicKuwait = 13313,
ArabicLebanon = 12289,
ArabicLibya = 4097,
ArabicMorocco = 6145,
ArabicOman = 8193,
ArabicQatar = 16385,
ArabicSaudiArabia = 1025,
ArabicSyria = 10241,
ArabicTunisia = 7169,
ArabicUAE = 14337,
ArabicYemen = 9217,
Armenian = 1067,
Assamese = 1101,
AzeriCyrillic = 2092,
AzeriLatin = 1068,
Basque = 1069,
Belarusian = 1059,
Bengali = 1093,
BengaliBangladesh = 2117,
Bulgarian = 1026,
Burmese = 1109,
Catalan = 1027,
Cherokee = 1116,
ChineseHongKong = 3076,
ChineseMacao = 5124,
ChinesePRC = 2052,
ChineseSingapore = 4100,
ChineseTaiwan = 1028,
Croatian = 1050,
Czech = 1029,
Danish = 1030,
Divehi = 1125,
DutchBelgium = 2067,
DutchNetherlands = 1043,
Edo = 1126,
EnglishAustralia = 3081,
EnglishBelize = 10249,
EnglishCanada = 4105,
EnglishCaribbean = 9225,
EnglishHongKong = 15369,
EnglishIndia = 16393,
EnglishIndonesia = 14345,
EnglishIreland = 6153,
EnglishJamaica = 8201,
EnglishMalaysia = 17417,
EnglishNewZealand = 5129,
EnglishPhilippines = 13321,
EnglishSingapore = 18441,
EnglishSouthAfrica = 7177,
EnglishTrinidadAndTobago = 11273,
EnglishUK = 2057,
EnglishUS = 1033,
EnglishZimbabwe = 12297,
Estonian = 1061,
Faeroese = 1080,
Farsi = 1065,
Filipino = 1124,
Finnish = 1035,
FrenchBelgium = 2060,
FrenchCameroon = 11276,
FrenchCanada = 3084,
FrenchCongoDRC = 9228,
FrenchCotedIvoire = 12300,
FrenchFrance = 1036,
FrenchHaiti = 15372,
FrenchLuxembourg = 5132,
FrenchMali = 13324,
FrenchMonaco = 6156,
FrenchMorocco = 14348,
FrenchReunion = 8204,
FrenchSenegal = 10252,
FrenchSwitzerland = 4108,
FrenchWestIndies = 7180,
FrisianNetherlands = 1122,
Fulfulde = 1127,
FYROMacedonian = 1071,
GaelicIreland = 2108,
GaelicScotland = 1084,
Galician = 1110,
Georgian = 1079,
GermanAustria = 3079,
GermanGermany = 1031,
GermanLiechtenstein = 5127,
GermanLuxembourg = 4103,
GermanSwitzerland = 2055,
Greek = 1032,
Guarani = 1140,
Gujarati = 1095,
Hausa = 1128,
Hawaiian = 1141,
Hebrew = 1037,
Hindi = 1081,
Hungarian = 1038,
Ibibio = 1129,
Icelandic = 1039,
Igbo = 1136,
Indonesian = 1057,
Inuktitut = 1117,
ItalianItaly = 1040,
ItalianSwitzerland = 2064,
Japanese = 1041,
Kannada = 1099,
Kanuri = 1137,
Kashmiri = 2144,
KashmiriArabic = 1120,
Kazakh = 1087,
Khmer = 1107,
Konkani = 1111,
Korean = 1042,
Kyrgyz = 1088,
Lao = 1108,
Latin = 1142,
Latvian = 1062,
Lithuanian = 1063,
Malay = 1086,
MalayBruneiDarussalam = 2110,
Malayalam = 1100,
Maltese = 1082,
Manipuri = 1112,
Maori = 1153,
Marathi = 1102,
Mongolian = 1104,
MongolianMongolian = 2128,
Nepali = 1121,
NepaliIndia = 2145,
NorwegianBokmal = 1044,
NorwegianNynorsk = 2068,
Oriya = 1096,
Oromo = 1138,
Papiamentu = 1145,
Pashto = 1123,
Polish = 1045,
PortugueseBrazil = 1046,
PortuguesePortugal = 2070,
Punjabi = 1094,
PunjabiPakistan = 2118,
QuechuaBolivia = 1131,
QuechuaEcuador = 2155,
QuechuaPeru = 3179,
RhaetoRomanic = 1047,
RomanianMoldova = 2072,
RomanianRomania = 1048,
RussianMoldova = 2073,
RussianRussia = 1049,
SamiLappish = 1083,
Sanskrit = 1103,
Sepedi = 1132,
SerbianCyrillic = 3098,
SerbianLatin = 2074,
SindhiArabic = 2137,
SindhiDevanagari = 1113,
Sinhalese = 1115,
Slovak = 1051,
Slovenian = 1060,
Somali = 1143,
Sorbian = 1070,
SpanishArgentina = 11274,
SpanishBolivia = 16394,
SpanishChile = 13322,
SpanishColombia = 9226,
SpanishCostaRica = 5130,
SpanishDominicanRepublic = 7178,
SpanishEcuador = 12298,
SpanishElSalvador = 17418,
SpanishGuatemala = 4106,
SpanishHonduras = 18442,
SpanishMexico = 2058,
SpanishNicaragua = 19466,
SpanishPanama = 6154,
SpanishParaguay = 15370,
SpanishPeru = 10250,
SpanishPuertoRico = 20490,
SpanishSpainModernSort = 3082,
SpanishSpainTraditionalSort = 1034,
SpanishUruguay = 14346,
SpanishVenezuela = 8202,
Sutu = 1072,
Swahili = 1089,
SwedishFinland = 2077,
SwedishSweden = 1053,
Syriac = 1114,
Tajik = 1064,
Tamazight = 1119,
TamazightLatin = 2143,
Tamil = 1097,
Tatar = 1092,
Telugu = 1098,
Thai = 1054,
TibetanBhutan = 2129,
TibetanPRC = 1105,
TigrignaEritrea = 2163,
TigrignaEthiopia = 1139,
Tsonga = 1073,
Tswana = 1074,
Turkish = 1055,
Turkmen = 1090,
Ukrainian = 1058,
Urdu = 1056,
UzbekCyrillic = 2115,
UzbekLatin = 1091,
Venda = 1075,
Vietnamese = 1066,
Welsh = 1106,
Xhosa = 1076,
Yi = 1144,
Yiddish = 1085,
Yoruba = 1130,
Zulu = 1077
};
}
\ No newline at end of file
#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
This diff is collapsed.
#pragma once
template <class T> class Singleton
{
protected:
Singleton()
{
}
virtual ~Singleton()
{
m_pSelf = 0;
}
public:
static T* Instance();
void FreeInstance();
private:
static T* m_pSelf;
};
template <class T> T* Singleton<T>::m_pSelf = 0;
template <class T> T* Singleton<T>::Instance ()
{
if (0 == m_pSelf)
m_pSelf = new T;
return m_pSelf;
}
template <class T> void Singleton<T>::FreeInstance()
{
delete this;
}
\ No newline at end of file
#pragma once
namespace TextMark
{
static const wchar_t ParagraphEnd = (wchar_t) 13;
static const wchar_t HardLineBreak = (wchar_t) 11;
static const wchar_t BreakingHyphen = (wchar_t) 4;
static const wchar_t CellOrRowMark = (wchar_t) 7;
static const wchar_t NonRequiredHyphen = (wchar_t) 31;
static const wchar_t NonBreakingHyphen = (wchar_t) 30;
static const wchar_t NonBreakingSpace = (wchar_t) 160;
static const wchar_t Space = (wchar_t) 32;
static const wchar_t PageBreakOrSectionMark = (wchar_t) 12;
static const wchar_t ColumnBreak = (wchar_t) 14;
static const wchar_t Tab = (wchar_t) 9;
static const wchar_t FieldBeginMark = (wchar_t) 19;
static const wchar_t FieldSeparator = (wchar_t) 20;
static const wchar_t FieldEndMark = (wchar_t) 21;
//Special WCHARacters (chp.fSpec == 1)
static const wchar_t CurrentPageNumber = (wchar_t) 0;
static const wchar_t Picture = (wchar_t) 1;
static const wchar_t AutoNumberedFootnoteReference = (wchar_t) 2;
static const wchar_t AutoNumberedEndnoteReference = (wchar_t) 2;
static const wchar_t FootnoteSeparator = (wchar_t) 3;
static const wchar_t FootnoteContinuation = (wchar_t) 4;
static const wchar_t AnnotationReference = (wchar_t) 5;
static const wchar_t LineNumber = (wchar_t) 6;
static const wchar_t HandAnnotationPicture = (wchar_t) 7;
static const wchar_t DrawnObject = (wchar_t) 8;
static const wchar_t Symbol = (wchar_t) 40;
}
\ No newline at end of file
This diff is collapsed.
#pragma once
template< class InIt, class OutIt > inline
void utf8_encode( InIt in, const InIt end, OutIt out )
{
while( !(in == end) ) {
unsigned long wc = static_cast<wchar_t>(*in); ++in;
over:
if( wc < 0x80 ) {
*out = static_cast<char>(wc); ++out;
continue;
}
if( sizeof(wchar_t) == 2 &&
wc >= 0xD800 && wc < 0xE000 )
{//handle surrogates for UTF-16
if( wc >= 0xDC00 ) { wc = '?'; goto over; }
if( in == end ) return;
unsigned long lo = static_cast<wchar_t>(*in); ++in;
if( lo >= 0xDC00 && wc < 0xE000 ) {
wc = 0x10000 + ((wc & 0x3FF) << 10 | lo & 0x3FF);
} else {
*out = '?'; ++out; wc = lo;
goto over;
}
}
char c; int shift;
if( wc < 0x800 ) { shift = 6; c = ('\xFF' << 6); } else
if( wc < 0x10000 ) { shift = 12; c = ('\xFF' << 5); } else
if( wc < 0x200000 ) { shift = 18; c = ('\xFF' << 4); } else
if( wc < 0x4000000 ) { shift = 24; c = ('\xFF' << 3); } else
{ shift = 30; c = ('\xFF' << 2); }
do {
c |= (wc >> shift) & 0x3f;
*out = c; ++out;
c = char(0x80); shift -= 6;
} while( shift >= 0 );
}
}
template< class InIt, class OutIt > inline
void utf8_decode( InIt in, const InIt end, OutIt out )
{
int cnt;
for(; !(in == end); ++in) {
unsigned long wc = static_cast<unsigned char>(*in);
over:
if( wc & 0x80 ) {
if( 0xC0 == (0xE0 & wc) ) { cnt = 1; wc &= ~0xE0; } else
if( 0xE0 == (0xF0 & wc) ) { cnt = 2; wc &= ~0xF0; } else
if( 0xF0 == (0xF8 & wc) ) { cnt = 3; wc &= ~0xF8; } else
if( 0xF8 == (0xFC & wc) ) { cnt = 4; wc &= ~0xFC; } else
if( 0xFC == (0xFE & wc) ) { cnt = 5; wc &= ~0xFE; } else
{ *out = wchar_t('?'); ++out; continue; };//invalid start code
if( 0 == wc ) wc = ~0UL;//codepoint encoded with overlong sequence
do {
if( ++in == end ) return;
unsigned char c = static_cast<unsigned char>(*in);
if( 0x80 != (0xC0 & c) )
{ *out = static_cast<wchar_t>(wc); ++out; wc = c; goto over; }
wc <<= 6; wc |= c & ~0xC0;
} while( --cnt );
if( 0x80000000 & wc ) wc = '?';//codepoint exceeds unicode range
if( sizeof(wchar_t) == 2 && wc > 0xFFFF )
{//handle surrogates for UTF-16
wc -= 0x10000;
*out = static_cast<wchar_t>(0xD800 | ((wc >> 10) & 0x3FF)); ++out;
*out = static_cast<wchar_t>(0xDC00 | (wc & 0x3FF)); ++out;
continue;
}
}
*out = static_cast<wchar_t>(wc); ++out;
}
}
\ No newline at end of file
#pragma once
#include "../../Common/DocxFormat/Source/XML/xmlutils.h"
namespace DocFileFormat
{
class AbstractOpenXmlMapping
{
public:
AbstractOpenXmlMapping (XmlUtils::CXmlWriter* pWriter) : m_pXmlWriter(pWriter)
{
}
inline XmlUtils::CXmlWriter* GetXMLWriter()
{
return m_pXmlWriter;
}
virtual ~AbstractOpenXmlMapping()
{
}
protected:
XmlUtils::CXmlWriter* m_pXmlWriter;
};
}
#pragma once
#include "FileInformationBlock.h"
#include "VirtualStreamReader.h"
namespace DocFileFormat
{
class AnnotationOwnerList: public vector<wstring>
{
public:
AnnotationOwnerList(FileInformationBlock* fib, POLE::Stream* tableStream) : std::vector<wstring>()
{
VirtualStreamReader reader(tableStream, fib->m_FibWord97.fcGrpXstAtnOwners);
while (reader.GetPosition() < (fib->m_FibWord97.fcGrpXstAtnOwners + fib->m_FibWord97.lcbGrpXstAtnOwners))
{
push_back(reader.ReadXst());
}
}
};
}
\ No newline at end of file
#include "AnnotationReferenceDescriptor.h"
namespace DocFileFormat
{
ByteStructure* AnnotationReferenceDescriptor::ConstructObject(VirtualStreamReader* reader, int length)
{
AnnotationReferenceDescriptor *newObject = new AnnotationReferenceDescriptor();
//read the user initials (LPXCharBuffer9)
short cch = reader->ReadInt16();
unsigned char *chars = reader->ReadBytes(18, true);
FormatUtils::GetSTLCollectionFromBytes<wstring>( &(newObject->m_UserInitials), chars, ( cch * 2 ), ENCODING_UNICODE);
newObject->m_AuthorIndex = reader->ReadUInt16();
//skip 4 bytes
reader->ReadBytes(4, false);
newObject->m_BookmarkId = reader->ReadInt32();
RELEASEARRAYOBJECTS(chars);
return static_cast<ByteStructure*>(newObject);
}
}
\ No newline at end of file
#pragma once
#include "ByteStructure.h"
namespace DocFileFormat
{
class AnnotationReferenceDescriptor: public ByteStructure
{
public:
static const int STRUCTURE_SIZE = 30;
inline std::wstring GetUserInitials() const
{
return m_UserInitials;
}
inline unsigned short GetAuthorIndex() const
{
return m_AuthorIndex;
}
inline int GetBookmarkId() const
{
return m_BookmarkId;
}
AnnotationReferenceDescriptor() : m_UserInitials( _T( "" ) ), m_AuthorIndex(0), m_BookmarkId(0)
{
}
virtual ~AnnotationReferenceDescriptor()
{
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length );
private:
/// The initials of the user who left the annotation.
std::wstring m_UserInitials;
/// An index into the string table of comment author names.
unsigned short m_AuthorIndex;
/// Identifies a bookmark.
int m_BookmarkId;
};
}
#pragma once
namespace DocFileFormat
{
class AutoSummaryInfo
{
private:
/// True if the ASUMYI is valid
bool fValid;
/// True if AutoSummary View is active
bool fView;
/// Display method for AutoSummary View:
/// 0 = Emphasize in current doc
/// 1 = Reduce doc to summary
/// 2 = Insert into doc
/// 3 = Show in new document
short iViewBy;
/// True if File Properties summary information
/// should be updated after the next summarization
bool fUpdateProps;
/// Dialog summary level
short wDlgLevel;
/// Upper bound for lLevel for sentences in this document
int lHighestLevel;
/// Show document sentences at or below this level
int lCurrentLevel;
public:
virtual ~AutoSummaryInfo()
{
}
AutoSummaryInfo():
fValid(false), fView(false), iViewBy(0), fUpdateProps(false), wDlgLevel(0),
lHighestLevel(0), lCurrentLevel(0)
{
}
/// Parses the bytes to retrieve a AutoSummaryInfo
AutoSummaryInfo( unsigned char* bytes, int size ):
fValid(false), fView(false), iViewBy(0), fUpdateProps(false), wDlgLevel(0),
lHighestLevel(0), lCurrentLevel(0)
{
if ( size == 12 )
{
//split unsigned char 0 and 1 into bits
this->fValid = FormatUtils::GetBitFromBytes( bytes, size, 0 );
this->fView = FormatUtils::GetBitFromBytes( bytes, size, 1 );
this->iViewBy = (short)FormatUtils::GetUIntFromBytesBits( bytes, size, 2, 2 );
this->fUpdateProps = FormatUtils::GetBitFromBytes( bytes, size, 4 );
this->wDlgLevel = FormatUtils::BytesToInt16( bytes, 2, size );
this->lHighestLevel = FormatUtils::BytesToInt32( bytes, 4, size );
this->lCurrentLevel = FormatUtils::BytesToInt32( bytes, 8, size );
}
else
{
//throw new ByteParseException("Cannot parse the struct ASUMYI, the length of the struct doesn't match");
}
}
};
}
\ No newline at end of file
#pragma once
#include "VirtualStreamReader.h"
#include "ByteStructure.h"
namespace DocFileFormat
{
class BookmarkFirst: public ByteStructure
{
private:
/// An unsigned integer that specifies a zero-based index into the PlcfBkl or PlcfBkld
/// that is paired with the PlcfBkf or PlcfBkfd containing this FBKF.
/// The entry found at said index specifies the location of the end of the bookmark associated with this FBKF.
/// Ibkl MUST be unique for all FBKFs inside a given PlcfBkf or PlcfBkfd.
short ibkl;
/// A BKC that specifies further information about the bookmark associated with this FBKF.
short bkc;
public:
static const int STRUCTURE_SIZE = 4;
BookmarkFirst()
{
}
short GetIndex() const
{
return this->ibkl;
}
short GetInformation() const
{
return this->bkc;
}
virtual ~BookmarkFirst()
{
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length )
{
BookmarkFirst *newObject = new BookmarkFirst();
newObject->ibkl = reader->ReadInt16();
newObject->bkc = reader->ReadInt16();
return static_cast<ByteStructure*>( newObject );
}
};
}
#pragma once
#include "IVisitable.h"
#include "Global.h"
namespace DocFileFormat
{
typedef enum _BorderType
{
none = 0,
single,
thick,
Double,
unused,
hairline,
dotted,
dashed,
dotDash,
dotDotDash,
triple,
thinThickSmallGap,
thickThinSmallGap,
thinThickThinSmallGap,
thinThickMediumGap,
thickThinMediumGap,
thinThickThinMediumGap,
thinThickLargeGap,
thickThinLargeGap,
thinThickThinLargeGap,
wave,
doubleWave,
dashSmallGap,
dashDotStroked,
threeDEmboss,
threeDEngrave
} BorderType;
class BorderCode: public IVisitable
{
friend class DocumentMapping;
friend class PropertiesMapping;
friend class VMLPictureMapping;
private:
/// 24-bit border color
int cv;
/// Width of a single line in 1/8pt, max of 32pt
unsigned char dptLineWidth;
/// Border type code:
/// 0 none
/// 1 single
/// 2 thick
/// 3 double
/// 5 hairline
/// 6 dot
/// 7 dash large gap
/// 8 dot dash
/// 9 dot dot dash
/// 10 triple
/// 11 thin-thick small gap
/// 12 tick-thin small gap
/// 13 thin-thick-thin small gap
/// 14 thin-thick medium gap
/// 15 thick-thin medium gap
/// 16 thin-thick-thin medium gap
/// 17 thin-thick large gap
/// 18 thick-thin large gap
/// 19 thin-thick-thin large gap
/// 20 wave
/// 21 double wave
/// 22 dash small gap
/// 23 dash dot stroked
/// 24 emboss 3D
/// 25 engrave 3D
unsigned char brcType;
/// The color of the Border.
/// Unused if cv is set.
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
bool fShadow;
/// When true, don't reverse the border
bool fFrame;
/// It's a nil BRC, bytes are FFFF.
bool fNil;
public:
/// Creates a new BorderCode with default values
BorderCode(): cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false)
{
}
/// Parses the unsigned char for a BRC
BorderCode( unsigned char* bytes, int size ):
cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false)
{
if ( FormatUtils::ArraySum( bytes, size ) == ( size * 255 ) )
{
this->fNil = true;
}
else if ( size == 8 )
{
//it's a border code of Word 2000/2003
this->cv = FormatUtils::BytesToInt32( bytes, 0, size );
this->ico = wstring( Global::ColorIdentifier[0] );
this->dptLineWidth = bytes[4];
this->brcType = bytes[5];
short val = FormatUtils::BytesToInt16( bytes, 6, size );
this->dptSpace = val & 0x001F;
//not sure if this is correct, the values from the spec are definitly wrong:
this->fShadow = FormatUtils::BitmaskToBool( val, 0x20 );
this->fFrame = FormatUtils::BitmaskToBool( val, 0x40 );
}
else if ( size == 4 )
{
//it's a border code of Word 97
unsigned short val = FormatUtils::BytesToUInt16( bytes, 0, size );
this->dptLineWidth = (unsigned char)( val & 0x00FF );
this->brcType = (unsigned char)( ( val & 0xFF00 ) >> 8 );
val = FormatUtils::BytesToUInt16( bytes, 2, size );
this->ico = FormatUtils::MapValueToWideString( ( val & 0x00FF ), &Global::ColorIdentifier[0][0], 17, 12 );
this->dptSpace = ( val & 0x1F00 ) >> 8;
}
else
{
//throw new ByteParseException("Cannot parse the struct BRC, the length of the struct doesn't match");
}
}
BorderCode( const BorderCode& bc )
{
if ( this != &bc )
{
this->cv = bc.cv;
this->dptLineWidth = bc.dptLineWidth;
this->brcType = bc.brcType;
this->ico = bc.ico;
this->dptSpace = bc.dptSpace;
this->fShadow = bc.fShadow;
this->fFrame = bc.fFrame;
this->fNil = bc.fNil;
}
}
bool operator == ( const BorderCode& bc )
{
if ( ( this->cv == bc.cv ) && ( this->dptLineWidth == bc.dptLineWidth ) && ( this->brcType == bc.brcType ) &&
( this->ico == bc.ico ) && ( this->dptSpace == bc.dptSpace ) && ( this->fShadow == bc.fShadow ) &&
( this->fFrame == bc.fFrame ) && ( this->fNil == bc.fNil ) )
{
return true;
}
else
{
return false;
}
}
bool operator != ( const BorderCode& bc )
{
return !( *this == bc );
}
};
}
#pragma once
#include "VirtualStreamReader.h"
namespace DocFileFormat
{
class ByteStructure
{
protected:
ByteStructure() {}
public:
virtual ~ByteStructure() {}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length ) = 0; // Virtual constructor
};
class EmptyStructure: public ByteStructure
{
public:
static const int STRUCTURE_SIZE = 0;
EmptyStructure() {}
virtual ~EmptyStructure() {}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length )
{
EmptyStructure *newObject = new EmptyStructure();
return static_cast<ByteStructure*>( newObject );
}
};
}
#pragma once
#include "IMapping.h"
#include "RevisionData.h"
#include "ParagraphPropertyExceptions.h"
#include "PropertiesMapping.h"
#include "LanguageId.h"
#include "LanguageIdMapping.h"
#include "StyleSheetMapping.h"
#include "BorderCode.h"
#include "ShadingDescriptor.h"
#include "WordDocument.h"
namespace DocFileFormat
{
static const wchar_t SuperscriptIndex[3][12] =
{
_T( "baseline" ),
_T( "superscript" ),
_T( "subscript" )
};
class CharacterPropertiesMapping: public PropertiesMapping, public IMapping
{
public:
CharacterPropertiesMapping( XmlUtils::CXmlWriter* writer, WordDocument* doc, RevisionData* rev, ParagraphPropertyExceptions* currentPapx, bool styleChpx, bool isRunStyleNeeded = true );
CharacterPropertiesMapping( XMLTools::XMLElement<wchar_t>* rPr, WordDocument* doc, RevisionData* rev, ParagraphPropertyExceptions* currentPapx, bool styleChpx, bool isRunStyleNeeded = true );
virtual ~CharacterPropertiesMapping();
void Apply( IVisitable* chpx );
bool CheckIsSymbolFont();
private:
void convertSprms( list<SinglePropertyModifier>* sprms, XMLTools::XMLElement<wchar_t>* parent );
list<CharacterPropertyExceptions*> buildHierarchy( const StyleSheet* styleSheet, unsigned short istdStart );
bool applyToggleHierachy( const SinglePropertyModifier& sprm );
bool toogleValue( bool currentValue, unsigned char toggle );
protected:
/// CHPX flags are special flags because the can be 0,1,128 and 129,
/// so this method overrides the appendFlagElement method.
virtual void appendFlagElement( XMLTools::XMLElement<wchar_t>* node, const SinglePropertyModifier& sprm, const wchar_t* elementName, bool unique );
private:
WordDocument* _doc;
XMLTools::XMLElement<wchar_t>* _rPr;
unsigned short _currentIstd;
RevisionData* _revisionData;
bool _styleChpx;
XmlUtils::CXmlWriter pRunPr;
ParagraphPropertyExceptions* _currentPapx;
list<CharacterPropertyExceptions*> _hierarchy;
bool _isRunStyleNeeded;
bool _isOwnRPr;
std::wstring m_sAsciiFont;
std::wstring m_sEastAsiaFont;
std::wstring m_shAnsiFont;
};
}
\ No newline at end of file
#pragma once
#include "PropertyExceptions.h"
namespace DocFileFormat
{
class CharacterPropertyExceptions: public PropertyExceptions
{
public:
/// Creates a CHPX wich doesn't modify anything.
/// The grpprl list is empty
CharacterPropertyExceptions(): PropertyExceptions()
{
}
/// Parses the bytes to retrieve a CHPX
CharacterPropertyExceptions( unsigned char* bytes, int size ): PropertyExceptions( bytes, size )
{
}
};
}
\ No newline at end of file
#pragma once
namespace DocFileFormat
{
class CharacterRange
{
private:
int CharacterPosition;
int CharacterCount;
public:
CharacterRange():
CharacterPosition(0), CharacterCount(0)
{
}
CharacterRange( int cp, int ccp ):
CharacterPosition(0), CharacterCount(0)
{
this->CharacterPosition = cp;
this->CharacterCount = ccp;
}
~CharacterRange()
{
}
int GetCharacterPosition() const
{
return this->CharacterPosition;
}
int GetCharacterCount() const
{
return this->CharacterCount;
}
};
}
\ No newline at end of file
#pragma once
#include "TableMapping.h"
#include "DocumentMapping.h"
#include "AnnotationReferenceDescriptor.h"
namespace DocFileFormat
{
class CommentsMapping: public DocumentMapping
{
public:
CommentsMapping (ConversionContext* ctx) : DocumentMapping( ctx, this )
{
}
virtual void Apply( IVisitable* visited )
{
m_document = static_cast<WordDocument*>( visited );
if ( ( m_document != NULL ) && ( m_document->FIB->m_RgLw97.ccpAtn > 0 ) )
{
m_context->_docx->RegisterComments();
int index = 0;
m_pXmlWriter->WriteNodeBegin( _T( "?xml version=\"1.0\" encoding=\"UTF-8\"?" ) );
m_pXmlWriter->WriteNodeBegin( _T( "w:comments" ), TRUE );
//write namespaces
m_pXmlWriter->WriteAttribute( _T( "xmlns:w" ), OpenXmlNamespaces::WordprocessingML );
m_pXmlWriter->WriteAttribute( _T( "xmlns:v" ), OpenXmlNamespaces::VectorML );
m_pXmlWriter->WriteAttribute( _T( "xmlns:o" ), OpenXmlNamespaces::Office );
m_pXmlWriter->WriteAttribute( _T( "xmlns:w10" ), OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute( _T( "xmlns:r" ), OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
int cp = m_document->FIB->m_RgLw97.ccpText + m_document->FIB->m_RgLw97.ccpFtn + m_document->FIB->m_RgLw97.ccpHdr;
size_t count = m_document->AnnotationsReferencePlex->Elements.size();
for (unsigned int i = 0; i < count; ++i)
{
AnnotationReferenceDescriptor* atrdPre10 = static_cast<AnnotationReferenceDescriptor*>(m_document->AnnotationsReferencePlex->Elements[index]);
m_pXmlWriter->WriteNodeBegin( _T( "w:comment" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( index ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:author" ), m_document->AnnotationOwners->at( atrdPre10->GetAuthorIndex() ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:initials" ), atrdPre10->GetUserInitials().c_str() );
//!!!TODO!!!
/*//ATRDpost10 is optional and not saved in all files
if (doc.AnnotationReferenceExtraTable != null &&
doc.AnnotationReferenceExtraTable.Count > index)
{
AnnotationReferenceDescriptorExtra atrdPost10 = doc.AnnotationReferenceExtraTable[index];
atrdPost10.Date.Convert(new DateMapping(_writer));
}*/
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
while ( ( cp - m_document->FIB->m_RgLw97.ccpText - m_document->FIB->m_RgLw97.ccpFtn - m_document->FIB->m_RgLw97.ccpHdr ) < (*m_document->IndividualCommentsPlex)[index + 1] )
{
int fc = m_document->FindFileCharPos(cp);
ParagraphPropertyExceptions* papx = findValidPapx(fc);
TableInfo tai(papx);
if ( tai.fInTable )
{
//this PAPX is for a table
Table table(this, cp, ( ( tai.iTap > 0 ) ? ( 1 ) : ( 0 ) ));
table.Convert(this);
cp = table.GetCPEnd();
}
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph(cp);
}
}
m_pXmlWriter->WriteNodeEnd(_T( "w:comment" ));
++index;
}
m_pXmlWriter->WriteNodeEnd( _T( "w:comments" ) );
m_context->_docx->CommentsXML = std::wstring(m_pXmlWriter->GetXmlString());
}
}
};
}
#pragma once
#if defined(_WIN32) || defined(_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../DesktopEditor/common/ASCVariant.h"
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
namespace OpenXmlContentTypes
{
// default content types
static const TCHAR* Xml = _T("application/xml");
// package content types
static const TCHAR* Relationships = _T("application/vnd.openxmlformats-package.relationships+xml");
static const TCHAR* CoreProperties = _T("application/vnd.openxmlformats-package.core-properties+xml");
// general office document content types
static const TCHAR* ExtendedProperties = _T("application/vnd.openxmlformats-officedocument.extended-properties+xml");
static const TCHAR* Theme = _T("application/vnd.openxmlformats-officedocument.theme+xml");
static const TCHAR* CustomXmlProperties = _T("application/vnd.openxmlformats-officedocument.customXmlProperties+xml");
static const TCHAR* OleObject = _T("application/vnd.openxmlformats-officedocument.oleObject");
static const TCHAR* Vml = _T("application/vnd.openxmlformats-officedocument.vmlDrawing");
static const TCHAR* Drawing = _T("application/vnd.openxmlformats-officedocument.drawing+xml");
static const TCHAR* MSExcel = _T("application/vnd.ms-excel");
static const TCHAR* MSWord = _T("application/msword");
static const TCHAR* MSPowerpoint = _T("application/vnd.ms-powerpoint");
static const TCHAR* Emf = _T("image/x-emf");
static const TCHAR* Jpeg = _T("image/jpeg");
static const TCHAR* Png = _T("image/png");
static const TCHAR* Tiff = _T("image/tiff");
static const TCHAR* Wmf = _T("image/x-wmf");
}
namespace WordprocessingMLContentTypes
{
// WordprocessingML content types
static const TCHAR* MainDocument = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml");
static const TCHAR* MainDocumentMacro = _T("application/vnd.ms-word.document.macroEnabled.main+xml");
static const TCHAR* MainDocumentTemplate = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml");
static const TCHAR* MainDocumentMacroTemplate = _T("application/vnd.ms-word.template.macroEnabledTemplate.main+xml");
static const TCHAR* Styles = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml");
static const TCHAR* Numbering = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml");
static const TCHAR* FontTable = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml");
static const TCHAR* WebSettings = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml");
static const TCHAR* Settings = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml");
static const TCHAR* Comments = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml");
static const TCHAR* Footnotes = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml");
static const TCHAR* Endnotes = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml");
static const TCHAR* Header = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml");
static const TCHAR* Footer = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml");
static const TCHAR* Glossary = _T("application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml");
}
namespace MicrosoftWordContentTypes
{
static const TCHAR* KeyMapCustomization = _T("application/vnd.ms-word.keyMapCustomizations+xml");
static const TCHAR* VbaProject = _T("application/vnd.ms-office.vbaProject");
static const TCHAR* VbaData = _T("application/vnd.ms-word.vbaData+xml");
static const TCHAR* Toolbars = _T("application/vnd.ms-word.attachedToolbars");
}
namespace OpenXmlNamespaces
{
// package namespaces
static const TCHAR* ContentTypes = _T("http://schemas.openxmlformats.org/package/2006/content-types");
static const TCHAR* RelationshipsPackage = _T("http://schemas.openxmlformats.org/package/2006/relationships");
static const TCHAR* Relationships = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships");
// Drawing ML namespaces
static const TCHAR* DrawingML = _T("http://schemas.openxmlformats.org/drawingml/2006/main");
static const TCHAR* DrawingMLPicture = _T("http://schemas.openxmlformats.org/drawingml/2006/picture");
// WordprocessingML namespaces
static const TCHAR* WordprocessingML = _T("http://schemas.openxmlformats.org/wordprocessingml/2006/main");
static const TCHAR* WordprocessingDrawingML = _T("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
static const TCHAR* VectorML = _T("urn:schemas-microsoft-com:vml");
static const TCHAR* MicrosoftWordML = _T("http://schemas.microsoft.com/office/word/2006/wordml");
// PresentationML namespaces
static const TCHAR* PresentationML = _T("http://schemas.openxmlformats.org/presentationml/2006/main");
// SpreadsheetML Namespaces
static const TCHAR* SharedStringML = _T("http://schemas.openxmlformats.org/spreadsheetml/2006/main");
static const TCHAR* WorkBookML = _T("http://schemas.openxmlformats.org/spreadsheetml/2006/main");
static const TCHAR* StylesML = _T("http://schemas.openxmlformats.org/spreadsheetml/2006/main");
//Office
static const TCHAR* Office = _T("urn:schemas-microsoft-com:office:office");
static const TCHAR* OfficeWord = _T("urn:schemas-microsoft-com:office:word");
}
namespace OpenXmlRelationshipTypes
{
static const TCHAR* CoreProperties = _T("http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties");
static const TCHAR* ExtendedProperties = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties");
static const TCHAR* Theme = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme");
static const TCHAR* OfficeDocument = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument");
static const TCHAR* Styles = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles");
static const TCHAR* FontTable = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable");
static const TCHAR* Numbering = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering");
static const TCHAR* WebSettings = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings");
static const TCHAR* Settings = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings");
static const TCHAR* CustomXml = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml");
static const TCHAR* CustomXmlProperties = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps");
static const TCHAR* Comments = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments");
static const TCHAR* Footnotes = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes");
static const TCHAR* Endnotes = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes");
static const TCHAR* Header = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/header");
static const TCHAR* Footer = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer");
static const TCHAR* Image = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image");
static const TCHAR* OleObject = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject");
static const TCHAR* GlossaryDocument = _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument");
}
namespace MicrosoftWordRelationshipTypes
{
static const TCHAR* KeyMapCustomizations = _T("http://schemas.microsoft.com/office/2006/relationships/keyMapCustomizations");
static const TCHAR* VbaProject = _T("http://schemas.microsoft.com/office/2006/relationships/vbaProject");
static const TCHAR* VbaData = _T("http://schemas.microsoft.com/office/2006/relationships/wordVbaData");
static const TCHAR* Toolbars = _T("http://schemas.microsoft.com/office/2006/relationships/attachedToolbars");
}
#pragma once
#include "WordDocument.h"
#include "WordprocessingDocument.h"
namespace DocFileFormat
{
class ConversionContext
{
public:
ConversionContext (WordDocument* doc, WordprocessingDocument* docx)
{
_doc = doc;
_docx = docx;
}
virtual ~ConversionContext()
{
}
// Adds a new RSID to the set
inline void AddRsid(const wstring& rsid)
{
if (AllRsids.find(rsid) == AllRsids.end())
AllRsids.insert(rsid);
}
inline WordDocument* GetDocument()
{
return _doc;
}
inline WordprocessingDocument* GetXmlDocument()
{
return _docx;
}
public:
WordprocessingDocument* _docx;
WordDocument* _doc;
/// A set thta contains all revision ids.
set<wstring> AllRsids;
};
}
\ No newline at end of file

#include "Converter.h"
namespace DocFileFormat
{
Converter::Converter()
{
}
Converter::~Converter()
{
}
}
namespace DocFileFormat
{
long Converter::Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress)
{
ConversionContext context( doc, docx );
//Write numbering.xml
NumberingMapping numberingMapping( &context );
doc->listTable->Convert( &numberingMapping );
if ( progress != NULL )
{
progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 810000 );
short cancel = 0;
progress->OnProgressEx( progress->caller, DOC_ONPROGRESSEVENT_ID, 810000, &cancel );
if ( cancel != 0 )
{
return S_FALSE;
}
}
//write document.xml and the header and footers
MainDocumentMapping mainDocMapping( &context, progress );
doc->Convert( &mainDocMapping );
if ( progress != NULL )
{
progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 825000 );
short cancel = 0;
progress->OnProgressEx( progress->caller, DOC_ONPROGRESSEVENT_ID, 825000, &cancel );
if ( cancel != 0 )
{
return S_FALSE;
}
}
//Write styles.xml
StyleSheetMapping styleSheetMapping( &context );
doc->Styles->Convert( &styleSheetMapping );
if ( progress != NULL )
{
progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 850000 );
short cancel = 0;
progress->OnProgressEx( progress->caller, DOC_ONPROGRESSEVENT_ID, 850000, &cancel );
if ( cancel != 0 )
{
return S_FALSE;
}
}
//Write fontTable.xml
FontTableMapping fontTableMapping( &context );
doc->FontTable->Convert( &fontTableMapping );
if ( progress != NULL )
{
progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 875000 );
short cancel = 0;
progress->OnProgressEx( progress->caller, DOC_ONPROGRESSEVENT_ID, 875000, &cancel );
if ( cancel != 0 )
{
return S_FALSE;
}
}
//write the footnotes
FootnotesMapping footnotesMapping( &context );
doc->Convert( &footnotesMapping );
if ( progress != NULL )
{
progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 900000 );
short cancel = 0;
progress->OnProgressEx( progress->caller, DOC_ONPROGRESSEVENT_ID, 900000, &cancel );
if ( cancel != 0 )
{
return S_FALSE;
}
}
//write the endnotes
EndnotesMapping endnotesMapping( &context );
doc->Convert( &endnotesMapping );
if ( progress != NULL )
{
progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 925000 );
short cancel = 0;
progress->OnProgressEx( progress->caller, DOC_ONPROGRESSEVENT_ID, 925000, &cancel );
if ( cancel != 0 )
{
return S_FALSE;
}
}
//write the comments
CommentsMapping commentsMapping( &context );
doc->Convert( &commentsMapping );
if ( progress != NULL )
{
progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 950000 );
short cancel = 0;
progress->OnProgressEx( progress->caller, DOC_ONPROGRESSEVENT_ID, 950000, &cancel );
if ( cancel != 0 )
{
return S_FALSE;
}
}
//write settings.xml at last because of the rsid list
SettingsMapping settingsMapping( &context );
doc->DocProperties->Convert( &settingsMapping );
if ( progress != NULL )
{
progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 975000 );
short cancel = 0;
progress->OnProgressEx( progress->caller, DOC_ONPROGRESSEVENT_ID, 975000, &cancel );
if ( cancel != 0 )
{
return S_FALSE;
}
}
return S_OK;
}
long Converter::LoadAndConvert(const CString& strSrcFile, const CString& strDstDirectory, const ProgressCallback* progress)
{
g_oCriticalSection.Enter();
long result = S_FALSE;
WordDocument doc(strSrcFile);
WordprocessingDocument docx(strDstDirectory, &doc);
result = doc.LoadDocument(progress);
if (result != S_FALSE)
{
result = Convert(&doc, &docx, progress);
if (result != S_FALSE)
{
docx.SaveDocument();
if (progress)progress->OnProgress(progress->caller, DOC_ONPROGRESSEVENT_ID, 1000000);
short cancel = 0;
if (progress)progress->OnProgressEx(progress->caller, DOC_ONPROGRESSEVENT_ID, 1000000, &cancel);
if (0 != cancel)
{
return S_FALSE;
}
}
}
g_oCriticalSection.Leave();
return result;
}
}
#pragma once
#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"
extern ASCOfficeCriticalSection g_oCriticalSection;
namespace DocFileFormat
{
class Converter
{
public:
Converter();
~Converter();
long LoadAndConvert(const CString& strSrcFile, const CString& strDstDirectory, const ProgressCallback* progress);
private:
long Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress);
};
}
#pragma once
#include "../Common/FormatUtils.h"
namespace DocFileFormat
{
class DateAndTime
{
private:
/// minutes (0-59)
short mint;
/// hours (0-23)
short hr;
/// day of month (1-31)
short dom;
/// month (1-12)
short mon;
/// year (1900-2411)-1900
short yr;
/// weekday<br/>
/// 0 Sunday
/// 1 Monday
/// 2 Tuesday
/// 3 Wednesday
/// 4 Thursday
/// 5 Friday
/// 6 Saturday
short wdy;
public:
/// Creates a new DateAndTime with default values
DateAndTime()
{
setDefaultValues();
}
/// Parses the unsigned char sto retrieve a DateAndTime
DateAndTime( unsigned char* bytes, int size )
{
if ( size == 4 )
{
this->mint = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 0, 6 );
this->hr = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 6, 5 );
this->dom = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 11, 5 );
this->mon = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 16, 4 );
this->yr = (short)( 1900 + FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 20, 9 ) );
this->wdy = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 29, 3 );
}
else
{
//throw new ByteParseException("Cannot parse the struct DTTM, the length of the struct doesn't match");
}
}
#if defined(_WIN32) || defined(_WIN64)
SYSTEMTIME ToSYSTEMTIME()
{
SYSTEMTIME st = { 0 };
if ( ( this->yr == 1900 ) && ( this->mon == 0 ) && ( this->dom == 0 ) &&
( this->hr == 0 ) && ( this->mint == 0 ) )
{
st.wYear = 1900;
st.wMonth = 1;
st.wDayOfWeek = 0;
st.wDay = 1;
st.wHour = 0;
st.wMinute = 0;
st.wSecond = 0;
st.wMilliseconds = 0;
return st;
}
else
{
st.wYear = this->yr;
st.wMonth = this->mon;
st.wDayOfWeek = 0;
st.wDay = this->dom;
st.wHour = this->hr;
st.wMinute = this->mint;
st.wSecond = 0;
st.wMilliseconds = 0;
return st;
}
}
#endif
private:
void setDefaultValues()
{
this->dom = 0;
this->hr = 0;
this->mint = 0;
this->mon = 0;
this->wdy = 0;
this->yr = 0;
}
};
}
This diff is collapsed.
#pragma once
#include "ContentTypes.h"
#include "RevisionData.h"
#include "BookmarkFirst.h"
#include "WideString.h"
#include "PictureDescriptor.h"
#include "VMLPictureMapping.h"
#include "VMLShapeMapping.h"
#include "CharacterPropertyExceptions.h"
#include "TableInfo.h"
#include "TablePropertyExceptions.h"
#include "AbstractOpenXmlMapping.h"
#include "TableRowPropertiesMapping.h"
#include "TableCellPropertiesMapping.h"
#include "OleObject.h"
#include "OleObjectMapping.h"
#include "ConversionContext.h"
#include "IMapping.h"
namespace DocFileFormat
{
class FootnotesMapping;
class CommentsMapping;
struct Symbol
{
wstring FontName;
wstring HexValue;
};
class DocumentMapping: public AbstractOpenXmlMapping, public IMapping
{
friend class Table;
friend class TableRow;
friend class TableCell;
friend class DocParagraph;
public:
DocumentMapping(ConversionContext* context, IMapping* caller);
DocumentMapping(ConversionContext* context, XmlUtils::CXmlWriter* writer, IMapping* caller);
virtual ~DocumentMapping();
virtual void Apply( IVisitable* visited ) = 0;
protected:
/// Looks into the section table to find out if this CP is the end of a section
bool isSectionEnd( int cp );
/// Writes a Paragraph that starts at the given cp and
/// ends at the next paragraph end mark or section end mark
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 );
/// 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 );
/// 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);
void writeTextEnd( const wstring& textType );
/// Searches for bookmarks in the list of characters.
vector<int> searchBookmarks( 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 );
/// 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 );
/// 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 );
/// 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 findCellEndCp( int initialCp, unsigned int nestingLevel );
bool writeBookmarks( int cp );
bool writeBookmarkStart( short id );
bool writeBookmarkEnd( short id );
/// Checks if the CHPX is special
bool isSpecial( CharacterPropertyExceptions* chpx );
/// 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 );
private:
Symbol getSymbol( const CharacterPropertyExceptions* chpx );
bool m_bInternalXmlWriter;
protected:
WordDocument* m_document;
ConversionContext* m_context;
ParagraphPropertyExceptions* _lastValidPapx;
SectionPropertyExceptions* _lastValidSepx;
int _skipRuns;
int _sectionNr;
int _footnoteNr;
int _endnoteNr;
int _commentNr;
bool _writeInstrText;
unsigned int _fldCharCounter;
IMapping* _caller;
};
}
This diff is collapsed.
This diff is collapsed.
#pragma once
#include "../Common/FormatUtils.h"
namespace DocFileFormat
{
class DocumentTypographyInfo
{
friend class SettingsMapping;
private:
/// True if we're kerning punctation
bool fKerningPunct;
/// Kinsoku method of justification:
/// 0 = always expand
/// 1 = compress punctation
/// 2 = compress punctation and kana
short iJustification;
/// Level of kinsoku:
/// 0 = level 1
/// 1 = Level 2
/// 2 = Custom
short iLevelOfKinsoku;
/// "2 page on 1" feature is turned on
bool f2on1;
/// Old East Asian feature
bool fOldDefineLineBaseOnGrid;
/// Custom Kinsoku
short iCustomKsu;
/// When set to true, use strict (level 2) Kinsoku rules
bool fJapaneseUseLevel2;
/// Length of rgxchFPunct
short cchFollowingPunct;
/// Length of rgxchLPunct
short cchLeadingPunct;
/// Array of characters that should never appear at the start of a line
wstring rgxchFPunct;
/// Array of characters that should never appear at the end of a line
wstring rgxchLPunct;
public:
virtual ~DocumentTypographyInfo()
{
}
DocumentTypographyInfo():
fKerningPunct(false), iJustification(0), iLevelOfKinsoku(0), f2on1(false), fOldDefineLineBaseOnGrid(false),
iCustomKsu(0), fJapaneseUseLevel2(false), cchFollowingPunct(0), cchLeadingPunct(0), rgxchFPunct( _T( "" ) ),
rgxchLPunct( _T( "" ) )
{
}
/// Parses the bytes to retrieve a DocumentTypographyInfo
DocumentTypographyInfo( unsigned char* bytes, int size ):
fKerningPunct(false), iJustification(0), iLevelOfKinsoku(0), f2on1(false), fOldDefineLineBaseOnGrid(false),
iCustomKsu(0), fJapaneseUseLevel2(false), cchFollowingPunct(0), cchLeadingPunct(0), rgxchFPunct( _T( "" ) ),
rgxchLPunct( _T( "" ) )
{
if ( size == 310 )
{
//split unsigned char 0 and 1 into bits
this->fKerningPunct = FormatUtils::GetBitFromBytes( bytes, size, 0 );
this->iJustification = (short)FormatUtils::GetUIntFromBytesBits( bytes, size, 1, 2 );
this->iLevelOfKinsoku = (short)FormatUtils::GetUIntFromBytesBits( bytes, size, 3, 2 );
this->f2on1 = FormatUtils::GetBitFromBytes( bytes, size, 5 );
this->fOldDefineLineBaseOnGrid = FormatUtils::GetBitFromBytes( bytes, size, 6 );
this->iCustomKsu = (short)FormatUtils::GetUIntFromBytesBits( bytes, size, 7, 3 );
this->fJapaneseUseLevel2 = FormatUtils::GetBitFromBytes( bytes, size, 10 );
this->cchFollowingPunct = FormatUtils::BytesToInt16( bytes, 2, size );
this->cchLeadingPunct = FormatUtils::BytesToInt16( bytes, 4, size );
unsigned char fpunctBytes[202];
memcpy( fpunctBytes, ( bytes + 6 ), 202 );
FormatUtils::GetSTLCollectionFromBytes<wstring>( &(this->rgxchFPunct), fpunctBytes, 202, ENCODING_UNICODE );
unsigned char lpunctBytes[102];
memcpy( lpunctBytes, ( bytes + 208 ), 102 );
FormatUtils::GetSTLCollectionFromBytes<wstring>( &(this->rgxchLPunct), lpunctBytes, 102, ENCODING_UNICODE );
}
else
{
//throw new ByteParseException("Cannot parse the struct DOPTYPOGRAPHY, the length of the struct doesn't match");
}
}
};
}
#pragma once
namespace DocFileFormat
{
class DrawingObjectGrid
{
friend class SettingsMapping;
private:
/// x-coordinate of the upper left-hand corner of the grid
short xaGrid;
/// y-coordinate of the upper left-hand corner of the grid
short yaGrid;
/// Width of each grid square
short dxaGrid;
/// Height of each grid square
short dyaGrid;
/// The number of grid squares (in the y direction) between each
/// gridline drawn on the screen. 0 means don‘t display any
/// gridlines in the y direction.
short dyGridDisplay;
/// Suppress display of gridlines
bool fTurnItOff;
/// The number of grid squares (in the x direction) between each
/// gridline drawn on the screen. 0 means don‘t display any
/// gridlines in the y direction.
short dxGridDisplay;
/// If true, the grid will start at the left and top margins and
/// ignore xaGrid and yaGrid
bool fFollowMargins;
public:
virtual ~DrawingObjectGrid()
{
}
DrawingObjectGrid():
xaGrid(0), yaGrid(0), dxaGrid(0), dyaGrid(0), dyGridDisplay(0), fTurnItOff(false), dxGridDisplay(0),
fFollowMargins(false)
{
}
/// Parses the bytes to retrieve a DrawingObjectGrid
DrawingObjectGrid( unsigned char* bytes, int size ):
xaGrid(0), yaGrid(0), dxaGrid(0), dyaGrid(0), dyGridDisplay(0), fTurnItOff(false), dxGridDisplay(0),
fFollowMargins(false)
{
if ( size == 10 )
{
this->xaGrid = FormatUtils::BytesToInt16( bytes, 0, size );
this->yaGrid = FormatUtils::BytesToInt16( bytes, 2, size );
this->dxaGrid = FormatUtils::BytesToInt16( bytes, 4, size );
this->dyaGrid = FormatUtils::BytesToInt16( bytes, 6, size );
//split unsigned char 8 and 9 into bits
this->dyGridDisplay = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 8 ), 2, 0, 7 );
this->fTurnItOff = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 7 );
this->dxGridDisplay = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 8 ), 2, 8, 7 );
this->fFollowMargins = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 15 );
}
else
{
//throw new ByteParseException("Cannot parse the struct DOGRID, the length of the struct doesn't match");
}
}
};
}
\ No newline at end of file
#pragma once
namespace DocFileFormat
{
class EmuValue
{
public:
// Creates a new EmuValue for the given value.
EmuValue (int value = 0)
{
m_Value = value;
}
// Converts the EMU to pt
double ToPoints() const
{
return (double) m_Value / 12700.0;
}
// Converts the EMU to twips
inline double ToTwips () const
{
return (double) m_Value / 635.0;
}
inline double ToCm () const
{
return m_Value / 36000.0;
}
inline double ToMm () const
{
return ToCm () * 10.0;
}
inline operator int () const
{
return m_Value;
}
private:
int m_Value;
};
}
\ No newline at end of file
#pragma once
#include "ByteStructure.h"
namespace DocFileFormat
{
class EndnoteDescriptor: public ByteStructure
{
private:
short aEndIdx;
public:
static const int STRUCTURE_SIZE = 2;
EndnoteDescriptor():
aEndIdx(0)
{
}
virtual ~EndnoteDescriptor()
{
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length )
{
EndnoteDescriptor *newObject = new EndnoteDescriptor();
newObject->aEndIdx = reader->ReadInt16();
return static_cast<ByteStructure*>( newObject );
}
};
}
\ No newline at end of file
#pragma once
#include "ContentTypes.h"
#include "WordDocument.h"
#include "DocumentMapping.h"
namespace DocFileFormat
{
class EndnotesMapping: public DocumentMapping
{
public:
EndnotesMapping (ConversionContext* ctx) : DocumentMapping(ctx, this)
{
}
virtual void Apply( IVisitable* visited )
{
m_document = static_cast<WordDocument*>( visited );
if ( ( m_document != NULL ) && ( m_document->FIB->m_RgLw97.ccpEdn > 0 ) )
{
m_context->_docx->RegisterEndnotes();
int id = 0;
m_pXmlWriter->WriteNodeBegin( _T( "?xml version=\"1.0\" encoding=\"UTF-8\"?" ) );
m_pXmlWriter->WriteNodeBegin( _T( "w:endnotes" ), TRUE );
//write namespaces
m_pXmlWriter->WriteAttribute( _T( "xmlns:w" ), OpenXmlNamespaces::WordprocessingML );
m_pXmlWriter->WriteAttribute( _T( "xmlns:v" ), OpenXmlNamespaces::VectorML );
m_pXmlWriter->WriteAttribute( _T( "xmlns:o" ), OpenXmlNamespaces::Office );
m_pXmlWriter->WriteAttribute( _T( "xmlns:w10" ), OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute( _T( "xmlns:r" ), OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
int cp = ( m_document->FIB->m_RgLw97.ccpText + m_document->FIB->m_RgLw97.ccpFtn + m_document->FIB->m_RgLw97.ccpHdr + m_document->FIB->m_RgLw97.ccpAtn );
while ( cp <= ( m_document->FIB->m_RgLw97.ccpText + m_document->FIB->m_RgLw97.ccpFtn + m_document->FIB->m_RgLw97.ccpHdr + m_document->FIB->m_RgLw97.ccpAtn + m_document->FIB->m_RgLw97.ccpEdn - 2 ) )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:endnote" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( id ).c_str() );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
while ( ( cp - m_document->FIB->m_RgLw97.ccpText - m_document->FIB->m_RgLw97.ccpFtn - m_document->FIB->m_RgLw97.ccpHdr - m_document->FIB->m_RgLw97.ccpAtn ) < (*m_document->IndividualEndnotesPlex)[id + 1] )
{
int fc = m_document->FindFileCharPos(cp);
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx );
if ( tai.fInTable )
{
//this PAPX is for a table
Table table( this, cp, ( ( tai.iTap > 0 ) ? ( 1 ) : ( 0 ) ) );
table.Convert( this );
cp = table.GetCPEnd();
}
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph( cp );
}
}
m_pXmlWriter->WriteNodeEnd( _T( "w:endnote" ) );
id++;
}
m_pXmlWriter->WriteNodeEnd( _T( "w:endnotes" ) );
m_context->_docx->EndnotesXML = wstring( m_pXmlWriter->GetXmlString() );
}
}
};
}
\ No newline at end of file
#pragma once
#include "ByteStructure.h"
namespace DocFileFormat
{
class FieldCharacter: public ByteStructure
{
public:
struct grffldEnd
{
unsigned char fDiffer:1;
unsigned char fZombieEmbed:1;
unsigned char fResultsDirty:1;
unsigned char fResultsEdited:1;
unsigned char fLocked:1;
unsigned char fPrivateResult:1;
unsigned char fNested:1;
unsigned char fHasSep:1;
};
public:
static const int STRUCTURE_SIZE = 2;
FieldCharacter():
fldch(0), grffld(0)
{
}
virtual ~FieldCharacter()
{
}
virtual ByteStructure* ConstructObject (VirtualStreamReader* pReader, int length)
{
FieldCharacter* pFldChar = new FieldCharacter();
if (pFldChar)
{
pFldChar->fldch = pReader->ReadByte();
pFldChar->grffld = pReader->ReadByte();
#ifdef _DEBUG
grffldEnd* __grffldEnd = (grffldEnd*)(&pFldChar->grffld);
int dbg = 0;
#endif
}
return static_cast<ByteStructure*>(pFldChar);
}
private:
unsigned char fldch;
unsigned char grffld;
};
}
\ No newline at end of file
This diff is collapsed.
#pragma once
namespace DocFileFormat
{
/// Specifies an approximation of a real number, where the approximation has a fixed number of digits after the radix point.
///
/// This type is specified in [MS-OSHARED] section 2.2.1.6.
///
/// Value of the real number = Integral + ( Fractional / 65536.0 )
///
/// Integral (2 bytes): A signed integer that specifies the integral part of the real number.
/// Fractional (2 bytes): An unsigned integer that specifies the fractional part of the real number.
class FixedPointNumber
{
public:
unsigned short Integral;
unsigned short Fractional;
FixedPointNumber( unsigned short integral = 0, unsigned short fractional = 0 )
{
this->Integral = integral;
this->Fractional = fractional;
}
FixedPointNumber( unsigned int value )
{
unsigned char* bytes = FormatUtils::GetBytes( value );
this->Integral = FormatUtils::BytesToUInt16( bytes, 0, sizeof(value) );
this->Fractional = FormatUtils::BytesToUInt16( bytes, 2, sizeof(value) );
RELEASEARRAYOBJECTS( bytes );
}
FixedPointNumber( const unsigned char* bytes, unsigned int size )
{
if ( ( bytes != NULL ) && ( size >= 4 ) )
{
this->Integral = FormatUtils::BytesToUInt16( bytes, 0, size );
this->Fractional = FormatUtils::BytesToUInt16( bytes, 2, size );
}
}
double ToAngle() const
{
if ( this->Fractional != 0 )
{
// negative angle
return ( this->Fractional - 65536.0 );
}
else if ( this->Integral != 0 )
{
//positive angle
return ( 65536.0 - this->Integral );
}
else
{
return 0.0;
}
}
double GetValue() const
{
return (double)( this->Integral + ( (double)this->Fractional / 65536.0 ) );
}
};
}
\ No newline at end of file
This diff is collapsed.
#pragma once
#include "VirtualStreamReader.h"
#include "ByteStructure.h"
namespace DocFileFormat
{
typedef struct FontSignature
{
unsigned int UnicodeSubsetBitfield0;
unsigned int UnicodeSubsetBitfield1;
unsigned int UnicodeSubsetBitfield2;
unsigned int UnicodeSubsetBitfield3;
unsigned int CodePageBitfield0;
unsigned int CodePageBitfield1;
} FontSignature;
class FontFamilyName: public ByteStructure
{
friend class CharacterPropertiesMapping;
friend class DocumentMapping;
friend class FontTableMapping;
friend class StyleSheetMapping;
private:
/// When true, font is a TrueType font
bool fTrueType;
/// Font family id
unsigned char ff;
/// Base weight of font
short wWeight;
/// Character set identifier
unsigned char chs;
/// Pitch request
unsigned char prq;
/// Name of font
wstring xszFtn;
/// Alternative name of the font
wstring xszAlt;
/// Panose
unsigned char *panose;
/// Panose size
unsigned int panoseSize;
/// Font sinature
FontSignature fs;
public:
FontFamilyName();
virtual ~FontFamilyName();
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length );
private:
long searchTerminationZero( VirtualStreamReader *reader );
};
}
This diff is collapsed.
#pragma once
#include "StringTable.h"
#include "FontFamilyName.h"
#include "ContentTypes.h"
#include "AbstractOpenXmlMapping.h"
#include "ConversionContext.h"
#include "IMapping.h"
namespace DocFileFormat
{
static const wchar_t FontFamily[6][11] =
{
_T( "auto" ),
_T( "roman" ),
_T( "swiss" ),
_T( "modern" ),
_T( "script" ),
_T( "decorative" )
};
static const wchar_t FontPitch[3][9] =
{
_T( "default" ),
_T( "fixed" ),
_T( "variable" )
};
class FontTableMapping: public AbstractOpenXmlMapping, public IMapping
{
private:
ConversionContext* _ctx;
public:
FontTableMapping( ConversionContext* ctx );
virtual ~FontTableMapping();
virtual void Apply( IVisitable* visited );
};
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment