Compare commits

..

72 Commits

Author SHA1 Message Date
94548131a1 v5.1.5 2018-07-17 17:08:49 +03:00
47f28ac212 RtfFormat - fix bug #34747 2018-07-09 14:43:46 +03:00
653a4e77c5 moved 'encrypt' data type 2018-07-04 18:11:43 +03:00
1c94b64399 added class for "encrypt" data event 2018-07-04 14:37:48 +03:00
2b2352fc74 Fix error build 2018-07-04 12:22:28 +03:00
06150358a9 Fix bug with calculating inverse matrix 2018-06-27 14:29:21 +03:00
945c04b294 Hatched brush support in builder mode 2018-06-26 17:57:25 +03:00
045b00ad5a x2t - version up 2018-06-21 11:17:42 +03:00
ff8ecb2d2f RtfFormat - fix users files 2018-06-20 18:54:06 +03:00
5893b93e3a XlsFormatFile - fix users files 2018-06-19 13:48:57 +03:00
c462f522d6 x2t - fix bugs #37945, #37946 2018-06-18 15:57:38 +03:00
678ec98721 . 2018-06-18 13:34:40 +03:00
c17fa8462d x2t - add document ID for crypt ooxml 2018-06-18 13:24:59 +03:00
04eda04870 Add StopNoJoin method to BaseThread 2018-06-15 11:46:21 +03:00
0295ef2d54 RtfFormatReader - fix bug #37902 2018-06-07 18:01:45 +03:00
797b745b35 [s2t] Fix open file with unknown picture format
As result, different file names were obtained in binary and file system
2018-06-07 14:42:45 +03:00
37c276b736 [x2t] Fix bug #37892 2018-06-04 18:46:13 +03:00
41ea42459a . 2018-06-01 19:23:56 +03:00
bc68323506 . 2018-06-01 19:20:35 +03:00
5a8c9069be OdfFormatReader - fix users file 2018-06-01 18:17:56 +03:00
ae90e4ae96 Merge pull request #87 from ONLYOFFICE/feature/onlypass
Feature/onlypass
2018-05-30 13:58:42 +03:00
6fae9115ea Merge branch 'hotfix/v5.1.5' into feature/onlypass 2018-05-30 13:58:29 +03:00
b952692225 . 2018-05-30 12:50:50 +03:00
867b0634f3 Fix bug #36423
Fix problem with the clip in the EMF
2018-05-29 18:33:49 +03:00
dde6b8bdc7 . 2018-05-29 14:15:32 +03:00
b66bb0d63f RtfFormatReader - add commetns 2018-05-29 14:14:33 +03:00
d666da2697 OdfFormatReader - fix bug #37832 2018-05-28 13:35:45 +03:00
97ff1efba8 XlsFormat -fix issue 308 2018-05-24 17:52:21 +03:00
50ff5fc0b2 v5.1.4 2018-05-24 15:32:34 +03:00
1c2b86519e [bug] Fix bug 37565 2018-05-23 16:38:24 +03:00
323d1b44cd openssl 2018-05-23 13:36:26 +03:00
83fa44edcd Use system libcurl 2018-05-21 18:12:06 +03:00
2ead42a513 Build on linux 2018-05-17 15:32:23 +03:00
427046cb8f Fix build on mac 2018-05-17 12:14:12 +03:00
e60cc05b6e Downgrade icu to v58.2
ICU58 is the last version that works on Windows XP and Windows Vista.
2018-05-16 12:20:15 +03:00
8cd55fb9c4 OdfFormatReader - fix bug #37746 2018-05-15 16:47:14 +03:00
01b9309f09 x2t - fix bug #37740 2018-05-15 13:39:22 +03:00
d3a4f00f76 Add curl source to gitignore 2018-05-11 19:45:49 +03:00
a7d2191649 Add static libcurl (#81) 2018-05-10 19:23:59 +03:00
14fa14de3f RtfFormatReader - fix bug 37500 2018-05-07 19:26:38 +03:00
cced8f4912 x2t - fix bug 37670 2018-05-07 17:32:35 +03:00
a52a8e982e Merge pull request #80 from ONLYOFFICE/feature/desktop(5.1.3+)
Feature/desktop(5.1.3+)
2018-05-04 13:53:59 +03:00
6afa54ebef x2t - fix users files 2018-04-28 17:04:49 +03:00
27a0e77ef1 [bugs] Crypto bugs 2018-04-28 15:08:38 +03:00
76b682063e x2t - save comments for presentation (undelete ms office) 2018-04-27 19:11:58 +03:00
effdab1ff4 Add not sha1 algorithms to sign/verify providers 2018-04-27 19:01:51 +03:00
48aa99af83 Merge pull request #79 from ONLYOFFICE/feature/konovalovsergey-patch-1
[x2t] Bump compatibilityMode setting
2018-04-27 17:42:09 +03:00
00e9ce56df x2t - fix bug 37579 & bug 37589 2018-04-27 16:00:25 +03:00
261e48227d Bugs 2018-04-26 18:29:39 +03:00
29e3f90ebf v5.1.3 2018-04-26 18:23:51 +03:00
b9b843f25d Windows: add long file names support (x2t) 2018-04-26 13:45:02 +03:00
d7e2bedc6b Openssl errors 2018-04-25 16:51:10 +03:00
58cd45f4ee [x2t] Bump compatibilityMode setting
Prevent opening files in compatibility mode in Word 2016.
2018-04-24 18:52:25 +03:00
33f7ee49df Bugs 2018-04-24 17:45:58 +03:00
95a49140cb Windows: add long file names support 2018-04-23 17:17:19 +03:00
aad12cf471 New scheme for openssl certificate selection 2018-04-23 17:17:19 +03:00
f0ffb7f14c x2t fix after testing (#76) 2018-04-20 18:46:45 +03:00
4c8bc2227a x2t - fix after testing (#75) 2018-04-20 12:05:39 +03:00
c517b3ac19 fix 5.1.3 after used icu6 (#73) 2018-04-17 13:59:21 +03:00
48a1f01220 DocFormatReader- fix users file (table) (#71) 2018-04-16 17:59:44 +03:00
8a2923e534 Use only major version for icu numbering 2018-04-16 17:10:55 +03:00
0ab7e55add Recover icu paths for windows 2018-04-16 17:10:55 +03:00
cb1cb43a0b Fix the target chosing 2018-04-16 17:10:55 +03:00
0ca3432d05 Add icu installation to local folder on linux 2018-04-16 17:10:55 +03:00
50208be48d Add icu building from source on linux 2018-04-16 17:10:55 +03:00
c796f4a0f6 . 2018-04-16 17:10:55 +03:00
618da3c8cc UnicodeConverter - fix build with icu 6.0 win32&win64 2018-04-16 17:10:55 +03:00
9b4568e81a Restore icu version 2018-04-16 17:10:55 +03:00
752acf1e46 Refactore fetching icu 2018-04-16 17:10:55 +03:00
d9afc49bb3 Change devenv to msbuild 2018-04-16 17:10:55 +03:00
4c6ba8ed41 Add icu building from source code on windows 2018-04-16 17:10:55 +03:00
a8bcd38bce v5.1.2 2018-04-11 14:26:30 +03:00
306 changed files with 6671 additions and 9239 deletions

7
.gitignore vendored
View File

@ -13,6 +13,11 @@ Common/3dParty/cef/win_32
Common/3dParty/cef/linux_64
Common/3dParty/cef/linux_32
Common/3dParty/cef/mac_64
Common/3dParty/curl/win_64
Common/3dParty/curl/win_32
Common/3dParty/curl/linux_64
Common/3dParty/curl/linux_32
Common/3dParty/curl/mac_64
Common/3dParty/v8/v8
Common/3dParty/v8/depot_tools
Common/3dParty/v8/win_64
@ -40,6 +45,8 @@ ASCOfficeXlsFile2/win32/_ASCOfficeXlsFile2_i.c
ASCOfficeXlsFile2/win32/_ASCOfficeXlsFile2_p.c
ASCOfficeXlsFile2/win32/dlldata.c
OfficeUtils/win32/OfficeUtilsLib/OfficeUtilsLib/ReadMe.txt
X2tConverter/**/Makefile.*
*.7z
*.obj
*.pdb
*.tlb

View File

@ -58,6 +58,9 @@
#include <boost/format.hpp>
#define GETBITS(from, numL, numH) ((from & (((1 << (numH - numL + 1)) - 1) << numL)) >> numL)
#define GETBIT(from, num) ((from & (1 << num)) != 0)
namespace DocFileFormat
{
typedef unsigned char Bool8;

View File

@ -41,7 +41,7 @@ namespace DocFileFormat
public:
AnnotationOwnerList(FileInformationBlock* fib, POLE::Stream* tableStream) : std::vector<std::wstring>()
{
VirtualStreamReader reader(tableStream, fib->m_FibWord97.fcGrpXstAtnOwners, fib->m_nWordVersion);
VirtualStreamReader reader(tableStream, fib->m_FibWord97.fcGrpXstAtnOwners, fib->m_bOlderVersion);
if (fib->m_FibWord97.fcGrpXstAtnOwners > reader.GetSize()) return;

View File

@ -40,7 +40,7 @@ namespace DocFileFormat
//read the user initials (LPXCharBuffer9)
if (reader->nWordVersion > 0)
if (reader->olderVersion)
{
short cch = reader->ReadByte();

View File

@ -41,9 +41,9 @@ namespace DocFileFormat
static const int STRUCTURE_SIZE = 30;
static const int STRUCTURE_SIZE_OLD = 20;
static const int GetSize(int nWordVersion)
static const int GetSize(bool bOldVersion)
{
return (nWordVersion > 0) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
return bOldVersion ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
}
inline std::wstring GetUserInitials() const

View File

@ -118,78 +118,70 @@ namespace DocFileFormat
public:
/// Creates a new BorderCode with default values
BorderCode(): cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorNameIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false)
BorderCode(): cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false)
{
}
/// Parses the unsigned char for a BRC
BorderCode( unsigned char* bytes, int size ):
cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorNameIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false)
cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false)
{
if ( FormatUtils::ArraySum( bytes, size ) == ( size * 255 ) )
{
fNil = true;
this->fNil = true;
}
else if ( size == 8 )
{
//it's a border code of Word 2000/2003
cv = FormatUtils::BytesToInt32( bytes, 0, size );
ico = std::wstring( Global::ColorIdentifier[0] );
this->cv = FormatUtils::BytesToInt32( bytes, 0, size );
this->ico = std::wstring( Global::ColorIdentifier[0] );
dptLineWidth = bytes[4];
brcType = bytes[5];
this->dptLineWidth = bytes[4];
this->brcType = bytes[5];
short val = FormatUtils::BytesToInt16( bytes, 6, size );
dptSpace = val & 0x001F;
this->dptSpace = val & 0x001F;
//not sure if this is correct, the values from the spec are definitly wrong:
fShadow = FormatUtils::BitmaskToBool( val, 0x20 );
fFrame = FormatUtils::BitmaskToBool( val, 0x40 );
this->fShadow = FormatUtils::BitmaskToBool( val, 0x20 );
this->fFrame = FormatUtils::BitmaskToBool( val, 0x40 );
}
else if ( size == 4 )
{
//it's a border code of Word 97
unsigned short val = FormatUtils::BytesToUInt16( bytes, 0, size );
dptLineWidth = (unsigned char)( val & 0x00FF );
brcType = (unsigned char)( ( val & 0xFF00 ) >> 8 );
this->dptLineWidth = (unsigned char)( val & 0x00FF );
this->brcType = (unsigned char)( ( val & 0xFF00 ) >> 8 );
val = FormatUtils::BytesToUInt16( bytes, 2, size );
ico = FormatUtils::MapValueToWideString( ( val & 0x00FF ), &Global::ColorNameIdentifier[0][0], 17, 12 );
dptSpace = ( val & 0x1F00 ) >> 8;
this->ico = FormatUtils::MapValueToWideString( ( val & 0x00FF ), &Global::ColorIdentifier[0][0], 17, 12 );
this->dptSpace = ( val & 0x1F00 ) >> 8;
}
else if (size == 2)
else
{
unsigned short val = FormatUtils::BytesToUInt16( bytes, 0, size );
dptLineWidth = GETBITS(val, 0, 2);
brcType = GETBITS(val, 3, 4);
fShadow = GETBIT(val, 5);
ico = FormatUtils::MapValueToWideString(GETBITS(val, 6, 10), &Global::ColorNameIdentifier[0][0], 17, 12 );
dptSpace = GETBITS(val, 11, 15);
//throw new ByteParseException("Cannot parse the struct BRC, the length of the struct doesn't match");
}
}
BorderCode( const BorderCode& bc )
{
if ( this != &bc )
{
cv = bc.cv;
dptLineWidth = bc.dptLineWidth;
brcType = bc.brcType;
ico = bc.ico;
dptSpace = bc.dptSpace;
fShadow = bc.fShadow;
fFrame = bc.fFrame;
fNil = bc.fNil;
this->cv = bc.cv;
this->dptLineWidth = bc.dptLineWidth;
this->brcType = bc.brcType;
this->ico = bc.ico;
this->dptSpace = bc.dptSpace;
this->fShadow = bc.fShadow;
this->fFrame = bc.fFrame;
this->fNil = bc.fNil;
}
}
bool operator == ( const BorderCode& bc )
{
if ( ( cv == bc.cv ) && ( dptLineWidth == bc.dptLineWidth ) && ( brcType == bc.brcType ) &&
( ico == bc.ico ) && ( dptSpace == bc.dptSpace ) && ( fShadow == bc.fShadow ) &&
( fFrame == bc.fFrame ) && ( fNil == bc.fNil ) )
if ( ( this->cv == bc.cv ) && ( this->dptLineWidth == bc.dptLineWidth ) && ( this->brcType == bc.brcType ) &&
( this->ico == bc.ico ) && ( this->dptSpace == bc.dptSpace ) && ( this->fShadow == bc.fShadow ) &&
( this->fFrame == bc.fFrame ) && ( this->fNil == bc.fNil ) )
{
return true;
}

View File

@ -129,360 +129,357 @@ namespace DocFileFormat
parent->AppendChild( *webHidden );
RELEASEOBJECT( webHidden );
}
if ((sprms) && (!sprms->empty()))
std::list<SinglePropertyModifier>::iterator end = sprms->end();
for (std::list<SinglePropertyModifier>::iterator iter = sprms->begin(); iter != end; ++iter)
{
std::list<SinglePropertyModifier>::iterator end = sprms->end();
for (std::list<SinglePropertyModifier>::iterator iter = sprms->begin(); iter != end; ++iter)
int nProperty = 0; //for unknown test
switch ( (int)( iter->OpCode ) )
{
int nProperty = 0; //for unknown test
switch ( (int)( iter->OpCode ) )
case sprmOldCIstd :
case sprmCIstd : // style id
{
case sprmOldCIstd :
case sprmCIstd : // style id
if (_isRunStyleNeeded && !_webHidden)
{
if (_isRunStyleNeeded && !_webHidden)
_currentIstd = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if (_currentIstd < _doc->Styles->Styles->size())
{
_currentIstd = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if (_currentIstd < _doc->Styles->Styles->size())
{
appendValueElement( parent, L"rStyle", StyleSheetMapping::MakeStyleId( _doc->Styles->Styles->at( _currentIstd ) ), true );
}
}
}break;
case sprmCFBiDi :
appendFlagElement( parent, *iter, L"rtl", true );
_isRTL = true;
break;
case sprmOldCFBold :
case sprmCFBold :
appendFlagElement( parent, *iter, L"b", true );
break;
case sprmCFBoldBi :
appendFlagElement( parent, *iter, L"bCs", true );
break;
case sprmOldCFCaps :
case sprmCFCaps :
appendFlagElement( parent, *iter, L"caps", true );
break;
case sprmCFComplexScripts :
appendFlagElement( parent, *iter, L"cs", true );
break;
case sprmCFDStrike :
appendFlagElement( parent, *iter, L"dstrike", true );
break;
case sprmCFEmboss :
appendFlagElement( parent, *iter, L"emboss", true );
break;
case sprmCFImprint :
appendFlagElement( parent, *iter, L"imprint", true );
break;
case sprmOldCFItalic :
case sprmCFItalic :
appendFlagElement( parent, *iter, L"i", true );
break;
case sprmCFItalicBi:
appendFlagElement( parent, *iter, L"iCs", true );
break;
case 0x0875:
appendFlagElement( parent, *iter, L"noProof", true );
break;
case sprmOldCFOutline:
case sprmCFOutline:
appendFlagElement( parent, *iter, L"outline", true );
break;
case sprmOldCFShadow:
case sprmCFShadow:
appendFlagElement( parent, *iter, L"shadow", true );
break;
case sprmOldCFSmallCaps:
case sprmCFSmallCaps:
appendFlagElement( parent, *iter, L"smallCaps", true );
break;
case sprmCFSpecVanish:
appendFlagElement( parent, *iter, L"specVanish", true );
break;
case sprmOldCFStrike:
case sprmCFStrike:
appendFlagElement( parent, *iter, L"strike", true );
break;
case sprmOldCFVanish:
case sprmCFVanish:
appendFlagElement( parent, *iter, L"vanish", true );
break;
case 0x0811:
appendFlagElement( parent, *iter, L"webHidden", true );
break;
case sprmOldCIss:
case sprmCIss:
if (iter->argumentsSize > 0 && iter->Arguments[0] < 3) //Metaevan.doc
appendValueElement( parent, L"vertAlign", FormatUtils::MapValueToWideString( iter->Arguments[0], &SuperscriptIndex[0][0], 3, 12 ), true );
break;
case sprmCRgLid0_80:
case sprmCRgLid0:
{ //latin
LanguageId langid( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
LanguageIdMapping* langIDMapping = new LanguageIdMapping( lang, Default );
langid.Convert( langIDMapping );
RELEASEOBJECT( langIDMapping );
}break;
case sprmOldCLid:
case sprmCRgLid1_80:
case sprmCRgLid1:
{ //east asia
LanguageId langid( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
LanguageIdMapping* langIDMapping = new LanguageIdMapping( lang, EastAsian );
langid.Convert( langIDMapping );
RELEASEOBJECT( langIDMapping );
}break;
case sprmCLidBi:
{
LanguageId langid( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
LanguageIdMapping* langIDMapping = new LanguageIdMapping( lang, Complex );
langid.Convert( langIDMapping );
RELEASEOBJECT( langIDMapping );
}break;
case sprmCBrc80:
case sprmCBrc:
{ //borders
XMLTools::XMLElement bdr( L"w:bdr" );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &bdr );
parent->AppendChild( bdr );
}break;
case sprmCShd80:
case sprmCShd:
{ //shading
ShadingDescriptor desc( iter->Arguments, iter->argumentsSize );
appendShading( parent, desc );
}break;
case sprmOldCIco:
case sprmCIco:
case sprmCIcoBi:
{//color
colorVal->SetValue( FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::ColorIdentifier[0][0], 17, 12 ));
}break;
case sprmCCv:
{
std::wstringstream sstream;
sstream << boost::wformat(L"%02x%02x%02x") % iter->Arguments[0] % /*G*/iter->Arguments[1] % /*B*/iter->Arguments[2];
colorVal->SetValue(sstream.str());
}break;
case sprmCOldHighlight:
{
appendValueElement( parent, L"highlight", FormatUtils::MapValueToWideString( iter->Arguments[1], &Global::ColorNameIdentifier[0][0], 17, 12 ), true );
}break;
case sprmCHighlight:
{
appendValueElement( parent, L"highlight", FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::ColorNameIdentifier[0][0], 17, 12 ), true );
}break;
case sprmOldCDxaSpace:
case sprmCDxaSpace:
{
appendValueElement( parent, L"spacing", FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
case sprmCFtcBi :
{//default from FontTable
size_t nIndex = FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize);
if( nIndex < _doc->FontTable->Data.size() )
{
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
if (ffn)
m_sDefaultFont = ffn->xszFtn;
}
}break;
case sprmCHpsBi :
{
appendValueElement( parent, L"szCs",
FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
}
break;
// Font Size in points (2~3276) default 20-half-points
case sprmOldCHps :
{
appendValueElement (parent, L"sz",
FormatUtils::IntToWideString (FormatUtils::BytesToUChar (iter->Arguments, 0, iter->argumentsSize) ),
true );
}break;
case sprmCHps :
{
appendValueElement (parent, L"sz",
FormatUtils::IntToWideString (FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize) ), true );
}break;
case sprmCMajority :
{ //for complex props
}break;
case sprmOldCHpsPos:
{ // The vertical position, in half-points, of text relative to the normal position. (MUST be between -3168 and 3168)
short nVertPos = FormatUtils::BytesToUChar(iter->Arguments, 0, iter->argumentsSize);
appendValueElement (parent, L"position", nVertPos, true);
}break;
case sprmCHpsPos:
{ // The vertical position, in half-points, of text relative to the normal position. (MUST be between -3168 and 3168)
short nVertPos = FormatUtils::BytesToInt16(iter->Arguments, 0, iter->argumentsSize);
appendValueElement (parent, L"position", nVertPos, true);
}break;
case sprmOldCHpsKern:
case sprmCHpsKern:
{
appendValueElement( parent, L"kern", FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
case sprmOldCFtc:
case sprmCRgFtc0:
{ // font family
size_t nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if( nIndex < _doc->FontTable->Data.size() )
{
XMLTools::XMLAttribute* ascii = new XMLTools::XMLAttribute( L"w:ascii" );
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
m_sAsciiFont = ffn->xszFtn;
ascii->SetValue( FormatUtils::XmlEncode(m_sAsciiFont, true));
rFonts->AppendAttribute( *ascii );
RELEASEOBJECT( ascii );
}
}break;
case sprmCRgFtc1:
{
size_t nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if( nIndex >= 0 && nIndex < _doc->FontTable->Data.size() )
{
XMLTools::XMLAttribute* eastAsia = new XMLTools::XMLAttribute( L"w:eastAsia" );
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
m_sEastAsiaFont = ffn->xszFtn;
eastAsia->SetValue( FormatUtils::XmlEncode(m_sEastAsiaFont));
rFonts->AppendAttribute( *eastAsia );
RELEASEOBJECT( eastAsia );
appendValueElement( parent, L"rStyle", StyleSheetMapping::MakeStyleId( _doc->Styles->Styles->at( _currentIstd ) ), true );
}
}
break;
}break;
case sprmCRgFtc2:
case sprmCFBiDi :
appendFlagElement( parent, *iter, L"rtl", true );
_isRTL = true;
break;
case sprmOldCFBold :
case sprmCFBold :
appendFlagElement( parent, *iter, L"b", true );
break;
case sprmCFBoldBi :
appendFlagElement( parent, *iter, L"bCs", true );
break;
case sprmOldCFCaps :
case sprmCFCaps :
appendFlagElement( parent, *iter, L"caps", true );
break;
case sprmCFComplexScripts :
appendFlagElement( parent, *iter, L"cs", true );
break;
case sprmCFDStrike :
appendFlagElement( parent, *iter, L"dstrike", true );
break;
case sprmCFEmboss :
appendFlagElement( parent, *iter, L"emboss", true );
break;
case sprmCFImprint :
appendFlagElement( parent, *iter, L"imprint", true );
break;
case sprmOldCFItalic :
case sprmCFItalic :
appendFlagElement( parent, *iter, L"i", true );
break;
case sprmCFItalicBi:
appendFlagElement( parent, *iter, L"iCs", true );
break;
case 0x0875:
appendFlagElement( parent, *iter, L"noProof", true );
break;
case sprmOldCFOutline:
case sprmCFOutline:
appendFlagElement( parent, *iter, L"outline", true );
break;
case sprmOldCFShadow:
case sprmCFShadow:
appendFlagElement( parent, *iter, L"shadow", true );
break;
case sprmOldCFSmallCaps:
case sprmCFSmallCaps:
appendFlagElement( parent, *iter, L"smallCaps", true );
break;
case sprmCFSpecVanish:
appendFlagElement( parent, *iter, L"specVanish", true );
break;
case sprmOldCFStrike:
case sprmCFStrike:
appendFlagElement( parent, *iter, L"strike", true );
break;
case sprmOldCFVanish:
case sprmCFVanish:
appendFlagElement( parent, *iter, L"vanish", true );
break;
case 0x0811:
appendFlagElement( parent, *iter, L"webHidden", true );
break;
case sprmOldCIss:
case sprmCIss:
if (iter->argumentsSize > 0 && iter->Arguments[0] < 3) //Metaevan.doc
appendValueElement( parent, L"vertAlign", FormatUtils::MapValueToWideString( iter->Arguments[0], &SuperscriptIndex[0][0], 3, 12 ), true );
break;
case sprmCRgLid0_80:
case sprmCRgLid0:
{ //latin
LanguageId langid( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
LanguageIdMapping* langIDMapping = new LanguageIdMapping( lang, Default );
langid.Convert( langIDMapping );
RELEASEOBJECT( langIDMapping );
}break;
case sprmOldCLid:
case sprmCRgLid1_80:
case sprmCRgLid1:
{ //east asia
LanguageId langid( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
LanguageIdMapping* langIDMapping = new LanguageIdMapping( lang, EastAsian );
langid.Convert( langIDMapping );
RELEASEOBJECT( langIDMapping );
}break;
case sprmCLidBi:
{
LanguageId langid( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
LanguageIdMapping* langIDMapping = new LanguageIdMapping( lang, Complex );
langid.Convert( langIDMapping );
RELEASEOBJECT( langIDMapping );
}break;
case sprmCBrc80:
case sprmCBrc:
{ //borders
XMLTools::XMLElement bdr( L"w:bdr" );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &bdr );
parent->AppendChild( bdr );
}break;
case sprmCShd80:
case sprmCShd:
{ //shading
ShadingDescriptor desc( iter->Arguments, iter->argumentsSize );
appendShading( parent, desc );
}break;
case sprmOldCIco:
case sprmCIco:
case sprmCIcoBi:
{//color
colorVal->SetValue( FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::ColorIdentifier[0][0], 17, 12 ));
}break;
case sprmCCv:
{
std::wstringstream sstream;
sstream << boost::wformat(L"%02x%02x%02x") % iter->Arguments[0] % /*G*/iter->Arguments[1] % /*B*/iter->Arguments[2];
colorVal->SetValue(sstream.str());
}break;
case sprmCOldHighlight:
{
appendValueElement( parent, L"highlight", FormatUtils::MapValueToWideString( iter->Arguments[1], &Global::ColorIdentifier[0][0], 17, 12 ), true );
}break;
case sprmCHighlight:
{
appendValueElement( parent, L"highlight", FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::ColorIdentifier[0][0], 17, 12 ), true );
}break;
case sprmOldCDxaSpace:
case sprmCDxaSpace:
{
appendValueElement( parent, L"spacing", FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
case sprmCFtcBi :
{//default from FontTable
size_t nIndex = FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize);
if( nIndex < _doc->FontTable->Data.size() )
{
size_t nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if( nIndex>=0 && nIndex < _doc->FontTable->Data.size() )
{
XMLTools::XMLAttribute* ansi = new XMLTools::XMLAttribute( L"w:hAnsi" );
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
m_shAnsiFont = ffn->xszFtn;
ansi->SetValue( FormatUtils::XmlEncode(m_shAnsiFont));
rFonts->AppendAttribute( *ansi );
RELEASEOBJECT( ansi );
}
}break;
case sprmOldCKul:
case sprmCKul:
{ //Underlining
appendValueElement( parent, L"u", FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::UnderlineCode[0][0], 56, 16 ), true );
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
if (ffn)
m_sDefaultFont = ffn->xszFtn;
}
break;
}break;
case sprmCCharScale:
{ //char width
appendValueElement( parent, L"w", FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
case sprmCSfxText:
{ //animation
appendValueElement( parent, L"effect", FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::TextAnimation[0][0], 7, 16 ), true );
}break;
case sprmCIdctHint:
{
switch(iter->Arguments[0])
{
case 0: break; // default
case 1: break; // eastAsia
case 2: break; // cs
case 0xFF: break; //No ST_Hint equivalent
}
}break;
case sprmCPbiIBullet:
{
int nIndex = FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize );
if (nIndex >=0)
{
std::map<int, int>::iterator it = _doc->PictureBulletsCPsMap.find(nIndex);
if (it != _doc->PictureBulletsCPsMap.end())
{
//добавить
}
}
}break;
case sprmCPbiGrf:
{
//used picture bullet
int val = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
}break;
case sprmCRsidProp:
case sprmCRsidText:
break;
default:
if (iter->argumentsSize == 2)
{
nProperty = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
}else
if (iter->argumentsSize == 1)
{
nProperty = FormatUtils::BytesToUChar( iter->Arguments, 0, iter->argumentsSize );
}
break;
case sprmCHpsBi :
{
appendValueElement( parent, L"szCs",
FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
}
break;
// Font Size in points (2~3276) default 20-half-points
case sprmOldCHps :
{
appendValueElement (parent, L"sz",
FormatUtils::IntToWideString (FormatUtils::BytesToUChar (iter->Arguments, 0, iter->argumentsSize) ),
true );
}break;
case sprmCHps :
{
appendValueElement (parent, L"sz",
FormatUtils::IntToWideString (FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize) ), true );
}break;
case sprmCMajority :
{ //for complex props
}break;
case sprmOldCHpsPos:
{ // The vertical position, in half-points, of text relative to the normal position. (MUST be between -3168 and 3168)
short nVertPos = FormatUtils::BytesToUChar(iter->Arguments, 0, iter->argumentsSize);
appendValueElement (parent, L"position", nVertPos, true);
}break;
case sprmCHpsPos:
{ // The vertical position, in half-points, of text relative to the normal position. (MUST be between -3168 and 3168)
short nVertPos = FormatUtils::BytesToInt16(iter->Arguments, 0, iter->argumentsSize);
appendValueElement (parent, L"position", nVertPos, true);
}break;
case sprmOldCHpsKern:
case sprmCHpsKern:
{
appendValueElement( parent, L"kern", FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
case sprmOldCFtc:
case sprmCRgFtc0:
{ // font family
size_t nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if( nIndex < _doc->FontTable->Data.size() )
{
XMLTools::XMLAttribute* ascii = new XMLTools::XMLAttribute( L"w:ascii" );
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
m_sAsciiFont = ffn->xszFtn;
ascii->SetValue( FormatUtils::XmlEncode(m_sAsciiFont, true));
rFonts->AppendAttribute( *ascii );
RELEASEOBJECT( ascii );
}
}break;
case sprmCRgFtc1:
{
size_t nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if( nIndex >= 0 && nIndex < _doc->FontTable->Data.size() )
{
XMLTools::XMLAttribute* eastAsia = new XMLTools::XMLAttribute( L"w:eastAsia" );
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
m_sEastAsiaFont = ffn->xszFtn;
eastAsia->SetValue( FormatUtils::XmlEncode(m_sEastAsiaFont));
rFonts->AppendAttribute( *eastAsia );
RELEASEOBJECT( eastAsia );
}
}
break;
case sprmCRgFtc2:
{
size_t nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if( nIndex>=0 && nIndex < _doc->FontTable->Data.size() )
{
XMLTools::XMLAttribute* ansi = new XMLTools::XMLAttribute( L"w:hAnsi" );
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
m_shAnsiFont = ffn->xszFtn;
ansi->SetValue( FormatUtils::XmlEncode(m_shAnsiFont));
rFonts->AppendAttribute( *ansi );
RELEASEOBJECT( ansi );
}
}break;
case sprmOldCKul:
case sprmCKul:
{ //Underlining
appendValueElement( parent, L"u", FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::UnderlineCode[0][0], 56, 16 ), true );
}
break;
case sprmCCharScale:
{ //char width
appendValueElement( parent, L"w", FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
case sprmCSfxText:
{ //animation
appendValueElement( parent, L"effect", FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::TextAnimation[0][0], 7, 16 ), true );
}break;
case sprmCIdctHint:
{
switch(iter->Arguments[0])
{
case 0: break; // default
case 1: break; // eastAsia
case 2: break; // cs
case 0xFF: break; //No ST_Hint equivalent
}
}break;
case sprmCPbiIBullet:
{
int nIndex = FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize );
if (nIndex >=0)
{
std::map<int, int>::iterator it = _doc->PictureBulletsCPsMap.find(nIndex);
if (it != _doc->PictureBulletsCPsMap.end())
{
//добавить
}
}
}break;
case sprmCPbiGrf:
{
//used picture bullet
int val = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
}break;
case sprmCRsidProp:
case sprmCRsidText:
break;
default:
if (iter->argumentsSize == 2)
{
nProperty = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
}else
if (iter->argumentsSize == 1)
{
nProperty = FormatUtils::BytesToUChar( iter->Arguments, 0, iter->argumentsSize );
}
break;
}
}

View File

@ -35,188 +35,19 @@
namespace DocFileFormat
{
class CharacterPropertyExceptions: public PropertyExceptions
{
public:
/// Creates a CHPX wich doesn't modify anything.
/// The grpprl list is empty
CharacterPropertyExceptions(): PropertyExceptions()
{
}
class CharacterPropertyExceptions: public PropertyExceptions
{
public:
/// Creates a CHPX wich doesn't modify anything.
/// The grpprl list is empty
CharacterPropertyExceptions(): PropertyExceptions()
{
}
/// Parses the bytes to retrieve a CHPX
CharacterPropertyExceptions( unsigned char* bytes, int size, int nWordVersion) :
PropertyExceptions( bytes, size, nWordVersion )
{
if (nWordVersion > 1)
{
RELEASEOBJECT( grpprl );
grpprl = new std::list<SinglePropertyModifier>();
MemoryStream oStream(bytes, size);
int pos = 0;
if (nWordVersion == 3)
{
if (pos + 2 > size) return;
unsigned short fChar = oStream.ReadUInt16(); pos += 2;
unsigned char val;
val = GETBIT(fChar, 0); grpprl->push_back(SinglePropertyModifier(sprmOldCFBold, 1, &val));
val = GETBIT(fChar, 1); grpprl->push_back(SinglePropertyModifier(sprmOldCFItalic, 1, &val));
val = GETBIT(fChar, 2); grpprl->push_back(SinglePropertyModifier(sprmOldCFStrike, 1, &val));
val = GETBIT(fChar, 3); grpprl->push_back(SinglePropertyModifier(sprmOldCFOutline, 1, &val));
val = GETBIT(fChar, 4); grpprl->push_back(SinglePropertyModifier(sprmOldCFFldVanish, 1, &val));
val = GETBIT(fChar, 5); grpprl->push_back(SinglePropertyModifier(sprmOldCFSmallCaps, 1, &val));
val = GETBIT(fChar, 6); grpprl->push_back(SinglePropertyModifier(sprmOldCFCaps, 1, &val));
val = GETBIT(fChar, 7); grpprl->push_back(SinglePropertyModifier(sprmOldCFVanish, 1, &val));
val = GETBIT(fChar, 8); grpprl->push_back(SinglePropertyModifier(sprmOldCFRMark, 1, &val));
val = GETBIT(fChar, 9); grpprl->push_back(SinglePropertyModifier(sprmOldCFSpec, 1, &val));
bool fsIco = GETBIT(fChar, 10);
bool fsFtc = GETBIT(fChar, 11);
bool fsHps = GETBIT(fChar, 12);
bool fsKul = GETBIT(fChar, 13);
bool fsPos = GETBIT(fChar, 14);
bool fsSpace = GETBIT(fChar, 15);
if (pos + 2 > size) return;
int fff = oStream.ReadUInt16(); pos += 2;//?????
if (pos + 2 > size) return;
unsigned short ftc = oStream.ReadUInt16(); pos += 2; // Font Code
grpprl->push_back(SinglePropertyModifier(sprmOldCFtc, 2, (unsigned char*)&ftc));
if (pos + 1 > size) return;
unsigned char hps = oStream.ReadByte(); pos += 1; // Font size in half points
if (hps > 0)
{
grpprl->push_back(SinglePropertyModifier(sprmOldCHps, 1, &hps));
}
if (pos + 1 > size) return;
unsigned char hpsPos = oStream.ReadByte(); pos += 1; // Sub/Superscript ( signed number, 0 = normal )
grpprl->push_back(SinglePropertyModifier(sprmOldCHpsPos, 1, &hpsPos));
if (pos + 2 > size) return;
unsigned short fText = oStream.ReadUInt16(); pos += 2;
unsigned short qpsSpace = GETBITS(fText, 0, 5);
unsigned char wSpare2 = GETBITS(fText, 6, 7);
unsigned char ico = GETBITS(fText, 8, 11);
unsigned char kul = GETBITS(fText, 12, 14);
bool fSysVanish = GETBIT(fChar, 15);
grpprl->push_back(SinglePropertyModifier(sprmOldCKul, 1, &kul));
grpprl->push_back(SinglePropertyModifier(sprmOldCIco, 1, &ico));
//sizeof(CHP) == 12 == 0xC
if (pos + 4 > size) return;
unsigned int fcPic = oStream.ReadUInt16(); pos += 4; //pos = 8
grpprl->push_back(SinglePropertyModifier(sprmOldCPicLocation, 4, (BYTE*)&fcPic));
if (pos + 1 > size) return;
unsigned char fnPic = oStream.ReadByte(); pos += 1;
if (pos + 2 > size) return;
unsigned short hpsLargeChp = oStream.ReadUInt16(); pos += 2;// ??? type
}
else if (nWordVersion == 2)
{
if (pos + 2 > size) return;
unsigned short fChar = oStream.ReadUInt16(); pos += 2;
unsigned char val;
val = GETBIT(fChar, 0); grpprl->push_back(SinglePropertyModifier(sprmOldCFBold, 1, &val));
val = GETBIT(fChar, 1); grpprl->push_back(SinglePropertyModifier(sprmOldCFItalic, 1, &val));
val = GETBIT(fChar, 2); grpprl->push_back(SinglePropertyModifier(sprmOldCIbstRMark, 1, &val));
val = GETBIT(fChar, 3); grpprl->push_back(SinglePropertyModifier(sprmOldCFOutline, 1, &val));
val = GETBIT(fChar, 4); grpprl->push_back(SinglePropertyModifier(sprmOldCFFldVanish, 1, &val));
val = GETBIT(fChar, 5); grpprl->push_back(SinglePropertyModifier(sprmOldCFSmallCaps, 1, &val));
val = GETBIT(fChar, 6); grpprl->push_back(SinglePropertyModifier(sprmOldCFCaps, 1, &val));
val = GETBIT(fChar, 7); grpprl->push_back(SinglePropertyModifier(sprmOldCFVanish, 1, &val));
val = GETBIT(fChar, 8); grpprl->push_back(SinglePropertyModifier(sprmOldCFRMark, 1, &val));
val = GETBIT(fChar, 9); grpprl->push_back(SinglePropertyModifier(sprmOldCFSpec, 1, &val));
val = GETBIT(fChar, 10); grpprl->push_back(SinglePropertyModifier(sprmOldCFStrike, 1, &val));
val = GETBIT(fChar, 11); grpprl->push_back(SinglePropertyModifier(sprmOldCFObj, 1, &val));
val = GETBIT(fChar, 12); grpprl->push_back(SinglePropertyModifier(sprmCFBoldBi, 1, &val));
val = GETBIT(fChar, 13); grpprl->push_back(SinglePropertyModifier(sprmCFItalicBi, 1, &val));
val = GETBIT(fChar, 14); grpprl->push_back(SinglePropertyModifier(sprmCFBiDi, 1, &val));
val = GETBIT(fChar, 15); grpprl->push_back(SinglePropertyModifier(sprmCFDiacColor, 1, &val));
if (pos + 2 > size) return;
unsigned short fChar2 = oStream.ReadUInt16(); pos += 2;
bool fsIco = GETBIT(fChar2, 0);
bool fsFtc = GETBIT(fChar2, 1);
bool fsHps = GETBIT(fChar2, 2);
bool fsKul = GETBIT(fChar2, 3);
bool fsPos = GETBIT(fChar2, 4);
bool fsSpace = GETBIT(fChar2, 5);
bool fsLid = GETBIT(fChar2, 6);
bool fsIcoBi = GETBIT(fChar2, 7);
bool fsFtcBi = GETBIT(fChar2, 8);
bool fsHpsBi = GETBIT(fChar2, 9);
bool fsLidBi = GETBIT(fChar2, 10);
if (pos + 2 > size) return;
unsigned short ftc = oStream.ReadUInt16(); pos += 2; // Font Code
grpprl->push_back(SinglePropertyModifier(sprmOldCFtc, 2, (unsigned char*)&ftc));
if (pos + 1 > size) return;
unsigned char hps = oStream.ReadByte(); pos += 1; // Font size in half points
if (hps > 0)
{
grpprl->push_back(SinglePropertyModifier(sprmOldCHps, 1, &hps));
}
if (pos + 1 > size) return;
unsigned char hpsPos = oStream.ReadByte(); pos += 1; // Sub/Superscript ( signed number, 0 = normal )
grpprl->push_back(SinglePropertyModifier(sprmOldCHpsPos, 1, &hpsPos));
if (pos + 2 > size) return;
unsigned short fText = oStream.ReadUInt16(); pos += 2;
unsigned short qpsSpace = GETBITS(fText, 0, 5);
unsigned char wSpare2 = GETBITS(fText, 6, 7);
unsigned char ico = GETBITS(fText, 8, 11);
unsigned char kul = GETBITS(fText, 12, 14);
bool fSysVanish = GETBIT(fChar, 15);
grpprl->push_back(SinglePropertyModifier(sprmOldCKul, 1, &kul));
grpprl->push_back(SinglePropertyModifier(sprmOldCIco, 1, &ico));
//if (pos + 1 > size) return;
//unsigned char icoBi = oStream.ReadUInt16(); pos += 1;//wSpare3
if (pos + 2 > size) return;
unsigned short lid = oStream.ReadUInt16(); pos += 2;
grpprl->push_back(SinglePropertyModifier(sprmOldCLid, 2, (BYTE*)&lid));
if (pos + 2 > size) return;
unsigned short ftcBi = oStream.ReadUInt16(); pos += 2;
grpprl->push_back(SinglePropertyModifier(sprmCFtcBi, 4, (BYTE*)&ftcBi));
//if (pos + 2 > size) return;
//unsigned short hpsBi = oStream.ReadUInt16(); pos += 2;
//grpprl->push_back(SinglePropertyModifier(sprmCHpsBi, 4, (BYTE*)&hpsBi));
//if (pos + 2 > size) return;
//unsigned short lidBi = oStream.ReadUInt16(); pos += 2;
//grpprl->push_back(SinglePropertyModifier(sprmCLidBi, 2, (BYTE*)&lidBi));
if (pos + 4 > size) return;
unsigned int fcPic = oStream.ReadUInt16(); pos += 4; //pos = 8
grpprl->push_back(SinglePropertyModifier(sprmOldCPicLocation, 4, (BYTE*)&fcPic));
if (pos + 1 > size) return;
unsigned char fnPic = oStream.ReadByte(); pos += 1;
if (pos + 2 > size) return;
unsigned short hpsLargeChp = oStream.ReadUInt16(); pos += 2;// ??? type
}
}
}
};
/// Parses the bytes to retrieve a CHPX
CharacterPropertyExceptions( unsigned char* bytes, int size, bool oldVersion) :
PropertyExceptions( bytes, size, oldVersion )
{
}
};
}

View File

@ -72,10 +72,14 @@ namespace DocFileFormat
{
AnnotationReferenceDescriptor* atrdPre10 = static_cast<AnnotationReferenceDescriptor*>(m_document->AnnotationsReferencePlex->Elements[index]);
unsigned short index_author = atrdPre10->GetAuthorIndex();
m_pXmlWriter->WriteNodeBegin( L"w:comment", TRUE );
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( index + 1 ));
m_pXmlWriter->WriteAttribute( L"w:author",
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( atrdPre10->GetAuthorIndex() ) ));
if (index_author < m_document->AnnotationOwners->size()) //conv_253l2H1CehgKwsxCtNk__docx.doc
{
m_pXmlWriter->WriteAttribute( L"w:author",
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( index_author ) ));
}
m_pXmlWriter->WriteAttribute( L"w:initials", atrdPre10->GetUserInitials());
//!!!TODO!!!
@ -95,7 +99,7 @@ namespace DocFileFormat
if (fc < 0) break;
ParagraphPropertyExceptions* papx = findValidPapx(fc);
TableInfo tai(papx, m_document->nWordVersion);
TableInfo tai(papx);
if ( tai.fInTable )
{
@ -107,7 +111,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph(cp, 0x7fffffff);
cp = writeParagraph(cp);
}
}

View File

@ -163,6 +163,7 @@ namespace OpenXmlRelationshipTypes
static const wchar_t* GlossaryDocument = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument";
static const wchar_t* Package = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
static const wchar_t* VbaProject = L"http://schemas.microsoft.com/office/2006/relationships/vbaProject";
static const wchar_t* Hyperlink = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
}
namespace MicrosoftWordRelationshipTypes

View File

@ -59,30 +59,29 @@ namespace DocFileFormat
short wdy;
public:
DateAndTime()
{
setDefaultValues();
}
DateAndTime( unsigned int val )
{
DateAndTime((unsigned char*)&val, 4);
}
DateAndTime( unsigned char* bytes, int size )
{
if ( size == 4 )
{
this->mint = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 0, 6 );
this->hr = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 6, 5 );
this->dom = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 11, 5 );
this->mon = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 16, 4 );
this->yr = (short)( 1900 + FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 20, 9 ) );
this->wdy = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 29, 3 );
}
else
{
//throw new ByteParseException("Cannot parse the struct DTTM, the length of the struct doesn't match");
}
}
/// Creates a new DateAndTime with default values
DateAndTime()
{
setDefaultValues();
}
/// Parses the unsigned char sto retrieve a DateAndTime
DateAndTime( unsigned char* bytes, int size )
{
if ( size == 4 )
{
this->mint = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 0, 6 );
this->hr = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 6, 5 );
this->dom = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 11, 5 );
this->mon = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 16, 4 );
this->yr = (short)( 1900 + FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 20, 9 ) );
this->wdy = (short)FormatUtils::GetIntFromBits( FormatUtils::BytesToInt32( bytes, 0, size ), 29, 3 );
}
else
{
//throw new ByteParseException("Cannot parse the struct DTTM, the length of the struct doesn't match");
}
}
#if defined(_WIN32) || defined(_WIN64)
SYSTEMTIME ToSYSTEMTIME()
{

View File

@ -89,11 +89,6 @@ namespace DocFileFormat
//if cp is the last char of a section, the next section will start at cp +1
size_t current = 0;
if (m_document->SectionPlex->CharacterPositions.empty())
{
return cp;
}
for (std::vector<int>::iterator iter = m_document->SectionPlex->CharacterPositions.begin() + 1; iter != m_document->SectionPlex->CharacterPositions.end(); ++iter)
{
if (cp < *iter)
@ -145,7 +140,7 @@ namespace DocFileFormat
// Writes a Paragraph that starts at the given cp and
// ends at the next paragraph end mark or section end mark
int DocumentMapping::writeParagraph(int cp, int cpEnd)
int DocumentMapping::writeParagraph(int cp)
{
//search the paragraph end
int cpParaEnd = cp;
@ -175,7 +170,7 @@ namespace DocFileFormat
{
cpParaEnd++;
return writeParagraph(cp, (std::min)(cpEnd, cpParaEnd), false);
return writeParagraph(cp, cpParaEnd, false);
}
}
@ -191,8 +186,8 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos(cp);
int fcEnd = m_document->FindFileCharPos(cpEnd);
if (fc < 0 || fcEnd < 0 || fc == fcEnd)
return -1;
if (fc < 0 || fcEnd < 0)
return 0;
ParagraphPropertyExceptions* papx = findValidPapx(fc);
@ -538,7 +533,8 @@ namespace DocFileFormat
}
else if (TextMark::PageBreakOrSectionMark == code)
{
if (_isSectionPageBreak == 0)
//write page break, section breaks are written by writeParagraph() method
if (/*!isSectionEnd(c)*/_isSectionPageBreak == 0)
{
writeTextElement(text, textType);
@ -575,21 +571,20 @@ namespace DocFileFormat
std::vector<std::wstring> arField;
boost::algorithm::split(arField, sFieldString, boost::algorithm::is_any_of(L"\\"), boost::algorithm::token_compress_on);
std::wstring EMBED ( L"EMBED" );
std::wstring embed ( L"embed" );
std::wstring LINK ( L"LINK" );
std::wstring FORM ( L"FORM" );
std::wstring Excel ( L"Excel" );
std::wstring Word ( L"Word" );
std::wstring opendocument(L"opendocument" );
std::wstring Equation ( L"Equation" );
std::wstring MERGEFORMAT( L"MERGEFORMAT" );
std::wstring QUOTE ( L"QUOTE" );
std::wstring EMBED ( L" EMBED" );
std::wstring LINK ( L" LINK" );
std::wstring FORM ( L" FORM" );
std::wstring Excel ( L" Excel" );
std::wstring Word ( L" Word" );
std::wstring opendocument(L" opendocument" );
std::wstring Equation ( L" Equation" );
std::wstring MERGEFORMAT( L" MERGEFORMAT" );
std::wstring QUOTE ( L" QUOTE" );
std::wstring chart ( L"Chart" );
std::wstring PBrush ( L"PBrush" );
std::wstring TOC ( L"TOC" );
std::wstring HYPERLINK ( L"HYPERLINK" );
std::wstring PAGEREF ( L"PAGEREF" );
std::wstring PBrush ( L" PBrush" );
std::wstring TOC ( L" TOC" );
std::wstring HYPERLINK ( L" HYPERLINK" );
std::wstring PAGEREF ( L" PAGEREF" );
std::wstring PAGE ( L"PAGE" );
if (arField.empty() == false)
@ -598,8 +593,7 @@ namespace DocFileFormat
f = sFieldString;
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() ||
search( f.begin(), f.end(), embed.begin(), embed.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();
@ -685,14 +679,21 @@ namespace DocFileFormat
if ( _bContentWrite )
{
m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true );
m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true );
_fieldLevels.back().bBegin = true;
}
else
{
//while ( cpFieldSep2 < cpFieldEnd)
//{
// cpFieldSep2 = searchNextTextMark(m_document->Text, cpFieldSep1 + 1, TextMark::FieldSeparator);
// std::wstring f1( ( m_document->Text->begin() + cpFieldSep1 ), ( m_document->Text->begin() + cpFieldSep2 + 1 ) );
// toc.push_back(f1);
//
// if (search( f1.begin(), f1.end(), PAGEREF.begin(), PAGEREF.end()) != f1.end())
for (size_t i = 1; i < arField.size(); i++)
{
std::wstring f1 = arField[1];
@ -702,12 +703,12 @@ namespace DocFileFormat
{
_writeWebHidden = true;
std::wstring _writeTocLink =f1.substr(d + 9);
d = (int)_writeTocLink.find(L" ");
d = (int)_writeTocLink.find(L" ");
_writeTocLink = _writeTocLink.substr(0, d);
_writeAfterRun = std::wstring (L"<w:hyperlink w:anchor = \"");
_writeAfterRun = std::wstring (L"<w:hyperlink w:anchor = \"");
_writeAfterRun += _writeTocLink;
_writeAfterRun += std::wstring (L"\" w:history=\"1\">");
_writeAfterRun += std::wstring (L"\" w:history=\"1\">");
break;
//cp = cpFieldSep1;
@ -717,7 +718,28 @@ namespace DocFileFormat
_skipRuns = 5; //with separator
}
}
else if ( bEMBED || bLINK || bQUOTE)
//else if ( bHYPERLINK )
//{//todooo - выделение гиперссылки отдельно
// std::vector<std::wstring> arRefs;
// boost::algorithm::split(arRefs, f, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
//
// std::wstring sLink = arRefs[2];
// m_pXmlWriter->WriteNodeBegin( L"w:hyperlink", true );
// int relID = m_context->_docx->RegisterHyperlink(_caller, sLink);
// m_pXmlWriter->WriteAttribute( L"r:id", L"rId"+ FormatUtils::IntToWideString( relID ) );
// m_pXmlWriter->WriteAttribute( L"w:history", 1 );
// m_pXmlWriter->WriteNodeEnd( L"", true, false );
// if (arRefs.size() > 2)
// {
// writeTextElement(arRefs[3].substr(1, arRefs[3].length() - 2), textType);
// }
// m_pXmlWriter->WriteNodeEnd( L"w:hyperlink", false, true );
// _skipRuns = 1;
//}
else if ( bEMBED || (bLINK && !bHYPERLINK)|| bQUOTE)
{
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
int cpFieldSep = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::FieldSeparator);
@ -745,9 +767,9 @@ namespace DocFileFormat
if (!m_shapeIdOwner.empty()) //4571833.doc
oVmlMapper.m_shapeId = m_shapeIdOwner;
if (m_document->nWordVersion > 0)
{
OleObject ole ( chpxObj, m_document);
if (m_document->bOlderVersion)
{
OleObject ole ( chpxObj, m_document->GetStorage(), m_document->bOlderVersion);
oleWriter.WriteNodeBegin (L"w:object", true);
oleWriter.WriteAttribute( L"w:dxaOrig", FormatUtils::IntToWideString( ( ole.pictureDesciptor.dxaGoal + ole.pictureDesciptor.dxaOrigin ) ));
@ -763,7 +785,7 @@ namespace DocFileFormat
}
else
{
PictureDescriptor pic(chpxObj, m_document->DataStream, 0x7fffffff, m_document->nWordVersion);
PictureDescriptor pic(chpxObj, m_document->DataStream, 0x7fffffff, m_document->bOlderVersion);
oleWriter.WriteNodeBegin (L"w:object", true);
oleWriter.WriteAttribute( L"w:dxaOrig", FormatUtils::IntToWideString( ( pic.dxaGoal + pic.dxaOrigin ) ) );
@ -781,7 +803,7 @@ namespace DocFileFormat
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions( fcFieldSep, ( fcFieldSep + 1 ) );
CharacterPropertyExceptions* chpxSep = chpxs->front();
OleObject ole ( chpxSep, m_document);
OleObject ole ( chpxSep, m_document->GetStorage(), m_document->bOlderVersion);
OleObjectMapping oleObjectMapping( &oleObjectWriter, m_context, &pic, _caller, oVmlMapper.m_shapeId );
if (oVmlMapper.m_isEmbedded)
@ -840,19 +862,21 @@ namespace DocFileFormat
else if (TextMark::FieldEndMark == code)
{
if (!_fieldLevels.empty())
{
_fieldLevels.back().bEnd = true;
if (_fieldLevels.back().bBegin == true && !text.empty())
{
if (!text.empty())
{
writeTextElement(text, textType);
text.clear();
}
}
if (_fieldLevels.back().bBegin)
{
_fieldLevels.back().bEnd = true;
XMLTools::XMLElement elem( L"w:fldChar" );
elem.AppendAttribute( L"w:fldCharType", L"end" );
XMLTools::XMLElement elem( L"w:fldChar" );
elem.AppendAttribute( L"w:fldCharType", L"end" );
m_pXmlWriter->WriteString( elem.GetXMLString());
m_pXmlWriter->WriteString( elem.GetXMLString());
}
_fieldLevels.pop_back();
}
@ -890,7 +914,7 @@ namespace DocFileFormat
if (pSpa)
{
PictureDescriptor pictDiscr(chpx, m_document->WordDocumentStream, 0x7fffffff, m_document->nWordVersion);
PictureDescriptor pictDiscr(chpx, m_document->WordDocumentStream, 0x7fffffff, m_document->bOlderVersion);
ShapeContainer* pShape = m_document->GetOfficeArt()->GetShapeContainer(pSpa->GetShapeID());
if (pShape)
@ -912,9 +936,9 @@ namespace DocFileFormat
}
}
}
else if (TextMark::Picture == code && fSpec)
else if ((TextMark::Picture == code) && fSpec )
{
PictureDescriptor oPicture (chpx, m_document->nWordVersion > 0 ? m_document->WordDocumentStream : m_document->DataStream, 0x7fffffff, m_document->nWordVersion);
PictureDescriptor oPicture (chpx, m_document->bOlderVersion ? m_document->WordDocumentStream : m_document->DataStream, 0x7fffffff, m_document->bOlderVersion);
bool isInline = _isTextBoxContent;
@ -950,7 +974,7 @@ namespace DocFileFormat
if (oVmlMapper.m_isEmbedded)
{
OleObject ole ( chpx, m_document);
OleObject ole ( chpx, m_document->GetStorage(), m_document->bOlderVersion);
OleObjectMapping oleObjectMapping( &pictWriter, m_context, &oPicture, _caller, oVmlMapper.m_shapeId );
ole.isEquation = oVmlMapper.m_isEquation;
@ -1151,20 +1175,7 @@ namespace DocFileFormat
if ( fc >= nMinVal )
{
ret = m_document->AllPapx->find(nMinVal)->second;
//? if (!ret && m_document->AllPapx->size() > 0)
//? {
//? map<int, ParagraphPropertyExceptions*>::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;
}
}
@ -1211,23 +1222,22 @@ namespace DocFileFormat
int fc2 = m_document->FindFileCharPos( cp );
int fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
//build the table grid
std::vector<short> grid, grid_write;
buildTableGrid( cp, nestingLevel, grid, grid_write );
std::vector<short> grid;
buildTableGrid( cp, nestingLevel, grid);
//find first row end
int fcRowEnd = findRowEndFc( cp, nestingLevel );
TablePropertyExceptions row1Tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->nWordVersion);
TablePropertyExceptions row1Tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->bOlderVersion);
//start table
m_pXmlWriter->WriteNodeBegin( L"w:tbl" );
//Convert it
TablePropertiesMapping *tpMapping = new TablePropertiesMapping( m_pXmlWriter, m_document->Styles, &grid, &grid_write );
TablePropertiesMapping *tpMapping = new TablePropertiesMapping( m_pXmlWriter, m_document->Styles, &grid);
row1Tapx.Convert( tpMapping );
@ -1240,11 +1250,11 @@ namespace DocFileFormat
//only convert the cells with the given nesting level
while ( tai.iTap == nestingLevel )
{
cp = writeTableRow( cp, &grid, &grid_write, 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, m_document->nWordVersion );
tai = TableInfo( papx );
}
}
else
@ -1253,11 +1263,11 @@ namespace DocFileFormat
//convert until the end of table is reached
while ( tai.fInTable )
{
cp = writeTableRow( cp, &grid, &grid_write, nestingLevel );
cp = writeTableRow( cp, &grid, nestingLevel );
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
}
}
@ -1268,24 +1278,27 @@ namespace DocFileFormat
}
// Builds a list that contains the width of the several columns of the table.
bool DocumentMapping::buildTableGrid(int initialCp, unsigned int nestingLevel, std::vector<short>& grid, std::vector<short>& grid_write)
bool DocumentMapping::buildTableGrid(int initialCp, unsigned int nestingLevel, std::vector<short>& grid)
{
ParagraphPropertyExceptions* backup = _lastValidPapx;
std::vector<short> boundaries;
std::vector<short> boundaries_all;
std::map<short, short> boundaries;
int cp = initialCp;
int fc = m_document->FindFileCharPos( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
int fcRowEnd = findRowEndFc( cp, cp, nestingLevel );
ParagraphPropertyExceptions* papx_prev = NULL;
short max_boundary = -1;
short count_column = 0;
while ( tai.fInTable )
{
short current_count_column = 0;
//check all SPRMs of this TAPX
for ( std::list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ )
{
@ -1294,46 +1307,36 @@ namespace DocFileFormat
switch(iter->OpCode)
{
case sprmTDefTable:
case sprmOldTDefTable:
{
unsigned char itcMac = iter->Arguments[0];
while(boundaries.size() < itcMac + 1)
boundaries.push_back(-0x7fff);
short boundary0 = -0x7fff;
for (unsigned char i = 0; i < itcMac; i++)
case sprmTDefTable:
case sprmOldTDefTable:
{
short boundary1 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( i * 2 ), iter->argumentsSize );
short boundary2 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( ( i + 1 ) * 2 ), iter->argumentsSize );
//SprmTDefTable tdef(iter->Arguments, iter->argumentsSize);
//int itcMac = tdef.numberOfColumns;
if (boundary2 - boundary1 > 1 && boundary1 - boundary0 > 1)
{
if ( boundaries[i] == -0x7fff || boundaries[i+1] == -0x7fff)
{
boundaries[i] = boundary1;
boundaries[i+1] = boundary2;
}
}
if ( find( boundaries_all.begin(), boundaries_all.end(), boundary1 ) == boundaries_all.end() )
{
boundaries_all.push_back( boundary1 );
}
unsigned char itcMac = iter->Arguments[0];
if ( find( boundaries_all.begin(), boundaries_all.end(), boundary2 ) == boundaries_all.end() )
short boundary1, boundary2;
for (unsigned char i = 0; i < itcMac; i++)
{
boundaries_all.push_back( boundary2 );
boundary1 = FormatUtils::BytesToInt16( iter->Arguments + 1, i * 2 , iter->argumentsSize );
boundary2 = FormatUtils::BytesToInt16( iter->Arguments + 1, ( i + 1 ) * 2, iter->argumentsSize );
AddBoundary(boundary1, boundary2, boundaries);
}
boundary0 = boundary1;
}break;
}
if (max_boundary < boundary2)
max_boundary = boundary2;
AddBoundary(boundary2, max_boundary, boundaries);
}break;
}
}
if (current_count_column > count_column)
count_column = current_count_column;
//get the next papx
papx = findValidPapx( fcRowEnd );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
fcRowEnd = findRowEndFc( cp, cp, nestingLevel );
if (papx_prev && papx_prev == papx )
@ -1341,21 +1344,11 @@ namespace DocFileFormat
papx_prev = papx;
}
//build the grid based on the boundaries
sort( boundaries_all.begin(), boundaries_all.end() );
if ( !boundaries.empty() )
{
for ( size_t i = 0; i < ( boundaries.size() - 1 ); i++ )
for ( std::map<short, short>::iterator it = boundaries.begin(); it != boundaries.end(); ++it)
{
grid_write.push_back( boundaries[i + 1] - boundaries[i] );
}
}
if ( !boundaries_all.empty() )
{
for ( size_t i = 0; i < ( boundaries_all.size() - 1 ); i++ )
{
grid.push_back( boundaries_all[i + 1] - boundaries_all[i] );
grid.push_back( it->second );
}
}
_lastValidPapx = backup;
@ -1363,6 +1356,40 @@ namespace DocFileFormat
return true;
}
void DocumentMapping::AddBoundary(short boundary1, short boundary2, std::map<short, short> &boundaries)
{
if (boundary2 - boundary1 < 10)
return;
std::map<short, short>::iterator pFind = boundaries.find(boundary1);
while(true)
{
if (pFind == boundaries.end())
{
boundaries.insert(std::make_pair(boundary1, boundary2 - boundary1));
break;
}
else if (pFind->second != boundary2 - boundary1)
{
if (pFind->second > boundary2 - boundary1)
{
short new_size = boundary2 - boundary1;
boundary1 = boundary2;
boundary2 = pFind->second + pFind->first;
pFind->second = new_size;
}
else
{
boundary1 = pFind->second + pFind->first;
}
pFind = boundaries.find(boundary1);
}
else
break;
}
}
// Finds the FC of the next row end mark.
int DocumentMapping::findRowEndFc(int initialCp, int& rowEndCp, unsigned int nestingLevel )
{
@ -1370,7 +1397,7 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
if ( nestingLevel > 1 )
{
@ -1386,7 +1413,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
cp++;
}
@ -1409,7 +1436,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
cp++;
}
}
@ -1428,7 +1455,7 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
if ( nestingLevel > 1 )
{
@ -1448,7 +1475,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
cp++;
}
@ -1471,7 +1498,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
cp++;
}
}
@ -1480,20 +1507,20 @@ 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, std::vector<short>* grid, std::vector<short>* grid_write, unsigned int nestingLevel)
int DocumentMapping::writeTableRow(int initialCp, std::vector<short>* grid, unsigned int nestingLevel)
{
int cp = initialCp;
int fc = m_document->FindFileCharPos( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
//start w:tr
m_pXmlWriter->WriteNodeBegin( L"w:tr" );
//convert the properties
int fcRowEnd = findRowEndFc( cp, nestingLevel );
TablePropertyExceptions tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->nWordVersion);
TablePropertyExceptions tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->bOlderVersion);
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions( fcRowEnd, fcRowEnd + 1 );
TableRowPropertiesMapping* trpMapping = new TableRowPropertiesMapping( m_pXmlWriter, *(chpxs->begin()) );
@ -1510,14 +1537,14 @@ namespace DocFileFormat
//Write until the first "inner trailer paragraph" is reached
while ( !( ( m_document->Text->at( cp ) == TextMark::ParagraphEnd ) && ( tai.fInnerTtp ) ) && tai.fInTable )
{
cp = writeTableCell( cp, &tapx, grid, grid_write, gridIndex, cellIndex, nestingLevel );
cp = writeTableCell( cp, &tapx, grid, gridIndex, cellIndex, nestingLevel );
cellIndex++;
//each cell has it's own PAPX
fc = m_document->FindFileCharPos(cp );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
}
}
else
@ -1527,14 +1554,14 @@ namespace DocFileFormat
while ( !( ( m_document->Text->at( cp ) == TextMark::CellOrRowMark ) && ( tai.fTtp ) )
&& tai.fInTable )
{
cp = writeTableCell( cp, &tapx, grid, grid_write, gridIndex, cellIndex, nestingLevel );
cp = writeTableCell( cp, &tapx, grid, gridIndex, cellIndex, nestingLevel );
cellIndex++;
//each cell has it's own PAPX
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
}
}
@ -1550,7 +1577,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, std::vector<short>* grid, std::vector<short>* grid_write, int& gridIndex, int cellIndex, unsigned int nestingLevel )
int DocumentMapping::writeTableCell(int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel )
{
int cp = initialCp;
int cpCellEnd = findCellEndCp( initialCp, nestingLevel );
@ -1558,7 +1585,7 @@ namespace DocFileFormat
//start w:tc
m_pXmlWriter->WriteNodeBegin( L"w:tc" );
TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( m_pXmlWriter, grid, grid_write, gridIndex, cellIndex );
TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( m_pXmlWriter, grid, gridIndex, cellIndex );
if ( tapx != NULL )
{
@ -1576,7 +1603,7 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
//cp = writeParagraph(cp);
@ -1596,7 +1623,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph( cp, 0x7fffffff );
cp = writeParagraph( cp );
}
}
@ -1615,7 +1642,7 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos( initialCp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
while ( !tai.fInnerTableCell )
{
@ -1624,7 +1651,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cpCellEnd );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
}
cpCellEnd++;
@ -1745,8 +1772,13 @@ namespace DocFileFormat
// Checks if the CHPX is special
bool DocumentMapping::isSpecial(CharacterPropertyExceptions* chpx)
{
if (!chpx) return false;
if (!chpx->grpprl) return false;
/*
for (list<SinglePropertyModifier>::iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); ++iter)
{
short value = FormatUtils::BytesToInt16 (iter->Arguments, 0, iter->argumentsSize);
int c = 0;
}
*/
for (std::list<SinglePropertyModifier>::iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); ++iter)
{
@ -1816,11 +1848,6 @@ namespace DocFileFormat
{
SectionPropertyExceptions* ret = NULL;
if (!m_document->AllSepx)
{
return ret;
}
try
{
ret = m_document->AllSepx->operator [](cp);

View File

@ -87,7 +87,7 @@ namespace DocFileFormat
bool isSectionEnd ( int cp );
// Writes a Paragraph that starts at the given cp and
// ends at the next paragraph end mark or section end mark
int writeParagraph( int cp, int cpEnd );
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, bool lastBad = false );
@ -110,15 +110,15 @@ namespace DocFileFormat
// 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.
bool buildTableGrid( int initialCp, unsigned int nestingLevel, std::vector<short>& grid, std::vector<short>& grid_write );
bool buildTableGrid( int initialCp, unsigned int nestingLevel, std::vector<short>& grid);
// 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, std::vector<short>* grid, std::vector<short>* grid_write, unsigned int nestingLevel );
int writeTableRow ( int initialCp, std::vector<short>* grid, unsigned int nestingLevel );
// Writes the table cell that starts at the given cp value and ends at the next cell end mark
int writeTableCell ( int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, std::vector<short>* grid_write, int& gridIndex, int cellIndex, unsigned int nestingLevel );
int writeTableCell ( int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel );
int findCellEndCp ( int initialCp, unsigned int nestingLevel );
bool writeBookmarks ( int cp );
@ -135,6 +135,8 @@ namespace DocFileFormat
// Searches the given vector for the next FieldEnd character.
int searchNextTextMark( std::vector<wchar_t>* chars, int initialCp, wchar_t mark );
Symbol getSymbol ( const CharacterPropertyExceptions* chpx );
void AddBoundary(short boundary1, short boundary2, std::map<short, short> &boundaries);
//----------------------------------------------------------------------------------------------------------------------
bool m_bInternalXmlWriter;

View File

@ -48,89 +48,22 @@ namespace DocFileFormat
{
Initialize();
VirtualStreamReader tStream( tableStream, fib->m_FibWord97.fcDop, fib->m_nWordVersion);
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 = NULL;
unsigned int size = fib->m_FibWord97.lcbDop;
unsigned char* bytes = tStream.ReadBytes( size, true );
try
{
if (fib->m_nWordVersion == 2)
{
unsigned char* Temp = tStream.ReadBytes(size, true);
tStream.Seek(fib->m_FibWord97.fcDop, 0);
delete []Temp;
unsigned char flags1 = tStream.ReadByte();
fFacingPages = GETBIT(flags1, 0);
fWindowControl = GETBIT(flags1, 1);
Fpc = GETBITS(flags1, 5, 6);
bool fWide = GETBIT(flags1, 7);
grpfIhdt = tStream.ReadByte();
unsigned short flags2 = tStream.ReadUInt16();
rncFtn = GETBIT(flags2, 0);
nFtn = GETBITS(flags2, 1, 15);
unsigned char irmBar = tStream.ReadByte();
unsigned char flags3 = tStream.ReadByte();
unsigned char irmProps = GETBITS(flags3, 0, 6);
fRevMarking = GETBIT(flags3, 7);
unsigned short flags4 = tStream.ReadUInt16();
fBackup = GETBIT(flags4, 0);
fExactWords = GETBIT(flags4, 1);
fPagHidden = GETBIT(flags4, 2);
fPagResults = GETBIT(flags4, 3);
fLockAtn = GETBIT(flags4, 4);
fMirrorMargins = GETBIT(flags4, 5);
bool fKeepFileFormat = GETBIT(flags4, 6);
fDflttrueType = GETBIT(flags4, 7);
fPagSuppressTopSpacing = GETBIT(flags4, 8);
fMaybeRTLTables = GETBIT(flags4, 9);
bool fSpares = tStream.ReadUInt16();
dxaTab = tStream.ReadUInt16();
wSpare = tStream.ReadUInt16();//ftcDefaultBi
dxaHotZ = tStream.ReadUInt16();
wSpare2 = tStream.ReadUInt16();
wSpare3 = tStream.ReadUInt16();
dttmCreated = DateAndTime( tStream.ReadUInt32() );
dttmRevised = DateAndTime( tStream.ReadUInt32() );
dttmLastPrint = DateAndTime( tStream.ReadUInt32() );
nRevision = tStream.ReadUInt16();
tmEdited = tStream.ReadUInt32();
cWords = tStream.ReadUInt32();
cCh = tStream.ReadUInt32();
cPg = tStream.ReadUInt16();
unsigned short rgwSpareDocSum[2];
rgwSpareDocSum[0] = tStream.ReadUInt16();
rgwSpareDocSum[1] = tStream.ReadUInt16();
}
else if ( size > 0 )
if ( size > 0 )
{
bytes = tStream.ReadBytes( size, true );
fFacingPages = FormatUtils::GetBitFromBytes( bytes, 2, 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)FormatUtils::GetUIntFromBytesBits( bytes, 2, 5, 2 );
grpfIhdt = FormatUtils::BytesToUChar( bytes, 1, size );
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 );
@ -612,7 +545,6 @@ namespace DocFileFormat
fSwapBordersFacingPgs = false;
dxaTab = 0;
wSpare = 0;
wSpare3 = 0;
dxaHotZ = 0;
cConsecHypLim = 0;
wSpare2 = 0;

View File

@ -177,8 +177,7 @@ namespace DocFileFormat
unsigned short cConsecHypLim;
// Reserved
unsigned short wSpare2;
unsigned short wSpare3;
// Date and time document was created
// Date and time document was created
DateAndTime dttmCreated;
// Date and time document was last revised
DateAndTime dttmRevised;

View File

@ -37,9 +37,9 @@ namespace DocFileFormat
{
EncryptionHeader::EncryptionHeader( FileInformationBlock* fib, POLE::Stream* tableStream ) : bStandard(false), bXOR(false), bAES(false)
{
VirtualStreamReader tStream( tableStream, 0, fib->m_nWordVersion);
VirtualStreamReader tStream( tableStream, 0, fib->m_bOlderVersion);
if (fib->m_FibBase.fObfuscation || fib->m_nWordVersion > 0)
if (fib->m_FibBase.fObfuscation || fib->m_bOlderVersion)
{
bXOR = true;

View File

@ -79,7 +79,7 @@ namespace DocFileFormat
if (fc < 0) break;
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
if ( tai.fInTable )
{
@ -91,7 +91,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph( cp, 0x7fffffff );
cp = writeParagraph( cp );
}
}

File diff suppressed because it is too large Load Diff

View File

@ -69,22 +69,14 @@ namespace DocFileFormat
newObject->prq = (unsigned char) FormatUtils::BitmaskToInt ( ffid, 0x03 );
newObject->fTrueType = FormatUtils::BitmaskToBool ( ffid, 0x04 );
newObject->ff = (unsigned char) FormatUtils::BitmaskToInt ( ffid, 0x70 );
newObject->wWeight = reader->ReadInt16();
newObject->chs = reader->ReadByte();
//int sz_fonts = 150; //.. нужно генерить уникальное todooo
int szAlt = 0;
if (reader->nWordVersion == 2)
{
newObject->wWeight = reader->ReadByte();
}
else
{
newObject->wWeight = reader->ReadInt16();
newObject->chs = reader->ReadByte();
szAlt = reader->ReadByte();
}
int szAlt = reader->ReadByte();
if (reader->nWordVersion == 0)
if (!reader->olderVersion)
{
//read the 10 bytes panose
newObject->panoseSize = 10;
@ -105,7 +97,7 @@ namespace DocFileFormat
unsigned char *bytes = reader->ReadBytes( (int)( strEnd - strStart ), true );
if (reader->nWordVersion > 0)
if (reader->olderVersion)
{
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(newObject->xszFtn), bytes, (int)( strEnd - strStart ), ENCODING_WINDOWS_1250 );
}
@ -139,7 +131,7 @@ namespace DocFileFormat
bytes = reader->ReadBytes( (int)( strEnd - strStart ), true );
if (reader->nWordVersion > 0)
if (reader->olderVersion)
{
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(newObject->xszAlt), bytes, (int)( strEnd - strStart ), ENCODING_WINDOWS_1250);
}
@ -159,7 +151,7 @@ namespace DocFileFormat
{
long strStart = reader->GetPosition();
if (reader->nWordVersion > 0)
if (reader->olderVersion)
{//ansi string only
while ( reader->ReadByte() != 0 )
{

View File

@ -71,7 +71,7 @@ namespace DocFileFormat
if (fc < 0) break;
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
if ( tai.fInTable )
{
@ -89,7 +89,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph( cp, 0x7fffffff );
cp = writeParagraph( cp );
}
}

View File

@ -81,7 +81,7 @@ namespace DocFileFormat
if (fc < 0) break;
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
if ( tai.fInTable )
{
@ -93,7 +93,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph( cp, 0x7fffffff );
cp = writeParagraph( cp );
}
while (cp <= cpStart) //conv_fQioC665ib4ngHkDGY4__docx.doc
cp++;

View File

@ -98,7 +98,7 @@ void FormFieldData::_FFData::read(VirtualStreamReader *reader)
xstzEntryMcr = readXstz(reader);
xstzExitMcr = readXstz(reader);
}
FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, int nWordVersion )
FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, bool bOlderVersion_ )
{
binary_data_size = 0;
@ -139,7 +139,7 @@ FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx,
if (fc >= 0 && bNilPICFAndBinData)
{
VirtualStreamReader reader(stream, fc, nWordVersion);
VirtualStreamReader reader(stream, fc, bOlderVersion_);
int sz_stream = reader.GetSize();

View File

@ -108,7 +108,7 @@ namespace DocFileFormat
//STTB hsttbDropList;
void read(VirtualStreamReader* reader);
};
FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, int nWordVersion );
FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, bool bOlderVersion );
virtual ~FormFieldData() {}
private:
friend class FormFieldDataMapping;

View File

@ -52,7 +52,7 @@ namespace DocFileFormat
/*========================================================================================================*/
FormattedDiskPageCHPX::FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset, int nWordVersion ):
FormattedDiskPageCHPX::FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset, bool oldVersion ):
FormattedDiskPage(), rgb(NULL), grpchpxSize(NULL), grpchpx(NULL)
{
Type = Character;
@ -80,6 +80,7 @@ namespace DocFileFormat
j += 4;
}
//create arrays
grpchpxSize = crun;
rgb = new unsigned char[crun];
grpchpx = new CharacterPropertyExceptions*[grpchpxSize];
@ -103,10 +104,11 @@ namespace DocFileFormat
//read the bytes of chpx
chpx = new unsigned char[cb];
//Array.Copy(bytes, (wordOffset * 2) + 1, chpx, 0, chpx.Length);
memcpy( chpx, ( bytes + (wordOffset * 2) + 1 ), cb );
//parse CHPX and fill grpchpx
grpchpx[i] = new CharacterPropertyExceptions( chpx, cb, nWordVersion);
grpchpx[i] = new CharacterPropertyExceptions( chpx, cb, oldVersion);
RELEASEARRAYOBJECTS( chpx );
}
@ -137,7 +139,7 @@ namespace DocFileFormat
}
//there are n offsets and n-1 fkp's in the bin table
if (fib->m_nWordVersion > 0)
if (fib->m_bOlderVersion)
{
int n = ( ( (int)fib->m_FibWord97.lcbPlcfBteChpx - 8 ) / 6 ) + 1;
@ -160,7 +162,7 @@ namespace DocFileFormat
int offset = fkpnr * 512;
//parse the FKP and add it to the list
CHPXlist->push_back( new FormattedDiskPageCHPX( wordStream, offset, fib->m_nWordVersion ) );
CHPXlist->push_back( new FormattedDiskPageCHPX( wordStream, offset, fib->m_bOlderVersion ) );
}
}
else
@ -176,7 +178,7 @@ namespace DocFileFormat
int offset = fkpnr * 512;
//parse the FKP and add it to the list
CHPXlist->push_back( new FormattedDiskPageCHPX( wordStream, offset, fib->m_nWordVersion ) );
CHPXlist->push_back( new FormattedDiskPageCHPX( wordStream, offset, fib->m_bOlderVersion ) );
}
}

