From de899687bb5ea3350489dd8e896107edd21d8b93 Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Sun, 26 Jun 2016 17:37:17 +0300 Subject: [PATCH] =?UTF-8?q?DocFormatReader=20-=20=D0=B4=D0=B5=D1=88=D0=B8?= =?UTF-8?q?=D1=84=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20+=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA=D0=B0=20=D1=84=D0=BE?= =?UTF-8?q?=D1=80=D0=BC=D0=B0=D1=82=D0=B0=2095=20=D0=B3=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ASCOfficeDocFile/Common/FormatUtils.h | 191 ++- ASCOfficeDocFile/Common/MD4/global.h | 43 - ASCOfficeDocFile/Common/MD4/md4.h | 91 -- ASCOfficeDocFile/Common/MD4/md4c.cpp | 280 ---- ASCOfficeDocFile/Common/MD4/md4c.h | 39 - ASCOfficeDocFile/Common/XmlTools.h | 76 +- .../DocDocxConverter/AnnotationOwnerList.h | 9 +- .../AnnotationReferenceDescriptor.cpp | 2 +- .../DocDocxConverter/BorderCode.h | 4 +- .../CharacterPropertiesMapping.cpp | 14 +- .../CharacterPropertiesMapping.h | 9 +- .../CharacterPropertyExceptions.h | 3 +- .../DocDocxConverter/ConversionContext.h | 4 +- .../DocDocxConverter/Converter.cpp | 51 +- ASCOfficeDocFile/DocDocxConverter/Converter.h | 23 +- .../DocDocxConverter/DocumentMapping.cpp | 240 +-- .../DocDocxConverter/DocumentMapping.h | 30 +- .../DocDocxConverter/DocumentProperties.cpp | 1326 ++++++++--------- .../DocDocxConverter/DocumentTypographyInfo.h | 8 +- .../DocDocxConverter/EndnotesMapping.h | 2 +- .../DocDocxConverter/FileInformationBlock.h | 1098 +++++++++----- .../DocDocxConverter/FontFamilyName.cpp | 87 +- .../DocDocxConverter/FontFamilyName.h | 4 +- .../DocDocxConverter/FontTableMapping.cpp | 8 +- .../DocDocxConverter/FooterMapping.cpp | 2 +- .../DocDocxConverter/FootnotesMapping.h | 2 +- .../FormattedDiskPageCHPX.cpp | 75 +- .../DocDocxConverter/FormattedDiskPageCHPX.h | 4 +- .../FormattedDiskPagePAPX.cpp | 101 +- .../DocDocxConverter/FormattedDiskPagePAPX.h | 8 +- .../DocDocxConverter/HeaderAndFooterTable.cpp | 9 +- .../DocDocxConverter/HeaderMapping.cpp | 2 +- .../DocDocxConverter/LanguageIdMapping.cpp | 4 +- .../DocDocxConverter/LanguageIdMapping.h | 2 +- .../DocDocxConverter/ListData.cpp | 4 +- ASCOfficeDocFile/DocDocxConverter/ListData.h | 4 +- .../DocDocxConverter/ListFormatOverride.h | 6 +- .../ListFormatOverrideTable.h | 8 +- .../DocDocxConverter/ListLevel.cpp | 14 +- ASCOfficeDocFile/DocDocxConverter/ListLevel.h | 4 +- .../DocDocxConverter/ListTable.cpp | 6 +- ASCOfficeDocFile/DocDocxConverter/ListTable.h | 2 +- .../DocDocxConverter/MainDocumentMapping.cpp | 48 +- .../DocDocxConverter/NumberingMapping.cpp | 20 +- .../DocDocxConverter/NumberingMapping.h | 4 +- .../DocDocxConverter/OfficeArtContent.h | 13 +- .../OfficeDrawing/ChildAnchor.h | 4 +- .../OfficeDrawing/DrawingGroupRecord.h | 2 +- .../OfficeDrawing/GroupShapeRecord.h | 4 +- .../OfficeDrawing/PathParser.h | 2 +- .../OfficeDrawing/RegularContainer.h | 6 +- .../OfficeDrawing/ShapeContainer.h | 10 +- .../OfficeDrawing/ShapeOptions.h | 8 +- ASCOfficeDocFile/DocDocxConverter/OleObject.h | 94 +- .../DocDocxConverter/OleObjectMapping.h | 26 +- .../DocDocxConverter/OpenXmlPackage.cpp | 47 +- .../DocDocxConverter/OpenXmlPackage.h | 65 +- .../ParagraphPropertiesMapping.cpp | 6 +- .../ParagraphPropertyExceptions.cpp | 12 +- .../ParagraphPropertyExceptions.h | 9 +- .../DocDocxConverter/PictureDescriptor.cpp | 17 +- .../DocDocxConverter/PictureDescriptor.h | 11 +- .../DocDocxConverter/PieceDescriptor.h | 13 +- .../DocDocxConverter/PieceTable.cpp | 75 +- .../DocDocxConverter/PieceTable.h | 5 +- ASCOfficeDocFile/DocDocxConverter/Plex.h | 13 +- .../DocDocxConverter/PropertiesMapping.cpp | 407 ++--- .../DocDocxConverter/PropertiesMapping.h | 10 +- .../DocDocxConverter/PropertyExceptions.cpp | 179 ++- .../DocDocxConverter/PropertyExceptions.h | 2 +- ASCOfficeDocFile/DocDocxConverter/RGBColor.h | 4 +- .../SectionPropertiesMapping.cpp | 12 +- .../SectionPropertiesMapping.h | 4 +- .../SectionPropertyExceptions.h | 6 +- .../DocDocxConverter/SettingsMapping.cpp | 4 +- .../DocDocxConverter/SprmTDefTable.h | 4 +- .../DocDocxConverter/StringTable.h | 254 ++-- .../StructuredStorageReader.h | 8 +- .../DocDocxConverter/StyleSheet.cpp | 8 +- .../DocDocxConverter/StyleSheet.h | 2 +- .../StyleSheetDescription.cpp | 53 +- .../DocDocxConverter/StyleSheetDescription.h | 4 +- .../DocDocxConverter/StyleSheetMapping.cpp | 34 +- .../DocDocxConverter/StyleSheetMapping.h | 6 +- .../TableCellPropertiesMapping.cpp | 7 +- .../TableCellPropertiesMapping.h | 12 +- ASCOfficeDocFile/DocDocxConverter/TableInfo.h | 2 +- .../DocDocxConverter/TableMapping.cpp | 35 +- .../DocDocxConverter/TableMapping.h | 10 +- .../TablePropertiesMapping.cpp | 14 +- .../DocDocxConverter/TablePropertiesMapping.h | 6 +- .../TablePropertyExceptions.h | 14 +- .../TableRowPropertiesMapping.cpp | 2 +- .../DocDocxConverter/TextboxMapping.cpp | 1 + .../DocDocxConverter/VMLPictureMapping.cpp | 36 +- .../DocDocxConverter/VMLPictureMapping.h | 2 +- .../DocDocxConverter/VMLShapeMapping.cpp | 26 +- .../DocDocxConverter/VMLShapeMapping.h | 66 +- .../DocDocxConverter/VMLShapeTypeMapping.cpp | 8 +- .../DocDocxConverter/VMLShapeTypeMapping.h | 2 +- .../DocDocxConverter/VirtualStreamReader.h | 71 +- .../DocDocxConverter/WideString.h | 16 +- .../DocDocxConverter/WordDocument.cpp | 856 ++++++----- .../DocDocxConverter/WordDocument.h | 210 ++- .../WordprocessingDocument.cpp | 40 +- .../DocDocxConverter/WordprocessingDocument.h | 30 +- .../DocFormatLib/DocFormatLib.cpp | 8 +- ASCOfficeDocFile/DocFormatLib/DocFormatLib.h | 6 +- .../DocFormatLib/Linux/DocFormatLib.pro | 3 - .../DocFormatLib/Win32/DocFormatLib.vcproj | 36 +- .../DocFormatTest/DocFormatTest.cpp | 12 +- .../DocFormatTest/DocFormatTest.vcproj | 4 + ASCOfficeDocFile/DocxDocConverter/Spa.h | 2 +- ASCOfficeDocFile/Win32/ASCDocFile.cpp | 7 +- .../Win32/ASCOfficeDocFile2005.vcproj | 28 + .../Win32/OfficeDocFile_VS2005.sln | 462 ++++-- .../source/XlsFormat/Crypt/RC4Crypt.cpp | 2 +- X2tConverter/src/ASCConverters.cpp | 5 +- 118 files changed, 3963 insertions(+), 3492 deletions(-) delete mode 100644 ASCOfficeDocFile/Common/MD4/global.h delete mode 100644 ASCOfficeDocFile/Common/MD4/md4.h delete mode 100644 ASCOfficeDocFile/Common/MD4/md4c.cpp delete mode 100644 ASCOfficeDocFile/Common/MD4/md4c.h diff --git a/ASCOfficeDocFile/Common/FormatUtils.h b/ASCOfficeDocFile/Common/FormatUtils.h index f8ad3d2fb2..09bd7f3aed 100644 --- a/ASCOfficeDocFile/Common/FormatUtils.h +++ b/ASCOfficeDocFile/Common/FormatUtils.h @@ -47,8 +47,6 @@ #include "utf8.h" -using namespace std; - #if defined(_WIN32) || defined(_WIN64) #include #include @@ -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_Pair; + typedef std::pair 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( "&" ) ); + result = std::wstring( _T( "&" ) ); } break; case _T( '<' ): { - result = wstring( _T( "<" ) ); + result = std::wstring( _T( "<" ) ); } break; case _T( '>' ): { - result = wstring( _T( ">" ) ); + result = std::wstring( _T( ">" ) ); } break; case _T( '\"' ): { - result = wstring( _T( """ ) ); + result = std::wstring( _T( """ ) ); } break; case _T( '\'' ): { - result = wstring( _T( "'" ) ); + result = std::wstring( _T( "'" ) ); } 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 static bool GetSTLCollectionFromBytes( T *STLCollection, unsigned char *bytes, int size, Encoding encoding ) + template 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 const &facet = std::use_facet >(loc); - if ( encoding == ENCODING_UNICODE ) + 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 static bool GetSTLCollectionFromUtf8( T *STLCollection, unsigned char *bytes, int size) + { + if ( ( STLCollection == NULL ) || ( bytes == NULL ) ) + { + return false; + } + if (sizeof(wchar_t) == 2)//utf8 -> utf16 + { + unsigned int nLength = size; + + UTF16 *pStrUtf16 = new UTF16 [nLength+1]; + memset ((void *) pStrUtf16, 0, sizeof (UTF16) * (nLength+1)); + + UTF8 *pStrUtf8 = (UTF8 *) bytes; + + // this values will be modificated + const UTF8 *pStrUtf8_Conv = pStrUtf8; + UTF16 *pStrUtf16_Conv = pStrUtf16; + + ConversionResult eUnicodeConversionResult = ConvertUTF8toUTF16 (&pStrUtf8_Conv, &pStrUtf8[nLength] + , &pStrUtf16_Conv, &pStrUtf16 [nLength] + , strictConversion); + + if (conversionOK != eUnicodeConversionResult) + { + delete [] pStrUtf16; + return GetSTLCollectionFromLocale(STLCollection, bytes,size); + } + for (long i=0; i < nLength; i++) + { + STLCollection->push_back(pStrUtf16[i]); + } + delete [] pStrUtf16; + return true; + } + else //utf8 -> utf32 + { + unsigned int nLength = size; + + UTF32 *pStrUtf32 = new UTF32 [nLength+1]; + memset ((void *) pStrUtf32, 0, sizeof (UTF32) * (nLength+1)); + + + UTF8 *pStrUtf8 = (UTF8 *) bytes; + + // this values will be modificated + const UTF8 *pStrUtf8_Conv = pStrUtf8; + UTF32 *pStrUtf32_Conv = pStrUtf32; + + ConversionResult eUnicodeConversionResult = ConvertUTF8toUTF32 (&pStrUtf8_Conv, &pStrUtf8[nLength] + , &pStrUtf32_Conv, &pStrUtf32 [nLength] + , strictConversion); + + if (conversionOK != eUnicodeConversionResult) + { + delete [] pStrUtf32; + return GetSTLCollectionFromLocale(STLCollection, bytes, size); + } + for (long i=0; i < nLength; i++) + { + STLCollection->push_back(pStrUtf32[i]); + } + delete [] pStrUtf32; + return true; + } + } + + template 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 bits( mask ); + std::bitset 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; diff --git a/ASCOfficeDocFile/Common/MD4/global.h b/ASCOfficeDocFile/Common/MD4/global.h deleted file mode 100644 index 87c2333c73..0000000000 --- a/ASCOfficeDocFile/Common/MD4/global.h +++ /dev/null @@ -1,43 +0,0 @@ -#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 - #include -#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 diff --git a/ASCOfficeDocFile/Common/MD4/md4.h b/ASCOfficeDocFile/Common/MD4/md4.h deleted file mode 100644 index 1399ea48d8..0000000000 --- a/ASCOfficeDocFile/Common/MD4/md4.h +++ /dev/null @@ -1,91 +0,0 @@ -#pragma once - -#include -#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 GetMD4Bytes() const - { - std::vector 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 diff --git a/ASCOfficeDocFile/Common/MD4/md4c.cpp b/ASCOfficeDocFile/Common/MD4/md4c.cpp deleted file mode 100644 index 58fe2f157c..0000000000 --- a/ASCOfficeDocFile/Common/MD4/md4c.cpp +++ /dev/null @@ -1,280 +0,0 @@ - -/* 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; -} diff --git a/ASCOfficeDocFile/Common/MD4/md4c.h b/ASCOfficeDocFile/Common/MD4/md4c.h deleted file mode 100644 index deec3d1fb5..0000000000 --- a/ASCOfficeDocFile/Common/MD4/md4c.h +++ /dev/null @@ -1,39 +0,0 @@ -#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 diff --git a/ASCOfficeDocFile/Common/XmlTools.h b/ASCOfficeDocFile/Common/XmlTools.h index da22ee3e2e..08398e6880 100644 --- a/ASCOfficeDocFile/Common/XmlTools.h +++ b/ASCOfficeDocFile/Common/XmlTools.h @@ -35,8 +35,6 @@ #include #include -using namespace std; - #if defined(_WIN32) || defined(_WIN64) #include #include @@ -67,8 +65,8 @@ namespace XMLTools template class XMLAttribute { private: - basic_string m_Name; - basic_string m_Value; + std::basic_string m_Name; + std::basic_string m_Value; public: @@ -99,33 +97,33 @@ namespace XMLTools void SetValue( const T* value ) { - m_Value = basic_string( value ); + m_Value = std::basic_string( value ); } /*========================================================================================================*/ - basic_string GetName() const + std::basic_string GetName() const { return m_Name; } /*========================================================================================================*/ - basic_string GetValue() const + std::basic_string GetValue() const { return m_Value; } /*========================================================================================================*/ - basic_string GetXMLString() + std::basic_string GetXMLString() { - basic_string xmlString( _T( "" ) ); + std::basic_string xmlString( _T( "" ) ); xmlString += m_Name; - xmlString += basic_string( _T( "=\"" ) ); + xmlString += std::basic_string( _T( "=\"" ) ); xmlString += m_Value; - xmlString += basic_string( _T( "\"" ) ); + xmlString += std::basic_string( _T( "\"" ) ); return xmlString; } @@ -137,19 +135,19 @@ namespace XMLTools template class XMLElement { - typedef pair< basic_string, basic_string > AttributeValuePair; + typedef std::pair< std::basic_string, std::basic_string > AttributeValuePair; private: - basic_string m_Name; - basic_string m_ElementText; - map, basic_string> m_AttributeMap; - list> m_Elements; + std::basic_string m_Name; + std::basic_string m_ElementText; + std::map, std::basic_string> m_AttributeMap; + std::list> m_Elements; - typedef typename list>::iterator ElementsIterator; - typedef typename list>::const_iterator ElementsIteratorConst; + typedef typename std::list>::iterator ElementsIterator; + typedef typename std::list>::const_iterator ElementsIteratorConst; - typedef typename map, basic_string>::iterator AttMapIterator; - typedef typename map, basic_string>::const_iterator AttMapIteratorConst; + typedef typename std::map, std::basic_string>::iterator AttMapIterator; + typedef typename std::map, std::basic_string>::const_iterator AttMapIteratorConst; public: @@ -167,7 +165,7 @@ namespace XMLTools /*========================================================================================================*/ - XMLElement( const T* prefix, const T* localName ) : m_Name( basic_string( prefix ) + basic_string( _T( ":" ) ) + basic_string( localName ) ), m_ElementText( _T( "" ) ) + XMLElement( const T* prefix, const T* localName ) : m_Name( std::basic_string( prefix ) + std::basic_string( _T( ":" ) ) + std::basic_string( localName ) ), m_ElementText( _T( "" ) ) { } @@ -183,14 +181,14 @@ namespace XMLTools void AppendText( const T* text ) { - m_ElementText = basic_string( text ); + m_ElementText = std::basic_string( text ); } /*========================================================================================================*/ void AppendTextSymbol( const T symbol ) { - m_ElementText += basic_string( &symbol ); + m_ElementText += std::basic_string( &symbol ); } /*========================================================================================================*/ @@ -206,7 +204,7 @@ namespace XMLTools void AppendAttribute( const T* name, const T* value ) { - AttributeValuePair p( basic_string( const_cast( name ) ), basic_string( const_cast( value ) ) ); + AttributeValuePair p( std::basic_string( const_cast( name ) ), std::basic_string( const_cast( 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( elementName ) ) + if ( iter->m_Name == std::basic_string( elementName ) ) { result = true; @@ -265,7 +263,7 @@ namespace XMLTools /*========================================================================================================*/ - bool RemoveChildByName( const basic_string& elementName ) + bool RemoveChildByName( const std::basic_string& elementName ) { bool result = false; @@ -334,34 +332,34 @@ namespace XMLTools /*========================================================================================================*/ - basic_string GetName() const + std::basic_string GetName() const { return m_Name; } /*========================================================================================================*/ - basic_string GetXMLString() + std::basic_string GetXMLString() { - basic_string xmlString( _T( "" ) ); + std::basic_string xmlString( _T( "" ) ); - bool bIsNameExists = ( m_Name != basic_string( _T( "" ) ) ); - bool bIsTextExists = ( m_ElementText != basic_string( _T( "" ) ) ); + bool bIsNameExists = ( m_Name != std::basic_string( _T( "" ) ) ); + bool bIsTextExists = ( m_ElementText != std::basic_string( _T( "" ) ) ); if ( bIsNameExists ) { - xmlString += basic_string( _T( "<" ) ) + m_Name; + xmlString += std::basic_string( _T( "<" ) ) + m_Name; } if ( ( bIsNameExists ) && ( m_AttributeMap.size() > 0 ) ) { for ( AttMapIterator iter = m_AttributeMap.begin(); iter != m_AttributeMap.end(); iter++ ) { - xmlString += basic_string( _T( " " ) ); + xmlString += std::basic_string( _T( " " ) ); xmlString += iter->first; - xmlString += basic_string( _T( "=\"" ) ); + xmlString += std::basic_string( _T( "=\"" ) ); xmlString += iter->second; - xmlString += basic_string( _T( "\"" ) ); + xmlString += std::basic_string( _T( "\"" ) ); } } @@ -369,7 +367,7 @@ namespace XMLTools { if ( bIsNameExists ) { - xmlString += basic_string( _T( ">" ) ); + xmlString += std::basic_string( _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( "( _T( ">" ) ); + xmlString += std::basic_string( _T( ">" ) ); } } else { if ( bIsNameExists ) { - xmlString += basic_string( _T( "/>" ) ); + xmlString += std::basic_string( _T( "/>" ) ); } } diff --git a/ASCOfficeDocFile/DocDocxConverter/AnnotationOwnerList.h b/ASCOfficeDocFile/DocDocxConverter/AnnotationOwnerList.h index b6afd0ca49..2f8bedb27b 100644 --- a/ASCOfficeDocFile/DocDocxConverter/AnnotationOwnerList.h +++ b/ASCOfficeDocFile/DocDocxConverter/AnnotationOwnerList.h @@ -36,12 +36,15 @@ namespace DocFileFormat { - class AnnotationOwnerList: public vector + class AnnotationOwnerList: public std::vector { public: - AnnotationOwnerList(FileInformationBlock* fib, POLE::Stream* tableStream) : std::vector() + AnnotationOwnerList(FileInformationBlock* fib, POLE::Stream* tableStream) : std::vector() { - 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()); diff --git a/ASCOfficeDocFile/DocDocxConverter/AnnotationReferenceDescriptor.cpp b/ASCOfficeDocFile/DocDocxConverter/AnnotationReferenceDescriptor.cpp index 8425a94c1b..3a89650009 100644 --- a/ASCOfficeDocFile/DocDocxConverter/AnnotationReferenceDescriptor.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/AnnotationReferenceDescriptor.cpp @@ -43,7 +43,7 @@ namespace DocFileFormat unsigned char *chars = reader->ReadBytes(18, true); - FormatUtils::GetSTLCollectionFromBytes( &(newObject->m_UserInitials), chars, ( cch * 2 ), ENCODING_UNICODE); + FormatUtils::GetSTLCollectionFromBytes( &(newObject->m_UserInitials), chars, ( cch * 2 ), ENCODING_UTF16); newObject->m_AuthorIndex = reader->ReadUInt16(); diff --git a/ASCOfficeDocFile/DocDocxConverter/BorderCode.h b/ASCOfficeDocFile/DocDocxConverter/BorderCode.h index f73e4123c7..8de709920f 100644 --- a/ASCOfficeDocFile/DocDocxConverter/BorderCode.h +++ b/ASCOfficeDocFile/DocDocxConverter/BorderCode.h @@ -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]; diff --git a/ASCOfficeDocFile/DocDocxConverter/CharacterPropertiesMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/CharacterPropertiesMapping.cpp index d6fc793282..20479a77c7 100644 --- a/ASCOfficeDocFile/DocDocxConverter/CharacterPropertiesMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/CharacterPropertiesMapping.cpp @@ -115,7 +115,7 @@ namespace DocFileFormat /*========================================================================================================*/ - void CharacterPropertiesMapping::convertSprms( list* sprms, XMLTools::XMLElement* parent ) + void CharacterPropertiesMapping::convertSprms( std::list* sprms, XMLTools::XMLElement* parent ) { XMLTools::XMLElement * rFonts = new XMLTools::XMLElement ( _T( "w:rFonts" ) ); XMLTools::XMLElement * color = new XMLTools::XMLElement ( _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( _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* ascii = new XMLTools::XMLAttribute( _T( "w:ascii" ) ); FontFamilyName* ffn = static_cast( _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* eastAsia = new XMLTools::XMLAttribute( _T( "w:eastAsia" ) ); FontFamilyName* ffn = static_cast( _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* ansi = new XMLTools::XMLAttribute( _T( "w:hAnsi" ) ); FontFamilyName* ffn = static_cast( _doc->FontTable->operator [] ( nIndex ) ); @@ -527,9 +527,9 @@ namespace DocFileFormat /*========================================================================================================*/ - list CharacterPropertiesMapping::buildHierarchy( const StyleSheet* styleSheet, unsigned short istdStart ) + std::list CharacterPropertiesMapping::buildHierarchy( const StyleSheet* styleSheet, unsigned short istdStart ) { - list hierarchy; + std::list hierarchy; unsigned int istd = (unsigned int)istdStart; bool goOn = true; diff --git a/ASCOfficeDocFile/DocDocxConverter/CharacterPropertiesMapping.h b/ASCOfficeDocFile/DocDocxConverter/CharacterPropertiesMapping.h index 65f9fdbf26..2ce702b6de 100644 --- a/ASCOfficeDocFile/DocDocxConverter/CharacterPropertiesMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/CharacterPropertiesMapping.h @@ -63,8 +63,8 @@ namespace DocFileFormat bool _webHidden; bool _isRTL; private: - void convertSprms( list* sprms, XMLTools::XMLElement* parent ); - list buildHierarchy( const StyleSheet* styleSheet, unsigned short istdStart ); + void convertSprms( std::list* sprms, XMLTools::XMLElement* parent ); + std::list 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 _hierarchy; + ParagraphPropertyExceptions* _currentPapx; + std::list _hierarchy; bool _isRunStyleNeeded; bool _isOwnRPr; diff --git a/ASCOfficeDocFile/DocDocxConverter/CharacterPropertyExceptions.h b/ASCOfficeDocFile/DocDocxConverter/CharacterPropertyExceptions.h index bb434ea1b6..435a3c0211 100644 --- a/ASCOfficeDocFile/DocDocxConverter/CharacterPropertyExceptions.h +++ b/ASCOfficeDocFile/DocDocxConverter/CharacterPropertyExceptions.h @@ -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 ) { } }; diff --git a/ASCOfficeDocFile/DocDocxConverter/ConversionContext.h b/ASCOfficeDocFile/DocDocxConverter/ConversionContext.h index 5b2d8bb584..d70a46cdd4 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ConversionContext.h +++ b/ASCOfficeDocFile/DocDocxConverter/ConversionContext.h @@ -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 AllRsids; + std::set AllRsids; }; } \ No newline at end of file diff --git a/ASCOfficeDocFile/DocDocxConverter/Converter.cpp b/ASCOfficeDocFile/DocDocxConverter/Converter.cpp index ac597fc25d..5f631e6431 100644 --- a/ASCOfficeDocFile/DocDocxConverter/Converter.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/Converter.cpp @@ -32,6 +32,21 @@ #include "Converter.h" +#include "WordDocument.h" + +#include "TableMapping.h" + +#include "StyleSheetMapping.h" +#include "FontTableMapping.h" +#include "FootnotesMapping.h" +#include "EndnotesMapping.h" +#include "NumberingMapping.h" +#include "CommentsMapping.h" +#include "SettingsMapping.h" +#include "MainDocumentMapping.h" +#include "WordprocessingDocument.h" +#include "ConversionContext.h" + namespace DocFileFormat { @@ -51,8 +66,11 @@ namespace DocFileFormat ConversionContext context( doc, docx ); //Write numbering.xml - NumberingMapping numberingMapping( &context ); - doc->listTable->Convert( &numberingMapping ); + if (doc->listTable) + { + NumberingMapping numberingMapping( &context ); + doc->listTable->Convert( &numberingMapping ); + } if ( progress != NULL ) { @@ -85,8 +103,11 @@ namespace DocFileFormat } //Write styles.xml - StyleSheetMapping styleSheetMapping( &context ); - doc->Styles->Convert( &styleSheetMapping ); + if (doc->Styles) + { + StyleSheetMapping styleSheetMapping( &context ); + doc->Styles->Convert( &styleSheetMapping ); + } if ( progress != NULL ) { @@ -102,8 +123,11 @@ namespace DocFileFormat } //Write fontTable.xml - FontTableMapping fontTableMapping( &context ); - doc->FontTable->Convert( &fontTableMapping ); + if (doc->FontTable) + { + FontTableMapping fontTableMapping( &context ); + doc->FontTable->Convert( &fontTableMapping ); + } if ( progress != NULL ) { @@ -170,8 +194,11 @@ namespace DocFileFormat } //write settings.xml at last because of the rsid list - SettingsMapping settingsMapping( &context ); - doc->DocProperties->Convert( &settingsMapping ); + if (doc->DocProperties) + { + SettingsMapping settingsMapping( &context ); + doc->DocProperties->Convert( &settingsMapping ); + } if ( progress != NULL ) { @@ -189,16 +216,14 @@ namespace DocFileFormat return S_OK; } - long Converter::LoadAndConvert(const CString& strSrcFile, const CString& strDstDirectory, const ProgressCallback* progress) + long Converter::LoadAndConvert(const std::wstring& strSrcFile, const std::wstring& strDstDirectory, const std::wstring& password, const ProgressCallback* progress) { - long result = S_FALSE; - - WordDocument doc(strSrcFile); + WordDocument doc(progress, m_sTempFolder); WordprocessingDocument docx(strDstDirectory, &doc); - result = doc.LoadDocument(progress); + result = doc.LoadDocument(strSrcFile, password); if (result == S_OK) { diff --git a/ASCOfficeDocFile/DocDocxConverter/Converter.h b/ASCOfficeDocFile/DocDocxConverter/Converter.h index a7a2a3675b..eb5ad8c75e 100644 --- a/ASCOfficeDocFile/DocDocxConverter/Converter.h +++ b/ASCOfficeDocFile/DocDocxConverter/Converter.h @@ -31,30 +31,25 @@ */ #pragma once -#include "WordDocument.h" +#include -#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); }; diff --git a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp index e79dc85118..639d9c9b95 100755 --- a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp @@ -154,7 +154,7 @@ namespace DocFileFormat // Writes a Paragraph that starts at the given cpStart and // ends at the given cpEnd - int DocumentMapping::writeParagraph (int initialCp, int cpEnd, bool sectionEnd) + int DocumentMapping::writeParagraph (int initialCp, int cpEnd, bool sectionEnd, bool lastBad) { int cp = initialCp; int fc = m_document->FindFileCharPos(cp); @@ -223,18 +223,24 @@ namespace DocFileFormat } } - if ((chpxs != NULL) && (chpxFcs != NULL) && !chpxFcs->empty()) + if ((chpxs != NULL) && (chpxFcs != NULL) && !chpxFcs->empty())//? второе { int i = 0; // write a runs for each CHPX + std::list::iterator cpeIter_last = chpxs->end(); cpeIter_last--; for (std::list::iterator cpeIter = chpxs->begin(); cpeIter != chpxs->end(); ++cpeIter) { //get the FC range for this run - int fcChpxStart = chpxFcs->at(i); - int fcChpxEnd = chpxFcs->at(i + 1); + int fcChpxStart = chpxFcs ? chpxFcs->at(i) : fc; + int fcChpxEnd = chpxFcs ? chpxFcs->at(i + 1) : fcEnd; + + //? if (lastBad && cpeIter == cpeIter_last) + //? { + //? fcChpxEnd = fcEnd; + //? } //it's the first chpx and it starts before the paragraph @@ -253,20 +259,7 @@ namespace DocFileFormat } //read the chars that are formatted via this CHPX - - std::vector* chpxChars = m_document->m_PieceTable->GetChars(fcChpxStart, fcChpxEnd, cp, m_document->WordDocumentStream); - -#ifdef _DEBUG - if (0) - { - //ATLTRACE(L"fcBegin : %d, fcEnd : %d\n", fcChpxStart, fcChpxEnd); - for (size_t j = 0; j < chpxChars->size(); ++j) - { - //ATLTRACE (L"%c", chpxChars->operator [](j)); - //ATLTRACE(L"\n"); - } - } -#endif + std::vector* chpxChars = m_document->GetChars(fcChpxStart, fcChpxEnd, cp); //search for bookmarks in the chars std::vector bookmarks = searchBookmarks(chpxChars, cp); @@ -274,10 +267,10 @@ namespace DocFileFormat //if there are bookmarks in this run, split the run into several runs if (bookmarks.size()) { - std::list>* runs = splitCharList(chpxChars, &bookmarks); + std::list>* runs = splitCharList(chpxChars, &bookmarks); if (runs) { - for (std::list >::iterator iter = runs->begin(); iter != runs->end(); ++iter) + for (std::list >::iterator iter = runs->begin(); iter != runs->end(); ++iter) { if (writeBookmarks(cp)) { @@ -518,23 +511,39 @@ namespace DocFileFormat int cpFieldStart = initialCp + i; int cpFieldEnd = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::FieldEndMark ); - std::wstring f( ( m_document->Text->begin() + cpFieldStart ), ( m_document->Text->begin() + cpFieldEnd + 1 ) ); - std::wstring embed ( _T( " EMBED" ) ); - std::wstring link ( _T( " LINK" ) ); - std::wstring form ( _T( " FORM" ) ); - std::wstring excel ( _T( " Excel" ) ); - std::wstring word ( _T( " Word" ) ); - std::wstring equation ( _T( " Equation" ) ) ; - std::wstring mergeformat( _T( " MERGEFORMAT" ) ); - std::wstring quote ( _T( " QUOTE" ) ); + std::wstring f; + if (cpFieldEnd < m_document->Text->size()) + f = std::wstring( ( m_document->Text->begin() + cpFieldStart ), ( m_document->Text->begin() + cpFieldEnd + 1 ) ); + + std::wstring EMBED ( _T( " EMBED" ) ); + std::wstring LINK ( _T( " LINK" ) ); + std::wstring FORM ( _T( " FORM" ) ); + std::wstring Excel ( _T( " Excel" ) ); + std::wstring Word ( _T( " Word" ) ); + std::wstring opendocument(_T( " opendocument" ) ); + std::wstring Equation ( _T( " Equation" ) ) ; + std::wstring MERGEFORMAT( _T( " MERGEFORMAT" ) ); + std::wstring QUOTE ( _T( " QUOTE" ) ); std::wstring chart ( _T( "Chart" ) ); std::wstring PBrush ( _T( " PBrush" ) ); std::wstring TOC ( _T( " TOC" ) ); std::wstring HYPERLINK ( _T( " HYPERLINK" ) ); std::wstring PAGEREF ( _T( " PAGEREF" ) ); - - if ( search( f.begin(), f.end(), form.begin(), form.end() ) != f.end() ) + bool bChart = search( f.begin(), f.end(), chart.begin(), chart.end()) != f.end(); + bool bEMBED = search( f.begin(), f.end(), EMBED.begin(), EMBED.end()) != f.end(); + bool bLINK = search( f.begin(), f.end(), LINK.begin(), LINK.end()) != f.end(); + bool bOpendocument = search( f.begin(), f.end(), opendocument.begin(), opendocument.end()) != f.end(); + bool bFORM = search( f.begin(), f.end(), FORM.begin(), FORM.end()) != f.end(); + bool bMERGEFORMAT = search( f.begin(), f.end(), MERGEFORMAT.begin(), MERGEFORMAT.end()) != f.end(); + bool bExcel = search( f.begin(), f.end(), Excel.begin(), Excel.end()) != f.end(); + bool bWord = search( f.begin(), f.end(), Word.begin(), Word.end()) != f.end(); + bool bHYPERLINK = search( f.begin(), f.end(), HYPERLINK.begin(), HYPERLINK.end()) != f.end(); + bool bPAGEREF = search( f.begin(), f.end(), PAGEREF.begin(), PAGEREF.end()) != f.end(); + bool bQUOTE = search( f.begin(), f.end(), QUOTE.begin(), QUOTE.end()) != f.end(); + bool bEquation = search( f.begin(), f.end(), Equation.begin(), Equation.end()) != f.end(); + + if ( bFORM ) { m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), TRUE ); m_pXmlWriter->WriteAttribute( _T( "w:fldCharType" ), _T( "begin" ) ); @@ -557,13 +566,9 @@ namespace DocFileFormat _fldCharCounter++; } - else if (( search( f.begin(), f.end(), mergeformat.begin(), mergeformat.end()) != f.end()) || - (( search( f.begin(), f.end(), excel.begin(), excel.end()) != f.end() || - search( f.begin(), f.end(), word.begin(), word.end()) != f.end()) + else if ( ( bMERGEFORMAT || bExcel || bWord || bOpendocument ) && - ( search(f.begin(), f.end(), embed.begin(), embed.end()) != f.end() || - search( f.begin(), f.end(), link.begin(), link.end() ) != f.end()) && - search( f.begin(), f.end(), chart.begin(), chart.end() ) == f.end())) + ( ( bEMBED || bLINK ) && bChart) ) { m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), TRUE ); m_pXmlWriter->WriteAttribute( _T( "w:fldCharType" ), _T( "begin" ) ); @@ -577,8 +582,7 @@ namespace DocFileFormat _fldCharCounter++; } - else if ( search( f.begin(), f.end(), HYPERLINK.begin(), HYPERLINK.end()) != f.end() && - search( f.begin(), f.end(), PAGEREF.begin(), PAGEREF.end()) != f.end()) + else if ( bHYPERLINK && bPAGEREF ) { int cpFieldSep2 = cpFieldStart, cpFieldSep1 = cpFieldStart; std::vector toc; @@ -628,21 +632,19 @@ namespace DocFileFormat _skipRuns = 5; } } - else if ( search( f.begin(), f.end(), embed.begin(), embed.end()) != f.end() - || search( f.begin(), f.end(), link.begin(), link.end() ) != f.end() - || search( f.begin(), f.end(), quote.begin(), quote.end()) != f.end()) + else if ( bEMBED || bLINK || bQUOTE) { int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture); int cpFieldSep = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::FieldSeparator); if (cpPic < cpFieldEnd) { - int fcPic = m_document->m_PieceTable->FileCharacterPositions->operator []( cpPic ); - list* chpxs = m_document->GetCharacterPropertyExceptions(fcPic, fcPic + 1); + int fcPic = m_document->FindFileCharPos( cpPic ); + std::list* chpxs = m_document->GetCharacterPropertyExceptions(fcPic, fcPic + 1); - CharacterPropertyExceptions* chpxPic = chpxs->front(); + CharacterPropertyExceptions* chpxPic = chpxs->front(); - PictureDescriptor pic(chpxPic, m_document->DataStream); + PictureDescriptor pic(chpxPic, m_document->DataStream, 0x7fffffff, m_document->FIB->m_bOlderVersion); RevisionData oData = RevisionData(chpxPic); @@ -667,7 +669,9 @@ namespace DocFileFormat if ( cpFieldSep < cpFieldEnd ) { int fcFieldSep = m_document->m_PieceTable->FileCharacterPositions->operator []( cpFieldSep ); - list* chpxs = m_document->GetCharacterPropertyExceptions( fcFieldSep, ( fcFieldSep + 1 ) ); + int fcFieldSep1 = m_document->FindFileCharPos( cpFieldSep ); + + std::list* chpxs = m_document->GetCharacterPropertyExceptions( fcFieldSep, ( fcFieldSep + 1 ) ); CharacterPropertyExceptions* chpxSep = chpxs->front(); OleObject ole ( chpxSep, m_document->GetStorage() ); @@ -698,10 +702,8 @@ namespace DocFileFormat } } - if (search(f.begin(), f.end(), embed.begin(), embed.end()) != f.end() ) - _skipRuns = 3; - else - _skipRuns = 5; + if (bEMBED) _skipRuns = 3; + else _skipRuns = 5; } else { @@ -782,7 +784,7 @@ namespace DocFileFormat } else if ((TextMark::Picture == c) && fSpec) { - PictureDescriptor oPicture (chpx, m_document->DataStream); + PictureDescriptor oPicture (chpx, m_document->DataStream, 0x7fffffff, m_document->FIB->m_bOlderVersion); if ((oPicture.mfp.mm > 98) && (NULL != oPicture.shapeContainer)) { @@ -922,7 +924,7 @@ namespace DocFileFormat // Searches for bookmarks in the list of characters. std::vector DocumentMapping::searchBookmarks(std::vector* chars, int initialCp) { - vector ret; + std::vector ret; if (m_document->BookmarkStartPlex->IsValid()) { @@ -946,8 +948,9 @@ namespace DocFileFormat ParagraphPropertyExceptions* DocumentMapping::findValidPapx(int fc) { - ParagraphPropertyExceptions* ret = NULL; - vector* pVector = m_document->AllPapxVector; + ParagraphPropertyExceptions* ret = NULL; + std::vector* pVector = m_document->AllPapxVector; + int nMin = 0; int nMax = (int)pVector->size(); if( nMax > 0 ) @@ -970,41 +973,30 @@ namespace DocFileFormat if ( fc >= nMinVal ) { ret = m_document->AllPapx->find(nMinVal)->second; +//? if (!ret && m_document->AllPapx->size() > 0) +//? { +//? map::iterator it = m_document->AllPapx->end(); +//? it--; +//? do +//? { +//? if (it->first < nMinVal && it->second) +//? break; +//? it--; +//? } +//? while(it != m_document->AllPapx->begin()); +//? +//? ret = it->second; +//? } _lastValidPapx = ret; } } return ret; - - //map::const_iterator iterMin = m_document->AllPapx->begin(); - //map::const_iterator iterMax = ++m_document->AllPapx->begin(); - - //while ( iterMax != m_document->AllPapx->end() ) - //{ - // if ( ( fc >= iterMin->first ) && ( fc < iterMax->first ) ) - // { - // ret = iterMin->second; - // _lastValidPapx = ret; - - // break; - // } - - // iterMin++; - // iterMax++; - //} - - //if ( fc >= iterMin->first ) - //{ - // ret = iterMin->second; - // _lastValidPapx = ret; - //} - - //return ret; } - std::list >* DocumentMapping::splitCharList(std::vector* chars, std::vector* splitIndices) + std::list >* DocumentMapping::splitCharList(std::vector* chars, std::vector* splitIndices) { - list >* ret = new list >(); - vector wcharVector; + std::list >* ret = new std::list >(); + std::vector wcharVector; int startIndex = 0; @@ -1016,7 +1008,7 @@ namespace DocFileFormat if ( cch > 0 ) { - wcharVector = vector( cch ); + wcharVector = std::vector( cch ); copy( chars->begin() + startIndex, chars->begin() + startIndex + cch, wcharVector.begin() ); ret->push_back( wcharVector ); } @@ -1026,7 +1018,7 @@ namespace DocFileFormat } //add the last part - wcharVector = vector( chars->size() - startIndex ); + wcharVector = std::vector( chars->size() - startIndex ); copy( chars->begin() + startIndex, chars->end(), wcharVector.begin() ); ret->push_back( wcharVector ); wcharVector.clear(); @@ -1038,17 +1030,18 @@ namespace DocFileFormat int DocumentMapping::writeTable(int initialCp, unsigned int nestingLevel) { int cp = initialCp; + int fc2 = m_document->FindFileCharPos( cp ); int fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); ParagraphPropertyExceptions* papx = findValidPapx( fc ); TableInfo tai( papx ); //build the table grid - vector* grid = buildTableGrid( cp, nestingLevel ); + std::vector* grid = buildTableGrid( cp, nestingLevel ); //find first row end int fcRowEnd = findRowEndFc( cp, nestingLevel ); - TablePropertyExceptions row1Tapx( findValidPapx( fcRowEnd ), m_document->DataStream ); + TablePropertyExceptions row1Tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->FIB->m_bOlderVersion); //start table m_pXmlWriter->WriteNodeBegin( _T( "w:tbl" ) ); @@ -1068,6 +1061,7 @@ namespace DocFileFormat while ( tai.iTap == nestingLevel ) { cp = writeTableRow( cp, grid, nestingLevel ); + //?fc = m_document->FindFileCharPos(cp ); fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); papx = findValidPapx( fc ); tai = TableInfo( papx ); @@ -1080,7 +1074,8 @@ namespace DocFileFormat while ( tai.fInTable ) { cp = writeTableRow( cp, grid, nestingLevel ); - fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); + fc = m_document->FindFileCharPos( cp ); + papx = findValidPapx( fc ); tai = TableInfo( papx ); } @@ -1103,8 +1098,8 @@ namespace DocFileFormat std::vector* grid = new std::vector(); int cp = initialCp; - int fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); - + int fc = m_document->FindFileCharPos( cp ); + ParagraphPropertyExceptions* papx = findValidPapx( fc ); TableInfo tai( papx ); @@ -1114,7 +1109,7 @@ namespace DocFileFormat while ( tai.fInTable ) { //check all SPRMs of this TAPX - for ( list::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ ) + for ( std::list::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ ) { //find the tDef SPRM if ( iter->OpCode == sprmTDefTable ) @@ -1170,7 +1165,8 @@ namespace DocFileFormat int DocumentMapping::findRowEndFc(int initialCp, int& rowEndCp, unsigned int nestingLevel ) { int cp = initialCp; - int fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); + int fc = m_document->FindFileCharPos( cp ); + ParagraphPropertyExceptions* papx = findValidPapx( fc ); TableInfo tai( papx ); @@ -1185,7 +1181,8 @@ namespace DocFileFormat cp++; } - fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); + fc = m_document->FindFileCharPos( cp ); + papx = findValidPapx( fc ); tai = TableInfo( papx ); @@ -1207,7 +1204,8 @@ namespace DocFileFormat cp++; } - fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); + fc = m_document->FindFileCharPos( cp ); + papx = findValidPapx( fc ); tai = TableInfo( papx ); cp++; @@ -1221,8 +1219,12 @@ namespace DocFileFormat // Finds the FC of the next row end mark. int DocumentMapping::findRowEndFc(int initialCp, unsigned int nestingLevel ) { + if ( initialCp > m_document->Text->size() - 1) + return initialCp; + int cp = initialCp; - int fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); + int fc = m_document->FindFileCharPos( cp ); + ParagraphPropertyExceptions* papx = findValidPapx( fc ); TableInfo tai( papx ); @@ -1232,12 +1234,17 @@ namespace DocFileFormat //Search the "inner table trailer paragraph" while ( ( tai.fInnerTtp == false ) && ( tai.fInTable == true ) ) { - while ( m_document->Text->at( cp ) != TextMark::ParagraphEnd ) + while ( true ) { + if (cp > m_document->Text->size() - 1 ) + break; + if (m_document->Text->at( cp ) == TextMark::ParagraphEnd) + break; cp++; } - fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); + fc = m_document->FindFileCharPos( cp ); + papx = findValidPapx( fc ); tai = TableInfo( papx ); @@ -1250,12 +1257,17 @@ namespace DocFileFormat //Search the "table trailer paragraph" while ( ( tai.fTtp == false ) && ( tai.fInTable == true ) ) { - while ( m_document->Text->at( cp ) != TextMark::CellOrRowMark ) + while (true) { + if (cp > m_document->Text->size() - 1 ) + break; + if (m_document->Text->at( cp ) == TextMark::CellOrRowMark) + break; cp++; } - fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); + fc = m_document->FindFileCharPos( cp ); + papx = findValidPapx( fc ); tai = TableInfo( papx ); cp++; @@ -1266,10 +1278,11 @@ namespace DocFileFormat } /// Writes the table row that starts at the given cp value and ends at the next row end mark - int DocumentMapping::writeTableRow(int initialCp, vector* grid, unsigned int nestingLevel) + int DocumentMapping::writeTableRow(int initialCp, std::vector* grid, unsigned int nestingLevel) { int cp = initialCp; - int fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); + int fc = m_document->FindFileCharPos( cp ); + ParagraphPropertyExceptions* papx = findValidPapx( fc ); TableInfo tai( papx ); @@ -1278,10 +1291,12 @@ namespace DocFileFormat //convert the properties int fcRowEnd = findRowEndFc( cp, nestingLevel ); - TablePropertyExceptions tapx( findValidPapx( fcRowEnd ), m_document->DataStream ); - list* chpxs = m_document->GetCharacterPropertyExceptions( fcRowEnd, fcRowEnd + 1 ); + TablePropertyExceptions tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->FIB->m_bOlderVersion); + + std::list* chpxs = m_document->GetCharacterPropertyExceptions( fcRowEnd, fcRowEnd + 1 ); TableRowPropertiesMapping* trpMapping = new TableRowPropertiesMapping( m_pXmlWriter, *(chpxs->begin()) ); tapx.Convert( trpMapping ); + RELEASEOBJECT( trpMapping ); int gridIndex = 0; @@ -1297,7 +1312,8 @@ namespace DocFileFormat cellIndex++; //each cell has it's own PAPX - fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); + fc = m_document->FindFileCharPos(cp ); + papx = findValidPapx( fc ); tai = TableInfo( papx ); } @@ -1313,7 +1329,8 @@ namespace DocFileFormat cellIndex++; //each cell has it's own PAPX - fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); + fc = m_document->FindFileCharPos( cp ); + papx = findValidPapx( fc ); tai = TableInfo( papx ); } @@ -1331,7 +1348,7 @@ namespace DocFileFormat } /// Writes the table cell that starts at the given cp value and ends at the next cell end mark - int DocumentMapping::writeTableCell(int initialCp, TablePropertyExceptions* tapx, vector* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel ) + int DocumentMapping::writeTableCell(int initialCp, TablePropertyExceptions* tapx, std::vector* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel ) { int cp = initialCp; @@ -1357,7 +1374,8 @@ namespace DocFileFormat while ( cp < cpCellEnd ) { //cp = writeParagraph(cp); - int fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); + int fc = m_document->FindFileCharPos( cp ); + ParagraphPropertyExceptions* papx = findValidPapx( fc ); TableInfo tai( papx ); @@ -1395,7 +1413,8 @@ namespace DocFileFormat if ( nestingLevel > 1 ) { - int fc = m_document->m_PieceTable->FileCharacterPositions->operator []( initialCp ); + int fc = m_document->FindFileCharPos( initialCp ); + ParagraphPropertyExceptions* papx = findValidPapx( fc ); TableInfo tai( papx ); @@ -1403,7 +1422,8 @@ namespace DocFileFormat { cpCellEnd++; - fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cpCellEnd ); + fc = m_document->FindFileCharPos( cpCellEnd ); + papx = findValidPapx( fc ); tai = TableInfo( papx ); } @@ -1497,7 +1517,7 @@ namespace DocFileFormat } */ - for (list::iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); ++iter) + for (std::list::iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); ++iter) { if ((sprmCPicLocation == iter->OpCode) || (sprmCHsp == iter->OpCode)) // PICTURE { diff --git a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h index eaefd9f60c..443138b085 100644 --- a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h @@ -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* chars, CharacterPropertyExceptions* chpx, int initialCp ); + int writeRun( std::vector* chars, CharacterPropertyExceptions* chpx, int initialCp ); /// Writes the given text to the document - void writeText( vector* 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* 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 searchBookmarks( vector* chars, int initialCp ); + std::vector searchBookmarks( std::vector* chars, int initialCp ); ParagraphPropertyExceptions* findValidPapx( int fc ); /// Splits a list of characters into several lists - list >* splitCharList( vector* chars, vector* splitIndices ); + std::list >* splitCharList( std::vector* chars, std::vector* 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* buildTableGrid( int initialCp, unsigned int nestingLevel ); + std::vector* 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* grid, unsigned int nestingLevel ); + int writeTableRow( int initialCp, std::vector* 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* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel ); + int writeTableCell( int initialCp, TablePropertyExceptions* tapx, std::vector* 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* chars, int initialCp, wchar_t mark ); + int searchNextTextMark( std::vector* chars, int initialCp, wchar_t mark ); private: Symbol getSymbol( const CharacterPropertyExceptions* chpx ); diff --git a/ASCOfficeDocFile/DocDocxConverter/DocumentProperties.cpp b/ASCOfficeDocFile/DocDocxConverter/DocumentProperties.cpp index fdbedaef35..1433a5abc8 100644 --- a/ASCOfficeDocFile/DocDocxConverter/DocumentProperties.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/DocumentProperties.cpp @@ -34,714 +34,690 @@ namespace DocFileFormat { - WordDocumentProperties::~WordDocumentProperties() - { - RELEASEOBJECT( doptypography ); - RELEASEOBJECT( dogrid ); - RELEASEOBJECT( asumyi ); - } + WordDocumentProperties::~WordDocumentProperties() + { + RELEASEOBJECT( doptypography ); + RELEASEOBJECT( dogrid ); + RELEASEOBJECT( asumyi ); + } /*========================================================================================================*/ - /// Parses the bytes to retrieve a DocumentProperties - WordDocumentProperties::WordDocumentProperties(FileInformationBlock* fib, POLE::Stream* tableStream) : doptypography(NULL), dogrid(NULL), asumyi(NULL) + WordDocumentProperties::WordDocumentProperties(FileInformationBlock* fib, POLE::Stream* tableStream) : doptypography(NULL), dogrid(NULL), asumyi(NULL) + { + Initialize(); + + VirtualStreamReader tStream( tableStream, fib->m_FibWord97.fcDop, fib->m_bOlderVersion); + +//setDefaultCompatibilityOptions( fib->m_FibBase.nFib ); + + unsigned int size = fib->m_FibWord97.lcbDop; + unsigned char* bytes = tStream.ReadBytes( size, true ); + + try { - Initialize(); - - VirtualStreamReader tStream( tableStream, fib->m_FibWord97.fcDop ); - - //setDefaultCompatibilityOptions( fib->m_FibBase.nFib ); - - unsigned int size = fib->m_FibWord97.lcbDop; - unsigned char* bytes = tStream.ReadBytes( size, true ); - - try + if ( size > 0 ) { - if ( size > 0 ) + fFacingPages = FormatUtils::GetBitFromBytes( bytes, 2, 0 ); + fWindowControl = FormatUtils::GetBitFromBytes( bytes, 2, 1 ); + fPMHMainDoc = FormatUtils::GetBitFromBytes( bytes, 2, 2 ); + grfSuppression = (short)FormatUtils::GetUIntFromBytesBits( bytes, 2, 3, 2 ); + Fpc = (short)(short)FormatUtils::GetUIntFromBytesBits( bytes, 2, 5, 2 ); + + rncFtn = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 2 ), 2, 0, 2 ); + nFtn = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 2 ), 2, 2, 14 ); + + fOutlineDirtySave = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 0 ); + fOnlyMacPics = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 8 ); + fOnlyWinPics = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 9 ); + fLabelDoc = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 10 ); + fHyphCapitals = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 11 ); + fAutoHyphen = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 12 ); + fFormNoFields = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 13 ); + fLinkStyles = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 14 ); + fRevMarking = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 15 ); + + fBackup = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 0 ); + fExactWords = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 1 ); + fPagHidden = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 2 ); + fPagResults = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 3 ); + fLockAtn = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 4 ); + fMirrorMargins = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 5 ); + + fDflttrueType = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 7 ); + fProtEnabled = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 8 ); + fDispFormFldSel = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 9 ); + fRMView = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 10 ); + fRMPrint = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 11 ); + + fLockRev = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 14 ); + fEmbedFonts = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 15 ); + + fNoTabForInd = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 0 ); + fNoSpaceRaiseLower = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 1 ); + fSuppressSpbfAfterPageBreak = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 2 ); + fWrapTrailSpaces = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 3 ); + fMapPrintTextColor = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 4 ); + fNoColumnBalance = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 5 ); + fConvMailMergeEsc = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 6 ); + fSuppressTopSpacing = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 7 ); + fOrigWordTableRules = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 8 ); + fTransparentMetafiles = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 9 ); + fShowBreaksInFrames = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 10 ); + fSwapBordersFacingPgs = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 11 ); + + dxaTab = FormatUtils::BytesToUInt16( bytes, 10, size ); + dxaHotZ = FormatUtils::BytesToUInt16( bytes, 14, size ); + cConsecHypLim = FormatUtils::BytesToUInt16( bytes, 16, size ); + + unsigned char createdbytes[4]; + memcpy( createdbytes, ( bytes + 20 ), 4 ); + dttmCreated = DateAndTime( createdbytes, 4 ); + + unsigned char revisedbytes[4]; + memcpy( revisedbytes, ( bytes + 24 ), 4 ); + dttmRevised = DateAndTime( revisedbytes, 4 ); + + unsigned char printbytes[4]; + memcpy( printbytes, ( bytes + 28 ), 4 ); + dttmLastPrint = DateAndTime( printbytes, 4 ); + + nRevision = FormatUtils::BytesToInt16( bytes, 32, size ); + tmEdited = FormatUtils::BytesToInt32( bytes, 34, size ); + cWords = FormatUtils::BytesToInt32( bytes, 38, size ); + cCh = FormatUtils::BytesToInt32( bytes, 42, size ); + cPg = FormatUtils::BytesToInt16( bytes, 46, size ); + cParas = FormatUtils::BytesToInt32( bytes, 48, size ); + + rncEdn = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 52 ), 2, 0, 2 ); + nEdn = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 52 ), 2, 2, 14 ); + + Epc = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 54 ), 2, 0, 2 ); + nfcFtnRef = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 54 ), 2, 2, 4 ); + nfcEdnRef = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 54 ), 2, 6, 4 ); + fPrintFormData = FormatUtils::GetBitFromBytes( ( bytes + 54 ), 2, 10 ); + fSaveFormData = FormatUtils::GetBitFromBytes( ( bytes + 54 ), 2, 11 ); + fShadeFormData = FormatUtils::GetBitFromBytes( ( bytes + 54 ), 2, 12 ); + + fWCFtnEdn = FormatUtils::GetBitFromBytes( ( bytes + 54 ), 2, 15 ); + + cLines = FormatUtils::BytesToInt32( bytes, 56, size ); + cWordsFtnEdn = FormatUtils::BytesToInt32( bytes, 60, size ); + cChFtnEdn = FormatUtils::BytesToInt32( bytes, 64, size ); + cPgFtnEdn = FormatUtils::BytesToInt16( bytes, 68, size ); + cParasFtnEdn = FormatUtils::BytesToInt32( bytes, 70, size ); + cLinesFtnEdn = FormatUtils::BytesToInt32( bytes, 74, size ); + lKeyProtDoc = FormatUtils::BytesToInt32( bytes, 78, size ); + + wvkSaved = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 82 ), 2, 0, 3 ); + wScaleSaved = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 82 ), 2, 3, 9 ); + zkSaved = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 82 ), 2, 12, 2 ); + fRotateFontW6 = FormatUtils::GetBitFromBytes( ( bytes + 82 ), 2, 14 ); + iGutterPos = FormatUtils::GetBitFromBytes( ( bytes + 82 ), 2, 15 ); + +//compatibility options section + if ( size > 84 ) { - //split unsigned char 0 and 1 into bits - fFacingPages = FormatUtils::GetBitFromBytes( bytes, 2, 0 ); - fWindowControl = FormatUtils::GetBitFromBytes( bytes, 2, 1 ); - fPMHMainDoc = FormatUtils::GetBitFromBytes( bytes, 2, 2 ); - grfSuppression = (short)FormatUtils::GetUIntFromBytesBits( bytes, 2, 3, 2 ); - Fpc = (short)(short)FormatUtils::GetUIntFromBytesBits( bytes, 2, 5, 2 ); + fNoTabForInd = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 0 ); + fNoSpaceRaiseLower = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 1 ); + fSuppressSpbfAfterPageBreak = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 2 ); + fWrapTrailSpaces = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 3 ); + fMapPrintTextColor = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 4 ); + fNoColumnBalance = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 5 ); + fConvMailMergeEsc = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 6 ); + fSuppressTopSpacing = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 7 ); + fOrigWordTableRules = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 8 ); + fTransparentMetafiles = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 9 ); + fShowBreaksInFrames = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 10 ); + fSwapBordersFacingPgs = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 11 ); - //split unsigned char 2 and 3 into bits - rncFtn = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 2 ), 2, 0, 2 ); - nFtn = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 2 ), 2, 2, 14 ); + fSuppressTopSpacingMac5 = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 16 ); + fTruncDxaExpand = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 17 ); + fPrintBodyBeforeHdr = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 18 ); + fNoLeading = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 19 ); - //split unsigned char 4 and 5 into bits - fOutlineDirtySave = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 0 ); - fOnlyMacPics = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 8 ); - fOnlyWinPics = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 9 ); - fLabelDoc = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 10 ); - fHyphCapitals = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 11 ); - fAutoHyphen = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 12 ); - fFormNoFields = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 13 ); - fLinkStyles = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 14 ); - fRevMarking = FormatUtils::GetBitFromBytes( ( bytes + 4 ), 2, 15 ); + fMWSmallCaps = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 21 ); - //split unsigned char 6 and 7 into bits - fBackup = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 0 ); - fExactWords = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 1 ); - fPagHidden = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 2 ); - fPagResults = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 3 ); - fLockAtn = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 4 ); - fMirrorMargins = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 5 ); - //bit 6 is reserved - fDflttrueType = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 7 ); - fProtEnabled = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 8 ); - fDispFormFldSel = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 9 ); - fRMView = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 10 ); - fRMPrint = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 11 ); - //bit 12 and 13 are reserved - fLockRev = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 14 ); - fEmbedFonts = FormatUtils::GetBitFromBytes( ( bytes + 6 ), 2, 15 ); - - //split unsigned char 8 and 9 into bits - fNoTabForInd = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 0 ); - fNoSpaceRaiseLower = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 1 ); - fSuppressSpbfAfterPageBreak = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 2 ); - fWrapTrailSpaces = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 3 ); - fMapPrintTextColor = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 4 ); - fNoColumnBalance = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 5 ); - fConvMailMergeEsc = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 6 ); - fSuppressTopSpacing = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 7 ); - fOrigWordTableRules = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 8 ); - fTransparentMetafiles = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 9 ); - fShowBreaksInFrames = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 10 ); - fSwapBordersFacingPgs = FormatUtils::GetBitFromBytes( ( bytes + 8 ), 2, 11 ); - - dxaTab = FormatUtils::BytesToUInt16( bytes, 10, size ); - dxaHotZ = FormatUtils::BytesToUInt16( bytes, 14, size ); - cConsecHypLim = FormatUtils::BytesToUInt16( bytes, 16, size ); - - unsigned char createdbytes[4]; - memcpy( createdbytes, ( bytes + 20 ), 4 ); - dttmCreated = DateAndTime( createdbytes, 4 ); - - unsigned char revisedbytes[4]; - memcpy( revisedbytes, ( bytes + 24 ), 4 ); - dttmRevised = DateAndTime( revisedbytes, 4 ); - - unsigned char printbytes[4]; - memcpy( printbytes, ( bytes + 28 ), 4 ); - dttmLastPrint = DateAndTime( printbytes, 4 ); - - nRevision = FormatUtils::BytesToInt16( bytes, 32, size ); - tmEdited = FormatUtils::BytesToInt32( bytes, 34, size ); - cWords = FormatUtils::BytesToInt32( bytes, 38, size ); - cCh = FormatUtils::BytesToInt32( bytes, 42, size ); - cPg = FormatUtils::BytesToInt16( bytes, 46, size ); - cParas = FormatUtils::BytesToInt32( bytes, 48, size ); - - //split unsigned char 52 and 53 into bits - rncEdn = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 52 ), 2, 0, 2 ); - nEdn = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 52 ), 2, 2, 14 ); - - //split unsigned char 54 and 55 into bits - Epc = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 54 ), 2, 0, 2 ); - nfcFtnRef = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 54 ), 2, 2, 4 ); - nfcEdnRef = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 54 ), 2, 6, 4 ); - fPrintFormData = FormatUtils::GetBitFromBytes( ( bytes + 54 ), 2, 10 ); - fSaveFormData = FormatUtils::GetBitFromBytes( ( bytes + 54 ), 2, 11 ); - fShadeFormData = FormatUtils::GetBitFromBytes( ( bytes + 54 ), 2, 12 ); - //bits 13 and 14 are reserved - fWCFtnEdn = FormatUtils::GetBitFromBytes( ( bytes + 54 ), 2, 15 ); - - cLines = FormatUtils::BytesToInt32( bytes, 56, size ); - cWordsFtnEdn = FormatUtils::BytesToInt32( bytes, 60, size ); - cChFtnEdn = FormatUtils::BytesToInt32( bytes, 64, size ); - cPgFtnEdn = FormatUtils::BytesToInt16( bytes, 68, size ); - cParasFtnEdn = FormatUtils::BytesToInt32( bytes, 70, size ); - cLinesFtnEdn = FormatUtils::BytesToInt32( bytes, 74, size ); - lKeyProtDoc = FormatUtils::BytesToInt32( bytes, 78, size ); - - //split unsigned char 82 and 83 into bits - wvkSaved = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 82 ), 2, 0, 3 ); - wScaleSaved = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 82 ), 2, 3, 9 ); - zkSaved = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 82 ), 2, 12, 2 ); - fRotateFontW6 = FormatUtils::GetBitFromBytes( ( bytes + 82 ), 2, 14 ); - iGutterPos = FormatUtils::GetBitFromBytes( ( bytes + 82 ), 2, 15 ); - - //compatibility options section - if ( size > 84 ) + if ( size > 88 ) { - //split unsigned char 84,85,86,87 into bits - fNoTabForInd = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 0 ); - fNoSpaceRaiseLower = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 1 ); - fSuppressSpbfAfterPageBreak = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 2 ); - fWrapTrailSpaces = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 3 ); - fMapPrintTextColor = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 4 ); - fNoColumnBalance = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 5 ); - fConvMailMergeEsc = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 6 ); - fSuppressTopSpacing = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 7 ); - fOrigWordTableRules = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 8 ); - fTransparentMetafiles = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 9 ); - fShowBreaksInFrames = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 10 ); - fSwapBordersFacingPgs = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 11 ); - //bits 12,13,14,15 are reserved - fSuppressTopSpacingMac5 = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 16 ); - fTruncDxaExpand = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 17 ); - fPrintBodyBeforeHdr = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 18 ); - fNoLeading = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 19 ); - //bits 20 is reserved - fMWSmallCaps = FormatUtils::GetBitFromBytes( ( bytes + 84 ), 4, 21 ); - //bits 22-31 are reserved + adt = FormatUtils::BytesToUInt16( bytes, 88, size ); - if ( size > 88 ) + unsigned char doptypoBytes[310]; + memcpy( doptypoBytes, ( bytes + 90 ), 310 ); + doptypography = new DocumentTypographyInfo( doptypoBytes, 310 ); + + unsigned char dogridBytes[10]; + memcpy( dogridBytes, ( bytes + 400 ), 10 ); + dogrid = new DrawingObjectGrid( dogridBytes, 10 ); + + lvl = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 410 ), 2, 1, 4 ); + fGramAllDone = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 5 ); + fGramAllClean = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 6 ); + fSubsetFonts = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 7 ); + fHideLastVersion = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 8 ); + fHtmlDoc = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 9 ); + + fSnapBorder = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 11 ); + fIncludeHeader = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 12 ); + fIncludeFooter = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 13 ); + fForcePageSizePag = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 14 ); + fMinFontSizePag = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 15 ); + + fHaveVersions = FormatUtils::GetBitFromBytes( ( bytes + 412 ), 2, 0 ); + fAutoVersion = FormatUtils::GetBitFromBytes( ( bytes + 412 ), 2, 1 ); + + unsigned char asumybits[12]; + memcpy( asumybits, ( bytes + 414 ), 12 ); + asumyi = new AutoSummaryInfo( asumybits, 12 ); + + cChWS = FormatUtils::BytesToInt32( bytes, 426, size ); + cChWSFtnEdn = FormatUtils::BytesToInt32( bytes, 430, size ); + grfDocEvents = FormatUtils::BytesToInt32( bytes, 434, size ); + + fVirusPromted = FormatUtils::GetBitFromBytes( ( bytes + 438 ), 4, 0 ); + fVirusLoadSafe = FormatUtils::GetBitFromBytes( ( bytes + 438 ), 4, 1 ); + KeyVirusSession30 = (int)FormatUtils::GetUIntFromBytesBits( ( bytes + 438 ), 4, 2, 30 ); + + cDBC = FormatUtils::BytesToInt32( bytes, 480, size ); + cDBCFtnEdn = FormatUtils::BytesToInt32( bytes, 484, size ); + nfcEdnRef = FormatUtils::BytesToInt16( bytes, 492, size ); + nfcFtnRef = FormatUtils::BytesToInt16( bytes, 494, size ); + hpsZoonFontPag = FormatUtils::BytesToInt16( bytes, 496, size ); + dywDispPag = FormatUtils::BytesToInt16( bytes, 498, size ); + +//WORD 2000, 2002, 2003 PART + if ( size > 500 ) { - adt = FormatUtils::BytesToUInt16( bytes, 88, size ); + ilvlLastBulletMain = bytes[500]; + ilvlLastNumberMain = bytes[501]; + istdClickTypePara = FormatUtils::BytesToInt16( bytes, 502, size ); - unsigned char doptypoBytes[310]; - memcpy( doptypoBytes, ( bytes + 90 ), 310 ); - doptypography = new DocumentTypographyInfo( doptypoBytes, 310 ); + fLADAllDone = FormatUtils::GetBitFromBytes( ( bytes + 504 ), 2, 0 ); + fEnvelopeVis = FormatUtils::GetBitFromBytes( ( bytes + 504 ), 2, 1 ); + fMaybeTentativeListInDoc = FormatUtils::GetBitFromBytes( ( bytes + 504 ), 2, 2 ); + fMaybeFitText = FormatUtils::GetBitFromBytes( ( bytes + 504 ), 2, 3 ); + fRelyOnCss_WebOpt = FormatUtils::GetBitFromBytes( ( bytes + 504 ), 2, 9 ); + fRelyOnVML_WebOpt = FormatUtils::GetBitFromBytes( ( bytes + 504 ), 2, 10 ); + fAllowPNG_WebOpt = FormatUtils::GetBitFromBytes( ( bytes + 504 ), 2, 11 ); + screenSize_WebOpt = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 504 ), 2, 12, 4 ); - unsigned char dogridBytes[10]; - memcpy( dogridBytes, ( bytes + 400 ), 10 ); - dogrid = new DrawingObjectGrid( dogridBytes, 10 ); + fOrganizeInFolder_WebOpt = FormatUtils::GetBitFromBytes( ( bytes + 506 ), 2, 0 ); + fUseLongFileNames_WebOpt = FormatUtils::GetBitFromBytes( ( bytes + 506 ), 2, 1 ); + iPixelsPerInch_WebOpt = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 506 ), 2, 2, 10 ); + fWebOptionsInit = FormatUtils::GetBitFromBytes( ( bytes + 506 ), 2, 12 ); + fMaybeFEL = FormatUtils::GetBitFromBytes( ( bytes + 506 ), 2, 13 ); + fCharLineUnits = FormatUtils::GetBitFromBytes( ( bytes + 506 ), 2, 14 ); + fMaybeRTLTables = FormatUtils::GetBitFromBytes( ( bytes + 506 ), 2, 15 ); - //split unsigned char 410 and 411 into bits - //bit 0 is reserved - lvl = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 410 ), 2, 1, 4 ); - fGramAllDone = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 5 ); - fGramAllClean = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 6 ); - fSubsetFonts = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 7 ); - fHideLastVersion = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 8 ); - fHtmlDoc = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 9 ); - //bit 10 is reserved - fSnapBorder = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 11 ); - fIncludeHeader = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 12 ); - fIncludeFooter = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 13 ); - fForcePageSizePag = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 14 ); - fMinFontSizePag = FormatUtils::GetBitFromBytes( ( bytes + 410 ), 2, 15 ); + fNoTabForInd = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 0 ); + fNoSpaceRaiseLower = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 1 ); + fSuppressSpbfAfterPageBreak = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 2 ); + fWrapTrailSpaces = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 3 ); + fMapPrintTextColor = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 4 ); + fNoColumnBalance = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 5 ); + fConvMailMergeEsc = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 6 ); + fSuppressTopSpacing = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 7 ); + fOrigWordTableRules = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 8 ); + fTransparentMetafiles = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 9 ); + fShowBreaksInFrames = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 10 ); + fSwapBordersFacingPgs = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 11 ); + fLeaveBackslashAlone = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 12 ); + fExpShRtn = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 13 ); + fDntULTrlSpc = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 14 ); + fDntBlnSbDbWid = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 15 ); + fSuppressTopSpacingMac5 = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 16 ); + fTruncDxaExpand = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 17 ); + fPrintBodyBeforeHdr = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 18 ); + fNoLeading = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 19 ); + fMakeSpaceForUL = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 20 ); + fMWSmallCaps = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 21 ); + f2ptExtLeadingOnly = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 22 ); + fTruncFontHeight = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 23 ); + fSubOnSize = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 24 ); + fLineWrapLikeWord6 = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 25 ); + fWW6BorderRules = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 26 ); + fExactOnTop = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 27 ); + fExtraAfter = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 28 ); + fWPSpace = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 29 ); + fWPJust = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 30 ); + fPrintMet = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 31 ); - //split unsigned char 412 and 413 into bits - fHaveVersions = FormatUtils::GetBitFromBytes( ( bytes + 412 ), 2, 0 ); - fAutoVersion = FormatUtils::GetBitFromBytes( ( bytes + 412 ), 2, 1 ); - //other bits are reserved + //split bytes 512,513,514,515 into bits + fSpLayoutLikeWW8 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 0 ); + fFtnLayoutLikeWW8 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 1 ); + fDontUseHTMLParagraphAutoSpacing = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 2 ); + fDontAdjustLineHeightInTable = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 3 ); + fForgetLastTabAlign = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 4 ); + fUseAutoSpaceForFullWidthAlpha = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 5 ); + fAlignTablesRowByRow = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 6 ); + fLayoutRawTableWidth = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 7 ); + fLayoutTableRowsApart = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 8 ); + fUserWord97LineBreakingRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 9 ); + fDontBreakWrappedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 10 ); + fDontSnapToGridInCell = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 11 ); + fDontAllowFieldEndSelect = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 12 ); + fApplyBreakingRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 13 ); + fDontWrapTextWithPunct = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 14 ); + fDontUseAsianBreakRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 15 ); + fUseWord2002TableStyleRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 16 ); + fGrowAutofit = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 17 ); + fUseNormalStyleForList = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 18 ); + fDontUseIndentAsNumberingTabStop = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 19 ); + fFELineBreak11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 20 ); + fAllowSpaceOfSameStyleInTable = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 21 ); + fWW11IndentRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 22 ); + fDontAutofitConstrainedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 23 ); + fAutofitLikeWW11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 24 ); + fUnderlineTabInNumList = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 25 ); + fHangulWidthLikeWW11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 26 ); + fSplitPgBreakAndParaMark = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 27 ); + fDontVertAlignCellWithSp = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 28 ); + fDontBreakConstrainedForcedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 29 ); + fDontVertAlignInTxbx = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 30 ); + fWord11KerningPairs = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 31 ); + fCachedColBalance = FormatUtils::GetBitFromBytes( ( bytes + 516 ), 4, 0 ); + + //bytes 517-539 are unused - unsigned char asumybits[12]; - memcpy( asumybits, ( bytes + 414 ), 12 ); - asumyi = new AutoSummaryInfo( asumybits, 12 ); + verCompatPreW10 = (unsigned short)FormatUtils::GetUIntFromBytesBits( ( bytes + 540 ), 4, 0, 16 ); + fNoMargPgvwSaved = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 16 ); + fNoMargPgvWPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 17 ); + fWebViewPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 18 ); + fSeeDrawingsPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 19 ); + fBulletProofed = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 20 ); + fCorrupted = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 21 ); + fSaveUim = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 22 ); + fFilterPrivacy = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 23 ); + fInFReplaceNoRM = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 24 ); + fSeenRepairs = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 25 ); + fHasXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 26 ); + fSeeScriptAnchorsPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 27 ); + fValidateXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 28 ); + fSaveIfInvalidXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 29 ); + fShowXMLErrors = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 30 ); + fAlwaysMergeEmptyNamespace = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 31 ); - cChWS = FormatUtils::BytesToInt32( bytes, 426, size ); - cChWSFtnEdn = FormatUtils::BytesToInt32( bytes, 430, size ); - grfDocEvents = FormatUtils::BytesToInt32( bytes, 434, size ); + cpMaxListCacheMainDoc = FormatUtils::BytesToInt32( bytes, 544, size ); - //split bytes 438-441 in bits - fVirusPromted = FormatUtils::GetBitFromBytes( ( bytes + 438 ), 4, 0 ); - fVirusLoadSafe = FormatUtils::GetBitFromBytes( ( bytes + 438 ), 4, 1 ); - KeyVirusSession30 = (int)FormatUtils::GetUIntFromBytesBits( ( bytes + 438 ), 4, 2, 30 ); + //split bytes 548,549 into bits + fDoNotEmbedSystemFont = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 0 ); + fWordCompact = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 1 ); + fLiveRecover = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 2 ); + fEmbedFactoids = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 3 ); + fFactoidXML = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 4 ); + fFactoidAllDone = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 5 ); + fFolioPrint = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 6 ); + fReverseFolio = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 7 ); + iTextLineEnding = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 548 ), 2, 8, 3 ); + fHideFcc = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 11 ); + fAcetateShowMarkup = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 12 ); + fAcetateShowAtn = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 13 ); + fAcetateShowInsDel = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 14 ); + fAcetateShowProps = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 15 ); - cDBC = FormatUtils::BytesToInt32( bytes, 480, size ); - cDBCFtnEdn = FormatUtils::BytesToInt32( bytes, 484, size ); - nfcEdnRef = FormatUtils::BytesToInt16( bytes, 492, size ); - nfcFtnRef = FormatUtils::BytesToInt16( bytes, 494, size ); - hpsZoonFontPag = FormatUtils::BytesToInt16( bytes, 496, size ); - dywDispPag = FormatUtils::BytesToInt16( bytes, 498, size ); + istdTableDflt = FormatUtils::BytesToUInt16( bytes, 550, size ); + verCompat = FormatUtils::BytesToUInt16( bytes, 552, size ); + grfFmtFilter = FormatUtils::BytesToUInt16( bytes, 554, size ); + iFolioPages = FormatUtils::BytesToInt16( bytes, 556, size ); + cpgText = FormatUtils::BytesToUInt16( bytes, 558, size ); + cpMinRMText = FormatUtils::BytesToInt32( bytes, 560, size ); + cpMinRMFtn = FormatUtils::BytesToInt32( bytes, 564, size ); + cpMinRMHdd = FormatUtils::BytesToInt32( bytes, 568, size ); + cpMinRMAtn = FormatUtils::BytesToInt32( bytes, 572, size ); + cpMinRMEdn = FormatUtils::BytesToInt32( bytes, 576, size ); + cpMinRMTxbx = FormatUtils::BytesToInt32( bytes, 580, size ); + cpMinRMHdrTxbx = FormatUtils::BytesToInt32( bytes, 584, size ); + rsidRoot = FormatUtils::BytesToInt32( bytes, 588, size ); - //WORD 2000, 2002, 2003 PART - if ( size > 500 ) + if ( size == 610 ) { - ilvlLastBulletMain = bytes[500]; - ilvlLastNumberMain = bytes[501]; - istdClickTypePara = FormatUtils::BytesToInt16( bytes, 502, size ); + //split bytes 592,593,594,595 into bits + fTreatLockAtnAsReadOnly = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 0 ); + fStyleLock = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 1 ); + fAutoFmtOverride = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 2 ); + fRemoveWordML = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 3 ); + fApplyCustomXForm = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 4 ); + fStyeLockEnforced = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 5 ); + fFakeLockAtn = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 6 ); + fIgnoreMixedContent = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 7 ); + fShowPlaceholderText = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 8 ); + grf = FormatUtils::GetUIntFromBytesBits( ( bytes + 592 ), 4, 9, 23 ); - //split unsigned char 504 and 505 into bits - fLADAllDone = FormatUtils::GetBitFromBytes( ( bytes + 504 ), 2, 0 ); - fEnvelopeVis = FormatUtils::GetBitFromBytes( ( bytes + 504 ), 2, 1 ); - fMaybeTentativeListInDoc = FormatUtils::GetBitFromBytes( ( bytes + 504 ), 2, 2 ); - fMaybeFitText = FormatUtils::GetBitFromBytes( ( bytes + 504 ), 2, 3 ); - fRelyOnCss_WebOpt = FormatUtils::GetBitFromBytes( ( bytes + 504 ), 2, 9 ); - fRelyOnVML_WebOpt = FormatUtils::GetBitFromBytes( ( bytes + 504 ), 2, 10 ); - fAllowPNG_WebOpt = FormatUtils::GetBitFromBytes( ( bytes + 504 ), 2, 11 ); - screenSize_WebOpt = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 504 ), 2, 12, 4 ); + //split bytes 596 and 597 into bits + fReadingModeInkLockDown = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 0 ); + fAcetateShowInkAtn = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 1 ); + fFilterDttm = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 2 ); + fEnforceDocProt = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 3 ); + iDocProtCur = (unsigned short)FormatUtils::GetUIntFromBytesBits( ( bytes + 596 ), 2, 4, 3 ); + fDispBkSpSaved = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 7 ); - //split unsigned char 506 and 507 into bits - fOrganizeInFolder_WebOpt = FormatUtils::GetBitFromBytes( ( bytes + 506 ), 2, 0 ); - fUseLongFileNames_WebOpt = FormatUtils::GetBitFromBytes( ( bytes + 506 ), 2, 1 ); - iPixelsPerInch_WebOpt = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 506 ), 2, 2, 10 ); - fWebOptionsInit = FormatUtils::GetBitFromBytes( ( bytes + 506 ), 2, 12 ); - fMaybeFEL = FormatUtils::GetBitFromBytes( ( bytes + 506 ), 2, 13 ); - fCharLineUnits = FormatUtils::GetBitFromBytes( ( bytes + 506 ), 2, 14 ); - fMaybeRTLTables = FormatUtils::GetBitFromBytes( ( bytes + 506 ), 2, 15 ); - - //split bytes 508,509,510,511 into bits - fNoTabForInd = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 0 ); - fNoSpaceRaiseLower = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 1 ); - fSuppressSpbfAfterPageBreak = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 2 ); - fWrapTrailSpaces = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 3 ); - fMapPrintTextColor = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 4 ); - fNoColumnBalance = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 5 ); - fConvMailMergeEsc = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 6 ); - fSuppressTopSpacing = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 7 ); - fOrigWordTableRules = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 8 ); - fTransparentMetafiles = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 9 ); - fShowBreaksInFrames = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 10 ); - fSwapBordersFacingPgs = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 11 ); - fLeaveBackslashAlone = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 12 ); - fExpShRtn = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 13 ); - fDntULTrlSpc = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 14 ); - fDntBlnSbDbWid = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 15 ); - fSuppressTopSpacingMac5 = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 16 ); - fTruncDxaExpand = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 17 ); - fPrintBodyBeforeHdr = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 18 ); - fNoLeading = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 19 ); - fMakeSpaceForUL = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 20 ); - fMWSmallCaps = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 21 ); - f2ptExtLeadingOnly = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 22 ); - fTruncFontHeight = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 23 ); - fSubOnSize = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 24 ); - fLineWrapLikeWord6 = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 25 ); - fWW6BorderRules = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 26 ); - fExactOnTop = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 27 ); - fExtraAfter = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 28 ); - fWPSpace = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 29 ); - fWPJust = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 30 ); - fPrintMet = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 31 ); - - //split bytes 512,513,514,515 into bits - fSpLayoutLikeWW8 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 0 ); - fFtnLayoutLikeWW8 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 1 ); - fDontUseHTMLParagraphAutoSpacing = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 2 ); - fDontAdjustLineHeightInTable = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 3 ); - fForgetLastTabAlign = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 4 ); - fUseAutoSpaceForFullWidthAlpha = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 5 ); - fAlignTablesRowByRow = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 6 ); - fLayoutRawTableWidth = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 7 ); - fLayoutTableRowsApart = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 8 ); - fUserWord97LineBreakingRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 9 ); - fDontBreakWrappedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 10 ); - fDontSnapToGridInCell = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 11 ); - fDontAllowFieldEndSelect = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 12 ); - fApplyBreakingRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 13 ); - fDontWrapTextWithPunct = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 14 ); - fDontUseAsianBreakRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 15 ); - fUseWord2002TableStyleRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 16 ); - fGrowAutofit = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 17 ); - fUseNormalStyleForList = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 18 ); - fDontUseIndentAsNumberingTabStop = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 19 ); - fFELineBreak11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 20 ); - fAllowSpaceOfSameStyleInTable = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 21 ); - fWW11IndentRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 22 ); - fDontAutofitConstrainedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 23 ); - fAutofitLikeWW11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 24 ); - fUnderlineTabInNumList = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 25 ); - fHangulWidthLikeWW11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 26 ); - fSplitPgBreakAndParaMark = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 27 ); - fDontVertAlignCellWithSp = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 28 ); - fDontBreakConstrainedForcedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 29 ); - fDontVertAlignInTxbx = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 30 ); - fWord11KerningPairs = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 31 ); - fCachedColBalance = FormatUtils::GetBitFromBytes( ( bytes + 516 ), 4, 0 ); - - //bytes 517-539 are unused - - //split bytes 540,541,542,543 into bits - verCompatPreW10 = (unsigned short)FormatUtils::GetUIntFromBytesBits( ( bytes + 540 ), 4, 0, 16 ); - fNoMargPgvwSaved = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 16 ); - fNoMargPgvWPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 17 ); - fWebViewPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 18 ); - fSeeDrawingsPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 19 ); - fBulletProofed = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 20 ); - fCorrupted = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 21 ); - fSaveUim = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 22 ); - fFilterPrivacy = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 23 ); - fInFReplaceNoRM = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 24 ); - fSeenRepairs = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 25 ); - fHasXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 26 ); - fSeeScriptAnchorsPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 27 ); - fValidateXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 28 ); - fSaveIfInvalidXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 29 ); - fShowXMLErrors = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 30 ); - fAlwaysMergeEmptyNamespace = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 31 ); - - cpMaxListCacheMainDoc = FormatUtils::BytesToInt32( bytes, 544, size ); - - //split bytes 548,549 into bits - fDoNotEmbedSystemFont = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 0 ); - fWordCompact = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 1 ); - fLiveRecover = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 2 ); - fEmbedFactoids = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 3 ); - fFactoidXML = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 4 ); - fFactoidAllDone = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 5 ); - fFolioPrint = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 6 ); - fReverseFolio = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 7 ); - iTextLineEnding = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 548 ), 2, 8, 3 ); - fHideFcc = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 11 ); - fAcetateShowMarkup = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 12 ); - fAcetateShowAtn = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 13 ); - fAcetateShowInsDel = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 14 ); - fAcetateShowProps = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 15 ); - - istdTableDflt = FormatUtils::BytesToUInt16( bytes, 550, size ); - verCompat = FormatUtils::BytesToUInt16( bytes, 552, size ); - grfFmtFilter = FormatUtils::BytesToUInt16( bytes, 554, size ); - iFolioPages = FormatUtils::BytesToInt16( bytes, 556, size ); - cpgText = FormatUtils::BytesToUInt16( bytes, 558, size ); - cpMinRMText = FormatUtils::BytesToInt32( bytes, 560, size ); - cpMinRMFtn = FormatUtils::BytesToInt32( bytes, 564, size ); - cpMinRMHdd = FormatUtils::BytesToInt32( bytes, 568, size ); - cpMinRMAtn = FormatUtils::BytesToInt32( bytes, 572, size ); - cpMinRMEdn = FormatUtils::BytesToInt32( bytes, 576, size ); - cpMinRMTxbx = FormatUtils::BytesToInt32( bytes, 580, size ); - cpMinRMHdrTxbx = FormatUtils::BytesToInt32( bytes, 584, size ); - rsidRoot = FormatUtils::BytesToInt32( bytes, 588, size ); - - if ( size == 610 ) - { - //split bytes 592,593,594,595 into bits - fTreatLockAtnAsReadOnly = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 0 ); - fStyleLock = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 1 ); - fAutoFmtOverride = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 2 ); - fRemoveWordML = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 3 ); - fApplyCustomXForm = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 4 ); - fStyeLockEnforced = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 5 ); - fFakeLockAtn = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 6 ); - fIgnoreMixedContent = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 7 ); - fShowPlaceholderText = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 8 ); - grf = FormatUtils::GetUIntFromBytesBits( ( bytes + 592 ), 4, 9, 23 ); - - //split bytes 596 and 597 into bits - fReadingModeInkLockDown = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 0 ); - fAcetateShowInkAtn = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 1 ); - fFilterDttm = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 2 ); - fEnforceDocProt = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 3 ); - iDocProtCur = (unsigned short)FormatUtils::GetUIntFromBytesBits( ( bytes + 596 ), 2, 4, 3 ); - fDispBkSpSaved = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 7 ); - - dxaPageLock = FormatUtils::BytesToInt16( bytes, 598, size ); - dyaPageLock = FormatUtils::BytesToInt16( bytes, 600, size ); - pctFontLock = FormatUtils::BytesToInt32( bytes, 602, size ); - grfitbid = bytes[606]; - //unsigned char 607 is unused - ilfoMacAtCleanup = FormatUtils::BytesToUInt16( bytes, 608, size ); - } + dxaPageLock = FormatUtils::BytesToInt16( bytes, 598, size ); + dyaPageLock = FormatUtils::BytesToInt16( bytes, 600, size ); + pctFontLock = FormatUtils::BytesToInt32( bytes, 602, size ); + grfitbid = bytes[606]; + //unsigned char 607 is unused + ilfoMacAtCleanup = FormatUtils::BytesToUInt16( bytes, 608, size ); } } } } } - catch (/*Exception*/...) - { - //this DOP was probably not written by Word - //TraceLogger.Warning("Unexpected length of DOP ({0} bytes) in input file.", (int)fib.lcbDop); - } - - RELEASEARRAYOBJECTS( bytes ); } - - /*========================================================================================================*/ - - void WordDocumentProperties::setDefaultCompatibilityOptions( FibVersion nFib ) + catch (/*Exception*/...) { - if( nFib == Fib1997 ) - { - //Word 97 default settings - fAlignTablesRowByRow = true; - fLayoutTableRowsApart = true; - fGrowAutofit = true; - fDontWrapTextWithPunct = true; - //ToDo: Don't autofit tables next to wrapped objects - //ToDo: Don't break constrained tables forced onto the page - fDontBreakWrappedTables = true; - fDontSnapToGridInCell = true; - fDontUseAsianBreakRules = true; - fNoTabForInd = true; - fDontUseHTMLParagraphAutoSpacing = true; - fForgetLastTabAlign = true; - fSpLayoutLikeWW8 = true; - fFtnLayoutLikeWW8 = true; - fLayoutRawTableWidth = true; - fDontAllowFieldEndSelect = true; - //ToDo: underline characters in numbered lists - fUseWord2002TableStyleRules = true; - fUserWord97LineBreakingRules = true; - } - else if ( nFib == Fib2000 ) - { - //Word 2000 default settings - - fGrowAutofit = true; - fDontWrapTextWithPunct = true; - //ToDo: Don't autofit tables next to wrapped objects - fDontBreakWrappedTables = true; - fDontSnapToGridInCell = true; - fDontUseAsianBreakRules = true; - fNoTabForInd = true; - fDontAllowFieldEndSelect = true; - //ToDo: underline characters in numbered lists - fUseWord2002TableStyleRules = true; - } - else if( nFib == Fib2002 ) - { - //Word 2002 (XP) - - fGrowAutofit = true; - //ToDo: Don't autofit tables next to wrapped objects - fDontBreakWrappedTables = true; - fNoTabForInd = true; - fUseWord2002TableStyleRules = true; - } - else if ( nFib == Fib2003 ) - { - //Word 2003 - - //ToDo: Don't autofit tables next to wrapped objects - fDontBreakWrappedTables = true; - fNoTabForInd = true; - - } - else if ( nFib < Fib1997 ) - { - //throw new UnspportedFileVersionException(); - } } - /*========================================================================================================*/ + RELEASEARRAYOBJECTS( bytes ); + } - void WordDocumentProperties::Initialize() - { - fFacingPages = false; - fWindowControl = false; - fPMHMainDoc = false; - grfSuppression = 0; - Fpc = 0; - grpfIhdt = 0; - rncFtn = 0; - nFtn = 0; - fOutlineDirtySave = false; - fOnlyMacPics = false; - fOnlyWinPics = false; - fLabelDoc = false; - fHyphCapitals = false; - fAutoHyphen = false; - fFormNoFields = false; - fLinkStyles = false; - fRevMarking = false; - fBackup = false; - fExactWords = false; - fPagHidden = false; - fPagResults = false; - fLockAtn = false; - fMirrorMargins = false; - fDflttrueType = false; - fPagSuppressTopSpacing = false; - fProtEnabled = false; - fDispFormFldSel = false; - fRMView = false; - fRMPrint = false; - fLockRev = false; - fEmbedFonts = false; - fNoTabForInd = false; - fNoSpaceRaiseLower = false; - fSuppressSpbfAfterPageBreak = false; - fWrapTrailSpaces = false; - fMapPrintTextColor = false; - fNoColumnBalance = false; - fConvMailMergeEsc = false; - fSuppressTopSpacing = false; - fOrigWordTableRules = false; - fTransparentMetafiles = false; - fShowBreaksInFrames = false; - fSwapBordersFacingPgs = false; - dxaTab = 0; - wSpare = 0; - dxaHotZ = 0; - cConsecHypLim = 0; - wSpare2 = 0; - nRevision = 0; - tmEdited = 0; - cWords = 0; - cCh = 0; - cPg = 0; - cParas = 0; - rncEdn = 0; - nEdn = 0; - Epc = 0; - nfcFtnRef = 0; - nfcEdnRef = 0; - fPrintFormData = false; - fSaveFormData = false; - fShadeFormData = false; - fWCFtnEdn = false; - cLines = 0; - cWordsFtnEdn = 0; - cChFtnEdn = 0; - cPgFtnEdn = 0; - cParasFtnEdn = 0; - cLinesFtnEdn = 0; - lKeyProtDoc = 0; - wvkSaved = 0; - wScaleSaved = 0; - zkSaved = 0; - fRotateFontW6 = false; - iGutterPos = false; - fSuppressTopSpacingMac5 = false; - fTruncDxaExpand = false; - fPrintBodyBeforeHdr = false; - fNoLeading = false; - fMWSmallCaps = false; - adt = 0; - doptypography = NULL; - dogrid = NULL; - lvl = 0; - fGramAllDone = false; - fGramAllClean = false; - fSubsetFonts = false; - fHideLastVersion = false; - fHtmlDoc = false; - fSnapBorder = false; - fIncludeHeader = false; - fIncludeFooter = false; - fForcePageSizePag = false; - fMinFontSizePag = false; - fHaveVersions = false; - fAutoVersion = false; - asumyi = NULL; - cChWS = 0; - cChWSFtnEdn = 0; - grfDocEvents = 0; - fVirusPromted = false; - fVirusLoadSafe = false; - KeyVirusSession30 = 0; - cDBC = 0; - cDBCFtnEdn = 0; - hpsZoonFontPag = 0; - dywDispPag = 0; - ilvlLastBulletMain = 0; - ilvlLastNumberMain = 0; - istdClickTypePara = 0; - fLADAllDone = false; - fEnvelopeVis = false; - fMaybeTentativeListInDoc = false; - fMaybeFitText = false; - fRelyOnCss_WebOpt = false; - fRelyOnVML_WebOpt = false; - fAllowPNG_WebOpt = false; - screenSize_WebOpt = 0; - fOrganizeInFolder_WebOpt = false; - fUseLongFileNames_WebOpt = false; - iPixelsPerInch_WebOpt = 0; - fWebOptionsInit = false; - fMaybeFEL = false; - fCharLineUnits = false; - fMaybeRTLTables = false; - fLeaveBackslashAlone = false; - fExpShRtn = false; - fDntULTrlSpc = false; - fDntBlnSbDbWid = false; - fMakeSpaceForUL = false; - f2ptExtLeadingOnly = false; - fTruncFontHeight = false; - fSubOnSize = false; - fLineWrapLikeWord6 = false; - fWW6BorderRules = false; - fExactOnTop = false; - fExtraAfter = false; - fWPSpace = false; - fWPJust = false; - fPrintMet = false; - fSpLayoutLikeWW8 = false; - fFtnLayoutLikeWW8 = false; - fDontUseHTMLParagraphAutoSpacing = false; - fDontAdjustLineHeightInTable = false; - fForgetLastTabAlign = false; - fUseAutoSpaceForFullWidthAlpha = false; - fAlignTablesRowByRow = false; - fLayoutRawTableWidth = false; - fLayoutTableRowsApart = false; - fUserWord97LineBreakingRules = false; - fDontBreakWrappedTables = false; - fDontSnapToGridInCell = false; - fDontAllowFieldEndSelect = false; - fApplyBreakingRules = false; - fDontWrapTextWithPunct = false; - fDontUseAsianBreakRules = false; - fUseWord2002TableStyleRules = false; - fGrowAutofit = false; - fUseNormalStyleForList = false; - fDontUseIndentAsNumberingTabStop = false; - fFELineBreak11 = false; - fAllowSpaceOfSameStyleInTable = false; - fWW11IndentRules = false; - fDontAutofitConstrainedTables = false; - fAutofitLikeWW11 = false; - fUnderlineTabInNumList = false; - fHangulWidthLikeWW11 = false; - fSplitPgBreakAndParaMark = false; - fDontVertAlignCellWithSp = false; - fDontBreakConstrainedForcedTables = false; - fDontVertAlignInTxbx = false; - fWord11KerningPairs = false; - fCachedColBalance = false; - verCompatPreW10 = 0; - fNoMargPgvwSaved = false; - fNoMargPgvWPag = false; - fWebViewPag = false; - fSeeDrawingsPag = false; - fBulletProofed = false; - fCorrupted = false; - fSaveUim = false; - fFilterPrivacy = false; - fInFReplaceNoRM = false; - fSeenRepairs = false; - fHasXML = false; - fSeeScriptAnchorsPag = false; - fValidateXML = false; - fSaveIfInvalidXML = false; - fShowXMLErrors = false; - fAlwaysMergeEmptyNamespace = false; - cpMaxListCacheMainDoc = 0; - fDoNotEmbedSystemFont = false; - fWordCompact = false; - fLiveRecover = false; - fEmbedFactoids = false; - fFactoidXML = false; - fFactoidAllDone = false; - fFolioPrint = false; - fReverseFolio = false; - iTextLineEnding = false; - fHideFcc = false; - fAcetateShowMarkup = false; - fAcetateShowAtn = false; - fAcetateShowInsDel = false; - fAcetateShowProps = false; - istdTableDflt = 0; - verCompat = 0; - grfFmtFilter = 0; - iFolioPages = 0; - cpgText = 0; - cpMinRMText = 0; - cpMinRMFtn = 0; - cpMinRMHdd = 0; - cpMinRMAtn = 0; - cpMinRMEdn = 0; - cpMinRMTxbx = 0; - cpMinRMHdrTxbx = 0; - rsidRoot = 0; - fTreatLockAtnAsReadOnly = false; - fStyleLock = false; - fAutoFmtOverride = false; - fRemoveWordML = false; - fApplyCustomXForm = false; - fStyeLockEnforced = false; - fFakeLockAtn = false; - fIgnoreMixedContent = false; - fShowPlaceholderText = false; - grf = 0; - fReadingModeInkLockDown = false; - fAcetateShowInkAtn = false; - fFilterDttm = false; - fEnforceDocProt = false; - iDocProtCur = 0; - fDispBkSpSaved = false; - dxaPageLock = 0; - dyaPageLock = 0; - pctFontLock = 0; - grfitbid = 0; - ilfoMacAtCleanup = 0; - } + + void WordDocumentProperties::setDefaultCompatibilityOptions( FibVersion nFib ) + { + if( nFib == Fib1997 ) + { + //Word 97 default settings + fAlignTablesRowByRow = true; + fLayoutTableRowsApart = true; + fGrowAutofit = true; + fDontWrapTextWithPunct = true; + //ToDo: Don't autofit tables next to wrapped objects + //ToDo: Don't break constrained tables forced onto the page + fDontBreakWrappedTables = true; + fDontSnapToGridInCell = true; + fDontUseAsianBreakRules = true; + fNoTabForInd = true; + fDontUseHTMLParagraphAutoSpacing = true; + fForgetLastTabAlign = true; + fSpLayoutLikeWW8 = true; + fFtnLayoutLikeWW8 = true; + fLayoutRawTableWidth = true; + fDontAllowFieldEndSelect = true; + //ToDo: underline characters in numbered lists + fUseWord2002TableStyleRules = true; + fUserWord97LineBreakingRules = true; + } + else if ( nFib == Fib2000 ) + { + //Word 2000 default settings + + fGrowAutofit = true; + fDontWrapTextWithPunct = true; + //ToDo: Don't autofit tables next to wrapped objects + fDontBreakWrappedTables = true; + fDontSnapToGridInCell = true; + fDontUseAsianBreakRules = true; + fNoTabForInd = true; + fDontAllowFieldEndSelect = true; + //ToDo: underline characters in numbered lists + fUseWord2002TableStyleRules = true; + } + else if( nFib == Fib2002 ) + { + //Word 2002 (XP) + + fGrowAutofit = true; + //ToDo: Don't autofit tables next to wrapped objects + fDontBreakWrappedTables = true; + fNoTabForInd = true; + fUseWord2002TableStyleRules = true; + } + else if ( nFib == Fib2003 ) + { + //Word 2003 + + //ToDo: Don't autofit tables next to wrapped objects + fDontBreakWrappedTables = true; + fNoTabForInd = true; + + } + else if ( nFib < Fib1997 ) + { + //throw new UnspportedFileVersionException(); + } + } + + + void WordDocumentProperties::Initialize() + { + fFacingPages = false; + fWindowControl = false; + fPMHMainDoc = false; + grfSuppression = 0; + Fpc = 0; + grpfIhdt = 0; + rncFtn = 0; + nFtn = 0; + fOutlineDirtySave = false; + fOnlyMacPics = false; + fOnlyWinPics = false; + fLabelDoc = false; + fHyphCapitals = false; + fAutoHyphen = false; + fFormNoFields = false; + fLinkStyles = false; + fRevMarking = false; + fBackup = false; + fExactWords = false; + fPagHidden = false; + fPagResults = false; + fLockAtn = false; + fMirrorMargins = false; + fDflttrueType = false; + fPagSuppressTopSpacing = false; + fProtEnabled = false; + fDispFormFldSel = false; + fRMView = false; + fRMPrint = false; + fLockRev = false; + fEmbedFonts = false; + fNoTabForInd = false; + fNoSpaceRaiseLower = false; + fSuppressSpbfAfterPageBreak = false; + fWrapTrailSpaces = false; + fMapPrintTextColor = false; + fNoColumnBalance = false; + fConvMailMergeEsc = false; + fSuppressTopSpacing = false; + fOrigWordTableRules = false; + fTransparentMetafiles = false; + fShowBreaksInFrames = false; + fSwapBordersFacingPgs = false; + dxaTab = 0; + wSpare = 0; + dxaHotZ = 0; + cConsecHypLim = 0; + wSpare2 = 0; + nRevision = 0; + tmEdited = 0; + cWords = 0; + cCh = 0; + cPg = 0; + cParas = 0; + rncEdn = 0; + nEdn = 0; + Epc = 0; + nfcFtnRef = 0; + nfcEdnRef = 0; + fPrintFormData = false; + fSaveFormData = false; + fShadeFormData = false; + fWCFtnEdn = false; + cLines = 0; + cWordsFtnEdn = 0; + cChFtnEdn = 0; + cPgFtnEdn = 0; + cParasFtnEdn = 0; + cLinesFtnEdn = 0; + lKeyProtDoc = 0; + wvkSaved = 0; + wScaleSaved = 0; + zkSaved = 0; + fRotateFontW6 = false; + iGutterPos = false; + fSuppressTopSpacingMac5 = false; + fTruncDxaExpand = false; + fPrintBodyBeforeHdr = false; + fNoLeading = false; + fMWSmallCaps = false; + adt = 0; + doptypography = NULL; + dogrid = NULL; + lvl = 0; + fGramAllDone = false; + fGramAllClean = false; + fSubsetFonts = false; + fHideLastVersion = false; + fHtmlDoc = false; + fSnapBorder = false; + fIncludeHeader = false; + fIncludeFooter = false; + fForcePageSizePag = false; + fMinFontSizePag = false; + fHaveVersions = false; + fAutoVersion = false; + asumyi = NULL; + cChWS = 0; + cChWSFtnEdn = 0; + grfDocEvents = 0; + fVirusPromted = false; + fVirusLoadSafe = false; + KeyVirusSession30 = 0; + cDBC = 0; + cDBCFtnEdn = 0; + hpsZoonFontPag = 0; + dywDispPag = 0; + ilvlLastBulletMain = 0; + ilvlLastNumberMain = 0; + istdClickTypePara = 0; + fLADAllDone = false; + fEnvelopeVis = false; + fMaybeTentativeListInDoc = false; + fMaybeFitText = false; + fRelyOnCss_WebOpt = false; + fRelyOnVML_WebOpt = false; + fAllowPNG_WebOpt = false; + screenSize_WebOpt = 0; + fOrganizeInFolder_WebOpt = false; + fUseLongFileNames_WebOpt = false; + iPixelsPerInch_WebOpt = 0; + fWebOptionsInit = false; + fMaybeFEL = false; + fCharLineUnits = false; + fMaybeRTLTables = false; + fLeaveBackslashAlone = false; + fExpShRtn = false; + fDntULTrlSpc = false; + fDntBlnSbDbWid = false; + fMakeSpaceForUL = false; + f2ptExtLeadingOnly = false; + fTruncFontHeight = false; + fSubOnSize = false; + fLineWrapLikeWord6 = false; + fWW6BorderRules = false; + fExactOnTop = false; + fExtraAfter = false; + fWPSpace = false; + fWPJust = false; + fPrintMet = false; + fSpLayoutLikeWW8 = false; + fFtnLayoutLikeWW8 = false; + fDontUseHTMLParagraphAutoSpacing = false; + fDontAdjustLineHeightInTable = false; + fForgetLastTabAlign = false; + fUseAutoSpaceForFullWidthAlpha = false; + fAlignTablesRowByRow = false; + fLayoutRawTableWidth = false; + fLayoutTableRowsApart = false; + fUserWord97LineBreakingRules = false; + fDontBreakWrappedTables = false; + fDontSnapToGridInCell = false; + fDontAllowFieldEndSelect = false; + fApplyBreakingRules = false; + fDontWrapTextWithPunct = false; + fDontUseAsianBreakRules = false; + fUseWord2002TableStyleRules = false; + fGrowAutofit = false; + fUseNormalStyleForList = false; + fDontUseIndentAsNumberingTabStop = false; + fFELineBreak11 = false; + fAllowSpaceOfSameStyleInTable = false; + fWW11IndentRules = false; + fDontAutofitConstrainedTables = false; + fAutofitLikeWW11 = false; + fUnderlineTabInNumList = false; + fHangulWidthLikeWW11 = false; + fSplitPgBreakAndParaMark = false; + fDontVertAlignCellWithSp = false; + fDontBreakConstrainedForcedTables = false; + fDontVertAlignInTxbx = false; + fWord11KerningPairs = false; + fCachedColBalance = false; + verCompatPreW10 = 0; + fNoMargPgvwSaved = false; + fNoMargPgvWPag = false; + fWebViewPag = false; + fSeeDrawingsPag = false; + fBulletProofed = false; + fCorrupted = false; + fSaveUim = false; + fFilterPrivacy = false; + fInFReplaceNoRM = false; + fSeenRepairs = false; + fHasXML = false; + fSeeScriptAnchorsPag = false; + fValidateXML = false; + fSaveIfInvalidXML = false; + fShowXMLErrors = false; + fAlwaysMergeEmptyNamespace = false; + cpMaxListCacheMainDoc = 0; + fDoNotEmbedSystemFont = false; + fWordCompact = false; + fLiveRecover = false; + fEmbedFactoids = false; + fFactoidXML = false; + fFactoidAllDone = false; + fFolioPrint = false; + fReverseFolio = false; + iTextLineEnding = false; + fHideFcc = false; + fAcetateShowMarkup = false; + fAcetateShowAtn = false; + fAcetateShowInsDel = false; + fAcetateShowProps = false; + istdTableDflt = 0; + verCompat = 0; + grfFmtFilter = 0; + iFolioPages = 0; + cpgText = 0; + cpMinRMText = 0; + cpMinRMFtn = 0; + cpMinRMHdd = 0; + cpMinRMAtn = 0; + cpMinRMEdn = 0; + cpMinRMTxbx = 0; + cpMinRMHdrTxbx = 0; + rsidRoot = 0; + fTreatLockAtnAsReadOnly = false; + fStyleLock = false; + fAutoFmtOverride = false; + fRemoveWordML = false; + fApplyCustomXForm = false; + fStyeLockEnforced = false; + fFakeLockAtn = false; + fIgnoreMixedContent = false; + fShowPlaceholderText = false; + grf = 0; + fReadingModeInkLockDown = false; + fAcetateShowInkAtn = false; + fFilterDttm = false; + fEnforceDocProt = false; + iDocProtCur = 0; + fDispBkSpSaved = false; + dxaPageLock = 0; + dyaPageLock = 0; + pctFontLock = 0; + grfitbid = 0; + ilfoMacAtCleanup = 0; + } } //кодировка 1251 diff --git a/ASCOfficeDocFile/DocDocxConverter/DocumentTypographyInfo.h b/ASCOfficeDocFile/DocDocxConverter/DocumentTypographyInfo.h index 71acadfca6..6cb305ac25 100644 --- a/ASCOfficeDocFile/DocDocxConverter/DocumentTypographyInfo.h +++ b/ASCOfficeDocFile/DocDocxConverter/DocumentTypographyInfo.h @@ -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( &(this->rgxchFPunct), fpunctBytes, 202, ENCODING_UNICODE ); + FormatUtils::GetSTLCollectionFromBytes( &(this->rgxchFPunct), fpunctBytes, 202, ENCODING_UTF16 ); unsigned char lpunctBytes[102]; memcpy( lpunctBytes, ( bytes + 208 ), 102 ); - FormatUtils::GetSTLCollectionFromBytes( &(this->rgxchLPunct), lpunctBytes, 102, ENCODING_UNICODE ); + FormatUtils::GetSTLCollectionFromBytes( &(this->rgxchLPunct), lpunctBytes, 102, ENCODING_UTF16 ); } else { diff --git a/ASCOfficeDocFile/DocDocxConverter/EndnotesMapping.h b/ASCOfficeDocFile/DocDocxConverter/EndnotesMapping.h index bb4ea4325b..a6b8c949bb 100644 --- a/ASCOfficeDocFile/DocDocxConverter/EndnotesMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/EndnotesMapping.h @@ -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() ); } } }; diff --git a/ASCOfficeDocFile/DocDocxConverter/FileInformationBlock.h b/ASCOfficeDocFile/DocDocxConverter/FileInformationBlock.h index 2725587e46..ebf5c23218 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FileInformationBlock.h +++ b/ASCOfficeDocFile/DocDocxConverter/FileInformationBlock.h @@ -29,19 +29,18 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ -#ifndef FileInformationBlock_h -#define FileInformationBlock_h +#pragma once #include "VirtualStreamReader.h" +#include "../../ASCOfficeXlsFile2/source/XlsFormat/Crypt/Decryptor.h" namespace DocFileFormat { typedef enum FibVersion { - //Fib1993 = 0x0065, // Word 6.0 - //Fib1995 = 0x0068, // Word 7.0 (95) - //Fib2002 = 0x0069, // Word 8.0 (97) - + Fib1993 = 0x0065, // Word 6.0 + Fib1995 = 0x0068, // Word 7.0 (95) + Fib1996 = 0x0069, // Word 8.0 (97) Fib1997 = 0x00C1, Fib2000 = 0x00D9, Fib2002 = 0x0101, @@ -51,6 +50,12 @@ namespace DocFileFormat typedef struct FibBase { + FibBase() : + wIdent(0), nFib(Fib1997), lid(0), pnNext(0), fDot(false), fGlsy(false), fComplex(false), fHasPic(false), + cQuickSaves(0), fEncrypted(false), fWhichTblStm(false), fReadOnlyRecommended(false), fWriteReservation(false), + fExtChar(false), fLoadOverwrite(false), fFarEast(false), fObfuscation(false), nFibBack(0), lKey(0), envr(0), fMac(false), + fEmptySpecial(false), fLoadOverridePage(false), fFutureSavedUndo(false), fWord97Saved(false), fcMin(0), fcMac(0) {} +//------------------------------------------------------------ WORD wIdent; FibVersion nFib; WORD lid; @@ -67,7 +72,7 @@ namespace DocFileFormat bool fExtChar; bool fLoadOverwrite; bool fFarEast; - bool fCrypto; + bool fObfuscation; WORD nFibBack; int lKey; unsigned char envr; @@ -87,6 +92,8 @@ namespace DocFileFormat typedef struct RgLw97 { + RgLw97() : cbMac(0), ccpText(0), ccpFtn(0), ccpHdr(0), ccpAtn(0), ccpEdn(0), ccpTxbx(0), ccpHdrTxbx(0) {} +//---------------------- int cbMac; int ccpText; int ccpFtn; @@ -99,6 +106,38 @@ namespace DocFileFormat typedef struct FibWord97 { + FibWord97() : + fcStshfOrig (0), lcbStshfOrig (0), fcStshf (0), lcbStshf (0), fcPlcffndRef (0), lcbPlcffndRef (0), + fcPlcffndTxt (0), lcbPlcffndTxt (0), fcPlcfandRef (0), lcbPlcfandRef (0), fcPlcfandTxt (0), lcbPlcfandTxt (0), + fcPlcfSed (0), lcbPlcfSed (0), fcPlcPad (0), lcbPlcPad (0), fcPlcfPhe (0), lcbPlcfPhe (0), + fcSttbfGlsy (0), lcbSttbfGlsy (0), fcPlcfGlsy (0), lcbPlcfGlsy (0), fcPlcfHdd (0), lcbPlcfHdd (0), + fcPlcfBteChpx (0), lcbPlcfBteChpx (0), fcPlcfBtePapx (0), lcbPlcfBtePapx (0), fcPlcfSea (0), lcbPlcfSea (0), + fcSttbfFfn (0), lcbSttbfFfn (0), fcPlcfFldMom (0), lcbPlcfFldMom (0), fcPlcfFldHdr (0), lcbPlcfFldHdr (0), + fcPlcfFldFtn (0), lcbPlcfFldFtn (0), fcPlcfFldAtn (0), lcbPlcfFldAtn (0), fcPlcfFldMcr (0), lcbPlcfFldMcr (0), + fcSttbfBkmk (0), lcbSttbfBkmk (0), fcPlcfBkf (0), lcbPlcfBkf (0), fcPlcfBkl (0), lcbPlcfBkl (0), + fcCmds (0), lcbCmds (0), fcSttbfMcr (0), lcbSttbfMcr (0), fcPrDrvr (0), lcbPrDrvr (0), + fcPrEnvPort (0), lcbPrEnvPort (0), fcPrEnvLand (0), lcbPrEnvLand (0), fcWss (0), lcbWss (0), + fcDop (0), lcbDop (0), fcSttbfAssoc (0), lcbSttbfAssoc (0), fcClx (0), lcbClx (0), + fcPlcfPgdFtn (0), lcbPlcfPgdFtn (0), fcAutosaveSource (0), lcbAutosaveSource (0), fcGrpXstAtnOwners (0), lcbGrpXstAtnOwners (0), + fcSttbfAtnBkmk (0), lcbSttbfAtnBkmk (0), fcPlcSpaMom (0), lcbPlcSpaMom (0), fcPlcSpaHdr (0), lcbPlcSpaHdr (0), + fcPlcfAtnBkf (0), lcbPlcfAtnBkf (0), fcPlcfAtnBkl (0), lcbPlcfAtnBkl (0), fcPms (0), lcbPms (0), + fcFormFldSttbs (0), lcbFormFldSttbs (0), fcPlcfendRef (0), lcbPlcfendRef (0), fcPlcfendTxt (0), lcbPlcfendTxt (0), + fcPlcfFldEdn (0), lcbPlcfFldEdn (0), fcDggInfo (0), lcbDggInfo (0), fcSttbfRMark (0), lcbSttbfRMark (0), + fcSttbfCaption (0), lcbSttbfCaption (0), fcSttbfAutoCaption (0), lcbSttbfAutoCaption (0), fcPlcfWkb (0), lcbPlcfWkb (0), + fcPlcfSpl (0), lcbPlcfSpl (0), fcPlcftxbxTxt (0), lcbPlcftxbxTxt (0), fcPlcfFldTxbx (0), lcbPlcfFldTxbx (0), + fcPlcfHdrtxbxTxt (0), lcbPlcfHdrtxbxTxt (0), fcPlcffldHdrTxbx (0), lcbPlcffldHdrTxbx (0), fcStwUser (0), lcbStwUser (0), + fcSttbTtmbd (0), lcbSttbTtmbd (0), fcCookieData (0), lcbCookieData (0), fcPgdMotherOldOld (0), lcbPgdMotherOldOld (0), + fcBkdMotherOldOld (0), lcbBkdMotherOldOld (0), fcPgdFtnOldOld (0), lcbPgdFtnOldOld (0),fcBkdFtnOldOld (0), lcbBkdFtnOldOld (0), + fcPgdEdnOldOld (0), lcbPgdEdnOldOld (0), fcBkdEdnOldOld (0), lcbBkdEdnOldOld (0),fcSttbfIntlFld (0), lcbSttbfIntlFld (0), + fcRouteSlip (0), lcbRouteSlip (0), fcSttbSavedBy (0), lcbSttbSavedBy (0), fcSttbFnm (0), lcbSttbFnm (0), + fcPlfLst (0), lcbPlfLst (0), fcPlfLfo (0), lcbPlfLfo (0), fcPlcfTxbxBkd (0), lcbPlcfTxbxBkd (0), + fcPlcfTxbxHdrBkd (0), lcbPlcfTxbxHdrBkd (0), fcDocUndoWord9 (0), lcbDocUndoWord9 (0),fcRgbUse (0), lcbRgbUse (0), + fcUsp (0), lcbUsp (0), fcUskf (0), lcbUskf (0), fcPlcupcRgbUse (0), lcbPlcupcRgbUse (0), + fcPlcupcUsp (0), lcbPlcupcUsp (0), fcSttbGlsyStyle (0), lcbSttbGlsyStyle (0), fcPlgosl (0), lcbPlgosl (0), + fcPlcocx (0), lcbPlcocx (0), fcPlcfBteLvc (0), lcbPlcfBteLvc (0), dwLowDateTime (0), dwHighDateTime (0), + fcPlcfLvcPre10 (0), lcbPlcfLvcPre10 (0), fcPlcfAsumy (0), lcbPlcfAsumy (0), fcPlcfGram (0), lcbPlcfGram (0), + fcSttbListNames (0), lcbSttbListNames (0), fcSttbfUssr (0), lcbSttbfUssr (0) {} + //----------------------------------------------------------------- unsigned int fcStshfOrig; unsigned int lcbStshfOrig; unsigned int fcStshf; @@ -457,148 +496,324 @@ namespace DocFileFormat unsigned int lcbColorSchemeMapping; } FibWord2007; - typedef struct FibNew + struct FibNew { + FibNew() : nFibNew(Fib1997), cQuickSavesNew(0) {} FibVersion nFibNew; WORD cQuickSavesNew; - } FibNew; + }; class FileInformationBlock { public: - FibBase m_FibBase; - RgW97 m_RgW97; - RgLw97 m_RgLw97; - FibWord97 m_FibWord97; - FibWord2000 m_FibWord2000; - FibWord2002 m_FibWord2002; - FibWord2003 m_FibWord2003; - FibWord2007 m_FibWord2007; - FibNew m_FibNew; + bool m_bOlderVersion; + int m_CodePage; + CRYPT::DecryptorPtr m_Decryptor; + FibBase m_FibBase; + + RgW97 m_RgW97; + RgLw97 m_RgLw97; + + FibWord97 m_FibWord97; + FibWord2000 m_FibWord2000; + FibWord2002 m_FibWord2002; + FibWord2003 m_FibWord2003; + FibWord2007 m_FibWord2007; + + FibNew m_FibNew; - WORD csw; - WORD cslw; - WORD cbRgFcLcb; - WORD cswNew; - - FileInformationBlock( VirtualStreamReader reader ) + WORD csw; + WORD cslw; + WORD cbRgFcLcb; + WORD cswNew; + + void reset( VirtualStreamReader reader ) { - unsigned int flag16 = 0; - unsigned char flag8 = 0; - - //read the FIB base - this->m_FibBase.wIdent = reader.ReadUInt16(); //0 - this->m_FibBase.nFib = (FibVersion)reader.ReadUInt16(); //2 - reader.ReadBytes( 2, false ); //4 - this->m_FibBase.lid = reader.ReadUInt16(); //6 - this->m_FibBase.pnNext = reader.ReadInt16(); //8 - flag16 = reader.ReadUInt16(); //10 - this->m_FibBase.fDot = FormatUtils::BitmaskToBool((int)flag16, 0x0001); - this->m_FibBase.fGlsy = FormatUtils::BitmaskToBool((int)flag16, 0x0002); - this->m_FibBase.fComplex = FormatUtils::BitmaskToBool((int)flag16, 0x0002); - this->m_FibBase.fHasPic = FormatUtils::BitmaskToBool((int)flag16, 0x0008); - this->m_FibBase.cQuickSaves = (WORD)(((int)flag16 & 0x00F0) >> 4); - this->m_FibBase.fEncrypted = FormatUtils::BitmaskToBool((int)flag16, 0x0100); - this->m_FibBase.fWhichTblStm = FormatUtils::BitmaskToBool((int)flag16, 0x0200); - this->m_FibBase.fReadOnlyRecommended = FormatUtils::BitmaskToBool((int)flag16, 0x0400); - this->m_FibBase.fWriteReservation = FormatUtils::BitmaskToBool((int)flag16, 0x0800); - this->m_FibBase.fExtChar = FormatUtils::BitmaskToBool((int)flag16, 0x1000); - this->m_FibBase.fLoadOverwrite = FormatUtils::BitmaskToBool((int)flag16, 0x2000); - this->m_FibBase.fFarEast = FormatUtils::BitmaskToBool((int)flag16, 0x4000); - this->m_FibBase.fCrypto = FormatUtils::BitmaskToBool((int)flag16, 0x8000); - this->m_FibBase.nFibBack = reader.ReadUInt16(); //12 - this->m_FibBase.lKey = reader.ReadInt32(); //14 - this->m_FibBase.envr = reader.ReadByte(); //18 - flag8 = reader.ReadByte(); //19 - this->m_FibBase.fMac = FormatUtils::BitmaskToBool((int)flag8, 0x01); - this->m_FibBase.fEmptySpecial = FormatUtils::BitmaskToBool((int)flag8, 0x02); - this->m_FibBase.fLoadOverridePage = FormatUtils::BitmaskToBool((int)flag8, 0x04); - this->m_FibBase.fFutureSavedUndo = FormatUtils::BitmaskToBool((int)flag8, 0x08); - this->m_FibBase.fWord97Saved = FormatUtils::BitmaskToBool((int)flag8, 0x10); - reader.ReadBytes( 4, false ); //20 - this->m_FibBase.fcMin = reader.ReadInt32(); //24 - this->m_FibBase.fcMac = reader.ReadInt32(); //28 - - this->csw = reader.ReadUInt16(); //32 - - //read the RgW97 - reader.ReadBytes( 26, false ); //34 - this->m_RgW97.lidFE = reader.ReadUInt16(); //60 - - this->cslw = reader.ReadUInt16(); //62 - - //read the RgLW97 - m_RgLw97.cbMac = reader.ReadInt32(); //64 - reader.ReadBytes(8, false); //68 - m_RgLw97.ccpText = reader.ReadInt32(); //76 - m_RgLw97.ccpFtn = reader.ReadInt32(); //80 - m_RgLw97.ccpHdr = reader.ReadInt32(); //84 - - reader.ReadBytes( 4, false ); //88 - - m_RgLw97.ccpAtn = reader.ReadInt32(); //92 - m_RgLw97.ccpEdn = reader.ReadInt32(); //96 - m_RgLw97.ccpTxbx = reader.ReadInt32(); //100 - m_RgLw97.ccpHdrTxbx = reader.ReadInt32(); //104 - - reader.ReadBytes(44, false); //108 - - cbRgFcLcb = reader.ReadUInt16(); //152 - - if (m_FibBase.nFib >= Fib1997) + if (m_FibBase.nFib > 0 && m_FibBase.nFib < Fib1997) { + m_RgLw97.cbMac = reader.ReadInt32();//32 + /*m_FibWord97.fcSpare0 = */reader.ReadInt32(); + /*m_FibWord97.fcSpare1 = */reader.ReadInt32(); + /*m_FibWord97.fcSpare2 = */reader.ReadInt32(); + /*m_FibWord97.fcSpare3 = */reader.ReadInt32(); //48 + m_RgLw97.ccpText = reader.ReadInt32(); + m_RgLw97.ccpFtn = reader.ReadInt32(); + m_RgLw97.ccpHdr = reader.ReadInt32(); + + /*m_FibWord97.ccpMcr = */reader.ReadInt32(); + m_RgLw97.ccpAtn = reader.ReadInt32(); + m_RgLw97.ccpEdn = reader.ReadInt32(); + m_RgLw97.ccpTxbx = reader.ReadInt32(); + m_RgLw97.ccpHdrTxbx = reader.ReadInt32(); + + /*m_FibWord97.ccpSpare2 = */reader.ReadInt32(); //84 + m_FibWord97.fcStshfOrig = reader.ReadInt32(); + m_FibWord97.lcbStshfOrig = reader.ReadInt32(); + m_FibWord97.fcStshf = reader.ReadInt32(); + m_FibWord97.lcbStshf = reader.ReadInt32(); + m_FibWord97.fcPlcffndRef = reader.ReadInt32(); + m_FibWord97.lcbPlcffndRef = reader.ReadInt32(); + + m_FibWord97.lcbPlcfandTxt = reader.ReadInt32();//112 + + m_FibWord97.lcbPlcffndTxt = reader.ReadInt32(); + + m_FibWord97.fcPlcfandRef = reader.ReadInt32(); + m_FibWord97.lcbPlcfandRef = reader.ReadInt32(); + + m_FibWord97.fcPlcfandTxt = reader.ReadInt32(); + m_FibWord97.lcbPlcfandTxt = reader.ReadInt32(); + + m_FibWord97.fcPlcfSed = reader.ReadInt32(); //136 + m_FibWord97.lcbPlcfSed = reader.ReadInt32(); + + m_FibWord97.fcPlcPad = reader.ReadInt32(); + m_FibWord97.lcbPlcPad = reader.ReadInt32(); + + m_FibWord97.fcPlcfPhe = reader.ReadInt32(); + m_FibWord97.lcbPlcfPhe = reader.ReadInt32(); + + m_FibWord97.fcSttbfGlsy = reader.ReadInt32(); + m_FibWord97.lcbSttbfGlsy = reader.ReadInt32(); + + m_FibWord97.fcPlcfGlsy = reader.ReadInt32(); + m_FibWord97.lcbPlcfGlsy = reader.ReadInt32(); + m_FibWord97.fcPlcfHdd = reader.ReadInt32(); + m_FibWord97.lcbPlcfHdd = reader.ReadInt32(); + + m_FibWord97.fcPlcfBteChpx = reader.ReadInt32(); + m_FibWord97.lcbPlcfBteChpx = reader.ReadInt32(); + + m_FibWord97.fcPlcfBtePapx = reader.ReadInt32(); + m_FibWord97.lcbPlcfBtePapx = reader.ReadInt32(); + + m_FibWord97.fcPlcfSea = reader.ReadInt32(); + m_FibWord97.lcbPlcfSea = reader.ReadInt32(); + + m_FibWord97.fcSttbfFfn = reader.ReadInt32(); + m_FibWord97.lcbSttbfFfn = reader.ReadInt32(); + + m_FibWord97.fcPlcfFldMom = reader.ReadInt32(); //216 + m_FibWord97.lcbPlcfFldMom = reader.ReadInt32(); + + m_FibWord97.fcPlcfFldHdr = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldHdr = reader.ReadInt32(); + + m_FibWord97.fcPlcfFldFtn = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldFtn = reader.ReadInt32(); + + m_FibWord97.fcPlcfFldAtn = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldAtn = reader.ReadInt32(); + + m_FibWord97.fcPlcfFldMcr = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldMcr = reader.ReadInt32(); + + m_FibWord97.fcSttbfBkmk = reader.ReadInt32(); + m_FibWord97.lcbSttbfBkmk = reader.ReadInt32(); + + m_FibWord97.fcPlcfBkf = reader.ReadInt32(); + m_FibWord97.lcbPlcfBkf = reader.ReadInt32(); + + m_FibWord97.fcPlcfBkl = reader.ReadInt32(); + m_FibWord97.lcbPlcfBkl = reader.ReadInt32(); + + m_FibWord97.fcCmds = reader.ReadInt32(); + m_FibWord97.lcbCmds = reader.ReadInt32(); + + /*m_FibWord97.fcPlcMcr = */reader.ReadInt32(); + /*m_FibWord97.lcbPlcMcr = */reader.ReadInt32(); + + m_FibWord97.fcSttbfMcr = reader.ReadInt32(); + m_FibWord97.lcbSttbfMcr = reader.ReadInt32(); + + m_FibWord97.fcPrDrvr = reader.ReadInt32(); + m_FibWord97.lcbPrDrvr = reader.ReadInt32(); + + m_FibWord97.fcPrEnvPort = reader.ReadInt32(); + m_FibWord97.lcbPrEnvPort = reader.ReadInt32(); //316 + + m_FibWord97.fcPrEnvLand = reader.ReadInt32(); + m_FibWord97.lcbPrEnvLand = reader.ReadInt32(); + + m_FibWord97.fcWss = reader.ReadInt32(); + m_FibWord97.lcbWss = reader.ReadInt32(); + + m_FibWord97.fcDop = reader.ReadInt32(); + m_FibWord97.lcbDop = reader.ReadInt32(); + + m_FibWord97.fcSttbfAssoc = reader.ReadInt32(); + m_FibWord97.lcbSttbfAssoc = reader.ReadInt32(); + + m_FibWord97.fcClx = reader.ReadInt32(); + m_FibWord97.lcbClx = reader.ReadInt32(); + + m_FibWord97.fcPlcfPgdFtn = reader.ReadInt32(); + m_FibWord97.lcbPlcfPgdFtn = reader.ReadInt32(); + + m_FibWord97.fcAutosaveSource = reader.ReadInt32(); + m_FibWord97.lcbAutosaveSource = reader.ReadInt32(); + m_FibWord97.fcGrpXstAtnOwners = reader.ReadInt32(); + m_FibWord97.lcbGrpXstAtnOwners = reader.ReadInt32(); + + m_FibWord97.fcSttbfAtnBkmk = reader.ReadInt32(); + m_FibWord97.lcbSttbfAtnBkmk = reader.ReadInt32(); + /*m_FibWord97.wSpare4Fib = */reader.ReadInt16(); //392 + /*m_FibWord97.pnChpFirst = */reader.ReadInt16(); + /*m_FibWord97.pnPapFirst = */reader.ReadInt16(); + + /*m_FibWord97.cpnBteChp = */reader.ReadInt16(); + /*m_FibWord97.cpnBtePap = */reader.ReadInt16(); + + m_FibWord97.fcPlcSpaMom = reader.ReadInt32(); + m_FibWord97.lcbPlcSpaMom = reader.ReadInt32(); + + m_FibWord97.fcPlcSpaHdr = reader.ReadInt32(); /*fcPlcfdoaHdr*/ + m_FibWord97.lcbPlcSpaHdr = reader.ReadInt32(); /*lcbPlcfdoaHdr*/ + + /*m_FibWord97.fcUnused1 =*/ reader.ReadInt32(); + /*m_FibWord97.lcbUnused1 =*/ reader.ReadInt32(); + /*m_FibWord97.fcUnused2 =*/ reader.ReadInt32(); + /*m_FibWord97.lcbUnused2 =*/ reader.ReadInt32(); + + m_FibWord97.fcPlcfAtnBkf = reader.ReadInt32(); + m_FibWord97.lcbPlcfAtnBkf = reader.ReadInt32(); + m_FibWord97.fcPlcfAtnBkl = reader.ReadInt32(); + m_FibWord97.lcbPlcfAtnBkl = reader.ReadInt32(); + m_FibWord97.fcPms = reader.ReadInt32(); + m_FibWord97.lcbPms = reader.ReadInt32(); + m_FibWord97.fcFormFldSttbs/*f*/ = reader.ReadInt32(); + m_FibWord97.lcbFormFldSttbs/*f*/= reader.ReadInt32(); + + m_FibWord97.fcPlcfendRef = reader.ReadInt32(); //466 + m_FibWord97.lcbPlcfendRef = reader.ReadInt32(); + m_FibWord97.fcPlcfendTxt = reader.ReadInt32(); + m_FibWord97.lcbPlcfendTxt = reader.ReadInt32(); + m_FibWord97.fcPlcfFldEdn = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldEdn = reader.ReadInt32(); + /*m_FibWord97.fcPlcfpgdEdn =*/ reader.ReadInt32(); + /*m_FibWord97.lcbPlcfpgdEdn =*/ reader.ReadInt32(); + /*m_FibWord97.fcUnused3 =*/ reader.ReadInt32(); + /*m_FibWord97.lcbUnused3 =*/ reader.ReadInt32(); + m_FibWord97.fcSttbfRMark = reader.ReadInt32(); + m_FibWord97.lcbSttbfRMark = reader.ReadInt32(); + m_FibWord97.fcSttbfCaption = reader.ReadInt32(); + m_FibWord97.lcbSttbfCaption = reader.ReadInt32(); + m_FibWord97.fcSttbfAutoCaption = reader.ReadInt32(); + m_FibWord97.lcbSttbfAutoCaption = reader.ReadInt32(); + m_FibWord97.fcPlcfWkb = reader.ReadInt32(); //530 + m_FibWord97.lcbPlcfWkb = reader.ReadInt32(); + /*m_FibWord97.fcUnused4 =*/ reader.ReadInt32(); + /*m_FibWord97.lcbUnused4 =*/ reader.ReadInt32(); + m_FibWord97.fcPlcftxbxTxt = reader.ReadInt32(); + m_FibWord97.lcbPlcftxbxTxt = reader.ReadInt32(); + m_FibWord97.fcPlcfFldTxbx = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldTxbx = reader.ReadInt32(); + m_FibWord97.fcPlcfHdrtxbxTxt = reader.ReadInt32(); + m_FibWord97.lcbPlcfHdrtxbxTxt = reader.ReadInt32(); + m_FibWord97.fcPlcffldHdrTxbx = reader.ReadInt32(); + m_FibWord97.lcbPlcffldHdrTxbx = reader.ReadInt32(); + m_FibWord97.fcStwUser = reader.ReadInt32(); + m_FibWord97.lcbStwUser = reader.ReadInt32(); + m_FibWord97.fcSttbTtmbd = reader.ReadInt32(); + m_FibWord97.lcbSttbTtmbd = reader.ReadInt32(); + /*m_FibWord97.fcPlcunused = */reader.ReadInt32(); + /*m_FibWord97.lcbUnused = */reader.ReadInt32(); + + m_FibWord97.fcPgdMotherOldOld = reader.ReadInt32(); /*fcpgdMother.fcPgd*/ //602 + m_FibWord97.lcbPgdMotherOldOld = reader.ReadInt32(); /*fcPgdMother.lcbPgd*/ + m_FibWord97.fcBkdMotherOldOld = reader.ReadInt32(); /*fcPgdMother.fcBkd*/ + m_FibWord97.lcbBkdMotherOldOld = reader.ReadInt32(); /*fcPgdMother.lcbBkd*/ // ???? size 2 ???? + + m_FibWord97.fcPgdFtnOldOld = reader.ReadInt32(); /*fcPgdFtn.fcPgd*/ + m_FibWord97.lcbPgdFtnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbPgd*/ + m_FibWord97.fcBkdFtnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.fcBkd*/ + m_FibWord97.lcbBkdFtnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbBkd*/ + + m_FibWord97.fcPgdEdnOldOld = reader.ReadInt32(); /*fcpgdFtn.fcPgd*/ + m_FibWord97.lcbPgdEdnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbPgd*/ + m_FibWord97.fcBkdEdnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.fcBkd*/ + m_FibWord97.lcbBkdEdnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbBkd*/ + + m_FibWord97.fcSttbfIntlFld = reader.ReadInt32(); + m_FibWord97.lcbSttbfIntlFld = reader.ReadInt32(); + m_FibWord97.fcRouteSlip = reader.ReadInt32(); //656 + m_FibWord97.lcbRouteSlip = reader.ReadInt32(); + m_FibWord97.fcSttbSavedBy = reader.ReadInt32(); + m_FibWord97.lcbSttbSavedBy = reader.ReadInt32(); + m_FibWord97.fcSttbFnm = reader.ReadInt32(); + m_FibWord97.lcbSttbFnm = reader.ReadInt32(); //676 + } + if (m_FibBase.nFib >= Fib1997 || m_FibBase.nFib == 0) + { + reader.ReadBytes(8, false); //68 + + m_RgLw97.ccpText = reader.ReadInt32(); //76 + m_RgLw97.ccpFtn = reader.ReadInt32(); //80 + m_RgLw97.ccpHdr = reader.ReadInt32(); //84 + + reader.ReadBytes( 4, false ); //88 + + m_RgLw97.ccpAtn = reader.ReadInt32(); //92 + m_RgLw97.ccpEdn = reader.ReadInt32(); //96 + m_RgLw97.ccpTxbx = reader.ReadInt32(); //100 + m_RgLw97.ccpHdrTxbx = reader.ReadInt32(); //104 + + reader.ReadBytes(44, false); //108 + + cbRgFcLcb = reader.ReadUInt16(); //152 + //Read the FibRgFcLcb97 - m_FibWord97.fcStshfOrig = reader.ReadUInt32(); //154 - m_FibWord97.lcbStshfOrig = reader.ReadUInt32(); //158 - m_FibWord97.fcStshf = reader.ReadUInt32(); //162 - m_FibWord97.lcbStshf = reader.ReadUInt32(); //166 - m_FibWord97.fcPlcffndRef = reader.ReadUInt32(); //170 - m_FibWord97.lcbPlcffndRef = reader.ReadUInt32(); //174 - m_FibWord97.fcPlcffndTxt = reader.ReadUInt32(); //178 - m_FibWord97.lcbPlcffndTxt = reader.ReadUInt32(); //182 - m_FibWord97.fcPlcfandRef = reader.ReadUInt32(); //186 - m_FibWord97.lcbPlcfandRef = reader.ReadUInt32(); //190 - m_FibWord97.fcPlcfandTxt = reader.ReadUInt32(); //194 - m_FibWord97.lcbPlcfandTxt = reader.ReadUInt32(); //198 - m_FibWord97.fcPlcfSed = reader.ReadUInt32(); //202 - m_FibWord97.lcbPlcfSed = reader.ReadUInt32(); //206 - m_FibWord97.fcPlcPad = reader.ReadUInt32(); //210 - m_FibWord97.lcbPlcPad = reader.ReadUInt32(); //214 - m_FibWord97.fcPlcfPhe = reader.ReadUInt32(); //218 - m_FibWord97.lcbPlcfPhe = reader.ReadUInt32(); //222 - m_FibWord97.fcSttbfGlsy = reader.ReadUInt32(); //226 - m_FibWord97.lcbSttbfGlsy = reader.ReadUInt32(); //230 - m_FibWord97.fcPlcfGlsy = reader.ReadUInt32(); //234 - m_FibWord97.lcbPlcfGlsy = reader.ReadUInt32(); //238 - m_FibWord97.fcPlcfHdd = reader.ReadUInt32(); //242 - m_FibWord97.lcbPlcfHdd = reader.ReadUInt32(); //246 - m_FibWord97.fcPlcfBteChpx = reader.ReadUInt32(); //250 - m_FibWord97.lcbPlcfBteChpx = reader.ReadUInt32(); //254 - m_FibWord97.fcPlcfBtePapx = reader.ReadUInt32(); //258 - m_FibWord97.lcbPlcfBtePapx = reader.ReadUInt32(); //262 - m_FibWord97.fcPlcfSea = reader.ReadUInt32(); //266 - m_FibWord97.lcbPlcfSea = reader.ReadUInt32(); //270 - m_FibWord97.fcSttbfFfn = reader.ReadUInt32(); //274 - m_FibWord97.lcbSttbfFfn = reader.ReadUInt32(); //278 - m_FibWord97.fcPlcfFldMom = reader.ReadUInt32(); //282 - m_FibWord97.lcbPlcfFldMom = reader.ReadUInt32(); //286 - m_FibWord97.fcPlcfFldHdr = reader.ReadUInt32(); //290 - m_FibWord97.lcbPlcfFldHdr = reader.ReadUInt32(); //294 - m_FibWord97.fcPlcfFldFtn = reader.ReadUInt32(); //298 - m_FibWord97.lcbPlcfFldFtn = reader.ReadUInt32(); //302 - m_FibWord97.fcPlcfFldAtn = reader.ReadUInt32(); //306 - m_FibWord97.lcbPlcfFldAtn = reader.ReadUInt32(); //310 - m_FibWord97.fcPlcfFldMcr = reader.ReadUInt32(); //314 - m_FibWord97.lcbPlcfFldMcr = reader.ReadUInt32(); //318 - m_FibWord97.fcSttbfBkmk = reader.ReadUInt32(); //322 - m_FibWord97.lcbSttbfBkmk = reader.ReadUInt32(); //326 - m_FibWord97.fcPlcfBkf = reader.ReadUInt32(); //330 - m_FibWord97.lcbPlcfBkf = reader.ReadUInt32(); //334 - m_FibWord97.fcPlcfBkl = reader.ReadUInt32(); //338 - m_FibWord97.lcbPlcfBkl = reader.ReadUInt32(); //342 - m_FibWord97.fcCmds = reader.ReadUInt32(); //346 - m_FibWord97.lcbCmds = reader.ReadUInt32(); //350 + m_FibWord97.fcStshfOrig = reader.ReadUInt32(); //154 + m_FibWord97.lcbStshfOrig = reader.ReadUInt32(); //158 + m_FibWord97.fcStshf = reader.ReadUInt32(); //162 + m_FibWord97.lcbStshf = reader.ReadUInt32(); //166 + m_FibWord97.fcPlcffndRef = reader.ReadUInt32(); //170 + m_FibWord97.lcbPlcffndRef = reader.ReadUInt32(); //174 + m_FibWord97.fcPlcffndTxt = reader.ReadUInt32(); //178 + m_FibWord97.lcbPlcffndTxt = reader.ReadUInt32(); //182 + m_FibWord97.fcPlcfandRef = reader.ReadUInt32(); //186 + m_FibWord97.lcbPlcfandRef = reader.ReadUInt32(); //190 + m_FibWord97.fcPlcfandTxt = reader.ReadUInt32(); //194 + m_FibWord97.lcbPlcfandTxt = reader.ReadUInt32(); //198 + m_FibWord97.fcPlcfSed = reader.ReadUInt32(); //202 + m_FibWord97.lcbPlcfSed = reader.ReadUInt32(); //206 + m_FibWord97.fcPlcPad = reader.ReadUInt32(); //210 + m_FibWord97.lcbPlcPad = reader.ReadUInt32(); //214 + m_FibWord97.fcPlcfPhe = reader.ReadUInt32(); //218 + m_FibWord97.lcbPlcfPhe = reader.ReadUInt32(); //222 + m_FibWord97.fcSttbfGlsy = reader.ReadUInt32(); //226 + m_FibWord97.lcbSttbfGlsy = reader.ReadUInt32(); //230 + m_FibWord97.fcPlcfGlsy = reader.ReadUInt32(); //234 + m_FibWord97.lcbPlcfGlsy = reader.ReadUInt32(); //238 + m_FibWord97.fcPlcfHdd = reader.ReadUInt32(); //242 + m_FibWord97.lcbPlcfHdd = reader.ReadUInt32(); //246 + m_FibWord97.fcPlcfBteChpx = reader.ReadUInt32(); //250 + m_FibWord97.lcbPlcfBteChpx = reader.ReadUInt32(); //254 + m_FibWord97.fcPlcfBtePapx = reader.ReadUInt32(); //258 + m_FibWord97.lcbPlcfBtePapx = reader.ReadUInt32(); //262 + m_FibWord97.fcPlcfSea = reader.ReadUInt32(); //266 + m_FibWord97.lcbPlcfSea = reader.ReadUInt32(); //270 + m_FibWord97.fcSttbfFfn = reader.ReadUInt32(); //274 + m_FibWord97.lcbSttbfFfn = reader.ReadUInt32(); //278 + m_FibWord97.fcPlcfFldMom = reader.ReadUInt32(); //282 + m_FibWord97.lcbPlcfFldMom = reader.ReadUInt32(); //286 + m_FibWord97.fcPlcfFldHdr = reader.ReadUInt32(); //290 + m_FibWord97.lcbPlcfFldHdr = reader.ReadUInt32(); //294 + m_FibWord97.fcPlcfFldFtn = reader.ReadUInt32(); //298 + m_FibWord97.lcbPlcfFldFtn = reader.ReadUInt32(); //302 + m_FibWord97.fcPlcfFldAtn = reader.ReadUInt32(); //306 + m_FibWord97.lcbPlcfFldAtn = reader.ReadUInt32(); //310 + m_FibWord97.fcPlcfFldMcr = reader.ReadUInt32(); //314 + m_FibWord97.lcbPlcfFldMcr = reader.ReadUInt32(); //318 + m_FibWord97.fcSttbfBkmk = reader.ReadUInt32(); //322 + m_FibWord97.lcbSttbfBkmk = reader.ReadUInt32(); //326 + m_FibWord97.fcPlcfBkf = reader.ReadUInt32(); //330 + m_FibWord97.lcbPlcfBkf = reader.ReadUInt32(); //334 + m_FibWord97.fcPlcfBkl = reader.ReadUInt32(); //338 + m_FibWord97.lcbPlcfBkl = reader.ReadUInt32(); //342 + m_FibWord97.fcCmds = reader.ReadUInt32(); //346 + m_FibWord97.lcbCmds = reader.ReadUInt32(); //350 reader.ReadUInt32(); // 354 reader.ReadUInt32(); // 358 @@ -635,322 +850,387 @@ namespace DocFileFormat reader.ReadUInt32(); //466 reader.ReadUInt32(); //470 - m_FibWord97.fcPlcSpaMom = reader.ReadUInt32(); //474 - m_FibWord97.lcbPlcSpaMom = reader.ReadUInt32(); //478 - m_FibWord97.fcPlcSpaHdr = reader.ReadUInt32(); //482 - m_FibWord97.lcbPlcSpaHdr = reader.ReadUInt32(); //486 - m_FibWord97.fcPlcfAtnBkf = reader.ReadUInt32(); //490 - m_FibWord97.lcbPlcfAtnBkf = reader.ReadUInt32(); //494 - m_FibWord97.fcPlcfAtnBkl = reader.ReadUInt32(); //498 - m_FibWord97.lcbPlcfAtnBkl = reader.ReadUInt32(); //502 - m_FibWord97.fcPms = reader.ReadUInt32(); //506 - m_FibWord97.lcbPms = reader.ReadUInt32(); //510 - m_FibWord97.fcFormFldSttbs = reader.ReadUInt32(); //514 + m_FibWord97.fcPlcSpaMom = reader.ReadUInt32(); //474 + m_FibWord97.lcbPlcSpaMom = reader.ReadUInt32(); //478 + m_FibWord97.fcPlcSpaHdr = reader.ReadUInt32(); //482 + m_FibWord97.lcbPlcSpaHdr = reader.ReadUInt32(); //486 + m_FibWord97.fcPlcfAtnBkf = reader.ReadUInt32(); //490 + m_FibWord97.lcbPlcfAtnBkf = reader.ReadUInt32(); //494 + m_FibWord97.fcPlcfAtnBkl = reader.ReadUInt32(); //498 + m_FibWord97.lcbPlcfAtnBkl = reader.ReadUInt32(); //502 + m_FibWord97.fcPms = reader.ReadUInt32(); //506 + m_FibWord97.lcbPms = reader.ReadUInt32(); //510 + m_FibWord97.fcFormFldSttbs = reader.ReadUInt32(); //514 m_FibWord97.lcbFormFldSttbs = reader.ReadUInt32(); //518 - m_FibWord97.fcPlcfendRef = reader.ReadUInt32(); //522 - m_FibWord97.lcbPlcfendRef = reader.ReadUInt32(); //526 - m_FibWord97.fcPlcfendTxt = reader.ReadUInt32(); //530 - m_FibWord97.lcbPlcfendTxt = reader.ReadUInt32(); //534 - m_FibWord97.fcPlcfFldEdn = reader.ReadUInt32(); //538 - m_FibWord97.lcbPlcfFldEdn = reader.ReadUInt32(); //542 + m_FibWord97.fcPlcfendRef = reader.ReadUInt32(); //522 + m_FibWord97.lcbPlcfendRef = reader.ReadUInt32(); //526 + m_FibWord97.fcPlcfendTxt = reader.ReadUInt32(); //530 + m_FibWord97.lcbPlcfendTxt = reader.ReadUInt32(); //534 + m_FibWord97.fcPlcfFldEdn = reader.ReadUInt32(); //538 + m_FibWord97.lcbPlcfFldEdn = reader.ReadUInt32(); //542 reader.ReadUInt32(); //546 reader.ReadUInt32(); //550 - m_FibWord97.fcDggInfo = reader.ReadUInt32(); //554 - m_FibWord97.lcbDggInfo = reader.ReadUInt32(); //558 - m_FibWord97.fcSttbfRMark = reader.ReadUInt32(); //562 - m_FibWord97.lcbSttbfRMark = reader.ReadUInt32(); //566 - m_FibWord97.fcSttbfCaption = reader.ReadUInt32(); //570 - m_FibWord97.lcbSttbfCaption = reader.ReadUInt32(); //574 - m_FibWord97.fcSttbfAutoCaption = reader.ReadUInt32(); //578 + m_FibWord97.fcDggInfo = reader.ReadUInt32(); //554 + m_FibWord97.lcbDggInfo = reader.ReadUInt32(); //558 + m_FibWord97.fcSttbfRMark = reader.ReadUInt32(); //562 + m_FibWord97.lcbSttbfRMark = reader.ReadUInt32(); //566 + m_FibWord97.fcSttbfCaption = reader.ReadUInt32(); //570 + m_FibWord97.lcbSttbfCaption = reader.ReadUInt32(); //574 + m_FibWord97.fcSttbfAutoCaption = reader.ReadUInt32(); //578 m_FibWord97.lcbSttbfAutoCaption = reader.ReadUInt32(); //582 - m_FibWord97.fcPlcfWkb = reader.ReadUInt32(); //586 - m_FibWord97.lcbPlcfWkb = reader.ReadUInt32(); //590 - m_FibWord97.fcPlcfSpl = reader.ReadUInt32(); //594 - m_FibWord97.lcbPlcfSpl = reader.ReadUInt32(); //598 - m_FibWord97.fcPlcftxbxTxt = reader.ReadUInt32(); //602 - m_FibWord97.lcbPlcftxbxTxt = reader.ReadUInt32(); //606 - m_FibWord97.fcPlcfFldTxbx = reader.ReadUInt32(); //610 - m_FibWord97.lcbPlcfFldTxbx = reader.ReadUInt32(); //614 - m_FibWord97.fcPlcfHdrtxbxTxt = reader.ReadUInt32(); //618 - m_FibWord97.lcbPlcfHdrtxbxTxt = reader.ReadUInt32(); //622 - m_FibWord97.fcPlcffldHdrTxbx = reader.ReadUInt32(); //626 - m_FibWord97.lcbPlcffldHdrTxbx = reader.ReadUInt32(); //630 - m_FibWord97.fcStwUser = reader.ReadUInt32(); //634 - m_FibWord97.lcbStwUser = reader.ReadUInt32(); //638 - m_FibWord97.fcSttbTtmbd = reader.ReadUInt32(); //642 - m_FibWord97.lcbSttbTtmbd = reader.ReadUInt32(); //646 - m_FibWord97.fcCookieData = reader.ReadUInt32(); //650 - m_FibWord97.lcbCookieData = reader.ReadUInt32(); //654 - m_FibWord97.fcPgdMotherOldOld = reader.ReadUInt32(); //658 - m_FibWord97.lcbPgdMotherOldOld = reader.ReadUInt32(); //662 - m_FibWord97.fcBkdMotherOldOld = reader.ReadUInt32(); //666 - m_FibWord97.lcbBkdMotherOldOld = reader.ReadUInt32(); //670 - m_FibWord97.fcPgdFtnOldOld = reader.ReadUInt32(); //674 - m_FibWord97.lcbPgdFtnOldOld = reader.ReadUInt32(); //678 - m_FibWord97.fcBkdFtnOldOld = reader.ReadUInt32(); //682 - m_FibWord97.lcbBkdFtnOldOld = reader.ReadUInt32(); //686 - m_FibWord97.fcPgdEdnOldOld = reader.ReadUInt32(); //690 - m_FibWord97.lcbPgdEdnOldOld = reader.ReadUInt32(); //694 - m_FibWord97.fcBkdEdnOldOld = reader.ReadUInt32(); //698 - m_FibWord97.lcbBkdEdnOldOld = reader.ReadUInt32(); //702 - m_FibWord97.fcSttbfIntlFld = reader.ReadUInt32(); //706 - m_FibWord97.lcbSttbfIntlFld = reader.ReadUInt32(); //710 - m_FibWord97.fcRouteSlip = reader.ReadUInt32(); //714 - m_FibWord97.lcbRouteSlip = reader.ReadUInt32(); //718 - m_FibWord97.fcSttbSavedBy = reader.ReadUInt32(); //722 - m_FibWord97.lcbSttbSavedBy = reader.ReadUInt32(); //726 - m_FibWord97.fcSttbFnm = reader.ReadUInt32(); //730 - m_FibWord97.lcbSttbFnm = reader.ReadUInt32(); //734 - m_FibWord97.fcPlfLst = reader.ReadUInt32(); //738 - m_FibWord97.lcbPlfLst = reader.ReadUInt32(); //742 - m_FibWord97.fcPlfLfo = reader.ReadUInt32(); //746 - m_FibWord97.lcbPlfLfo = reader.ReadUInt32(); //750 - m_FibWord97.fcPlcfTxbxBkd = reader.ReadUInt32(); //754 - m_FibWord97.lcbPlcfTxbxBkd = reader.ReadUInt32(); //758 - m_FibWord97.fcPlcfTxbxHdrBkd = reader.ReadUInt32(); //762 - m_FibWord97.lcbPlcfTxbxHdrBkd = reader.ReadUInt32(); //766 - m_FibWord97.fcDocUndoWord9 = reader.ReadUInt32(); //770 - m_FibWord97.lcbDocUndoWord9 = reader.ReadUInt32(); //774 - m_FibWord97.fcRgbUse = reader.ReadUInt32(); //778 - m_FibWord97.lcbRgbUse = reader.ReadUInt32(); //782 - m_FibWord97.fcUsp = reader.ReadUInt32(); //786 - m_FibWord97.lcbUsp = reader.ReadUInt32(); //790 - m_FibWord97.fcUskf = reader.ReadUInt32(); //794 - m_FibWord97.lcbUskf = reader.ReadUInt32(); //798 - m_FibWord97.fcPlcupcRgbUse = reader.ReadUInt32(); //802 - m_FibWord97.lcbPlcupcRgbUse = reader.ReadUInt32(); //806 - m_FibWord97.fcPlcupcUsp = reader.ReadUInt32(); //810 - m_FibWord97.lcbPlcupcUsp = reader.ReadUInt32(); //814 - m_FibWord97.fcSttbGlsyStyle = reader.ReadUInt32(); //818 - m_FibWord97.lcbSttbGlsyStyle = reader.ReadUInt32(); //822 - m_FibWord97.fcPlgosl = reader.ReadUInt32(); //826 - m_FibWord97.lcbPlgosl = reader.ReadUInt32(); //830 - m_FibWord97.fcPlcocx = reader.ReadUInt32(); //834 - m_FibWord97.lcbPlcocx = reader.ReadUInt32(); //838 - m_FibWord97.fcPlcfBteLvc = reader.ReadUInt32(); //842 - m_FibWord97.lcbPlcfBteLvc = reader.ReadUInt32(); //846 - m_FibWord97.dwLowDateTime = reader.ReadUInt32(); //850 - m_FibWord97.dwHighDateTime = reader.ReadUInt32(); //854 - m_FibWord97.fcPlcfLvcPre10 = reader.ReadUInt32(); //858 - m_FibWord97.lcbPlcfLvcPre10 = reader.ReadUInt32(); //862 - m_FibWord97.fcPlcfAsumy = reader.ReadUInt32(); //866 - m_FibWord97.lcbPlcfAsumy = reader.ReadUInt32(); //870 - m_FibWord97.fcPlcfGram = reader.ReadUInt32(); //874 - m_FibWord97.lcbPlcfGram = reader.ReadUInt32(); //878 - m_FibWord97.fcSttbListNames = reader.ReadUInt32(); //882 - m_FibWord97.lcbSttbListNames = reader.ReadUInt32(); //886 - m_FibWord97.fcSttbfUssr = reader.ReadUInt32(); //890 - m_FibWord97.lcbSttbfUssr = reader.ReadUInt32(); //894 + m_FibWord97.fcPlcfWkb = reader.ReadUInt32(); //586 + m_FibWord97.lcbPlcfWkb = reader.ReadUInt32(); //590 + m_FibWord97.fcPlcfSpl = reader.ReadUInt32(); //594 + m_FibWord97.lcbPlcfSpl = reader.ReadUInt32(); //598 + m_FibWord97.fcPlcftxbxTxt = reader.ReadUInt32(); //602 + m_FibWord97.lcbPlcftxbxTxt = reader.ReadUInt32(); //606 + m_FibWord97.fcPlcfFldTxbx = reader.ReadUInt32(); //610 + m_FibWord97.lcbPlcfFldTxbx = reader.ReadUInt32(); //614 + m_FibWord97.fcPlcfHdrtxbxTxt = reader.ReadUInt32(); //618 + m_FibWord97.lcbPlcfHdrtxbxTxt = reader.ReadUInt32(); //622 + m_FibWord97.fcPlcffldHdrTxbx = reader.ReadUInt32(); //626 + m_FibWord97.lcbPlcffldHdrTxbx = reader.ReadUInt32(); //630 + m_FibWord97.fcStwUser = reader.ReadUInt32(); //634 + m_FibWord97.lcbStwUser = reader.ReadUInt32(); //638 + m_FibWord97.fcSttbTtmbd = reader.ReadUInt32(); //642 + m_FibWord97.lcbSttbTtmbd = reader.ReadUInt32(); //646 + m_FibWord97.fcCookieData = reader.ReadUInt32(); //650 + m_FibWord97.lcbCookieData = reader.ReadUInt32(); //654 + m_FibWord97.fcPgdMotherOldOld = reader.ReadUInt32(); //658 + m_FibWord97.lcbPgdMotherOldOld = reader.ReadUInt32(); //662 + m_FibWord97.fcBkdMotherOldOld = reader.ReadUInt32(); //666 + m_FibWord97.lcbBkdMotherOldOld = reader.ReadUInt32(); //670 + m_FibWord97.fcPgdFtnOldOld = reader.ReadUInt32(); //674 + m_FibWord97.lcbPgdFtnOldOld = reader.ReadUInt32(); //678 + m_FibWord97.fcBkdFtnOldOld = reader.ReadUInt32(); //682 + m_FibWord97.lcbBkdFtnOldOld = reader.ReadUInt32(); //686 + m_FibWord97.fcPgdEdnOldOld = reader.ReadUInt32(); //690 + m_FibWord97.lcbPgdEdnOldOld = reader.ReadUInt32(); //694 + m_FibWord97.fcBkdEdnOldOld = reader.ReadUInt32(); //698 + m_FibWord97.lcbBkdEdnOldOld = reader.ReadUInt32(); //702 + m_FibWord97.fcSttbfIntlFld = reader.ReadUInt32(); //706 + m_FibWord97.lcbSttbfIntlFld = reader.ReadUInt32(); //710 + m_FibWord97.fcRouteSlip = reader.ReadUInt32(); //714 + m_FibWord97.lcbRouteSlip = reader.ReadUInt32(); //718 + m_FibWord97.fcSttbSavedBy = reader.ReadUInt32(); //722 + m_FibWord97.lcbSttbSavedBy = reader.ReadUInt32(); //726 + m_FibWord97.fcSttbFnm = reader.ReadUInt32(); //730 + m_FibWord97.lcbSttbFnm = reader.ReadUInt32(); //734 + m_FibWord97.fcPlfLst = reader.ReadUInt32(); //738 + m_FibWord97.lcbPlfLst = reader.ReadUInt32(); //742 + m_FibWord97.fcPlfLfo = reader.ReadUInt32(); //746 + m_FibWord97.lcbPlfLfo = reader.ReadUInt32(); //750 + m_FibWord97.fcPlcfTxbxBkd = reader.ReadUInt32(); //754 + m_FibWord97.lcbPlcfTxbxBkd = reader.ReadUInt32(); //758 + m_FibWord97.fcPlcfTxbxHdrBkd = reader.ReadUInt32(); //762 + m_FibWord97.lcbPlcfTxbxHdrBkd = reader.ReadUInt32(); //766 + m_FibWord97.fcDocUndoWord9 = reader.ReadUInt32(); //770 + m_FibWord97.lcbDocUndoWord9 = reader.ReadUInt32(); //774 + m_FibWord97.fcRgbUse = reader.ReadUInt32(); //778 + m_FibWord97.lcbRgbUse = reader.ReadUInt32(); //782 + m_FibWord97.fcUsp = reader.ReadUInt32(); //786 + m_FibWord97.lcbUsp = reader.ReadUInt32(); //790 + m_FibWord97.fcUskf = reader.ReadUInt32(); //794 + m_FibWord97.lcbUskf = reader.ReadUInt32(); //798 + m_FibWord97.fcPlcupcRgbUse = reader.ReadUInt32(); //802 + m_FibWord97.lcbPlcupcRgbUse = reader.ReadUInt32(); //806 + m_FibWord97.fcPlcupcUsp = reader.ReadUInt32(); //810 + m_FibWord97.lcbPlcupcUsp = reader.ReadUInt32(); //814 + m_FibWord97.fcSttbGlsyStyle = reader.ReadUInt32(); //818 + m_FibWord97.lcbSttbGlsyStyle = reader.ReadUInt32(); //822 + m_FibWord97.fcPlgosl = reader.ReadUInt32(); //826 + m_FibWord97.lcbPlgosl = reader.ReadUInt32(); //830 + m_FibWord97.fcPlcocx = reader.ReadUInt32(); //834 + m_FibWord97.lcbPlcocx = reader.ReadUInt32(); //838 + m_FibWord97.fcPlcfBteLvc = reader.ReadUInt32(); //842 + m_FibWord97.lcbPlcfBteLvc = reader.ReadUInt32(); //846 + m_FibWord97.dwLowDateTime = reader.ReadUInt32(); //850 + m_FibWord97.dwHighDateTime = reader.ReadUInt32(); //854 + m_FibWord97.fcPlcfLvcPre10 = reader.ReadUInt32(); //858 + m_FibWord97.lcbPlcfLvcPre10 = reader.ReadUInt32(); //862 + m_FibWord97.fcPlcfAsumy = reader.ReadUInt32(); //866 + m_FibWord97.lcbPlcfAsumy = reader.ReadUInt32(); //870 + m_FibWord97.fcPlcfGram = reader.ReadUInt32(); //874 + m_FibWord97.lcbPlcfGram = reader.ReadUInt32(); //878 + m_FibWord97.fcSttbListNames = reader.ReadUInt32(); //882 + m_FibWord97.lcbSttbListNames = reader.ReadUInt32(); //886 + m_FibWord97.fcSttbfUssr = reader.ReadUInt32(); //890 + m_FibWord97.lcbSttbfUssr = reader.ReadUInt32(); //894 } if (m_FibBase.nFib >= Fib2000) { //Read also the FibRgFcLcb2000 - this->m_FibWord2000.fcPlcfTch = reader.ReadUInt32(); //898 - this->m_FibWord2000.lcbPlcfTch = reader.ReadUInt32(); //902 - this->m_FibWord2000.fcRmdThreading = reader.ReadUInt32(); //906 - this->m_FibWord2000.lcbRmdThreading = reader.ReadUInt32(); //910 - this->m_FibWord2000.fcMid = reader.ReadUInt32(); //914 - this->m_FibWord2000.lcbMid = reader.ReadUInt32(); //918 - this->m_FibWord2000.fcSttbRgtplc = reader.ReadUInt32(); //922 - this->m_FibWord2000.lcbSttbRgtplc = reader.ReadUInt32(); //926 - this->m_FibWord2000.fcMsoEnvelope = reader.ReadUInt32(); //930 - this->m_FibWord2000.lcbMsoEnvelope = reader.ReadUInt32(); //934 - this->m_FibWord2000.fcPlcfLad = reader.ReadUInt32(); //938 - this->m_FibWord2000.lcbPlcfLad = reader.ReadUInt32(); //942 - this->m_FibWord2000.fcRgDofr = reader.ReadUInt32(); //946 - this->m_FibWord2000.lcbRgDofr = reader.ReadUInt32(); //950 - this->m_FibWord2000.fcPlcosl = reader.ReadUInt32(); //954 - this->m_FibWord2000.lcbPlcosl = reader.ReadUInt32(); //958 - this->m_FibWord2000.fcPlcfCookieOld = reader.ReadUInt32(); //962 - this->m_FibWord2000.lcbPlcfCookieOld = reader.ReadUInt32(); //966 - this->m_FibWord2000.fcPgdMotherOld = reader.ReadUInt32(); //970 - this->m_FibWord2000.lcbPgdMotherOld = reader.ReadUInt32(); //974 - this->m_FibWord2000.fcBkdMotherOld = reader.ReadUInt32(); //978 - this->m_FibWord2000.lcbBkdMotherOld = reader.ReadUInt32(); //982 - this->m_FibWord2000.fcPgdFtnOld = reader.ReadUInt32(); //986 - this->m_FibWord2000.lcbPgdFtnOld = reader.ReadUInt32(); //990 - this->m_FibWord2000.fcBkdFtnOld = reader.ReadUInt32(); //994 - this->m_FibWord2000.lcbBkdFtnOld = reader.ReadUInt32(); //998 - this->m_FibWord2000.fcPgdEdnOld = reader.ReadUInt32(); //1002 - this->m_FibWord2000.lcbPgdEdnOld = reader.ReadUInt32(); //1006 - this->m_FibWord2000.fcBkdEdnOld = reader.ReadUInt32(); //1010 - this->m_FibWord2000.lcbBkdEdnOld = reader.ReadUInt32(); //1014 + m_FibWord2000.fcPlcfTch = reader.ReadUInt32(); //898 + m_FibWord2000.lcbPlcfTch = reader.ReadUInt32(); //902 + m_FibWord2000.fcRmdThreading = reader.ReadUInt32(); //906 + m_FibWord2000.lcbRmdThreading = reader.ReadUInt32(); //910 + m_FibWord2000.fcMid = reader.ReadUInt32(); //914 + m_FibWord2000.lcbMid = reader.ReadUInt32(); //918 + m_FibWord2000.fcSttbRgtplc = reader.ReadUInt32(); //922 + m_FibWord2000.lcbSttbRgtplc = reader.ReadUInt32(); //926 + m_FibWord2000.fcMsoEnvelope = reader.ReadUInt32(); //930 + m_FibWord2000.lcbMsoEnvelope = reader.ReadUInt32(); //934 + m_FibWord2000.fcPlcfLad = reader.ReadUInt32(); //938 + m_FibWord2000.lcbPlcfLad = reader.ReadUInt32(); //942 + m_FibWord2000.fcRgDofr = reader.ReadUInt32(); //946 + m_FibWord2000.lcbRgDofr = reader.ReadUInt32(); //950 + m_FibWord2000.fcPlcosl = reader.ReadUInt32(); //954 + m_FibWord2000.lcbPlcosl = reader.ReadUInt32(); //958 + m_FibWord2000.fcPlcfCookieOld = reader.ReadUInt32(); //962 + m_FibWord2000.lcbPlcfCookieOld = reader.ReadUInt32(); //966 + m_FibWord2000.fcPgdMotherOld = reader.ReadUInt32(); //970 + m_FibWord2000.lcbPgdMotherOld = reader.ReadUInt32(); //974 + m_FibWord2000.fcBkdMotherOld = reader.ReadUInt32(); //978 + m_FibWord2000.lcbBkdMotherOld = reader.ReadUInt32(); //982 + m_FibWord2000.fcPgdFtnOld = reader.ReadUInt32(); //986 + m_FibWord2000.lcbPgdFtnOld = reader.ReadUInt32(); //990 + m_FibWord2000.fcBkdFtnOld = reader.ReadUInt32(); //994 + m_FibWord2000.lcbBkdFtnOld = reader.ReadUInt32(); //998 + m_FibWord2000.fcPgdEdnOld = reader.ReadUInt32(); //1002 + m_FibWord2000.lcbPgdEdnOld = reader.ReadUInt32(); //1006 + m_FibWord2000.fcBkdEdnOld = reader.ReadUInt32(); //1010 + m_FibWord2000.lcbBkdEdnOld = reader.ReadUInt32(); //1014 } - if ( this->m_FibBase.nFib >= Fib2002 ) + if ( m_FibBase.nFib >= Fib2002 ) { //Read also the fibRgFcLcb2002 reader.ReadUInt32(); //1018 reader.ReadUInt32(); //1022 - this->m_FibWord2002.fcPlcfPgp = reader.ReadUInt32(); //1026 - this->m_FibWord2002.lcbPlcfPgp = reader.ReadUInt32(); //1030 - this->m_FibWord2002.fcPlcfuim = reader.ReadUInt32(); //1034 - this->m_FibWord2002.lcbPlcfuim = reader.ReadUInt32(); //1038 - this->m_FibWord2002.fcPlfguidUim = reader.ReadUInt32(); //1042 - this->m_FibWord2002.lcbPlfguidUim = reader.ReadUInt32(); //1046 - this->m_FibWord2002.fcAtrdExtra = reader.ReadUInt32(); //1050 - this->m_FibWord2002.lcbAtrdExtra = reader.ReadUInt32(); //1054 - this->m_FibWord2002.fcPlrsid = reader.ReadUInt32(); //1058 - this->m_FibWord2002.lcbPlrsid = reader.ReadUInt32(); //1062 - this->m_FibWord2002.fcSttbfBkmkFactoid = reader.ReadUInt32(); //1066 - this->m_FibWord2002.lcbSttbfBkmkFactoid = reader.ReadUInt32(); //1070 - this->m_FibWord2002.fcPlcfBkfFactoid = reader.ReadUInt32(); //1074 - this->m_FibWord2002.lcbPlcfBkfFactoid = reader.ReadUInt32(); //1078 - this->m_FibWord2002.fcPlcfcookie = reader.ReadUInt32(); //1082 - this->m_FibWord2002.lcbPlcfcookie = reader.ReadUInt32(); //1086 - this->m_FibWord2002.fcPlcfBklFactoid = reader.ReadUInt32(); //1090 - this->m_FibWord2002.lcbPlcfBklFactoid = reader.ReadUInt32(); //1094 - this->m_FibWord2002.fcFactoidData = reader.ReadUInt32(); //1098 - this->m_FibWord2002.lcbFactoidData = reader.ReadUInt32(); //1102 - this->m_FibWord2002.fcDocUndo = reader.ReadUInt32(); //1106 - this->m_FibWord2002.lcbDocUndo = reader.ReadUInt32(); //1110 - this->m_FibWord2002.fcSttbfBkmkFcc = reader.ReadUInt32(); //1114 - this->m_FibWord2002.lcbSttbfBkmkFcc = reader.ReadUInt32(); //1118 - this->m_FibWord2002.fcPlcfBkfFcc = reader.ReadUInt32(); //1122 - this->m_FibWord2002.lcbPlcfBkfFcc = reader.ReadUInt32(); //1126 - this->m_FibWord2002.fcPlcfBklFcc = reader.ReadUInt32(); //1130 - this->m_FibWord2002.lcbPlcfBklFcc = reader.ReadUInt32(); //1134 - this->m_FibWord2002.fcSttbfbkmkBPRepairs = reader.ReadUInt32(); //1138 - this->m_FibWord2002.lcbSttbfbkmkBPRepairs = reader.ReadUInt32(); //1142 - this->m_FibWord2002.fcPlcfbkfBPRepairs = reader.ReadUInt32(); //1146 - this->m_FibWord2002.lcbPlcfbkfBPRepairs = reader.ReadUInt32(); //1150 - this->m_FibWord2002.fcPlcfbklBPRepairs = reader.ReadUInt32(); //1154 - this->m_FibWord2002.lcbPlcfbklBPRepairs = reader.ReadUInt32(); //1158 - this->m_FibWord2002.fcPmsNew = reader.ReadUInt32(); //1162 - this->m_FibWord2002.lcbPmsNew = reader.ReadUInt32(); //1166 - this->m_FibWord2002.fcODSO = reader.ReadUInt32(); //1170 - this->m_FibWord2002.lcbODSO = reader.ReadUInt32(); //1174 - this->m_FibWord2002.fcPlcfpmiOldXP = reader.ReadUInt32(); //1178 - this->m_FibWord2002.lcbPlcfpmiOldXP = reader.ReadUInt32(); //1182 - this->m_FibWord2002.fcPlcfpmiNewXP = reader.ReadUInt32(); //1186 - this->m_FibWord2002.lcbPlcfpmiNewXP = reader.ReadUInt32(); //1190 - this->m_FibWord2002.fcPlcfpmiMixedXP = reader.ReadUInt32(); //1194 - this->m_FibWord2002.lcbPlcfpmiMixedXP = reader.ReadUInt32(); //1198 + m_FibWord2002.fcPlcfPgp = reader.ReadUInt32(); //1026 + m_FibWord2002.lcbPlcfPgp = reader.ReadUInt32(); //1030 + m_FibWord2002.fcPlcfuim = reader.ReadUInt32(); //1034 + m_FibWord2002.lcbPlcfuim = reader.ReadUInt32(); //1038 + m_FibWord2002.fcPlfguidUim = reader.ReadUInt32(); //1042 + m_FibWord2002.lcbPlfguidUim = reader.ReadUInt32(); //1046 + m_FibWord2002.fcAtrdExtra = reader.ReadUInt32(); //1050 + m_FibWord2002.lcbAtrdExtra = reader.ReadUInt32(); //1054 + m_FibWord2002.fcPlrsid = reader.ReadUInt32(); //1058 + m_FibWord2002.lcbPlrsid = reader.ReadUInt32(); //1062 + m_FibWord2002.fcSttbfBkmkFactoid = reader.ReadUInt32(); //1066 + m_FibWord2002.lcbSttbfBkmkFactoid = reader.ReadUInt32(); //1070 + m_FibWord2002.fcPlcfBkfFactoid = reader.ReadUInt32(); //1074 + m_FibWord2002.lcbPlcfBkfFactoid = reader.ReadUInt32(); //1078 + m_FibWord2002.fcPlcfcookie = reader.ReadUInt32(); //1082 + m_FibWord2002.lcbPlcfcookie = reader.ReadUInt32(); //1086 + m_FibWord2002.fcPlcfBklFactoid = reader.ReadUInt32(); //1090 + m_FibWord2002.lcbPlcfBklFactoid = reader.ReadUInt32(); //1094 + m_FibWord2002.fcFactoidData = reader.ReadUInt32(); //1098 + m_FibWord2002.lcbFactoidData = reader.ReadUInt32(); //1102 + m_FibWord2002.fcDocUndo = reader.ReadUInt32(); //1106 + m_FibWord2002.lcbDocUndo = reader.ReadUInt32(); //1110 + m_FibWord2002.fcSttbfBkmkFcc = reader.ReadUInt32(); //1114 + m_FibWord2002.lcbSttbfBkmkFcc = reader.ReadUInt32(); //1118 + m_FibWord2002.fcPlcfBkfFcc = reader.ReadUInt32(); //1122 + m_FibWord2002.lcbPlcfBkfFcc = reader.ReadUInt32(); //1126 + m_FibWord2002.fcPlcfBklFcc = reader.ReadUInt32(); //1130 + m_FibWord2002.lcbPlcfBklFcc = reader.ReadUInt32(); //1134 + m_FibWord2002.fcSttbfbkmkBPRepairs = reader.ReadUInt32(); //1138 + m_FibWord2002.lcbSttbfbkmkBPRepairs = reader.ReadUInt32(); //1142 + m_FibWord2002.fcPlcfbkfBPRepairs = reader.ReadUInt32(); //1146 + m_FibWord2002.lcbPlcfbkfBPRepairs = reader.ReadUInt32(); //1150 + m_FibWord2002.fcPlcfbklBPRepairs = reader.ReadUInt32(); //1154 + m_FibWord2002.lcbPlcfbklBPRepairs = reader.ReadUInt32(); //1158 + m_FibWord2002.fcPmsNew = reader.ReadUInt32(); //1162 + m_FibWord2002.lcbPmsNew = reader.ReadUInt32(); //1166 + m_FibWord2002.fcODSO = reader.ReadUInt32(); //1170 + m_FibWord2002.lcbODSO = reader.ReadUInt32(); //1174 + m_FibWord2002.fcPlcfpmiOldXP = reader.ReadUInt32(); //1178 + m_FibWord2002.lcbPlcfpmiOldXP = reader.ReadUInt32(); //1182 + m_FibWord2002.fcPlcfpmiNewXP = reader.ReadUInt32(); //1186 + m_FibWord2002.lcbPlcfpmiNewXP = reader.ReadUInt32(); //1190 + m_FibWord2002.fcPlcfpmiMixedXP = reader.ReadUInt32(); //1194 + m_FibWord2002.lcbPlcfpmiMixedXP = reader.ReadUInt32(); //1198 reader.ReadUInt32(); //1202 reader.ReadUInt32(); //1206 - this->m_FibWord2002.fcPlcffactoid = reader.ReadUInt32(); //1210 - this->m_FibWord2002.lcbPlcffactoid = reader.ReadUInt32(); //1214 - this->m_FibWord2002.fcPlcflvcOldXP = reader.ReadUInt32(); //1218 - this->m_FibWord2002.lcbPlcflvcOldXP = reader.ReadUInt32(); //1222 - this->m_FibWord2002.fcPlcflvcNewXP = reader.ReadUInt32(); //1226 - this->m_FibWord2002.lcbPlcflvcNewXP = reader.ReadUInt32(); //1230 - this->m_FibWord2002.fcPlcflvcMixedXP = reader.ReadUInt32(); //1234 - this->m_FibWord2002.lcbPlcflvcMixedXP = reader.ReadUInt32(); //1238 + m_FibWord2002.fcPlcffactoid = reader.ReadUInt32(); //1210 + m_FibWord2002.lcbPlcffactoid = reader.ReadUInt32(); //1214 + m_FibWord2002.fcPlcflvcOldXP = reader.ReadUInt32(); //1218 + m_FibWord2002.lcbPlcflvcOldXP = reader.ReadUInt32(); //1222 + m_FibWord2002.fcPlcflvcNewXP = reader.ReadUInt32(); //1226 + m_FibWord2002.lcbPlcflvcNewXP = reader.ReadUInt32(); //1230 + m_FibWord2002.fcPlcflvcMixedXP = reader.ReadUInt32(); //1234 + m_FibWord2002.lcbPlcflvcMixedXP = reader.ReadUInt32(); //1238 } - if ( this->m_FibBase.nFib >= Fib2003 ) + if ( m_FibBase.nFib >= Fib2003 ) { //Read also the fibRgFcLcb2003 - this->m_FibWord2003.fcHplxsdr = reader.ReadUInt32(); - this->m_FibWord2003.lcbHplxsdr = reader.ReadUInt32(); - this->m_FibWord2003.fcSttbfBkmkSdt = reader.ReadUInt32(); - this->m_FibWord2003.lcbSttbfBkmkSdt = reader.ReadUInt32(); - this->m_FibWord2003.fcPlcfBkfSdt = reader.ReadUInt32(); - this->m_FibWord2003.lcbPlcfBkfSdt = reader.ReadUInt32(); - this->m_FibWord2003.fcPlcfBklSdt = reader.ReadUInt32(); - this->m_FibWord2003.lcbPlcfBklSdt = reader.ReadUInt32(); - this->m_FibWord2003.fcCustomXForm = reader.ReadUInt32(); - this->m_FibWord2003.lcbCustomXForm = reader.ReadUInt32(); - this->m_FibWord2003.fcSttbfBkmkProt = reader.ReadUInt32(); - this->m_FibWord2003.lcbSttbfBkmkProt = reader.ReadUInt32(); - this->m_FibWord2003.fcPlcfBkfProt = reader.ReadUInt32(); - this->m_FibWord2003.lcbPlcfBkfProt = reader.ReadUInt32(); - this->m_FibWord2003.fcPlcfBklProt = reader.ReadUInt32(); - this->m_FibWord2003.lcbPlcfBklProt = reader.ReadUInt32(); - this->m_FibWord2003.fcSttbProtUser = reader.ReadUInt32(); - this->m_FibWord2003.lcbSttbProtUser = reader.ReadUInt32(); + m_FibWord2003.fcHplxsdr = reader.ReadUInt32(); + m_FibWord2003.lcbHplxsdr = reader.ReadUInt32(); + m_FibWord2003.fcSttbfBkmkSdt = reader.ReadUInt32(); + m_FibWord2003.lcbSttbfBkmkSdt = reader.ReadUInt32(); + m_FibWord2003.fcPlcfBkfSdt = reader.ReadUInt32(); + m_FibWord2003.lcbPlcfBkfSdt = reader.ReadUInt32(); + m_FibWord2003.fcPlcfBklSdt = reader.ReadUInt32(); + m_FibWord2003.lcbPlcfBklSdt = reader.ReadUInt32(); + m_FibWord2003.fcCustomXForm = reader.ReadUInt32(); + m_FibWord2003.lcbCustomXForm = reader.ReadUInt32(); + m_FibWord2003.fcSttbfBkmkProt = reader.ReadUInt32(); + m_FibWord2003.lcbSttbfBkmkProt = reader.ReadUInt32(); + m_FibWord2003.fcPlcfBkfProt = reader.ReadUInt32(); + m_FibWord2003.lcbPlcfBkfProt = reader.ReadUInt32(); + m_FibWord2003.fcPlcfBklProt = reader.ReadUInt32(); + m_FibWord2003.lcbPlcfBklProt = reader.ReadUInt32(); + m_FibWord2003.fcSttbProtUser = reader.ReadUInt32(); + m_FibWord2003.lcbSttbProtUser = reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); - this->m_FibWord2003.fcPlcfpmiOld = reader.ReadUInt32(); - this->m_FibWord2003.lcbPlcfpmiOld = reader.ReadUInt32(); - this->m_FibWord2003.fcPlcfpmiOldInline = reader.ReadUInt32(); - this->m_FibWord2003.lcbPlcfpmiOldInline = reader.ReadUInt32(); - this->m_FibWord2003.fcPlcfpmiNew = reader.ReadUInt32(); - this->m_FibWord2003.lcbPlcfpmiNew = reader.ReadUInt32(); - this->m_FibWord2003.fcPlcfpmiNewInline = reader.ReadUInt32(); - this->m_FibWord2003.lcbPlcfpmiNewInline = reader.ReadUInt32(); - this->m_FibWord2003.fcPlcflvcOld = reader.ReadUInt32(); - this->m_FibWord2003.lcbPlcflvcOld = reader.ReadUInt32(); - this->m_FibWord2003.fcPlcflvcOldInline = reader.ReadUInt32(); - this->m_FibWord2003.lcbPlcflvcOldInline = reader.ReadUInt32(); - this->m_FibWord2003.fcPlcflvcNew = reader.ReadUInt32(); - this->m_FibWord2003.lcbPlcflvcNew = reader.ReadUInt32(); - this->m_FibWord2003.fcPlcflvcNewInline = reader.ReadUInt32(); - this->m_FibWord2003.lcbPlcflvcNewInline = reader.ReadUInt32(); - this->m_FibWord2003.fcPgdMother = reader.ReadUInt32(); - this->m_FibWord2003.lcbPgdMother = reader.ReadUInt32(); - this->m_FibWord2003.fcBkdMother = reader.ReadUInt32(); - this->m_FibWord2003.lcbBkdMother = reader.ReadUInt32(); - this->m_FibWord2003.fcAfdMother = reader.ReadUInt32(); - this->m_FibWord2003.lcbAfdMother = reader.ReadUInt32(); - this->m_FibWord2003.fcPgdFtn = reader.ReadUInt32(); - this->m_FibWord2003.lcbPgdFtn = reader.ReadUInt32(); - this->m_FibWord2003.fcBkdFtn = reader.ReadUInt32(); - this->m_FibWord2003.lcbBkdFtn = reader.ReadUInt32(); - this->m_FibWord2003.fcAfdFtn = reader.ReadUInt32(); - this->m_FibWord2003.lcbAfdFtn = reader.ReadUInt32(); - this->m_FibWord2003.fcPgdEdn = reader.ReadUInt32(); - this->m_FibWord2003.lcbPgdEdn = reader.ReadUInt32(); - this->m_FibWord2003.fcBkdEdn = reader.ReadUInt32(); - this->m_FibWord2003.lcbBkdEdn = reader.ReadUInt32(); - this->m_FibWord2003.fcAfdEdn = reader.ReadUInt32(); - this->m_FibWord2003.lcbAfdEdn = reader.ReadUInt32(); - this->m_FibWord2003.fcAfd = reader.ReadUInt32(); - this->m_FibWord2003.lcbAfd = reader.ReadUInt32(); + m_FibWord2003.fcPlcfpmiOld = reader.ReadUInt32(); + m_FibWord2003.lcbPlcfpmiOld = reader.ReadUInt32(); + m_FibWord2003.fcPlcfpmiOldInline = reader.ReadUInt32(); + m_FibWord2003.lcbPlcfpmiOldInline = reader.ReadUInt32(); + m_FibWord2003.fcPlcfpmiNew = reader.ReadUInt32(); + m_FibWord2003.lcbPlcfpmiNew = reader.ReadUInt32(); + m_FibWord2003.fcPlcfpmiNewInline = reader.ReadUInt32(); + m_FibWord2003.lcbPlcfpmiNewInline = reader.ReadUInt32(); + m_FibWord2003.fcPlcflvcOld = reader.ReadUInt32(); + m_FibWord2003.lcbPlcflvcOld = reader.ReadUInt32(); + m_FibWord2003.fcPlcflvcOldInline = reader.ReadUInt32(); + m_FibWord2003.lcbPlcflvcOldInline = reader.ReadUInt32(); + m_FibWord2003.fcPlcflvcNew = reader.ReadUInt32(); + m_FibWord2003.lcbPlcflvcNew = reader.ReadUInt32(); + m_FibWord2003.fcPlcflvcNewInline = reader.ReadUInt32(); + m_FibWord2003.lcbPlcflvcNewInline = reader.ReadUInt32(); + m_FibWord2003.fcPgdMother = reader.ReadUInt32(); + m_FibWord2003.lcbPgdMother = reader.ReadUInt32(); + m_FibWord2003.fcBkdMother = reader.ReadUInt32(); + m_FibWord2003.lcbBkdMother = reader.ReadUInt32(); + m_FibWord2003.fcAfdMother = reader.ReadUInt32(); + m_FibWord2003.lcbAfdMother = reader.ReadUInt32(); + m_FibWord2003.fcPgdFtn = reader.ReadUInt32(); + m_FibWord2003.lcbPgdFtn = reader.ReadUInt32(); + m_FibWord2003.fcBkdFtn = reader.ReadUInt32(); + m_FibWord2003.lcbBkdFtn = reader.ReadUInt32(); + m_FibWord2003.fcAfdFtn = reader.ReadUInt32(); + m_FibWord2003.lcbAfdFtn = reader.ReadUInt32(); + m_FibWord2003.fcPgdEdn = reader.ReadUInt32(); + m_FibWord2003.lcbPgdEdn = reader.ReadUInt32(); + m_FibWord2003.fcBkdEdn = reader.ReadUInt32(); + m_FibWord2003.lcbBkdEdn = reader.ReadUInt32(); + m_FibWord2003.fcAfdEdn = reader.ReadUInt32(); + m_FibWord2003.lcbAfdEdn = reader.ReadUInt32(); + m_FibWord2003.fcAfd = reader.ReadUInt32(); + m_FibWord2003.lcbAfd = reader.ReadUInt32(); } - if ( this->m_FibBase.nFib >= Fib2007 ) + if ( m_FibBase.nFib >= Fib2007 ) { //Read also the fibRgFcLcb2007 - this->m_FibWord2007.fcPlcfmthd = reader.ReadUInt32(); - this->m_FibWord2007.lcbPlcfmthd = reader.ReadUInt32(); - this->m_FibWord2007.fcSttbfBkmkMoveFrom = reader.ReadUInt32(); - this->m_FibWord2007.lcbSttbfBkmkMoveFrom = reader.ReadUInt32(); - this->m_FibWord2007.fcPlcfBkfMoveFrom = reader.ReadUInt32(); - this->m_FibWord2007.lcbPlcfBkfMoveFrom = reader.ReadUInt32(); - this->m_FibWord2007.fcPlcfBklMoveFrom = reader.ReadUInt32(); - this->m_FibWord2007.lcbPlcfBklMoveFrom = reader.ReadUInt32(); - this->m_FibWord2007.fcSttbfBkmkMoveTo = reader.ReadUInt32(); - this->m_FibWord2007.lcbSttbfBkmkMoveTo = reader.ReadUInt32(); - this->m_FibWord2007.fcPlcfBkfMoveTo = reader.ReadUInt32(); - this->m_FibWord2007.lcbPlcfBkfMoveTo = reader.ReadUInt32(); - this->m_FibWord2007.fcPlcfBklMoveTo = reader.ReadUInt32(); - this->m_FibWord2007.lcbPlcfBklMoveTo = reader.ReadUInt32(); + m_FibWord2007.fcPlcfmthd = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfmthd = reader.ReadUInt32(); + m_FibWord2007.fcSttbfBkmkMoveFrom = reader.ReadUInt32(); + m_FibWord2007.lcbSttbfBkmkMoveFrom = reader.ReadUInt32(); + m_FibWord2007.fcPlcfBkfMoveFrom = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfBkfMoveFrom = reader.ReadUInt32(); + m_FibWord2007.fcPlcfBklMoveFrom = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfBklMoveFrom = reader.ReadUInt32(); + m_FibWord2007.fcSttbfBkmkMoveTo = reader.ReadUInt32(); + m_FibWord2007.lcbSttbfBkmkMoveTo = reader.ReadUInt32(); + m_FibWord2007.fcPlcfBkfMoveTo = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfBkfMoveTo = reader.ReadUInt32(); + m_FibWord2007.fcPlcfBklMoveTo = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfBklMoveTo = reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); - this->m_FibWord2007.fcSttbfBkmkArto = reader.ReadUInt32(); - this->m_FibWord2007.lcbSttbfBkmkArto = reader.ReadUInt32(); - this->m_FibWord2007.fcPlcfBkfArto = reader.ReadUInt32(); - this->m_FibWord2007.lcbPlcfBkfArto = reader.ReadUInt32(); - this->m_FibWord2007.fcPlcfBklArto = reader.ReadUInt32(); - this->m_FibWord2007.lcbPlcfBklArto = reader.ReadUInt32(); - this->m_FibWord2007.fcArtoData = reader.ReadUInt32(); - this->m_FibWord2007.lcbArtoData = reader.ReadUInt32(); + m_FibWord2007.fcSttbfBkmkArto = reader.ReadUInt32(); + m_FibWord2007.lcbSttbfBkmkArto = reader.ReadUInt32(); + m_FibWord2007.fcPlcfBkfArto = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfBkfArto = reader.ReadUInt32(); + m_FibWord2007.fcPlcfBklArto = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfBklArto = reader.ReadUInt32(); + m_FibWord2007.fcArtoData = reader.ReadUInt32(); + m_FibWord2007.lcbArtoData = reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); - this->m_FibWord2007.fcOssTheme = reader.ReadUInt32(); - this->m_FibWord2007.lcbOssTheme = reader.ReadUInt32(); - this->m_FibWord2007.fcColorSchemeMapping = reader.ReadUInt32(); - this->m_FibWord2007.lcbColorSchemeMapping = reader.ReadUInt32(); + m_FibWord2007.fcOssTheme = reader.ReadUInt32(); + m_FibWord2007.lcbOssTheme = reader.ReadUInt32(); + m_FibWord2007.fcColorSchemeMapping = reader.ReadUInt32(); + m_FibWord2007.lcbColorSchemeMapping = reader.ReadUInt32(); } - this->cswNew = reader.ReadUInt16(); + cswNew = reader.ReadUInt16(); - if (this->cswNew != 0) + if (cswNew != 0) { //Read the FibRgCswNew - this->m_FibNew.nFibNew = (FibVersion)reader.ReadUInt16(); - this->m_FibNew.cQuickSavesNew = reader.ReadUInt16(); + m_FibNew.nFibNew = (FibVersion)reader.ReadUInt16(); + m_FibNew.cQuickSavesNew = reader.ReadUInt16(); } } + FileInformationBlock( VirtualStreamReader reader ) + { + m_bOlderVersion = false; + m_CodePage = 1250; + + unsigned int flag16 = 0; + unsigned char flag8 = 0; + + //read the FIB base + m_FibBase.wIdent = reader.ReadUInt16(); //0 + m_FibBase.nFib = (FibVersion)reader.ReadUInt16(); //2 + + reader.ReadBytes( 2, false ); //4 //nProduct + + m_FibBase.lid = reader.ReadUInt16(); //6 + m_FibBase.pnNext = reader.ReadInt16(); //8 + + flag16 = reader.ReadUInt16(); //10 + + m_FibBase.fDot = FormatUtils::BitmaskToBool((int)flag16, 0x0001); + m_FibBase.fGlsy = FormatUtils::BitmaskToBool((int)flag16, 0x0002); + m_FibBase.fComplex = FormatUtils::BitmaskToBool((int)flag16, 0x0002); + m_FibBase.fHasPic = FormatUtils::BitmaskToBool((int)flag16, 0x0008); + m_FibBase.cQuickSaves = (WORD)(((int)flag16 & 0x00F0) >> 4); + m_FibBase.fEncrypted = FormatUtils::BitmaskToBool((int)flag16, 0x0100); + m_FibBase.fWhichTblStm = FormatUtils::BitmaskToBool((int)flag16, 0x0200); + m_FibBase.fReadOnlyRecommended = FormatUtils::BitmaskToBool((int)flag16, 0x0400); + m_FibBase.fWriteReservation = FormatUtils::BitmaskToBool((int)flag16, 0x0800); + m_FibBase.fExtChar = FormatUtils::BitmaskToBool((int)flag16, 0x1000); + m_FibBase.fLoadOverwrite = FormatUtils::BitmaskToBool((int)flag16, 0x2000); + m_FibBase.fFarEast = FormatUtils::BitmaskToBool((int)flag16, 0x4000); + m_FibBase.fObfuscation = FormatUtils::BitmaskToBool((int)flag16, 0x8000); + + m_FibBase.nFibBack = reader.ReadUInt16(); //12 + m_FibBase.lKey = reader.ReadInt32(); //14 + m_FibBase.envr = reader.ReadByte(); //18 + + flag8 = reader.ReadByte(); //19 + + m_FibBase.fMac = FormatUtils::BitmaskToBool((int)flag8, 0x01); + m_FibBase.fEmptySpecial = FormatUtils::BitmaskToBool((int)flag8, 0x02); + m_FibBase.fLoadOverridePage = FormatUtils::BitmaskToBool((int)flag8, 0x04); + m_FibBase.fFutureSavedUndo = FormatUtils::BitmaskToBool((int)flag8, 0x08); + m_FibBase.fWord97Saved = FormatUtils::BitmaskToBool((int)flag8, 0x10); + + reader.ReadBytes( 4, false ); //20 + + m_FibBase.fcMin = reader.ReadInt32(); //24 + m_FibBase.fcMac = reader.ReadInt32(); //28 + + csw = reader.ReadUInt16(); //32 + + if (m_FibBase.nFib >= Fib1997 || m_FibBase.nFib == 0) + { + //read the RgW97 + reader.ReadBytes( 26, false ); //34 + m_RgW97.lidFE = reader.ReadUInt16(); //60 + + cslw = reader.ReadUInt16(); //62 + + //read the RgLW97 + + m_RgLw97.cbMac = reader.ReadInt32(); //64 + } + reset(reader); + } }; } -#endif FileInformationBlock_h diff --git a/ASCOfficeDocFile/DocDocxConverter/FontFamilyName.cpp b/ASCOfficeDocFile/DocDocxConverter/FontFamilyName.cpp index 1af7bb6a0d..ddb13534df 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FontFamilyName.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/FontFamilyName.cpp @@ -72,32 +72,41 @@ namespace DocFileFormat newObject->wWeight = reader->ReadInt16(); newObject->chs = reader->ReadByte(); - //skip unsigned char 5 - reader->ReadByte(); + //int sz_fonts = 150; //.. нужно генерить уникальное todooo + + int szAlt = reader->ReadByte(); - //read the 10 bytes panose - newObject->panoseSize = 10; - newObject->panose = reader->ReadBytes( newObject->panoseSize, true ); + if (!reader->olderVersion) + { + //read the 10 bytes panose + newObject->panoseSize = 10; + newObject->panose = reader->ReadBytes( newObject->panoseSize, true ); - //read the 24 bytes FontSignature - newObject->fs.UnicodeSubsetBitfield0 = reader->ReadUInt32(); - newObject->fs.UnicodeSubsetBitfield1 = reader->ReadUInt32(); - newObject->fs.UnicodeSubsetBitfield2 = reader->ReadUInt32(); - newObject->fs.UnicodeSubsetBitfield3 = reader->ReadUInt32(); - newObject->fs.CodePageBitfield0 = reader->ReadUInt32(); - newObject->fs.CodePageBitfield1 = reader->ReadUInt32(); + //read the 24 bytes FontSignature + newObject->fs.UnicodeSubsetBitfield0 = reader->ReadUInt32(); + newObject->fs.UnicodeSubsetBitfield1 = reader->ReadUInt32(); + newObject->fs.UnicodeSubsetBitfield2 = reader->ReadUInt32(); + newObject->fs.UnicodeSubsetBitfield3 = reader->ReadUInt32(); + newObject->fs.CodePageBitfield0 = reader->ReadUInt32(); + newObject->fs.CodePageBitfield1 = reader->ReadUInt32(); + } + //read the next \0 terminated string + long strStart = reader->GetPosition(); + long strEnd = searchTerminationZero( reader ); - //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( &(newObject->xszFtn), bytes, (int)( strEnd - strStart ), (Encoding)ENCODING_UNICODE ); + if (reader->olderVersion) + { + FormatUtils::GetSTLCollectionFromBytes( &(newObject->xszFtn), bytes, (int)( strEnd - strStart ), ENCODING_WINDOWS_1250 ); + } + else + { + FormatUtils::GetSTLCollectionFromBytes( &(newObject->xszFtn), bytes, (int)( strEnd - strStart ), ENCODING_UTF16 ); + } - if (newObject->xszFtn.length() >0) + if (newObject->xszFtn.length() > 0) { if ((int) newObject->xszFtn.at(0) < 31) //DDToneWebService.doc { @@ -105,25 +114,31 @@ namespace DocFileFormat } } - if (newObject->xszFtn.length() < 2)//programo.doc + if (newObject->xszFtn.length() < 2 && szAlt < 1)//programo.doc { - newObject->xszFtn = _T("font") + FormatUtils::IntToWideString(++sz_fonts); + newObject->xszFtn = _T("font"); } RELEASEARRAYOBJECTS( bytes ); long readBytes = reader->GetPosition() - startPos; - if( readBytes < length ) + if( readBytes < length && szAlt > 0) { - //read the next \0 terminated string - strStart = reader->GetPosition(); - strEnd = searchTerminationZero( reader ); + //read the next \0 terminated string + strStart = reader->GetPosition(); + strEnd = searchTerminationZero( reader ); bytes = reader->ReadBytes( (int)( strEnd - strStart ), true ); - FormatUtils::GetSTLCollectionFromBytes( &(newObject->xszAlt), bytes, (int)( strEnd - strStart ), ENCODING_UNICODE ); - + if (reader->olderVersion) + { + FormatUtils::GetSTLCollectionFromBytes( &(newObject->xszAlt), bytes, (int)( strEnd - strStart ), ENCODING_WINDOWS_1250); + } + else + { + FormatUtils::GetSTLCollectionFromBytes( &(newObject->xszAlt), bytes, (int)( strEnd - strStart ), ENCODING_UTF16 ); + } RELEASEARRAYOBJECTS( bytes ); } @@ -136,10 +151,20 @@ namespace DocFileFormat { long strStart = reader->GetPosition(); - while ( reader->ReadInt16() != 0 ) - { - ; - } + if (reader->olderVersion) + {//ansi string only + while ( reader->ReadByte() != 0 ) + { + ; + } + } + else + {//unicode string + while ( reader->ReadInt16() != 0 ) + { + ; + } + } long pos = reader->GetPosition(); diff --git a/ASCOfficeDocFile/DocDocxConverter/FontFamilyName.h b/ASCOfficeDocFile/DocDocxConverter/FontFamilyName.h index b8c70b5532..0166b464d3 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FontFamilyName.h +++ b/ASCOfficeDocFile/DocDocxConverter/FontFamilyName.h @@ -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 diff --git a/ASCOfficeDocFile/DocDocxConverter/FontTableMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/FontTableMapping.cpp index d2769c1a4f..6c526ef6a8 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FontTableMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/FontTableMapping.cpp @@ -61,7 +61,7 @@ namespace DocFileFormat int sz_fonts = table->Data.size(); - for ( vector::iterator iter = table->Data.begin(); iter != table->Data.end(); iter++ ) + for ( std::vector::iterator iter = table->Data.begin(); iter != table->Data.end(); iter++ ) { FontFamilyName* font = dynamic_cast( *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 diff --git a/ASCOfficeDocFile/DocDocxConverter/FooterMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/FooterMapping.cpp index d7ed59bf07..a8933716fe 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FooterMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/FooterMapping.cpp @@ -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 diff --git a/ASCOfficeDocFile/DocDocxConverter/FootnotesMapping.h b/ASCOfficeDocFile/DocDocxConverter/FootnotesMapping.h index 542abd7cae..3ab2e01050 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FootnotesMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/FootnotesMapping.h @@ -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()); } } }; diff --git a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPageCHPX.cpp b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPageCHPX.cpp index e4be9ea9b9..f7a479791e 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPageCHPX.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPageCHPX.cpp @@ -52,8 +52,8 @@ namespace DocFileFormat /*========================================================================================================*/ - FormattedDiskPageCHPX::FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset ): - FormattedDiskPage(), rgb(NULL), grpchpxSize(NULL), grpchpx(NULL) + FormattedDiskPageCHPX::FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset, bool oldVersion ): + FormattedDiskPage(), rgb(NULL), grpchpxSize(NULL), grpchpx(NULL) { Type = Character; WordStream = wordStream; @@ -81,9 +81,9 @@ namespace DocFileFormat } //create arrays - rgb = new unsigned char[crun]; - grpchpxSize = crun; - grpchpx = new CharacterPropertyExceptions*[grpchpxSize]; + grpchpxSize = crun; + rgb = new unsigned char[crun]; + grpchpx = new CharacterPropertyExceptions*[grpchpxSize]; j = 4 * ( crun + 1 ); @@ -108,7 +108,7 @@ namespace DocFileFormat memcpy( chpx, ( bytes + (wordOffset * 2) + 1 ), cb ); //parse CHPX and fill grpchpx - grpchpx[i] = new CharacterPropertyExceptions( chpx, cb ); + grpchpx[i] = new CharacterPropertyExceptions( chpx, cb, oldVersion); RELEASEARRAYOBJECTS( chpx ); } @@ -125,30 +125,61 @@ namespace DocFileFormat /*========================================================================================================*/ /// Parses the 0Table (or 1Table) for FKP _entries containing CHPX - list* FormattedDiskPageCHPX::GetAllCHPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream ) + std::list* FormattedDiskPageCHPX::GetAllCHPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream ) { - list* CHPXlist = new list(); + std::list* CHPXlist = new std::list(); //get bintable for CHPX unsigned char* binTableChpx = new unsigned char[fib->m_FibWord97.lcbPlcfBteChpx]; - tableStream->seek( fib->m_FibWord97.fcPlcfBteChpx); - tableStream->read( binTableChpx, fib->m_FibWord97.lcbPlcfBteChpx); - - //there are n offsets and n-1 fkp's in the bin table - int n = ( ( (int)fib->m_FibWord97.lcbPlcfBteChpx - 4 ) / 8 ) + 1; - - //Get the indexed CHPX FKPs - for ( unsigned int i = (n * 4); i < fib->m_FibWord97.lcbPlcfBteChpx; i += 4 ) + if (tableStream) { - //indexed FKP is the 6th 512byte page - int fkpnr = FormatUtils::BytesToInt32( binTableChpx, i, fib->m_FibWord97.lcbPlcfBteChpx ); + 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 - //so starts at: - int offset = fkpnr * 512; + 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 ); - //parse the FKP and add it to the list - CHPXlist->push_back( new FormattedDiskPageCHPX( wordStream, offset ) ); + 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 ) + { + //indexed FKP is the 6th 512byte page + int fkpnr = FormatUtils::BytesToInt32( binTableChpx, i, fib->m_FibWord97.lcbPlcfBteChpx ); + + //so starts at: + int offset = fkpnr * 512; + + //parse the FKP and add it to the list + CHPXlist->push_back( new FormattedDiskPageCHPX( wordStream, offset, fib->m_bOlderVersion ) ); + } } RELEASEARRAYOBJECTS( binTableChpx ); diff --git a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPageCHPX.h b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPageCHPX.h index 0acd8c95f6..3a25b0ce77 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPageCHPX.h +++ b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPageCHPX.h @@ -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* GetAllCHPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream ); + static std::list* GetAllCHPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream ); }; } \ No newline at end of file diff --git a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.cpp b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.cpp index ed58847b4b..741bf4dbf3 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.cpp @@ -52,8 +52,8 @@ namespace DocFileFormat /*========================================================================================================*/ - FormattedDiskPagePAPX::FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream ): - FormattedDiskPage(), rgbx(NULL), grppapxSize(0), grppapx(NULL) + FormattedDiskPagePAPX::FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, bool oldVersion): + FormattedDiskPage(), rgbx(NULL), grppapxSize(0), grppapx(NULL) { Type = Paragraph; WordStream = wordStream; @@ -68,9 +68,9 @@ namespace DocFileFormat //get the count crun = bytes[511]; - //create and fill the array with the adresses - rgfcSize = crun + 1; - rgfc = new int[rgfcSize]; + //create and fill the array with the adresses + rgfcSize = crun + 1; + rgfc = new int[rgfcSize]; int j = 0; @@ -131,7 +131,7 @@ namespace DocFileFormat memcpy( papx, ( bytes + (bx.wordOffset * 2) + padbyte + 1 ), ( cw * 2 ) ); //parse PAPX and fill grppapx - grppapx[i] = new ParagraphPropertyExceptions( papx, ( cw * 2 ), dataStream ); + grppapx[i] = new ParagraphPropertyExceptions( papx, ( cw * 2 ), dataStream, oldVersion ); RELEASEARRAYOBJECTS( papx ); } @@ -150,32 +150,73 @@ namespace DocFileFormat /*========================================================================================================*/ /// Parses the 0Table (or 1Table) for FKP _entries containing PAPX - list* FormattedDiskPagePAPX::GetAllPAPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream) + std::list* FormattedDiskPagePAPX::GetAllPAPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream) { - list* PAPXlist = new list(); + std::list* PAPXlist = new std::list(); //get bintable for PAPX unsigned char* binTablePapx = new unsigned char[fib->m_FibWord97.lcbPlcfBtePapx]; - tableStream->seek( fib->m_FibWord97.fcPlcfBtePapx); - tableStream->read( binTablePapx, fib->m_FibWord97.lcbPlcfBtePapx); + 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 - //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; - //Get the indexed PAPX FKPs - for ( unsigned int i = ( n * 4 ); i < fib->m_FibWord97.lcbPlcfBtePapx; i += 4 ) - { - //indexed FKP is the xth 512byte page - int fkpnr = FormatUtils::BytesToInt32( binTablePapx, i, fib->m_FibWord97.lcbPlcfBtePapx ); + 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 + } - //so starts at: - int offset = fkpnr * 512; + 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 ); - //parse the FKP and add it to the list - PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream ) ); - } + //so starts at: + int offset = fkpnr * 512; + //parse the FKP and add it to the list + PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_bOlderVersion) ); + } + + //if (PAPXlist->back()->rgfc[PAPXlist->back()->rgfcSize-1] < last) + //{ + // PAPXlist->back()->rgfc[PAPXlist->back()->rgfcSize-1] = last; + // //tableStream->read( binTablePapx, fib->m_FibWord97.lcbPlcfBtePapx); + // //offset+=512; + // //PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream ) ); + //} + } + else + { + int n = ( ( (int)fib->m_FibWord97.lcbPlcfBtePapx - 4 ) / 8 ) + 1; + //Get the indexed PAPX FKPs + for ( unsigned int i = ( n * 4 ); i < fib->m_FibWord97.lcbPlcfBtePapx; i += 4 ) + { + //indexed FKP is the xth 512byte page + int fkpnr = FormatUtils::BytesToInt32( binTablePapx, i, fib->m_FibWord97.lcbPlcfBtePapx ); + + //so starts at: + int offset = fkpnr * 512; + + //parse the FKP and add it to the list + PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_bOlderVersion) ); + } + + } + RELEASEARRAYOBJECTS( binTablePapx ); return PAPXlist; @@ -184,7 +225,7 @@ namespace DocFileFormat /*========================================================================================================*/ /// Returns a list of all PAPX FCs between they given boundaries. - list* FormattedDiskPagePAPX::GetFileCharacterPositions + std::list* FormattedDiskPagePAPX::GetFileCharacterPositions ( int fcMin, int fcMax, @@ -194,12 +235,12 @@ namespace DocFileFormat POLE::Stream* dataStream ) { - list* cpList = new list(); - list *fkps = FormattedDiskPagePAPX::GetAllPAPXFKPs( fib, wordStream, tableStream, dataStream ); + std::list* cpList = new std::list(); + std::list *fkps = FormattedDiskPagePAPX::GetAllPAPXFKPs( fib, wordStream, tableStream, dataStream ); unsigned int i = 0; FormattedDiskPagePAPX* fkp = NULL; - for ( list::iterator iter = fkps->begin(); iter != fkps->end(); iter++ ) + for ( std::list::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* FormattedDiskPagePAPX::GetParagraphPropertyExceptions + std::list* FormattedDiskPagePAPX::GetParagraphPropertyExceptions ( int fcMin, int fcMax, @@ -243,11 +284,11 @@ namespace DocFileFormat POLE::Stream* dataStream ) { - list* ppxList = new list(); - list* fkps = FormattedDiskPagePAPX::GetAllPAPXFKPs( fib, wordStream, tableStream, dataStream ); + std::list* ppxList = new std::list(); + std::list* fkps = FormattedDiskPagePAPX::GetAllPAPXFKPs( fib, wordStream, tableStream, dataStream ); FormattedDiskPagePAPX *fkp = NULL; - for ( list::iterator iter = fkps->begin(); iter != fkps->end(); iter++ ) + for ( std::list::iterator iter = fkps->begin(); iter != fkps->end(); iter++ ) { fkp = (*iter); diff --git a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.h b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.h index 12e36b0cce..f160a7a83b 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.h +++ b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.h @@ -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* GetAllPAPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream); + static std::list* 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* GetFileCharacterPositions( int fcMin, int fcMax, FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream ); + static std::list* 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* GetParagraphPropertyExceptions( int fcMin, int fcMax, FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream ); + static std::list* GetParagraphPropertyExceptions( int fcMin, int fcMax, FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream ); }; } diff --git a/ASCOfficeDocFile/DocDocxConverter/HeaderAndFooterTable.cpp b/ASCOfficeDocFile/DocDocxConverter/HeaderAndFooterTable.cpp index ea332dd3b4..e33324b05d 100644 --- a/ASCOfficeDocFile/DocDocxConverter/HeaderAndFooterTable.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/HeaderAndFooterTable.cpp @@ -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] ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/HeaderMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/HeaderMapping.cpp index b8793f2066..1abbc36f65 100644 --- a/ASCOfficeDocFile/DocDocxConverter/HeaderMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/HeaderMapping.cpp @@ -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 diff --git a/ASCOfficeDocFile/DocDocxConverter/LanguageIdMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/LanguageIdMapping.cpp index 2a58c2b87e..1f3f73b1e3 100644 --- a/ASCOfficeDocFile/DocDocxConverter/LanguageIdMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/LanguageIdMapping.cpp @@ -57,7 +57,7 @@ namespace DocFileFormat { if ( dynamic_cast( lid )->Code != Nothing ) { - wstring langcode = getLanguageCode( dynamic_cast( lid ) ); + std::wstring langcode = getLanguageCode( dynamic_cast( lid ) ); XMLTools::XMLAttribute* 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); diff --git a/ASCOfficeDocFile/DocDocxConverter/LanguageIdMapping.h b/ASCOfficeDocFile/DocDocxConverter/LanguageIdMapping.h index fb39eb9c2a..0ff58b0c5d 100644 --- a/ASCOfficeDocFile/DocDocxConverter/LanguageIdMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/LanguageIdMapping.h @@ -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; diff --git a/ASCOfficeDocFile/DocDocxConverter/ListData.cpp b/ASCOfficeDocFile/DocDocxConverter/ListData.cpp index 23f0756630..5343b08206 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ListData.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/ListData.cpp @@ -64,11 +64,11 @@ namespace DocFileFormat if ( this->fSimpleList ) { - this->rglvl = new vector( 1 ); + this->rglvl = new std::vector( 1 ); } else { - this->rglvl = new vector( 9 ); + this->rglvl = new std::vector( 9 ); } this->fRestartHdn = FormatUtils::BitmaskToBool( flag, 0x02 ); diff --git a/ASCOfficeDocFile/DocDocxConverter/ListData.h b/ASCOfficeDocFile/DocDocxConverter/ListData.h index b740181b32..a01e605783 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ListData.h +++ b/ASCOfficeDocFile/DocDocxConverter/ListData.h @@ -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 rgistd; + std::vector 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* rglvl; + std::vector* rglvl; /// A grfhic that specifies HTML incompatibilities of the list. unsigned char grfhic; unsigned char* _rawBytes; diff --git a/ASCOfficeDocFile/DocDocxConverter/ListFormatOverride.h b/ASCOfficeDocFile/DocDocxConverter/ListFormatOverride.h index 818fe15b1a..f8c9f7882a 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ListFormatOverride.h +++ b/ASCOfficeDocFile/DocDocxConverter/ListFormatOverride.h @@ -58,7 +58,7 @@ namespace DocFileFormat /// A grfhic that specifies HTML incompatibilities. unsigned char grfhic; /// Array of all levels whose format is overridden - vector rgLfoLvl; + std::vector rgLfoLvl; public: /// Parses the given Stream Reader to retrieve a ListFormatOverride @@ -76,7 +76,7 @@ namespace DocFileFormat if ( this->clfolvl != 0 ) { - this->rgLfoLvl = vector( this->clfolvl ); + this->rgLfoLvl = std::vector( this->clfolvl ); } reader->Seek( startPos, 0/*STREAM_SEEK_SET*/ ); @@ -85,7 +85,7 @@ namespace DocFileFormat virtual ~ListFormatOverride() { - for ( vector::iterator iter = this->rgLfoLvl.begin(); iter != this->rgLfoLvl.end(); iter++ ) + for ( std::vector::iterator iter = this->rgLfoLvl.begin(); iter != this->rgLfoLvl.end(); iter++ ) { RELEASEOBJECT( *iter ); } diff --git a/ASCOfficeDocFile/DocDocxConverter/ListFormatOverrideTable.h b/ASCOfficeDocFile/DocDocxConverter/ListFormatOverrideTable.h index f6fc2a1cee..f2ccaaf442 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ListFormatOverrideTable.h +++ b/ASCOfficeDocFile/DocDocxConverter/ListFormatOverrideTable.h @@ -37,19 +37,21 @@ namespace DocFileFormat { - class ListFormatOverrideTable: public vector + class ListFormatOverrideTable: public std::vector { private: static const int LFO_LENGTH = 16; static const int LFOLVL_LENGTH = 6; - vector cps; + std::vector 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(); diff --git a/ASCOfficeDocFile/DocDocxConverter/ListLevel.cpp b/ASCOfficeDocFile/DocDocxConverter/ListLevel.cpp index a13594ea73..e77fa88c8a 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ListLevel.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/ListLevel.cpp @@ -46,7 +46,7 @@ namespace DocFileFormat /// Parses the given StreamReader to retrieve a LVL struct ListLevel::ListLevel( VirtualStreamReader* reader, int length ): - grpprlPapx(NULL), grpprlChpx(NULL), _rawBytes(NULL) + grpprlPapx(NULL), grpprlChpx(NULL), _rawBytes(NULL) { long startPos = reader->GetPosition(); @@ -81,15 +81,17 @@ 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 ); - this->grpprlPapx = new ParagraphPropertyExceptions( *(px->grpprl) ); + unsigned char *bytes = reader->ReadBytes( this->cbGrpprlPapx, true ); + + 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( &(this->xst), bytes, ( strLen * 2 ), ENCODING_UNICODE ); + FormatUtils::GetSTLCollectionFromBytes( &(this->xst), bytes, ( strLen * 2 ), ENCODING_UTF16 ); RELEASEARRAYOBJECTS( bytes ); } diff --git a/ASCOfficeDocFile/DocDocxConverter/ListLevel.h b/ASCOfficeDocFile/DocDocxConverter/ListLevel.h index 8d22c709d2..bbdd3b75b2 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ListLevel.h +++ b/ASCOfficeDocFile/DocDocxConverter/ListLevel.h @@ -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 rgbxchNums; + std::vector 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; diff --git a/ASCOfficeDocFile/DocDocxConverter/ListTable.cpp b/ASCOfficeDocFile/DocDocxConverter/ListTable.cpp index 5f992bac86..fc68feba0e 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ListTable.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/ListTable.cpp @@ -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::iterator iter = listData.begin(); iter != listData.end(); iter++ ) + for ( std::list::iterator iter = listData.begin(); iter != listData.end(); iter++ ) { for ( unsigned int j = 0; j < (*iter)->rglvl->size(); j++ ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/ListTable.h b/ASCOfficeDocFile/DocDocxConverter/ListTable.h index d5674be74f..c3f95258f0 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ListTable.h +++ b/ASCOfficeDocFile/DocDocxConverter/ListTable.h @@ -41,7 +41,7 @@ namespace DocFileFormat class ListTable: public IVisitable { public: - list listData; + std::list listData; virtual ~ListTable(); ListTable( FileInformationBlock* fib, POLE::Stream* tableStream ); diff --git a/ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.cpp index cae531fbf8..65b7c0afa4 100644 --- a/ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.cpp @@ -80,7 +80,11 @@ namespace DocFileFormat m_pXmlWriter->WriteNodeBegin( _T("w:body"), FALSE ); // Convert the document - _lastValidPapx = (*(m_document->AllPapxFkps->begin()))->grppapx[0]; + _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* chpxChars = m_document->m_PieceTable->GetEncodingChars (fc, fcEnd, m_document->WordDocumentStream); //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 ); + //if (fc < 0 || fcEnd < 0) break; + // + //// Read the chars + //std::vector* chars = m_document->GetChars (fc, fcEnd, fc); - // Write text - m_pXmlWriter->WriteString(text.c_str()); - - RELEASEOBJECT(chpxChars); - - //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::iterator iter = m_document->AllSepx->begin(); iter != m_document->AllSepx->end(); ++iter) + for (std::map::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 diff --git a/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.cpp index f4f591b3f2..97536aec5d 100644 --- a/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.cpp @@ -79,7 +79,7 @@ namespace DocFileFormat int i = 0; - for (list::iterator iter = rglst->listData.begin(); iter != rglst->listData.end(); ++iter, ++i) + for (std::list::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::const_iterator iter = lfo->rgLfoLvl.begin(); iter != lfo->rgLfoLvl.end(); ++iter) + for (std::vector::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, int id) + int NumberingMapping::FindIndexbyId(const std::list& listData, int id) { int ret = -1; int i = 0; - for (list::const_iterator iter = listData.begin(); iter != listData.end(); ++iter, ++i) + for (std::list::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::const_iterator iter = m_document->PictureBulletsCPsMap.begin(); iter != m_document->PictureBulletsCPsMap.end(); ++iter) + for (std::map::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* chpxs = m_document->GetCharacterPropertyExceptions(fc, fcEnd); + std::list* 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::const_iterator iter = grpprlChpx->grpprl->begin(); iter != grpprlChpx->grpprl->end(); ++iter) + for (std::list::const_iterator iter = grpprlChpx->grpprl->begin(); iter != grpprlChpx->grpprl->end(); ++iter) { if ((int)(iter->OpCode) == sprmCPbiIBullet) { diff --git a/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.h b/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.h index 7653da89d8..e45e253fa5 100644 --- a/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.h @@ -62,9 +62,9 @@ namespace DocFileFormat public: NumberingMapping(ConversionContext* ctx); void Apply(IVisitable* visited); - static int FindIndexbyId(const list& listData, int id); + static int FindIndexbyId(const std::list& 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: diff --git a/ASCOfficeDocFile/DocDocxConverter/OfficeArtContent.h b/ASCOfficeDocFile/DocDocxConverter/OfficeArtContent.h index 80e1e1382e..4483349ec7 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OfficeArtContent.h +++ b/ASCOfficeDocFile/DocDocxConverter/OfficeArtContent.h @@ -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::iterator iter = m_arrDrawings.begin(); iter != m_arrDrawings.end(); ++iter) + for ( std::list::iterator iter = m_arrDrawings.begin(); iter != m_arrDrawings.end(); ++iter) RELEASEOBJECT(iter->container); } @@ -114,7 +117,7 @@ namespace DocFileFormat { ShapeContainer* ret = NULL; - for (list::iterator iter = m_arrDrawings.begin(); iter != m_arrDrawings.end(); ++iter) + for (std::list::iterator iter = m_arrDrawings.begin(); iter != m_arrDrawings.end(); ++iter) { GroupContainer* group = iter->container->FirstChildWithType(); if (group) @@ -172,7 +175,7 @@ namespace DocFileFormat private: - DrawingGroup* m_pDrawingGroupData; - list m_arrDrawings; + DrawingGroup* m_pDrawingGroupData; + std::list m_arrDrawings; }; } diff --git a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ChildAnchor.h b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ChildAnchor.h index 71606a3d78..55e6e55094 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ChildAnchor.h +++ b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ChildAnchor.h @@ -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; diff --git a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/DrawingGroupRecord.h b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/DrawingGroupRecord.h index 7871ab081b..d6276f9e70 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/DrawingGroupRecord.h +++ b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/DrawingGroupRecord.h @@ -56,7 +56,7 @@ namespace DocFileFormat unsigned int ShapesSavedCount; // Total number of shapes saved unsigned int DrawingsSavedCount; // Total number of drawings saved - list Clusters; + std::list Clusters; DrawingGroupRecord () : Record(), MaxShapeId(0), IdClustersCount(0), ShapesSavedCount(0), DrawingsSavedCount(0) { diff --git a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/GroupShapeRecord.h b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/GroupShapeRecord.h index 08f06ecf3a..59bbb11a1f 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/GroupShapeRecord.h +++ b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/GroupShapeRecord.h @@ -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; }; } diff --git a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/PathParser.h b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/PathParser.h index cb2044500b..a9f5eeee52 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/PathParser.h +++ b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/PathParser.h @@ -161,7 +161,7 @@ namespace DocFileFormat int cc = 0; std::vector::const_iterator end = m_arSegments.end(); - for (vector::const_iterator iter = m_arSegments.begin(); iter != end; ++iter, cc++) + for (std::vector::const_iterator iter = m_arSegments.begin(); iter != end; ++iter, cc++) { try { diff --git a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/RegularContainer.h b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/RegularContainer.h index 0de1159e89..03afeb2630 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/RegularContainer.h +++ b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/RegularContainer.h @@ -46,7 +46,7 @@ namespace DocFileFormat virtual ~RegularContainer() { - for (vector::iterator iter = Children.begin(); iter != Children.end(); ++iter) + for (std::vector::iterator iter = Children.begin(); iter != Children.end(); ++iter) { RELEASEOBJECT (*iter); } @@ -84,7 +84,7 @@ namespace DocFileFormat { T* firstChildWithType = NULL; - for ( vector::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ ) + for ( std::vector::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 Children; + std::vector Children; }; } \ No newline at end of file diff --git a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ShapeContainer.h b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ShapeContainer.h index 1dc69102e7..4e1ab2944a 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ShapeContainer.h +++ b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ShapeContainer.h @@ -58,7 +58,7 @@ namespace DocFileFormat { int ret = 0; - for ( vector::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ ) + for ( std::vector::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ ) { Shape* sh = dynamic_cast( *iter ); if (sh) @@ -80,18 +80,18 @@ namespace DocFileFormat } /// Searches all OptionEntry in the ShapeContainer and puts them into a list. - list ExtractOptions() const + std::list ExtractOptions() const { - list ret; + std::list ret; //build the list of all option entries of this shape - for ( vector::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ ) + for ( std::vector::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ ) { ShapeOptions* opt = dynamic_cast( *iter ); if ( opt != NULL ) { - for ( vector::iterator oeIter = opt->Options.begin(); oeIter != opt->Options.end(); oeIter++ ) + for ( std::vector::iterator oeIter = opt->Options.begin(); oeIter != opt->Options.end(); oeIter++ ) { ret.push_back( *oeIter ); } diff --git a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ShapeOptions.h b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ShapeOptions.h index c51e90cf8b..30789fb14e 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ShapeOptions.h +++ b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/ShapeOptions.h @@ -587,8 +587,8 @@ namespace DocFileFormat static const unsigned short TYPE_CODE_0xF121 = 0xF121; static const unsigned short TYPE_CODE_0xF122 = 0xF122; - vector Options; - map OptionsByID; + std::vector Options; + std::map OptionsByID; ShapeOptions() : Record() { @@ -596,7 +596,7 @@ namespace DocFileFormat virtual ~ShapeOptions() { - for (vector::iterator iter = Options.begin(); iter != Options.end(); ++iter) + for (std::vector::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(Options[i].pid, Options[i])); + OptionsByID.insert(std::pair(Options[i].pid, Options[i])); } Reader->Seek(( pos + size ), 0/*STREAM_SEEK_SET*/); diff --git a/ASCOfficeDocFile/DocDocxConverter/OleObject.h b/ASCOfficeDocFile/DocDocxConverter/OleObject.h index 23460ba2ce..5d3f06c1fe 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OleObject.h +++ b/ASCOfficeDocFile/DocDocxConverter/OleObject.h @@ -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( &this->Link, str, cch, ENCODING_WINDOWS_1251 ); + FormatUtils::GetSTLCollectionFromBytes( &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( &this->Link, str, ( cch * 2 ), ENCODING_UNICODE ); + FormatUtils::GetSTLCollectionFromBytes( &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,46 +198,46 @@ namespace DocFileFormat } } - void processCompObjStream( const string& compStream ) - { - try - { - POLE::Stream* pCompStream = NULL; - HRESULT res = S_OK; + void processCompObjStream( const std::string& compStream ) + { + try + { + POLE::Stream* pCompStream = NULL; + HRESULT res = S_OK; - pCompStream = new POLE::Stream(oleStorage, compStream); + pCompStream = new POLE::Stream(oleStorage, compStream); - if ( pCompStream ) - { - VirtualStreamReader reader( pCompStream ); - - //skip the CompObjHeader - reader.ReadBytes( 28, false ); - - int sz_obj = reader.GetSize() - reader.GetPosition(); - - if (sz_obj > 4) + if ( pCompStream ) { - //todooo сделать по нормальному CompObjHeader - psc3a.doc - //UserType = reader.ReadLengthPrefixedAnsiString(); + VirtualStreamReader reader( pCompStream, 0, false); - //sz_obj = reader.GetSize() - reader.GetPosition(); - //if (sz_obj > 4) - // ClipboardFormat = reader.ReadLengthPrefixedAnsiString(); + //skip the CompObjHeader + reader.ReadBytes( 28, false ); - //sz_obj = reader.GetSize() - reader.GetPosition(); - //if (sz_obj > 4) - // Program = reader.ReadLengthPrefixedAnsiString(); + int sz_obj = reader.GetSize() - reader.GetPosition(); + + if (sz_obj > 4) + { + //todooo сделать по нормальному CompObjHeader - psc3a.doc + //UserType = reader.ReadLengthPrefixedAnsiString(); + + //sz_obj = reader.GetSize() - reader.GetPosition(); + //if (sz_obj > 4) + // ClipboardFormat = reader.ReadLengthPrefixedAnsiString(); + + //sz_obj = reader.GetSize() - reader.GetPosition(); + //if (sz_obj > 4) + // Program = reader.ReadLengthPrefixedAnsiString(); + } + delete pCompStream; } - delete pCompStream; - } - } - catch (...) + } + catch (...) { } - } + } - 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 ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/OleObjectMapping.h b/ASCOfficeDocFile/DocDocxConverter/OleObjectMapping.h index 1e13c5c410..ea9579fa9c 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OleObjectMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/OleObjectMapping.h @@ -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; } diff --git a/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp b/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp index e3df80c29e..0b76e0aa16 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp @@ -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::const_iterator iter = this->HeaderRelationshipsFiles.begin(); iter != this->HeaderRelationshipsFiles.end(); iter++ ) + for ( std::list::const_iterator iter = this->HeaderRelationshipsFiles.begin(); iter != this->HeaderRelationshipsFiles.end(); iter++ ) { this->WriteRelsFile( *iter ); } - for ( list::const_iterator iter = this->FooterRelationshipsFiles.begin(); iter != this->FooterRelationshipsFiles.end(); iter++ ) + for ( std::list::const_iterator iter = this->FooterRelationshipsFiles.begin(); iter != this->FooterRelationshipsFiles.end(); iter++ ) { this->WriteRelsFile( *iter ); } @@ -141,16 +140,16 @@ namespace DocFileFormat } HRESULT OpenXmlPackage::SaveOLEObject( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure ) { - POLE::Storage *storageOut = new POLE::Storage(fileName.c_str()); - - if (storageOut == NULL || docFile == NULL) return S_FALSE; - if (storageOut->open(true, true)==false) - { - delete storageOut; - return S_FALSE; - } + POLE::Storage *storageOut = new POLE::Storage(fileName.c_str()); + + if (storageOut == NULL || docFile == NULL) return S_FALSE; + if (storageOut->open(true, true)==false) + { + delete storageOut; + return S_FALSE; + } - POLE::Storage *storageInp = docFile->GetStorage()->GetStorage(); + POLE::Storage *storageInp = docFile->GetStorage()->GetStorage(); { std::string id(oleObjectFileStructure.objectID.begin(),oleObjectFileStructure.objectID.end()); @@ -317,7 +316,7 @@ namespace DocFileFormat writer.WriteNodeEnd( _T( "" ), TRUE, FALSE ); - for ( list::const_iterator iter = relationshipsFile.Relationships.begin(); iter != relationshipsFile.Relationships.end(); iter++ ) + for ( std::list::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::iterator iter = this->DocumentContentTypesFile._defaultTypes.begin(); iter != this->DocumentContentTypesFile._defaultTypes.end(); iter++ ) + for ( std::map::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::iterator iter = this->DocumentContentTypesFile._partOverrides.begin(); iter != this->DocumentContentTypesFile._partOverrides.end(); iter++ ) + for ( std::map::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")); } diff --git a/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.h b/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.h index dcb808255a..97eda917bf 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.h +++ b/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.h @@ -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,30 +59,30 @@ namespace DocFileFormat struct RelationshipsFile { - wstring FileName; - list Relationships; - int RelID; + std::wstring FileName; + std::list Relationships; + int RelID; RelationshipsFile(): RelID(0) { } - RelationshipsFile( const wstring& fileName ): + RelationshipsFile( const std::wstring& fileName ): RelID(0), FileName( fileName ) { } - RelationshipsFile( int relID, const wstring& fileName, const list& relationships ): - RelID(relID), FileName( fileName ), Relationships( relationships ) + RelationshipsFile( int relID, const std::wstring& fileName, const std::list& relationships ): + RelID(relID), FileName( fileName ), Relationships( relationships ) { } }; struct ContentTypesFile { - map _defaultTypes; - map _partOverrides; + std::map _defaultTypes; + std::map _partOverrides; }; struct ImageFileStructure @@ -92,7 +92,7 @@ namespace DocFileFormat } - ImageFileStructure(const wstring& _ext, const vector& _data, Global::BlipType _blipType = Global::msoblipUNKNOWN) : ext(_ext), data(_data), blipType(_blipType) + ImageFileStructure(const std::wstring& _ext, const std::vector& _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 HeaderRelationshipsFiles; - list FooterRelationshipsFiles; + + std::list HeaderRelationshipsFiles; + std::list 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 ); }; } diff --git a/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertiesMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertiesMapping.cpp index a042647d2e..fbd78f821b 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertiesMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertiesMapping.cpp @@ -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; } diff --git a/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertyExceptions.cpp b/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertyExceptions.cpp index da4dd02fd3..250ef2cf1c 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertyExceptions.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertyExceptions.cpp @@ -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::iterator iter = this->grpprl->begin(); iter != this->grpprl->end(); iter++ ) + for ( std::list::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( *(externalPx.grpprl) ); + this->grpprl = new std::list( *(externalPx.grpprl) ); //remove the sprmPHugePapx this->grpprl->remove( sprm ); diff --git a/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertyExceptions.h b/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertyExceptions.h index e8aac6cbce..178d121f34 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertyExceptions.h +++ b/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertyExceptions.h @@ -45,13 +45,12 @@ 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& grpprl ): - PropertyExceptions( grpprl ), istd(0) + ParagraphPropertyExceptions( const std::list& 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); }; } diff --git a/ASCOfficeDocFile/DocDocxConverter/PictureDescriptor.cpp b/ASCOfficeDocFile/DocDocxConverter/PictureDescriptor.cpp index 92bc58710e..ae5edc3946 100644 --- a/ASCOfficeDocFile/DocDocxConverter/PictureDescriptor.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/PictureDescriptor.cpp @@ -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(); @@ -98,8 +99,8 @@ namespace DocFileFormat if (mfp.mm > 98) { - unsigned char* bytes = reader.ReadBytes(14, true); - rcWinMf = vector(bytes, (bytes + 14)); + unsigned char* bytes = reader.ReadBytes(14, true); + rcWinMf = std::vector(bytes, (bytes + 14)); RELEASEARRAYOBJECTS(bytes); //dimensions @@ -148,7 +149,7 @@ namespace DocFileFormat if ( stPicName != NULL ) { std::wstring picName; - FormatUtils::GetSTLCollectionFromBytes( &picName, stPicName, cchPicName, ENCODING_WINDOWS_1251 ); + FormatUtils::GetSTLCollectionFromBytes( &picName, stPicName, cchPicName, ENCODING_WINDOWS_1250 ); RELEASEARRAYOBJECTS(stPicName); } } @@ -181,7 +182,7 @@ namespace DocFileFormat { int ret = -1; - for ( list::const_iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); iter++ ) + for ( std::list::const_iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); iter++ ) { switch ( iter->OpCode ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/PictureDescriptor.h b/ASCOfficeDocFile/DocDocxConverter/PictureDescriptor.h index 4ed8063f4f..5a31ef7108 100644 --- a/ASCOfficeDocFile/DocDocxConverter/PictureDescriptor.h +++ b/ASCOfficeDocFile/DocDocxConverter/PictureDescriptor.h @@ -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 rcWinMf; + std::vector 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 diff --git a/ASCOfficeDocFile/DocDocxConverter/PieceDescriptor.h b/ASCOfficeDocFile/DocDocxConverter/PieceDescriptor.h index 7bd37e92d9..698006f82f 100644 --- a/ASCOfficeDocFile/DocDocxConverter/PieceDescriptor.h +++ b/ASCOfficeDocFile/DocDocxConverter/PieceDescriptor.h @@ -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; }; diff --git a/ASCOfficeDocFile/DocDocxConverter/PieceTable.cpp b/ASCOfficeDocFile/DocDocxConverter/PieceTable.cpp index 3d98f3afe7..3fa160c620 100644 --- a/ASCOfficeDocFile/DocDocxConverter/PieceTable.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/PieceTable.cpp @@ -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]; - tableStream->seek(fib->m_FibWord97.fcClx); - tableStream->read(clx, (int)fib->m_FibWord97.lcbClx); + if (tableStream) + { + tableStream->seek(fib->m_FibWord97.fcClx); + tableStream->read(clx, (int)fib->m_FibWord97.lcbClx); + } - Pieces = list(); - FileCharacterPositions = new map(); - CharacterPositions = new map(); + Pieces = std::list(); + FileCharacterPositions = new std::map(); + CharacterPositions = new std::map(); 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 *piecePairs = new std::vector(); - for ( list::iterator iter = this->Pieces.begin(); iter != this->Pieces.end(); ++iter) + for ( std::list::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 >(piecePairs, bytes, cb, pcd.encoding); + FormatUtils::GetSTLCollectionFromBytes >(piecePairs, bytes, cb, pcd.code_page); RELEASEARRAYOBJECTS(bytes); } @@ -196,14 +200,14 @@ namespace DocFileFormat { std::vector *encodingChars = new std::vector(); - for (list::iterator iter = Pieces.begin(); iter != Pieces.end(); ++iter) + for (std::list::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>( encodingChars, bytes, cb, pcd.encoding ); + FormatUtils::GetSTLCollectionFromBytes>( encodingChars, bytes, cb, pcd.code_page ); RELEASEARRAYOBJECTS( bytes ); } @@ -249,7 +253,7 @@ namespace DocFileFormat wordStream->read( bytes, cb); //get the chars - FormatUtils::GetSTLCollectionFromBytes>( encodingChars, bytes, cb, pcd.encoding ); + FormatUtils::GetSTLCollectionFromBytes>( encodingChars, bytes, cb, pcd.code_page ); RELEASEARRAYOBJECTS( bytes ); } @@ -268,7 +272,7 @@ namespace DocFileFormat wordStream->read( bytes, cb); //get the chars - FormatUtils::GetSTLCollectionFromBytes>(encodingChars, bytes, cb, pcd.encoding); + FormatUtils::GetSTLCollectionFromBytes>(encodingChars, bytes, cb, pcd.code_page); RELEASEARRAYOBJECTS(bytes); @@ -291,7 +295,7 @@ namespace DocFileFormat wordStream->read( bytes, cb ); //get the chars - FormatUtils::GetSTLCollectionFromBytes>( encodingChars, bytes, cb, pcd.encoding ); + FormatUtils::GetSTLCollectionFromBytes>( encodingChars, bytes, cb, pcd.code_page ); RELEASEARRAYOBJECTS( bytes ); @@ -318,21 +322,11 @@ namespace DocFileFormat { std::vector* encodingChars = new std::vector(); - //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::iterator iter = Pieces.begin(); iter != Pieces.end(); ++iter) + for (std::list::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* encodingChars) + inline bool PieceTable::ReadSymbolsBuffer(int pos, int size, int coding, POLE::Stream* word, std::vector* encodingChars) { unsigned char* bytes = new unsigned char[size]; if (NULL == bytes) @@ -488,7 +477,7 @@ namespace DocFileFormat word->read(bytes, size); - FormatUtils::GetSTLCollectionFromBytes>(encodingChars, bytes, size, encoding); + FormatUtils::GetSTLCollectionFromBytes>(encodingChars, bytes, size, coding); RELEASEARRAYOBJECTS(bytes); diff --git a/ASCOfficeDocFile/DocDocxConverter/PieceTable.h b/ASCOfficeDocFile/DocDocxConverter/PieceTable.h index 8f67216ac9..27a489b6d9 100644 --- a/ASCOfficeDocFile/DocDocxConverter/PieceTable.h +++ b/ASCOfficeDocFile/DocDocxConverter/PieceTable.h @@ -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* GetAllEncodingText(POLE::Stream* wordStream); std::vector* GetEncodingChars(int fcStart, int fcEnd, POLE::Stream* wordStream); std::vector* 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* encodingChars); + bool ReadSymbolsBuffer(int pos, int size, int coding, POLE::Stream* word, std::vector* encodingChars); public: diff --git a/ASCOfficeDocFile/DocDocxConverter/Plex.h b/ASCOfficeDocFile/DocDocxConverter/Plex.h index e9fddd5818..594165a91d 100644 --- a/ASCOfficeDocFile/DocDocxConverter/Plex.h +++ b/ASCOfficeDocFile/DocDocxConverter/Plex.h @@ -44,16 +44,19 @@ namespace DocFileFormat protected: static const int CP_LENGTH = 4; - vector CharacterPositions; - vector Elements; + std::vector CharacterPositions; + std::vector 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::iterator iter = Elements.begin(); iter != Elements.end(); ++iter) + for (std::vector::iterator iter = Elements.begin(); iter != Elements.end(); ++iter) { RELEASEOBJECT(*iter); } diff --git a/ASCOfficeDocFile/DocDocxConverter/PropertiesMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/PropertiesMapping.cpp index ce762f8673..dc05e7bd42 100644 --- a/ASCOfficeDocFile/DocDocxConverter/PropertiesMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/PropertiesMapping.cpp @@ -34,205 +34,206 @@ namespace DocFileFormat { - map PropertiesMapping::brcTypeMap; - ASCOfficeCriticalSection PropertiesMapping::brcTypeMapLock; + std::map PropertiesMapping::brcTypeMap; + ASCOfficeCriticalSection PropertiesMapping::brcTypeMapLock; + void PropertiesMapping::init() { brcTypeMapLock.Enter(); if(brcTypeMap.size() == 0) { - brcTypeMap.insert( make_pair( 0x00, wstring( _T( "none" ) ) ) ); - brcTypeMap.insert( make_pair( 0x01, wstring( _T( "single" ) ) ) ); - brcTypeMap.insert( make_pair( 0x02, wstring( _T( "thick" ) ) ) ); - brcTypeMap.insert( make_pair( 0x03, wstring( _T( "double" ) ) ) ); - brcTypeMap.insert( make_pair( 0x05, wstring( _T( "hairline" ) ) ) ); - brcTypeMap.insert( make_pair( 0x06, wstring( _T( "dotted" ) ) ) ); - brcTypeMap.insert( make_pair( 0x07, wstring( _T( "dashed" ) ) ) ); - brcTypeMap.insert( make_pair( 0x08, wstring( _T( "dotDash" ) ) ) ); - brcTypeMap.insert( make_pair( 0x09, wstring( _T( "dotDotDash" ) ) ) ); - brcTypeMap.insert( make_pair( 0x0A, wstring( _T( "triple" ) ) ) ); - brcTypeMap.insert( make_pair( 0x0B, wstring( _T( "thinThickSmallGap" ) ) ) ); - brcTypeMap.insert( make_pair( 0x0C, wstring( _T( "thickThinSmallGap" ) ) ) ); - brcTypeMap.insert( make_pair( 0x0D, wstring( _T( "thinThickThinSmallGap" ) ) ) ); - brcTypeMap.insert( make_pair( 0x0E, wstring( _T( "thinThickMediumGap" ) ) ) ); - brcTypeMap.insert( make_pair( 0x0F, wstring( _T( "thickThinMediumGap" ) ) ) ); - brcTypeMap.insert( make_pair( 0x10, wstring( _T( "thinThickThinMediumGap" ) ) ) ); - brcTypeMap.insert( make_pair( 0x11, wstring( _T( "thinThickLargeGap" ) ) ) ); - brcTypeMap.insert( make_pair( 0x12, wstring( _T( "thickThinLargeGap" ) ) ) ); - brcTypeMap.insert( make_pair( 0x13, wstring( _T( "thinThickThinLargeGap" ) ) ) ); - brcTypeMap.insert( make_pair( 0x14, wstring( _T( "wave" ) ) ) ); - brcTypeMap.insert( make_pair( 0x15, wstring( _T( "doubleWave" ) ) ) ); - brcTypeMap.insert( make_pair( 0x16, wstring( _T( "dashSmallGap" ) ) ) ); - brcTypeMap.insert( make_pair( 0x17, wstring( _T( "dashDotStroked" ) ) ) ); - brcTypeMap.insert( make_pair( 0x18, wstring( _T( "threeDEmboss" ) ) ) ); - brcTypeMap.insert( make_pair( 0x19, wstring( _T( "threeDEngrave" ) ) ) ); - brcTypeMap.insert( make_pair( 0x1A, wstring( _T( "outset" ) ) ) ); - brcTypeMap.insert( make_pair( 0x1B, wstring( _T( "inset" ) ) ) ); - brcTypeMap.insert( make_pair( 0x40, wstring( _T( "apples" ) ) ) ); - brcTypeMap.insert( make_pair( 0x41, wstring( _T( "archedScallops" ) ) ) ); - brcTypeMap.insert( make_pair( 0x42, wstring( _T( "babyPacifier" ) ) ) ); - brcTypeMap.insert( make_pair( 0x43, wstring( _T( "babyRattle" ) ) ) ); - brcTypeMap.insert( make_pair( 0x44, wstring( _T( "balloons3Colors" ) ) ) ); - brcTypeMap.insert( make_pair( 0x45, wstring( _T( "balloonsHotAir" ) ) ) ); - brcTypeMap.insert( make_pair( 0x46, wstring( _T( "basicBlackDashes" ) ) ) ); - brcTypeMap.insert( make_pair( 0x47, wstring( _T( "basicBlackDots" ) ) ) ); - brcTypeMap.insert( make_pair( 0x48, wstring( _T( "basicBlackSquares" ) ) ) ); - brcTypeMap.insert( make_pair( 0x49, wstring( _T( "basicThinLines" ) ) ) ); - brcTypeMap.insert( make_pair( 0x4A, wstring( _T( "basicWhiteDashes" ) ) ) ); - brcTypeMap.insert( make_pair( 0x4B, wstring( _T( "basicWhiteDots" ) ) ) ); - brcTypeMap.insert( make_pair( 0x4C, wstring( _T( "basicWhiteSquares" ) ) ) ); - brcTypeMap.insert( make_pair( 0x4D, wstring( _T( "basicWideInline" ) ) ) ); - brcTypeMap.insert( make_pair( 0x4E, wstring( _T( "basicWideMidline" ) ) ) ); - brcTypeMap.insert( make_pair( 0x4F, wstring( _T( "basicWideOutline" ) ) ) ); - brcTypeMap.insert( make_pair( 0x50, wstring( _T( "bats" ) ) ) ); - brcTypeMap.insert( make_pair( 0x51, wstring( _T( "birds" ) ) ) ); - brcTypeMap.insert( make_pair( 0x52, wstring( _T( "birdsFlight" ) ) ) ); - brcTypeMap.insert( make_pair( 0x53, wstring( _T( "cabins" ) ) ) ); - brcTypeMap.insert( make_pair( 0x54, wstring( _T( "cakeSlice" ) ) ) ); - brcTypeMap.insert( make_pair( 0x55, wstring( _T( "candyCorn" ) ) ) ); - brcTypeMap.insert( make_pair( 0x56, wstring( _T( "celticKnotwork" ) ) ) ); - brcTypeMap.insert( make_pair( 0x57, wstring( _T( "certificateBanner" ) ) ) ); - brcTypeMap.insert( make_pair( 0x58, wstring( _T( "chainLink" ) ) ) ); - brcTypeMap.insert( make_pair( 0x59, wstring( _T( "champagneBottle" ) ) ) ); - brcTypeMap.insert( make_pair( 0x5A, wstring( _T( "checkedBarBlack" ) ) ) ); - brcTypeMap.insert( make_pair( 0x5B, wstring( _T( "checkedBarColor" ) ) ) ); - brcTypeMap.insert( make_pair( 0x5C, wstring( _T( "checkered" ) ) ) ); - brcTypeMap.insert( make_pair( 0x5D, wstring( _T( "christmasTree" ) ) ) ); - brcTypeMap.insert( make_pair( 0x5E, wstring( _T( "circlesLines" ) ) ) ); - brcTypeMap.insert( make_pair( 0x5F, wstring( _T( "circlesRectangles" ) ) ) ); - brcTypeMap.insert( make_pair( 0x60, wstring( _T( "classicalWave" ) ) ) ); - brcTypeMap.insert( make_pair( 0x61, wstring( _T( "clocks" ) ) ) ); - brcTypeMap.insert( make_pair( 0x62, wstring( _T( "compass" ) ) ) ); - brcTypeMap.insert( make_pair( 0x63, wstring( _T( "confetti" ) ) ) ); - brcTypeMap.insert( make_pair( 0x64, wstring( _T( "confettiGrays" ) ) ) ); - brcTypeMap.insert( make_pair( 0x65, wstring( _T( "confettiOutline" ) ) ) ); - brcTypeMap.insert( make_pair( 0x66, wstring( _T( "confettiStreamers" ) ) ) ); - brcTypeMap.insert( make_pair( 0x67, wstring( _T( "confettiWhite" ) ) ) ); - brcTypeMap.insert( make_pair( 0x68, wstring( _T( "cornerTriangles" ) ) ) ); - brcTypeMap.insert( make_pair( 0x69, wstring( _T( "couponCutoutDashes" ) ) ) ); - brcTypeMap.insert( make_pair( 0x6A, wstring( _T( "couponCutoutDots" ) ) ) ); - brcTypeMap.insert( make_pair( 0x6B, wstring( _T( "crazyMaze" ) ) ) ); - brcTypeMap.insert( make_pair( 0x6C, wstring( _T( "creaturesButterfly" ) ) ) ); - brcTypeMap.insert( make_pair( 0x6D, wstring( _T( "creaturesFish" ) ) ) ); - brcTypeMap.insert( make_pair( 0x6E, wstring( _T( "creaturesInsects" ) ) ) ); - brcTypeMap.insert( make_pair( 0x6F, wstring( _T( "creaturesLadyBug" ) ) ) ); - brcTypeMap.insert( make_pair( 0x70, wstring( _T( "crossStitch" ) ) ) ); - brcTypeMap.insert( make_pair( 0x71, wstring( _T( "cup" ) ) ) ); - brcTypeMap.insert( make_pair( 0x72, wstring( _T( "decoArch" ) ) ) ); - brcTypeMap.insert( make_pair( 0x73, wstring( _T( "decoArchColor" ) ) ) ); - brcTypeMap.insert( make_pair( 0x74, wstring( _T( "decoBlocks" ) ) ) ); - brcTypeMap.insert( make_pair( 0x75, wstring( _T( "diamondsGray" ) ) ) ); - brcTypeMap.insert( make_pair( 0x76, wstring( _T( "doubleD" ) ) ) ); - brcTypeMap.insert( make_pair( 0x77, wstring( _T( "doubleDiamonds" ) ) ) ); - brcTypeMap.insert( make_pair( 0x78, wstring( _T( "earth1" ) ) ) ); - brcTypeMap.insert( make_pair( 0x79, wstring( _T( "earth2" ) ) ) ); - brcTypeMap.insert( make_pair( 0x7A, wstring( _T( "eclipsingSquares1" ) ) ) ); - brcTypeMap.insert( make_pair( 0x7B, wstring( _T( "eclipsingSquares2" ) ) ) ); - brcTypeMap.insert( make_pair( 0x7C, wstring( _T( "eggsBlack" ) ) ) ); - brcTypeMap.insert( make_pair( 0x7D, wstring( _T( "fans" ) ) ) ); - brcTypeMap.insert( make_pair( 0x7E, wstring( _T( "film" ) ) ) ); - brcTypeMap.insert( make_pair( 0x7F, wstring( _T( "firecrackers" ) ) ) ); - brcTypeMap.insert( make_pair( 0x80, wstring( _T( "flowersBlockPrint" ) ) ) ); - brcTypeMap.insert( make_pair( 0x81, wstring( _T( "flowersDaisies" ) ) ) ); - brcTypeMap.insert( make_pair( 0x82, wstring( _T( "flowersModern1" ) ) ) ); - brcTypeMap.insert( make_pair( 0x83, wstring( _T( "flowersModern2" ) ) ) ); - brcTypeMap.insert( make_pair( 0x84, wstring( _T( "flowersPansy" ) ) ) ); - brcTypeMap.insert( make_pair( 0x85, wstring( _T( "flowersRedRose" ) ) ) ); - brcTypeMap.insert( make_pair( 0x86, wstring( _T( "flowersRoses" ) ) ) ); - brcTypeMap.insert( make_pair( 0x87, wstring( _T( "flowersTeacup" ) ) ) ); - brcTypeMap.insert( make_pair( 0x88, wstring( _T( "flowersTiny" ) ) ) ); - brcTypeMap.insert( make_pair( 0x89, wstring( _T( "gems" ) ) ) ); - brcTypeMap.insert( make_pair( 0x8A, wstring( _T( "gingerbreadMan" ) ) ) ); - brcTypeMap.insert( make_pair( 0x8B, wstring( _T( "gradient" ) ) ) ); - brcTypeMap.insert( make_pair( 0x8C, wstring( _T( "handmade1" ) ) ) ); - brcTypeMap.insert( make_pair( 0x8D, wstring( _T( "handmade2" ) ) ) ); - brcTypeMap.insert( make_pair( 0x8E, wstring( _T( "heartBalloon" ) ) ) ); - brcTypeMap.insert( make_pair( 0x8F, wstring( _T( "heartGray" ) ) ) ); - brcTypeMap.insert( make_pair( 0x90, wstring( _T( "hearts" ) ) ) ); - brcTypeMap.insert( make_pair( 0x91, wstring( _T( "heebieJeebies" ) ) ) ); - brcTypeMap.insert( make_pair( 0x92, wstring( _T( "holly" ) ) ) ); - brcTypeMap.insert( make_pair( 0x93, wstring( _T( "houseFunky" ) ) ) ); - brcTypeMap.insert( make_pair( 0x94, wstring( _T( "hypnotic" ) ) ) ); - brcTypeMap.insert( make_pair( 0x95, wstring( _T( "iceCreamCones" ) ) ) ); - brcTypeMap.insert( make_pair( 0x96, wstring( _T( "lightBulb" ) ) ) ); - brcTypeMap.insert( make_pair( 0x97, wstring( _T( "lightning1" ) ) ) ); - brcTypeMap.insert( make_pair( 0x98, wstring( _T( "lightning2" ) ) ) ); - brcTypeMap.insert( make_pair( 0x99, wstring( _T( "mapPins" ) ) ) ); - brcTypeMap.insert( make_pair( 0x9A, wstring( _T( "mapleLeaf" ) ) ) ); - brcTypeMap.insert( make_pair( 0x9B, wstring( _T( "mapleMuffins" ) ) ) ); - brcTypeMap.insert( make_pair( 0x9C, wstring( _T( "marquee" ) ) ) ); - brcTypeMap.insert( make_pair( 0x9D, wstring( _T( "marqueeToothed" ) ) ) ); - brcTypeMap.insert( make_pair( 0x9E, wstring( _T( "moons" ) ) ) ); - brcTypeMap.insert( make_pair( 0x9F, wstring( _T( "mosaic" ) ) ) ); - brcTypeMap.insert( make_pair( 0xA0, wstring( _T( "musicNotes" ) ) ) ); - brcTypeMap.insert( make_pair( 0xA1, wstring( _T( "northwest" ) ) ) ); - brcTypeMap.insert( make_pair( 0xA2, wstring( _T( "ovals" ) ) ) ); - brcTypeMap.insert( make_pair( 0xA3, wstring( _T( "packages" ) ) ) ); - brcTypeMap.insert( make_pair( 0xA4, wstring( _T( "palmsBlack" ) ) ) ); - brcTypeMap.insert( make_pair( 0xA5, wstring( _T( "palmsColor" ) ) ) ); - brcTypeMap.insert( make_pair( 0xA6, wstring( _T( "paperClips" ) ) ) ); - brcTypeMap.insert( make_pair( 0xA7, wstring( _T( "papyrus" ) ) ) ); - brcTypeMap.insert( make_pair( 0xA8, wstring( _T( "partyFavor" ) ) ) ); - brcTypeMap.insert( make_pair( 0xA9, wstring( _T( "partyGlass" ) ) ) ); - brcTypeMap.insert( make_pair( 0xAA, wstring( _T( "pencils" ) ) ) ); - brcTypeMap.insert( make_pair( 0xAB, wstring( _T( "people" ) ) ) ); - brcTypeMap.insert( make_pair( 0xAC, wstring( _T( "peopleWaving" ) ) ) ); - brcTypeMap.insert( make_pair( 0xAD, wstring( _T( "peopleHats" ) ) ) ); - brcTypeMap.insert( make_pair( 0xAE, wstring( _T( "poinsettias" ) ) ) ); - brcTypeMap.insert( make_pair( 0xAF, wstring( _T( "postageStamp" ) ) ) ); - brcTypeMap.insert( make_pair( 0xB0, wstring( _T( "pumpkin1" ) ) ) ); - brcTypeMap.insert( make_pair( 0xB1, wstring( _T( "pushPinNote2" ) ) ) ); - brcTypeMap.insert( make_pair( 0xB2, wstring( _T( "pushPinNote1" ) ) ) ); - brcTypeMap.insert( make_pair( 0xB3, wstring( _T( "pyramids" ) ) ) ); - brcTypeMap.insert( make_pair( 0xB4, wstring( _T( "pyramidsAbove" ) ) ) ); - brcTypeMap.insert( make_pair( 0xB5, wstring( _T( "quadrants" ) ) ) ); - brcTypeMap.insert( make_pair( 0xB6, wstring( _T( "rings" ) ) ) ); - brcTypeMap.insert( make_pair( 0xB7, wstring( _T( "safari" ) ) ) ); - brcTypeMap.insert( make_pair( 0xB8, wstring( _T( "sawtooth" ) ) ) ); - brcTypeMap.insert( make_pair( 0xB9, wstring( _T( "sawtoothGray" ) ) ) ); - brcTypeMap.insert( make_pair( 0xBA, wstring( _T( "scaredCat" ) ) ) ); - brcTypeMap.insert( make_pair( 0xBB, wstring( _T( "seattle" ) ) ) ); - brcTypeMap.insert( make_pair( 0xBC, wstring( _T( "shadowedSquares" ) ) ) ); - brcTypeMap.insert( make_pair( 0xBD, wstring( _T( "sharksTeeth" ) ) ) ); - brcTypeMap.insert( make_pair( 0xBE, wstring( _T( "shorebirdTracks" ) ) ) ); - brcTypeMap.insert( make_pair( 0xBF, wstring( _T( "skyrocket" ) ) ) ); - brcTypeMap.insert( make_pair( 0xC0, wstring( _T( "snowflakeFancy" ) ) ) ); - brcTypeMap.insert( make_pair( 0xC1, wstring( _T( "snowflakes" ) ) ) ); - brcTypeMap.insert( make_pair( 0xC2, wstring( _T( "sombrero" ) ) ) ); - brcTypeMap.insert( make_pair( 0xC3, wstring( _T( "southwest" ) ) ) ); - brcTypeMap.insert( make_pair( 0xC4, wstring( _T( "stars" ) ) ) ); - brcTypeMap.insert( make_pair( 0xC5, wstring( _T( "starsTop" ) ) ) ); - brcTypeMap.insert( make_pair( 0xC6, wstring( _T( "stars3d" ) ) ) ); - brcTypeMap.insert( make_pair( 0xC7, wstring( _T( "starsBlack" ) ) ) ); - brcTypeMap.insert( make_pair( 0xC8, wstring( _T( "starsShadowed" ) ) ) ); - brcTypeMap.insert( make_pair( 0xC9, wstring( _T( "sun" ) ) ) ); - brcTypeMap.insert( make_pair( 0xCA, wstring( _T( "swirligig" ) ) ) ); - brcTypeMap.insert( make_pair( 0xCB, wstring( _T( "tornPaper" ) ) ) ); - brcTypeMap.insert( make_pair( 0xCC, wstring( _T( "tornPaperBlack" ) ) ) ); - brcTypeMap.insert( make_pair( 0xCD, wstring( _T( "trees" ) ) ) ); - brcTypeMap.insert( make_pair( 0xCE, wstring( _T( "triangleParty" ) ) ) ); - brcTypeMap.insert( make_pair( 0xCF, wstring( _T( "triangles" ) ) ) ); - brcTypeMap.insert( make_pair( 0xD0, wstring( _T( "tribal1" ) ) ) ); - brcTypeMap.insert( make_pair( 0xD1, wstring( _T( "tribal2" ) ) ) ); - brcTypeMap.insert( make_pair( 0xD2, wstring( _T( "tribal3" ) ) ) ); - brcTypeMap.insert( make_pair( 0xD3, wstring( _T( "tribal4" ) ) ) ); - brcTypeMap.insert( make_pair( 0xD4, wstring( _T( "tribal5" ) ) ) ); - brcTypeMap.insert( make_pair( 0xD5, wstring( _T( "tribal6" ) ) ) ); - brcTypeMap.insert( make_pair( 0xD6, wstring( _T( "twistedLines1" ) ) ) ); - brcTypeMap.insert( make_pair( 0xD7, wstring( _T( "twistedLines2" ) ) ) ); - brcTypeMap.insert( make_pair( 0xD8, wstring( _T( "vine" ) ) ) ); - brcTypeMap.insert( make_pair( 0xD9, wstring( _T( "waveline" ) ) ) ); - brcTypeMap.insert( make_pair( 0xDA, wstring( _T( "weavingAngles" ) ) ) ); - brcTypeMap.insert( make_pair( 0xDB, wstring( _T( "weavingBraid" ) ) ) ); - brcTypeMap.insert( make_pair( 0xDC, wstring( _T( "weavingRibbon" ) ) ) ); - brcTypeMap.insert( make_pair( 0xDD, wstring( _T( "weavingStrips" ) ) ) ); - brcTypeMap.insert( make_pair( 0xDE, wstring( _T( "whiteFlowers" ) ) ) ); - brcTypeMap.insert( make_pair( 0xDF, wstring( _T( "woodwork" ) ) ) ); - brcTypeMap.insert( make_pair( 0xE0, wstring( _T( "xIllusions" ) ) ) ); - brcTypeMap.insert( make_pair( 0xE1, wstring( _T( "zanyTriangles" ) ) ) ); - brcTypeMap.insert( make_pair( 0xE2, wstring( _T( "zigZag" ) ) ) ); - brcTypeMap.insert( make_pair( 0xE3, wstring( _T( "zigZagStitch" ) ) ) ); - brcTypeMap.insert( make_pair( 0xFF, wstring( _T( "none" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x00, std::wstring( _T( "none" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x01, std::wstring( _T( "single" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x02, std::wstring( _T( "thick" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x03, std::wstring( _T( "double" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x05, std::wstring( _T( "hairline" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x06, std::wstring( _T( "dotted" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x07, std::wstring( _T( "dashed" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x08, std::wstring( _T( "dotDash" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x09, std::wstring( _T( "dotDotDash" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x0A, std::wstring( _T( "triple" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x0B, std::wstring( _T( "thinThickSmallGap" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x0C, std::wstring( _T( "thickThinSmallGap" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x0D, std::wstring( _T( "thinThickThinSmallGap" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x0E, std::wstring( _T( "thinThickMediumGap" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x0F, std::wstring( _T( "thickThinMediumGap" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x10, std::wstring( _T( "thinThickThinMediumGap" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x11, std::wstring( _T( "thinThickLargeGap" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x12, std::wstring( _T( "thickThinLargeGap" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x13, std::wstring( _T( "thinThickThinLargeGap" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x14, std::wstring( _T( "wave" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x15, std::wstring( _T( "doubleWave" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x16, std::wstring( _T( "dashSmallGap" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x17, std::wstring( _T( "dashDotStroked" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x18, std::wstring( _T( "threeDEmboss" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x19, std::wstring( _T( "threeDEngrave" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x1A, std::wstring( _T( "outset" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x1B, std::wstring( _T( "inset" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x40, std::wstring( _T( "apples" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x41, std::wstring( _T( "archedScallops" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x42, std::wstring( _T( "babyPacifier" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x43, std::wstring( _T( "babyRattle" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x44, std::wstring( _T( "balloons3Colors" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x45, std::wstring( _T( "balloonsHotAir" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x46, std::wstring( _T( "basicBlackDashes" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x47, std::wstring( _T( "basicBlackDots" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x48, std::wstring( _T( "basicBlackSquares" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x49, std::wstring( _T( "basicThinLines" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x4A, std::wstring( _T( "basicWhiteDashes" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x4B, std::wstring( _T( "basicWhiteDots" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x4C, std::wstring( _T( "basicWhiteSquares" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x4D, std::wstring( _T( "basicWideInline" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x4E, std::wstring( _T( "basicWideMidline" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x4F, std::wstring( _T( "basicWideOutline" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x50, std::wstring( _T( "bats" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x51, std::wstring( _T( "birds" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x52, std::wstring( _T( "birdsFlight" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x53, std::wstring( _T( "cabins" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x54, std::wstring( _T( "cakeSlice" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x55, std::wstring( _T( "candyCorn" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x56, std::wstring( _T( "celticKnotwork" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x57, std::wstring( _T( "certificateBanner" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x58, std::wstring( _T( "chainLink" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x59, std::wstring( _T( "champagneBottle" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x5A, std::wstring( _T( "checkedBarBlack" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x5B, std::wstring( _T( "checkedBarColor" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x5C, std::wstring( _T( "checkered" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x5D, std::wstring( _T( "christmasTree" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x5E, std::wstring( _T( "circlesLines" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x5F, std::wstring( _T( "circlesRectangles" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x60, std::wstring( _T( "classicalWave" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x61, std::wstring( _T( "clocks" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x62, std::wstring( _T( "compass" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x63, std::wstring( _T( "confetti" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x64, std::wstring( _T( "confettiGrays" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x65, std::wstring( _T( "confettiOutline" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x66, std::wstring( _T( "confettiStreamers" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x67, std::wstring( _T( "confettiWhite" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x68, std::wstring( _T( "cornerTriangles" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x69, std::wstring( _T( "couponCutoutDashes" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x6A, std::wstring( _T( "couponCutoutDots" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x6B, std::wstring( _T( "crazyMaze" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x6C, std::wstring( _T( "creaturesButterfly" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x6D, std::wstring( _T( "creaturesFish" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x6E, std::wstring( _T( "creaturesInsects" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x6F, std::wstring( _T( "creaturesLadyBug" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x70, std::wstring( _T( "crossStitch" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x71, std::wstring( _T( "cup" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x72, std::wstring( _T( "decoArch" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x73, std::wstring( _T( "decoArchColor" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x74, std::wstring( _T( "decoBlocks" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x75, std::wstring( _T( "diamondsGray" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x76, std::wstring( _T( "doubleD" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x77, std::wstring( _T( "doubleDiamonds" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x78, std::wstring( _T( "earth1" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x79, std::wstring( _T( "earth2" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x7A, std::wstring( _T( "eclipsingSquares1" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x7B, std::wstring( _T( "eclipsingSquares2" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x7C, std::wstring( _T( "eggsBlack" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x7D, std::wstring( _T( "fans" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x7E, std::wstring( _T( "film" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x7F, std::wstring( _T( "firecrackers" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x80, std::wstring( _T( "flowersBlockPrint" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x81, std::wstring( _T( "flowersDaisies" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x82, std::wstring( _T( "flowersModern1" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x83, std::wstring( _T( "flowersModern2" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x84, std::wstring( _T( "flowersPansy" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x85, std::wstring( _T( "flowersRedRose" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x86, std::wstring( _T( "flowersRoses" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x87, std::wstring( _T( "flowersTeacup" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x88, std::wstring( _T( "flowersTiny" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x89, std::wstring( _T( "gems" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x8A, std::wstring( _T( "gingerbreadMan" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x8B, std::wstring( _T( "gradient" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x8C, std::wstring( _T( "handmade1" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x8D, std::wstring( _T( "handmade2" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x8E, std::wstring( _T( "heartBalloon" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x8F, std::wstring( _T( "heartGray" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x90, std::wstring( _T( "hearts" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x91, std::wstring( _T( "heebieJeebies" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x92, std::wstring( _T( "holly" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x93, std::wstring( _T( "houseFunky" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x94, std::wstring( _T( "hypnotic" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x95, std::wstring( _T( "iceCreamCones" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x96, std::wstring( _T( "lightBulb" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x97, std::wstring( _T( "lightning1" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x98, std::wstring( _T( "lightning2" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x99, std::wstring( _T( "mapPins" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x9A, std::wstring( _T( "mapleLeaf" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x9B, std::wstring( _T( "mapleMuffins" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x9C, std::wstring( _T( "marquee" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x9D, std::wstring( _T( "marqueeToothed" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x9E, std::wstring( _T( "moons" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0x9F, std::wstring( _T( "mosaic" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xA0, std::wstring( _T( "musicNotes" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xA1, std::wstring( _T( "northwest" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xA2, std::wstring( _T( "ovals" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xA3, std::wstring( _T( "packages" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xA4, std::wstring( _T( "palmsBlack" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xA5, std::wstring( _T( "palmsColor" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xA6, std::wstring( _T( "paperClips" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xA7, std::wstring( _T( "papyrus" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xA8, std::wstring( _T( "partyFavor" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xA9, std::wstring( _T( "partyGlass" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xAA, std::wstring( _T( "pencils" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xAB, std::wstring( _T( "people" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xAC, std::wstring( _T( "peopleWaving" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xAD, std::wstring( _T( "peopleHats" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xAE, std::wstring( _T( "poinsettias" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xAF, std::wstring( _T( "postageStamp" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xB0, std::wstring( _T( "pumpkin1" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xB1, std::wstring( _T( "pushPinNote2" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xB2, std::wstring( _T( "pushPinNote1" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xB3, std::wstring( _T( "pyramids" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xB4, std::wstring( _T( "pyramidsAbove" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xB5, std::wstring( _T( "quadrants" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xB6, std::wstring( _T( "rings" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xB7, std::wstring( _T( "safari" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xB8, std::wstring( _T( "sawtooth" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xB9, std::wstring( _T( "sawtoothGray" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xBA, std::wstring( _T( "scaredCat" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xBB, std::wstring( _T( "seattle" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xBC, std::wstring( _T( "shadowedSquares" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xBD, std::wstring( _T( "sharksTeeth" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xBE, std::wstring( _T( "shorebirdTracks" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xBF, std::wstring( _T( "skyrocket" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xC0, std::wstring( _T( "snowflakeFancy" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xC1, std::wstring( _T( "snowflakes" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xC2, std::wstring( _T( "sombrero" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xC3, std::wstring( _T( "southwest" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xC4, std::wstring( _T( "stars" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xC5, std::wstring( _T( "starsTop" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xC6, std::wstring( _T( "stars3d" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xC7, std::wstring( _T( "starsBlack" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xC8, std::wstring( _T( "starsShadowed" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xC9, std::wstring( _T( "sun" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xCA, std::wstring( _T( "swirligig" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xCB, std::wstring( _T( "tornPaper" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xCC, std::wstring( _T( "tornPaperBlack" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xCD, std::wstring( _T( "trees" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xCE, std::wstring( _T( "triangleParty" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xCF, std::wstring( _T( "triangles" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xD0, std::wstring( _T( "tribal1" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xD1, std::wstring( _T( "tribal2" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xD2, std::wstring( _T( "tribal3" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xD3, std::wstring( _T( "tribal4" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xD4, std::wstring( _T( "tribal5" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xD5, std::wstring( _T( "tribal6" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xD6, std::wstring( _T( "twistedLines1" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xD7, std::wstring( _T( "twistedLines2" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xD8, std::wstring( _T( "vine" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xD9, std::wstring( _T( "waveline" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xDA, std::wstring( _T( "weavingAngles" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xDB, std::wstring( _T( "weavingBraid" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xDC, std::wstring( _T( "weavingRibbon" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xDD, std::wstring( _T( "weavingStrips" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xDE, std::wstring( _T( "whiteFlowers" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xDF, std::wstring( _T( "woodwork" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xE0, std::wstring( _T( "xIllusions" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xE1, std::wstring( _T( "zanyTriangles" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xE2, std::wstring( _T( "zigZag" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xE3, std::wstring( _T( "zigZagStitch" ) ) ) ); + brcTypeMap.insert( std::make_pair( 0xFF, std::wstring( _T( "none" ) ) ) ); } brcTypeMapLock.Leave(); } @@ -350,9 +351,9 @@ namespace DocFileFormat { XMLTools::XMLElement* ele = new XMLTools::XMLElement( _T( "w" ), elementName ); - wstring strValue = FormatUtils::IntToWideString( elementValue ); + std::wstring strValue = FormatUtils::IntToWideString( elementValue ); - if ( strValue != wstring( _T( "" ) ) ) + if ( strValue != std::wstring( _T( "" ) ) ) { XMLTools::XMLAttribute* val = new XMLTools::XMLAttribute( _T( "w:val" ), strValue.c_str() ); ele->AppendAttribute( *val ); @@ -376,9 +377,9 @@ namespace DocFileFormat { XMLTools::XMLElement* ele = new XMLTools::XMLElement( _T( "w" ), elementName ); - wstring strValue = FormatUtils::IntToWideString( elementValue ); + std::wstring strValue = FormatUtils::IntToWideString( elementValue ); - if ( strValue != wstring( _T( "" ) ) ) + if ( strValue != std::wstring( _T( "" ) ) ) { XMLTools::XMLAttribute* val = new XMLTools::XMLAttribute( _T( "w:val" ), strValue.c_str() ); ele->AppendAttribute( *val ); @@ -402,9 +403,9 @@ namespace DocFileFormat { XMLTools::XMLElement* ele = new XMLTools::XMLElement( _T( "w" ), elementName ); - wstring strValue = FormatUtils::IntToWideString( elementValue ); + std::wstring strValue = FormatUtils::IntToWideString( elementValue ); - if ( strValue != wstring( _T( "" ) ) ) + if ( strValue != std::wstring( _T( "" ) ) ) { XMLTools::XMLAttribute* val = new XMLTools::XMLAttribute( _T( "w:val" ), strValue.c_str() ); ele->AppendAttribute( *val ); @@ -519,16 +520,16 @@ namespace DocFileFormat /*========================================================================================================*/ - wstring PropertiesMapping::getBorderType( unsigned char type ) + std::wstring PropertiesMapping::getBorderType( unsigned char type ) { return this->brcTypeMap[type]; } /*========================================================================================================*/ - wstring PropertiesMapping::getShadingPattern( const ShadingDescriptor& shd ) + std::wstring PropertiesMapping::getShadingPattern( const ShadingDescriptor& shd ) { - wstring pattern = _T( "" ); + std::wstring pattern = _T( "" ); switch ( shd.ipat ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/PropertiesMapping.h b/ASCOfficeDocFile/DocDocxConverter/PropertiesMapping.h index d7f85bdead..21d66215b1 100644 --- a/ASCOfficeDocFile/DocDocxConverter/PropertiesMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/PropertiesMapping.h @@ -65,16 +65,16 @@ namespace DocFileFormat void appendValueElement( XMLTools::XMLElement* node, const wchar_t* elementName, unsigned char elementValue, bool unique ); void appendBorderAttributes( BorderCode* brc, XMLTools::XMLElement* border ); void appendShading( XMLTools::XMLElement* 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* node, const wchar_t* elementName, const wchar_t* elementValue, bool unique ); void addOrSetBorder( XMLTools::XMLElement* pBdr, const XMLTools::XMLElement* border ); protected: XmlUtils::CXmlWriter* m_pXmlWriter; - static map brcTypeMap; - - static ASCOfficeCriticalSection brcTypeMapLock; + + static std::map brcTypeMap; + static ASCOfficeCriticalSection brcTypeMapLock; }; } diff --git a/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.cpp b/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.cpp index 46519cc35c..bb7950a85c 100644 --- a/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.cpp @@ -50,109 +50,108 @@ namespace DocFileFormat /*========================================================================================================*/ - PropertyExceptions::PropertyExceptions( const list& grpprl ) + PropertyExceptions::PropertyExceptions( const std::list& grpprl ) { - this->grpprl = new list( grpprl ); + this->grpprl = new std::list( grpprl ); } /*========================================================================================================*/ - PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size ): grpprl(NULL) - { - this->grpprl = new std::list(); +PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool oldVersion ): grpprl(NULL) +{ + this->grpprl = new std::list(); - if ( ( bytes != NULL ) && ( size != 0 ) ) - { - //read the sprms + if ( ( bytes == NULL ) || ( size == 0 ) ) return; + + //read the sprms - int sprmStart = 0; - bool goOn = true; - - while ( goOn ) - { - //enough bytes to read? - if ( ( sprmStart + 2 ) < size ) - { - //make spra - OperationCode opCode = (OperationCode)FormatUtils::BytesToUInt16( bytes, sprmStart, size ); - unsigned char spra = (unsigned char)( (int)opCode >> 13 ); + int sprmStart = 0; + bool goOn = true; - // get size of operand - short opSize = (short)SinglePropertyModifier::GetOperandSize( spra ); - unsigned char lenByte = 0; + while ( goOn ) + { + //enough bytes to read? + if ( ( sprmStart + 2 ) < size ) + { + //make spra + OperationCode opCode = (OperationCode)FormatUtils::BytesToUInt16( bytes, sprmStart, size ); + unsigned char spra = (unsigned char)( (int)opCode >> 13 ); - //operand has variable size - if ( opSize == 255 ) - { - //some opCode need special treatment - switch ( opCode ) - { - case sprmTDefTable: - case sprmTDefTable10: - { - //The opSize of the table definition is stored in 2 bytes instead of 1 - lenByte = 2; - opSize = FormatUtils::BytesToInt16( bytes, ( sprmStart + 2 ), size ); - //Word adds an additional unsigned char to the opSize to compensate the additional - //unsigned char needed for the length - opSize--; + // get size of operand + short opSize = (short)SinglePropertyModifier::GetOperandSize( spra ); + unsigned char lenByte = 0; + + //operand has variable size + if ( opSize == 255 ) + { + //some opCode need special treatment + switch ( opCode ) + { + case sprmTDefTable: + case sprmTDefTable10: + { + //The opSize of the table definition is stored in 2 bytes instead of 1 + lenByte = 2; + opSize = FormatUtils::BytesToInt16( bytes, ( sprmStart + 2 ), size ); + //Word adds an additional unsigned char to the opSize to compensate the additional + //unsigned char needed for the length + opSize--; + } + break; + + case sprmPChgTabs: + { + //The tab operand can be bigger than 255 bytes (length unsigned char is set to 255). + //In this case a special calculation of the opSize is needed + lenByte = 1; + opSize = bytes[sprmStart + 2]; + + if ( opSize == 255 ) + { + unsigned char itbdDelMax = bytes[sprmStart + 3]; + unsigned char itbdAddMax = bytes[sprmStart + 3 + 2 * itbdDelMax]; + opSize = (short)( ( itbdDelMax * 4 + itbdAddMax * 3 ) - 1 ); + } + } + break; + + default: + { //The variable length stand in the unsigned char after the opcode + lenByte = 1; + opSize = bytes[sprmStart + 2]; + } + break; + } } - break; - - case sprmPChgTabs: - { - //The tab operand can be bigger than 255 bytes (length unsigned char is set to 255). - //In this case a special calculation of the opSize is needed - lenByte = 1; - opSize = bytes[sprmStart + 2]; - - if ( opSize == 255 ) - { - unsigned char itbdDelMax = bytes[sprmStart + 3]; - unsigned char itbdAddMax = bytes[sprmStart + 3 + 2 * itbdDelMax]; - opSize = (short)( ( itbdDelMax * 4 + itbdAddMax * 3 ) - 1 ); - } - } - break; - - default: - { //The variable length stand in the unsigned char after the opcode - lenByte = 1; - opSize = bytes[sprmStart + 2]; - } - break; - } - } - //copy sprm to array - //length is 2byte for the opCode, lenByte for the length, opSize for the length of the operand - int sprmBytesSize = 2 + lenByte + opSize; - unsigned char* sprmBytes = NULL; - - sprmBytes = new unsigned char[sprmBytesSize]; + //copy sprm to array + //length is 2byte for the opCode, lenByte for the length, opSize for the length of the operand + int sprmBytesSize = 2 + lenByte + opSize; + unsigned char* sprmBytes = NULL; + + sprmBytes = new unsigned char[sprmBytesSize]; - if ( size >= ( sprmStart + sprmBytesSize ) ) - { - memcpy( sprmBytes, ( bytes + sprmStart ), sprmBytesSize ); + if ( size >= ( sprmStart + sprmBytesSize ) ) + { + memcpy( sprmBytes, ( bytes + sprmStart ), sprmBytesSize ); - //parse - SinglePropertyModifier sprm( sprmBytes, sprmBytesSize ); - grpprl->push_back( sprm ); + //parse + SinglePropertyModifier sprm( sprmBytes, sprmBytesSize ); + grpprl->push_back( sprm ); - sprmStart += sprmBytesSize; - } - else - { - goOn = false; - } + sprmStart += sprmBytesSize; + } + else + { + goOn = false; + } - RELEASEARRAYOBJECTS( sprmBytes ); - } - else - { - goOn = false; - } - } - } - } + RELEASEARRAYOBJECTS( sprmBytes ); + } + else + { + goOn = false; + } + } + } } \ No newline at end of file diff --git a/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.h b/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.h index 731a4cb1bb..aa49d777da 100644 --- a/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.h +++ b/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.h @@ -48,6 +48,6 @@ namespace DocFileFormat virtual ~PropertyExceptions(); PropertyExceptions(); PropertyExceptions( const std::list& grpprl ); - PropertyExceptions( unsigned char* bytes, int size ); + PropertyExceptions( unsigned char* bytes, int size, bool oldVersion ); }; } diff --git a/ASCOfficeDocFile/DocDocxConverter/RGBColor.h b/ASCOfficeDocFile/DocDocxConverter/RGBColor.h index bc8f81abe7..94d5599ce5 100644 --- a/ASCOfficeDocFile/DocDocxConverter/RGBColor.h +++ b/ASCOfficeDocFile/DocDocxConverter/RGBColor.h @@ -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 ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/SectionPropertiesMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/SectionPropertiesMapping.cpp index 8197dc3860..695e453735 100644 --- a/ASCOfficeDocFile/DocDocxConverter/SectionPropertiesMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/SectionPropertiesMapping.cpp @@ -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::iterator iter = sepx->grpprl->begin(); iter != sepx->grpprl->end(); ++iter) + for (std::list::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; } diff --git a/ASCOfficeDocFile/DocDocxConverter/SectionPropertiesMapping.h b/ASCOfficeDocFile/DocDocxConverter/SectionPropertiesMapping.h index e99fd6fb18..59ae56c7cb 100644 --- a/ASCOfficeDocFile/DocDocxConverter/SectionPropertiesMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/SectionPropertiesMapping.h @@ -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; }; diff --git a/ASCOfficeDocFile/DocDocxConverter/SectionPropertyExceptions.h b/ASCOfficeDocFile/DocDocxConverter/SectionPropertyExceptions.h index e13a442647..f9fab1a694 100644 --- a/ASCOfficeDocFile/DocDocxConverter/SectionPropertyExceptions.h +++ b/ASCOfficeDocFile/DocDocxConverter/SectionPropertyExceptions.h @@ -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::iterator iter = this->grpprl->begin(); iter != this->grpprl->end(); iter++ ) + for ( std::list::iterator iter = this->grpprl->begin(); iter != this->grpprl->end(); iter++ ) { SinglePropertyModifier sprm( *iter ); diff --git a/ASCOfficeDocFile/DocDocxConverter/SettingsMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/SettingsMapping.cpp index 166c0b3894..14d5efc2d4 100644 --- a/ASCOfficeDocFile/DocDocxConverter/SettingsMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/SettingsMapping.cpp @@ -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::iterator iter = this->_ctx->AllRsids.begin(); iter != this->_ctx->AllRsids.end(); iter++ ) + for ( std::set::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() ); diff --git a/ASCOfficeDocFile/DocDocxConverter/SprmTDefTable.h b/ASCOfficeDocFile/DocDocxConverter/SprmTDefTable.h index 603320584a..24c084c33b 100644 --- a/ASCOfficeDocFile/DocDocxConverter/SprmTDefTable.h +++ b/ASCOfficeDocFile/DocDocxConverter/SprmTDefTable.h @@ -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 rgdxaCenter; + std::vector 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 rgTc80; + std::vector rgTc80; }; } \ No newline at end of file diff --git a/ASCOfficeDocFile/DocDocxConverter/StringTable.h b/ASCOfficeDocFile/DocDocxConverter/StringTable.h index dda8587d6a..33ece8d4ab 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StringTable.h +++ b/ASCOfficeDocFile/DocDocxConverter/StringTable.h @@ -39,127 +39,147 @@ namespace DocFileFormat { - template class StringTable: public IVisitable - { - friend class CharacterPropertiesMapping; - friend class FontTableMapping; - friend class StyleSheetMapping; - friend class DocumentMapping; + template class StringTable: public IVisitable + { + friend class CharacterPropertiesMapping; + friend class FontTableMapping; + friend class StyleSheetMapping; + friend class DocumentMapping; private: - ASCDocFormatUtils::Encoding _enc; - bool fExtend; - int cData; - unsigned short cbExtra; - vector Data; - - public: - virtual ~StringTable() - { - for ( vector::iterator iter = this->Data.begin(); iter != this->Data.end(); iter++ ) - { - RELEASEOBJECT( *iter ); - } - } - - StringTable( VirtualStreamReader *reader ): - _enc(ENCODING_INVALID_VALUE), fExtend(false), cData(0), cbExtra(0) - { - parse( reader, (unsigned int)reader->GetPosition() ); - } - - StringTable( POLE::Stream* tableStream, unsigned int fc, unsigned int lcb ): - _enc(ENCODING_INVALID_VALUE), fExtend(false), cData(0), cbExtra(0) - { - if ( lcb > 0 ) - { - VirtualStreamReader reader( tableStream, fc ); + bool fExtend; + int cbData; + unsigned short cbExtra; - parse( &reader, fc ) ; - } - } + std::vector Data; - ByteStructure* operator [] ( unsigned int index ) const - { - if ( index < this->Data.size() ) - { - return this->Data.at( index ); - } - else - { - return NULL; - } - } - - private: - void parse( VirtualStreamReader *reader, unsigned int fc ) - { - if ( reader != NULL ) + int code_page; + public: + virtual ~StringTable() { - //read fExtend - if ( reader->ReadUInt16() == 0xFFFF ) - { - //if the first 2 bytes are 0xFFFF the STTB contains unicode characters - this->fExtend = true; - _enc = ENCODING_UNICODE; - } - else - { - //else the STTB contains 1byte characters and the fExtend field is non-existend - //seek back to the beginning - this->fExtend = false; - _enc = ENCODING_WINDOWS_1251; - - reader->Seek( (int)fc, 0/*STREAM_SEEK_SET*/ ); - } - - //read cData - long cDataStart = reader->GetPosition(); - unsigned short c = reader->ReadUInt16(); - - if ( c != 0xFFFF ) - { - //cData is a 2byte unsigned Integer and the read bytes are already cData - this->cData = (int)c; - } - else - { - //cData is a 4byte signed Integer, so we need to seek back - reader->Seek( (int)( fc + cDataStart ), 0/*STREAM_SEEK_SET*/ ); - - this->cData = reader->ReadInt32(); - } - - //read cbExtra - this->cbExtra = reader->ReadUInt16(); - - //read the strings and extra datas - for ( int i = 0; i < this->cData; i++ ) - { - int cchData = 0; - int cbData = 0; - - if ( this->fExtend ) - { - cchData = (int)reader->ReadUInt16(); - cbData = cchData * 2; - } - else - { - cchData = (int)reader->ReadByte(); - cbData = cchData; - } - - long posBeforeType = reader->GetPosition(); - - this->Data.push_back( T().ConstructObject( reader, cbData ) ); - - reader->Seek( (int)( posBeforeType + cbData ), 0/*STREAM_SEEK_SET */); - - //skip the extra unsigned char - reader->ReadBytes( cbExtra, false ); - } + for ( std::vector::iterator iter = this->Data.begin(); iter != this->Data.end(); iter++ ) + { + RELEASEOBJECT( *iter ); + } } - } - }; + + StringTable( VirtualStreamReader *reader, int code_page_ ): + code_page(code_page_), fExtend(false), cData(0), cbExtra(0) + { + parse( reader, (unsigned int)reader->GetPosition() ); + } + + StringTable( POLE::Stream* tableStream, unsigned int fc, unsigned int lcb, bool older ) : + code_page(1250), fExtend(false), cbData(0), cbExtra(0) + { + if ( lcb > 0 ) + { + VirtualStreamReader reader( tableStream, fc, older); + + parse( &reader, fc, lcb ) ; + } + } + + ByteStructure* operator [] ( unsigned int index ) const + { + if ( index < this->Data.size() ) + { + return this->Data.at( index ); + } + else + { + return NULL; + } + } + + private: + + void parse( VirtualStreamReader *reader, unsigned int fc, unsigned int lcb = 0 ) + { + if ( reader == NULL ) return; + if (fc > reader->GetSize()) return; + + this->cbData = lcb; + + int count_elements = 0; + //read fExtend + if ( reader->ReadUInt16() == 0xFFFF ) + { + //if the first 2 bytes are 0xFFFF the STTB contains unicode characters + this->fExtend = true; + code_page = ENCODING_UTF16; + } + else + { + //else the STTB contains 1byte characters and the fExtend field is non-existend + //seek back to the beginning + this->fExtend = false; + code_page = ENCODING_WINDOWS_1250; + + reader->Seek( (int)fc, 0/*STREAM_SEEK_SET*/ ); + } + + //read cData + long cDataStart = reader->GetPosition(); + unsigned short c = reader->ReadUInt16(); + + if ( c != 0xFFFF ) + { + if (reader->olderVersion) + this->cbData = (int)c; // all size + else + count_elements = c; + + } + else + { + //cData is a 4byte signed Integer, so we need to seek back + reader->Seek( (int)( fc + cDataStart ), 0/*STREAM_SEEK_SET*/ ); + + this->cbData = reader->ReadInt32(); + } + //read cbExtra + if (reader->olderVersion == false) + { + this->cbExtra = reader->ReadUInt16(); + } + + if (lcb > 0 && (lcb/* - fc*/) != this->cbData + this->cbExtra) + { + //???? + } + + while(true) //read the strings and extra datas + { + if (reader->GetPosition() >= fc + this->cbData + this->cbExtra && count_elements < 1) + break; //1995 and older + + if (this->Data.size() == count_elements && count_elements > 0) + break; //1997 and newer + + int cchData = 0; + int cbData = 0; + + if ( this->fExtend ) + { + cchData = (int)reader->ReadUInt16(); + cbData = cchData * 2; + } + else + { + cchData = (int)reader->ReadByte(); + cbData = cchData; + } + + long posBeforeType = reader->GetPosition(); + + this->Data.push_back( T().ConstructObject( reader, cbData ) ); + + reader->Seek( (int)( posBeforeType + cbData ), 0/*STREAM_SEEK_SET */); + + + reader->ReadBytes( cbExtra, false );//skip the extra unsigned char + } + } + }; } diff --git a/ASCOfficeDocFile/DocDocxConverter/StructuredStorageReader.h b/ASCOfficeDocFile/DocDocxConverter/StructuredStorageReader.h index fd4974bb81..39cbc57cb5 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StructuredStorageReader.h +++ b/ASCOfficeDocFile/DocDocxConverter/StructuredStorageReader.h @@ -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; } diff --git a/ASCOfficeDocFile/DocDocxConverter/StyleSheet.cpp b/ASCOfficeDocFile/DocDocxConverter/StyleSheet.cpp index a51444b5d3..d6e8710153 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StyleSheet.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/StyleSheet.cpp @@ -40,7 +40,7 @@ namespace DocFileFormat if ( NULL != Styles ) { - for ( vector::iterator iter = Styles->begin(); iter != Styles->end(); iter++ ) + for ( std::vector::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(); + this->Styles = new std::vector(); 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 ); } diff --git a/ASCOfficeDocFile/DocDocxConverter/StyleSheet.h b/ASCOfficeDocFile/DocDocxConverter/StyleSheet.h index 8d2560dc6f..79f70f91ac 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StyleSheet.h +++ b/ASCOfficeDocFile/DocDocxConverter/StyleSheet.h @@ -51,6 +51,6 @@ namespace DocFileFormat /// The StyleSheetInformation of the stylesheet. StyleSheetInformation* stshi; /// The list contains all styles. - vector* Styles; + std::vector* Styles; }; } \ No newline at end of file diff --git a/ASCOfficeDocFile/DocDocxConverter/StyleSheetDescription.cpp b/ASCOfficeDocFile/DocDocxConverter/StyleSheetDescription.cpp index 6694fb4f72..a8240e3829 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StyleSheetDescription.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/StyleSheetDescription.cpp @@ -48,7 +48,8 @@ namespace DocFileFormat } /// Parses the bytes to retrieve a StyleSheetDescription - StyleSheetDescription::StyleSheetDescription (unsigned char* bytes, int size, int cbStdBase, POLE::Stream* dataStream) : papx(NULL), chpx(NULL), tapx(NULL) + StyleSheetDescription::StyleSheetDescription (unsigned char* bytes, int size, int cbStdBase, POLE::Stream* dataStream, bool oldVersion) : + papx(NULL), chpx(NULL), tapx(NULL) { //parsing the base (fix part) @@ -114,21 +115,30 @@ namespace DocFileFormat //rsid rsid = FormatUtils::GetUIntFromBytesBits( bytes, size, 96, 32 ); } +//parsing the variable part + unsigned char *name = NULL; + unsigned char characterCount = bytes[cbStdBase]; + int upxOffset = 0; - //parsing the variable part - - //xstz - unsigned char characterCount = bytes[cbStdBase]; - //characters are zero-terminated, so 1 char has 2 bytes: - unsigned char* name = new unsigned char[characterCount * 2]; - memcpy( name, ( bytes + cbStdBase + 2 ), ( characterCount * 2 ) ); - //remove zero-termination - FormatUtils::GetSTLCollectionFromBytes( &(this->xstzName), name, ( characterCount * 2 ), ENCODING_UNICODE ); + if (oldVersion) + { + name = new unsigned char[characterCount];//characters are zero-terminated, so 1 char has 2 bytes: + memcpy( name, ( bytes + cbStdBase + 1 ), ( characterCount ) ); + FormatUtils::GetSTLCollectionFromBytes( &(this->xstzName), name, ( characterCount ), ENCODING_WINDOWS_1250 ); + upxOffset = cbStdBase + 1 + ( characterCount /** 2*/ ) + 1; + } + else + { + name = new unsigned char[characterCount * 2];//characters are zero-terminated, so 1 char has 2 bytes: + memcpy( name, ( bytes + cbStdBase + 2 ), ( characterCount * 2 ) ); + //remove zero-termination + FormatUtils::GetSTLCollectionFromBytes( &(this->xstzName), name, ( characterCount * 2 ), ENCODING_UTF16 ); + + //parse the UPX structs + upxOffset = cbStdBase + 1 + ( characterCount * 2 ) + 2; + } RELEASEARRAYOBJECTS( name ); - //parse the UPX structs - int upxOffset = cbStdBase + 1 + ( characterCount * 2 ) + 2; - for ( int i = 0; i < this->cupx; i++ ) { //find the next even unsigned char border @@ -153,22 +163,23 @@ namespace DocFileFormat { case 0: { - RELEASEOBJECT( this->tapx ); - this->tapx = new TablePropertyExceptions( upxBytes, cbUPX ); + //todooo не реализовано + //RELEASEOBJECT( this->tapx ); + //this->tapx = new TablePropertyExceptions( upxBytes, cbUPX, dataStream, oldVersion); } break; case 1: { RELEASEOBJECT( this->papx ); - this->papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream ); + this->papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream, oldVersion); } break; case 2: { RELEASEOBJECT( this->chpx ); - this->chpx = new CharacterPropertyExceptions( upxBytes, cbUPX ); + this->chpx = new CharacterPropertyExceptions( upxBytes, cbUPX , oldVersion); } break; } @@ -181,14 +192,14 @@ namespace DocFileFormat case 0: { RELEASEOBJECT( this->papx ); - this->papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream ); + this->papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream, oldVersion ); } break; case 1: { RELEASEOBJECT( this->chpx ); - this->chpx = new CharacterPropertyExceptions( upxBytes, cbUPX ); + this->chpx = new CharacterPropertyExceptions( upxBytes, cbUPX, oldVersion); } break; } @@ -201,7 +212,7 @@ namespace DocFileFormat case 0: { RELEASEOBJECT( this->papx ); - this->papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream ); + this->papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream, oldVersion ); } break; } @@ -214,7 +225,7 @@ namespace DocFileFormat case 0: { RELEASEOBJECT( this->chpx ); - this->chpx = new CharacterPropertyExceptions( upxBytes, cbUPX ); + this->chpx = new CharacterPropertyExceptions( upxBytes, cbUPX, oldVersion); } break; } diff --git a/ASCOfficeDocFile/DocDocxConverter/StyleSheetDescription.h b/ASCOfficeDocFile/DocDocxConverter/StyleSheetDescription.h index 316836b242..02d9bc9b6f 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StyleSheetDescription.h +++ b/ASCOfficeDocFile/DocDocxConverter/StyleSheetDescription.h @@ -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 diff --git a/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.cpp index 44fd8ae610..ff1dad0b3f 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.cpp @@ -35,8 +35,8 @@ namespace DocFileFormat { - map StyleSheetMapping::m_mapStyleId; - ASCOfficeCriticalSection StyleSheetMapping::m_mapStyleIdLock; + std::map StyleSheetMapping::m_mapStyleId; + ASCOfficeCriticalSection StyleSheetMapping::m_mapStyleIdLock; StyleSheetMapping::StyleSheetMapping( ConversionContext* ctx ) : AbstractOpenXmlMapping( new XmlUtils::CXmlWriter() ) { @@ -80,7 +80,7 @@ namespace DocFileFormat writeNormalTableStyle(); } - for ( vector::iterator iter = sheet->Styles->begin(); iter != sheet->Styles->end(); iter++ ) + for ( std::vector::iterator iter = sheet->Styles->begin(); iter != sheet->Styles->end(); iter++ ) { if ( *iter != NULL ) { @@ -170,7 +170,7 @@ namespace DocFileFormat //write table properties if ( (*iter)->tapx != NULL ) { - vector tableGrid; + std::vector tableGrid; TablePropertiesMapping* tpMapping = new TablePropertiesMapping (m_pXmlWriter, sheet, &tableGrid, false); (*iter)->tapx->Convert( tpMapping ); RELEASEOBJECT( tpMapping ); @@ -182,15 +182,15 @@ namespace DocFileFormat m_pXmlWriter->WriteNodeEnd( _T( "w:styles" ) ); - this->_ctx->_docx->StyleSheetXML = wstring( m_pXmlWriter->GetXmlString() ); + this->_ctx->_docx->StyleSheetXML = std::wstring( m_pXmlWriter->GetXmlString() ); } /*========================================================================================================*/ /// Generates a style id for custom style names or returns the build-in identifier for build-in styles. - wstring StyleSheetMapping::MakeStyleId( StyleSheetDescription* std ) + std::wstring StyleSheetMapping::MakeStyleId( StyleSheetDescription* std ) { - wstring ret; + std::wstring ret; if ( std != NULL ) { @@ -199,7 +199,7 @@ namespace DocFileFormat //use the identifier if ( std->sti < 159 ) { - ret = wstring( StyleIdentifierMap[std->sti] ); + ret = std::wstring( StyleIdentifierMap[std->sti] ); } else { @@ -209,7 +209,7 @@ namespace DocFileFormat else { //if no identifier is set, use the unique id. - map::const_iterator findResult = m_mapStyleId.find(std->xstzName); + std::map::const_iterator findResult = m_mapStyleId.find(std->xstzName); if( findResult != m_mapStyleId.end() ) { ret = findResult->second; @@ -220,7 +220,7 @@ namespace DocFileFormat m_mapStyleIdLock.Enter(); int nIndex = m_mapStyleId.size(); ret = _T("UserStyle_") + FormatUtils::IntToWideString( nIndex ); - pair< std::wstring, std::wstring > p( std->xstzName, ret); + std::pair< std::wstring, std::wstring > p( std->xstzName, ret); m_mapStyleId.insert(p); m_mapStyleIdLock.Leave(); } @@ -260,7 +260,7 @@ namespace DocFileFormat m_pXmlWriter->WriteNodeEnd( _T( "w:rFonts" ) ); LanguageId langid(this->m_document->FIB->m_FibBase.lid); - wstring langcode = LanguageIdMapping::getLanguageCode( &langid ); + std::wstring langcode = LanguageIdMapping::getLanguageCode( &langid ); m_pXmlWriter->WriteNodeBegin( _T( "w:lang" ), TRUE ); m_pXmlWriter->WriteAttribute( _T( "w:val" ), langcode.c_str() ); @@ -286,10 +286,10 @@ namespace DocFileFormat /// Chooses the correct style name. /// Word 2007 needs the identifier instead of the stylename for translating it into the UI language. - wstring StyleSheetMapping::getStyleName( StyleSheetDescription* std ) + std::wstring StyleSheetMapping::getStyleName( StyleSheetDescription* std ) { - wstring id; - wstring name; + std::wstring id; + std::wstring name; if ( std != NULL ) { @@ -300,7 +300,7 @@ namespace DocFileFormat //use the identifier if ( std->sti < 159 ) { - id = wstring( StyleIdentifierMap[std->sti] ); + id = std::wstring( StyleIdentifierMap[std->sti] ); } else { @@ -310,7 +310,7 @@ namespace DocFileFormat else { //if no identifier is set, use the unique id. - map::const_iterator findResult = m_mapStyleId.find(name); + std::map::const_iterator findResult = m_mapStyleId.find(name); if( findResult != m_mapStyleId.end() ) { id = findResult->second; @@ -321,7 +321,7 @@ namespace DocFileFormat m_mapStyleIdLock.Enter(); int nIndex = m_mapStyleId.size(); id = _T("UserStyle_") + FormatUtils::IntToWideString( nIndex ); - pair< std::wstring, std::wstring > p( name, id); + std::pair< std::wstring, std::wstring > p( name, id); m_mapStyleId.insert(p); m_mapStyleIdLock.Leave(); } diff --git a/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.h b/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.h index 0c997c395d..89c4a4158a 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.h @@ -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 m_mapStyleId; + static std::wstring MakeStyleId( StyleSheetDescription* std ); + static std::map 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(); }; diff --git a/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.cpp index bc9d85a472..50c6dd726c 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.cpp @@ -35,7 +35,8 @@ namespace DocFileFormat { - TableCellPropertiesMapping::TableCellPropertiesMapping (XmlUtils::CXmlWriter* pWriter, const vector* tableGrid, int gridIndex, int cellIndex) : PropertiesMapping(pWriter) + TableCellPropertiesMapping::TableCellPropertiesMapping (XmlUtils::CXmlWriter* pWriter, const std::vector* tableGrid, int gridIndex, int cellIndex) : + PropertiesMapping(pWriter) { _width = 0; @@ -377,7 +378,7 @@ namespace DocFileFormat } } - bool TableCellPropertiesMapping::IsTableBordersDefined (const list* grpprl) const + bool TableCellPropertiesMapping::IsTableBordersDefined (const std::list* grpprl) const { if (grpprl) { @@ -392,7 +393,7 @@ namespace DocFileFormat return false; } - bool TableCellPropertiesMapping::IsTableCellWidthDefined (const list* grpprl) const + bool TableCellPropertiesMapping::IsTableCellWidthDefined (const std::list* grpprl) const { if (grpprl) { diff --git a/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.h b/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.h index 830c65c8b2..e398840e16 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.h @@ -58,7 +58,7 @@ namespace DocFileFormat public: virtual ~TableCellPropertiesMapping(); - TableCellPropertiesMapping (XmlUtils::CXmlWriter* pWriter, const vector* tableGrid, int gridIndex, int cellIndex); + TableCellPropertiesMapping (XmlUtils::CXmlWriter* pWriter, const std::vector* tableGrid, int gridIndex, int cellIndex); virtual void Apply( IVisitable* visited ); inline int GetGridSpan() const @@ -69,18 +69,20 @@ namespace DocFileFormat private: void apppendCellShading (unsigned char* sprmArg, int size, int cellIndex); - bool IsTableBordersDefined (const list* grpprl) const; - bool IsTableCellWidthDefined (const list* grpprl) const; + bool IsTableBordersDefined (const std::list* grpprl) const; + bool IsTableCellWidthDefined (const std::list* grpprl) const; private: int _gridIndex; int _cellIndex; + XMLTools::XMLElement* _tcPr; XMLTools::XMLElement* _tcMar; XMLTools::XMLElement* _tcBorders; - const vector* _grid; - vector _tGrid; + + const std::vector* _grid; + std::vector _tGrid; short _width; Global::CellWidthType _ftsWidth; diff --git a/ASCOfficeDocFile/DocDocxConverter/TableInfo.h b/ASCOfficeDocFile/DocDocxConverter/TableInfo.h index 10b740410b..b6df085388 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TableInfo.h +++ b/ASCOfficeDocFile/DocDocxConverter/TableInfo.h @@ -49,7 +49,7 @@ namespace DocFileFormat { if ( papx != NULL ) { - for ( list::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ ) + for ( std::list::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ ) { if ( iter->OpCode == sprmPFInTable ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/TableMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/TableMapping.cpp index a20096c934..c206d3b8a8 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TableMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/TableMapping.cpp @@ -41,7 +41,7 @@ namespace DocFileFormat TableCell::TableCell( const TableCell& _tableCell ) : cp(_tableCell.cp), depth(_tableCell.depth), documentMapping(_tableCell.documentMapping) { - for ( list::const_iterator iter = _tableCell.cellElements.begin(); iter != _tableCell.cellElements.end(); iter++ ) + for ( std::list::const_iterator iter = _tableCell.cellElements.begin(); iter != _tableCell.cellElements.end(); iter++ ) { this->AddItem( **iter ); } @@ -59,7 +59,7 @@ namespace DocFileFormat this->depth = _tableCell.depth; this->cellElements.clear(); - for ( list::const_iterator iter = _tableCell.cellElements.begin(); iter != _tableCell.cellElements.end(); iter++ ) + for ( std::list::const_iterator iter = _tableCell.cellElements.begin(); iter != _tableCell.cellElements.end(); iter++ ) { this->AddItem( **iter ); } @@ -106,7 +106,7 @@ namespace DocFileFormat this->cellElements.clear(); } - void TableCell::Convert(IMapping* mapping, TablePropertyExceptions* tapx, const vector* grid, int& gridIndex, int nCellIndex) + void TableCell::Convert(IMapping* mapping, TablePropertyExceptions* tapx, const std::vector* grid, int& gridIndex, int nCellIndex) { if (NULL != mapping) { @@ -135,7 +135,7 @@ namespace DocFileFormat documentMapping->_lastValidPapx = papxBackup; documentMapping->_lastValidSepx = sepxBackup; - for (list::iterator iter = cellElements.begin(); iter != cellElements.end(); ++iter) + for (std::list::iterator iter = cellElements.begin(); iter != cellElements.end(); ++iter) { (*iter)->Convert( mapping ); } @@ -193,7 +193,7 @@ namespace DocFileFormat this->cells.clear(); } - void TableRow::Convert(IMapping* mapping, const vector* grid) + void TableRow::Convert(IMapping* mapping, const std::vector* grid) { if ( mapping != NULL ) { @@ -213,15 +213,18 @@ namespace DocFileFormat //convert the properties int fcRowEnd = documentMapping->findRowEndFc(cp, depth); - TablePropertyExceptions tapx( this->documentMapping->findValidPapx( fcRowEnd ), this->documentMapping->m_document->DataStream ); - list* chpxs = this->documentMapping->m_document->GetCharacterPropertyExceptions( fcRowEnd, fcRowEnd + 1 ); + TablePropertyExceptions tapx ( documentMapping->findValidPapx( fcRowEnd ), + documentMapping->m_document->DataStream, + documentMapping->m_document->FIB->m_bOlderVersion); + + std::list* chpxs = this->documentMapping->m_document->GetCharacterPropertyExceptions( fcRowEnd, fcRowEnd + 1 ); TableRowPropertiesMapping trpMapping( this->documentMapping->GetXMLWriter(), *(chpxs->begin()) ); tapx.Convert( &trpMapping ); this->documentMapping->_lastValidPapx = papxBackup; this->documentMapping->_lastValidSepx = sepxBackup; - for ( list::iterator iter = this->cells.begin(); iter != this->cells.end(); iter++ ) + for ( std::list::iterator iter = this->cells.begin(); iter != this->cells.end(); iter++ ) { iter->Convert( mapping, &tapx, grid, gridIndex, nCellIndex++ ); } @@ -294,6 +297,8 @@ namespace DocFileFormat bool Table::IsCellMarker(int _cp) { + if ( _cp > documentMapping->m_document->Text->size() - 1) return false; + int fc = documentMapping->m_document->FindFileCharPos(_cp); if (fc < 0) return false; @@ -303,6 +308,7 @@ namespace DocFileFormat TableInfo tai( papx ); + return ( ( tai.fInTable ) && ( ( ( documentMapping->m_document->Text->at( _cp ) == 0x0007 ) && ( tai.iTap <= 1 ) && ( !tai.fTtp ) ) || ( ( documentMapping->m_document->Text->at( _cp ) == 0x000D ) && ( tai.iTap > 1 ) && @@ -311,6 +317,8 @@ namespace DocFileFormat bool Table::IsRowMarker( int _cp ) { + if ( _cp > documentMapping->m_document->Text->size() - 1) return false; + int fc = documentMapping->m_document->FindFileCharPos(_cp); if (fc < 0) return false; @@ -328,7 +336,10 @@ namespace DocFileFormat bool Table::IsParagraphMarker( int _cp ) { + if ( _cp > documentMapping->m_document->Text->size() - 1) return false; + int fc = documentMapping->m_document->FindFileCharPos(_cp); + if (fc < 0) return false; ParagraphPropertyExceptions* papx = NULL; @@ -496,12 +507,14 @@ namespace DocFileFormat SectionPropertyExceptions* sepxBackup = documentMapping->_lastValidSepx; //build the table grid - vector* grid = this->documentMapping->buildTableGrid( this->cpStart, this->depth ); + std::vector* grid = this->documentMapping->buildTableGrid( this->cpStart, this->depth ); //find first row end int fcRowEnd = this->documentMapping->findRowEndFc( this->cpStart, this->depth ); - TablePropertyExceptions row1Tapx( this->documentMapping->findValidPapx( fcRowEnd ), this->documentMapping->m_document->DataStream ); + TablePropertyExceptions row1Tapx( documentMapping->findValidPapx( fcRowEnd ), + documentMapping->m_document->DataStream , + documentMapping->m_document->FIB->m_bOlderVersion); //start table this->documentMapping->GetXMLWriter()->WriteNodeBegin( _T( "w:tbl" ) ); @@ -514,7 +527,7 @@ namespace DocFileFormat this->documentMapping->_lastValidPapx = papxBackup; this->documentMapping->_lastValidSepx = sepxBackup; - for ( list::iterator iter = this->rows.begin(); iter != this->rows.end(); iter++ ) + for ( std::list::iterator iter = this->rows.begin(); iter != this->rows.end(); iter++ ) { iter->Convert( mapping, grid ); } diff --git a/ASCOfficeDocFile/DocDocxConverter/TableMapping.h b/ASCOfficeDocFile/DocDocxConverter/TableMapping.h index c277ce6ed2..988637fbab 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TableMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/TableMapping.h @@ -58,14 +58,14 @@ namespace DocFileFormat void AddItem( const ITableCellElement& _tableCellElement ); bool IsEmpty() const; void Clear(); - void Convert( IMapping* mapping, TablePropertyExceptions* tapx, const vector* grid, int& gridIndex, int cellIndex ); + void Convert( IMapping* mapping, TablePropertyExceptions* tapx, const std::vector* grid, int& gridIndex, int cellIndex ); ~TableCell(); private: int cp; unsigned int depth; - list cellElements; + std::list cellElements; DocumentMapping* documentMapping; }; @@ -81,14 +81,14 @@ namespace DocFileFormat void AddCell( const TableCell& _tableCell ); bool IsEmpty() const; void Clear(); - void Convert( IMapping* mapping, const vector* grid ); + void Convert( IMapping* mapping, const std::vector* grid ); ~TableRow(); private: int cp; unsigned int depth; - list cells; + std::list cells; DocumentMapping* documentMapping; }; @@ -148,7 +148,7 @@ namespace DocFileFormat int cpStart; int cpEnd; unsigned int depth; - list rows; + std::list rows; DocumentMapping* documentMapping; }; diff --git a/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.cpp index b8947a0a3c..4eb927c8f0 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.cpp @@ -34,7 +34,7 @@ namespace DocFileFormat { - TablePropertiesMapping::TablePropertiesMapping (XmlUtils::CXmlWriter* pWriter, StyleSheet* styles, vector* grid, bool isTableStyleNeeded ): + TablePropertiesMapping::TablePropertiesMapping (XmlUtils::CXmlWriter* pWriter, StyleSheet* styles, std::vector* grid, bool isTableStyleNeeded ): PropertiesMapping(pWriter), _tblPr(NULL), _tblGrid(NULL), _tblBorders(NULL), _grid(NULL), brcLeft(NULL), brcTop(NULL), brcBottom(NULL), brcRight(NULL), brcHorz(NULL), brcVert(NULL), _styles(NULL), _isTableStyleNeeded(isTableStyleNeeded) @@ -74,7 +74,7 @@ namespace DocFileFormat short marginLeft = 0; short marginRight = 0; - for ( list::iterator iter = tapx->grpprl->begin(); iter != tapx->grpprl->end(); iter++ ) + for ( std::list::iterator iter = tapx->grpprl->begin(); iter != tapx->grpprl->end(); iter++ ) { switch( iter->OpCode ) { @@ -187,7 +187,7 @@ namespace DocFileFormat { unsigned char grfbrc = iter->Arguments[2]; short wMar = FormatUtils::BytesToInt16( iter->Arguments, 4, iter->argumentsSize ); - wstring strValue = FormatUtils::IntToWideString( wMar ); + std::wstring strValue = FormatUtils::IntToWideString( wMar ); if ( FormatUtils::BitmaskToBool( (int)grfbrc, 0x01 ) ) { @@ -228,11 +228,11 @@ namespace DocFileFormat //overlap case sprmTFNoAllowOverlap: { - wstring tblOverlapVal = wstring( _T( "overlap" ) ); + std::wstring tblOverlapVal = std::wstring( _T( "overlap" ) ); if ( iter->Arguments[0] ) { - tblOverlapVal = wstring( _T( "never" ) ); + tblOverlapVal = std::wstring( _T( "never" ) ); } appendValueElement( _tblPr, _T( "tblOverlap" ), tblOverlapVal.c_str(), true ); @@ -475,7 +475,7 @@ namespace DocFileFormat //append the grid _tblGrid = new XMLTools::XMLElement( _T( "w:tblGrid" ) ); - //Если _grid состоит из одних ASCDocFormatUtils::gc_nZeroWidth и layout != "fixed", значит это doc полученный нами при конвертации из html. Таблицу размеров писать не нужно + //Если _grid состоит из одних DocFormatUtils::gc_nZeroWidth и layout != "fixed", значит это doc полученный нами при конвертации из html. Таблицу размеров писать не нужно bool bWriteGridCol = false; if(true == bLayoutFixed) bWriteGridCol = true; @@ -483,7 +483,7 @@ namespace DocFileFormat { for ( unsigned int i = 0, nSize = _grid->size(); i < nSize; i++ ) { - if(_grid->at(i) % ASCDocFormatUtils::gc_nZeroWidth != 0) + if(_grid->at(i) % DocFormatUtils::gc_nZeroWidth != 0) { bWriteGridCol = true; break; diff --git a/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.h b/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.h index fb7c4967f4..4ba72b5003 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.h @@ -71,7 +71,7 @@ namespace DocFileFormat class TablePropertiesMapping: public PropertiesMapping, public IMapping { public: - TablePropertiesMapping( XmlUtils::CXmlWriter* writer, StyleSheet* styles, vector* grid, bool isTableStyleNeeded = true ); + TablePropertiesMapping( XmlUtils::CXmlWriter* writer, StyleSheet* styles, std::vector* grid, bool isTableStyleNeeded = true ); virtual ~TablePropertiesMapping(); void Apply( IVisitable* visited ); @@ -80,8 +80,10 @@ namespace DocFileFormat XMLTools::XMLElement* _tblPr; XMLTools::XMLElement* _tblGrid; XMLTools::XMLElement* _tblBorders; + StyleSheet* _styles; - vector* _grid; + std::vector* _grid; + BorderCode* brcLeft; BorderCode* brcTop; BorderCode* brcBottom; diff --git a/ASCOfficeDocFile/DocDocxConverter/TablePropertyExceptions.h b/ASCOfficeDocFile/DocDocxConverter/TablePropertyExceptions.h index c9e643daec..08e51082c5 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TablePropertyExceptions.h +++ b/ASCOfficeDocFile/DocDocxConverter/TablePropertyExceptions.h @@ -41,7 +41,8 @@ namespace DocFileFormat { public: /// Parses the bytes to retrieve a TAPX - TablePropertyExceptions(unsigned char* bytes, int size) : PropertyExceptions(bytes, size), m_bSkipShading97 (FALSE) + TablePropertyExceptions(unsigned char* bytes, int size, bool oldVersion) : + PropertyExceptions(bytes, size, oldVersion), m_bSkipShading97 (FALSE) { //not yet implemented } @@ -52,13 +53,14 @@ namespace DocFileFormat } /// Extracts the TAPX SPRMs out of a PAPX - TablePropertyExceptions (ParagraphPropertyExceptions* papx, POLE::Stream* dataStream) : PropertyExceptions() + TablePropertyExceptions (ParagraphPropertyExceptions* papx, POLE::Stream* dataStream, bool oldVersion) : + PropertyExceptions() { - VirtualStreamReader oBinReader(dataStream, 0); + VirtualStreamReader oBinReader(dataStream, 0, oldVersion); m_bSkipShading97 = FALSE; - for (list::iterator oSpmIter = papx->grpprl->begin(); oSpmIter != papx->grpprl->end(); ++oSpmIter) + for (std::list::iterator oSpmIter = papx->grpprl->begin(); oSpmIter != papx->grpprl->end(); ++oSpmIter) { if (oSpmIter->OpCode == sprmTDefTableShd || oSpmIter->OpCode == sprmTDefTableShd2nd || oSpmIter->OpCode == sprmTDefTableShd2nd || oSpmIter->OpCode == sprmTDefTableShd3rd) @@ -84,9 +86,9 @@ namespace DocFileFormat unsigned char* grpprlBytes = oBinReader.ReadBytes(grpprlSize, true); //parse the grpprl - PropertyExceptions externalPx(grpprlBytes, grpprlSize); + PropertyExceptions externalPx(grpprlBytes, grpprlSize, oldVersion); - for (list::iterator oIter = externalPx.grpprl->begin(); oIter != externalPx.grpprl->end(); ++oIter) + for (std::list::iterator oIter = externalPx.grpprl->begin(); oIter != externalPx.grpprl->end(); ++oIter) { if (oIter->Type == TAP) { diff --git a/ASCOfficeDocFile/DocDocxConverter/TableRowPropertiesMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/TableRowPropertiesMapping.cpp index 08c1e2c655..e8e170a474 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TableRowPropertiesMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/TableRowPropertiesMapping.cpp @@ -62,7 +62,7 @@ namespace DocFileFormat this->_trPr->AppendChild( del ); } - for ( list::iterator iter = tapx->grpprl->begin(); iter != tapx->grpprl->end(); iter++ ) + for ( std::list::iterator iter = tapx->grpprl->begin(); iter != tapx->grpprl->end(); iter++ ) { switch ( iter->OpCode ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/TextboxMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/TextboxMapping.cpp index 90078e89f1..44d0ace964 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TextboxMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/TextboxMapping.cpp @@ -33,6 +33,7 @@ #include "Converter.h" #include "TextboxMapping.h" +#include "TableMapping.h" namespace DocFileFormat { diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp index 02975da94d..a9045cae8f 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp @@ -135,8 +135,8 @@ namespace DocFileFormat if ((pict->shapeContainer || pict->blipStoreEntry) && pict->shapeContainer->Children.size() > 0) { - Shape* shape = static_cast(*(pict->shapeContainer->Children.begin())); - list options = pict->shapeContainer->ExtractOptions(); + Shape* shape = static_cast(*(pict->shapeContainer->Children.begin())); + std::list options = pict->shapeContainer->ExtractOptions(); //v:shapetype PictureFrameType type; @@ -148,9 +148,9 @@ namespace DocFileFormat //v:shape m_pXmlWriter->WriteNodeBegin( _T( "v:shape" ), true ); - m_pXmlWriter->WriteAttribute( _T( "type" ), ( wstring( _T( "#" ) ) + VMLShapeTypeMapping::GenerateTypeId( &type ) ).c_str() ); + m_pXmlWriter->WriteAttribute( _T( "type" ), ( std::wstring( _T( "#" ) ) + VMLShapeTypeMapping::GenerateTypeId( &type ) ).c_str() ); - wstring style; + std::wstring style; double xScaling = pict->mx / 1000.0; double yScaling = pict->my / 1000.0; @@ -158,10 +158,10 @@ namespace DocFileFormat TwipsValue width( ( pict->dxaGoal - ( pict->dxaCropLeft + pict->dxaCropRight ) ) * xScaling ); TwipsValue height( ( pict->dyaGoal - ( pict->dyaCropTop + pict->dyaCropBottom ) ) * yScaling ); - wstring widthString = FormatUtils::DoubleToWideString( width.ToPoints() ); - wstring heightString = FormatUtils::DoubleToWideString( height.ToPoints() ); + std::wstring widthString = FormatUtils::DoubleToWideString( width.ToPoints() ); + std::wstring heightString = FormatUtils::DoubleToWideString( height.ToPoints() ); - style = wstring( _T( "width:" ) ) + widthString + wstring( _T( "pt;" ) ) + wstring( _T( "height:" ) ) + heightString + wstring( _T( "pt;" ) ); + style = std::wstring( _T( "width:" ) ) + widthString + std::wstring( _T( "pt;" ) ) + std::wstring( _T( "height:" ) ) + heightString + std::wstring( _T( "pt;" ) ); m_pXmlWriter->WriteAttribute( _T( "style" ), style.c_str() ); @@ -203,25 +203,25 @@ namespace DocFileFormat case borderBottomColor: { RGBColor bottomColor( (int)iter->op, RedFirst ); - m_pXmlWriter->WriteAttribute( _T( "o:borderbottomcolor" ), ( wstring( _T( "#" ) ) + bottomColor.SixDigitHexCode ).c_str() ); + m_pXmlWriter->WriteAttribute( _T( "o:borderbottomcolor" ), ( std::wstring( _T( "#" ) ) + bottomColor.SixDigitHexCode ).c_str() ); } break; case borderLeftColor: { RGBColor leftColor( (int)iter->op, RedFirst ); - m_pXmlWriter->WriteAttribute( _T( "o:borderleftcolor" ), ( wstring( _T( "#" ) ) + leftColor.SixDigitHexCode ).c_str() ); + m_pXmlWriter->WriteAttribute( _T( "o:borderleftcolor" ), ( std::wstring( _T( "#" ) ) + leftColor.SixDigitHexCode ).c_str() ); } break; case borderRightColor: { RGBColor rightColor( (int)iter->op, RedFirst ); - m_pXmlWriter->WriteAttribute( _T( "o:borderrightcolor" ), ( wstring( _T( "#" ) ) + rightColor.SixDigitHexCode ).c_str() ); + m_pXmlWriter->WriteAttribute( _T( "o:borderrightcolor" ), ( std::wstring( _T( "#" ) ) + rightColor.SixDigitHexCode ).c_str() ); } break; case borderTopColor: { RGBColor topColor( (int)iter->op, RedFirst ); - m_pXmlWriter->WriteAttribute( _T( "o:bordertopcolor" ), ( wstring( _T( "#" ) ) + topColor.SixDigitHexCode ).c_str() ); + m_pXmlWriter->WriteAttribute( _T( "o:bordertopcolor" ), ( std::wstring( _T( "#" ) ) + topColor.SixDigitHexCode ).c_str() ); } break; //CROPPING @@ -229,28 +229,28 @@ namespace DocFileFormat { //cast to signed integer int cropBottom = (int)iter->op; - appendValueAttribute(m_imageData, _T( "cropbottom" ), ( FormatUtils::IntToWideString( cropBottom ) + wstring( _T( "f" ) ) ).c_str() ); + appendValueAttribute(m_imageData, _T( "cropbottom" ), ( FormatUtils::IntToWideString( cropBottom ) + std::wstring( _T( "f" ) ) ).c_str() ); } break; case cropFromLeft: { //cast to signed integer int cropLeft = (int)iter->op; - appendValueAttribute(m_imageData, _T( "cropleft" ), ( FormatUtils::IntToWideString( cropLeft ) + wstring( _T( "f" ) ) ).c_str()); + appendValueAttribute(m_imageData, _T( "cropleft" ), ( FormatUtils::IntToWideString( cropLeft ) + std::wstring( _T( "f" ) ) ).c_str()); } break; case cropFromRight: { //cast to signed integer int cropRight = (int)iter->op; - appendValueAttribute(m_imageData, _T( "cropright" ), ( FormatUtils::IntToWideString( cropRight ) + wstring( _T( "f" ) ) ).c_str()); + appendValueAttribute(m_imageData, _T( "cropright" ), ( FormatUtils::IntToWideString( cropRight ) + std::wstring( _T( "f" ) ) ).c_str()); } break; case cropFromTop: { //cast to signed integer int cropTop = (int)iter->op; - appendValueAttribute(m_imageData, _T( "croptop" ), ( FormatUtils::IntToWideString( cropTop ) + wstring( _T( "f" ) ) ).c_str()); + appendValueAttribute(m_imageData, _T( "croptop" ), ( FormatUtils::IntToWideString( cropTop ) + std::wstring( _T( "f" ) ) ).c_str()); } break; } @@ -261,7 +261,7 @@ namespace DocFileFormat if (CopyPicture(pict->blipStoreEntry)) { //v:imageData - appendValueAttribute(m_imageData, _T( "r:id" ), ( wstring( _T( "rId" ) ) + FormatUtils::IntToWideString(m_nImageId) ).c_str()); + appendValueAttribute(m_imageData, _T( "r:id" ), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString(m_nImageId) ).c_str()); appendValueAttribute(m_imageData, _T( "o:title" ) , _T( "" )); m_pXmlWriter->WriteString(m_imageData->GetXMLString().c_str()); } @@ -285,7 +285,7 @@ namespace DocFileFormat /// Writes a border element void VMLPictureMapping::writePictureBorder( const wchar_t* name, const BorderCode* brc ) { - m_pXmlWriter->WriteNodeBegin( ( wstring( _T( "w10:" ) ) + wstring( name ) ).c_str(), true ); + m_pXmlWriter->WriteNodeBegin( ( std::wstring( _T( "w10:" ) ) + std::wstring( name ) ).c_str(), true ); m_pXmlWriter->WriteAttribute( _T( "type" ), getBorderType( brc->brcType ).c_str() ); m_pXmlWriter->WriteAttribute( _T( "width" ), FormatUtils::IntToWideString( brc->dptLineWidth ).c_str() ); m_pXmlWriter->WriteNodeEnd ( _T( "" ), true ); @@ -329,7 +329,7 @@ namespace DocFileFormat if (bitBlip) { m_ctx->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlipEntry->btWin32), - vector(bitBlip->m_pvBits, (bitBlip->m_pvBits + bitBlip->pvBitsSize)), oBlipEntry->btWin32)); + std::vector(bitBlip->m_pvBits, (bitBlip->m_pvBits + bitBlip->pvBitsSize)), oBlipEntry->btWin32)); } } break; diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.h b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.h index e72b53f867..431a640638 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.h @@ -57,7 +57,7 @@ namespace DocFileFormat private: /// Writes a border element void writePictureBorder (const wchar_t* name, const BorderCode* brc); - void appendStyleProperty( wstring* b, const wstring& propName, const wstring& propValue ) const; + void appendStyleProperty( std::wstring* b, const std::wstring& propName, const std::wstring& propValue ) const; protected: /// Copies the picture from the binary stream to the zip archive diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp index 0f352ff616..9d075f5deb 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp @@ -277,10 +277,6 @@ namespace DocFileFormat std::list::const_iterator end = options.end(); for (std::list::const_iterator iter = options.begin(); iter != end; ++iter) { - //mso-position-horizontal:absolute - //mso-position-horizontal-relative:margin - //mso-position-vertical:absolute - //mso-position-vertical-relative:margin switch (iter->pid) { //BOOLEANS @@ -438,7 +434,7 @@ namespace DocFileFormat case lineColor: { RGBColor lineColor((int)iter->op, RedFirst); - m_pXmlWriter->WriteAttribute( _T("strokecolor"), (wstring(_T("#")) + lineColor.SixDigitHexCode).c_str()); + m_pXmlWriter->WriteAttribute( _T("strokecolor"), (std::wstring(_T("#")) + lineColor.SixDigitHexCode).c_str()); } break; @@ -663,7 +659,7 @@ namespace DocFileFormat case pibName: { std::wstring name; - FormatUtils::GetSTLCollectionFromBytes(&name, iter->opComplex, iter->op, ENCODING_UNICODE); + FormatUtils::GetSTLCollectionFromBytes(&name, iter->opComplex, iter->op, ENCODING_UTF16); appendValueAttribute(&m_imagedata, _T( "o:title" ), FormatUtils::XmlEncode(name).c_str()); } break; @@ -879,7 +875,7 @@ namespace DocFileFormat m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE ); //build shadow offsets - wstring offset; + std::wstring offset; if ( ShadowOffsetX != 0 ) { @@ -899,7 +895,7 @@ namespace DocFileFormat appendValueAttribute(&m_shadow, _T( "offset" ), offset.c_str()); } - wstring offset2; + std::wstring offset2; if ( SecondShadowOffsetX != 0 ) { @@ -945,7 +941,7 @@ namespace DocFileFormat //write the viewpoint if ( ( ViewPointX != 0 ) || ( ViewPointY != 0 ) || ( ViewPointZ != 0 ) ) { - wstring viewPoint; + std::wstring viewPoint; if ( ViewPointX != 0 ) { @@ -1259,7 +1255,7 @@ namespace DocFileFormat //write the blip if (oBlip) { - VirtualStreamReader reader(m_ctx->_doc->WordDocumentStream, oBlip->foDelay); + VirtualStreamReader reader(m_ctx->_doc->WordDocumentStream, oBlip->foDelay, m_ctx->_doc->FIB->m_bOlderVersion); switch (oBlip->btWin32) { @@ -1277,7 +1273,7 @@ namespace DocFileFormat decompressedSize = metaBlip->Decompress(&decompressed); if (0 != decompressedSize && NULL != decompressed) { - m_ctx->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlip->btWin32), vector(decompressed, (decompressed + decompressedSize)))); + m_ctx->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlip->btWin32), std::vector(decompressed, (decompressed + decompressedSize)))); RELEASEARRAYOBJECTS(decompressed); } @@ -1297,7 +1293,7 @@ namespace DocFileFormat if ((bitBlip) && (bitBlip->m_pvBits)) { m_ctx->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlip->btWin32), - vector(bitBlip->m_pvBits, (bitBlip->m_pvBits + bitBlip->pvBitsSize)), oBlip->btWin32)); + std::vector(bitBlip->m_pvBits, (bitBlip->m_pvBits + bitBlip->pvBitsSize)), oBlip->btWin32)); RELEASEOBJECT (bitBlip); } } @@ -1372,8 +1368,8 @@ namespace DocFileFormat height = TwipsValue( ( pict->dxaGoal - ( pict->dxaCropLeft + pict->dxaCropRight ) ) * xScaling ); } - wstring widthString = FormatUtils::DoubleToWideString( width.ToPoints() ); - wstring heightString = FormatUtils::DoubleToWideString( height.ToPoints() ); + std::wstring widthString = FormatUtils::DoubleToWideString( width.ToPoints() ); + std::wstring heightString = FormatUtils::DoubleToWideString( height.ToPoints() ); style->operator += ( std::wstring( _T( "width:" ) ) + widthString + std::wstring( _T( "pt;" ) ) ); style->operator += ( std::wstring( _T( "height:" ) ) + heightString + std::wstring( _T( "pt;" ) ) ); @@ -1423,7 +1419,7 @@ namespace DocFileFormat { if ((style != NULL) && (anchor != NULL)) { - ASCDocFormatUtils::Rectangle bounds = anchor->rcgBounds; + DocFormatUtils::Rectangle bounds = anchor->rcgBounds; if (twistDimensions) { diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h index c68a130dab..e06090aedc 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h @@ -70,51 +70,49 @@ namespace DocFileFormat // Converts a single shape void WriteShape (const ShapeContainer* pContainer); -// Generates a string id for the given shape + /// Generates a string id for the given shape std::wstring GenShapeId(const Shape* pShape) const; -// Build the VML wrapcoords string for a given pWrapPolygonVertices + /// Build the VML wrapcoords string for a given pWrapPolygonVertices std::wstring getWrapCoords( const OptionEntry& pWrapPolygonVertices ) const; -// Copies the picture from the binary stream to the zip archive -// and creates the relationships for the image. + /// Copies the picture from the binary stream to the zip archive + /// and creates the relationships for the image. bool copyPicture( const BlipStoreEntry* bse ); std::wstring GetTargetExt( Global::BlipType _type ) const; - void AppendDimensionToStyle( wstring* style, const PictureDescriptor* pict, bool twistDimensions ) const; - void AppendDimensionToStyle( wstring* style, const Spa* pSpa, bool twistDimensions ) const; - void AppendDimensionToStyle( wstring* style, const ChildAnchor* anchor, bool twistDimensions ) const; + void AppendDimensionToStyle ( std::wstring* style, const PictureDescriptor* pict, bool twistDimensions ) const; + void AppendDimensionToStyle ( std::wstring* style, const Spa* pSpa, bool twistDimensions ) const; + void AppendDimensionToStyle ( std::wstring* style, const ChildAnchor* anchor, bool twistDimensions ) const; + void appendStyleProperty ( std::wstring* b, const std::wstring& propName, const std::wstring& propValue ) const; - void appendStyleProperty( wstring* b, const wstring& propName, const wstring& propValue ) const; + std::wstring getTextboxAnchor( unsigned int anchor ) const; - std::wstring getTextboxAnchor ( unsigned int anchor ) const; - std::wstring mapVerticalPosition ( PositionVertical vPos ) const; - std::wstring mapVerticalPositionRelative ( int vRel ) const; - std::wstring mapHorizontalPosition ( PositionHorizontal hPos ) const; - std::wstring mapHorizontalPositionRelative ( int hRel ) const; + std::wstring mapVerticalPosition ( PositionVertical vPos ) const; + std::wstring mapVerticalPositionRelative( int vRel ) const; + std::wstring mapHorizontalPosition ( PositionHorizontal hPos ) const; + std::wstring mapHorizontalPositionRelative( int hRel ) const; - void AppendOptionsToStyle ( wstring* style, const list& options) const; + void AppendOptionsToStyle( std::wstring* style, const std::list& options ) const; - std::wstring buildStyle ( const Shape* shape, const ChildAnchor* anchor, const list& options, int zIndex ) const; - - std::wstring getLineStyle ( unsigned int p ) const; - std::wstring getArrowStyle ( unsigned int op ) const; - std::wstring getArrowLength ( unsigned int op ) const; - std::wstring getArrowWidth ( unsigned int op ) const; - std::wstring getFillMethod ( unsigned int p ) const; - std::wstring getFillColorString ( const unsigned char* p, unsigned int size ) const; - -// Returns the OpenXML fill type of a fill effect - std::wstring getFillType( unsigned int p ) const; - std::wstring getShadowType( unsigned int p ) const; -// Returns the OpenXML wrap type of the shape - std::wstring getWrapType(const Spa* pSpa) const; - std::wstring ParsePath (const list& options) const; + std::wstring buildStyle ( const Shape* shape, const ChildAnchor* anchor, const std::list& options, int zIndex ) const; + std::wstring getLineStyle ( unsigned int p ) const; + std::wstring getArrowStyle ( unsigned int op ) const; + std::wstring getArrowLength ( unsigned int op ) const; + std::wstring getArrowWidth ( unsigned int op ) const; + std::wstring getFillMethod ( unsigned int p ) const; + std::wstring getFillColorString( const unsigned char* p, unsigned int size ) const; + /// Returns the OpenXML fill type of a fill effect + std::wstring getFillType ( unsigned int p ) const; + std::wstring getShadowType ( unsigned int p ) const; + /// Returns the OpenXML wrap type of the shape + std::wstring getWrapType (const Spa* pSpa) const; + std::wstring ParsePath (const std::list& options) const; - void WriteBeginShapeNode (const Shape* pShape); - void WriteEndShapeNode (const Shape* pShape); - std::wstring GetShapeID (const Shape* pShape) const; + void WriteBeginShapeNode (const Shape* pShape); + void WriteEndShapeNode (const Shape* pShape); + std::wstring GetShapeID (const Shape* pShape) const; - std::wstring GetLineFrom (const ChildAnchor* pAnchor) const; - std::wstring GetLineTo (const ChildAnchor* pAnchor) const; + std::wstring GetLineFrom (const ChildAnchor* pAnchor) const; + std::wstring GetLineTo (const ChildAnchor* pAnchor) const; std::vector GetTextRectangles(const OptionEntry& inscribe) const; diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLShapeTypeMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/VMLShapeTypeMapping.cpp index 3582f26f88..de91eb551b 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLShapeTypeMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/VMLShapeTypeMapping.cpp @@ -111,7 +111,7 @@ namespace DocFileFormat { m_pXmlWriter->WriteNodeBegin( _T( "v:formulas" ) ); - for ( list::iterator iter = pShape->Formulas.begin(); iter != pShape->Formulas.end(); iter++ ) + for ( std::list::iterator iter = pShape->Formulas.begin(); iter != pShape->Formulas.end(); iter++ ) { m_pXmlWriter->WriteNodeBegin( _T( "v:f" ), true ); m_pXmlWriter->WriteAttribute( _T( "eqn" ), iter->c_str() ); @@ -179,7 +179,7 @@ namespace DocFileFormat { m_pXmlWriter->WriteNodeBegin( _T( "v:handles" ) ); - for ( list::iterator iter = pShape->Handles.begin(); iter != pShape->Handles.end(); ++iter) + for ( std::list::iterator iter = pShape->Handles.begin(); iter != pShape->Handles.end(); ++iter) { m_pXmlWriter->WriteNodeBegin( _T( "v:h" ), true ); @@ -213,9 +213,9 @@ namespace DocFileFormat std::wstring VMLShapeTypeMapping::GenerateTypeId (const ShapeType* pShape) { - wstring type; + std::wstring type; - type += wstring( _T( "_x0000_t" ) ); + type += std::wstring( _T( "_x0000_t" ) ); type += FormatUtils::IntToWideString(pShape->GetTypeCode() ); return type; diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLShapeTypeMapping.h b/ASCOfficeDocFile/DocDocxConverter/VMLShapeTypeMapping.h index c9abfedfce..128d796ada 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLShapeTypeMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/VMLShapeTypeMapping.h @@ -48,6 +48,6 @@ namespace DocFileFormat virtual ~VMLShapeTypeMapping(); virtual void Apply( IVisitable* visited ); /// Returns the id of the referenced type - static wstring GenerateTypeId (const ShapeType* pShape); + static std::wstring GenerateTypeId (const ShapeType* pShape); }; } diff --git a/ASCOfficeDocFile/DocDocxConverter/VirtualStreamReader.h b/ASCOfficeDocFile/DocDocxConverter/VirtualStreamReader.h index 9682957706..e0834805bc 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VirtualStreamReader.h +++ b/ASCOfficeDocFile/DocDocxConverter/VirtualStreamReader.h @@ -33,21 +33,18 @@ #include "IBinaryReader.h" #include "../Common/FormatUtils.h" - #include "../../Common/3dParty/pole/pole.h" +#include "../../Common/DocxFormat/Source/Base/Types_32.h" class VirtualStreamReader : public IBinaryReader { public: - VirtualStreamReader (POLE::Stream* _stream, ULONG _position = 0) : stream(NULL), position(0) + VirtualStreamReader (POLE::Stream* _stream, ULONG _position , bool _olderVersion) : + olderVersion(_olderVersion), stream(_stream), position(_position) { - stream = _stream; - position = _position; + if ( stream == NULL )return; - if ( stream != NULL ) - { - stream->seek(position); - } + stream->seek(position); } virtual ~VirtualStreamReader() @@ -62,9 +59,8 @@ public: { stream->seek( position ); stream->read((unsigned char*)(&rdUShort), sizeof( rdUShort )); - - position += sizeof( rdUShort ); } + position += sizeof( rdUShort ); return rdUShort; } @@ -78,38 +74,38 @@ public: stream->seek( position ); stream->read((unsigned char*)(&rdShort), sizeof( rdShort )); - position += sizeof( rdShort ); } + position += sizeof( rdShort ); return rdShort; } virtual int ReadInt32() { - int rdInt = 0; + _INT32 rdInt = 0; if (( stream != NULL ) && (position + 4 < stream->size())) { stream->seek( position ); stream->read( (unsigned char*) &rdInt, sizeof( rdInt ) ); - position += sizeof( rdInt ); } + position += sizeof( rdInt ); return rdInt; } virtual unsigned int ReadUInt32() { - int rdUInt = 0; + _UINT32 rdUInt = 0; if (( stream != NULL ) && (position + 4 < stream->size())) { stream->seek( position ); stream->read((unsigned char*) &rdUInt, sizeof( rdUInt ) ); - position += sizeof( rdUInt ); } + position += sizeof( rdUInt ); return rdUInt; } @@ -123,8 +119,8 @@ public: stream->seek( position); stream->read( (unsigned char*)&rdByte, sizeof( rdByte ) ); - position += sizeof( rdByte ); } + position += sizeof( rdByte ); return rdByte; } @@ -133,8 +129,7 @@ public: { unsigned char *rdBytes = NULL; - - if ( ( stream != NULL ) && ( count > 0 ) && isResultNeeded ) + if ( count > 0 && isResultNeeded) { if (position + count > stream->size()) { @@ -142,19 +137,15 @@ public: else count = stream->size() - position; } rdBytes = new unsigned char[count]; - - if ( rdBytes != NULL ) - { - stream->seek( position ); - stream->read( rdBytes, sizeof( unsigned char )*count ); - - position += sizeof( unsigned char )*count; - } } - else + + if ( stream != NULL && rdBytes != NULL ) { - position += sizeof( unsigned char )*count; + stream->seek( position ); + stream->read( rdBytes, sizeof( unsigned char )*count ); } + + position += sizeof( unsigned char )*count; return rdBytes; } @@ -205,7 +196,14 @@ public: int xstzSize = FormatUtils::BytesToInt16( cch, 0, cchSize ) * 2; unsigned char* xstz = ReadBytes(xstzSize, true); - FormatUtils::GetSTLCollectionFromBytes( &wstrResult, xstz, xstzSize, ENCODING_UNICODE ); + if (this->olderVersion) + { + FormatUtils::GetSTLCollectionFromBytes( &wstrResult, xstz, xstzSize, ENCODING_WINDOWS_1250 ); + } + else + { + FormatUtils::GetSTLCollectionFromBytes( &wstrResult, xstz, xstzSize, ENCODING_UTF16 ); + } RELEASEARRAYOBJECTS(xstz); RELEASEARRAYOBJECTS(cch); @@ -220,7 +218,7 @@ public: /// unsigned char 5 - (cch*2)+4: Unicode characters terminated by \0 std::wstring ReadLengthPrefixedUnicodeString() { - wstring result; + std::wstring result; int cch = ReadInt32(); @@ -229,7 +227,7 @@ public: //dont read the terminating zero unsigned char* stringBytes = ReadBytes( ( cch * 2 ), true ); - FormatUtils::GetSTLCollectionFromBytes( &result, stringBytes, ( ( cch * 2 ) - 2 ), ENCODING_UNICODE ); + FormatUtils::GetSTLCollectionFromBytes( &result, stringBytes, ( ( cch * 2 ) - 2 ), ENCODING_UTF16 ); RELEASEARRAYOBJECTS( stringBytes ); } @@ -243,7 +241,7 @@ public: /// unsigned char 5-cch+4: ANSI characters terminated by \0 std::wstring ReadLengthPrefixedAnsiString() { - wstring result; + std::wstring result; int cch = this->ReadInt32(); @@ -252,17 +250,16 @@ public: //dont read the terminating zero unsigned char* stringBytes = ReadBytes( cch, true ); - FormatUtils::GetSTLCollectionFromBytes( &result, stringBytes, ( cch - 1 ), ENCODING_WINDOWS_1251 ); + FormatUtils::GetSTLCollectionFromBytes( &result, stringBytes, ( cch - 1 ), ENCODING_WINDOWS_1250); RELEASEARRAYOBJECTS( stringBytes ); } return result; } - + bool olderVersion; private: - POLE::uint64 position; - //std::streampos position; - POLE::Stream* stream; + POLE::uint64 position; + POLE::Stream* stream; }; diff --git a/ASCOfficeDocFile/DocDocxConverter/WideString.h b/ASCOfficeDocFile/DocDocxConverter/WideString.h index 44e0a1909f..75dece4481 100644 --- a/ASCOfficeDocFile/DocDocxConverter/WideString.h +++ b/ASCOfficeDocFile/DocDocxConverter/WideString.h @@ -36,14 +36,14 @@ namespace DocFileFormat { - class WideString: public wstring, public ByteStructure + class WideString: public std::wstring, public ByteStructure { public: - WideString( VirtualStreamReader reader, int length ): wstring() + WideString( VirtualStreamReader reader, int length ): std::wstring() { } - WideString(): wstring() + WideString(): std::wstring() { } @@ -59,8 +59,14 @@ namespace DocFileFormat bytes = reader->ReadBytes( length, true ); //It's a real string table - FormatUtils::GetSTLCollectionFromBytes( newObject, bytes, length, ENCODING_UNICODE ); - + if (reader->olderVersion) + { + FormatUtils::GetSTLCollectionFromBytes( newObject, bytes, length, ENCODING_WINDOWS_1250 ); + } + else + { + FormatUtils::GetSTLCollectionFromBytes( newObject, bytes, length, ENCODING_UTF16 ); + } RELEASEARRAYOBJECTS( bytes ); return static_cast( newObject ); diff --git a/ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp b/ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp index 3b5fa42187..d7dd81a4c8 100644 --- a/ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp @@ -33,10 +33,16 @@ #include "WordDocument.h" #include "../../../Common/OfficeFileErrorDescription.h" +#include "../../../ASCOfficeXlsFile2/source/XlsFormat/Logic/SummaryInformationStream/SummaryInformation.h" +#include "../../../ASCOfficeXlsFile2/source/XlsFormat/Binary/CFStream.h" + +#include "../../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h" +#include "../../../DesktopEditor/common/File.h" + namespace DocFileFormat { - WordDocument::WordDocument (CString sFileName) : m_sFileName (sFileName), m_PieceTable(NULL), - WordDocumentStream(NULL), TableStream(NULL), DataStream(NULL), FIB(NULL), + WordDocument::WordDocument (const ProgressCallback* pCallFunc, const std::wstring & sTempFolder ) : + m_PieceTable(NULL), WordDocumentStream(NULL), TableStream(NULL), DataStream(NULL), FIB(NULL), Text(NULL), RevisionAuthorTable(NULL), FontTable(NULL), BookmarkNames(NULL), AutoTextNames(NULL), IndividualFootnotesPlex(NULL), FootnoteReferenceCharactersPlex(NULL), IndividualEndnotesPlex(NULL), EndnoteReferenceCharactersPlex(NULL), FieldsPlex(NULL), FootnoteDocumentFieldsPlex(NULL), @@ -44,39 +50,485 @@ namespace DocFileFormat AnnotationsReferencePlex(NULL), IndividualCommentsPlex(NULL), TextboxBreakPlex(NULL), TextboxBreakPlexHeader(NULL), OfficeDrawingPlex(NULL), OfficeDrawingPlexHeader(NULL), SectionPlex(NULL), BookmarkStartPlex(NULL), BookmarkEndPlex(NULL), AutoTextPlex(NULL), AllPapxFkps(NULL), AllChpxFkps(NULL), AllPapx(NULL), AllPapxVector(NULL), AllSepx(NULL), Styles(NULL), listTable(NULL), - AnnotationOwners(NULL), DocProperties(NULL), listFormatOverrideTable(NULL), headerAndFooterTable(NULL) + AnnotationOwners(NULL), DocProperties(NULL), listFormatOverrideTable(NULL), headerAndFooterTable(NULL), encryptionHeader(NULL) { - m_pCallFunc = NULL; - + m_pCallFunc = pCallFunc; + m_sTempFolder = sTempFolder; + m_pStorage = NULL; - m_pOfficeArtContent = NULL; - - fibFC = 0; + officeArtContent = NULL; + bOlderVersion = false; } WordDocument::~WordDocument() { - Clear(); + Clear(); + + if (!m_sTempDecryptFileName.empty()) + { + NSFile::CFileBinary::Remove(m_sTempDecryptFileName); + } } } namespace DocFileFormat { - long WordDocument::LoadDocument(const ProgressCallback* pCallFunc) + long WordDocument::LoadDocument(const std::wstring & fileName, const std::wstring & password) { - HRESULT hr = S_FALSE; + m_sFileName = fileName; + m_sPassword = password; - m_pCallFunc = pCallFunc; - hr = Parse (fibFC); + m_pStorage = new StructuredStorageReader(); - return hr; + if (!m_pStorage) + { + Clear(); + return AVS_ERROR_FILEFORMAT; + } + + if (m_pStorage->SetFile (m_sFileName.c_str()) == false) + { + Clear(); + return AVS_ERROR_FILEFORMAT; + } +//----------------------------------------------------------------------------------------------------------------- + if (m_pStorage->GetStream ("WordDocument", &WordDocumentStream) == false) + { + Clear(); + return AVS_ERROR_FILEFORMAT; + } +//------------------------------------------------------------------------------------------------------------------- + FIB = new FileInformationBlock(VirtualStreamReader(WordDocumentStream,0, false )); + + if (FIB->m_FibBase.nFib) + { + if (FIB->m_FibBase.nFib < Fib1997) + { + bOlderVersion = FIB->m_bOlderVersion = true; + } + } + else + { + if (FIB->m_FibNew.nFibNew < Fib1997 && FIB->m_FibNew.nFibNew > 0) + { + bOlderVersion = FIB->m_bOlderVersion = true; + } + } + bool res = false; + + if (FIB->m_FibBase.fWhichTblStm) + { + if (!m_pStorage->GetStream ("1Table", &TableStream)) + { + res = m_pStorage->GetStream ("0Table", &TableStream); + } + } + else + { + if (!m_pStorage->GetStream ("0Table", &TableStream)) + { + res = m_pStorage->GetStream ("1Table", &TableStream); + } + } + + if (FIB->m_FibBase.fEncrypted && !FIB->m_bOlderVersion) + { + encryptionHeader = new EncryptionHeader (FIB, TableStream); + + FIB->m_Decryptor = CRYPT::DecryptorPtr(new CRYPT::Decryptor(encryptionHeader->crypt_data, m_sPassword, 1)); + + if (FIB->m_Decryptor->IsVerify() == false) + { + Clear(); + + if (m_sPassword.empty() ) return AVS_ERROR_DRM; + else return AVS_ERROR_PASSWORD; + } + + if (DecryptFile() == false) return AVS_ERROR_DRM; + + FIB->reset(VirtualStreamReader(WordDocumentStream, 68, false)); + } + else if (FIB->m_FibBase.fEncrypted) return AVS_ERROR_DRM; + +//------------------------------------------------------------------------------------------------------------------ + POLE::Stream * Summary = NULL; + POLE::Stream * DocSummary = NULL; + + m_pStorage->GetStream ("SummaryInformation", &Summary); + m_pStorage->GetStream ("DocumentSummaryInformation", &DocSummary); + + document_code_page = ENCODING_WINDOWS_1250; + + if ((Summary) && (Summary->size() > 0)) + { + XLS::CFStreamPtr stream = XLS::CFStreamPtr(new XLS::CFStream(Summary)); + OLEPS::SummaryInformation summary_info(stream); + int document_code_page1 = summary_info.GetCodePage(); //from software last open + + if (document_code_page1 > 0) + document_code_page = document_code_page1; + } + if ((DocSummary) && (DocSummary->size() > 0)) + { + XLS::CFStreamPtr stream = XLS::CFStreamPtr(new XLS::CFStream(DocSummary)); + OLEPS::SummaryInformation doc_summary_info(stream); + int document_code_page2 = doc_summary_info.GetCodePage(); + + if (document_code_page2 > 0) + document_code_page = document_code_page2; + } + if (!FIB->m_bOlderVersion) + document_code_page = ENCODING_UTF16; + + FIB->m_CodePage = document_code_page; +//------------------------------------------------------------------------------------------------- + try + { + m_pStorage->GetStream ("Data", &DataStream); + } + catch (...) + { + DataStream = NULL; + } + + if (TableStream->size() < 1 && FIB->m_bOlderVersion) + { + RELEASEOBJECT(TableStream); + m_pStorage->GetStream ("WordDocument", &TableStream); + } + + RevisionAuthorTable = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfRMark, FIB->m_FibWord97.lcbSttbfRMark, FIB->m_bOlderVersion); + FontTable = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfFfn, FIB->m_FibWord97.lcbSttbfFfn, FIB->m_bOlderVersion); + BookmarkNames = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfBkmk, FIB->m_FibWord97.lcbSttbfBkmk, FIB->m_bOlderVersion); + AutoTextNames = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfGlsy, FIB->m_FibWord97.lcbSttbfGlsy, FIB->m_bOlderVersion); + + if (m_pCallFunc) + { + m_pCallFunc->OnProgress (m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 100000); + + SHORT bCancel = 0; + m_pCallFunc->OnProgressEx(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 100000, &bCancel); + + if (bCancel) + { + Clear(); + return AVS_ERROR_FILEFORMAT; + } + } + + // Read all needed PLCFs + if (FIB->m_RgLw97.ccpFtn > 0) + { + IndividualFootnotesPlex = new Plex(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndTxt, FIB->m_FibWord97.lcbPlcffndTxt, FIB->m_bOlderVersion); + FootnoteReferenceCharactersPlex = new Plex(FootnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndRef, FIB->m_FibWord97.lcbPlcffndRef, FIB->m_bOlderVersion); + } + + if (FIB->m_RgLw97.ccpEdn > 0) + { + IndividualEndnotesPlex = new Plex(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendTxt, FIB->m_FibWord97.lcbPlcfendTxt, FIB->m_bOlderVersion); + EndnoteReferenceCharactersPlex = new Plex(EndnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendRef, FIB->m_FibWord97.lcbPlcfendRef, FIB->m_bOlderVersion); + } + + if (FIB->m_RgLw97.ccpHdr > 0) + { + HeaderStoriesPlex = new Plex( EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfHdd, FIB->m_FibWord97.lcbPlcfHdd, FIB->m_bOlderVersion); + } + + if (FIB->m_RgLw97.ccpAtn > 0) + { + IndividualCommentsPlex = new Plex(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfandTxt, FIB->m_FibWord97.lcbPlcfandTxt, FIB->m_bOlderVersion); + AnnotationsReferencePlex = new Plex(AnnotationReferenceDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfandRef, FIB->m_FibWord97.lcbPlcfandRef, FIB->m_bOlderVersion); + } + OfficeDrawingPlex = new Plex (Spa::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcSpaMom, FIB->m_FibWord97.lcbPlcSpaMom, FIB->m_bOlderVersion); + OfficeDrawingPlexHeader = new Plex (Spa::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcSpaHdr, FIB->m_FibWord97.lcbPlcSpaHdr, FIB->m_bOlderVersion); + SectionPlex = new Plex (SectionDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfSed, FIB->m_FibWord97.lcbPlcfSed, FIB->m_bOlderVersion); + BookmarkStartPlex = new Plex (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkf, FIB->m_FibWord97.lcbPlcfBkf, FIB->m_bOlderVersion); + BookmarkEndPlex = new Plex (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkl, FIB->m_FibWord97.lcbPlcfBkl, FIB->m_bOlderVersion); + + TextboxBreakPlex = new Plex (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxBkd, FIB->m_FibWord97.lcbPlcfTxbxBkd, FIB->m_bOlderVersion); + TextboxBreakPlexHeader = new Plex (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxHdrBkd, FIB->m_FibWord97.lcbPlcfTxbxHdrBkd, FIB->m_bOlderVersion); + + for (size_t i = 0; i < BookmarkStartPlex->Elements.size(); ++i) + { + BookmarkFirst* pBookmark = static_cast(BookmarkStartPlex->Elements[i]); + if (pBookmark) + { + BookmarkStartEndCPs.push_back(std::make_pair(BookmarkStartPlex->CharacterPositions[i], BookmarkEndPlex->CharacterPositions[pBookmark->GetIndex()])); + } + } + + AutoTextPlex = new Plex (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfGlsy, FIB->m_FibWord97.lcbPlcfGlsy, FIB->m_bOlderVersion); + FieldsPlex = new Plex (FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldMom, FIB->m_FibWord97.lcbPlcfFldMom, FIB->m_bOlderVersion); + FootnoteDocumentFieldsPlex = new Plex (FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldFtn, FIB->m_FibWord97.lcbPlcfFldFtn, FIB->m_bOlderVersion); + EndnoteDocumentFieldsPlex = new Plex (FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldEdn, FIB->m_FibWord97.lcbPlcfFldEdn, FIB->m_bOlderVersion); + HeadersAndFootersDocumentFieldsPlex = new Plex (FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldHdr, FIB->m_FibWord97.lcbPlcfFldHdr, FIB->m_bOlderVersion); + + if (m_pCallFunc) + { + m_pCallFunc->OnProgress(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 200000 ); + + SHORT bCancel = 0; + m_pCallFunc->OnProgressEx(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 200000, &bCancel); + + if (bCancel) + { + Clear(); + return AVS_ERROR_FILEFORMAT; + } + } + +// Read the FKPs + AllPapxFkps = FormattedDiskPagePAPX::GetAllPAPXFKPs (FIB, WordDocumentStream, TableStream, DataStream); + AllChpxFkps = FormattedDiskPageCHPX::GetAllCHPXFKPs (FIB, WordDocumentStream, TableStream); + +// Read custom tables + if (TableStream) + { + DocProperties = new WordDocumentProperties (FIB, TableStream); + Styles = new StyleSheet (FIB, TableStream, DataStream); + listTable = new ListTable (FIB, TableStream); + listFormatOverrideTable = new ListFormatOverrideTable (FIB, TableStream); + officeArtContent = new OfficeArtContent (FIB, TableStream); + headerAndFooterTable = new HeaderAndFooterTable (FIB, TableStream); + AnnotationOwners = new AnnotationOwnerList (FIB, TableStream); + } + + if (m_pCallFunc) + { + m_pCallFunc->OnProgress(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 300000 ); + + SHORT bCancel = 0; + m_pCallFunc->OnProgressEx(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 300000, &bCancel); + + if (bCancel) + { + Clear(); + return AVS_ERROR_FILEFORMAT; + } + } + + if (FIB->m_FibWord97.lcbClx > 0) + { + FIB->m_FibBase.fComplex = true; + // Parse the piece table and construct a list that contains all chars + m_PieceTable = new PieceTable (FIB, TableStream, WordDocumentStream ); + Text = m_PieceTable->GetAllEncodingText (WordDocumentStream); + } + else + { + int cb = FIB->m_FibBase.fcMac - FIB->m_FibBase.fcMin; + + unsigned char *bytes = new unsigned char[cb]; + + WordDocumentStream->seek (FIB->m_FibBase.fcMin); + WordDocumentStream->read (bytes, cb); + + Text = new std::vector(); + FormatUtils::GetSTLCollectionFromBytes >(Text, bytes, cb, document_code_page); + + RELEASEARRAYOBJECTS(bytes); + } + + if (BookmarkNames) + { + for (unsigned int i = 0; i < BookmarkStartEndCPs.size(); ++i) + { + WideString* bookmarkName = static_cast(BookmarkNames->operator[]( i )); + + if ( ( bookmarkName != NULL ) && ( *bookmarkName == _T( "_PictureBullets" ) ) ) + { + for (unsigned int j = BookmarkStartEndCPs[i].first, k = 0; j < this->Text->size(); ++j, ++k ) + { + if ( this->Text->at( j ) == 1 ) + { + PictureBulletsCPsMap.insert (std::make_pair( k, j )); + } + } + } + } + } + + // Build a dictionaries of all PAPX + AllPapx = new std::map(); + AllPapxVector = new std::vector(); + + for (std::list::iterator iter = AllPapxFkps->begin(); iter != AllPapxFkps->end(); ++iter) + { + for (unsigned int j = 0; j < (*iter)->grppapxSize; ++j) + { + int nVal = (*iter)->rgfc[j]; + AllPapx->insert( std::pair( nVal, (*iter)->grppapx[j] ) ); + AllPapxVector->push_back(nVal); + } + } + + std::sort (AllPapxVector->begin(), AllPapxVector->end()); + + if (m_pCallFunc) + { + m_pCallFunc->OnProgress(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 400000 ); + + SHORT bCancel = 0; + m_pCallFunc->OnProgressEx(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 400000, &bCancel); + + if (bCancel) + { + Clear(); + return AVS_ERROR_FILEFORMAT; + } + } + + //build a dictionary of all SEPX + if ( !SectionPlex->Elements.empty() ) + { + AllSepx = new std::map(); + + for (unsigned int i = 0; i < SectionPlex->Elements.size(); ++i) + { + //Read the SED + SectionDescriptor* sed = static_cast(SectionPlex->Elements.at(i)); + int cp = SectionPlex->CharacterPositions[i + 1]; + + //Get the SEPX + VirtualStreamReader wordReader( this->WordDocumentStream, sed->fcSepx, FIB->m_bOlderVersion); + + //!!!TODO: cbSepx is the size in bytes of the rest properties part!!! + short cbSepx = wordReader.ReadInt16(); + unsigned char* bytes = wordReader.ReadBytes( ( cbSepx /*- 2*/ ), true ); + + AllSepx->insert( std::pair( cp, new SectionPropertyExceptions( bytes, ( cbSepx /*- 2*/ ), FIB->m_bOlderVersion ) ) ); + + RELEASEARRAYOBJECTS( bytes ); + } + } + + if (m_pCallFunc) + { + m_pCallFunc->OnProgress(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 500000 ); + + SHORT bCancel = 0; + m_pCallFunc->OnProgressEx(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 500000, &bCancel); + + if (bCancel) + { + Clear(); + return AVS_ERROR_FILEFORMAT; + } + } + + return 0; } + bool WordDocument::DecryptFile() + { + if (m_sTempFolder.empty()) + { + m_sTempFolder = FileSystem::Directory::GetTempPathW().GetBuffer(); + } + m_sTempDecryptFileName = m_sTempFolder + FILE_SEPARATOR_STR + L"~tempFile.doc"; + + POLE::Storage *storageIn = m_pStorage->GetStorage(); + POLE::Storage *storageOut = new POLE::Storage(m_sTempDecryptFileName.c_str()); + + if (!storageOut || !storageIn) return false; + + if (!storageOut->open(true, true)) + { + delete storageOut; + return false; + } + std::list listStream = storageIn->entries(); + + for (std::list::iterator it = listStream.begin(); it != listStream.end(); it++) + { + if (storageIn->isDirectory(*it)) + { + std::list list_entry = storageIn->GetAllStreams(*it); + + for (std::list::iterator it2 = list_entry.begin(); it2 != list_entry.end(); it2++) + { + DecryptStream(*it2, storageIn, storageOut); + } + } + else + DecryptStream(*it, storageIn, storageOut); + + } + storageOut->close(); + delete storageOut; + +//reset streams + RELEASEOBJECT(TableStream); + RELEASEOBJECT(WordDocumentStream); + + m_pStorage->SetFile(m_sTempDecryptFileName.c_str()); + + if (m_pStorage->GetStream ("WordDocument", &WordDocumentStream) == false) return false; + + if (FIB->m_FibBase.fWhichTblStm) + { + if (!m_pStorage->GetStream ("1Table", &TableStream)) m_pStorage->GetStream ("0Table", &TableStream); + } + else + { + if (!m_pStorage->GetStream ("0Table", &TableStream)) m_pStorage->GetStream ("1Table", &TableStream); + } + return true; + } + + bool WordDocument::DecryptStream(std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut) + { + POLE::Stream *stream = new POLE::Stream(storageIn, streamName); + if (!stream) return false; + + stream->seek(0); + int sz_stream = stream->size(); + + POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName, true, sz_stream); + if (!streamNew) return false; + + unsigned char* data_stream = new unsigned char[sz_stream]; + stream->read(data_stream, sz_stream); + + unsigned char* data_store = NULL; + int sz_data_store = 0; + + if ("WordDocument" == streamName) + { + sz_data_store = 68; + data_store = new unsigned char[sz_data_store]; + } + + if (data_store) + memcpy(data_store, data_stream, sz_data_store); + + FIB->m_Decryptor->Decrypt((char*)data_stream, sz_stream, 0); + + if (data_store) + memcpy(data_stream, data_store, sz_data_store); + + streamNew->write(data_stream, sz_stream); + + RELEASEARRAYOBJECTS(data_store); + RELEASEARRAYOBJECTS(data_stream); + + streamNew->flush(); + + delete streamNew; + delete stream; + + return true; + } + + void WordDocument::Clear() { + bOlderVersion = false; + if (AllPapxFkps) { - for (list::iterator iter = AllPapxFkps->begin(); iter != AllPapxFkps->end(); ++iter) + for (std::list::iterator iter = AllPapxFkps->begin(); iter != AllPapxFkps->end(); ++iter) { RELEASEOBJECT(*iter); } @@ -86,7 +538,7 @@ namespace DocFileFormat if (AllChpxFkps) { - for (list::iterator iter = AllChpxFkps->begin(); iter != AllChpxFkps->end(); ++iter) + for (std::list::iterator iter = AllChpxFkps->begin(); iter != AllChpxFkps->end(); ++iter) { RELEASEOBJECT(*iter); } @@ -96,7 +548,7 @@ namespace DocFileFormat if (AllSepx) { - for (map::iterator iter = AllSepx->begin(); iter != AllSepx->end(); ++iter) + for (std::map::iterator iter = AllSepx->begin(); iter != AllSepx->end(); ++iter) { RELEASEOBJECT(iter->second); } @@ -140,339 +592,20 @@ namespace DocFileFormat RELEASEOBJECT(DocProperties); RELEASEOBJECT(listFormatOverrideTable); RELEASEOBJECT(headerAndFooterTable); + RELEASEOBJECT(encryptionHeader); RELEASEOBJECT(m_pStorage); - RELEASEOBJECT(m_pOfficeArtContent); + RELEASEOBJECT(officeArtContent); RELEASEOBJECT(DataStream); RELEASEOBJECT(TableStream); RELEASEOBJECT(WordDocumentStream); } - long WordDocument::Parse(int fibFC) - { - bool res = false; - - m_pStorage = new StructuredStorageReader(); - - if (m_pStorage) - { - if (m_pStorage->SetFile (m_sFileName.GetBuffer()) == false) - { - Clear(); - return AVS_ERROR_FILEFORMAT; - } - } - if (m_pStorage->GetStream ("WordDocument", &WordDocumentStream) == false) - { - Clear(); - return AVS_ERROR_FILEFORMAT; - } - - // Parse FIB - FIB = new FileInformationBlock(VirtualStreamReader(WordDocumentStream,0)); - -#ifdef _DEBUG - //if (Fib2007 == FIB->m_FibBase.nFib) ATLTRACE (_T("NOTE: OFFICE 2007 file format\n")); - //else if (Fib2003 == FIB->m_FibBase.nFib) ATLTRACE (_T("NOTE: OFFICE 2003 file format\n")); - //else if (Fib2002 == FIB->m_FibBase.nFib) ATLTRACE (_T("NOTE: OFFICE 2002 file format\n")); - //else if (Fib2000 == FIB->m_FibBase.nFib) ATLTRACE (_T("NOTE: OFFICE 2000 file format\n")); - //else if (Fib1997 == FIB->m_FibBase.nFib) ATLTRACE (_T("NOTE: OFFICE 1997 file format\n")); - //else if (Fib1997 < FIB->m_FibBase.nFib) ATLTRACE (_T("ERROR: OFFICE file format - UNSUPPORTED\n")); -#endif - - // Check the file version - if (FIB->m_FibBase.nFib) - { - // nFib (2 bytes): An unsigned integer that specifies the version number of the file format used. - // Superseded by FibRgCswNew.nFibNew if it is present. This value SHOULD<12> be 0x00C1. - - // <12> Section 2.5.2: A special empty document is installed with Word 97, Word 2000, Word 2002, - // and Office Word 2003 to allow "Create New Word Document" from the operating system. This - // document has an nFib of 0x00C0. In addition the BiDi build of Word 97 differentiates its documents - // by saving 0x00C2 as the nFib. In both cases treat them as if they were 0x00C1. - - // FIB version written. This will be >= 101 for all Word 6.0 for Windows and after documents - - if (FIB->m_FibBase.nFib < Fib1997) - { - Clear(); - return AVS_MSFILE_ERROR_OLDER; - } - } - else - { - if (FIB->m_FibNew.nFibNew < Fib1997) - { - Clear(); - return AVS_MSFILE_ERROR_OLDER; - } - } - - if (FIB->m_FibBase.fEncrypted) - { - Clear(); - return AVS_ERROR_DRM; - } - - // Get the streams - if (FIB->m_FibBase.fWhichTblStm) - { - res = m_pStorage->GetStream ("1Table", &TableStream); - } - else - { - res = m_pStorage->GetStream ("0Table", &TableStream); - } - - if (res == false) - { - Clear(); - return AVS_ERROR_FILEFORMAT; - } - - try - { - m_pStorage->GetStream ("Data", &DataStream); - } - catch (...) - { - DataStream = NULL; - } - - //Read all needed STTBs - RevisionAuthorTable = new StringTable(TableStream, FIB->m_FibWord97.fcSttbfRMark, FIB->m_FibWord97.lcbSttbfRMark ); - FontTable = new StringTable(TableStream, FIB->m_FibWord97.fcSttbfFfn, FIB->m_FibWord97.lcbSttbfFfn ); - BookmarkNames = new StringTable(TableStream, FIB->m_FibWord97.fcSttbfBkmk, FIB->m_FibWord97.lcbSttbfBkmk ); - AutoTextNames = new StringTable(TableStream, FIB->m_FibWord97.fcSttbfGlsy, FIB->m_FibWord97.lcbSttbfGlsy ); - - if (m_pCallFunc) - { - m_pCallFunc->OnProgress (m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 100000); - - SHORT bCancel = 0; - m_pCallFunc->OnProgressEx(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 100000, &bCancel); - - if (bCancel) - { - Clear(); - return AVS_ERROR_FILEFORMAT; - } - } - - // Read all needed PLCFs - if (FIB->m_RgLw97.ccpFtn > 0) - { - IndividualFootnotesPlex = new Plex(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndTxt, FIB->m_FibWord97.lcbPlcffndTxt ); - FootnoteReferenceCharactersPlex = new Plex(FootnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndRef, FIB->m_FibWord97.lcbPlcffndRef ); - } - - if (FIB->m_RgLw97.ccpEdn > 0) - { - IndividualEndnotesPlex = new Plex(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendTxt, FIB->m_FibWord97.lcbPlcfendTxt ); - EndnoteReferenceCharactersPlex = new Plex(EndnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendRef, FIB->m_FibWord97.lcbPlcfendRef ); - } - - if (FIB->m_RgLw97.ccpHdr > 0) - { - HeaderStoriesPlex = new Plex( EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfHdd, FIB->m_FibWord97.lcbPlcfHdd ); - } - - if (FIB->m_RgLw97.ccpAtn > 0) - { - IndividualCommentsPlex = new Plex(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfandTxt, FIB->m_FibWord97.lcbPlcfandTxt); - AnnotationsReferencePlex = new Plex(AnnotationReferenceDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfandRef, FIB->m_FibWord97.lcbPlcfandRef); - } - - TextboxBreakPlex = new Plex (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxBkd, FIB->m_FibWord97.lcbPlcfTxbxBkd); - TextboxBreakPlexHeader = new Plex (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxHdrBkd, FIB->m_FibWord97.lcbPlcfTxbxHdrBkd); - OfficeDrawingPlex = new Plex (Spa::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcSpaMom, FIB->m_FibWord97.lcbPlcSpaMom); - OfficeDrawingPlexHeader = new Plex (Spa::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcSpaHdr, FIB->m_FibWord97.lcbPlcSpaHdr); - SectionPlex = new Plex (SectionDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfSed, FIB->m_FibWord97.lcbPlcfSed); - BookmarkStartPlex = new Plex (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkf, FIB->m_FibWord97.lcbPlcfBkf); - BookmarkEndPlex = new Plex (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkl, FIB->m_FibWord97.lcbPlcfBkl); - - // только для тестов - //m_arFTBXS = new Plex (FTXBXS::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcftxbxTxt, FIB->m_FibWord97.lcbPlcftxbxTxt); - - //#ifdef _DEBUG - // DumpBuffer(L"C:\\office_spa.dat", VirtualStreamReader(TableStream), FIB->m_FibWord97.fcPlcSpaMom, FIB->m_FibWord97.lcbPlcSpaMom); - //#endif - - for (size_t i = 0; i < BookmarkStartPlex->Elements.size(); ++i) - { - BookmarkFirst* pBookmark = static_cast(BookmarkStartPlex->Elements[i]); - if (pBookmark) - { - BookmarkStartEndCPs.push_back(make_pair(BookmarkStartPlex->CharacterPositions[i], BookmarkEndPlex->CharacterPositions[pBookmark->GetIndex()])); - } - } - - AutoTextPlex = new Plex (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfGlsy, FIB->m_FibWord97.lcbPlcfGlsy); - FieldsPlex = new Plex (FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldMom, FIB->m_FibWord97.lcbPlcfFldMom); - FootnoteDocumentFieldsPlex = new Plex (FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldFtn, FIB->m_FibWord97.lcbPlcfFldFtn); - EndnoteDocumentFieldsPlex = new Plex (FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldEdn, FIB->m_FibWord97.lcbPlcfFldEdn); - HeadersAndFootersDocumentFieldsPlex = new Plex (FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldHdr, FIB->m_FibWord97.lcbPlcfFldHdr); - - if (m_pCallFunc) - { - m_pCallFunc->OnProgress(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 200000 ); - - SHORT bCancel = 0; - m_pCallFunc->OnProgressEx(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 200000, &bCancel); - - if (bCancel) - { - Clear(); - return AVS_ERROR_FILEFORMAT; - } - } - - // Read the FKPs - AllPapxFkps = FormattedDiskPagePAPX::GetAllPAPXFKPs (FIB, WordDocumentStream, TableStream, DataStream); - AllChpxFkps = FormattedDiskPageCHPX::GetAllCHPXFKPs (FIB, WordDocumentStream, TableStream); - - // Read custom tables - DocProperties = new WordDocumentProperties (FIB, TableStream); - Styles = new StyleSheet (FIB, TableStream, DataStream); - listTable = new ListTable (FIB, TableStream); - listFormatOverrideTable = new ListFormatOverrideTable (FIB, TableStream); - m_pOfficeArtContent = new OfficeArtContent (FIB, TableStream); - headerAndFooterTable = new HeaderAndFooterTable (FIB, TableStream); - AnnotationOwners = new AnnotationOwnerList (FIB, TableStream); - -#ifdef _DEBUG - //if (FIB->m_FibWord97.lcbDop) - // DumpBuffer(L"C:\\dop.dat", VirtualStreamReader(TableStream), FIB->m_FibWord97.fcDop, FIB->m_FibWord97.lcbDop); -#endif - -#ifdef _DEBUG - //DumpBuffer(L"d:\\office_art.dat", VirtualStreamReader(TableStream), FIB->m_FibWord97.fcDggInfo, FIB->m_FibWord97.lcbDggInfo); -#endif - if (m_pCallFunc) - { - m_pCallFunc->OnProgress(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 300000 ); - - SHORT bCancel = 0; - m_pCallFunc->OnProgressEx(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 300000, &bCancel); - - if (bCancel) - { - Clear(); - return AVS_ERROR_FILEFORMAT; - } - } - - // Parse the piece table and construct a list that contains all chars - m_PieceTable = new PieceTable (FIB, TableStream); - Text = m_PieceTable->GetAllEncodingText (WordDocumentStream); - -#ifdef _DEBUG - if (0) - { - //ATLTRACE (L"\n=========================================================\n"); - for (size_t j = 0; j < Text->size(); ++j) - { - //ATLTRACE (L"%c", Text->operator [](j)); - } - //ATLTRACE (L"\n=======================================================\n"); - } -#endif - if (BookmarkNames) - { - for (unsigned int i = 0; i < BookmarkStartEndCPs.size(); ++i) - { - WideString* bookmarkName = static_cast(BookmarkNames->operator[]( i )); - - if ( ( bookmarkName != NULL ) && ( *bookmarkName == _T( "_PictureBullets" ) ) ) - { - for (unsigned int j = BookmarkStartEndCPs[i].first, k = 0; j < this->Text->size(); ++j, ++k ) - { - if ( this->Text->at( j ) == 1 ) - { - PictureBulletsCPsMap.insert (make_pair( k, j )); - } - } - } - } - } - - // Build a dictionaries of all PAPX - AllPapx = new map(); - AllPapxVector = new vector(); - - for (list::iterator iter = AllPapxFkps->begin(); iter != AllPapxFkps->end(); ++iter) - { - for (unsigned int j = 0; j < (*iter)->grppapxSize; ++j) - { - int nVal = (*iter)->rgfc[j]; - AllPapx->insert( pair( nVal, (*iter)->grppapx[j] ) ); - AllPapxVector->push_back(nVal); - } - } - - std::sort (AllPapxVector->begin(), AllPapxVector->end()); - - if (m_pCallFunc) - { - m_pCallFunc->OnProgress(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 400000 ); - - SHORT bCancel = 0; - m_pCallFunc->OnProgressEx(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 400000, &bCancel); - - if (bCancel) - { - Clear(); - return AVS_ERROR_FILEFORMAT; - } - } - - //build a dictionary of all SEPX - if ( !SectionPlex->Elements.empty() ) - { - AllSepx = new map(); - - for (unsigned int i = 0; i < SectionPlex->Elements.size(); ++i) - { - //Read the SED - SectionDescriptor* sed = static_cast(SectionPlex->Elements.at(i)); - int cp = SectionPlex->CharacterPositions[i + 1]; - - //Get the SEPX - VirtualStreamReader wordReader( this->WordDocumentStream, sed->fcSepx ); - - //!!!TODO: cbSepx is the size in bytes of the rest properties part!!! - short cbSepx = wordReader.ReadInt16(); - unsigned char* bytes = wordReader.ReadBytes( ( cbSepx /*- 2*/ ), true ); - - AllSepx->insert( pair( cp, new SectionPropertyExceptions( bytes, ( cbSepx /*- 2*/ ) ) ) ); - - RELEASEARRAYOBJECTS( bytes ); - } - } - - if (m_pCallFunc) - { - m_pCallFunc->OnProgress(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 500000 ); - - SHORT bCancel = 0; - m_pCallFunc->OnProgressEx(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 500000, &bCancel); - - if (bCancel) - { - Clear(); - return AVS_ERROR_FILEFORMAT; - } - } - - return 0; - } - // Returns a list of all CHPX which are valid for the given FCs. - std::vector* WordDocument::GetFileCharacterPositions(int fcMin, int fcMax) { - vector* intVector = new vector(); + std::vector* intVector = new std::vector(); int i = 0; @@ -531,7 +664,7 @@ namespace DocFileFormat std::list* WordDocument::GetCharacterPropertyExceptions(int fcMin, int fcMax) { - std::list* cpeList = new list(); + std::list* cpeList = new std::list(); for (std::list::iterator iter = AllChpxFkps->begin(); iter != AllChpxFkps->end(); ++iter) { @@ -561,4 +694,47 @@ namespace DocFileFormat return cpeList; } + std::vector* WordDocument::GetChars (int fcStart, int fcEnd, int cp) + { + if (FIB->m_FibBase.fComplex) + { + return m_PieceTable->GetChars (fcStart, fcEnd, cp, WordDocumentStream); // *chars = new std::vector(); + + fcStart -= FIB->m_FibBase.fcMin; + fcEnd -= FIB->m_FibBase.fcMin; + + for (int i = fcStart; i < fcEnd; i++) + { + chars->push_back(Text->at(i)); + } + + return chars; + } + } + std::vector* WordDocument::GetEncodingChars (int fcStart, int fcEnd) + { + if (FIB->m_FibBase.fComplex) + { + return m_PieceTable->GetEncodingChars (fcStart, fcEnd, WordDocumentStream); // *encodingChars = new std::vector(); + + fcStart -= FIB->m_FibBase.fcMin; + fcEnd -= FIB->m_FibBase.fcMin; + + for (int i = fcStart; i < fcEnd; i++) + { + encodingChars->push_back(Text->at(i)); + } + + return encodingChars; + } + } + } diff --git a/ASCOfficeDocFile/DocDocxConverter/WordDocument.h b/ASCOfficeDocFile/DocDocxConverter/WordDocument.h index 1529276b45..4982b4a50e 100644 --- a/ASCOfficeDocFile/DocDocxConverter/WordDocument.h +++ b/ASCOfficeDocFile/DocDocxConverter/WordDocument.h @@ -32,7 +32,6 @@ #pragma once #include "StructuredStorageReader.h" -#include "VirtualStreamReader.h" #include "FileInformationBlock.h" #include "PieceTable.h" #include "StringTable.h" @@ -51,6 +50,7 @@ #include "ListTable.h" #include "AnnotationOwnerList.h" #include "DocumentProperties.h" +#include "EncryptionHeader.h" #include "ListFormatOverrideTable.h" #include "OfficeArtContent.h" #include "HeaderAndFooterTable.h" @@ -86,10 +86,17 @@ namespace DocFileFormat public: - WordDocument (CString sFileName); + WordDocument (const ProgressCallback* pCallFunc, const std::wstring & tempFolder ); virtual ~WordDocument(); - long LoadDocument (const ProgressCallback* pCallFunc); + long LoadDocument (const std::wstring & fileName, const std::wstring & password); + + bool bOlderVersion; + int document_code_page; + + private: + bool DecryptFile(); + bool DecryptStream(std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut); inline StructuredStorageReader* GetStorage() const { @@ -98,130 +105,103 @@ namespace DocFileFormat inline OfficeArtContent* GetOfficeArt () { - return m_pOfficeArtContent; + return officeArtContent; } - + inline int FindFileCharPos(int cp) { - std::map::iterator it = m_PieceTable->FileCharacterPositions->find(cp); - return (it != m_PieceTable->FileCharacterPositions->end()) ? it->second : -1; + if (FIB->m_FibBase.fComplex) + { + if (!m_PieceTable) return -1; + if ((!m_PieceTable->FileCharacterPositions) || (m_PieceTable->FileCharacterPositions->empty())) return -1; + + std::map::iterator it = m_PieceTable->FileCharacterPositions->find(cp); + return (it != m_PieceTable->FileCharacterPositions->end()) ? it->second : -1; + } + else + { + int fc = cp + FIB->m_FibBase.fcMin; + if (fc > FIB->m_FibBase.fcMac) + return -1; + return fc; + } } - - private: - - vector* GetFileCharacterPositions( int fcMin, int fcMax ); - list* GetCharacterPropertyExceptions( int fcMin, int fcMax ); - long Parse (int fibFC); + std::vector* GetEncodingChars (int fcStart, int fcEnd); + std::vector* GetChars (int fcStart, int fcEnd, int cp); + + std::vector* GetFileCharacterPositions ( int fcMin, int fcMax ); + std::list* GetCharacterPropertyExceptions ( int fcMin, int fcMax ); + void Clear(); - private: - - CString m_sFileName; - + std::wstring m_sFileName; + std::wstring m_sPassword; + std::wstring m_sTempFolder; + std::wstring m_sTempDecryptFileName; + const ProgressCallback* m_pCallFunc; + + POLE::Stream * WordDocumentStream; // The stream "WordDocument" + POLE::Stream * TableStream; // The stream "0Table" or "1Table" + POLE::Stream * DataStream; // The stream called "Data" + StructuredStorageReader * m_pStorage; //POLE::Storage* Storage + + std::vector * Text; // All text of the Word document + std::list * AllPapxFkps; // A list of all FKPs that contain PAPX + std::list * AllChpxFkps; // A list of all FKPs that contain CHPX + + std::map * AllPapx; // The value is the PAPX that formats the paragraph. + std::map * AllSepx; // The value is the SEPX that formats the section. + std::vector * AllPapxVector;// A vector to quick find in AllPapx - int fibFC; + std::map PictureBulletsCPsMap; + std::vector> BookmarkStartEndCPs; - //PieceTable PieceTable; - PieceTable* m_PieceTable; + FileInformationBlock * FIB; + StyleSheet * Styles; // The style sheet of the document + PieceTable * m_PieceTable; // PieceTable PieceTable; + ListFormatOverrideTable * listFormatOverrideTable; // lists and numberings in the document. + HeaderAndFooterTable * headerAndFooterTable; + AnnotationOwnerList * AnnotationOwners; + ListTable * listTable; // list numberings in the document. + WordDocumentProperties * DocProperties; + EncryptionHeader * encryptionHeader; + OfficeArtContent * officeArtContent; // info about the drawings in the document. - // The stream "WordDocument" - POLE::Stream* WordDocumentStream; - // The stream "0Table" or "1Table" - POLE::Stream* TableStream; - // The stream called "Data" - POLE::Stream* DataStream; - // The StructuredStorageFile itself - //POLE::Storage* Storage; - StructuredStorageReader* m_pStorage; - // The file information block of the word document - FileInformationBlock *FIB; - // All text of the Word document - vector *Text; + StringTable *RevisionAuthorTable; + StringTable *FontTable; // A list of all font names, used in the doucument + StringTable *BookmarkNames; + StringTable *AutoTextNames; - /// The style sheet of the document - StyleSheet* Styles; + Plex *IndividualFootnotesPlex; //A plex of locations of individual footnotes + Plex *FootnoteReferenceCharactersPlex; //A plex of footnote reference characters + + Plex *IndividualEndnotesPlex; //A plex of locations of individual endnotes + Plex *EndnoteReferenceCharactersPlex; //A plex of endnote reference characters + + Plex *HeaderStoriesPlex; //A plex of the header document + Plex *IndividualCommentsPlex; // A plex with all ATRDPre10 structs + + Plex *TextboxBreakPlex; // Describes the breaks inside the textbox subdocument + Plex *TextboxBreakPlexHeader; // Describes the breaks inside the header textbox subdocument + + Plex *OfficeDrawingPlex; + Plex *OfficeDrawingPlexHeader; + + Plex *SectionPlex; // A Plex containing all section descriptors + + Plex *m_arFTBXS; // FOR TEST + + Plex *BookmarkStartPlex; + Plex *BookmarkEndPlex; - StringTable *RevisionAuthorTable; - // A list of all font names, used in the doucument - StringTable *FontTable; - StringTable *BookmarkNames; - StringTable *AutoTextNames; - - //A plex of locations of individual footnotes - Plex *IndividualFootnotesPlex; - //A plex of footnote reference characters - Plex *FootnoteReferenceCharactersPlex; - - //A plex of locations of individual endnotes - Plex *IndividualEndnotesPlex; - //A plex of endnote reference characters - Plex *EndnoteReferenceCharactersPlex; - - Plex *FieldsPlex; - Plex *FootnoteDocumentFieldsPlex; - Plex *EndnoteDocumentFieldsPlex; - Plex *HeadersAndFootersDocumentFieldsPlex; - - //A plex of the header document - Plex *HeaderStoriesPlex; - - Plex *IndividualCommentsPlex; - /// A plex with all ATRDPre10 structs + Plex *FieldsPlex; + Plex *FootnoteDocumentFieldsPlex; + Plex *EndnoteDocumentFieldsPlex; + Plex *HeadersAndFootersDocumentFieldsPlex; Plex *AnnotationsReferencePlex; - - AnnotationOwnerList* AnnotationOwners; - - /// A list that contains all formatting information of - /// the lists and numberings in the document. - ListTable* listTable; - - // That contains information about the drawings in the document. - OfficeArtContent* m_pOfficeArtContent; - - /// Describes the breaks inside the textbox subdocument - Plex* TextboxBreakPlex; - Plex* m_arFTBXS; // FOR TEST - /// Describes the breaks inside the header textbox subdocument - Plex* TextboxBreakPlexHeader; - Plex* OfficeDrawingPlex; - Plex* OfficeDrawingPlexHeader; - /// A Plex containing all section descriptors - Plex *SectionPlex; - Plex *BookmarkStartPlex; - Plex *BookmarkEndPlex; - vector> BookmarkStartEndCPs; - map PictureBulletsCPsMap; - /// Each character position specifies the beginning of a range of text - /// that constitutes the contents of an AutoText item. - Plex *AutoTextPlex; - - /// The DocumentProperties of the word document - WordDocumentProperties* DocProperties; - - /// A list that contains all overriding formatting information - /// of the lists and numberings in the document. - ListFormatOverrideTable* listFormatOverrideTable; - - /// A list of all FKPs that contain PAPX - list *AllPapxFkps; - /// A list of all FKPs that contain CHPX - list *AllChpxFkps; - - /// A dictionary that contains all SEPX of the document. - /// The key is the CP at which sections ends. - /// The value is the SEPX that formats the section. - map* AllSepx; - - /// A dictionary that contains all PAPX of the document. - /// The key is the FC at which the paragraph starts. - /// The value is the PAPX that formats the paragraph. - map* AllPapx; - - /// A vector to quick find in AllPapx - vector* AllPapxVector; - - /// A table that contains the positions of the headers and footer in the text. - HeaderAndFooterTable* headerAndFooterTable; + Plex *AutoTextPlex; // Each character position specifies the beginning of\ + a range of text that constitutes the contents of an AutoText item + }; } diff --git a/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.cpp b/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.cpp index 041ec42ae5..13d678caf2 100644 --- a/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.cpp @@ -96,11 +96,13 @@ namespace ImageHelper namespace DocFileFormat { - WordprocessingDocument::WordprocessingDocument(const wchar_t* _pathOutput, const WordDocument* _docFile) : OpenXmlPackage( _docFile ), FontTableXML( _T( "" ) ), DocumentXML( _T( "" ) ), - StyleSheetXML( _T( "" ) ), FootnotesXML ( _T( "" ) ), NumberingXML( _T( "" ) ), - CommentsXML( _T( "" ) ), SettingsXML( _T( "" ) ), CommandTableXML ( _T( "" ) ) + WordprocessingDocument::WordprocessingDocument(const std::wstring & _pathOutput, const WordDocument* _docFile) : + OpenXmlPackage( _docFile ), + FontTableXML( _T( "" ) ), DocumentXML( _T( "" ) ), + StyleSheetXML( _T( "" ) ), FootnotesXML ( _T( "" ) ), NumberingXML( _T( "" ) ), + CommentsXML( _T( "" ) ), SettingsXML( _T( "" ) ), CommandTableXML ( _T( "" ) ) { - m_strOutputPath = std::wstring(_pathOutput); + m_strOutputPath = _pathOutput; } WordprocessingDocument::~WordprocessingDocument() @@ -117,15 +119,15 @@ namespace DocFileFormat //Write main content. (word directory) - SaveToFile(string2std_string(pathWord.GetPath()), wstring( _T("document.xml" ) ), DocumentXML ); - SaveToFile(string2std_string(pathWord.GetPath()), wstring( _T( "fontTable.xml" ) ), FontTableXML ); - SaveToFile(string2std_string(pathWord.GetPath()), wstring( _T( "styles.xml" ) ), StyleSheetXML ); - SaveToFile(string2std_string(pathWord.GetPath()), wstring( _T( "footnotes.xml" ) ), FootnotesXML ); - SaveToFile(string2std_string(pathWord.GetPath()), wstring( _T( "endnotes.xml" ) ), EndnotesXML ); - SaveToFile(string2std_string(pathWord.GetPath()), wstring( _T( "numbering.xml" ) ), NumberingXML ); - SaveToFile(string2std_string(pathWord.GetPath()), wstring( _T( "comments.xml" ) ), CommentsXML ); - SaveToFile(string2std_string(pathWord.GetPath()), wstring( _T( "settings.xml" ) ), SettingsXML ); - SaveToFile(string2std_string(pathWord.GetPath()), wstring( _T( "customizations.xml" ) ),CommandTableXML ); + SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T("document.xml" ) ), DocumentXML ); + SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T( "fontTable.xml" ) ), FontTableXML ); + SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T( "styles.xml" ) ), StyleSheetXML ); + SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T( "footnotes.xml" ) ), FootnotesXML ); + SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T( "endnotes.xml" ) ), EndnotesXML ); + SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T( "numbering.xml" ) ), NumberingXML ); + SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T( "comments.xml" ) ), CommentsXML ); + SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T( "settings.xml" ) ), SettingsXML ); + SaveToFile(string2std_string(pathWord.GetPath()), std::wstring( _T( "customizations.xml" ) ),CommandTableXML ); if (!ImagesList.empty()) { @@ -135,7 +137,7 @@ namespace DocFileFormat int i = 1; - for (list::iterator iter = ImagesList.begin(); iter != ImagesList.end(); ++iter) + for (std::list::iterator iter = ImagesList.begin(); iter != ImagesList.end(); ++iter) { unsigned char* bytes = NULL; bytes = new unsigned char[iter->data.size()]; @@ -165,7 +167,7 @@ namespace DocFileFormat FileSystem::Directory::CreateDirectory( pathObjects.GetPath()); int i = 1; - for (list::iterator iter = OleObjectsList.begin(); iter != OleObjectsList.end(); ++iter) + for (std::list::iterator iter = OleObjectsList.begin(); iter != OleObjectsList.end(); ++iter) { std::wstring fileName = string2std_string(pathObjects.GetPath()) + FILE_SEPARATOR_STR + _T( "oleObject" ) + FormatUtils::IntToWideString(i++) + iter->ext; @@ -183,14 +185,14 @@ namespace DocFileFormat int headersCount = 0; int footersCount = 0; - for (list::iterator iter = HeaderXMLList.begin(); iter != HeaderXMLList.end(); ++iter) + for (std::list::iterator iter = HeaderXMLList.begin(); iter != HeaderXMLList.end(); ++iter) { - SaveToFile(string2std_string(pathWord.GetPath()), ( wstring( _T( "header" ) ) + FormatUtils::IntToWideString(++headersCount) + wstring( _T( ".xml" ) ) ), *iter); + SaveToFile(string2std_string(pathWord.GetPath()), ( std::wstring( _T( "header" ) ) + FormatUtils::IntToWideString(++headersCount) + std::wstring( _T( ".xml" ) ) ), *iter); } - for (list::iterator iter = FooterXMLList.begin(); iter != FooterXMLList.end(); ++iter) + for (std::list::iterator iter = FooterXMLList.begin(); iter != FooterXMLList.end(); ++iter) { - SaveToFile(string2std_string(pathWord.GetPath()), ( wstring( _T( "footer" ) ) + FormatUtils::IntToWideString(++footersCount) + wstring( _T( ".xml" ) ) ), *iter); + SaveToFile(string2std_string(pathWord.GetPath()), ( std::wstring( _T( "footer" ) ) + FormatUtils::IntToWideString(++footersCount) + std::wstring( _T( ".xml" ) ) ), *iter); } } } diff --git a/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.h b/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.h index 9fef9c20c8..f57d05bc5d 100644 --- a/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.h +++ b/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.h @@ -55,26 +55,26 @@ namespace DocFileFormat friend class OleObjectMapping; private: - wstring FileName; + std::wstring FileName; - wstring FontTableXML; - wstring DocumentXML; - wstring StyleSheetXML; - wstring FootnotesXML; - wstring EndnotesXML; - wstring NumberingXML; - wstring CommentsXML; - wstring SettingsXML; - wstring CommandTableXML; + std::wstring FontTableXML; + std::wstring DocumentXML; + std::wstring StyleSheetXML; + std::wstring FootnotesXML; + std::wstring EndnotesXML; + std::wstring NumberingXML; + std::wstring CommentsXML; + std::wstring SettingsXML; + std::wstring CommandTableXML; - list ImagesList; - list OleObjectsList; + std::list ImagesList; + std::list OleObjectsList; - list HeaderXMLList; - list FooterXMLList; + std::list HeaderXMLList; + std::list FooterXMLList; public: - WordprocessingDocument(const wchar_t* _docxDirectory, const WordDocument* _docFile); + WordprocessingDocument(const std::wstring & _docxDirectory, const WordDocument* _docFile); virtual ~WordprocessingDocument(); void SaveDocument(); }; diff --git a/ASCOfficeDocFile/DocFormatLib/DocFormatLib.cpp b/ASCOfficeDocFile/DocFormatLib/DocFormatLib.cpp index 31992ec151..a5c80edf86 100644 --- a/ASCOfficeDocFile/DocFormatLib/DocFormatLib.cpp +++ b/ASCOfficeDocFile/DocFormatLib/DocFormatLib.cpp @@ -37,17 +37,19 @@ #include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h" #include "../../OfficeUtils/src/OfficeUtils.h" -HRESULT COfficeDocFile::LoadFromFile(std::wstring bsDocFile, std::wstring bsDocxDirectory, ProgressCallback *ffCallBack ) +HRESULT COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::wstring & docxDirectory, const std::wstring & password, ProgressCallback *ffCallBack ) { HRESULT hr = S_FALSE; DocFileFormat::Converter docToDocx; - hr= docToDocx.LoadAndConvert(std_string2string(bsDocFile), std_string2string(bsDocxDirectory), ffCallBack); + docToDocx.m_sTempFolder = m_sTempFolder; + + hr= docToDocx.LoadAndConvert(docFile, docxDirectory, password, ffCallBack); return hr; } -HRESULT COfficeDocFile::SaveToFile (std::wstring sDstFileName, std::wstring sSrcFileName, ProgressCallback *ffCallBack ) +HRESULT COfficeDocFile::SaveToFile (const std::wstring & sDstFileName, const std::wstring & sSrcFileName, ProgressCallback *ffCallBack ) { return S_OK; } diff --git a/ASCOfficeDocFile/DocFormatLib/DocFormatLib.h b/ASCOfficeDocFile/DocFormatLib/DocFormatLib.h index 39cb02b721..327446afbf 100644 --- a/ASCOfficeDocFile/DocFormatLib/DocFormatLib.h +++ b/ASCOfficeDocFile/DocFormatLib/DocFormatLib.h @@ -53,8 +53,10 @@ public: { } - HRESULT LoadFromFile(std::wstring sSrcFileName, std::wstring sDstFileName, ProgressCallback *ffCallBack = NULL); - HRESULT SaveToFile(std::wstring sDstFileName, std::wstring sSrcFileName, ProgressCallback *ffCallBack = NULL); + std::wstring m_sTempFolder; + + HRESULT LoadFromFile(const std::wstring & sSrcFileName, const std::wstring & sDstFileName, const std::wstring & password, ProgressCallback *ffCallBack = NULL); + HRESULT SaveToFile(const std::wstring & sDstFileName, const std::wstring & sSrcFileName, ProgressCallback *ffCallBack = NULL); }; diff --git a/ASCOfficeDocFile/DocFormatLib/Linux/DocFormatLib.pro b/ASCOfficeDocFile/DocFormatLib/Linux/DocFormatLib.pro index c3359ef933..97e465b61c 100644 --- a/ASCOfficeDocFile/DocFormatLib/Linux/DocFormatLib.pro +++ b/ASCOfficeDocFile/DocFormatLib/Linux/DocFormatLib.pro @@ -162,9 +162,6 @@ HEADERS += \ ../../Common/TextMark.h \ ../../Common/utf8.h \ ../../Common/XmlTools.h \ - ../../Common/MD4/global.h \ - ../../Common/MD4/md4.h \ - ../../Common/MD4/md4c.h \ ../../DocDocxConverter/AbstractOpenXmlMapping.h \ ../../DocDocxConverter/AnnotationOwnerList.h \ ../../DocDocxConverter/AnnotationReferenceDescriptor.h \ diff --git a/ASCOfficeDocFile/DocFormatLib/Win32/DocFormatLib.vcproj b/ASCOfficeDocFile/DocFormatLib/Win32/DocFormatLib.vcproj index 1d711e621c..e41c7d450b 100644 --- a/ASCOfficeDocFile/DocFormatLib/Win32/DocFormatLib.vcproj +++ b/ASCOfficeDocFile/DocFormatLib/Win32/DocFormatLib.vcproj @@ -323,26 +323,6 @@ RelativePath="..\..\Common\XmlTools.h" > - - - - - - - - - - @@ -435,6 +415,14 @@ RelativePath="..\..\DocDocxConverter\EmuValue.h" > + + + + @@ -1205,6 +1193,14 @@ + + + -#include +#include + +#if defined(_WIN64) + #pragma comment(lib, "../../build/bin/icu/win_64/icuuc.lib") +#elif defined (_WIN32) + #pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib") +#endif int _tmain(int argc, _TCHAR* argv[]) { @@ -52,8 +58,10 @@ int _tmain(int argc, _TCHAR* argv[]) // doc->docx COfficeDocFile docFile; + + docFile.m_sTempFolder = outputDir; - HRESULT hRes = docFile.LoadFromFile( sSrcDoc, dstTempPath, NULL); + HRESULT hRes = docFile.LoadFromFile( sSrcDoc, dstTempPath, L"password", NULL); if (hRes == S_OK) { diff --git a/ASCOfficeDocFile/DocFormatTest/DocFormatTest.vcproj b/ASCOfficeDocFile/DocFormatTest/DocFormatTest.vcproj index 96031e925b..c2548a6c8e 100644 --- a/ASCOfficeDocFile/DocFormatTest/DocFormatTest.vcproj +++ b/ASCOfficeDocFile/DocFormatTest/DocFormatTest.vcproj @@ -382,6 +382,10 @@ RelativePath="..\..\Common\DocxFormat\Source\XML\libxml2\libxml2.cpp" > + + diff --git a/ASCOfficeDocFile/DocxDocConverter/Spa.h b/ASCOfficeDocFile/DocxDocConverter/Spa.h index 9231850045..52fce80ec0 100644 --- a/ASCOfficeDocFile/DocxDocConverter/Spa.h +++ b/ASCOfficeDocFile/DocxDocConverter/Spa.h @@ -237,7 +237,7 @@ namespace ASCDocFileFormat /// 3 reserved for future use AnchorType by; /// Text wrapping mode - /// 0 like 2, but doesnСt require absolute object + /// 0 like 2, but doesn‘t require absolute object /// 1 no text next to shape /// 2 wrap around absolute object /// 3 wrap as if no object present diff --git a/ASCOfficeDocFile/Win32/ASCDocFile.cpp b/ASCOfficeDocFile/Win32/ASCDocFile.cpp index fc7e72041f..2d4363d11f 100644 --- a/ASCOfficeDocFile/Win32/ASCDocFile.cpp +++ b/ASCOfficeDocFile/Win32/ASCDocFile.cpp @@ -42,6 +42,11 @@ #include #endif +#if defined(_WIN64) + #pragma comment(lib, "../../build/bin/icu/win_64/icuuc.lib") +#elif defined (_WIN32) + #pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib") +#endif STDMETHODIMP CASCOfficeDocFile::LoadFromFile(BSTR bsDocFile, BSTR bsDocxFilePath, BSTR bsXMLOptions) { @@ -59,7 +64,7 @@ STDMETHODIMP CASCOfficeDocFile::LoadFromFile(BSTR bsDocFile, BSTR bsDocxFilePath ffCallBack.OnProgressEx = OnProgressExFunc; ffCallBack.caller = this; - HRESULT hr = file.LoadFromFile(bsDocFile, bsDocxFilePath,&ffCallBack); + HRESULT hr = file.LoadFromFile(bsDocFile, bsDocxFilePath, L"", &ffCallBack); #ifdef _DEBUG //_CrtDumpMemoryLeaks(); diff --git a/ASCOfficeDocFile/Win32/ASCOfficeDocFile2005.vcproj b/ASCOfficeDocFile/Win32/ASCOfficeDocFile2005.vcproj index b5321894ee..620616b600 100644 --- a/ASCOfficeDocFile/Win32/ASCOfficeDocFile2005.vcproj +++ b/ASCOfficeDocFile/Win32/ASCOfficeDocFile2005.vcproj @@ -647,6 +647,14 @@ UsePrecompiledHeader="0" /> + + + + + + + + + + + doct @@ -931,6 +933,7 @@ namespace NExtractTools FileSystem::Directory::CreateDirectory(sResultDocxDir); COfficeDocFile docFile; + docFile.m_sTempFolder = sTemp; if (docFile.LoadFromFile( sFrom, sResultDocxDir, NULL)== S_OK) {