View File

@ -50,7 +50,7 @@ namespace DocFileFormat
public:
virtual ~FormattedDiskPageCHPX();
FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset, int nWordVersion );
FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset, bool oldVersion );
/// Parses the 0Table (or 1Table) for FKP _entries containing CHPX
static std::list<FormattedDiskPageCHPX*>* GetAllCHPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream );
};

View File

@ -52,53 +52,59 @@ namespace DocFileFormat
/*========================================================================================================*/
FormattedDiskPagePAPX::FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, int nWordVersion, bool fComplex):
FormattedDiskPagePAPX::FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, bool oldVersion, bool fComplex):
FormattedDiskPage(), rgbx(NULL), grppapxSize(0), grppapx(NULL)
{
Type = Paragraph;
WordStream = wordStream;
{
Type = Paragraph;
WordStream = wordStream;
//read the 512 bytes (FKP)
unsigned char* bytes = NULL;
bytes = new unsigned char[512];
//read the 512 bytes (FKP)
unsigned char* bytes = NULL;
bytes = new unsigned char[512];
WordStream->seek( offset);
WordStream->read( bytes, 512);
WordStream->seek( offset);
WordStream->read( bytes, 512);
//get the count
crun = bytes[511];
//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;
int j = 0;
for ( unsigned int i = 0; i < rgfcSize; i++ )
{
rgfc[i] = FormatUtils::BytesToInt32( bytes, j, 512 );
j += 4;
}
rgbx = new BX[crun];
grppapxSize = crun;
grppapx = new ParagraphPropertyExceptions*[grppapxSize];
for ( unsigned int i = 0; i < rgfcSize; i++ )
{
rgfc[i] = FormatUtils::BytesToInt32( bytes, j, 512 );
j += 4;
}
for ( unsigned int i = 0; i < grppapxSize; i++ )
{
grppapx[i] = NULL;
}
//create arrays
rgbx = new BX[crun];
grppapxSize = crun;
grppapx = new ParagraphPropertyExceptions*[grppapxSize];
j = 4 * ( crun + 1 );
for ( unsigned int i = 0; i < grppapxSize; i++ )
{
grppapx[i] = NULL;
}
unsigned char phe[12];
j = 4 * ( crun + 1 );
//read the 12 for PHE
unsigned char* phe = NULL;
phe = new unsigned char[12];
unsigned char* papx = NULL;
for ( unsigned char i = 0; i < crun; i++ )
for ( int i = 0; i < crun; i++ )
{
BX bx;
bx.wordOffset = bytes[j];
j++;
if (fComplex || nWordVersion == 0)
if (fComplex || !oldVersion)
{
memcpy( phe, ( bytes + j), 12 );
@ -107,13 +113,6 @@ namespace DocFileFormat
j += 12;
}
else if (nWordVersion == 2)
{
memcpy( phe, ( bytes + bx.wordOffset * 2 + j + 1), 6);
//fill the rgbx array
bx.phe = ParagraphHeight( phe, 6, false );
}
else
{
memcpy( phe, ( bytes + j), 6);
@ -127,26 +126,29 @@ namespace DocFileFormat
if ( bx.wordOffset != 0 )
{
//read first unsigned char of PAPX
//PAPX is stored in a FKP; so the first unsigned char is a count of words
unsigned char padbyte = 0;
unsigned char cw = bytes[bx.wordOffset * 2] * 2;
unsigned char cw = bytes[bx.wordOffset * 2];
//if that unsigned char is zero, it's a pad unsigned char, and the word count is the following unsigned char
if ( cw == 0 )
{
padbyte = 1;
cw = bytes[bx.wordOffset * 2 + 1] * 2;
cw = bytes[bx.wordOffset * 2 + 1];
}
if ( cw != 0 )
{
//read the bytes for papx
unsigned char* papx = new unsigned char[cw];
memcpy( papx, ( bytes + (bx.wordOffset * 2) + padbyte + 1 ), cw );
papx = new unsigned char[cw * 2];
memcpy( papx, ( bytes + (bx.wordOffset * 2) + padbyte + 1 ), ( cw * 2 ) );
//parse PAPX and fill grppapx
grppapx[i] = new ParagraphPropertyExceptions( papx, cw, dataStream, nWordVersion );
grppapx[i] = new ParagraphPropertyExceptions( papx, ( cw * 2 ), dataStream, oldVersion );
RELEASEARRAYOBJECTS( papx );
}
}
else
{
@ -155,6 +157,7 @@ namespace DocFileFormat
}
}
RELEASEARRAYOBJECTS( phe );
RELEASEARRAYOBJECTS( bytes );
}
@ -176,7 +179,7 @@ namespace DocFileFormat
//there are n offsets and n-1 fkp's in the bin table
if (fib->m_nWordVersion > 0 && fib->m_FibBase.fComplex == false)
if (fib->m_bOlderVersion && fib->m_FibBase.fComplex == false)
{
int n = ( ( (int)fib->m_FibWord97.lcbPlcfBtePapx - 8 ) / 6 ) + 1;
@ -199,7 +202,7 @@ namespace DocFileFormat
int offset = fkpnr * 512;
//parse the FKP and add it to the list
PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_nWordVersion, fib->m_FibBase.fComplex) );
PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_bOlderVersion, fib->m_FibBase.fComplex) );
}
//if (PAPXlist->back()->rgfc[PAPXlist->back()->rgfcSize-1] < last)
@ -223,7 +226,7 @@ namespace DocFileFormat
int offset = fkpnr * 512;
//parse the FKP and add it to the list
PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_nWordVersion, fib->m_FibBase.fComplex) );
PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_bOlderVersion, fib->m_FibBase.fComplex) );
}
}

View File

@ -63,7 +63,7 @@ namespace DocFileFormat
public:
virtual ~FormattedDiskPagePAPX();
FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, int nWordVersion, bool fComplex);
FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, bool oldVersion, bool fComplex);
/// Parses the 0Table (or 1Table) for FKP _entries containing PAPX
static std::list<FormattedDiskPagePAPX*>* GetAllPAPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream);
/// Returns a list of all PAPX FCs between they given boundaries.

View File

@ -38,30 +38,10 @@ namespace Global
static const wchar_t ColorIdentifier[17][12] =
{
L"auto",
L"000000",//L"black",
L"0000FF",//L"blue",
L"00FFFF",//L"cyan",
L"00FF00",// L"green",
L"FF00FF",//L"magenta",
L"FF0000",//L"red",
L"FFFF00",//L"yellow",
L"FFFFFF",//L"white",
L"darkBlue",
L"darkCyan",
L"darkGreen",
L"darkMagenta",
L"darkRed",
L"darkYellow",
L"darkGray",
L"lightGray"
};
static const wchar_t ColorNameIdentifier[17][12] =
{
L"auto",
L"black",
L"blue",
L"cyan",
L"green",
L"green",
L"magenta",
L"red",
L"yellow",
@ -75,6 +55,7 @@ namespace Global
L"darkGray",
L"lightGray"
};
static const wchar_t UnderlineCode[56][16] =
{
L"none",

View File

@ -38,83 +38,110 @@ namespace DocFileFormat
{
HeaderAndFooterTable::HeaderAndFooterTable (FileInformationBlock* fib, POLE::Stream* pTableStream)
{
m_nCurrentIndex = 0;
VirtualStreamReader tableReader (pTableStream, fib->m_FibWord97.fcPlcfHdd, fib->m_nWordVersion);
VirtualStreamReader tableReader (pTableStream, fib->m_FibWord97.fcPlcfHdd, fib->m_bOlderVersion);
if (fib->m_FibWord97.fcPlcfHdd > tableReader.GetSize()) return;
unsigned int tableSize = fib->m_FibWord97.lcbPlcfHdd / 4;//in bytes
if ( tableSize < 1 || fib->m_RgLw97.ccpHdr <1 )
return;
int* table = new int[tableSize];
for (unsigned int i = 0; i < tableSize; ++i)
if ( ( tableSize > 0 ) && ( fib->m_RgLw97.ccpHdr > 0 ) )
{
table[i] = tableReader.ReadInt32();
}
int* table = new int[tableSize];
int initialPos = fib->m_RgLw97.ccpText + fib->m_RgLw97.ccpFtn;
int count = 0;
int pos = (fib->m_FibBase.fComplex || fib->m_nWordVersion == 0) ? 6 : 0;
//the first 6 _entries are about footnote and endnote formatting -Word97 so skip these
std::vector<std::vector<CharacterRange*>*> arHeadersFooters;
if (fib->m_nWordVersion == 2)
{
count = ( tableSize - 1);
}
else
{
count = ( tableSize - pos - 1) / 6;
arHeadersFooters.push_back(&m_arEvenHeaders);
arHeadersFooters.push_back(&m_arOddHeaders);
arHeadersFooters.push_back(&m_arEvenFooters);
arHeadersFooters.push_back(&m_arOddFooters);
arHeadersFooters.push_back(&m_arFirstHeaders);
arHeadersFooters.push_back(&m_arFirstFooters);
}
for (int i = 0; i < count; ++i)
{
//Even Header
if (fib->m_nWordVersion == 2)
for (unsigned int i = 0; i < tableSize; ++i)
{
table[i] = tableReader.ReadInt32();
}
int initialPos = fib->m_RgLw97.ccpText + fib->m_RgLw97.ccpFtn;
//the first 6 _entries are about footnote and endnote formatting
//so skip these _entries
int pos = (fib->m_FibBase.fComplex || !fib->m_bOlderVersion) ? 6 : 0;
int count = ( tableSize - pos - 2) / 6;
for (int i = 0; i < count; ++i)
{
//Even Header
if ( table[pos] == table[pos + 1] )
{
m_arCommonHeadersFooters.push_back( NULL );
m_arEvenHeaders.push_back( NULL );
}
else
{
m_arCommonHeadersFooters.push_back( new CharacterRange( initialPos + table[pos], table[pos + 1] - table[pos]) );
m_arEvenHeaders.push_back( new CharacterRange( ( initialPos + table[pos] ), ( table[pos + 1] - table[pos] ) ) );
}
pos++;
//Odd Header
if ( table[pos] == table[pos + 1] )
{
m_arOddHeaders.push_back( NULL );
}
else
{
m_arOddHeaders.push_back( new CharacterRange( ( initialPos + table[pos] ), ( table[pos + 1] - table[pos] ) ) );
}
pos++;
//Even Footer
if ( table[pos] == table[pos + 1] )
{
m_arEvenFooters.push_back( NULL );
}
else
{
m_arEvenFooters.push_back( new CharacterRange( ( initialPos + table[pos] ), ( table[pos + 1] - table[pos] ) ) );
}
pos++;
//Odd Footer
if ( table[pos] == table[pos + 1] )
{
m_arOddFooters.push_back( NULL );
}
else
{
m_arOddFooters.push_back( new CharacterRange( ( initialPos + table[pos] ), ( table[pos + 1] - table[pos] ) ) );
}
pos++;
//First Page Header
if ( table[pos] == table[pos + 1] )
{
m_arFirstHeaders.push_back (NULL);
}
else
{
m_arFirstHeaders.push_back (new CharacterRange( ( initialPos + table[pos] ), ( table[pos + 1] - table[pos] ) ));
}
pos++;
if (pos >= tableSize)
break;
//First Page Footers
if ( table[pos] == table[pos + 1] )
{
m_arFirstFooters.push_back( NULL );
}
else
{
m_arFirstFooters.push_back( new CharacterRange( ( initialPos + table[pos] ), ( table[pos + 1] - table[pos] ) ) );
}
pos++;
}
else
{
for (size_t j = 0; j < 6; j++)
{
if ( table[pos] == table[pos + 1] )
{
arHeadersFooters[j]->push_back( NULL );
}
else
{
arHeadersFooters[j]->push_back( new CharacterRange( initialPos + table[pos], table[pos + 1] - table[pos]) );
}
pos++;
if (pos >= tableSize) break;
}
}
if (pos >= tableSize) break;
RELEASEARRAYOBJECTS(table);
}
RELEASEARRAYOBJECTS(table);
}
HeaderAndFooterTable::~HeaderAndFooterTable()
@ -125,7 +152,5 @@ namespace DocFileFormat
for_each (m_arFirstHeaders.begin(), m_arFirstHeaders.end(), DeleteDynamicObject());
for_each (m_arOddFooters.begin(), m_arOddFooters.end(), DeleteDynamicObject());
for_each (m_arOddHeaders.begin(), m_arOddHeaders.end(), DeleteDynamicObject());
for_each (m_arCommonHeadersFooters.begin(), m_arCommonHeadersFooters.end(), DeleteDynamicObject());
}
}

View File

@ -34,12 +34,10 @@
#include "CharacterRange.h"
#include "FileInformationBlock.h"
#define GET_CHARS_RANGE(NAME) inline CharacterRange* Get##NAME(int nIndex)\
{\
#define GET_CHARS_RANGE(NAME) inline CharacterRange* Get##NAME(int nIndex) {\
if (m_ar##NAME.empty()) return NULL; \
if (nIndex < (int)m_ar##NAME.size()) return m_ar##NAME[nIndex];\
return NULL; \
}\
return NULL; } \
namespace DocFileFormat
{
@ -56,17 +54,8 @@ namespace DocFileFormat
GET_CHARS_RANGE (EvenFooters);
GET_CHARS_RANGE (OddFooters);
inline CharacterRange* GetNextHeaderFooter()
{
if (m_nCurrentIndex < m_arCommonHeadersFooters.size())
return m_arCommonHeadersFooters[m_nCurrentIndex++];
return NULL;
}
private:
size_t m_nCurrentIndex;
std::vector<CharacterRange*> m_arCommonHeadersFooters;
std::vector<CharacterRange*> m_arFirstHeaders;
std::vector<CharacterRange*> m_arEvenHeaders;
std::vector<CharacterRange*> m_arOddHeaders;

View File

@ -71,7 +71,7 @@ namespace DocFileFormat
if (fc < 0) break;
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
if ( tai.fInTable )
{
@ -84,7 +84,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph( cp, 0x7fffffff );
cp = writeParagraph( cp );
}
}

View File

@ -152,53 +152,37 @@ namespace DocFileFormat
}
OutlineListDescriptor::OutlineListDescriptor( unsigned char * data, int length )
{
if (length < 212)
int pos = 0;
for (int i = 0 ; i < 9; i++)
{
//int sz = FormatUtils::BytesToUChar(data, 0, length);
int pos = 0;
for (int i = 0 ; i < 9; i++)
{
lvl[i].Parse(data + pos, 1);
pos += 1;
}
lvl[i].Parse(data + pos, length - pos);
pos += 16;
}
else
fRestartHdr = FormatUtils::BytesToUChar(data, pos, length); pos += 2;
fSpareOlst2 = FormatUtils::BytesToUChar(data, pos, length); pos += 2;
fSpareOlst3 = FormatUtils::BytesToUChar(data, pos, length); pos += 2;
fSpareOlst4 = FormatUtils::BytesToUChar(data, pos, length); pos += 2;
short strLen = length - pos;
while (strLen > 0)
{
int pos = 0;
for (int i = 0 ; i < 9; i++)
{
lvl[i].Parse(data + pos, length - pos);
pos += 16;
}
fRestartHdr = FormatUtils::BytesToUChar(data, pos, length); pos += 2;
fSpareOlst2 = FormatUtils::BytesToUChar(data, pos, length); pos += 2;
fSpareOlst3 = FormatUtils::BytesToUChar(data, pos, length); pos += 2;
fSpareOlst4 = FormatUtils::BytesToUChar(data, pos, length); pos += 2;
short strLen = length - pos;
while (strLen > 0)
{
if (data[strLen + 20 - 1] != 0)
break;
strLen--;
}
if (strLen > 0)
{
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(xst), data + 20, ( strLen ), ENCODING_WINDOWS_1250);
}
if (data[strLen + 20 - 1] != 0)
break;
strLen--;
}
if (strLen > 0)
{
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(xst), data + 20, ( strLen ), ENCODING_WINDOWS_1250);
}
}
ByteStructure* OutlineListDescriptor::ConstructObject(VirtualStreamReader* reader, int length)
{
int sz = GetSize(reader->nWordVersion);
unsigned char *data = reader->ReadBytes(sz, true);
OutlineListDescriptor *newObject = new OutlineListDescriptor(data, sz);
unsigned char *data = reader->ReadBytes(212, true);
OutlineListDescriptor *newObject = new OutlineListDescriptor(data, 212);
delete []data;

View File

@ -143,13 +143,8 @@ namespace DocFileFormat
std::wstring xst; //64 chars ansi
public:
static const int STRUCTURE_SIZE = 212;
static const int STRUCTURE_SIZE_OLD = 10;
public:
static const int GetSize(int nWordVersion)
{
return (nWordVersion == 2) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length );
virtual ~OutlineListDescriptor();

View File

@ -49,7 +49,7 @@ namespace DocFileFormat
{
if ( fib->m_FibWord97.lcbPlfLfo > 0 )
{
VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLfo, fib->m_nWordVersion);
VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLfo, fib->m_bOlderVersion);
if (fib->m_FibWord97.fcPlfLfo > reader.GetSize()) return;

View File

@ -77,7 +77,7 @@ namespace DocFileFormat
//this papx has no istd, so use PX to parse it
unsigned char *bytes = reader->ReadBytes( cbGrpprlPapx, true );
PropertyExceptions* px = new PropertyExceptions( bytes, cbGrpprlPapx, reader->nWordVersion);
PropertyExceptions* px = new PropertyExceptions( bytes, cbGrpprlPapx, reader->olderVersion);
grpprlPapx = new ParagraphPropertyExceptions( *(px->grpprl) );
RELEASEOBJECT( px );
@ -85,7 +85,7 @@ namespace DocFileFormat
//read the group of chpx sprms
bytes = reader->ReadBytes( cbGrpprlChpx, true );
grpprlChpx = new CharacterPropertyExceptions( bytes, cbGrpprlChpx, reader->nWordVersion );
grpprlChpx = new CharacterPropertyExceptions( bytes, cbGrpprlChpx, reader->olderVersion );
RELEASEARRAYOBJECTS( bytes );
//read the number text
@ -116,10 +116,6 @@ namespace DocFileFormat
void NumberingLevelDescriptor::Parse(unsigned char * data, int length )
{
if (length < 16)
{
return;
}
bEnabled = true;
nfc = FormatUtils::BytesToUChar(data, 0, length);

View File

@ -45,7 +45,7 @@ namespace DocFileFormat
{
if ( fib->m_FibWord97.lcbPlfLst > 0 )
{
VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLst, fib->m_nWordVersion);
VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLst, fib->m_bOlderVersion);
if (fib->m_FibWord97.fcPlfLst > reader.GetSize()) return;

View File

@ -110,7 +110,7 @@ namespace DocFileFormat
int countText = m_document->FIB->m_RgLw97.ccpText;
int countTextRel = m_document->FIB->m_RgLw97.ccpText - 1;
while (cp < countText && cp >= 0)
while (cp < countText)
{
fc = m_document->FindFileCharPos(cp);
@ -120,7 +120,7 @@ namespace DocFileFormat
if (papx)
{
TableInfo tai(papx, m_document->nWordVersion);
TableInfo tai(papx);
if (tai.fInTable)
{
int cpStart = cp;
@ -135,7 +135,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph(cp, countTextRel);
cp = writeParagraph(cp);
}
}
else

View File

@ -124,7 +124,7 @@ public:
if (m_Data)
{
rdByte = (m_Position < m_Size) ? m_Data[m_Position] : 0;
rdByte = m_Data[m_Position];
m_Position += sizeof(rdByte);
}

View File

@ -338,9 +338,9 @@ namespace DocFileFormat
}
std::wstring NumberingMapping::GetNumberFormatWideString(int nfc, int nWordVersion)
std::wstring NumberingMapping::GetNumberFormatWideString(int nfc, bool bOlderVersion)
{
if (nWordVersion > 0 && nfc > 5)
if (bOlderVersion && nfc > 5)
{
if (nfc == 0xff) return std::wstring( L"bullet");
else return std::wstring( L"none");
@ -633,7 +633,7 @@ namespace DocFileFormat
if ((chpxs != NULL) && (!chpxs->empty()))
{
PictureDescriptor pict(chpxs->front(), m_document->DataStream, fcEnd - fc, m_document->nWordVersion);
PictureDescriptor pict(chpxs->front(), m_document->DataStream, fcEnd - fc, m_document->FIB->m_bOlderVersion);
if ((pict.mfp.mm > 98) && (pict.shapeContainer != NULL))
{

View File

@ -65,7 +65,7 @@ namespace DocFileFormat
static int FindIndexbyId(const std::list<ListData*>& listData, int id);
/// Converts the number format code of the binary format.
static std::wstring GetNumberFormatWideString(int nfc, int nWordVersion = 0);
static std::wstring GetNumberFormatWideString(int nfc, bool bOlderVersion = false);
virtual ~NumberingMapping();

View File

@ -60,7 +60,7 @@ namespace DocFileFormat
OfficeArtContent (const FileInformationBlock* pFIB, POLE::Stream* pStream): m_pDrawingGroupData(NULL), m_pBackgroud(NULL)
{
VirtualStreamReader oStearmReader(pStream, 0 , pFIB->m_nWordVersion);
VirtualStreamReader oStearmReader(pStream, 0 , pFIB->m_bOlderVersion);
if (pFIB->m_FibWord97.fcDggInfo > oStearmReader.GetSize()) return;

View File

@ -67,6 +67,7 @@ public:
BYTE compression;
BYTE filter;
public:
CMetaHeader()
{
cbSize = cbSave = 0;
@ -77,6 +78,48 @@ public:
}
//void ToEMFHeader(Gdiplus::ENHMETAHEADER3* pHeader)
//{
// if (NULL == pHeader)
// return;
// pHeader->iType = 0x00000001;
// pHeader->nSize = 88;
// pHeader->rclBounds.left = rcBounds.left;
// pHeader->rclBounds.top = rcBounds.top;
// pHeader->rclBounds.right = rcBounds.right;
// pHeader->rclBounds.bottom = rcBounds.bottom;
// // нужно перевести в мм
// pHeader->rclFrame.left = rcBounds.left;
// pHeader->rclFrame.top = rcBounds.top;
// pHeader->rclFrame.right = rcBounds.right;
// pHeader->rclFrame.bottom = rcBounds.bottom;
// pHeader->dSignature = 0x464D4520;
// pHeader->nVersion = 0x00010000;
// pHeader->nBytes = cbSize;
// pHeader->nRecords = 1;
// pHeader->nHandles = 0;
// pHeader->sReserved = 0;
// pHeader->nDescription = 0;
// pHeader->offDescription = 0;
// pHeader->nPalEntries = 0;
// pHeader->szlDevice.cx = 200;
// pHeader->szlDevice.cy = 200;
// // нужно перевести в мм
// pHeader->szlMillimeters.cx = 100;
// pHeader->szlMillimeters.cy = 100;
//}
void ToWMFHeader(WmfPlaceableFileHeader* pHeader)
{
if (NULL == pHeader)

View File

@ -32,111 +32,97 @@
#pragma once
#include "OleObject.h"
#include "WordDocument.h"
namespace DocFileFormat
{
OleObject::OleObject( const CharacterPropertyExceptions* chpx, WordDocument* document)
: bLinked(false), updateMode(NoLink), isEquation(false), isEmbedded (false), oleStorage(NULL)
OleObject::OleObject( const CharacterPropertyExceptions* chpx, StructuredStorageReader* docStorage, bool bOlderVersion_ )
: bLinked(false), updateMode(NoLink), bOlderVersion(bOlderVersion_), isEquation(false), isEmbedded (false)
{
if (!document) return;
if (!docStorage) return;
if (!chpx) return;
nWordVersion = document->nWordVersion;
ObjectId = getOleEntryName( chpx );
StructuredStorageReader* docStorage = document->GetStorage();
oleStorage = docStorage->GetStorage();
if (!oleStorage) return;
std::wstring sObjectId( ObjectId.begin(), ObjectId.end() );
std::wstring name = L"ObjectPool/" + sObjectId + L"/";
HRESULT res = S_OK;
bool bOle = processOleStream( name + L"Ole" );
bool bCompObj = bLinked ? processLinkInfoStream( name + L"LinkInfo" ):
processCompObjStream( name + L"CompObj" );
if (bOle || bCompObj)
{
processPICStream( name + L"PIC" );
processMETAStream( name + L"META" );
processEquationNativeStream( name + L"Equation Native" );
}
else if (nWordVersion > 0)
{
int fc = pictureDesciptor.GetFcPic( chpx );
POLE::Stream* ObjectPoolStorage = new POLE::Stream(oleStorage, L"ObjectPool");
if ( fc >= 0 )
{
POLE::Stream* pOleStream = document->GetDocumentStream();
pictureDesciptor.parse( pOleStream, fc, 0xffffff, nWordVersion);
if (ObjectPoolStorage)
{
ObjectId = getOleEntryName( chpx );
VirtualStreamReader reader(pOleStream, pOleStream->tell(), nWordVersion);
std::wstring sObjectId( ObjectId.begin(), ObjectId.end() );
{
std::wstring name = L"ObjectPool/" + sObjectId + L"/";
processOleStream( name + L"Ole" );
int pos = reader.GetPosition();
short a1 = reader.ReadInt16();
short a2 = reader.ReadInt16();
short a3 = reader.ReadInt16();
int lcb = reader.ReadInt32();
//short a4 = reader.ReadInt16();
//short a5 = reader.ReadInt16();
//short a6 = reader.ReadInt16();
//short a7 = reader.ReadInt16();
int lcb1 = reader.ReadInt32();
ClipboardFormat = Program = reader.ReadLengthPrefixedAnsiString(0xffff);
short a10 = reader.ReadInt16();
short a11 = reader.ReadInt16();
short a12 = reader.ReadInt16();
short a14 = reader.ReadInt16();
//int lcb = 5000;//reader.ReadInt32();
int szHeader = reader.GetPosition() - pos;
int szData = reader.ReadInt32();
if (szData > lcb)
if ( bLinked )
{
szData = szData >> 16;
processLinkInfoStream( name + L"LinkInfo" );
}
unsigned char* bytes = reader.ReadBytes( szData, true );
if (bytes)
else
{
emeddedData = std::string((char*)bytes, szData);
delete []bytes;
processCompObjStream( name + L"CompObj" );
}
processPICStream( name + L"PIC" );
processEquationNativeStream( name + L"Equation Native" );
}
delete ObjectPoolStorage;
}
}
bool OleObject::processLinkInfoStream( const std::wstring& linkStream )
void OleObject::processLinkInfoStream( const std::wstring& linkStream )
{
try
{
POLE::Stream* pLinkStream = NULL;
HRESULT res = S_OK;
POLE::Stream* pLinkStream = NULL;
HRESULT res = S_OK;
pLinkStream = new POLE::Stream(oleStorage, linkStream);
pLinkStream = //oleStorage->stream(linkStream);
new POLE::Stream(oleStorage, linkStream);
if ( pLinkStream )
{
VirtualStreamReader reader( pLinkStream, 0, false);
processLinkInfoStream(reader);
if ( pLinkStream )
{
VirtualStreamReader reader( pLinkStream, 0, false);
delete pLinkStream;
return true;
}
//there are two versions of the Link string, one contains ANSI characters, the other contains
//unicode characters.
//Both strings seem not to be standardized:
//The length prefix is a character count EXCLUDING the terminating zero
//Read the ANSI version
short cch = reader.ReadInt16();
unsigned char* str = reader.ReadBytes( cch, true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &this->Link, str, cch, ENCODING_WINDOWS_1250 );
RELEASEARRAYOBJECTS( str );
//skip the terminating zero of the ANSI string
//even if the characters are ANSI chars, the terminating zero has 2 bytes
reader.ReadBytes( 2, false );
//skip the next 4 bytes (flags?)
reader.ReadBytes( 4, false );
//Read the Unicode version
this->Link.clear();
cch = reader.ReadInt16();
str = reader.ReadBytes( ( cch * 2 ), true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &this->Link, str, ( cch * 2 ), ENCODING_UTF16 );
RELEASEARRAYOBJECTS( str );
//skip the terminating zero of the Unicode string
reader.ReadBytes( 2, false );
delete pLinkStream;
}
}
catch (...)
{
}
return false;
}
void OleObject::processEquationNativeStream( const std::wstring& eqStream )
@ -169,32 +155,7 @@ void OleObject::processEquationNativeStream( const std::wstring& eqStream )
{
}
}
void OleObject::processMETAStream( const std::wstring& metaStream )
{
try
{
HRESULT res = S_OK;
POLE::Stream* pMETAStream = new POLE::Stream(oleStorage, metaStream);
if ( pMETAStream )
{
pictureDesciptor.Type = wmf;
VirtualStreamReader reader( pMETAStream, 0, false);
pictureDesciptor.mfp.mm = reader.ReadUInt16();
pictureDesciptor.mfp.xExt = reader.ReadUInt16();
pictureDesciptor.mfp.yExt = reader.ReadUInt16();
pictureDesciptor.mfp.hMf = reader.ReadUInt16();
pictureDesciptor.embeddedDataSize = reader.GetSize() - 8;
pictureDesciptor.embeddedData = reader.ReadBytes( pictureDesciptor.embeddedDataSize, true );
}
}
catch (...)
{
}
}
void OleObject::processPICStream( const std::wstring& picStream )
{
try
@ -209,54 +170,20 @@ void OleObject::processPICStream( const std::wstring& picStream )
int sz = reader.GetSize();
int cbHeader = reader.ReadUInt32();
int cbHeader = reader.ReadUInt32();
unsigned char* bytes = NULL;
pictureDesciptor.mfp.mm = reader.ReadInt16();
pictureDesciptor.mfp.xExt = reader.ReadInt16();
pictureDesciptor.mfp.yExt = reader.ReadInt16();
pictureDesciptor.mfp.hMf = reader.ReadInt16();
reader.ReadBytes(4, false);
int x = reader.ReadUInt32();
int y = reader.ReadUInt32();
pictureDesciptor.dxaGoal = reader.ReadUInt32();
pictureDesciptor.dyaGoal = reader.ReadUInt32();
int x = reader.ReadUInt32();
int y = reader.ReadUInt32();
pictureDesciptor.dyaGoal = reader.ReadUInt32();
pictureDesciptor.dxaGoal = reader.ReadUInt32();
unsigned char* data = reader.ReadBytes(16, true);
delete []data;
reader.ReadBytes(20, false);
pictureDesciptor.mx = reader.ReadUInt32();
pictureDesciptor.my = reader.ReadUInt32();
pictureDesciptor.dxaCropLeft = reader.ReadInt32();
pictureDesciptor.dyaCropTop = reader.ReadInt32();
pictureDesciptor.dxaCropRight = reader.ReadInt32();
pictureDesciptor.dyaCropBottom = reader.ReadInt32();
// borders
int bytesCount = (nWordVersion > 0) ? 2 : 4;
bytes = reader.ReadBytes( bytesCount, true );
pictureDesciptor.brcTop = new BorderCode( bytes, bytesCount );
RELEASEARRAYOBJECTS( bytes );
bytes = reader.ReadBytes( bytesCount, true );
pictureDesciptor.brcLeft = new BorderCode( bytes, bytesCount );
RELEASEARRAYOBJECTS( bytes );
bytes = reader.ReadBytes( bytesCount, true );
pictureDesciptor.brcBottom = new BorderCode( bytes, bytesCount );
RELEASEARRAYOBJECTS( bytes );
bytes = reader.ReadBytes( bytesCount, true );
pictureDesciptor.brcRight = new BorderCode( bytes, bytesCount );
RELEASEARRAYOBJECTS( bytes );
int etc = sz - reader.GetPosition();
unsigned char* data2 = reader.ReadBytes(etc, true);
delete []data2;
}
}
catch (...)
@ -264,7 +191,7 @@ void OleObject::processPICStream( const std::wstring& picStream )
}
}
bool OleObject::processCompObjStream( const std::wstring& compStream )
void OleObject::processCompObjStream( const std::wstring& compStream )
{
try
{
@ -272,23 +199,36 @@ bool OleObject::processCompObjStream( const std::wstring& compStream )
POLE::Stream* pCompStream = new POLE::Stream(oleStorage, compStream);
if ( (pCompStream) && (!pCompStream->fail()) )
if ( pCompStream )
{
VirtualStreamReader reader( pCompStream, 0, false);
processCompObjStream(reader);
//skip the CompObjHeader
reader.ReadBytes( 28, false );
unsigned int sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
{
UserType = reader.ReadLengthPrefixedAnsiString(sz_obj);
sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
ClipboardFormat = reader.ReadLengthPrefixedAnsiString(sz_obj);
sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
Program = reader.ReadLengthPrefixedAnsiString(sz_obj);
}
delete pCompStream;
return true;
}
}
catch (...)
{
}
return false;
}
bool OleObject::processOleStream( const std::wstring& oleStreamName )
void OleObject::processOleStream( const std::wstring& oleStreamName )
{
try
{
@ -297,87 +237,46 @@ bool OleObject::processOleStream( const std::wstring& oleStreamName )
pOleStream = new POLE::Stream(oleStorage, oleStreamName);
if ( (pOleStream) && (!pOleStream->fail()))
if ( pOleStream )
{
VirtualStreamReader reader( pOleStream, 0, false );
processOleStream(reader);
VirtualStreamReader reader( pOleStream, 0, false );
delete pOleStream;
//skip version
reader.ReadBytes( 4, false );
return true;
//read the embedded/linked flag
int flag = reader.ReadInt32();
bLinked = FormatUtils::BitmaskToBool( flag, 0x1 );
//Link update option
this->updateMode = (LinkUpdateOption)reader.ReadInt32();
switch ( this->updateMode )
{
case NoLink:
{
this->UpdateMode = L"NoLink";
}
break;
case Always:
{
this->UpdateMode = L"Always";
}
break;
case OnCall:
{
this->UpdateMode = L"OnCall";
}
break;
}
delete pOleStream;
}
}
catch (...)
{
}
return false;
}
void OleObject::processOleStream( VirtualStreamReader& reader )
{
//skip version
reader.ReadBytes( 4, false );
//read the embedded/linked flag
int flag = reader.ReadInt32();
bLinked = FormatUtils::BitmaskToBool( flag, 0x1 );
//Link update option
this->updateMode = (LinkUpdateOption)reader.ReadInt32();
switch ( this->updateMode )
{
case NoLink: UpdateMode = L"NoLink"; break;
case Always: UpdateMode = L"Always"; break;
case OnCall: UpdateMode = L"OnCall"; break;
}
}
void OleObject::processLinkInfoStream( VirtualStreamReader& reader )
{
short cch = reader.ReadInt16();
unsigned char* str = reader.ReadBytes( cch, true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &this->Link, str, cch, ENCODING_WINDOWS_1250 );
RELEASEARRAYOBJECTS( str );
//skip the terminating zero of the ANSI string
//even if the characters are ANSI chars, the terminating zero has 2 bytes
reader.ReadBytes( 2, false );
//skip the next 4 bytes (flags?)
reader.ReadBytes( 4, false );
//Read the Unicode version
this->Link.clear();
cch = reader.ReadInt16();
str = reader.ReadBytes( ( cch * 2 ), true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &this->Link, str, ( cch * 2 ), ENCODING_UTF16 );
RELEASEARRAYOBJECTS( str );
//skip the terminating zero of the Unicode string
reader.ReadBytes( 2, false );
}
void OleObject::processCompObjStream( VirtualStreamReader& reader )
{
//skip the CompObjHeader
reader.ReadBytes( 28, false );
unsigned int sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
{
UserType = reader.ReadLengthPrefixedAnsiString(sz_obj);
sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
ClipboardFormat = reader.ReadLengthPrefixedAnsiString(sz_obj);
sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
Program = reader.ReadLengthPrefixedAnsiString(sz_obj);
}
}
std::wstring OleObject::getOleEntryName( const CharacterPropertyExceptions* chpx )

View File

@ -32,11 +32,11 @@
#pragma once
#include "IVisitable.h"
#include "StructuredStorageReader.h"
#include "PictureDescriptor.h"
namespace DocFileFormat
{
class WordDocument;
class OleObject: public IVisitable
{
friend class OleObjectMapping;
@ -48,7 +48,7 @@ namespace DocFileFormat
Always = 1,
OnCall = 3
};
int nWordVersion;
bool bOlderVersion;
bool bLinked; // The the value is true, the object is a linked object
std::wstring ObjectId;
@ -68,22 +68,17 @@ namespace DocFileFormat
PictureDescriptor pictureDesciptor;
OleObject( const CharacterPropertyExceptions* chpx, WordDocument* document);
OleObject( const CharacterPropertyExceptions* chpx, StructuredStorageReader* docStorage, bool bOlderVersion_ );
virtual ~OleObject() {}
private:
POLE::Storage *oleStorage;
bool processLinkInfoStream ( const std::wstring& linkStream );
void processLinkInfoStream ( const std::wstring& linkStream );
void processEquationNativeStream( const std::wstring& eqStream );
void processPICStream ( const std::wstring& picStream );
void processMETAStream ( const std::wstring& metaStream );
bool processCompObjStream ( const std::wstring& compStream );
bool processOleStream ( const std::wstring& oleStreamName );
void processOleStream ( VirtualStreamReader& reader );
void processLinkInfoStream ( VirtualStreamReader& reader );
void processCompObjStream ( VirtualStreamReader& reader );
void processCompObjStream ( const std::wstring& compStream );
void processOleStream ( const std::wstring& oleStreamName );
std::wstring getOleEntryName ( const CharacterPropertyExceptions* chpx );
};

View File

@ -156,31 +156,26 @@ namespace DocFileFormat
private:
inline void copyEmbeddedObject( const OleObject* ole )
{
if ( ole == NULL ) return;
std::wstring clsid;
std::wstring exelChart = L"Excel.Chart";
if ( std::search( ole->Program.begin(), ole->Program.end(), exelChart.begin(), exelChart.end() ) == ole->Program.end() )
if ( ole != NULL )
{
clsid = ole->ClassId;
}
OleObjectFileStructure object_descr(OleObjectMapping::GetTargetExt( ole->ClipboardFormat ), ole->ObjectId, clsid);
std::wstring clsid;
std::wstring exelChart = L"Excel.Chart";
if (ole->nWordVersion == 2)
{
object_descr.clsid = ole->ClipboardFormat;
object_descr.bNativeOnly = true;
}
if (ole->isEquation || ole->isEmbedded || ole->nWordVersion == 2)
{
object_descr.data = ole->emeddedData;
}
if ( std::search( ole->Program.begin(), ole->Program.end(), exelChart.begin(), exelChart.end() ) == ole->Program.end() )
{
clsid = ole->ClassId;
}
OleObjectFileStructure object_descr(OleObjectMapping::GetTargetExt( ole->ClipboardFormat ), ole->ObjectId, clsid);
m_context->_docx->OleObjectsList.push_back(object_descr);
if (ole->isEquation || ole->isEmbedded)
{
object_descr.data = ole->emeddedData;
}
m_context->_docx->OleObjectsList.push_back(object_descr);
}
}
private:
ConversionContext* m_context;
PictureDescriptor* _pict;

View File

@ -135,101 +135,35 @@ namespace DocFileFormat
}
}
bool OpenXmlPackage::SaveEmbeddedObject( const std::wstring& fileName, const OleObjectFileStructure& object )
HRESULT OpenXmlPackage::SaveEmbeddedObject( const std::wstring& fileName, const std::string& data )
{
if (object.bNativeOnly)
{
POLE::Storage * storageOut = new POLE::Storage(fileName.c_str());
if ( (storageOut) && (storageOut->open(true, true)))
{
_UINT32 zero = 0, str_size = 0;
//Ole
BYTE dataOleInfo[] = {0x01,0x00,0x00,0x02,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
POLE::Stream oStream3(storageOut, L"\001Ole", true, 20);
oStream3.write(dataOleInfo, 20);
oStream3.flush();
//CompObj
BYTE dataCompObjHeader[28] = {0x01,0x00,0xfe,0xff,0x03,0x0a,0x00,0x00,0xff,0xff,0xff,0xff
,0x30,0x08,0x02
//,0x0a,0x00,0x03
,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46};
POLE::Stream oStream1(storageOut, L"\001CompObj", true, 28 + (object.clsid.length() + 5) +
(object.clsid.length() + 5) +
(object.clsid.length() + 5) + 4 * 4);
oStream1.write(dataCompObjHeader, 28);
str_size = object.clsid.length() + 1;
oStream1.write((BYTE*)&str_size, 4);
oStream1.write((BYTE*)object.clsid.c_str(), object.clsid.length());
oStream1.write((BYTE*)&zero, 1);
str_size = object.clsid.length() + 1;
oStream1.write((BYTE*)&str_size, 4);
oStream1.write((BYTE*)object.clsid.c_str(), object.clsid.length());
oStream1.write((BYTE*)&zero, 1);
str_size = object.clsid.length() + 1;
oStream1.write((BYTE*)&str_size, 4);
oStream1.write((BYTE*)object.clsid.c_str(), object.clsid.length());
oStream1.write((BYTE*)&zero, 1);
_UINT32 nUnicodeMarker = 0x71B239F4;
oStream1.write((BYTE*)&nUnicodeMarker, 4);
oStream1.write((BYTE*)&zero, 4); // UnicodeUserType
oStream1.write((BYTE*)&zero, 4); // UnicodeClipboardFormat
oStream1.write((BYTE*)&zero, 4); //
oStream1.flush();
//ObjInfo
BYTE dataObjInfo[] = {0x00,0x00,0x03,0x00,0x01,0x00};//{0x00,0x00,0x03,0x00,0x0D,0x00};
POLE::Stream oStream2(storageOut, L"\003ObjInfo", true, 6);
oStream2.write(dataObjInfo, 6);
oStream2.flush();
//Ole10Native
size_t nativeDataSize = object.data.length();
POLE::Stream streamData(storageOut, L"\001Ole10Native", true, nativeDataSize + 4);
streamData.write((BYTE*)&nativeDataSize, 4);
streamData.write((BYTE*)object.data.c_str(), nativeDataSize);
streamData.flush();
storageOut->close();
delete storageOut;
}
}
else
{
NSFile::CFileBinary file;
file.CreateFileW(fileName);
file.WriteFile((BYTE*)object.data.c_str(), (_UINT32)object.data.size());
file.CloseFile();
}
return true;
NSFile::CFileBinary file;
file.CreateFileW(fileName);
file.WriteFile((BYTE*)data.c_str(), (_UINT32)data.size());
file.CloseFile();
return S_OK;
}
bool OpenXmlPackage::SaveOLEObject( const std::wstring& fileName, const OleObjectFileStructure& object )
HRESULT OpenXmlPackage::SaveOLEObject( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure )
{
if (docFile == NULL) return false;
if (docFile == NULL) return S_FALSE;
POLE::Storage *storageOut = new POLE::Storage(fileName.c_str());
if (storageOut == NULL) return false;
if (storageOut == NULL) return S_FALSE;
if (storageOut->open(true, true)==false)
{
delete storageOut;
return false;
return S_FALSE;
}
POLE::Storage *storageInp = docFile->GetStorage()->GetStorage();
{
POLE::Stream* oleStorage = new POLE::Stream(storageInp, object.objectID);
POLE::Stream* oleStorage = new POLE::Stream(storageInp, oleObjectFileStructure.objectID);
if (oleStorage)
{
std::wstring path = L"ObjectPool/" + object.objectID;
std::wstring path = L"ObjectPool/" + oleObjectFileStructure.objectID;
std::list<std::wstring> entries = storageInp->entries_with_prefix(path);
for (std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); ++it)
@ -267,7 +201,7 @@ namespace DocFileFormat
storageOut->close();
delete storageOut;
return true;
return S_OK;
}
void OpenXmlPackage::RegisterDocPr()
{
@ -473,7 +407,10 @@ namespace DocFileFormat
return AddPart( mapping, L"word", fileName, VMLPictureMapping::GetContentType( blipType ), OpenXmlRelationshipTypes::Image );
}
int OpenXmlPackage::RegisterHyperlink(const IMapping* mapping, const std::wstring& link)
{
return AddPart(mapping, L"", link, L"", OpenXmlRelationshipTypes::Hyperlink, L"External");
}
int OpenXmlPackage::RegisterOLEObject(const IMapping* mapping, const std::wstring& objectType)
{
std::wstring fileName = ( std::wstring( L"embeddings/oleObject" ) + FormatUtils::IntToWideString( ++_oleCounter ) + OleObjectMapping::GetTargetExt(objectType));

View File

@ -102,16 +102,17 @@ namespace DocFileFormat
struct OleObjectFileStructure
{
bool bNativeOnly = false;
std::wstring ext;
std::wstring objectID;
std::wstring clsid;
std::string data;
OleObjectFileStructure(){}
OleObjectFileStructure( const std::wstring& _ext, const std::wstring& _objectID, const std::wstring&/*REFCLSID*/ _clsid ):
ext(_ext), objectID(_objectID), clsid(_clsid){}
ext(_ext), objectID(_objectID), clsid(_clsid){}
};
@ -161,8 +162,8 @@ namespace DocFileFormat
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 );
bool SaveOLEObject( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure );
bool SaveEmbeddedObject( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure );
HRESULT SaveOLEObject ( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure );
HRESULT SaveEmbeddedObject ( const std::wstring& fileName, const std::string& data );
void RegisterDocPr();
void RegisterDocument();
@ -177,6 +178,7 @@ namespace DocFileFormat
int RegisterEndnotes();
int RegisterComments();
int RegisterImage ( const IMapping* mapping, Global::BlipType blipType );
int RegisterHyperlink ( const IMapping* mapping, const std::wstring& link);
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 );

View File

@ -52,40 +52,38 @@ namespace DocFileFormat
//so used another bit setting
if ( size == 12 )
{
unsigned short nFlag = FormatUtils::BytesToInt16( bytes, 0, size );
if ( fTtpMode )
{
fSpare = FormatUtils::BitmaskToBool( nFlag, 0x0001 );
fUnk = FormatUtils::BitmaskToBool( nFlag, 0x0002 );
dcpTtpNext = nFlag;
fSpare = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0001 );
fUnk = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0002 );
dcpTtpNext = FormatUtils::BytesToInt16( bytes, 0, size );
dxaCol = FormatUtils::BytesToInt32( bytes, 4, size );
dymTableHeight = FormatUtils::BytesToInt32( bytes, 8, size );
}
else
{
fVolatile = FormatUtils::BitmaskToBool( nFlag, 0x0001 );
fUnk = FormatUtils::BitmaskToBool( nFlag, 0x0002 );
fDiffLines = FormatUtils::BitmaskToBool( nFlag, 0x0004 );
clMac = nFlag& 0x00FF;
fVolatile = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0001 );
fUnk = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0002 );
fDiffLines = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0004 );
clMac = FormatUtils::BytesToUInt16( bytes, 0, size ) & 0x00FF;
dxaCol = FormatUtils::BytesToInt32( bytes, 4, size );
dymLine = FormatUtils::BytesToInt32( bytes, 8, size );
dymHeight = dymLine;
dymHeight = FormatUtils::BytesToInt32( bytes, 8, size );
}
}
else if (size == 6)
{
unsigned short nFlag = FormatUtils::BytesToInt16( bytes, 0, size );
fVolatile = FormatUtils::BitmaskToBool( nFlag, 0x0001 );
fUnk = FormatUtils::BitmaskToBool( nFlag, 0x0002 );
fDiffLines = FormatUtils::BitmaskToBool( nFlag, 0x0004 );
clMac = nFlag & 0x000F;
fVolatile = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0001 );
fUnk = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0002 );
fDiffLines = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0004 );
clMac = FormatUtils::BytesToUChar( bytes, 0, size ) & 0x000F;
dxaCol = FormatUtils::BytesToInt16( bytes, 2, size );
dymLine = FormatUtils::BytesToInt16( bytes, 4, size );
dymHeight = dymLine;
dymHeight = FormatUtils::BytesToInt16( bytes, 4, size );
}
}
/*========================================================================================================*/

View File

@ -492,7 +492,7 @@ namespace DocFileFormat
pos++;
for( int i = 0; i < itbdDelMax; i++ )
for( int i=0; i < itbdDelMax; i++ )
{
XMLTools::XMLElement tab( L"w:tab" );

View File

@ -34,233 +34,51 @@
namespace DocFileFormat
{
ParagraphPropertyExceptions::ParagraphPropertyExceptions( unsigned char* bytes, int size, POLE::Stream* dataStream, int nWordVersion):
PropertyExceptions( ( bytes + 2 ), ( size - 2 ), nWordVersion)
{
if (size < 1) return;
ParagraphPropertyExceptions::ParagraphPropertyExceptions( unsigned char* bytes, int size, POLE::Stream* dataStream, bool oldVersion):
PropertyExceptions( ( bytes + 2 ), ( size - 2 ), oldVersion)
{
if ( size != 0 )
{
istd = FormatUtils::BytesToUInt16( bytes, 0, size );
}
if (nWordVersion > 1)
{
istd = bytes[0];
VirtualStreamReader *reader = NULL;
ReadExceptions(bytes + 7, size - 7, nWordVersion);
//There is a SPRM that points to an offset in the data stream,
//where a list of SPRM is saved.
for ( std::list<SinglePropertyModifier>::iterator iter = grpprl->begin(); iter != 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, oldVersion);
//parse the size of the external grpprl
unsigned char* sizebytes = reader->ReadBytes( 2, true );
unsigned int grpprlsize = FormatUtils::BytesToUInt16( sizebytes, 0, 2 );
RELEASEARRAYOBJECTS( sizebytes );
// RELEASEOBJECT( grpprl );
// grpprl = new std::list<SinglePropertyModifier>();
//
// MemoryStream oStream(bytes, size);
// int pos = 1;
// if (pos + 1 > size) return;
// unsigned char jc = oStream.ReadByte(); pos += 1;
// grpprl->push_back(SinglePropertyModifier(sprmOldPJc, 1, (BYTE*)&jc));
// if (pos + 1 > size) return;
// unsigned char fSideBySide = oStream.ReadByte(); pos += 1;
// grpprl->push_back(SinglePropertyModifier(sprmOldPFSideBySide, 1, (BYTE*)&fSideBySide));
//parse the external grpprl
unsigned char* grpprlBytes = reader->ReadBytes( grpprlsize, true );
// if (pos + 1 > size) return;
// unsigned char fKeep = oStream.ReadByte(); pos += 1;
// grpprl->push_back(SinglePropertyModifier(sprmOldPFKeep, 1, (BYTE*)&fKeep));
PropertyExceptions externalPx( grpprlBytes, grpprlsize, oldVersion );
// if (pos + 1 > size) return;
// unsigned char fKeepFollow = oStream.ReadByte(); pos += 1;
// grpprl->push_back(SinglePropertyModifier(sprmOldPFKeepFollow, 1, (BYTE*)&fKeepFollow));
// if (pos + 1 > size) return;
// unsigned char fPageBreakBefore = oStream.ReadByte(); pos += 1;
// grpprl->push_back(SinglePropertyModifier(sprmOldPPageBreakBefore, 1, (BYTE*)&fPageBreakBefore));
//
// if (pos + 1 > size) return;
// unsigned char flag = oStream.ReadByte(); pos += 1;
// unsigned char pcVert = GETBITS(flag, 4, 5);
// unsigned char pcHorz = GETBITS(flag, 6, 7);
// //grpprl->push_back(SinglePropertyModifier(sprmOldPPageBreakBefore, 1, &fPageBreakBefore));
// //grpprl->push_back(SinglePropertyModifier(sprmOldPPageBreakBefore, 1, &fPageBreakBefore));
// if (pos + 1 > size) return;
// unsigned char brcp = oStream.ReadByte(); pos += 1;
// grpprl->push_back(SinglePropertyModifier(sprmOldPBrcp, 1, (BYTE*)&brcp));
//
// if (pos + 1 > size) return;
// unsigned char brcl = oStream.ReadByte(); pos += 1;
// grpprl->push_back(SinglePropertyModifier(sprmOldPBrcl, 1, (BYTE*)&brcl));
// if (pos + 1 > size) return;
// unsigned char nfcSeqNumb = oStream.ReadByte(); pos += 1;
// grpprl->push_back(SinglePropertyModifier(sprmOldPPageBreakBefore, 1, (BYTE*)&nfcSeqNumb));
//
// if (pos + 1 > size) return;
// unsigned char nnSeqNumb = oStream.ReadByte(); pos += 1;
// grpprl->push_back(SinglePropertyModifier(sprmOldPNLvlAnm, 1, (BYTE*)&nnSeqNumb));
//
// if (pos + 2 > size) return;
// unsigned short dxaRight = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPDxaRight, 2, (BYTE*)&dxaRight));
//
// if (pos + 2 > size) return;
// unsigned short dxaLeft = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPDxaLeft, 2, (BYTE*)&dxaLeft));
//
// if (pos + 2 > size) return;
// unsigned short dxaLeft1 = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPDxaLeft1, 2, (BYTE*)&dxaLeft1));
//
// if (pos + 2 > size) return;
// unsigned short dyaLine = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPDyaLine, 2, (BYTE*)&dyaLine));
//
// if (pos + 2 > size) return;
// unsigned short dyaBefore = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPDyaBefore, 2, (BYTE*)&dyaBefore));
//
// if (pos + 2 > size) return;
// unsigned short dyaAfter = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPDyaAfter, 2, (BYTE*)&dyaAfter));
////phe - 6
// if (pos + 6 > size) return;
//
// //oStream.ReadUInt16();
// //oStream.ReadUInt16();
// //oStream.ReadUInt16();
// if (pos + 1 > size) return;
// unsigned char fInTable = oStream.ReadUInt16(); pos += 1;
// grpprl->push_back(SinglePropertyModifier(sprmOldPFInTable, 1, (BYTE*)&fInTable));
//
// if (pos + 1 > size) return;
// unsigned char fTtp = oStream.ReadUInt16(); pos += 1;
// grpprl->push_back(SinglePropertyModifier(sprmOldPTtp, 1, (BYTE*)&fTtp));
//
// if (pos + 2 > size) return;
// unsigned short ptap = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPPageBreakBefore, 2, (BYTE*)&ptap));
// if (pos + 2 > size) return;
// unsigned short dxaAbs = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPDxaAbs, 2, (BYTE*)&dxaAbs));
//
// if (pos + 2 > size) return;
// unsigned short dyaAbs = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPDyaAbs, 2, (BYTE*)&dyaAbs));
// if (pos + 2 > size) return;
// unsigned short dxaWidth = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPDxaWidth, 2, (BYTE*)&dxaWidth));
//
// if (pos + 2 > size) return;
// unsigned short brcTop = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPBrcTop10, 2, (BYTE*)&brcTop));
//
// if (pos + 2 > size) return;
// unsigned short brcLeft = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPBrcLeft10, 2, (BYTE*)&brcLeft));
//
// if (pos + 2 > size) return;
// unsigned short brcBottom = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPBrcBottom10, 2, (BYTE*)&brcBottom));
//
// if (pos + 2 > size) return;
// unsigned short brcRight = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPBrcRight10, 2, (BYTE*)&brcRight));
// if (pos + 2 > size) return;
// unsigned short brcBetween = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPBrcBetween10, 2, (BYTE*)&brcBetween));
//
// if (pos + 2 > size) return;
// unsigned short brcBar = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPBrcBar10, 2, (BYTE*)&brcBar));
//
// if (pos + 2 > size) return;
// unsigned short dxaFromText = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPPageBreakBefore, 2, (BYTE*)&dxaFromText));
//
// if (pos + 2 > size) return;
// unsigned short dyaFromText = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPFromText10, 2, (BYTE*)&dyaFromText));
//
// if (pos + 1 > size) return;
// unsigned char wr = oStream.ReadByte(); pos += 1;
// grpprl->push_back(SinglePropertyModifier(sprmOldPWr, 1, &wr));
//
// if (pos + 1 > size) return;
// unsigned char zz = oStream.ReadByte(); pos += 1;
//
// if (pos + 1 > size) return;
// unsigned char fTransparent = oStream.ReadByte(); pos += 1;
//
// if (pos + 1 > size) return;
// unsigned char fBiDi = oStream.ReadByte(); pos += 1;
// grpprl->push_back(SinglePropertyModifier(sprmPFBiDi, 1, &fBiDi));
//
// if (pos + 1 > size) return;
// unsigned char bSpare = oStream.ReadByte(); pos += 1;
//
// if (pos + 2 > size) return;
// unsigned short dyaHeight = oStream.ReadUInt16(); pos += 2;
// unsigned char fMinHeight = GETBIT(dyaHeight, 15);
// dyaHeight = GETBITS(dyaHeight, 0, 14);
// grpprl->push_back(SinglePropertyModifier(sprmOldTDyaRowHeight, 2, (BYTE*)&dyaHeight));
// //grpprl->push_back(SinglePropertyModifier(sprmOldTDyaRowHeight, 1, &fMinHeight));
//
// if (pos + 2 > size) return;
// unsigned short shd = oStream.ReadUInt16(); pos += 2;
// grpprl->push_back(SinglePropertyModifier(sprmOldPShd, 2, (BYTE*)&shd));
// if (pos + 2 > size) return;
// unsigned short itbdMac = oStream.ReadUInt16(); pos += 2;
// if (itbdMac > 0)
// {
// short *tabs = new short[itbdMac + 1];
// for (unsigned short i = 0; i < itbdMac; i++)
// {
// tabs[i + 1] = oStream.ReadUInt16(); pos += 2;
// }
// grpprl->push_back(SinglePropertyModifier(sprmPChgTabs, 2 * (itbdMac + 1), (BYTE*)tabs));
// delete []tabs;
// }
}
else
{
istd = FormatUtils::BytesToUInt16( bytes, 0, size );
VirtualStreamReader *reader = NULL;
//There is a SPRM that points to an offset in the data stream,
//where a list of SPRM is saved.
for ( std::list<SinglePropertyModifier>::iterator iter = grpprl->begin(); iter != 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, nWordVersion);
//parse the size of the external grpprl
unsigned char* sizebytes = reader->ReadBytes( 2, true );
unsigned int grpprlsize = FormatUtils::BytesToUInt16( sizebytes, 0, 2 );
RELEASEARRAYOBJECTS( sizebytes );
//parse the external grpprl
unsigned char* grpprlBytes = reader->ReadBytes( grpprlsize, true );
PropertyExceptions externalPx( grpprlBytes, grpprlsize, nWordVersion );
//assign the external grpprl
RELEASEOBJECT( grpprl );
grpprl = new std::list<SinglePropertyModifier>( *(externalPx.grpprl) );
//remove the sprmPHugePapx
grpprl->remove( sprm );
RELEASEARRAYOBJECTS( grpprlBytes );
RELEASEOBJECT( reader )
break;
}
}
//assign the external grpprl
RELEASEOBJECT( grpprl );
grpprl = new std::list<SinglePropertyModifier>( *(externalPx.grpprl) );
//remove the sprmPHugePapx
grpprl->remove( sprm );
RELEASEARRAYOBJECTS( grpprlBytes );
RELEASEOBJECT( reader )
break;
}
}
}
}

View File

@ -59,6 +59,6 @@ namespace DocFileFormat
}
/// Parses the bytes to retrieve a PAPX
ParagraphPropertyExceptions( unsigned char* bytes, int size, POLE::Stream* dataStream, int nWordVersion);
ParagraphPropertyExceptions( unsigned char* bytes, int size, POLE::Stream* dataStream, bool oldVersion);
};
}

View File

@ -44,7 +44,7 @@
namespace DocFileFormat
{
/// Parses the CHPX for a fcPic an loads the PictureDescriptor at this offset
PictureDescriptor::PictureDescriptor(CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size, int nWordVersion)
PictureDescriptor::PictureDescriptor(CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size, bool oldVersion)
:
dxaGoal(0), dyaGoal(0), mx(0), my(0), Type(jpg), mfp(), dxaCropLeft(0), dyaCropTop(0),
dxaCropRight(0), dyaCropBottom(0), brcTop(NULL), brcLeft(NULL), brcBottom(NULL), brcRight(NULL), dxaOrigin(0), dyaOrigin(0),
@ -55,7 +55,7 @@ namespace DocFileFormat
if ( fc >= 0 )
{
parse( stream, fc, size, nWordVersion);
parse( stream, fc, size, oldVersion);
}
}
PictureDescriptor::PictureDescriptor()
@ -82,11 +82,11 @@ namespace DocFileFormat
RELEASEARRAYOBJECTS(embeddedData);
RELEASEARRAYOBJECTS(embeddedDataHeader);
}
void PictureDescriptor::parse(POLE::Stream* stream, int fc, int sz, int nWordVersion)
void PictureDescriptor::parse(POLE::Stream* stream, int fc, int sz, bool oldVersion)
{
Clear();
VirtualStreamReader reader(stream, fc, nWordVersion);
VirtualStreamReader reader(stream, fc, oldVersion);
int sz_stream = reader.GetSize();
@ -136,7 +136,7 @@ namespace DocFileFormat
int brcl = reader.ReadInt16();
// borders
int bytesCount = (nWordVersion > 0) ? 2 : 4;
int bytesCount = oldVersion ? 2 : 4;
bytes = reader.ReadBytes( bytesCount, true );
brcTop = new BorderCode( bytes, bytesCount );
@ -158,7 +158,7 @@ namespace DocFileFormat
dyaOrigin = reader.ReadInt16();
int pos_end = reader.GetPosition();
if (nWordVersion > 0)
if (oldVersion)
{
int flag = brcl;

View File

@ -83,16 +83,16 @@ namespace DocFileFormat
public:
// Parses the CHPX for a fcPic an loads the PictureDescriptor at this offset
PictureDescriptor ( );
PictureDescriptor ( CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size, int nWordVersion);
PictureDescriptor ( CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size, bool oldVersion);
virtual ~PictureDescriptor();
void parse( POLE::Stream* stream, int fc, int sz, int nWordVersion);
void parse( POLE::Stream* stream, int fc, int sz, bool oldVersion);
private:
// 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();

View File

@ -43,18 +43,18 @@ namespace DocFileFormat
friend class TextboxMapping;
protected:
int CP_LENGTH;
static const int CP_LENGTH = 4;
std::vector<int> CharacterPositions;
std::vector<ByteStructure*> Elements;
bool m_bIsValid;
public:
Plex(int structureLength, POLE::Stream* stream, unsigned int fc, unsigned int lcb, int nWordVersion)
: m_bIsValid(false), CP_LENGTH(/*nWordVersion == 2 ? 2 :*/ 4)
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, nWordVersion);
VirtualStreamReader reader(stream, (ULONG)fc, oldVersion);
if (fc > reader.GetSize()) return;

View File

@ -38,31 +38,22 @@ namespace DocFileFormat
{
PropertyExceptions::~PropertyExceptions()
{
RELEASEOBJECT( grpprl );
RELEASEOBJECT( this->grpprl );
}
PropertyExceptions::PropertyExceptions() : grpprl(NULL)
PropertyExceptions::PropertyExceptions(): grpprl(NULL)
{
grpprl = new std::list<SinglePropertyModifier>();
this->grpprl = new std::list<SinglePropertyModifier>();
}
PropertyExceptions::PropertyExceptions( const std::list<SinglePropertyModifier>& _grpprl ) : grpprl(NULL)
PropertyExceptions::PropertyExceptions( const std::list<SinglePropertyModifier>& grpprl )
{
grpprl = new std::list<SinglePropertyModifier>( _grpprl );
this->grpprl = new std::list<SinglePropertyModifier>( grpprl );
}
PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, int nWordVersion ) : grpprl(NULL)
PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool oldVersion ) : grpprl(NULL)
{
if (nWordVersion >= 2)//word 2.0 or 1.0
return;
ReadExceptions(bytes, size, nWordVersion);
}
void PropertyExceptions::ReadExceptions(unsigned char* bytes, int size, int nWordVersion)
{
RELEASEOBJECT( grpprl );
grpprl = new std::list<SinglePropertyModifier>();
this->grpprl = new std::list<SinglePropertyModifier>();
if ( ( bytes == NULL ) || ( size == 0 ) ) return;
@ -71,28 +62,24 @@ namespace DocFileFormat
int sprmStart = 0;
bool goOn = true;
int opCodeSize = (nWordVersion > 0) ? 1 : 2;
int opCodeSize = (oldVersion ? 1 : 2);
while ( goOn )
{
if ( ( sprmStart + opCodeSize ) <= size )
if ( ( sprmStart + opCodeSize ) < size )
{
unsigned short code = (nWordVersion > 0) ? FormatUtils::BytesToUChar ( bytes, sprmStart, size ) :
FormatUtils::BytesToUInt16 ( bytes, sprmStart, size ) ;
unsigned short code = oldVersion ? FormatUtils::BytesToUChar ( bytes, sprmStart, size ) :
FormatUtils::BytesToUInt16 ( bytes, sprmStart, size ) ;
OperationCode opCode = (OperationCode)(nWordVersion == 2 ? OpCode93To95[code] : code);
if (nWordVersion > 0 && opCode == 0)
if (oldVersion && code == 0)
{
sprmStart++;
continue;
}
//if (nWordVersion == 2)
// bytes[sprmStart]= (unsigned char)opCode;
}
OperationCode opCode = (OperationCode)code;
short opSize = -1;
if (nWordVersion > 0)
if (oldVersion)
{
opSize = (short)SinglePropertyModifier::GetOldOperandSize( (unsigned char)opCode );
}
@ -155,32 +142,25 @@ namespace DocFileFormat
}
}
if (opSize < 0)
{
break;
}
//length is 2byte for the opCode, lenByte for the length, opSize for the length of the operand
int sprmBytesSize = opCodeSize + lenByte + opSize;
unsigned char* sprmBytes = NULL;
sprmBytes = new unsigned char[sprmBytesSize];
//if ( size >= ( sprmStart + sprmBytesSize ) )
if ( size >= ( sprmStart + sprmBytesSize ) )
{
int sz = (std::min)(sprmBytesSize, size - sprmStart);
memcpy( sprmBytes, ( bytes + sprmStart ), sprmBytesSize );
memcpy( sprmBytes, ( bytes + sprmStart ), sz );
SinglePropertyModifier sprm( sprmBytes, sz, nWordVersion);
SinglePropertyModifier sprm( sprmBytes, sprmBytesSize, oldVersion );
grpprl->push_back( sprm );
sprmStart += sz;
sprmStart += sprmBytesSize;
}
else
{
goOn = false;
}
//else
//{
// goOn = false;
//}
RELEASEARRAYOBJECTS( sprmBytes );
}

View File

@ -33,7 +33,6 @@
#include "IVisitable.h"
#include "SinglePropertyModifier.h"
#include "MemoryStream.h"
#include <list>
@ -49,8 +48,6 @@ namespace DocFileFormat
virtual ~PropertyExceptions();
PropertyExceptions();
PropertyExceptions( const std::list<SinglePropertyModifier>& grpprl );
PropertyExceptions( unsigned char* bytes, int size, int nWordVersion );
void ReadExceptions( unsigned char* bytes, int size, int nWordVersion );
PropertyExceptions( unsigned char* bytes, int size, bool oldVersion );
};
}

View File

@ -48,13 +48,8 @@ namespace DocFileFormat
RevisionData::RevisionData( CharacterPropertyExceptions* chpx ) : Dttm(), Isbt(0), Type(NoRevision), Changes(NULL), RsidDel(0), RsidProp(0), Rsid(0)
{
if (!chpx) return;
if (!chpx->grpprl)
return;
bool collectRevisionData = true;
Changes = new std::list<SinglePropertyModifier>();
this->Changes = new std::list<SinglePropertyModifier>();
for ( std::list<SinglePropertyModifier>::iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); iter++ )
{

View File

@ -41,22 +41,19 @@ namespace DocFileFormat
friend class WordDocument;
private:
static const int SED_LENGTH = 12;
short fn;
short fnMpr;
int fcMpr;
/// A signed integer that specifies the position in the WordDocument Stream where a Sepx structure is located.
int fcSepx;
static const int STRUCTURE_SIZE = 12;
static const int STRUCTURE_SIZE_OLD = 6;
public:
static const int GetSize(int nWordVersion)
{
return (nWordVersion == 2) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
}
SectionDescriptor() : fn(0), fnMpr(0), fcMpr(0), fcSepx(0)
{
}
static const int STRUCTURE_SIZE = 12;
SectionDescriptor()
{
}
virtual ~SectionDescriptor()
{
@ -66,20 +63,10 @@ namespace DocFileFormat
{
SectionDescriptor *newObject = new SectionDescriptor();
if (reader->nWordVersion == 2)
{
newObject->fn = reader->ReadInt16();
newObject->fcSepx = reader->ReadInt32();
//newObject->fnMpr = reader->ReadInt16();
//newObject->fcMpr = reader->ReadInt16();
}
else
{
newObject->fn = reader->ReadInt16();
newObject->fcSepx = reader->ReadInt32();
newObject->fnMpr = reader->ReadInt16();
newObject->fcMpr = reader->ReadInt32();
}
newObject->fn = reader->ReadInt16();
newObject->fcSepx = reader->ReadInt32();
newObject->fnMpr = reader->ReadInt16();
newObject->fcMpr = reader->ReadInt32();
return static_cast<ByteStructure*>( newObject );
}

View File

@ -98,11 +98,11 @@ namespace DocFileFormat
XMLTools::XMLElement endnotePr (L"w:endnotePr");
XMLTools::XMLElement pgNumType (L"w:pgNumType");
HeaderAndFooterTable* pTable = _ctx->_doc->headerAndFooterTable;
HeaderAndFooterTable* pTable = _ctx->_doc->headerAndFooterTable;
if (pTable)
{
unsigned char fHF = _ctx->_doc->nWordVersion == 0 ? 255 : 0; //all headers & footers
unsigned char fHF = 255; //all headers & footers
for (std::list<SinglePropertyModifier>::iterator iter = sepx->grpprl->begin(); iter != sepx->grpprl->end(); ++iter)
{
switch (iter->OpCode)
@ -132,29 +132,17 @@ namespace DocFileFormat
}break;
}
}
if (_ctx->_doc->nWordVersion == 2)
{
if (GETBIT(fHF, 0)) WriteSectionStory (pTable->GetNextHeaderFooter(), std::wstring(L"headerReference"), std::wstring(L"even"));
if (GETBIT(fHF, 1)) WriteSectionStory (pTable->GetNextHeaderFooter(), std::wstring(L"headerReference"), std::wstring(L"default"));
if (GETBIT(fHF, 2)) WriteSectionStory (pTable->GetNextHeaderFooter(), std::wstring(L"footerReference"), std::wstring(L"even"));
if (GETBIT(fHF, 3)) WriteSectionStory (pTable->GetNextHeaderFooter(), std::wstring(L"footerReference"), std::wstring(L"default"));
if (GETBIT(fHF, 4)) WriteSectionStory (pTable->GetNextHeaderFooter(), std::wstring(L"headerReference"), std::wstring(L"first"));
if (GETBIT(fHF, 5)) WriteSectionStory (pTable->GetNextHeaderFooter(), std::wstring(L"footerReference"), std::wstring(L"first"));
}
else
{
// Header
// Header
if (FormatUtils::GetBitFromInt(fHF, 0)) WriteSectionStory (pTable->GetEvenHeaders (m_nSelectProperties), std::wstring(L"headerReference"), std::wstring(L"even"));
if (FormatUtils::GetBitFromInt(fHF, 1)) WriteSectionStory (pTable->GetOddHeaders (m_nSelectProperties), std::wstring(L"headerReference"), std::wstring(L"default"));
if (FormatUtils::GetBitFromInt(fHF, 4)) WriteSectionStory (pTable->GetFirstHeaders (m_nSelectProperties), std::wstring(L"headerReference"), std::wstring(L"first"));
if (FormatUtils::GetBitFromInt(fHF, 0)) WriteSectionStory (pTable->GetEvenHeaders (m_nSelectProperties), std::wstring(L"headerReference"), std::wstring(L"even"));
if (FormatUtils::GetBitFromInt(fHF, 1)) WriteSectionStory (pTable->GetOddHeaders (m_nSelectProperties), std::wstring(L"headerReference"), std::wstring(L"default"));
if (FormatUtils::GetBitFromInt(fHF, 4)) WriteSectionStory (pTable->GetFirstHeaders (m_nSelectProperties), std::wstring(L"headerReference"), std::wstring(L"first"));
// Footer
// Footer
if (FormatUtils::GetBitFromInt(fHF, 2)) WriteSectionStory (pTable->GetEvenFooters (m_nSelectProperties), std::wstring(L"footerReference"), std::wstring(L"even"));
if (FormatUtils::GetBitFromInt(fHF, 3)) WriteSectionStory (pTable->GetOddFooters (m_nSelectProperties), std::wstring(L"footerReference"), std::wstring(L"default"));
if (FormatUtils::GetBitFromInt(fHF, 5)) WriteSectionStory (pTable->GetFirstFooters (m_nSelectProperties), std::wstring(L"footerReference"), std::wstring(L"first"));
}
if (FormatUtils::GetBitFromInt(fHF, 2)) WriteSectionStory (pTable->GetEvenFooters (m_nSelectProperties), std::wstring(L"footerReference"), std::wstring(L"even"));
if (FormatUtils::GetBitFromInt(fHF, 3)) WriteSectionStory (pTable->GetOddFooters (m_nSelectProperties), std::wstring(L"footerReference"), std::wstring(L"default"));
if (FormatUtils::GetBitFromInt(fHF, 5)) 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)
@ -228,10 +216,7 @@ namespace DocFileFormat
case sprmOldSBOrientation:
case sprmSBOrientation:
//orientation
if (_ctx->_doc->nWordVersion == 2)
appendValueAttribute( &pgSz, L"w:orient", FormatUtils::MapValueToWideString( iter->Arguments[0] + 1, &PageOrientationMap[0][0], 3, 10 ) );
else
appendValueAttribute( &pgSz, L"w:orient", FormatUtils::MapValueToWideString( iter->Arguments[0], &PageOrientationMap[0][0], 3, 10 ) );
appendValueAttribute( &pgSz, L"w:orient", FormatUtils::MapValueToWideString( iter->Arguments[0], &PageOrientationMap[0][0], 3, 10 ) );
break;
//paper source

View File

@ -39,13 +39,9 @@ namespace DocFileFormat
{
public:
/// Parses the bytes to retrieve a SectionPropertyExceptions
SectionPropertyExceptions( unsigned char* bytes, int size, int nWordVersion ):
PropertyExceptions( bytes, size, nWordVersion ), isBidi(false)
SectionPropertyExceptions( unsigned char* bytes, int size, bool oldVersion ):
PropertyExceptions( bytes, size, oldVersion ), isBidi(false)
{
if (nWordVersion >= 2)
{
ReadExceptions(bytes, size, nWordVersion);
}
for ( std::list<SinglePropertyModifier>::iterator iter = grpprl->begin(); iter != grpprl->end(); iter++ )
{
SinglePropertyModifier sprm( *iter );

View File

@ -56,7 +56,7 @@ namespace DocFileFormat
//zoom
m_oXmlWriter.WriteNodeBegin ( L"w:zoom", TRUE );
m_oXmlWriter.WriteAttribute ( L"w:percent", FormatUtils::IntToWideString( dop->wScaleSaved > 0 ? dop->wScaleSaved : 100 ) );
m_oXmlWriter.WriteAttribute ( L"w:percent", FormatUtils::IntToWideString( dop->wScaleSaved ) );
if ( dop->zkSaved != 0 )
{

View File

@ -36,27 +36,21 @@
namespace DocFileFormat
{
SinglePropertyModifier::SinglePropertyModifier(OperationCode opCode, int argumentsSize, unsigned char* arguments) :
Arguments(NULL), OpCode(opCode), fSpec(false), Type(PAP), argumentsSize(argumentsSize), nWordVersion (2)
SinglePropertyModifier::SinglePropertyModifier( bool oldVersion_) :
Arguments(NULL), OpCode(sprmPIstd), fSpec(false), Type(PAP), argumentsSize(0), oldVersion (oldVersion_)
{
Arguments = new unsigned char[argumentsSize];
memcpy(Arguments, arguments, argumentsSize);
}
SinglePropertyModifier::SinglePropertyModifier(unsigned char* bytes, int size, int nWordVersion_) :
Arguments(NULL), OpCode(sprmPIstd), fSpec(false), Type(PAP), argumentsSize(0), nWordVersion (nWordVersion_)
SinglePropertyModifier::SinglePropertyModifier(unsigned char* bytes, int size, bool oldVersion_) :
Arguments(NULL), OpCode(sprmPIstd), fSpec(false), Type(PAP), argumentsSize(0), oldVersion (oldVersion_)
{
unsigned char opSize = 0;
unsigned char opCodeSize = 0;
if (nWordVersion > 0)
if (oldVersion)
{
opCodeSize = 1;
//first 1 byte are the operation code ...
unsigned char code = FormatUtils::BytesToUChar( bytes, 0, size );
OpCode = (OperationCode)(nWordVersion == 2 ? OpCode93To95[code] : code);
OpCode = (OperationCode)FormatUtils::BytesToUChar( bytes, 0, size );
if (OpCode == 0 && size == 4)
{
//так записывается rgb цвет (
@ -138,12 +132,9 @@ namespace DocFileFormat
}
else
{
argumentsSize = (std::min)(size - opCodeSize, (int)opSize);
if (argumentsSize > 0)
{
Arguments = new unsigned char[argumentsSize];
memcpy( Arguments, ( bytes + opCodeSize ), argumentsSize );
}
argumentsSize = opSize;
Arguments = new unsigned char[argumentsSize];
memcpy( Arguments, ( bytes + opCodeSize ), argumentsSize );
}
}
@ -151,13 +142,13 @@ namespace DocFileFormat
{
if ( spm.Arguments != NULL )
{
argumentsSize = spm.argumentsSize;
argumentsSize = spm.argumentsSize;
Arguments = new unsigned char[argumentsSize];
memcpy( Arguments, spm.Arguments, argumentsSize );
fSpec = spm.fSpec;
OpCode = spm.OpCode;
OpCode = spm.OpCode;
Type = spm.Type;
nWordVersion = spm.nWordVersion;
oldVersion = spm.oldVersion;
}
}
@ -189,7 +180,7 @@ namespace DocFileFormat
fSpec = spm.fSpec;
Type = spm.Type;
argumentsSize = spm.argumentsSize;
nWordVersion = spm.nWordVersion;
oldVersion = spm.oldVersion;
Arguments = new unsigned char[argumentsSize];

View File

@ -45,16 +45,10 @@ namespace DocFileFormat
TAP = 5
} SprmType;
static const int OpCode93To95[] =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 65, 66, 67, 0, 82, 83, 0, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 0, 0x085C, 0x085D, 0x4A5E, 0x485F, 0x4A60, 0x4A61, 0x085A, 0, 0, 0, 0, 0, 0, 0, 119, 120, 121, 122, 123, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x322A, 0, 0x3228, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 182, 183, 184, 0x560B, 0, 0, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 208,
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, 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
};
class SinglePropertyModifier
{
public:
int nWordVersion;
bool oldVersion;
/// The operation code identifies the property of the
/// PAP/CHP/PIC/SEP/TAP which sould be modified
OperationCode OpCode;
@ -67,11 +61,10 @@ namespace DocFileFormat
/// The Arguments size
unsigned int argumentsSize;
SinglePropertyModifier( int nWordVersion);
SinglePropertyModifier(bool oldVersion);
/// parses the unsigned char to retrieve a SPRM
SinglePropertyModifier( unsigned char* bytes, int size, int nWordVersion );
SinglePropertyModifier( unsigned char* bytes, int size, bool oldVersion );
SinglePropertyModifier( const SinglePropertyModifier& spm);
SinglePropertyModifier( OperationCode opCode, int argumentsSize, unsigned char* arguments);
bool operator == ( const SinglePropertyModifier& spm ) const;
bool operator != ( const SinglePropertyModifier& spm ) const;

View File

@ -69,7 +69,7 @@ namespace DocFileFormat
short cb_primitive = reader->ReadInt16();
if ((cb_primitive < 1) || (pos + cb_primitive > length))
if (pos + cb_primitive > length)
{
reader->Seek(reader->GetPosition() - 4, 0);
break;
@ -100,7 +100,7 @@ namespace DocFileFormat
Spa* pSpa = new Spa();
if (!pSpa) return NULL;
if (reader->nWordVersion > 0)
if (reader->olderVersion)
{
int fc = reader->ReadInt32();
pSpa->cTxbx = reader->ReadUInt16();

View File

@ -54,9 +54,9 @@ namespace DocFileFormat
static const int STRUCTURE_SIZE = 26;
static const int STRUCTURE_SIZE_OLD = 6;
static const int GetSize(int nWordVersion)
static const int GetSize(bool bOldVersion)
{
return (nWordVersion > 0) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
return bOldVersion ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
}
Spa();

View File

@ -177,8 +177,6 @@ namespace DocFileFormat
}
}
private:
unsigned char numberOfColumns;
/// An array of 16-bit signed integer that specifies horizontal distance in twips.

View File

@ -71,12 +71,12 @@ namespace DocFileFormat
parse( reader, (unsigned int)reader->GetPosition() );
}
StringTable( POLE::Stream* tableStream, unsigned int fc, unsigned int lcb, int nWordVersion ) :
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, nWordVersion);
VirtualStreamReader reader( tableStream, fc, older);
parse( &reader, fc, lcb ) ;
}
@ -123,37 +123,25 @@ namespace DocFileFormat
//read cData
long cDataStart = reader->GetPosition();
unsigned short cb = 0, elem_sz = 0;
//if (reader->nWordVersion == 2)
//{
// unsigned char * bytes = reader->ReadBytes(lcb, true);
// reader->Seek( (int)fc, 0/*STREAM_SEEK_SET*/ );
// delete []bytes;
//}
unsigned short c = reader->ReadUInt16();
if (reader->nWordVersion > 0)
if ( c != 0xFFFF )
{
cb = reader->ReadUInt16();
this->cbData = cb; // all size
}
else if (reader->nWordVersion == 0)
{
cb = reader->ReadUInt16();
if ( cb != 0xFFFF )
{
count_elements = cb;
}
if (reader->olderVersion)
this->cbData = (int)c; // all size
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();
}
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->nWordVersion == 0)
if (reader->olderVersion == false)
{
this->cbExtra = reader->ReadUInt16();
}

View File

@ -54,164 +54,43 @@ 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, fib->m_nWordVersion);
VirtualStreamReader tableReader( tableStream, fib->m_FibWord97.fcStshf, fib->m_bOlderVersion);
short cbStshi = fib->m_FibWord97.lcbStshf;
//unsigned char* test = tableReader.ReadBytes( cbStshi, true );
//read size of the STSHI
int stshiLengthBytesSize = 2;
unsigned char* stshiLengthBytes = tableReader.ReadBytes( stshiLengthBytesSize, true );
short cbStshi = FormatUtils::BytesToInt16( stshiLengthBytes, 0, stshiLengthBytesSize );
RELEASEARRAYOBJECTS( stshiLengthBytes );
//read the bytes of the STSHI
tableReader.Seek( ( fib->m_FibWord97.fcStshf + 2 ), 0/*STREAM_SEEK_SET*/ );
unsigned char* stshi = tableReader.ReadBytes( cbStshi, true );
//parses STSHI
this->stshi = new StyleSheetInformation( stshi, cbStshi );
RELEASEARRAYOBJECTS( stshi );
//create list of STDs
Styles = new std::vector<StyleSheetDescription*>();
if (fib->m_nWordVersion < 2)
for ( int i = 0; i < this->stshi->cstd; i++ )
{
//read size of the STSHI
int stshiLengthBytesSize = 2;
unsigned char* stshiLengthBytes = tableReader.ReadBytes( stshiLengthBytesSize, true );
short cbStshi = FormatUtils::BytesToInt16( stshiLengthBytes, 0, stshiLengthBytesSize );
RELEASEARRAYOBJECTS( stshiLengthBytes );
//read the bytes of the STSHI
tableReader.Seek( ( fib->m_FibWord97.fcStshf + 2 ), 0/*STREAM_SEEK_SET*/ );
unsigned char* stshi = tableReader.ReadBytes( cbStshi, true );
//get the cbStd
unsigned short cbStd = tableReader.ReadUInt16();
//parses STSHI
this->stshi = new StyleSheetInformation( stshi, cbStshi );
RELEASEARRAYOBJECTS( stshi );
for ( int i = 0; i < this->stshi->cstd; i++ )
if ( cbStd != 0 )
{
//get the cbStd
unsigned short cbStd = tableReader.ReadUInt16();
//read the STD bytes
unsigned char* std = tableReader.ReadBytes( cbStd, true );
if ( cbStd != 0 )
{
//read the STD bytes
unsigned char* std = tableReader.ReadBytes( cbStd, true );
//parse the STD bytes
Styles->push_back( new StyleSheetDescription( std, cbStd, (int)this->stshi->cbSTDBaseInFile, dataStream, fib->m_bOlderVersion) );
//parse the STD bytes
Styles->push_back( new StyleSheetDescription( std, cbStd, (int)this->stshi->cbSTDBaseInFile, dataStream, fib->m_nWordVersion) );
RELEASEARRAYOBJECTS( std );
}
else
{
Styles->push_back( NULL );
}
RELEASEARRAYOBJECTS( std );
}
}
else
{
unsigned short i, sz = 0;
tableReader.ReadUInt16();
unsigned short sz_names = tableReader.ReadUInt16();
sz = 2;
while(sz < sz_names)
else
{
unsigned short sz_name = tableReader.ReadByte(); sz++;
StyleSheetDescription* std = new StyleSheetDescription();
if (sz_name != 0 && sz_name < 0xde)
{
//user style
unsigned char *bytes = tableReader.ReadBytes( sz_name, true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &std->xstzName, bytes, sz_name, ENCODING_WINDOWS_1250 );
RELEASEARRAYOBJECTS( bytes );
}
// ms style
else if (sz_name == 0)
{
//defpr
}
else
{
int ind = 255 - sz_name;
std::wstring names [] = {L"Normal", L"Heading1", L"Heading2", L"Heading3", L"Heading4", L"Heading5", L"Heading6", L"Heading7",
L"Heading8", L"Heading9", L"FootnoteText", L"FootnoteReference", L"Header", L"Footer", L"IndexHeading", L"LineNumber"};
_StyleIdentifier sti[] = {Normal, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, Heading7, Heading8, Heading9,
FootnoteText, FootnoteReference, Header, Footer, IndexHeading, LineNumber};
std->sti = sti[ind];
std->xstzName = names[ind];
}
// 0 Normal standard PAP(standard PAP has all fields cleared to 0), standard CHP ( chp.hps = 20, all other fields set to 0).
//
// 255 Normal indent pap.dxaLeft = 720.
///* Heading levels */
// 254 heading 1 pap.dyaBefore = 240 (12 points), chp.fBold = negation of Normal style's chp.fBold, chp.kul = 1 (single underline), chp.hps = 24, chp.ftc = 2 .
// 253 heading 2 pap.dyaBefore = 120 (6 points), chp.fBold = negation of Normal style's chp.fBold, chp.hps = 24, chp.ftc = 2
// 252 heading 3 pap.dxaLeft = 360, chp.fBold = negation of Normal style's chp.fBold, chp.hps = 24;
// 251 heading 4 pap.dxaLeft = 360, chp.kul = 1 (single underline), chp.hps = 24;
// 250 heading 5 pap.dxaLeft = 720, chp.fBold = negation of Normal style's chp.fBold, chp.hps = 20;
// 249 heading 6 pap.dxaLeft = 720, chp.kul = 1 (single underline), chp.hps = 20;
// 248 heading 7 pap.dxaLeft = 720, chp.fItalic = negation of Normal style's chp.fItalic, chp.hps = 20;
// 247 heading 8 pap.dxaLeft = 720, chp.fItalic = negation of Normal style's chp.fItalic, chp.hps = 20;
// 246 heading 9 pap.dxaLeft = 720, chp.fItalic = negation of Normal style's chp.fItalic, chp.hps = 20;
// 245 footnote text chp.hps = 20
// 244 footnote reference chp.hps = 16; hpsPos = 6
// 243 header When running a U.S. system file:
// pap.itbdMac = 2, pap.rgdxaTab[0] = 3 * 1440, pap.rgtbd[0].jc = 1, pap.rgtbd[0].tlc = 0, pap.rgdxaTab[1] = 6* 1440, pap.rgtbd[1].jc = 1, pap.rgtbd[1].tlc = 0;
// When running an International metric system:
// pap.itbdMac = 2, pap.rgdxaTab[0] =3969, pap.rgtbd[0].jc = 1, pap.rgtbd[0].tlc = 0, pap.rgdxaTab[1] = 8504, pap.rgtbd[1].jc = 1, pap.rgtbd[1].tlc = 0;
// 242 footer When running a U.S. system file:
// pap.itbdMac = 2, pap.rgdxaTab[0] = 3 * 1440, pap.rgtbd[0].jc = 1, pap.rgtbd[0].tlc = 0, pap.rgdxaTab[1] = 6* 1440, pap.rgtbd[1].jc = 1, pap.rgtbd[1].tlc = 0;
// When running an International metric system:
// pap.itbdMac = 2, pap.rgdxaTab[0] =3969, pap.rgtbd[0].jc = 1, pap.rgtbd[0].tlc = 0, pap.rgdxaTab[1] = 8504, pap.rgtbd[1].jc = 1, pap.rgtbd[1].tlc = 0;
// 241 index heading same as properties for Normal style (stc == 0)
// 240 line number same as properties for Normal style (stc == 0)
Styles->push_back(std);
sz += sz_name < 0xde ? sz_name : 0;
}
unsigned short sz_chpxs = tableReader.ReadUInt16();
i = 0;
sz = 2;
while(sz < sz_chpxs)
{
unsigned short sz_chpx = tableReader.ReadByte();
sz++;
if (Styles->size() <= i)
{
StyleSheetDescription* std = new StyleSheetDescription();
Styles->push_back(std);
}
if (sz_chpx != 0 && sz_chpx != 255)
{
unsigned char *bytes = tableReader.ReadBytes( sz_chpx, true );
Styles->at(i)->chpx = new CharacterPropertyExceptions( bytes, sz_chpx , fib->m_nWordVersion);
RELEASEARRAYOBJECTS( bytes );
sz += sz_chpx;
}
i++;
}
unsigned short sz_papxs = tableReader.ReadUInt16();
i = 0;
sz = 2;
while(sz < sz_papxs)
{
unsigned short sz_papx = tableReader.ReadByte();
sz++;
if ( sz_papx != 255)
{
unsigned char *bytes = tableReader.ReadBytes( sz_papx, true );
Styles->at(i)->papx = new ParagraphPropertyExceptions( bytes, sz_papx, tableStream, fib->m_nWordVersion );
RELEASEARRAYOBJECTS( bytes );
sz += sz_papx;
}
i++;
}
unsigned short sz_Estcps = tableReader.ReadUInt16();
i = 0;
sz = 2;
while(sz < sz_Estcps)
{
Styles->at(i++)->istdBase = tableReader.ReadByte();
sz += 1;
Styles->push_back( NULL );
}
}
}

View File

@ -35,20 +35,7 @@
namespace DocFileFormat
{
/// Creates an empty STD object
StyleSheetDescription::StyleSheetDescription(): papx(NULL), chpx(NULL), tapx(NULL), sti(User),
fAutoRedef(false),
fHidden(false),
f97LidsSet(false),
fCopyLang(false),
fPersonalCompose(false),
fPersonalReply(false),
fPersonal(false),
fNoHtmlExport(false),
fSemiHidden(false),
fLocked(false),
fInternalUse(false),
stk(paragraph_style),
istdBase(0xffffff), cupx (0), istdNext(0xffffff), bchUpe(0)
StyleSheetDescription::StyleSheetDescription() : papx(NULL), chpx(NULL), tapx(NULL)
{
}
@ -61,8 +48,8 @@ namespace DocFileFormat
}
/// Parses the bytes to retrieve a StyleSheetDescription
StyleSheetDescription::StyleSheetDescription (unsigned char* bytes, int size, int cbStdBase, POLE::Stream* dataStream, int nWordVersion) :
papx(NULL), chpx(NULL), tapx(NULL), sti(User),
StyleSheetDescription::StyleSheetDescription (unsigned char* bytes, int size, int cbStdBase, POLE::Stream* dataStream, bool oldVersion) :
papx(NULL), chpx(NULL), tapx(NULL),
fAutoRedef(false),
fHidden(false),
f97LidsSet(false),
@ -73,9 +60,8 @@ namespace DocFileFormat
fNoHtmlExport(false),
fSemiHidden(false),
fLocked(false),
fInternalUse(false),
stk(paragraph_style),
istdBase(0xffffff), cupx (0), istdNext(0xffffff), bchUpe(0)
fInternalUse(false)
{
//parsing the base (fix part)
@ -146,7 +132,7 @@ namespace DocFileFormat
unsigned char characterCount = bytes[cbStdBase];
int upxOffset = 0;
if (nWordVersion > 0)
if (oldVersion)
{
name = new unsigned char[characterCount];//characters are zero-terminated, so 1 char has 2 bytes:
memcpy( name, ( bytes + cbStdBase + 1 ), ( characterCount ) );
@ -191,21 +177,21 @@ namespace DocFileFormat
{
//todooo не реализовано
//RELEASEOBJECT( tapx );
//tapx = new TablePropertyExceptions( upxBytes, cbUPX, dataStream, nWordVersion);
//tapx = new TablePropertyExceptions( upxBytes, cbUPX, dataStream, oldVersion);
}
break;
case 1:
{
RELEASEOBJECT( papx );
papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream, nWordVersion);
papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream, oldVersion);
}
break;
case 2:
{
RELEASEOBJECT( chpx );
chpx = new CharacterPropertyExceptions( upxBytes, cbUPX , nWordVersion);
chpx = new CharacterPropertyExceptions( upxBytes, cbUPX , oldVersion);
}
break;
}
@ -218,14 +204,14 @@ namespace DocFileFormat
case 0:
{
RELEASEOBJECT( papx );
papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream, nWordVersion );
papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream, oldVersion );
}
break;
case 1:
{
RELEASEOBJECT( chpx );
chpx = new CharacterPropertyExceptions( upxBytes, cbUPX, nWordVersion);
chpx = new CharacterPropertyExceptions( upxBytes, cbUPX, oldVersion);
}
break;
}
@ -238,7 +224,7 @@ namespace DocFileFormat
case 0:
{
RELEASEOBJECT( papx );
papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream, nWordVersion );
papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream, oldVersion );
}
break;
}
@ -251,7 +237,7 @@ namespace DocFileFormat
case 0:
{
RELEASEOBJECT( chpx );
chpx = new CharacterPropertyExceptions( upxBytes, cbUPX, nWordVersion);
chpx = new CharacterPropertyExceptions( upxBytes, cbUPX, oldVersion);
}
break;
}

View File

@ -385,7 +385,7 @@ namespace DocFileFormat
friend class StyleSheetMapping;
friend class CharacterPropertiesMapping;
public:
private:
/// The name of the style
std::wstring xstzName;
/// Invariant style identifier
@ -450,10 +450,11 @@ namespace DocFileFormat
/// If the style doesn't modify table properties, tapx is null.
TablePropertyExceptions* tapx;
public:
/// Creates an empty STD object
StyleSheetDescription();
virtual ~StyleSheetDescription();
/// Parses the bytes to retrieve a StyleSheetDescription
StyleSheetDescription( unsigned char* bytes, int size, int cbStdBase, POLE::Stream* dataStream, int nWordVersion);
StyleSheetDescription( unsigned char* bytes, int size, int cbStdBase, POLE::Stream* dataStream, bool older);
};
}

View File

@ -35,8 +35,7 @@
namespace DocFileFormat
{
/// Parses the bytes to retrieve a StyleSheetInformation
StyleSheetInformation::StyleSheetInformation (unsigned char* bytes, int size) :
cstd(0), cbSTDBaseInFile(0), fStdStylenamesWritten(false), stiMaxWhenSaved(0), istdMaxFixedWhenSaved(0), nVerBuiltInNamesWhenSaved(0), cbLSD(0)
StyleSheetInformation::StyleSheetInformation (unsigned char* bytes, int size)
{
if ((0 != size) || (NULL != bytes))
{

View File

@ -171,7 +171,7 @@ namespace DocFileFormat
if ( (*iter)->tapx != NULL )
{
std::vector<short> tableGrid;
TablePropertiesMapping* tpMapping = new TablePropertiesMapping (m_pXmlWriter, sheet, &tableGrid, NULL, false);
TablePropertiesMapping* tpMapping = new TablePropertiesMapping (m_pXmlWriter, sheet, &tableGrid, false);
(*iter)->tapx->Convert( tpMapping );
RELEASEOBJECT( tpMapping );
}
@ -234,44 +234,41 @@ namespace DocFileFormat
void StyleSheetMapping::writeRunDefaults( StyleSheet* sheet )
{
if ((sheet->stshi) && (!sheet->stshi->rgftcStandardChpStsh.empty()))
{
m_pXmlWriter->WriteNodeBegin( L"w:rPrDefault" );
m_pXmlWriter->WriteNodeBegin( L"w:rPr" );
m_pXmlWriter->WriteNodeBegin( L"w:rPrDefault" );
m_pXmlWriter->WriteNodeBegin( L"w:rPr" );
//write default fonts
m_pXmlWriter->WriteNodeBegin( L"w:rFonts", TRUE );
//write default fonts
m_pXmlWriter->WriteNodeBegin( L"w:rFonts", TRUE );
FontFamilyName* ffnAscii = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[0] ) );
if (ffnAscii)
m_pXmlWriter->WriteAttribute( L"w:ascii", FormatUtils::XmlEncode(ffnAscii->xszFtn, true));
FontFamilyName* ffnAscii = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[0] ) );
if (ffnAscii)
m_pXmlWriter->WriteAttribute( L"w:ascii", FormatUtils::XmlEncode(ffnAscii->xszFtn, true));
FontFamilyName* ffnAsia = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[1] ) );
if (ffnAsia)
m_pXmlWriter->WriteAttribute( L"w:eastAsia", FormatUtils::XmlEncode(ffnAsia->xszFtn, true));
FontFamilyName* ffnAsia = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[1] ) );
if (ffnAsia)
m_pXmlWriter->WriteAttribute( L"w:eastAsia", FormatUtils::XmlEncode(ffnAsia->xszFtn, true));
FontFamilyName* ffnAnsi = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[2] ) );
if (ffnAnsi)
m_pXmlWriter->WriteAttribute( L"w:hAnsi", FormatUtils::XmlEncode(ffnAnsi->xszFtn, true));
FontFamilyName* ffnAnsi = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[2] ) );
if (ffnAnsi)
m_pXmlWriter->WriteAttribute( L"w:hAnsi", FormatUtils::XmlEncode(ffnAnsi->xszFtn, true));
FontFamilyName* ffnComplex = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[3] ) );
if (ffnComplex)
m_pXmlWriter->WriteAttribute( L"w:cs", FormatUtils::XmlEncode(ffnComplex->xszFtn, true));
FontFamilyName* ffnComplex = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[3] ) );
if (ffnComplex)
m_pXmlWriter->WriteAttribute( L"w:cs", FormatUtils::XmlEncode(ffnComplex->xszFtn, true));
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( L"w:rFonts" );
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( L"w:rFonts" );
LanguageId langid(this->m_document->FIB->m_FibBase.lid);
std::wstring langcode = LanguageIdMapping::getLanguageCode( &langid );
LanguageId langid(this->m_document->FIB->m_FibBase.lid);
std::wstring langcode = LanguageIdMapping::getLanguageCode( &langid );
m_pXmlWriter->WriteNodeBegin( L"w:lang", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", langcode);
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( L"w:lang" );
m_pXmlWriter->WriteNodeBegin( L"w:lang", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", langcode);
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( L"w:lang" );
m_pXmlWriter->WriteNodeEnd( L"w:rPr" );
m_pXmlWriter->WriteNodeEnd( L"w:rPrDefault" );
}
m_pXmlWriter->WriteNodeEnd( L"w:rPr" );
m_pXmlWriter->WriteNodeEnd( L"w:rPrDefault" );
}
/*========================================================================================================*/

View File

@ -35,7 +35,7 @@
namespace DocFileFormat
{
TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, const std::vector<short>* grid_write, int gridIndex, int cellIndex) :
TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, int gridIndex, int cellIndex) :
PropertiesMapping(pWriter)
{
_width = 0;
@ -141,6 +141,10 @@ namespace DocFileFormat
}
break;
case sprmTDxaCol:
{
}break;
case sprmTCellPadding:
{
unsigned char first = iter->Arguments[0];
@ -280,8 +284,7 @@ namespace DocFileFormat
XMLTools::XMLAttribute tcWVal ( L"w:w", FormatUtils::IntToWideString( _width > 1 ? _width : nComputedCellWidth) );
XMLTools::XMLAttribute tcWType ( L"w:type", _width > 1 ? FormatUtils::MapValueToWideString( _ftsWidth, &Global::CellWidthTypeMap[0][0], 4, 5 ) :
(nComputedCellWidth > 0 ? L"dxa" : L"auto"));
XMLTools::XMLAttribute tcWType ( L"w:type", _width > 1 ? FormatUtils::MapValueToWideString( _ftsWidth, &Global::CellWidthTypeMap[0][0], 4, 5 ) : L"dxa" );
tcW.AppendAttribute( tcWType );
tcW.AppendAttribute( tcWVal );

View File

@ -58,7 +58,7 @@ namespace DocFileFormat
public:
virtual ~TableCellPropertiesMapping();
TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, const std::vector<short>* grid_write, int gridIndex, int cellIndex);
TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, int gridIndex, int cellIndex);
virtual void Apply( IVisitable* visited );
inline int GetGridSpan() const
@ -91,6 +91,6 @@ namespace DocFileFormat
BorderCode* _brcRight;
BorderCode* _brcBottom;
int _gridSpan;
int _gridSpan;
};
}

View File

@ -44,7 +44,7 @@ namespace DocFileFormat
bool fInnerTableCell;
unsigned int iTap;
TableInfo( ParagraphPropertyExceptions* papx, int nWordVersion):
TableInfo( ParagraphPropertyExceptions* papx ):
fInTable(false), fTtp(false), fInnerTtp(false), fInnerTableCell(false), iTap(0)
{
if ( papx != NULL )

View File

@ -106,7 +106,7 @@ namespace DocFileFormat
cellElements.clear();
}
void TableCell::Convert(IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, const std::vector<short>* grid_write, int& gridIndex, int nCellIndex)
void TableCell::Convert(IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, int& gridIndex, int nCellIndex)
{
if (NULL != mapping)
{
@ -123,7 +123,7 @@ namespace DocFileFormat
documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tc" );
//convert the properties
TableCellPropertiesMapping tcpMapping(documentMapping->GetXMLWriter(), grid, grid_write, gridIndex, nCellIndex);
TableCellPropertiesMapping tcpMapping(documentMapping->GetXMLWriter(), grid, gridIndex, nCellIndex);
if ( tapx != NULL )
{
@ -193,7 +193,7 @@ namespace DocFileFormat
cells.clear();
}
void TableRow::Convert(IMapping* mapping, const std::vector<short>* grid, const std::vector<short>* grid_write)
void TableRow::Convert(IMapping* mapping, const std::vector<short>* grid)
{
if ( mapping != NULL )
{
@ -215,7 +215,7 @@ namespace DocFileFormat
int fcRowEnd = documentMapping->findRowEndFc(cp, depth);
TablePropertyExceptions tapx ( documentMapping->findValidPapx( fcRowEnd ),
documentMapping->m_document->DataStream,
documentMapping->m_document->nWordVersion);
documentMapping->m_document->FIB->m_bOlderVersion);
std::list<CharacterPropertyExceptions*>* chpxs = documentMapping->m_document->GetCharacterPropertyExceptions( fcRowEnd, fcRowEnd + 1 );
TableRowPropertiesMapping trpMapping( documentMapping->GetXMLWriter(), *(chpxs->begin()) );
@ -234,7 +234,7 @@ namespace DocFileFormat
{
for ( std::list<TableCell>::iterator iter = cells.begin(); iter != cells.end(); iter++ )
{
iter->Convert( mapping, &tapx, grid, grid_write, gridIndex, nCellIndex++);
iter->Convert( mapping, &tapx, grid, gridIndex, nCellIndex++);
}
}
@ -293,7 +293,7 @@ namespace DocFileFormat
documentMapping = static_cast<DocumentMapping*>(mapping);
}
documentMapping->writeParagraph( cpStart, 0x7fffffff );
documentMapping->writeParagraph( cpStart );
}
}
@ -315,7 +315,7 @@ namespace DocFileFormat
papx = documentMapping->findValidPapx(fc);
TableInfo tai( papx, documentMapping->m_document->nWordVersion );
TableInfo tai( papx );
return ( ( tai.fInTable ) && ( ( ( documentMapping->m_document->Text->at( _cp ) == 0x0007 ) && ( tai.iTap <= 1 ) &&
@ -335,7 +335,7 @@ namespace DocFileFormat
papx = documentMapping->findValidPapx( fc );
TableInfo tai( papx, documentMapping->m_document->nWordVersion );
TableInfo tai( papx );
return ( ( tai.fInTable ) && ( ( ( documentMapping->m_document->Text->at( _cp ) == 0x0007 ) && ( tai.iTap <= 1 ) &&
( tai.fTtp ) ) ||
@ -355,7 +355,7 @@ namespace DocFileFormat
papx = documentMapping->findValidPapx( fc );
TableInfo tai( papx, documentMapping->m_document->nWordVersion );
TableInfo tai( papx );
return ( ( tai.fInTable ) && ( documentMapping->m_document->Text->at( _cp ) == 0x000D ) &&
( !IsCellMarker( _cp ) ) && ( !IsRowMarker( _cp ) ) );
@ -378,7 +378,7 @@ namespace DocFileFormat
papx = documentMapping->findValidPapx( fc );
TableInfo tai( papx, documentMapping->m_document->nWordVersion );
TableInfo tai( papx );
TableRow tableRow ( documentMapping, _cp );
TableCell tableCell ( documentMapping, _cp );
@ -390,7 +390,7 @@ namespace DocFileFormat
papx = documentMapping->findValidPapx( fc );
tai = TableInfo( papx, documentMapping->m_document->nWordVersion );
tai = TableInfo( papx );
if ( tai.iTap > _depth )
{
@ -405,7 +405,7 @@ namespace DocFileFormat
papx = documentMapping->findValidPapx( fc );
tai = TableInfo( papx, documentMapping->m_document->nWordVersion );
tai = TableInfo( papx );
paragraphBeginCP = _cp;
}
@ -516,21 +516,21 @@ namespace DocFileFormat
SectionPropertyExceptions* sepxBackup = documentMapping->_lastValidSepx;
//build the table grid
std::vector<short> grid, grid_write;
documentMapping->buildTableGrid( cpStart, depth, grid, grid_write );
std::vector<short> grid;
documentMapping->buildTableGrid( cpStart, depth, grid);
//find first row end
int fcRowEnd = documentMapping->findRowEndFc( cpStart, depth );
TablePropertyExceptions row1Tapx( documentMapping->findValidPapx( fcRowEnd ),
documentMapping->m_document->DataStream ,
documentMapping->m_document->nWordVersion);
documentMapping->m_document->FIB->m_bOlderVersion);
//start table
documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tbl" );
//Convert it
TablePropertiesMapping tpMapping( documentMapping->GetXMLWriter(), documentMapping->m_document->Styles, &grid, &grid_write );
TablePropertiesMapping tpMapping( documentMapping->GetXMLWriter(), documentMapping->m_document->Styles, &grid);
row1Tapx.Convert( &tpMapping );
@ -539,7 +539,7 @@ namespace DocFileFormat
for ( std::list<TableRow>::iterator iter = rows.begin(); iter != rows.end(); iter++ )
{
iter->Convert( mapping, &grid, &grid_write );
iter->Convert( mapping, &grid );
}
//close w:tbl

View File

@ -58,7 +58,7 @@ namespace DocFileFormat
void AddItem( const ITableCellElement& _tableCellElement );
bool IsEmpty() const;
void Clear();
void Convert( IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, const std::vector<short>* grid_write, int& gridIndex, int cellIndex );
void Convert( IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, int& gridIndex, int cellIndex );
~TableCell();
private:
@ -81,7 +81,7 @@ namespace DocFileFormat
void AddCell( const TableCell& _tableCell );
bool IsEmpty() const;
void Clear();
void Convert( IMapping* mapping, const std::vector<short>* grid, const std::vector<short>* grid_write );
void Convert( IMapping* mapping, const std::vector<short>* grid);
~TableRow();
private:

View File

@ -34,8 +34,8 @@
namespace DocFileFormat
{
TablePropertiesMapping::TablePropertiesMapping (XMLTools::CStringXmlWriter* pWriter, StyleSheet* styles, std::vector<short>* grid, std::vector<short>* grid_write, bool isTableStyleNeeded ):
PropertiesMapping(pWriter), _tblPr(NULL), _tblGrid(NULL), _tblBorders(NULL), _grid(grid), _grid_write(grid_write),
TablePropertiesMapping::TablePropertiesMapping (XMLTools::CStringXmlWriter* pWriter, StyleSheet* styles, std::vector<short>* grid, bool isTableStyleNeeded ):
PropertiesMapping(pWriter), _tblPr(NULL), _tblGrid(NULL), _tblBorders(NULL), _grid(grid),
brcLeft(NULL), brcTop(NULL), brcBottom(NULL), brcRight(NULL), brcHorz(NULL), brcVert(NULL), _styles(styles),
_isTableStyleNeeded(isTableStyleNeeded)
{
@ -75,8 +75,6 @@ namespace DocFileFormat
BYTE itcFirst = 0;
BYTE itcLim = 0;
bool bTableW = false;
for ( std::list<SinglePropertyModifier>::iterator iter = tapx->grpprl->begin(); iter != tapx->grpprl->end(); iter++ )
{
switch( iter->OpCode )
@ -107,8 +105,8 @@ namespace DocFileFormat
break;
case sprmTTableWidth:
{
//preferred table width
{ //preferred table width
unsigned char fts = iter->Arguments[0];
short width = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize );
@ -121,8 +119,6 @@ namespace DocFileFormat
tblW.AppendAttribute( w );
_tblPr->AppendChild( tblW );
bTableW = true;
}
break;
case sprmTMerge:
@ -390,20 +386,8 @@ namespace DocFileFormat
break;
}
}
if (false == bTableW)
{
XMLTools::XMLElement tblW( L"w:tblW");
XMLTools::XMLAttribute w( L"w:w", L"0");
XMLTools::XMLAttribute type( L"w:type", L"auto" );
tblW.AppendAttribute( type );
tblW.AppendAttribute( w );
_tblPr->AppendChild( tblW );
}
//indent
//indent
if ( tblIndent != 0 )
{
XMLTools::XMLElement tblInd( L"w:tblInd");
@ -417,7 +401,7 @@ namespace DocFileFormat
_tblPr->AppendChild( tblInd );
}
//append floating props
//append floating props
if ( tblpPr.GetAttributeCount() > 0 )
{
_tblPr->AppendChild( tblpPr );
@ -511,7 +495,7 @@ namespace DocFileFormat
bWriteGridCol = true;
else
{
for ( size_t i = 0, nSize = _grid_write->size(); i < nSize; i++ )
for ( size_t i = 0, nSize = _grid->size(); i < nSize; i++ )
{
if(_grid->at(i) % DocFileFormat::gc_nZeroWidth != 0)
{
@ -522,10 +506,10 @@ namespace DocFileFormat
}
if(true == bWriteGridCol)
{
for ( size_t i = 0; i < _grid_write->size(); i++ )
for ( size_t i = 0; i < _grid->size(); i++ )
{
XMLTools::XMLElement gridCol( L"w:gridCol");
XMLTools::XMLAttribute gridColW( L"w:w", FormatUtils::IntToWideString( _grid_write->at( i ) ) );
XMLTools::XMLAttribute gridColW( L"w:w", FormatUtils::IntToWideString( _grid->at( i ) ) );
gridCol.AppendAttribute( gridColW );
_tblGrid->AppendChild( gridCol );
}

View File

@ -71,7 +71,7 @@ namespace DocFileFormat
class TablePropertiesMapping: public PropertiesMapping, public IMapping
{
public:
TablePropertiesMapping( XMLTools::CStringXmlWriter* writer, StyleSheet* styles, std::vector<short>* grid, std::vector<short>* grid_write, bool isTableStyleNeeded = true );
TablePropertiesMapping( XMLTools::CStringXmlWriter* writer, StyleSheet* styles, std::vector<short>* grid, bool isTableStyleNeeded = true );
virtual ~TablePropertiesMapping();
void Apply( IVisitable* visited );
@ -83,7 +83,6 @@ namespace DocFileFormat
StyleSheet* _styles;
std::vector<short>* _grid;
std::vector<short>* _grid_write;
BorderCode* brcLeft;
BorderCode* brcTop;

View File

@ -41,8 +41,8 @@ namespace DocFileFormat
{
public:
/// Parses the bytes to retrieve a TAPX
TablePropertyExceptions(unsigned char* bytes, int size, int nWordVersion) :
PropertyExceptions(bytes, size, nWordVersion), m_bSkipShading97 (FALSE)
TablePropertyExceptions(unsigned char* bytes, int size, bool oldVersion) :
PropertyExceptions(bytes, size, oldVersion), m_bSkipShading97 (FALSE)
{
//not yet implemented
}
@ -53,10 +53,10 @@ namespace DocFileFormat
}
/// Extracts the TAPX SPRMs out of a PAPX
TablePropertyExceptions (ParagraphPropertyExceptions* papx, POLE::Stream* dataStream, int nWordVersion) :
TablePropertyExceptions (ParagraphPropertyExceptions* papx, POLE::Stream* dataStream, bool oldVersion) :
PropertyExceptions()
{
VirtualStreamReader oBinReader(dataStream, 0, nWordVersion);
VirtualStreamReader oBinReader(dataStream, 0, oldVersion);
m_bSkipShading97 = FALSE;
@ -87,7 +87,7 @@ namespace DocFileFormat
unsigned char* grpprlBytes = oBinReader.ReadBytes(grpprlSize, true);
//parse the grpprl
PropertyExceptions externalPx(grpprlBytes, grpprlSize, nWordVersion);
PropertyExceptions externalPx(grpprlBytes, grpprlSize, oldVersion);
for (std::list<SinglePropertyModifier>::iterator oIter = externalPx.grpprl->begin(); oIter != externalPx.grpprl->end(); ++oIter)
{

View File

@ -160,7 +160,7 @@ namespace DocFileFormat
break;
papx_prev = papx;
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
if ( tai.fInTable )
{
@ -173,7 +173,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph( cp, 0x7fffffff );
cp = writeParagraph( cp );
}
}
_isTextBoxContent = false;

View File

@ -414,7 +414,6 @@ namespace DocFileFormat
}
strStyle += L"width:" + strWidth + L"pt;" + L"height:" + strHeight + L"pt;";
m_pXmlWriter->WriteAttribute( L"style", strStyle);
if (m_isOlePreview)
@ -426,21 +425,6 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( L"o:bullet", L"1" );
}
{//borders color
if (pict->brcTop)
m_pXmlWriter->WriteAttribute( L"o:bordertopcolor",
pict->brcTop->ico.empty() ? FormatUtils::IntToFormattedWideString(pict->brcTop->cv, L"#%06x") : pict->brcTop->ico);
if (pict->brcLeft)
m_pXmlWriter->WriteAttribute( L"o:borderleftcolor",
pict->brcTop->ico.empty() ? FormatUtils::IntToFormattedWideString(pict->brcLeft->cv, L"#%06x") : pict->brcLeft->ico);
if (pict->brcBottom)
m_pXmlWriter->WriteAttribute( L"o:borderbottomcolor",
pict->brcTop->ico.empty() ? FormatUtils::IntToFormattedWideString(pict->brcBottom->cv, L"#%06x") : pict->brcBottom->ico);
if (pict->brcRight)
m_pXmlWriter->WriteAttribute( L"o:borderrightcolor",
pict->brcTop->ico.empty() ? FormatUtils::IntToFormattedWideString(pict->brcRight->cv, L"#%06x") : pict->brcRight->ico);
}
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
if (CopyPicture(pict))
@ -455,7 +439,7 @@ namespace DocFileFormat
writePictureBorder( L"bordertop", pict->brcTop );
writePictureBorder( L"borderleft", pict->brcLeft );
writePictureBorder( L"borderbottom", pict->brcBottom );
writePictureBorder( L"borderright", pict->brcRight );
writePictureBorder( L"borderright", pict->brcRight );
}
m_pXmlWriter->WriteNodeEnd( L"v:shape" );
@ -492,16 +476,12 @@ namespace DocFileFormat
WmfPlaceableFileHeader oWmfHeader = {};
oMetaHeader.ToWMFHeader(&oWmfHeader);
int lLenHeader = 22 + (pict->embeddedDataHeader ? 114 : 0);
int lLenHeader = 114 + 22;
unsigned char *newData = new unsigned char[pict->embeddedDataSize + lLenHeader];
memcpy(newData, (unsigned char *)(&oWmfHeader), 22);
if (pict->embeddedDataHeader)
{
memcpy(newData + 22, pict->embeddedDataHeader, 114 );
}
memcpy(newData + 22, pict->embeddedDataHeader, 114 );
memcpy(newData + lLenHeader, pict->embeddedData, pict->embeddedDataSize);

View File

@ -1312,7 +1312,7 @@ namespace DocFileFormat
//write the blip
if (oBlip)
{
VirtualStreamReader reader(m_context->_doc->WordDocumentStream, oBlip->foDelay, m_context->_doc->nWordVersion);
VirtualStreamReader reader(m_context->_doc->WordDocumentStream, oBlip->foDelay, m_context->_doc->FIB->m_bOlderVersion);
switch (oBlip->btWin32)
{

View File

@ -40,6 +40,7 @@
#include "VMLShapeTypeMapping.h"
#include "TwipsValue.h"
#include "EmuValue.h"
#include "MemoryStream.h"
#include "RGBColor.h"
#include "FixedPointNumber.h"

View File

@ -39,8 +39,8 @@
class VirtualStreamReader : public IBinaryReader
{
public:
VirtualStreamReader (POLE::Stream* _stream, ULONG _position , int _nWordVersion) :
nWordVersion(_nWordVersion), stream(_stream), position(_position)
VirtualStreamReader (POLE::Stream* _stream, ULONG _position , bool _olderVersion) :
olderVersion(_olderVersion), stream(_stream), position(_position)
{
if ( stream == NULL )return;
@ -192,8 +192,7 @@ public:
unsigned char* xstz = NULL;
unsigned char* cch = NULL;
if (nWordVersion > 0)
if (olderVersion)
{
int cchSize = 1;
cch = ReadBytes( cchSize, true );
@ -286,7 +285,7 @@ public:
return result;
}
int nWordVersion;
bool olderVersion;
private:
POLE::uint64 position;

View File

@ -59,7 +59,7 @@ namespace DocFileFormat
bytes = reader->ReadBytes( length, true );
//It's a real string table
if (reader->nWordVersion > 0)
if (reader->olderVersion)
{
FormatUtils::GetSTLCollectionFromBytes<WideString>( newObject, bytes, length, ENCODING_WINDOWS_1250 );
}

View File

@ -97,11 +97,10 @@ namespace DocFileFormat
m_pStorage = NULL;
officeArtContent = NULL;
nWordVersion = 0;
bOlderVersion = false;
bDocumentCodePage = false;
nDocumentCodePage = ENCODING_WINDOWS_1250;
nFontsCodePage = ENCODING_WINDOWS_1250;
}
WordDocument::~WordDocument()
@ -117,7 +116,7 @@ namespace DocFileFormat
namespace DocFileFormat
{
int WordDocument::LoadDocument(const std::wstring & fileName, const std::wstring & password)
long WordDocument::LoadDocument(const std::wstring & fileName, const std::wstring & password)
{
m_sFileName = fileName;
m_sPassword = password;
@ -132,11 +131,8 @@ namespace DocFileFormat
if (m_pStorage->SetFile (m_sFileName.c_str()) == false)
{
if (false == LoadDocumentFlat())
{
Clear();
return AVS_ERROR_FILEFORMAT;
}
Clear();
return AVS_ERROR_FILEFORMAT;
}
//-----------------------------------------------------------------------------------------------------------------
if (m_pStorage->GetStream (L"WordDocument", &WordDocumentStream) == false)
@ -145,30 +141,20 @@ namespace DocFileFormat
return AVS_ERROR_FILEFORMAT;
}
//-------------------------------------------------------------------------------------------------------------------
FIB = new FileInformationBlock(VirtualStreamReader(WordDocumentStream, 0, false ));
FIB = new FileInformationBlock(VirtualStreamReader(WordDocumentStream,0, false ));
if (FIB->m_FibBase.nFib)
{
if (FIB->m_FibBase.nFib <= Fib1995)
{
nWordVersion = FIB->m_nWordVersion = 1;
if (FIB->m_FibBase.nFib <= Fib1989)
{
nWordVersion = FIB->m_nWordVersion = 2;
}
bOlderVersion = FIB->m_bOlderVersion = true;
}
}
else
{
if (FIB->m_FibNew.nFibNew <= Fib1995 && FIB->m_FibNew.nFibNew > 0)
{
nWordVersion = FIB->m_nWordVersion = 1;
if (FIB->m_FibNew.nFibNew <= Fib1989)
{
nWordVersion = FIB->m_nWordVersion = 2;
}
bOlderVersion = FIB->m_bOlderVersion = true;
}
}
bool res = false;
@ -235,7 +221,7 @@ namespace DocFileFormat
if (DecryptOfficeFile(&Decryptor) == false) return AVS_ERROR_DRM;
}
FIB->reset(VirtualStreamReader(WordDocumentStream, (nWordVersion > 0) ? 36 : 68, false));
FIB->reset(VirtualStreamReader(WordDocumentStream, bOlderVersion ? 36 : 68, false));
}
//------------------------------------------------------------------------------------------------------------------
@ -269,7 +255,7 @@ namespace DocFileFormat
bDocumentCodePage = true;
}
}
if (nWordVersion == 0)
if (!bOlderVersion)
{
nDocumentCodePage = ENCODING_UTF16;
bDocumentCodePage = true;
@ -286,20 +272,20 @@ namespace DocFileFormat
DataStream = NULL;
}
if (TableStream->size() < 1 && nWordVersion > 0)
if (TableStream->size() < 1 && bOlderVersion)
{
RELEASEOBJECT(TableStream);
m_pStorage->GetStream (L"WordDocument", &TableStream);
}
RevisionAuthorTable = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfRMark, FIB->m_FibWord97.lcbSttbfRMark, nWordVersion);
FontTable = new StringTable<FontFamilyName> (TableStream, FIB->m_FibWord97.fcSttbfFfn, FIB->m_FibWord97.lcbSttbfFfn, nWordVersion);
BookmarkNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfBkmk, FIB->m_FibWord97.lcbSttbfBkmk, nWordVersion);
AutoTextNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfGlsy, FIB->m_FibWord97.lcbSttbfGlsy, nWordVersion);
AssocNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfAssoc, FIB->m_FibWord97.lcbSttbfAssoc, nWordVersion);
BookmarkAnnotNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfAtnBkmk, FIB->m_FibWord97.lcbSttbfAtnBkmk, nWordVersion);
Captions = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfCaption, FIB->m_FibWord97.lcbSttbfCaption, nWordVersion);
AutoCaptions = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfAutoCaption, FIB->m_FibWord97.lcbSttbfAutoCaption, nWordVersion);
RevisionAuthorTable = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfRMark, FIB->m_FibWord97.lcbSttbfRMark, bOlderVersion);
FontTable = new StringTable<FontFamilyName> (TableStream, FIB->m_FibWord97.fcSttbfFfn, FIB->m_FibWord97.lcbSttbfFfn, bOlderVersion);
BookmarkNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfBkmk, FIB->m_FibWord97.lcbSttbfBkmk, bOlderVersion);
AutoTextNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfGlsy, FIB->m_FibWord97.lcbSttbfGlsy, bOlderVersion);
AssocNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfAssoc, FIB->m_FibWord97.lcbSttbfAssoc, bOlderVersion);
BookmarkAnnotNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfAtnBkmk, FIB->m_FibWord97.lcbSttbfAtnBkmk, bOlderVersion);
Captions = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfCaption, FIB->m_FibWord97.lcbSttbfCaption, bOlderVersion);
AutoCaptions = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfAutoCaption, FIB->m_FibWord97.lcbSttbfAutoCaption, bOlderVersion);
if (m_pCallFunc)
{
@ -318,46 +304,46 @@ namespace DocFileFormat
// Read all needed PLCFs
if (FIB->m_RgLw97.ccpFtn > 0)
{
IndividualFootnotesPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndTxt, FIB->m_FibWord97.lcbPlcffndTxt, nWordVersion);
FootnoteReferenceCharactersPlex = new Plex<FootnoteDescriptor>(FootnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndRef, FIB->m_FibWord97.lcbPlcffndRef, nWordVersion);
IndividualFootnotesPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndTxt, FIB->m_FibWord97.lcbPlcffndTxt, bOlderVersion);
FootnoteReferenceCharactersPlex = new Plex<FootnoteDescriptor>(FootnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndRef, FIB->m_FibWord97.lcbPlcffndRef, bOlderVersion);
}
if (nWordVersion > 0 && FIB->m_FibWord97.lcbPlcPad > 0)
if (FIB->m_FibWord97.lcbPlcPad > 0)
{
OutlineListDescriptorPlex = new Plex<OutlineListDescriptor>(OutlineListDescriptor::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcPad, FIB->m_FibWord97.lcbPlcPad, nWordVersion);
OutlineListDescriptorPlex = new Plex<OutlineListDescriptor>(OutlineListDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcPad, FIB->m_FibWord97.lcbPlcPad, bOlderVersion);
}
if (FIB->m_RgLw97.ccpEdn > 0)
{
IndividualEndnotesPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendTxt, FIB->m_FibWord97.lcbPlcfendTxt, nWordVersion);
EndnoteReferenceCharactersPlex = new Plex<EndnoteDescriptor>(EndnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendRef, FIB->m_FibWord97.lcbPlcfendRef, nWordVersion);
IndividualEndnotesPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendTxt, FIB->m_FibWord97.lcbPlcfendTxt, bOlderVersion);
EndnoteReferenceCharactersPlex = new Plex<EndnoteDescriptor>(EndnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendRef, FIB->m_FibWord97.lcbPlcfendRef, bOlderVersion);
}
if (FIB->m_RgLw97.ccpHdr > 0)
{
HeaderStoriesPlex = new Plex<EmptyStructure>( EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfHdd, FIB->m_FibWord97.lcbPlcfHdd, nWordVersion);
HeaderStoriesPlex = new Plex<EmptyStructure>( EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfHdd, FIB->m_FibWord97.lcbPlcfHdd, bOlderVersion);
}
if (FIB->m_RgLw97.ccpAtn > 0)
{
AnnotationsReferencePlex = new Plex<AnnotationReferenceDescriptor>(AnnotationReferenceDescriptor::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcfandRef, FIB->m_FibWord97.lcbPlcfandRef, nWordVersion);
IndividualCommentsPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfandTxt, FIB->m_FibWord97.lcbPlcfandTxt, nWordVersion);
AnnotationsReferencePlex = new Plex<AnnotationReferenceDescriptor>(AnnotationReferenceDescriptor::GetSize(bOlderVersion), TableStream, FIB->m_FibWord97.fcPlcfandRef, FIB->m_FibWord97.lcbPlcfandRef, bOlderVersion);
IndividualCommentsPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfandTxt, FIB->m_FibWord97.lcbPlcfandTxt, bOlderVersion);
}
OfficeDrawingPlex = new Plex<Spa> (Spa::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcSpaMom, FIB->m_FibWord97.lcbPlcSpaMom, nWordVersion);
OfficeDrawingPlexHeader = new Plex<Spa> (Spa::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcSpaHdr, FIB->m_FibWord97.lcbPlcSpaHdr, nWordVersion);
OfficeDrawingPlex = new Plex<Spa> (Spa::GetSize(bOlderVersion), TableStream, FIB->m_FibWord97.fcPlcSpaMom, FIB->m_FibWord97.lcbPlcSpaMom, bOlderVersion);
OfficeDrawingPlexHeader = new Plex<Spa> (Spa::GetSize(bOlderVersion), TableStream, FIB->m_FibWord97.fcPlcSpaHdr, FIB->m_FibWord97.lcbPlcSpaHdr, bOlderVersion);
TextboxIndividualPlex = new Plex<FTXBXS> (FTXBXS::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcftxbxTxt, FIB->m_FibWord97.lcbPlcftxbxTxt, nWordVersion);
TextboxIndividualPlex = new Plex<FTXBXS> (FTXBXS::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcftxbxTxt, FIB->m_FibWord97.lcbPlcftxbxTxt, bOlderVersion);
SectionPlex = new Plex<SectionDescriptor> (SectionDescriptor::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcfSed, FIB->m_FibWord97.lcbPlcfSed, nWordVersion);
SectionPlex = new Plex<SectionDescriptor> (SectionDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfSed, FIB->m_FibWord97.lcbPlcfSed, bOlderVersion);
BookmarkStartPlex = new Plex<BookmarkFirst> (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkf, FIB->m_FibWord97.lcbPlcfBkf, nWordVersion);
BookmarkEndPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkl, FIB->m_FibWord97.lcbPlcfBkl, nWordVersion);
BookmarkStartPlex = new Plex<BookmarkFirst> (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkf, FIB->m_FibWord97.lcbPlcfBkf, bOlderVersion);
BookmarkEndPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkl, FIB->m_FibWord97.lcbPlcfBkl, bOlderVersion);
TextboxBreakPlex = new Plex<Tbkd> (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxBkd, FIB->m_FibWord97.lcbPlcfTxbxBkd, nWordVersion);
TextboxBreakPlexHeader = new Plex<Tbkd> (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxHdrBkd, FIB->m_FibWord97.lcbPlcfTxbxHdrBkd, nWordVersion);
TextboxBreakPlex = new Plex<Tbkd> (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxBkd, FIB->m_FibWord97.lcbPlcfTxbxBkd, bOlderVersion);
TextboxBreakPlexHeader = new Plex<Tbkd> (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxHdrBkd, FIB->m_FibWord97.lcbPlcfTxbxHdrBkd, bOlderVersion);
AnnotStartPlex = new Plex<BookmarkFirst> (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkf, FIB->m_FibWord97.lcbPlcfAtnBkf, nWordVersion);
AnnotEndPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkl, FIB->m_FibWord97.lcbPlcfAtnBkl, nWordVersion);
AnnotStartPlex = new Plex<BookmarkFirst> (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkf, FIB->m_FibWord97.lcbPlcfAtnBkf, bOlderVersion);
AnnotEndPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkl, FIB->m_FibWord97.lcbPlcfAtnBkl, bOlderVersion);
for (size_t i = 0; i < BookmarkStartPlex->Elements.size(); ++i)
@ -373,19 +359,15 @@ namespace DocFileFormat
BookmarkFirst* pBookmark = static_cast<BookmarkFirst*>(AnnotStartPlex->Elements[i]);
if (pBookmark)
{
short end = pBookmark->GetIndex();
if (i < AnnotStartPlex->CharacterPositions.size() && end < AnnotEndPlex->CharacterPositions.size())
{
AnnotStartEndCPs.push_back(std::make_pair(AnnotStartPlex->CharacterPositions[i], AnnotEndPlex->CharacterPositions[end]));
}
AnnotStartEndCPs.push_back(std::make_pair(AnnotStartPlex->CharacterPositions[i], AnnotEndPlex->CharacterPositions[pBookmark->GetIndex()]));
}
}
AutoTextPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfGlsy, FIB->m_FibWord97.lcbPlcfGlsy, nWordVersion);
FieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldMom, FIB->m_FibWord97.lcbPlcfFldMom, nWordVersion);
FootnoteDocumentFieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldFtn, FIB->m_FibWord97.lcbPlcfFldFtn, nWordVersion);
EndnoteDocumentFieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldEdn, FIB->m_FibWord97.lcbPlcfFldEdn, nWordVersion);
HeadersAndFootersDocumentFieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldHdr, FIB->m_FibWord97.lcbPlcfFldHdr, nWordVersion);
ListPlex = new Plex<ListNumCache> (ListNumCache::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBteLvc, FIB->m_FibWord97.lcbPlcfBteLvc, nWordVersion);
AutoTextPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfGlsy, FIB->m_FibWord97.lcbPlcfGlsy, bOlderVersion);
FieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldMom, FIB->m_FibWord97.lcbPlcfFldMom, bOlderVersion);
FootnoteDocumentFieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldFtn, FIB->m_FibWord97.lcbPlcfFldFtn, bOlderVersion);
EndnoteDocumentFieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldEdn, FIB->m_FibWord97.lcbPlcfFldEdn, bOlderVersion);
HeadersAndFootersDocumentFieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldHdr, FIB->m_FibWord97.lcbPlcfFldHdr, bOlderVersion);
ListPlex = new Plex<ListNumCache> (ListNumCache::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBteLvc, FIB->m_FibWord97.lcbPlcfBteLvc, bOlderVersion);
if (m_pCallFunc)
{
@ -430,12 +412,11 @@ namespace DocFileFormat
return AVS_ERROR_FILEFORMAT;
}
}
if (FontTable)
if (!bDocumentCodePage && FontTable)
{
std::unordered_map<int, int> fonts_charsets;
bool bFontsCodePage = false;
for ( std::vector<ByteStructure*>::iterator iter = FontTable->Data.begin(); !bFontsCodePage && iter != FontTable->Data.end(); iter++ )
for ( std::vector<ByteStructure*>::iterator iter = FontTable->Data.begin();!bDocumentCodePage && iter != FontTable->Data.end(); iter++ )
{
FontFamilyName* font = dynamic_cast<FontFamilyName*>( *iter );
if (!font) continue;
@ -448,8 +429,8 @@ namespace DocFileFormat
{
if (aCodePages[i][0] == font->chs && font->chs != 0)
{
nFontsCodePage = aCodePages[i][1];
bFontsCodePage = true;
nDocumentCodePage = aCodePages[i][1];
bDocumentCodePage = true;
break;
}
}
@ -464,26 +445,19 @@ namespace DocFileFormat
m_PieceTable = new PieceTable (FIB, TableStream, WordDocumentStream );
Text = m_PieceTable->GetAllEncodingText (WordDocumentStream);
}
if (FIB->m_FibWord97.lcbClx < 1 || ((Text) && (Text->empty())))
else
{
int cb = FIB->m_FibBase.fcMac - FIB->m_FibBase.fcMin;
if (cb > 0)
{
FIB->m_FibBase.fComplex = false;
unsigned char *bytes = new unsigned char[cb];
unsigned char *bytes = new unsigned char[cb];
WordDocumentStream->seek (FIB->m_FibBase.fcMin);
WordDocumentStream->read (bytes, cb);
WordDocumentStream->seek (FIB->m_FibBase.fcMin);
WordDocumentStream->read (bytes, cb);
RELEASEOBJECT(Text);
Text = new std::vector<wchar_t>();
Text = new std::vector<wchar_t>();
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t> >(Text, bytes, cb, nDocumentCodePage);
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t>>(Text, bytes, cb, nFontsCodePage != ENCODING_WINDOWS_1250 ? nFontsCodePage : nDocumentCodePage);
RELEASEARRAYOBJECTS(bytes);
}
RELEASEARRAYOBJECTS(bytes);
}
if (BookmarkNames)
@ -547,13 +521,13 @@ namespace DocFileFormat
int cp = SectionPlex->CharacterPositions[i + 1];
//Get the SEPX
VirtualStreamReader wordReader( WordDocumentStream, sed->fcSepx, nWordVersion);
VirtualStreamReader wordReader( WordDocumentStream, sed->fcSepx, bOlderVersion);
//!!!TODO: cbSepx is the size in bytes of the rest properties part!!!
short cbSepx = nWordVersion == 2 ? wordReader.ReadByte() : wordReader.ReadInt16();
unsigned char* bytes = wordReader.ReadBytes( ( cbSepx /*- 2*/ ), true );
short cbSepx = wordReader.ReadInt16();
unsigned char* bytes = wordReader.ReadBytes( ( cbSepx /*- 2*/ ), true );
AllSepx->insert( std::pair<int, SectionPropertyExceptions*>( cp, new SectionPropertyExceptions( bytes, ( cbSepx /*- 2*/ ), nWordVersion ) ) );
AllSepx->insert( std::pair<int, SectionPropertyExceptions*>( cp, new SectionPropertyExceptions( bytes, ( cbSepx /*- 2*/ ), bOlderVersion ) ) );
RELEASEARRAYOBJECTS( bytes );
}
@ -575,70 +549,6 @@ namespace DocFileFormat
return 0;
}
bool WordDocument::LoadDocumentFlat()
{
NSFile::CFileBinary file;
if (false == file.OpenFile(m_sFileName)) return false;
DWORD sz_read = 0;
unsigned short wIdent = 0;
file.ReadFile((BYTE*)&wIdent, 2, sz_read);
if ( wIdent != 0xA5EC && wIdent != 0xA5DC && wIdent != 0xA5DB)
{
file.CloseFile();
return false;
}
file.SeekFile(0);
if (m_sTempFolder.empty())
{
m_sTempFolder = NSFile::CFileBinary::GetTempPath();
}
m_sTempDecryptFileName = m_sTempFolder + FILE_SEPARATOR_STR + L"~tempFile.doc";
POLE::Storage *storageOut = new POLE::Storage(m_sTempDecryptFileName.c_str());
if (!storageOut)
{
file.CloseFile();
return false;
}
if (!storageOut->open(true, true))
{
file.CloseFile();
delete storageOut;
return false;
}
DWORD size_stream = file.GetFileSize();
POLE::Stream *streamNew = new POLE::Stream(storageOut, L"WordDocument", true, size_stream);
if (!streamNew) return false;
unsigned char* data_stream = new unsigned char[size_stream];
file.ReadFile(data_stream, size_stream, size_stream);
streamNew->write(data_stream, size_stream);
RELEASEARRAYOBJECTS(data_stream);
streamNew->flush();
delete streamNew;
storageOut->close();
delete storageOut;
file.CloseFile();
//reset streams
RELEASEOBJECT(WordDocumentStream);
m_pStorage->SetFile(m_sTempDecryptFileName.c_str());
return true;
}
bool WordDocument::DecryptOfficeFile(CRYPT::Decryptor* Decryptor)
{
if (m_sTempFolder.empty())
@ -700,7 +610,6 @@ namespace DocFileFormat
}
return true;
}
void WordDocument::DecryptStream( int level, std::wstring path, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor)
{
std::list<std::wstring> entries, entries_files, entries_dir;
@ -773,7 +682,7 @@ namespace DocFileFormat
if ( std::wstring::npos != streamName_open.find(L"WordDocument") )
{
size_data_store = (nWordVersion > 0) ? 36 : 68;
size_data_store = bOlderVersion ? 36 : 68;
data_store = new unsigned char[size_data_store];
}
@ -783,7 +692,7 @@ namespace DocFileFormat
size_t size_block = 0x200;
unsigned long block = 0;
for (POLE::uint64 pos = /*(nWordVersion > 0) ? size_data_store :*/ 0; pos < size_stream; pos += size_block, block++)
for (POLE::uint64 pos = /*bOlderVersion ? size_data_store :*/ 0; pos < size_stream; pos += size_block, block++)
{
if (pos + size_block > size_stream)
size_block = size_stream - pos;
@ -813,7 +722,7 @@ namespace DocFileFormat
void WordDocument::Clear()
{
nWordVersion = 0;
bOlderVersion = false;
if (AllPapxFkps)
{

View File

@ -94,24 +94,17 @@ namespace DocFileFormat
WordDocument (const ProgressCallback* pCallFunc, const std::wstring & tempFolder );
virtual ~WordDocument();
int LoadDocument(const std::wstring & fileName, const std::wstring & password);
long LoadDocument (const std::wstring & fileName, const std::wstring & password);
int nWordVersion;
bool bOlderVersion;
int nDocumentCodePage;
bool bDocumentCodePage;
int nFontsCodePage;
inline StructuredStorageReader* GetStorage() const
{
return m_pStorage;
}
inline POLE::Stream* GetDocumentStream() const
{
return WordDocumentStream;
}
private:
bool LoadDocumentFlat();
bool DecryptOfficeFile (CRYPT::Decryptor* Decryptor);
bool DecryptStream (std::wstring streamName_open, POLE::Storage * storageIn, std::wstring streamName_create, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor, bool bDecrypt);

View File

@ -304,7 +304,7 @@ namespace DocFileFormat
if (!iter->data.empty())
{
SaveEmbeddedObject(fileName, *iter);
SaveEmbeddedObject(fileName, iter->data);
}
else
{

View File

@ -39,6 +39,7 @@ namespace DocFileFormat
{
friend class Converter;
friend class MainDocumentMapping;
friend class DocumentMapping;
friend class CommandTableMapping;
friend class StyleSheetMapping;
friend class NumberingMapping;

View File

@ -31,8 +31,6 @@
*/
#include <iostream>
#include "../../Common/OfficeFileFormatChecker.h"
#include "../../Common/DocxFormat/Source/Base/Base.h"
#include "../../Common/DocxFormat/Source/Base/Base.h"
#include "../../DesktopEditor/common/Directory.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
@ -51,13 +49,6 @@
HRESULT convert_single(std::wstring srcFileName)
{
COfficeFileFormatChecker checker;
if (false == checker.isOfficeFile(srcFileName)) return S_FALSE;
if (AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC != checker.nFileType &&
AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC_FLAT != checker.nFileType) return S_FALSE;
HRESULT hr = S_OK;
std::wstring outputDir = NSDirectory::GetFolderPath(srcFileName);

View File

@ -455,7 +455,7 @@
>
</File>
<File
RelativePath="..\..\build\lib\win_32\DEBUG\UnicodeConverter.lib"
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
>
</File>
<File

View File

@ -783,7 +783,6 @@ public:
bool bDefault;
std::wstring BasedOn;
std::wstring NextId;
std::wstring Link;
bool qFormat;
long uiPriority;
bool hidden;
@ -843,12 +842,6 @@ public:
{
pCStringWriter->WriteString(L"<w:next w:val=\"" + NextId + L"\"/>");
}
if(!Link.empty())
{
pCStringWriter->WriteString(L"<w:link w:val=\"");
pCStringWriter->WriteEncodeXmlString(Link);
pCStringWriter->WriteString(L"\"/>");
}
if(bqFormat)
{
if(qFormat)

View File

@ -2791,10 +2791,6 @@ public:
NextId = XmlUtils::EncodeXmlString(NextId);
odocStyle->NextId = NextId;
}
else if(c_oSer_sts::Style_Link == type)
{
odocStyle->Link = m_oBufferedStream.GetString3(length);
}
else if(c_oSer_sts::Style_qFormat == type)
{
odocStyle->bqFormat = true;

View File

@ -37,7 +37,7 @@
namespace Writers
{
static std::wstring g_string_set_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><w:settings xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:v=\"urn:schemas-microsoft-com:vml\">");
static std::wstring g_string_set_Default = _T("<w:zoom w:percent=\"100\"/><w:characterSpacingControl w:val=\"doNotCompress\"/><w:compat><w:compatSetting w:name=\"compatibilityMode\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"14\"/><w:compatSetting w:name=\"overrideTableStyleFontSizeAndJustification\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/><w:compatSetting w:name=\"enableOpenTypeFeatures\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/><w:compatSetting w:name=\"doNotFlipMirrorIndents\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/></w:compat><w:themeFontLang w:val=\"en-US\" w:eastAsia=\"zh-CN\"/><w:shapeDefaults><o:shapedefaults v:ext=\"edit\" spidmax=\"1026\"/><o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"1\"/></o:shapelayout></w:shapeDefaults><w:decimalSymbol w:val=\".\"/><w:listSeparator w:val=\",\"/>");
static std::wstring g_string_set_Default = _T("<w:zoom w:percent=\"100\"/><w:characterSpacingControl w:val=\"doNotCompress\"/><w:compat><w:compatSetting w:name=\"compatibilityMode\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"15\"/><w:compatSetting w:name=\"overrideTableStyleFontSizeAndJustification\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/><w:compatSetting w:name=\"enableOpenTypeFeatures\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/><w:compatSetting w:name=\"doNotFlipMirrorIndents\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/></w:compat><w:themeFontLang w:val=\"en-US\" w:eastAsia=\"zh-CN\"/><w:shapeDefaults><o:shapedefaults v:ext=\"edit\" spidmax=\"1026\"/><o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"1\"/></o:shapelayout></w:shapeDefaults><w:decimalSymbol w:val=\".\"/><w:listSeparator w:val=\",\"/>");
static std::wstring g_string_set_End = _T("</w:settings>");
class SettingWriter

View File

@ -261,8 +261,7 @@ extern int g_nCurFormatVersion;
Style_unhideWhenUsed = 14,
Style_RowPr = 15,
Style_CellPr = 16,
Style_TblStylePr = 17,
Style_Link = 18
Style_TblStylePr = 17
};}
namespace c_oSerProp_tblStylePrType{enum c_oSerProp_tblStylePrType
{

View File

@ -2506,13 +2506,6 @@ namespace BinDocxRW
m_oBcw.m_oStream.WriteBYTE(c_oSer_sts::Style_Next);
m_oBcw.m_oStream.WriteStringW(style.m_oNext.get().ToString2());
}
//Link
if(false != style.m_oLink.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_sts::Style_Link);
m_oBcw.m_oStream.WriteStringW(style.m_oLink.get().ToString2());
}
//qFormat
if(false != style.m_oQFormat.IsInit())
{

View File

@ -39,10 +39,9 @@
namespace cpdoccore {
namespace oox {
/**/
docx_table_state::docx_table_state(docx_conversion_context & Context,
const std::wstring & StyleName) : context_(Context),
docx_table_state::docx_table_state(docx_conversion_context & Context, const std::wstring & StyleName) :
context_(Context),
table_style_(StyleName),
current_table_column_(-1),
columns_spanned_num_(0),
@ -93,6 +92,19 @@ std::wstring docx_table_state::current_row_style() const
return L"";
}
double docx_table_state::get_current_cell_width()
{
if (current_table_column_ < columns_width_.size())
return columns_width_[current_table_column_];
else
return 0;
}
void docx_table_state::add_column_width(double width)
{
columns_width_.push_back(width);
}
void docx_table_state::start_cell()
{
current_table_column_++;
@ -102,7 +114,6 @@ void docx_table_state::start_cell()
void docx_table_state::end_cell()
{}
bool docx_table_state::start_covered_cell(docx_conversion_context & Context)
{
std::wostream & _Wostream = context_.output_stream();

View File

@ -70,6 +70,8 @@ public:
void set_rows_spanned(unsigned int Column, unsigned int Val, unsigned int ColumnsSpanned, const std::wstring & Style);
unsigned int current_rows_spanned(unsigned int Column) const;
double get_current_cell_width();
void add_column_width(double width);
private:
docx_conversion_context & context_;
std::wstring table_style_;
@ -81,7 +83,8 @@ private:
std::vector<table_row_spanned> rows_spanned_;
bool close_table_covered_cell_;
std::vector<unsigned int> columns_;
std::vector<std::wstring> columnsDefaultCellStyleName_;
std::vector<double> columns_width_;
std::vector<std::wstring> columnsDefaultCellStyleName_;
};
@ -135,6 +138,14 @@ public:
{
return table_states_.back().start_cell();
}
double get_current_cell_width()
{
return table_states_.back().get_current_cell_width();
}
void add_column_width(double width)
{
table_states_.back().add_column_width(width);
}
void end_cell()
{

View File

@ -184,7 +184,7 @@ void oox_bar_chart::oox_serialize(std::wostream & _Wostream)
}
CP_XML_NODE(L"c:varyColors")
{
CP_XML_ATTR(L"val", 1);
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
}
oox_serialize_common(CP_XML_STREAM());
@ -226,7 +226,7 @@ void oox_line_chart::oox_serialize(std::wostream & _Wostream)
{
CP_XML_NODE(L"c:varyColors")
{
CP_XML_ATTR(L"val", 1);
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
}
oox_serialize_common(CP_XML_STREAM());
@ -259,7 +259,7 @@ void oox_area_chart::oox_serialize(std::wostream & _Wostream)
{
CP_XML_NODE(L"c:varyColors")
{
CP_XML_ATTR(L"val", 1);
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
}
oox_serialize_common(CP_XML_STREAM());
@ -289,7 +289,7 @@ void oox_bubble_chart::oox_serialize(std::wostream & _Wostream)
{
CP_XML_NODE(L"c:varyColors")
{
CP_XML_ATTR(L"val", 1);
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
}
oox_serialize_common(CP_XML_STREAM());
//CP_XML_NODE(L"c:bubbleScale")
@ -326,7 +326,7 @@ void oox_doughnut_chart::oox_serialize(std::wostream & _Wostream)
{
CP_XML_NODE(L"c:varyColors")
{
CP_XML_ATTR(L"val", 1);
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
}
oox_serialize_common(CP_XML_STREAM());
@ -366,7 +366,7 @@ void oox_pie_chart::oox_serialize(std::wostream & _Wostream)
{
CP_XML_NODE(L"c:varyColors")
{
CP_XML_ATTR(L"val", 1);
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
}
oox_serialize_common(CP_XML_STREAM());
}
@ -398,7 +398,7 @@ void oox_radar_chart::oox_serialize(std::wostream & _Wostream)
}
CP_XML_NODE(L"c:varyColors")
{
CP_XML_ATTR(L"val", 1);
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
}
oox_serialize_common(CP_XML_STREAM());
@ -436,7 +436,7 @@ void oox_scatter_chart::oox_serialize(std::wostream & _Wostream)
}
CP_XML_NODE(L"c:varyColors")
{
CP_XML_ATTR(L"val", 1);
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
}
oox_serialize_common(CP_XML_STREAM());

Some files were not shown because too many files have changed in this diff Show More