Compare commits

...

144 Commits

Author SHA1 Message Date
50ee7d7cc1 x2t - fix linux build 2018-05-04 17:44:23 +03:00
f9b54bffd4 Merge remote-tracking branch 'origin/hotfix/v5.1.4' into develop
# Conflicts:
#	DesktopEditor/common/Directory.h
#	DesktopEditor/common/File.h
2018-05-04 16:12:30 +03:00
128529ba80 x2t - from https://github.com/ONLYOFFICE/core/pull/65. 2018-05-03 19:44:09 +03:00
a571c88798 PdfReader - test project, fix image renderer 2018-05-03 18:12:51 +03:00
34bb84a792 [ios][x2t] fixed build 2018-05-03 16:50:50 +03:00
92d0d0d7ea . 2018-05-03 16:39:24 +03:00
449e3fc131 . 2018-05-03 16:18:33 +03:00
ce9fdb33b5 OdfFormatWriter - encrypted 2018-05-03 16:11:49 +03:00
2591f0a202 x2t - update crypto++ 2018-05-03 12:36:33 +03:00
6bc04fc06f . 2018-04-30 15:33:58 +03:00
047850dbd6 OdfFormatWriter - encryption 2018-04-29 17:22:44 +03:00
465b903ec5 Remove inline methods 2018-04-28 17:48:38 +03:00
c7b45910f8 . 2018-04-28 13:31:44 +03:00
ab1abb96fe [ios][x2t] fixed build 2018-04-28 12:09:15 +03:00
566d9e68e4 OdfFormatReader - decrypt 2018-04-27 20:23:32 +03:00
243b8eccdd [ios][x2t] fixed build 2018-04-27 19:55:37 +03:00
658040f77b [ios][x2t] up test project 2018-04-27 18:01:47 +03:00
a1b738fc42 Merge remote-tracking branch 'origin/hotfix/v5.1.4' into develop 2018-04-27 16:28:03 +03:00
2a4ce1f93f x2t - decrtypt Open Office Document 2018-04-27 15:42:25 +03:00
d4a70d306f x2t - fix bug 37589 2018-04-26 18:15:11 +03:00
234459f37c x2t - fix bug 37579 2018-04-25 12:21:46 +03:00
e7ed48af49 . 2018-04-24 13:02:29 +03:00
cbd79c902e Merge branch 'origin/hotfix/v5.1.3' into develop 2018-04-24 12:03:39 +03:00
40c24b1577 . 2018-04-24 11:48:35 +03:00
da329135e1 . 2018-04-20 16:40:19 +03:00
60ca9a2347 [ios][x2t] fixed build 2018-04-20 16:24:24 +03:00
5fdace28d2 Merge remote-tracking branch 'origin/hotfix/v5.1.3' into develop 2018-04-20 13:38:36 +03:00
85549c5b20 . 2018-04-20 13:35:30 +03:00
23ca735f23 Add not used String::format 2018-04-20 11:19:07 +03:00
4acefb020f Remove not required defines 2018-04-19 17:50:31 +03:00
684d697cae Remove xml2, agg, freestyle include folders from projects 2018-04-19 16:37:04 +03:00
1aa604c584 Remove dll-based projects from solution 2018-04-19 16:21:11 +03:00
51569b626f Fix build on macOS 2018-04-19 16:10:29 +03:00
89d7eb559d Switch to X2tSLN dependency 2018-04-19 15:30:06 +03:00
f6b3a78fe8 . 2018-04-19 15:16:16 +03:00
1900e2f0a0 . 2018-04-19 15:08:19 +03:00
d0e1785086 . 2018-04-19 14:47:58 +03:00
221d1ecbb5 x2t - fix test projects 2018-04-19 14:20:49 +03:00
2fc3b140d0 Fix build on macOS 2018-04-19 14:02:40 +03:00
bdb2ca8241 Merge remote-tracking branch 'origin/feature/core_dll' into develop 2018-04-19 13:20:07 +03:00
4055201322 . 2018-04-19 13:17:24 +03:00
5b305ec75d Correct previous commit 2018-04-19 12:00:24 +03:00
433686c01f Fix linux builds error 2018-04-19 11:59:40 +03:00
ccfc921883 x2t linux build 2018-04-19 10:08:08 +03:00
6b0d6fe890 AllFontsGen builds 2018-04-18 18:39:00 +03:00
5ae20c58ed Remove unused project 2018-04-18 18:16:33 +03:00
7b45fb8931 x2t worked version 2018-04-18 18:05:59 +03:00
d0ffc6f555 x2t 2018-04-18 17:39:28 +03:00
54e5bb8419 Remove OfficeUtils project 2018-04-18 17:28:01 +03:00
f7bb1766c0 Update project dependency 2018-04-18 17:02:08 +03:00
f0bb87ba14 . 2018-04-18 13:40:13 +03:00
a484dc1fd7 . 2018-04-18 13:27:33 +03:00
19cc78060c x2t builds 2018-04-18 13:16:10 +03:00
2682eda9c6 x2t builds (not complete) 2018-04-18 12:42:54 +03:00
8d750adb7b x2t (not complete) 2018-04-17 19:10:48 +03:00
f57b28cd24 PdfReader builds 2018-04-17 13:40:11 +03:00
b8215e9e82 Merge remote-tracking branch 'origin/hotfix/v5.1.3' into develop 2018-04-17 13:09:27 +03:00
f6305fca21 DocFormatReader - fix user file (table in table) 2018-04-17 12:50:15 +03:00
4cb984684d HtmlFile builds 2018-04-17 12:06:02 +03:00
903d903aad doctrenderer builds 2018-04-17 11:59:12 +03:00
fe53ae9b11 XpsFile builds 2018-04-17 11:27:14 +03:00
8ca218d600 PdfWriter & DjvuFile builds 2018-04-17 11:00:32 +03:00
87a9542fc7 [ios][x2t] support csv 2018-04-16 18:45:21 +03:00
a0b32c1523 21 2018-04-16 16:49:30 +03:00
a2cc70233e remove cximage from PdfWriter 2018-04-16 16:43:34 +03:00
42c35a9803 20 2018-04-16 15:02:52 +03:00
a395420d59 DocFormatReader - fix user file(table) 2018-04-16 14:50:51 +03:00
c4ca4b5613 x2t - fix linux build 2018-04-16 14:46:22 +03:00
8100a2860f 19 2018-04-16 14:14:31 +03:00
dd83971001 Use only major version for icu numbering (#69) 2018-04-16 12:43:07 +03:00
c4abf6d149 18 2018-04-16 12:32:59 +03:00
c749cbf081 17 2018-04-16 10:14:24 +03:00
c7accf4370 16 2018-04-16 09:26:46 +03:00
b49e43c4cb [x2t] Fix bug 37146 2018-04-13 20:17:13 +03:00
322bc72ad1 15 2018-04-13 19:00:52 +03:00
33bf2df39d 14 2018-04-13 18:32:17 +03:00
aa344408b0 14 2018-04-13 18:25:55 +03:00
2a5d29c874 13 2018-04-13 18:09:02 +03:00
50ae01723c OdfFormatWriter - fix paragraph shading 2018-04-13 18:08:24 +03:00
c05ea1bd21 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2018-04-13 10:26:37 +03:00
887905570a OdfFormatReader - read crypted files and decrypt it (template only) 2018-04-13 10:26:13 +03:00
ce76a7b075 [ios][x3t] support csv 2018-04-12 17:12:02 +03:00
6dda731502 PptFormatReader - fix after testing 2018-04-12 13:05:42 +03:00
3e9e70655c 12 2018-04-12 11:59:58 +03:00
ed9a6e7e5c 13 2018-04-11 18:53:29 +03:00
284b04574a 12 2018-04-11 18:21:02 +03:00
67eb5ac139 11 2018-04-11 17:41:48 +03:00
563014f8d7 10 2018-04-11 17:29:54 +03:00
290d845d7a 9 2018-04-11 17:20:13 +03:00
935e9396af 8 2018-04-11 15:17:28 +03:00
4de2649dcd 8 2018-04-11 15:07:12 +03:00
46bc4e5e96 7 2018-04-11 14:26:29 +03:00
56475b7e8a 6 2018-04-11 14:14:02 +03:00
69a69d9fc2 5 2018-04-11 14:06:59 +03:00
b470120075 x2t version 2.4.531 2018-04-11 11:59:36 +03:00
7d2f96d284 4 2018-04-11 11:51:43 +03:00
0de5fb6bfc x2t - extended convert by UnicodeConverter 2018-04-10 19:58:48 +03:00
e753476826 3 2018-04-10 19:01:28 +03:00
983873d010 2 2018-04-10 18:53:17 +03:00
af037642dd 1 2018-04-10 18:24:49 +03:00
68122490bf . 2018-04-10 16:28:14 +03:00
4833c652d8 x2t version 2.4.520 2018-04-10 16:01:13 +03:00
af0e9be136 PptFormatReader - new converting group shapes 2018-04-10 15:02:31 +03:00
d987233335 Merge pull request #67 from ONLYOFFICE/feature/icu60
Feature/icu60
2018-04-09 18:38:50 +03:00
5f100d4ea0 [ios][x2t] icu fixed 2018-04-09 17:49:56 +03:00
d4e34e244f [ios][x2t] remove warnings 2018-04-09 14:20:56 +03:00
4b8bc2c8e7 OoxmlFormat - convert border in vml shape 2018-04-06 14:19:58 +03:00
b04f44ee2c [ios][x2t] icu fixed 2018-04-06 13:24:37 +03:00
fb3b6aff47 . 2018-04-06 12:59:54 +03:00
531460e37d Merge remote-tracking branch 'origin/hotfix/v5.1.2' into develop 2018-04-06 11:47:42 +03:00
56279f7465 Merge remote-tracking branch 'origin/hotfix/v5.1.2' into develop 2018-04-05 19:05:56 +03:00
7dc6d70b8a Merge remote-tracking branch 'origin/hotfix/v5.1.2' into develop 2018-04-05 18:28:00 +03:00
d665d9449e Merge remote-tracking branch 'origin/hotfix/v5.1.2' into develop 2018-04-05 17:50:30 +03:00
b525e1deb4 Merge commit '992e62b8c8efa40aede48e3e6732fe6da38171fe' into develop 2018-04-05 17:39:21 +03:00
5e034e2877 Recover icu paths for windows 2018-04-05 12:43:57 +03:00
8d77cdaf24 Merge branch 'feature/icu55-build' into feature/icu60 2018-04-04 18:24:19 +03:00
e73b5c29b2 Fix the target chosing 2018-04-04 18:23:17 +03:00
6a3b4d12a5 Add icu installation to local folder on linux 2018-04-04 16:36:25 +03:00
992e62b8c8 Add icu building from source on linux 2018-04-04 14:25:53 +03:00
021e01af4e . 2018-04-04 14:05:25 +03:00
55a1a2ca59 Merge branch 'feature/icu60' of https://github.com/ONLYOFFICE/core into feature/icu60 2018-04-04 13:15:10 +03:00
e644ef4062 UnicodeConverter - fix build with icu 6.0 win32&win64 2018-04-04 13:14:34 +03:00
05bf38a35d x2t 2.4.525 linux build 2018-04-04 12:21:40 +03:00
45d51a0002 Restore icu version 2018-04-04 12:15:26 +03:00
247f0a7d89 Refactore fetching icu 2018-04-04 12:09:58 +03:00
7c621a4a81 Change devenv to msbuild 2018-04-03 19:57:02 +03:00
62ba68aaa8 Add icu building from source code on windows 2018-04-03 18:25:01 +03:00
0a816a2d6d Check a certificate of trust 2018-04-03 17:50:04 +03:00
c64a33f42d DocFormatReader - add older version format 2018-04-03 15:28:08 +03:00
0599018f99 Merge remote-tracking branch 'origin/hotfix/v5.1.1' into develop 2018-04-03 15:25:05 +03:00
17e8cfcaa8 [changelog] Add to develop
Add changelog to develop
2018-03-29 18:23:32 +03:00
5d4bdccbac [changelog] Add changelog
Create CHANGELOG.md for hotfix/v5.1.1
2018-03-29 18:20:59 +03:00
0af0739792 [ios][se] disable log 2018-03-29 14:42:56 +03:00
a2034c19c7 Merge remote-tracking branch 'origin/hotfix/v5.1.1' into develop
* origin/hotfix/v5.1.1:
  .
  x2t - fix bug #37323
2018-03-28 13:41:53 +03:00
7df5ff1aeb DocFormatReader - add word doc without compound storage(earlier 1995) 2018-03-27 16:43:48 +03:00
7ea2b40585 Merge remote-tracking branch 'origin/release/v5.1.0' into develop 2018-03-26 16:20:33 +03:00
758ae9a1da [x2t][feat] Add open/save link style 2018-03-13 19:57:05 +03:00
dcf6fadcad Merge remote-tracking branch 'origin/release/v5.1.0' into develop 2018-03-12 19:27:00 +03:00
0b3c1b8d55 Merge remote-tracking branch 'origin/release/v5.1.0' into develop 2018-03-12 17:46:44 +03:00
b6ad4dd76c Merge remote-tracking branch 'origin/release/v5.1.0' into develop 2018-03-12 10:51:52 +03:00
405396afca Merge remote-tracking branch 'origin/release/v5.1.0' into develop 2018-03-05 17:07:17 +03:00
f0cd60b93c Merge remote-tracking branch 'origin/release/v5.1.0' into develop 2018-03-02 11:12:28 +03:00
49aa15a751 Merge remote-tracking branch 'origin/release/v5.1.0' into develop 2018-02-28 19:59:59 +03:00
0c5410df72 x2t - metafile test 2018-02-28 19:58:41 +03:00
1116 changed files with 83563 additions and 53571 deletions

View File

@ -641,14 +641,12 @@ namespace DocFileFormat
else
{
std::string sCodePage;
for (int i = 0; i < UNICODE_CONVERTER_ENCODINGS_COUNT; ++i)
std::map<int, std::string>::const_iterator pFind = NSUnicodeConverter::mapEncodingsICU.find(code_page);
if (pFind != NSUnicodeConverter::mapEncodingsICU.end())
{
if (code_page == NSUnicodeConverter::Encodings[i].WindowsCodePage)
{
sCodePage = NSUnicodeConverter::Encodings[i].Name;
break;
}
sCodePage = pFind->second;
}
if (sCodePage.empty())
sCodePage = "CP1250"/* + std::to_string(code_page)*/;

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_bOlderVersion);
VirtualStreamReader reader(tableStream, fib->m_FibWord97.fcGrpXstAtnOwners, fib->m_nWordVersion);
if (fib->m_FibWord97.fcGrpXstAtnOwners > reader.GetSize()) return;

View File

@ -40,7 +40,7 @@ namespace DocFileFormat
//read the user initials (LPXCharBuffer9)
if (reader->olderVersion)
if (reader->nWordVersion > 0)
{
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(bool bOldVersion)
static const int GetSize(int nWordVersion)
{
return bOldVersion ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
return (nWordVersion > 0) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
}
inline std::wstring GetUserInitials() const

View File

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

View File

@ -129,357 +129,360 @@ namespace DocFileFormat
parent->AppendChild( *webHidden );
RELEASEOBJECT( webHidden );
}
std::list<SinglePropertyModifier>::iterator end = sprms->end();
for (std::list<SinglePropertyModifier>::iterator iter = sprms->begin(); iter != end; ++iter)
if ((sprms) && (!sprms->empty()))
{
int nProperty = 0; //for unknown test
switch ( (int)( iter->OpCode ) )
std::list<SinglePropertyModifier>::iterator end = sprms->end();
for (std::list<SinglePropertyModifier>::iterator iter = sprms->begin(); iter != end; ++iter)
{
case sprmOldCIstd :
case sprmCIstd : // style id
int nProperty = 0; //for unknown test
switch ( (int)( iter->OpCode ) )
{
if (_isRunStyleNeeded && !_webHidden)
case sprmOldCIstd :
case sprmCIstd : // style id
{
_currentIstd = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if (_currentIstd < _doc->Styles->Styles->size())
if (_isRunStyleNeeded && !_webHidden)
{
appendValueElement( parent, L"rStyle", StyleSheetMapping::MakeStyleId( _doc->Styles->Styles->at( _currentIstd ) ), true );
_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 );
}
}
}break;
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::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() )
case sprmCRgFtc2:
{
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
if (ffn)
m_sDefaultFont = ffn->xszFtn;
}
}break;
size_t nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
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())
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;
break;
case sprmCPbiGrf:
{
//used picture bullet
int val = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
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;
}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
}
case sprmCRsidProp:
case sprmCRsidText:
break;
}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 );
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;
}
break;
}
}

View File

@ -35,19 +35,188 @@
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, bool oldVersion) :
PropertyExceptions( bytes, size, oldVersion )
{
}
};
/// 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
}
}
}
};
}

View File

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

View File

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

View File

@ -89,6 +89,11 @@ 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)
@ -140,7 +145,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 DocumentMapping::writeParagraph(int cp, int cpEnd)
{
//search the paragraph end
int cpParaEnd = cp;
@ -170,7 +175,7 @@ namespace DocFileFormat
{
cpParaEnd++;
return writeParagraph(cp, cpParaEnd, false);
return writeParagraph(cp, (std::min)(cpEnd, cpParaEnd), false);
}
}
@ -186,8 +191,8 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos(cp);
int fcEnd = m_document->FindFileCharPos(cpEnd);
if (fc < 0 || fcEnd < 0)
return 0;
if (fc < 0 || fcEnd < 0 || fc == fcEnd)
return -1;
ParagraphPropertyExceptions* papx = findValidPapx(fc);
@ -533,8 +538,7 @@ namespace DocFileFormat
}
else if (TextMark::PageBreakOrSectionMark == code)
{
//write page break, section breaks are written by writeParagraph() method
if (/*!isSectionEnd(c)*/_isSectionPageBreak == 0)
if (_isSectionPageBreak == 0)
{
writeTextElement(text, textType);
@ -571,20 +575,21 @@ 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 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 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)
@ -593,7 +598,8 @@ 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();
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 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();
@ -687,13 +693,6 @@ namespace DocFileFormat
}
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];
@ -767,9 +766,9 @@ namespace DocFileFormat
if (!m_shapeIdOwner.empty()) //4571833.doc
oVmlMapper.m_shapeId = m_shapeIdOwner;
if (m_document->bOlderVersion)
{
OleObject ole ( chpxObj, m_document->GetStorage(), m_document->bOlderVersion);
if (m_document->nWordVersion > 0)
{
OleObject ole ( chpxObj, m_document);
oleWriter.WriteNodeBegin (L"w:object", true);
oleWriter.WriteAttribute( L"w:dxaOrig", FormatUtils::IntToWideString( ( ole.pictureDesciptor.dxaGoal + ole.pictureDesciptor.dxaOrigin ) ));
@ -785,7 +784,7 @@ namespace DocFileFormat
}
else
{
PictureDescriptor pic(chpxObj, m_document->DataStream, 0x7fffffff, m_document->bOlderVersion);
PictureDescriptor pic(chpxObj, m_document->DataStream, 0x7fffffff, m_document->nWordVersion);
oleWriter.WriteNodeBegin (L"w:object", true);
oleWriter.WriteAttribute( L"w:dxaOrig", FormatUtils::IntToWideString( ( pic.dxaGoal + pic.dxaOrigin ) ) );
@ -803,7 +802,7 @@ namespace DocFileFormat
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions( fcFieldSep, ( fcFieldSep + 1 ) );
CharacterPropertyExceptions* chpxSep = chpxs->front();
OleObject ole ( chpxSep, m_document->GetStorage(), m_document->bOlderVersion);
OleObject ole ( chpxSep, m_document);
OleObjectMapping oleObjectMapping( &oleObjectWriter, m_context, &pic, _caller, oVmlMapper.m_shapeId );
if (oVmlMapper.m_isEmbedded)
@ -914,7 +913,7 @@ namespace DocFileFormat
if (pSpa)
{
PictureDescriptor pictDiscr(chpx, m_document->WordDocumentStream, 0x7fffffff, m_document->bOlderVersion);
PictureDescriptor pictDiscr(chpx, m_document->WordDocumentStream, 0x7fffffff, m_document->nWordVersion);
ShapeContainer* pShape = m_document->GetOfficeArt()->GetShapeContainer(pSpa->GetShapeID());
if (pShape)
@ -936,9 +935,9 @@ namespace DocFileFormat
}
}
}
else if ((TextMark::Picture == code) && fSpec )
else if (TextMark::Picture == code && fSpec)
{
PictureDescriptor oPicture (chpx, m_document->bOlderVersion ? m_document->WordDocumentStream : m_document->DataStream, 0x7fffffff, m_document->bOlderVersion);
PictureDescriptor oPicture (chpx, m_document->nWordVersion > 0 ? m_document->WordDocumentStream : m_document->DataStream, 0x7fffffff, m_document->nWordVersion);
bool isInline = _isTextBoxContent;
@ -974,7 +973,7 @@ namespace DocFileFormat
if (oVmlMapper.m_isEmbedded)
{
OleObject ole ( chpx, m_document->GetStorage(), m_document->bOlderVersion);
OleObject ole ( chpx, m_document);
OleObjectMapping oleObjectMapping( &pictWriter, m_context, &oPicture, _caller, oVmlMapper.m_shapeId );
ole.isEquation = oVmlMapper.m_isEquation;
@ -1222,7 +1221,8 @@ namespace DocFileFormat
int fc2 = m_document->FindFileCharPos( cp );
int fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx );
TableInfo tai( papx, m_document->nWordVersion );
//build the table grid
std::vector<short> grid;
@ -1231,7 +1231,7 @@ namespace DocFileFormat
//find first row end
int fcRowEnd = findRowEndFc( cp, nestingLevel );
TablePropertyExceptions row1Tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->bOlderVersion);
TablePropertyExceptions row1Tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->nWordVersion);
//start table
m_pXmlWriter->WriteNodeBegin( L"w:tbl" );
@ -1254,7 +1254,7 @@ namespace DocFileFormat
//?fc = m_document->FindFileCharPos(cp );
fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx );
tai = TableInfo( papx, m_document->nWordVersion );
}
}
else
@ -1267,7 +1267,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx );
tai = TableInfo( papx, m_document->nWordVersion );
}
}
@ -1288,60 +1288,80 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx );
TableInfo tai( papx, m_document->nWordVersion );
int fcRowEnd = findRowEndFc( cp, cp, nestingLevel );
ParagraphPropertyExceptions* papx_prev = NULL;
short max_boundary = -1;
short count_column = 0;
bool fEndNestingLevel = false;
unsigned int iTap_current = 1;
while ( tai.fInTable )
{
short current_count_column = 0;
//check all SPRMs of this TAPX
iTap_current = 1;
for ( std::list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ )
{
//find the tDef SPRM
DWORD code = iter->OpCode;
switch(iter->OpCode)
{
case sprmTDefTable:
case sprmOldTDefTable:
case sprmPFInnerTableCell:
case sprmPFInnerTtp:
{
//SprmTDefTable tdef(iter->Arguments, iter->argumentsSize);
//int itcMac = tdef.numberOfColumns;
fEndNestingLevel = ( iter->Arguments[0] == 1 ) ? (true) : (false);
}break;
unsigned char itcMac = iter->Arguments[0];
short boundary1, boundary2;
for (unsigned char i = 0; i < itcMac; i++)
{
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);
}
if (max_boundary < boundary2)
max_boundary = boundary2;
AddBoundary(boundary2, max_boundary, boundaries);
case sprmPItap:
{
iTap_current = FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize );
}break;
}
}
if (nestingLevel == iTap_current)
{
for ( std::list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ )
{
//find the tDef SPRM
DWORD code = iter->OpCode;
if (current_count_column > count_column)
count_column = current_count_column;
switch(iter->OpCode)
{
case sprmTDefTable:
case sprmOldTDefTable:
{
unsigned char itcMac = iter->Arguments[0];
short boundary1, boundary2;
for (unsigned char i = 0; i < itcMac; i++)
{
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);
}
if (max_boundary < boundary2)
max_boundary = boundary2;
AddBoundary(boundary2, max_boundary, boundaries);
}break;
}
}
}
if (nestingLevel > 1 && fEndNestingLevel && !boundaries.empty())
break;
//get the next papx
papx = findValidPapx( fcRowEnd );
tai = TableInfo( papx );
tai = TableInfo( papx, m_document->nWordVersion );
fcRowEnd = findRowEndFc( cp, cp, nestingLevel );
if (papx_prev && papx_prev == papx )
break;//file(12).doc
papx_prev = papx;
}
if ( !boundaries.empty() )
@ -1358,7 +1378,7 @@ namespace DocFileFormat
void DocumentMapping::AddBoundary(short boundary1, short boundary2, std::map<short, short> &boundaries)
{
if (boundary2 - boundary1 < 10)
if (boundary2 - boundary1 < 3)
return;
std::map<short, short>::iterator pFind = boundaries.find(boundary1);
@ -1397,7 +1417,7 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx );
TableInfo tai( papx, m_document->nWordVersion );
if ( nestingLevel > 1 )
{
@ -1413,7 +1433,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx );
tai = TableInfo( papx, m_document->nWordVersion );
cp++;
}
@ -1436,7 +1456,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx );
tai = TableInfo( papx, m_document->nWordVersion );
cp++;
}
}
@ -1455,7 +1475,7 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx );
TableInfo tai( papx, m_document->nWordVersion );
if ( nestingLevel > 1 )
{
@ -1475,7 +1495,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx );
tai = TableInfo( papx, m_document->nWordVersion );
cp++;
}
@ -1498,7 +1518,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx );
tai = TableInfo( papx, m_document->nWordVersion );
cp++;
}
}
@ -1513,14 +1533,14 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx );
TableInfo tai( papx, m_document->nWordVersion );
//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->bOlderVersion);
TablePropertyExceptions tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->nWordVersion);
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions( fcRowEnd, fcRowEnd + 1 );
TableRowPropertiesMapping* trpMapping = new TableRowPropertiesMapping( m_pXmlWriter, *(chpxs->begin()) );
@ -1544,7 +1564,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos(cp );
papx = findValidPapx( fc );
tai = TableInfo( papx );
tai = TableInfo( papx, m_document->nWordVersion );
}
}
else
@ -1561,7 +1581,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx );
tai = TableInfo( papx, m_document->nWordVersion );
}
}
@ -1582,10 +1602,8 @@ namespace DocFileFormat
int cp = initialCp;
int cpCellEnd = findCellEndCp( initialCp, nestingLevel );
//start w:tc
m_pXmlWriter->WriteNodeBegin( L"w:tc" );
TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( m_pXmlWriter, grid, gridIndex, cellIndex );
XMLTools::CStringXmlWriter writerTcPr;
TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( &writerTcPr, grid, gridIndex, cellIndex, nestingLevel );
if ( tapx != NULL )
{
@ -1594,8 +1612,19 @@ namespace DocFileFormat
gridIndex = gridIndex + tcpMapping->GetGridSpan();
bool bCoverCell = tcpMapping->IsCoverCell();
RELEASEOBJECT( tcpMapping );
if (bCoverCell)
{
return cpCellEnd;
}
//start w:tc
m_pXmlWriter->WriteNodeBegin( L"w:tc" );
m_pXmlWriter->WriteString(writerTcPr.GetXmlString());
//write the paragraphs of the cell
while ( cp < cpCellEnd )
{
@ -1603,7 +1632,7 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx );
TableInfo tai( papx, m_document->nWordVersion );
//cp = writeParagraph(cp);
@ -1623,7 +1652,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph( cp );
cp = writeParagraph( cp, 0x7fffffff );
}
}
@ -1642,7 +1671,7 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos( initialCp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx );
TableInfo tai( papx, m_document->nWordVersion );
while ( !tai.fInnerTableCell )
{
@ -1651,7 +1680,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cpCellEnd );
papx = findValidPapx( fc );
tai = TableInfo( papx );
tai = TableInfo( papx, m_document->nWordVersion );
}
cpCellEnd++;
@ -1772,13 +1801,8 @@ namespace DocFileFormat
// Checks if the CHPX is special
bool DocumentMapping::isSpecial(CharacterPropertyExceptions* chpx)
{
/*
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;
}
*/
if (!chpx) return false;
if (!chpx->grpprl) return false;
for (std::list<SinglePropertyModifier>::iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); ++iter)
{
@ -1848,6 +1872,11 @@ 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 writeParagraph( int cp, int cpEnd );
// 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 );

View File

@ -48,22 +48,89 @@ namespace DocFileFormat
{
Initialize();
VirtualStreamReader tStream( tableStream, fib->m_FibWord97.fcDop, fib->m_bOlderVersion);
VirtualStreamReader tStream( tableStream, fib->m_FibWord97.fcDop, fib->m_nWordVersion);
//setDefaultCompatibilityOptions( fib->m_FibBase.nFib );
unsigned int size = fib->m_FibWord97.lcbDop;
unsigned char* bytes = tStream.ReadBytes( size, true );
unsigned int size = fib->m_FibWord97.lcbDop;
unsigned char* bytes = NULL;
try
{
if ( size > 0 )
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 )
{
fFacingPages = FormatUtils::GetBitFromBytes( bytes, 2, 0 );
bytes = tStream.ReadBytes( size, true );
fFacingPages = FormatUtils::GetBitFromBytes( bytes, 2, 0 );
fWindowControl = FormatUtils::GetBitFromBytes( bytes, 2, 1 );
fPMHMainDoc = FormatUtils::GetBitFromBytes( bytes, 2, 2 );
grfSuppression = (short)FormatUtils::GetUIntFromBytesBits( bytes, 2, 3, 2 );
Fpc = (short)(short)FormatUtils::GetUIntFromBytesBits( bytes, 2, 5, 2 );
Fpc = (short)FormatUtils::GetUIntFromBytesBits( bytes, 2, 5, 2 );
grpfIhdt = FormatUtils::BytesToUChar( bytes, 1, size );
rncFtn = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 2 ), 2, 0, 2 );
nFtn = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 2 ), 2, 2, 14 );
@ -545,6 +612,7 @@ namespace DocFileFormat
fSwapBordersFacingPgs = false;
dxaTab = 0;
wSpare = 0;
wSpare3 = 0;
dxaHotZ = 0;
cConsecHypLim = 0;
wSpare2 = 0;

View File

@ -177,7 +177,8 @@ namespace DocFileFormat
unsigned short cConsecHypLim;
// Reserved
unsigned short wSpare2;
// Date and time document was created
unsigned short wSpare3;
// 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_bOlderVersion);
VirtualStreamReader tStream( tableStream, 0, fib->m_nWordVersion);
if (fib->m_FibBase.fObfuscation || fib->m_bOlderVersion)
if (fib->m_FibBase.fObfuscation || fib->m_nWordVersion > 0)
{
bXOR = true;

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -69,14 +69,22 @@ 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();
int szAlt = reader->ReadByte();
szAlt = reader->ReadByte();
}
if (!reader->olderVersion)
if (reader->nWordVersion == 0)
{
//read the 10 bytes panose
newObject->panoseSize = 10;
@ -97,7 +105,7 @@ namespace DocFileFormat
unsigned char *bytes = reader->ReadBytes( (int)( strEnd - strStart ), true );
if (reader->olderVersion)
if (reader->nWordVersion > 0)
{
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(newObject->xszFtn), bytes, (int)( strEnd - strStart ), ENCODING_WINDOWS_1250 );
}
@ -131,7 +139,7 @@ namespace DocFileFormat
bytes = reader->ReadBytes( (int)( strEnd - strStart ), true );
if (reader->olderVersion)
if (reader->nWordVersion > 0)
{
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(newObject->xszAlt), bytes, (int)( strEnd - strStart ), ENCODING_WINDOWS_1250);
}
@ -151,7 +159,7 @@ namespace DocFileFormat
{
long strStart = reader->GetPosition();
if (reader->olderVersion)
if (reader->nWordVersion > 0)
{//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 );
TableInfo tai( papx, m_document->nWordVersion );
if ( tai.fInTable )
{
@ -89,7 +89,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph( cp );
cp = writeParagraph( cp, 0x7fffffff );
}
}

View File

@ -81,7 +81,7 @@ namespace DocFileFormat
if (fc < 0) break;
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx );
TableInfo tai( papx, m_document->nWordVersion );
if ( tai.fInTable )
{
@ -93,7 +93,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph( cp );
cp = writeParagraph( cp, 0x7fffffff );
}
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, bool bOlderVersion_ )
FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, int nWordVersion )
{
binary_data_size = 0;
@ -139,7 +139,7 @@ FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx,
if (fc >= 0 && bNilPICFAndBinData)
{
VirtualStreamReader reader(stream, fc, bOlderVersion_);
VirtualStreamReader reader(stream, fc, nWordVersion);
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, bool bOlderVersion );
FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, int nWordVersion );
virtual ~FormFieldData() {}
private:
friend class FormFieldDataMapping;

View File

@ -52,8 +52,8 @@ namespace DocFileFormat
/*========================================================================================================*/
FormattedDiskPageCHPX::FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset, bool oldVersion ):
FormattedDiskPage(), rgb(NULL), grpchpxSize(NULL), grpchpx(NULL)
FormattedDiskPageCHPX::FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset, int nWordVersion ):
FormattedDiskPage(), rgb(NULL), grpchpxSize(0), grpchpx(NULL)
{
Type = Character;
WordStream = wordStream;
@ -80,7 +80,6 @@ namespace DocFileFormat
j += 4;
}
//create arrays
grpchpxSize = crun;
rgb = new unsigned char[crun];
grpchpx = new CharacterPropertyExceptions*[grpchpxSize];
@ -104,11 +103,10 @@ 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, oldVersion);
grpchpx[i] = new CharacterPropertyExceptions( chpx, cb, nWordVersion);
RELEASEARRAYOBJECTS( chpx );
}
@ -139,7 +137,7 @@ namespace DocFileFormat
}
//there are n offsets and n-1 fkp's in the bin table
if (fib->m_bOlderVersion)
if (fib->m_nWordVersion > 0)
{
int n = ( ( (int)fib->m_FibWord97.lcbPlcfBteChpx - 8 ) / 6 ) + 1;
@ -162,7 +160,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_bOlderVersion ) );
CHPXlist->push_back( new FormattedDiskPageCHPX( wordStream, offset, fib->m_nWordVersion ) );
}
}
else
@ -178,7 +176,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_bOlderVersion ) );
CHPXlist->push_back( new FormattedDiskPageCHPX( wordStream, offset, fib->m_nWordVersion ) );
}
}

View File

@ -50,7 +50,7 @@ namespace DocFileFormat
public:
virtual ~FormattedDiskPageCHPX();
FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset, bool oldVersion );
FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset, int nWordVersion );
/// 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,59 +52,53 @@ namespace DocFileFormat
/*========================================================================================================*/
FormattedDiskPagePAPX::FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, bool oldVersion, bool fComplex):
FormattedDiskPagePAPX::FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, int nWordVersion, 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];
WordStream->seek( offset);
WordStream->read( bytes, 512);
//read the 512 bytes (FKP)
unsigned char* bytes = NULL;
bytes = new unsigned char[512];
//get the count
crun = bytes[511];
WordStream->seek( offset);
WordStream->read( bytes, 512);
//create and fill the array with the adresses
rgfcSize = crun + 1;
rgfc = new int[rgfcSize];
//get the count
crun = bytes[511];
int j = 0;
//create and fill the array with the adresses
rgfcSize = crun + 1;
rgfc = new int[rgfcSize];
int j = 0;
for ( unsigned int i = 0; i < rgfcSize; i++ )
{
rgfc[i] = FormatUtils::BytesToInt32( bytes, j, 512 );
j += 4;
}
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];
//create arrays
rgbx = new BX[crun];
grppapxSize = crun;
grppapx = new ParagraphPropertyExceptions*[grppapxSize];
for ( unsigned int i = 0; i < grppapxSize; i++ )
{
grppapx[i] = NULL;
}
for ( unsigned int i = 0; i < grppapxSize; i++ )
{
grppapx[i] = NULL;
}
j = 4 * ( crun + 1 );
j = 4 * ( crun + 1 );
//read the 12 for PHE
unsigned char* phe = NULL;
phe = new unsigned char[12];
unsigned char* papx = NULL;
unsigned char phe[12];
for ( int i = 0; i < crun; i++ )
for ( unsigned char i = 0; i < crun; i++ )
{
BX bx;
bx.wordOffset = bytes[j];
j++;
if (fComplex || !oldVersion)
if (fComplex || nWordVersion == 0)
{
memcpy( phe, ( bytes + j), 12 );
@ -113,6 +107,13 @@ 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);
@ -126,29 +127,27 @@ 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];
//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];
}
if ( cw != 0 )
{
int sz = cw * 2;
//read the bytes for papx
papx = new unsigned char[cw * 2];
memcpy( papx, ( bytes + (bx.wordOffset * 2) + padbyte + 1 ), ( cw * 2 ) );
unsigned char* papx = new unsigned char[sz];
memcpy( papx, ( bytes + (bx.wordOffset * 2) + padbyte + 1 ), sz );
//parse PAPX and fill grppapx
grppapx[i] = new ParagraphPropertyExceptions( papx, ( cw * 2 ), dataStream, oldVersion );
grppapx[i] = new ParagraphPropertyExceptions( papx, sz, dataStream, nWordVersion );
RELEASEARRAYOBJECTS( papx );
}
}
else
{
@ -157,7 +156,6 @@ namespace DocFileFormat
}
}
RELEASEARRAYOBJECTS( phe );
RELEASEARRAYOBJECTS( bytes );
}
@ -179,7 +177,7 @@ namespace DocFileFormat
//there are n offsets and n-1 fkp's in the bin table
if (fib->m_bOlderVersion && fib->m_FibBase.fComplex == false)
if (fib->m_nWordVersion > 0 && fib->m_FibBase.fComplex == false)
{
int n = ( ( (int)fib->m_FibWord97.lcbPlcfBtePapx - 8 ) / 6 ) + 1;
@ -202,7 +200,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_bOlderVersion, fib->m_FibBase.fComplex) );
PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_nWordVersion, fib->m_FibBase.fComplex) );
}
//if (PAPXlist->back()->rgfc[PAPXlist->back()->rgfcSize-1] < last)
@ -226,7 +224,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_bOlderVersion, fib->m_FibBase.fComplex) );
PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_nWordVersion, fib->m_FibBase.fComplex) );
}
}

View File

@ -63,7 +63,7 @@ namespace DocFileFormat
public:
virtual ~FormattedDiskPagePAPX();
FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, bool oldVersion, bool fComplex);
FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, int nWordVersion, 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,10 +38,30 @@ 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",
@ -55,7 +75,6 @@ namespace Global
L"darkGray",
L"lightGray"
};
static const wchar_t UnderlineCode[56][16] =
{
L"none",

View File

@ -38,110 +38,83 @@ namespace DocFileFormat
{
HeaderAndFooterTable::HeaderAndFooterTable (FileInformationBlock* fib, POLE::Stream* pTableStream)
{
VirtualStreamReader tableReader (pTableStream, fib->m_FibWord97.fcPlcfHdd, fib->m_bOlderVersion);
m_nCurrentIndex = 0;
VirtualStreamReader tableReader (pTableStream, fib->m_FibWord97.fcPlcfHdd, fib->m_nWordVersion);
if (fib->m_FibWord97.fcPlcfHdd > tableReader.GetSize()) return;
unsigned int tableSize = fib->m_FibWord97.lcbPlcfHdd / 4;//in bytes
if ( ( tableSize > 0 ) && ( fib->m_RgLw97.ccpHdr > 0 ) )
if ( tableSize < 1 || fib->m_RgLw97.ccpHdr <1 )
return;
int* table = new int[tableSize];
for (unsigned int i = 0; i < tableSize; ++i)
{
int* table = new int[tableSize];
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_arEvenHeaders.push_back( NULL );
}
else
{
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++;
}
RELEASEARRAYOBJECTS(table);
table[i] = tableReader.ReadInt32();
}
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)
{
if ( table[pos] == table[pos + 1] )
{
m_arCommonHeadersFooters.push_back( NULL );
}
else
{
m_arCommonHeadersFooters.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);
}
HeaderAndFooterTable::~HeaderAndFooterTable()
@ -152,5 +125,7 @@ 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,10 +34,12 @@
#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
{
@ -54,8 +56,17 @@ 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 );
TableInfo tai( papx, m_document->nWordVersion );
if ( tai.fInTable )
{
@ -84,7 +84,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph( cp );
cp = writeParagraph( cp, 0x7fffffff );
}
}

View File

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

View File

@ -143,8 +143,13 @@ 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_bOlderVersion);
VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLfo, fib->m_nWordVersion);
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->olderVersion);
PropertyExceptions* px = new PropertyExceptions( bytes, cbGrpprlPapx, reader->nWordVersion);
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->olderVersion );
grpprlChpx = new CharacterPropertyExceptions( bytes, cbGrpprlChpx, reader->nWordVersion );
RELEASEARRAYOBJECTS( bytes );
//read the number text
@ -116,6 +116,10 @@ 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_bOlderVersion);
VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLst, fib->m_nWordVersion);
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)
while (cp < countText && cp >= 0)
{
fc = m_document->FindFileCharPos(cp);
@ -120,7 +120,7 @@ namespace DocFileFormat
if (papx)
{
TableInfo tai(papx);
TableInfo tai(papx, m_document->nWordVersion);
if (tai.fInTable)
{
int cpStart = cp;
@ -135,7 +135,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph(cp);
cp = writeParagraph(cp, countTextRel);
}
}
else

View File

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

View File

@ -338,9 +338,9 @@ namespace DocFileFormat
}
std::wstring NumberingMapping::GetNumberFormatWideString(int nfc, bool bOlderVersion)
std::wstring NumberingMapping::GetNumberFormatWideString(int nfc, int nWordVersion)
{
if (bOlderVersion && nfc > 5)
if (nWordVersion > 0 && 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->FIB->m_bOlderVersion);
PictureDescriptor pict(chpxs->front(), m_document->DataStream, fcEnd - fc, m_document->nWordVersion);
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, bool bOlderVersion = false);
static std::wstring GetNumberFormatWideString(int nfc, int nWordVersion = 0);
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_bOlderVersion);
VirtualStreamReader oStearmReader(pStream, 0 , pFIB->m_nWordVersion);
if (pFIB->m_FibWord97.fcDggInfo > oStearmReader.GetSize()) return;

View File

@ -67,7 +67,6 @@ public:
BYTE compression;
BYTE filter;
public:
CMetaHeader()
{
cbSize = cbSave = 0;
@ -78,48 +77,6 @@ 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,97 +32,111 @@
#pragma once
#include "OleObject.h"
#include "WordDocument.h"
namespace DocFileFormat
{
OleObject::OleObject( const CharacterPropertyExceptions* chpx, StructuredStorageReader* docStorage, bool bOlderVersion_ )
: bLinked(false), updateMode(NoLink), bOlderVersion(bOlderVersion_), isEquation(false), isEmbedded (false)
OleObject::OleObject( const CharacterPropertyExceptions* chpx, WordDocument* document)
: bLinked(false), updateMode(NoLink), isEquation(false), isEmbedded (false), oleStorage(NULL)
{
if (!docStorage) return;
if (!document) return;
if (!chpx) return;
nWordVersion = document->nWordVersion;
ObjectId = getOleEntryName( chpx );
StructuredStorageReader* docStorage = document->GetStorage();
oleStorage = docStorage->GetStorage();
if (!oleStorage) return;
HRESULT res = S_OK;
std::wstring sObjectId( ObjectId.begin(), ObjectId.end() );
std::wstring name = L"ObjectPool/" + sObjectId + L"/";
POLE::Stream* ObjectPoolStorage = new POLE::Stream(oleStorage, L"ObjectPool");
if (ObjectPoolStorage)
bool bOle = processOleStream( name + L"Ole" );
bool bCompObj = bLinked ? processLinkInfoStream( name + L"LinkInfo" ):
processCompObjStream( name + L"CompObj" );
if (bOle || bCompObj)
{
ObjectId = getOleEntryName( chpx );
std::wstring sObjectId( ObjectId.begin(), ObjectId.end() );
{
std::wstring name = L"ObjectPool/" + sObjectId + L"/";
processOleStream( name + L"Ole" );
if ( bLinked )
{
processLinkInfoStream( name + L"LinkInfo" );
}
else
{
processCompObjStream( name + L"CompObj" );
}
processPICStream( name + L"PIC" );
processEquationNativeStream( name + L"Equation Native" );
}
delete ObjectPoolStorage;
processPICStream( name + L"PIC" );
processMETAStream( name + L"META" );
processEquationNativeStream( name + L"Equation Native" );
}
else if (nWordVersion > 0)
{
int fc = pictureDesciptor.GetFcPic( chpx );
if ( fc >= 0 )
{
POLE::Stream* pOleStream = document->GetDocumentStream();
pictureDesciptor.parse( pOleStream, fc, 0xffffff, nWordVersion);
VirtualStreamReader reader(pOleStream, pOleStream->tell(), nWordVersion);
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)
{
szData = szData >> 16;
}
unsigned char* bytes = reader.ReadBytes( szData, true );
if (bytes)
{
emeddedData = std::string((char*)bytes, szData);
delete []bytes;
}
}
}
}
void OleObject::processLinkInfoStream( const std::wstring& linkStream )
bool OleObject::processLinkInfoStream( const std::wstring& linkStream )
{
try
{
POLE::Stream* pLinkStream = NULL;
HRESULT res = S_OK;
POLE::Stream* pLinkStream = NULL;
HRESULT res = S_OK;
pLinkStream = //oleStorage->stream(linkStream);
new POLE::Stream(oleStorage, linkStream);
pLinkStream = new POLE::Stream(oleStorage, linkStream);
if ( pLinkStream )
{
VirtualStreamReader reader( pLinkStream, 0, false);
if ( pLinkStream )
{
VirtualStreamReader reader( pLinkStream, 0, false);
processLinkInfoStream(reader);
//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;
}
delete pLinkStream;
return true;
}
}
catch (...)
{
}
return false;
}
void OleObject::processEquationNativeStream( const std::wstring& eqStream )
@ -155,7 +169,32 @@ 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
@ -170,20 +209,54 @@ void OleObject::processPICStream( const std::wstring& picStream )
int sz = reader.GetSize();
int cbHeader = reader.ReadUInt32();
int cbHeader = reader.ReadUInt32();
reader.ReadBytes(4, false);
unsigned char* bytes = NULL;
pictureDesciptor.mfp.mm = reader.ReadInt16();
pictureDesciptor.mfp.xExt = reader.ReadInt16();
pictureDesciptor.mfp.yExt = reader.ReadInt16();
pictureDesciptor.mfp.hMf = reader.ReadInt16();
int x = reader.ReadUInt32();
int y = reader.ReadUInt32();
pictureDesciptor.dyaGoal = reader.ReadUInt32();
pictureDesciptor.dxaGoal = reader.ReadUInt32();
int x = reader.ReadUInt32();
int y = reader.ReadUInt32();
pictureDesciptor.dxaGoal = reader.ReadUInt32();
pictureDesciptor.dyaGoal = reader.ReadUInt32();
reader.ReadBytes(20, false);
unsigned char* data = reader.ReadBytes(16, true);
delete []data;
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 (...)
@ -191,7 +264,7 @@ void OleObject::processPICStream( const std::wstring& picStream )
}
}
void OleObject::processCompObjStream( const std::wstring& compStream )
bool OleObject::processCompObjStream( const std::wstring& compStream )
{
try
{
@ -199,36 +272,23 @@ void OleObject::processCompObjStream( const std::wstring& compStream )
POLE::Stream* pCompStream = new POLE::Stream(oleStorage, compStream);
if ( pCompStream )
if ( (pCompStream) && (!pCompStream->fail()) )
{
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;
}
void OleObject::processOleStream( const std::wstring& oleStreamName )
bool OleObject::processOleStream( const std::wstring& oleStreamName )
{
try
{
@ -237,46 +297,87 @@ void OleObject::processOleStream( const std::wstring& oleStreamName )
pOleStream = new POLE::Stream(oleStorage, oleStreamName);
if ( pOleStream )
if ( (pOleStream) && (!pOleStream->fail()))
{
VirtualStreamReader reader( pOleStream, 0, false );
VirtualStreamReader reader( pOleStream, 0, false );
processOleStream(reader);
//skip version
reader.ReadBytes( 4, false );
delete pOleStream;
//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;
return true;
}
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
};
bool bOlderVersion;
int nWordVersion;
bool bLinked; // The the value is true, the object is a linked object
std::wstring ObjectId;
@ -68,17 +68,22 @@ namespace DocFileFormat
PictureDescriptor pictureDesciptor;
OleObject( const CharacterPropertyExceptions* chpx, StructuredStorageReader* docStorage, bool bOlderVersion_ );
OleObject( const CharacterPropertyExceptions* chpx, WordDocument* document);
virtual ~OleObject() {}
private:
POLE::Storage *oleStorage;
void processLinkInfoStream ( const std::wstring& linkStream );
bool processLinkInfoStream ( const std::wstring& linkStream );
void processEquationNativeStream( const std::wstring& eqStream );
void processPICStream ( const std::wstring& picStream );
void processCompObjStream ( const std::wstring& compStream );
void processOleStream ( const std::wstring& oleStreamName );
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 );
std::wstring getOleEntryName ( const CharacterPropertyExceptions* chpx );
};

View File

@ -156,26 +156,31 @@ namespace DocFileFormat
private:
inline void copyEmbeddedObject( const OleObject* ole )
{
if ( ole != NULL )
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() )
{
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() )
{
clsid = ole->ClassId;
}
OleObjectFileStructure object_descr(OleObjectMapping::GetTargetExt( ole->ClipboardFormat ), ole->ObjectId, clsid);
if (ole->isEquation || ole->isEmbedded)
{
object_descr.data = ole->emeddedData;
}
m_context->_docx->OleObjectsList.push_back(object_descr);
clsid = ole->ClassId;
}
OleObjectFileStructure object_descr(OleObjectMapping::GetTargetExt( ole->ClipboardFormat ), ole->ObjectId, clsid);
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;
}
m_context->_docx->OleObjectsList.push_back(object_descr);
}
private:
ConversionContext* m_context;
PictureDescriptor* _pict;

View File

@ -135,35 +135,101 @@ namespace DocFileFormat
}
}
HRESULT OpenXmlPackage::SaveEmbeddedObject( const std::wstring& fileName, const std::string& data )
bool OpenXmlPackage::SaveEmbeddedObject( const std::wstring& fileName, const OleObjectFileStructure& object )
{
NSFile::CFileBinary file;
file.CreateFileW(fileName);
file.WriteFile((BYTE*)data.c_str(), (_UINT32)data.size());
file.CloseFile();
return S_OK;
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;
}
HRESULT OpenXmlPackage::SaveOLEObject( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure )
bool OpenXmlPackage::SaveOLEObject( const std::wstring& fileName, const OleObjectFileStructure& object )
{
if (docFile == NULL) return S_FALSE;
if (docFile == NULL) return false;
POLE::Storage *storageOut = new POLE::Storage(fileName.c_str());
if (storageOut == NULL) return S_FALSE;
if (storageOut == NULL) return false;
if (storageOut->open(true, true)==false)
{
delete storageOut;
return S_FALSE;
return false;
}
POLE::Storage *storageInp = docFile->GetStorage()->GetStorage();
{
POLE::Stream* oleStorage = new POLE::Stream(storageInp, oleObjectFileStructure.objectID);
POLE::Stream* oleStorage = new POLE::Stream(storageInp, object.objectID);
if (oleStorage)
{
std::wstring path = L"ObjectPool/" + oleObjectFileStructure.objectID;
std::wstring path = L"ObjectPool/" + object.objectID;
std::list<std::wstring> entries = storageInp->entries_with_prefix(path);
for (std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); ++it)
@ -201,7 +267,7 @@ namespace DocFileFormat
storageOut->close();
delete storageOut;
return S_OK;
return true;
}
void OpenXmlPackage::RegisterDocPr()
{

View File

@ -102,17 +102,16 @@ 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){}
};
@ -162,8 +161,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 );
HRESULT SaveOLEObject ( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure );
HRESULT SaveEmbeddedObject ( const std::wstring& fileName, const std::string& data );
bool SaveOLEObject( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure );
bool SaveEmbeddedObject( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure );
void RegisterDocPr();
void RegisterDocument();

View File

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

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,51 +34,233 @@
namespace DocFileFormat
{
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 );
}
ParagraphPropertyExceptions::ParagraphPropertyExceptions( unsigned char* bytes, int size, POLE::Stream* dataStream, int nWordVersion):
PropertyExceptions( ( bytes + 2 ), ( size - 2 ), nWordVersion)
{
if (size < 1) return;
VirtualStreamReader *reader = NULL;
if (nWordVersion > 1)
{
istd = bytes[0];
//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 );
ReadExceptions(bytes + 7, size - 7, nWordVersion);
//parse the external grpprl
unsigned char* grpprlBytes = reader->ReadBytes( grpprlsize, true );
// 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));
PropertyExceptions externalPx( grpprlBytes, grpprlsize, oldVersion );
// if (pos + 1 > size) return;
// unsigned char fKeep = oStream.ReadByte(); pos += 1;
// grpprl->push_back(SinglePropertyModifier(sprmOldPFKeep, 1, (BYTE*)&fKeep));
//assign the external grpprl
RELEASEOBJECT( grpprl );
grpprl = new std::list<SinglePropertyModifier>( *(externalPx.grpprl) );
//remove the sprmPHugePapx
grpprl->remove( sprm );
RELEASEARRAYOBJECTS( grpprlBytes );
RELEASEOBJECT( reader )
break;
// 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;
}
}
}
}
}
}

View File

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

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, bool oldVersion)
PictureDescriptor::PictureDescriptor(CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size, int nWordVersion)
:
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, oldVersion);
parse( stream, fc, size, nWordVersion);
}
}
PictureDescriptor::PictureDescriptor()
@ -82,11 +82,11 @@ namespace DocFileFormat
RELEASEARRAYOBJECTS(embeddedData);
RELEASEARRAYOBJECTS(embeddedDataHeader);
}
void PictureDescriptor::parse(POLE::Stream* stream, int fc, int sz, bool oldVersion)
void PictureDescriptor::parse(POLE::Stream* stream, int fc, int sz, int nWordVersion)
{
Clear();
VirtualStreamReader reader(stream, fc, oldVersion);
VirtualStreamReader reader(stream, fc, nWordVersion);
int sz_stream = reader.GetSize();
@ -136,7 +136,7 @@ namespace DocFileFormat
int brcl = reader.ReadInt16();
// borders
int bytesCount = oldVersion ? 2 : 4;
int bytesCount = (nWordVersion > 0) ? 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 (oldVersion)
if (nWordVersion > 0)
{
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, bool oldVersion);
PictureDescriptor ( CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size, int nWordVersion);
virtual ~PictureDescriptor();
void parse( POLE::Stream* stream, int fc, int sz, bool oldVersion);
void parse( POLE::Stream* stream, int fc, int sz, int nWordVersion);
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:
static const int CP_LENGTH = 4;
int CP_LENGTH;
std::vector<int> CharacterPositions;
std::vector<ByteStructure*> Elements;
bool m_bIsValid;
public:
Plex(int structureLength, POLE::Stream* stream, unsigned int fc, unsigned int lcb, bool oldVersion)
: m_bIsValid(false)
Plex(int structureLength, POLE::Stream* stream, unsigned int fc, unsigned int lcb, int nWordVersion)
: m_bIsValid(false), CP_LENGTH(/*nWordVersion == 2 ? 2 :*/ 4)
{
if ((lcb > 0) && (NULL != stream))
{
VirtualStreamReader reader(stream, (ULONG)fc, oldVersion);
VirtualStreamReader reader(stream, (ULONG)fc, nWordVersion);
if (fc > reader.GetSize()) return;

View File

@ -34,8 +34,8 @@
namespace DocFileFormat
{
std::map<unsigned char, std::wstring> PropertiesMapping::brcTypeMap;
OfficeCriticalSection PropertiesMapping::brcTypeMapLock;
std::map<unsigned char, std::wstring> PropertiesMapping::brcTypeMap;
NSCriticalSection::CRITICAL_SECTION_SMART PropertiesMapping::brcTypeMapLock;
void PropertiesMapping::init()
{

View File

@ -39,8 +39,7 @@
#include "ShadingDescriptor.h"
#include "SinglePropertyModifier.h"
#include "../../OfficeUtils/src/ASCOfficeCriticalSection.h" //for linux make inside
#include "../../DesktopEditor/graphics/TemporaryCS.h"
namespace DocFileFormat
{
@ -75,7 +74,7 @@ namespace DocFileFormat
XMLTools::CStringXmlWriter* m_pXmlWriter;
static std::map<unsigned char, std::wstring> brcTypeMap;
static OfficeCriticalSection brcTypeMapLock;
static std::map<unsigned char, std::wstring> brcTypeMap;
static NSCriticalSection::CRITICAL_SECTION_SMART brcTypeMapLock;
};
}

View File

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

View File

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

View File

@ -48,8 +48,13 @@ 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;
this->Changes = new std::list<SinglePropertyModifier>();
Changes = new std::list<SinglePropertyModifier>();
for ( std::list<SinglePropertyModifier>::iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); iter++ )
{

View File

@ -41,19 +41,22 @@ 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 STRUCTURE_SIZE = 12;
SectionDescriptor()
{
}
static const int GetSize(int nWordVersion)
{
return (nWordVersion == 2) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
}
SectionDescriptor() : fn(0), fnMpr(0), fcMpr(0), fcSepx(0)
{
}
virtual ~SectionDescriptor()
{
@ -63,10 +66,20 @@ namespace DocFileFormat
{
SectionDescriptor *newObject = new SectionDescriptor();
newObject->fn = reader->ReadInt16();
newObject->fcSepx = reader->ReadInt32();
newObject->fnMpr = reader->ReadInt16();
newObject->fcMpr = reader->ReadInt32();
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();
}
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 = 255; //all headers & footers
unsigned char fHF = _ctx->_doc->nWordVersion == 0 ? 255 : 0; //all headers & footers
for (std::list<SinglePropertyModifier>::iterator iter = sepx->grpprl->begin(); iter != sepx->grpprl->end(); ++iter)
{
switch (iter->OpCode)
@ -132,17 +132,29 @@ namespace DocFileFormat
}break;
}
}
// Header
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
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)
@ -216,7 +228,10 @@ namespace DocFileFormat
case sprmOldSBOrientation:
case sprmSBOrientation:
//orientation
appendValueAttribute( &pgSz, L"w:orient", FormatUtils::MapValueToWideString( iter->Arguments[0], &PageOrientationMap[0][0], 3, 10 ) );
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 ) );
break;
//paper source

View File

@ -39,9 +39,13 @@ namespace DocFileFormat
{
public:
/// Parses the bytes to retrieve a SectionPropertyExceptions
SectionPropertyExceptions( unsigned char* bytes, int size, bool oldVersion ):
PropertyExceptions( bytes, size, oldVersion ), isBidi(false)
SectionPropertyExceptions( unsigned char* bytes, int size, int nWordVersion ):
PropertyExceptions( bytes, size, nWordVersion ), 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 ) );
m_oXmlWriter.WriteAttribute ( L"w:percent", FormatUtils::IntToWideString( dop->wScaleSaved > 0 ? dop->wScaleSaved : 100 ) );
if ( dop->zkSaved != 0 )
{

View File

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

View File

@ -45,10 +45,16 @@ 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:
bool oldVersion;
int nWordVersion;
/// The operation code identifies the property of the
/// PAP/CHP/PIC/SEP/TAP which sould be modified
OperationCode OpCode;
@ -61,10 +67,11 @@ namespace DocFileFormat
/// The Arguments size
unsigned int argumentsSize;
SinglePropertyModifier(bool oldVersion);
SinglePropertyModifier( int nWordVersion);
/// parses the unsigned char to retrieve a SPRM
SinglePropertyModifier( unsigned char* bytes, int size, bool oldVersion );
SinglePropertyModifier( unsigned char* bytes, int size, int nWordVersion );
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 (pos + cb_primitive > length)
if ((cb_primitive < 1) || (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->olderVersion)
if (reader->nWordVersion > 0)
{
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(bool bOldVersion)
static const int GetSize(int nWordVersion)
{
return bOldVersion ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
return (nWordVersion > 0) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
}
Spa();

View File

@ -71,12 +71,12 @@ namespace DocFileFormat
parse( reader, (unsigned int)reader->GetPosition() );
}
StringTable( POLE::Stream* tableStream, unsigned int fc, unsigned int lcb, bool older ) :
StringTable( POLE::Stream* tableStream, unsigned int fc, unsigned int lcb, int nWordVersion ) :
code_page(1250), fExtend(false), cbData(0), cbExtra(0)
{
if ( lcb > 0 )
{
VirtualStreamReader reader( tableStream, fc, older);
VirtualStreamReader reader( tableStream, fc, nWordVersion);
parse( &reader, fc, lcb ) ;
}
@ -123,25 +123,37 @@ namespace DocFileFormat
//read cData
long cDataStart = reader->GetPosition();
unsigned short c = reader->ReadUInt16();
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;
//}
if ( c != 0xFFFF )
if (reader->nWordVersion > 0)
{
if (reader->olderVersion)
this->cbData = (int)c; // all size
cb = reader->ReadUInt16();
this->cbData = cb; // all size
}
else if (reader->nWordVersion == 0)
{
cb = reader->ReadUInt16();
if ( cb != 0xFFFF )
{
count_elements = cb;
}
else
count_elements = c;
{
//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();
}
}
else
{
//cData is a 4byte signed Integer, so we need to seek back
reader->Seek( (int)( fc + cDataStart ), 0/*STREAM_SEEK_SET*/ );
this->cbData = reader->ReadInt32();
}
//read cbExtra
if (reader->olderVersion == false)
if (reader->nWordVersion == 0)
{
this->cbExtra = reader->ReadUInt16();
}

View File

@ -54,43 +54,164 @@ 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_bOlderVersion);
VirtualStreamReader tableReader( tableStream, fib->m_FibWord97.fcStshf, fib->m_nWordVersion);
//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 );
short cbStshi = fib->m_FibWord97.lcbStshf;
//unsigned char* test = tableReader.ReadBytes( cbStshi, true );
//create list of STDs
Styles = new std::vector<StyleSheetDescription*>();
for ( int i = 0; i < this->stshi->cstd; i++ )
if (fib->m_nWordVersion < 2)
{
//get the cbStd
unsigned short cbStd = tableReader.ReadUInt16();
//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 );
if ( cbStd != 0 )
//parses STSHI
this->stshi = new StyleSheetInformation( stshi, cbStshi );
RELEASEARRAYOBJECTS( stshi );
for ( int i = 0; i < this->stshi->cstd; i++ )
{
//read the STD bytes
unsigned char* std = tableReader.ReadBytes( cbStd, true );
//get the cbStd
unsigned short cbStd = tableReader.ReadUInt16();
//parse the STD bytes
Styles->push_back( new StyleSheetDescription( std, cbStd, (int)this->stshi->cbSTDBaseInFile, dataStream, fib->m_bOlderVersion) );
if ( cbStd != 0 )
{
//read the STD bytes
unsigned char* std = tableReader.ReadBytes( cbStd, true );
RELEASEARRAYOBJECTS( std );
//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 );
}
}
else
}
else
{
unsigned short i, sz = 0;
tableReader.ReadUInt16();
unsigned short sz_names = tableReader.ReadUInt16();
sz = 2;
while(sz < sz_names)
{
Styles->push_back( NULL );
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;
}
}
}

View File

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

View File

@ -385,7 +385,7 @@ namespace DocFileFormat
friend class StyleSheetMapping;
friend class CharacterPropertiesMapping;
private:
public:
/// The name of the style
std::wstring xstzName;
/// Invariant style identifier
@ -450,11 +450,10 @@ 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, bool older);
StyleSheetDescription( unsigned char* bytes, int size, int cbStdBase, POLE::Stream* dataStream, int nWordVersion);
};
}

View File

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

View File

@ -35,8 +35,8 @@
namespace DocFileFormat
{
std::map<std::wstring, std::wstring> StyleSheetMapping::m_mapStyleId;
OfficeCriticalSection StyleSheetMapping::m_mapStyleIdLock;
std::map<std::wstring, std::wstring> StyleSheetMapping::m_mapStyleId;
NSCriticalSection::CRITICAL_SECTION_SMART StyleSheetMapping::m_mapStyleIdLock;
StyleSheetMapping::StyleSheetMapping( ConversionContext* ctx ) : AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() )
{
@ -234,41 +234,44 @@ namespace DocFileFormat
void StyleSheetMapping::writeRunDefaults( StyleSheet* sheet )
{
m_pXmlWriter->WriteNodeBegin( L"w:rPrDefault" );
m_pXmlWriter->WriteNodeBegin( L"w:rPr" );
if ((sheet->stshi) && (!sheet->stshi->rgftcStandardChpStsh.empty()))
{
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

@ -55,7 +55,7 @@ namespace DocFileFormat
/// Generates a style id for custom style names or returns the build-in identifier for build-in styles.
static std::wstring MakeStyleId( StyleSheetDescription* std );
static std::map<std::wstring, std::wstring> m_mapStyleId;
static OfficeCriticalSection m_mapStyleIdLock;
static NSCriticalSection::CRITICAL_SECTION_SMART m_mapStyleIdLock;
virtual ~StyleSheetMapping();
private:
@ -67,4 +67,4 @@ namespace DocFileFormat
/// Writes the "NormalTable" default style
void writeNormalTableStyle();
};
}
}

View File

@ -35,9 +35,11 @@
namespace DocFileFormat
{
TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, int gridIndex, int cellIndex) :
TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter,
const std::vector<short>* grid, int gridIndex, int cellIndex, unsigned int depth) :
PropertiesMapping(pWriter)
{
_depth = depth;
_width = 0;
_gridIndex = gridIndex;
@ -75,9 +77,25 @@ namespace DocFileFormat
TablePropertyExceptions* tapx = static_cast<TablePropertyExceptions*>(visited);
int nComputedCellWidth = 0;
_gridSpan = 1;
_gridSpan = 0;
_bCoverCell = false;
unsigned int iTap_current = 1;
for ( std::list<SinglePropertyModifier>::iterator iter = tapx->grpprl->begin(); iter != tapx->grpprl->end(); iter++ )
{
DWORD code = iter->OpCode;
switch(iter->OpCode)
{
case sprmPItap:
{
iTap_current = FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize );
}break;
}
}
std::list<SinglePropertyModifier>::const_reverse_iterator rend = tapx->grpprl->rend();
for (std::list<SinglePropertyModifier>::const_reverse_iterator iter = tapx->grpprl->rbegin(); iter != rend; ++iter)
{
switch (iter->OpCode)
@ -113,16 +131,39 @@ namespace DocFileFormat
{
appendValueElement( _tcPr, L"noWrap", L"", true );
}
int ind = (std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1);
int ind1 = ind;
while (ind1 < tdef.rgdxaCenter.size() - 1)
//int ind = (std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1);
//int ind1 = ind;
//while (ind1 < tdef.rgdxaCenter.size() - 1)
//{
// int sz = tdef.rgdxaCenter[ ind1 + 1] - tdef.rgdxaCenter[ ind1 ] ;
// if (sz > 1)
// break;
// ind1++;
//}
if (tdef.rgTc80[_cellIndex].horzMerge == 1)
{
int sz = tdef.rgdxaCenter[ ind1 + 1] - tdef.rgdxaCenter[ ind1 ] ;
if (sz > 1)
break;
ind1++;
for (size_t i = _cellIndex; i < tdef.rgTc80.size(); i++)
{
if (tdef.rgTc80[i].horzMerge < 1)
break;
nComputedCellWidth += tdef.rgdxaCenter[ i + 1] - tdef.rgdxaCenter[ i ] ;
_gridSpan++;
}
}
else if (tdef.rgTc80[_cellIndex].horzMerge == 2)
{//skip cover cell
_gridSpan = 1;
nComputedCellWidth = 0;
_bCoverCell = true;
}
else
{
_gridSpan = 1;
nComputedCellWidth += tdef.rgdxaCenter[ _cellIndex + 1] - tdef.rgdxaCenter[ _cellIndex ] ;
}
nComputedCellWidth = tdef.rgdxaCenter[ ind1 + 1] - tdef.rgdxaCenter[ ind ] ;
if (!IsTableBordersDefined(tapx->grpprl))
{
@ -284,30 +325,32 @@ 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 ) : L"dxa" );
XMLTools::XMLAttribute tcWType ( L"w:type", _width > 1 ? FormatUtils::MapValueToWideString( _ftsWidth, &Global::CellWidthTypeMap[0][0], 4, 5 ) :
(nComputedCellWidth > 0 ? L"dxa" : L"auto"));
tcW.AppendAttribute( tcWType );
tcW.AppendAttribute( tcWVal );
_tcPr->AppendChild( tcW );
if ( ( _gridIndex < (int)_grid->size() ) && ( nComputedCellWidth > _grid->at( _gridIndex ) ) )
//if ( ( _gridIndex < (int)_grid->size() ) && ( nComputedCellWidth > _grid->at( _gridIndex ) ) )
//{
// //check the number of merged cells
// int w = _grid->at( _gridIndex );
// for ( size_t i = _gridIndex + 1; i < _grid->size(); i++ )
// {
// _gridSpan++;
// w += _grid->at( i );
// if ( w >= nComputedCellWidth )
// {
// break;
// }
// }
if (_gridSpan > 1)
{
//check the number of merged cells
int w = _grid->at( _gridIndex );
for ( size_t i = _gridIndex + 1; i < _grid->size(); i++ )
{
_gridSpan++;
w += _grid->at( i );
if ( w >= nComputedCellWidth )
{
break;
}
}
appendValueElement( _tcPr, L"gridSpan", FormatUtils::IntToWideString( _gridSpan ), true );
}

View File

@ -58,7 +58,7 @@ namespace DocFileFormat
public:
virtual ~TableCellPropertiesMapping();
TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, int gridIndex, int cellIndex);
TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, int gridIndex, int cellIndex, unsigned int depth);
virtual void Apply( IVisitable* visited );
inline int GetGridSpan() const
@ -66,6 +66,11 @@ namespace DocFileFormat
return _gridSpan;
}
inline bool IsCoverCell() const
{
return _bCoverCell;
}
private:
void apppendCellShading (unsigned char* sprmArg, int size, int cellIndex);
@ -79,18 +84,20 @@ namespace DocFileFormat
XMLTools::XMLElement* _tcMar;
XMLTools::XMLElement* _tcBorders;
const std::vector<short>* _grid;
std::vector<short> _tGrid;
const std::vector<short>* _grid;
std::vector<short> _tGrid;
short _width;
Global::CellWidthType _ftsWidth;
TC80 _tcDef;
short _width;
Global::CellWidthType _ftsWidth;
TC80 _tcDef;
unsigned int _depth;
BorderCode* _brcTop;
BorderCode* _brcLeft;
BorderCode* _brcRight;
BorderCode* _brcBottom;
int _gridSpan;
int _gridSpan;
bool _bCoverCell;
};
}

View File

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

View File

@ -118,12 +118,10 @@ namespace DocFileFormat
//find cell end
int cpCellEnd = documentMapping->findCellEndCp(cp, depth);
//start w:tc
documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tc" );
//convert the properties
TableCellPropertiesMapping tcpMapping(documentMapping->GetXMLWriter(), grid, gridIndex, nCellIndex);
XMLTools::CStringXmlWriter writerTcPr;
TableCellPropertiesMapping tcpMapping(&writerTcPr, grid, gridIndex, nCellIndex, depth);
if ( tapx != NULL )
{
@ -131,6 +129,15 @@ namespace DocFileFormat
}
gridIndex += tcpMapping.GetGridSpan();
if (tcpMapping.IsCoverCell())
{
return;
}
//start w:tc
documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tc" );
documentMapping->GetXMLWriter()->WriteString(writerTcPr.GetXmlString());
documentMapping->_lastValidPapx = papxBackup;
documentMapping->_lastValidSepx = sepxBackup;
@ -215,7 +222,7 @@ namespace DocFileFormat
int fcRowEnd = documentMapping->findRowEndFc(cp, depth);
TablePropertyExceptions tapx ( documentMapping->findValidPapx( fcRowEnd ),
documentMapping->m_document->DataStream,
documentMapping->m_document->FIB->m_bOlderVersion);
documentMapping->m_document->nWordVersion);
std::list<CharacterPropertyExceptions*>* chpxs = documentMapping->m_document->GetCharacterPropertyExceptions( fcRowEnd, fcRowEnd + 1 );
TableRowPropertiesMapping trpMapping( documentMapping->GetXMLWriter(), *(chpxs->begin()) );
@ -293,7 +300,7 @@ namespace DocFileFormat
documentMapping = static_cast<DocumentMapping*>(mapping);
}
documentMapping->writeParagraph( cpStart );
documentMapping->writeParagraph( cpStart, 0x7fffffff );
}
}
@ -315,7 +322,7 @@ namespace DocFileFormat
papx = documentMapping->findValidPapx(fc);
TableInfo tai( papx );
TableInfo tai( papx, documentMapping->m_document->nWordVersion );
return ( ( tai.fInTable ) && ( ( ( documentMapping->m_document->Text->at( _cp ) == 0x0007 ) && ( tai.iTap <= 1 ) &&
@ -335,7 +342,7 @@ namespace DocFileFormat
papx = documentMapping->findValidPapx( fc );
TableInfo tai( papx );
TableInfo tai( papx, documentMapping->m_document->nWordVersion );
return ( ( tai.fInTable ) && ( ( ( documentMapping->m_document->Text->at( _cp ) == 0x0007 ) && ( tai.iTap <= 1 ) &&
( tai.fTtp ) ) ||
@ -355,7 +362,7 @@ namespace DocFileFormat
papx = documentMapping->findValidPapx( fc );
TableInfo tai( papx );
TableInfo tai( papx, documentMapping->m_document->nWordVersion );
return ( ( tai.fInTable ) && ( documentMapping->m_document->Text->at( _cp ) == 0x000D ) &&
( !IsCellMarker( _cp ) ) && ( !IsRowMarker( _cp ) ) );
@ -378,7 +385,7 @@ namespace DocFileFormat
papx = documentMapping->findValidPapx( fc );
TableInfo tai( papx );
TableInfo tai( papx, documentMapping->m_document->nWordVersion );
TableRow tableRow ( documentMapping, _cp );
TableCell tableCell ( documentMapping, _cp );
@ -390,7 +397,7 @@ namespace DocFileFormat
papx = documentMapping->findValidPapx( fc );
tai = TableInfo( papx );
tai = TableInfo( papx, documentMapping->m_document->nWordVersion );
if ( tai.iTap > _depth )
{
@ -405,7 +412,7 @@ namespace DocFileFormat
papx = documentMapping->findValidPapx( fc );
tai = TableInfo( papx );
tai = TableInfo( papx, documentMapping->m_document->nWordVersion );
paragraphBeginCP = _cp;
}
@ -524,7 +531,7 @@ namespace DocFileFormat
TablePropertyExceptions row1Tapx( documentMapping->findValidPapx( fcRowEnd ),
documentMapping->m_document->DataStream ,
documentMapping->m_document->FIB->m_bOlderVersion);
documentMapping->m_document->nWordVersion);
//start table
documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tbl" );

View File

@ -75,6 +75,8 @@ 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 )
@ -105,8 +107,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 );
@ -119,6 +121,8 @@ namespace DocFileFormat
tblW.AppendAttribute( w );
_tblPr->AppendChild( tblW );
bTableW = true;
}
break;
case sprmTMerge:
@ -386,8 +390,20 @@ namespace DocFileFormat
break;
}
}
if (false == bTableW)
{
XMLTools::XMLElement tblW( L"w:tblW");
//indent
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
if ( tblIndent != 0 )
{
XMLTools::XMLElement tblInd( L"w:tblInd");
@ -401,7 +417,7 @@ namespace DocFileFormat
_tblPr->AppendChild( tblInd );
}
//append floating props
//append floating props
if ( tblpPr.GetAttributeCount() > 0 )
{
_tblPr->AppendChild( tblpPr );

View File

@ -41,8 +41,8 @@ namespace DocFileFormat
{
public:
/// Parses the bytes to retrieve a TAPX
TablePropertyExceptions(unsigned char* bytes, int size, bool oldVersion) :
PropertyExceptions(bytes, size, oldVersion), m_bSkipShading97 (FALSE)
TablePropertyExceptions(unsigned char* bytes, int size, int nWordVersion) :
PropertyExceptions(bytes, size, nWordVersion), 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, bool oldVersion) :
TablePropertyExceptions (ParagraphPropertyExceptions* papx, POLE::Stream* dataStream, int nWordVersion) :
PropertyExceptions()
{
VirtualStreamReader oBinReader(dataStream, 0, oldVersion);
VirtualStreamReader oBinReader(dataStream, 0, nWordVersion);
m_bSkipShading97 = FALSE;
@ -87,7 +87,7 @@ namespace DocFileFormat
unsigned char* grpprlBytes = oBinReader.ReadBytes(grpprlSize, true);
//parse the grpprl
PropertyExceptions externalPx(grpprlBytes, grpprlSize, oldVersion);
PropertyExceptions externalPx(grpprlBytes, grpprlSize, nWordVersion);
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 );
TableInfo tai( papx, m_document->nWordVersion );
if ( tai.fInTable )
{
@ -173,7 +173,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph( cp );
cp = writeParagraph( cp, 0x7fffffff );
}
}
_isTextBoxContent = false;

View File

@ -414,6 +414,7 @@ namespace DocFileFormat
}
strStyle += L"width:" + strWidth + L"pt;" + L"height:" + strHeight + L"pt;";
m_pXmlWriter->WriteAttribute( L"style", strStyle);
if (m_isOlePreview)
@ -425,6 +426,21 @@ 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))
@ -439,7 +455,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" );
@ -476,12 +492,16 @@ namespace DocFileFormat
WmfPlaceableFileHeader oWmfHeader = {};
oMetaHeader.ToWMFHeader(&oWmfHeader);
int lLenHeader = 114 + 22;
int lLenHeader = 22 + (pict->embeddedDataHeader ? 114 : 0);
unsigned char *newData = new unsigned char[pict->embeddedDataSize + lLenHeader];
memcpy(newData, (unsigned char *)(&oWmfHeader), 22);
memcpy(newData + 22, pict->embeddedDataHeader, 114 );
if (pict->embeddedDataHeader)
{
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->FIB->m_bOlderVersion);
VirtualStreamReader reader(m_context->_doc->WordDocumentStream, oBlip->foDelay, m_context->_doc->nWordVersion);
switch (oBlip->btWin32)
{

View File

@ -40,7 +40,6 @@
#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 , bool _olderVersion) :
olderVersion(_olderVersion), stream(_stream), position(_position)
VirtualStreamReader (POLE::Stream* _stream, ULONG _position , int _nWordVersion) :
nWordVersion(_nWordVersion), stream(_stream), position(_position)
{
if ( stream == NULL )return;
@ -192,7 +192,8 @@ public:
unsigned char* xstz = NULL;
unsigned char* cch = NULL;
if (olderVersion)
if (nWordVersion > 0)
{
int cchSize = 1;
cch = ReadBytes( cchSize, true );
@ -285,7 +286,7 @@ public:
return result;
}
bool olderVersion;
int nWordVersion;
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->olderVersion)
if (reader->nWordVersion > 0)
{
FormatUtils::GetSTLCollectionFromBytes<WideString>( newObject, bytes, length, ENCODING_WINDOWS_1250 );
}

View File

@ -97,10 +97,11 @@ namespace DocFileFormat
m_pStorage = NULL;
officeArtContent = NULL;
bOlderVersion = false;
nWordVersion = 0;
bDocumentCodePage = false;
nDocumentCodePage = ENCODING_WINDOWS_1250;
nFontsCodePage = ENCODING_WINDOWS_1250;
}
WordDocument::~WordDocument()
@ -116,7 +117,7 @@ namespace DocFileFormat
namespace DocFileFormat
{
long WordDocument::LoadDocument(const std::wstring & fileName, const std::wstring & password)
int WordDocument::LoadDocument(const std::wstring & fileName, const std::wstring & password)
{
m_sFileName = fileName;
m_sPassword = password;
@ -131,8 +132,11 @@ namespace DocFileFormat
if (m_pStorage->SetFile (m_sFileName.c_str()) == false)
{
Clear();
return AVS_ERROR_FILEFORMAT;
if (false == LoadDocumentFlat())
{
Clear();
return AVS_ERROR_FILEFORMAT;
}
}
//-----------------------------------------------------------------------------------------------------------------
if (m_pStorage->GetStream (L"WordDocument", &WordDocumentStream) == false)
@ -141,20 +145,30 @@ 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)
{
bOlderVersion = FIB->m_bOlderVersion = true;
nWordVersion = FIB->m_nWordVersion = 1;
if (FIB->m_FibBase.nFib <= Fib1989)
{
nWordVersion = FIB->m_nWordVersion = 2;
}
}
}
else
{
if (FIB->m_FibNew.nFibNew <= Fib1995 && FIB->m_FibNew.nFibNew > 0)
{
bOlderVersion = FIB->m_bOlderVersion = true;
nWordVersion = FIB->m_nWordVersion = 1;
if (FIB->m_FibNew.nFibNew <= Fib1989)
{
nWordVersion = FIB->m_nWordVersion = 2;
}
}
}
bool res = false;
@ -221,7 +235,7 @@ namespace DocFileFormat
if (DecryptOfficeFile(&Decryptor) == false) return AVS_ERROR_DRM;
}
FIB->reset(VirtualStreamReader(WordDocumentStream, bOlderVersion ? 36 : 68, false));
FIB->reset(VirtualStreamReader(WordDocumentStream, (nWordVersion > 0) ? 36 : 68, false));
}
//------------------------------------------------------------------------------------------------------------------
@ -255,7 +269,7 @@ namespace DocFileFormat
bDocumentCodePage = true;
}
}
if (!bOlderVersion)
if (nWordVersion == 0)
{
nDocumentCodePage = ENCODING_UTF16;
bDocumentCodePage = true;
@ -272,20 +286,20 @@ namespace DocFileFormat
DataStream = NULL;
}
if (TableStream->size() < 1 && bOlderVersion)
if (TableStream->size() < 1 && nWordVersion > 0)
{
RELEASEOBJECT(TableStream);
m_pStorage->GetStream (L"WordDocument", &TableStream);
}
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);
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);
if (m_pCallFunc)
{
@ -304,46 +318,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, bOlderVersion);
FootnoteReferenceCharactersPlex = new Plex<FootnoteDescriptor>(FootnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndRef, FIB->m_FibWord97.lcbPlcffndRef, bOlderVersion);
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);
}
if (FIB->m_FibWord97.lcbPlcPad > 0)
if (nWordVersion > 0 && FIB->m_FibWord97.lcbPlcPad > 0)
{
OutlineListDescriptorPlex = new Plex<OutlineListDescriptor>(OutlineListDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcPad, FIB->m_FibWord97.lcbPlcPad, bOlderVersion);
OutlineListDescriptorPlex = new Plex<OutlineListDescriptor>(OutlineListDescriptor::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcPad, FIB->m_FibWord97.lcbPlcPad, nWordVersion);
}
if (FIB->m_RgLw97.ccpEdn > 0)
{
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);
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);
}
if (FIB->m_RgLw97.ccpHdr > 0)
{
HeaderStoriesPlex = new Plex<EmptyStructure>( EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfHdd, FIB->m_FibWord97.lcbPlcfHdd, bOlderVersion);
HeaderStoriesPlex = new Plex<EmptyStructure>( EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfHdd, FIB->m_FibWord97.lcbPlcfHdd, nWordVersion);
}
if (FIB->m_RgLw97.ccpAtn > 0)
{
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);
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);
}
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);
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);
TextboxIndividualPlex = new Plex<FTXBXS> (FTXBXS::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcftxbxTxt, FIB->m_FibWord97.lcbPlcftxbxTxt, bOlderVersion);
TextboxIndividualPlex = new Plex<FTXBXS> (FTXBXS::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcftxbxTxt, FIB->m_FibWord97.lcbPlcftxbxTxt, nWordVersion);
SectionPlex = new Plex<SectionDescriptor> (SectionDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfSed, FIB->m_FibWord97.lcbPlcfSed, bOlderVersion);
SectionPlex = new Plex<SectionDescriptor> (SectionDescriptor::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcfSed, FIB->m_FibWord97.lcbPlcfSed, 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);
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);
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);
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);
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);
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);
for (size_t i = 0; i < BookmarkStartPlex->Elements.size(); ++i)
@ -359,15 +373,19 @@ namespace DocFileFormat
BookmarkFirst* pBookmark = static_cast<BookmarkFirst*>(AnnotStartPlex->Elements[i]);
if (pBookmark)
{
AnnotStartEndCPs.push_back(std::make_pair(AnnotStartPlex->CharacterPositions[i], AnnotEndPlex->CharacterPositions[pBookmark->GetIndex()]));
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]));
}
}
}
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);
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);
if (m_pCallFunc)
{
@ -412,11 +430,12 @@ namespace DocFileFormat
return AVS_ERROR_FILEFORMAT;
}
}
if (!bDocumentCodePage && FontTable)
if (FontTable)
{
std::unordered_map<int, int> fonts_charsets;
bool bFontsCodePage = false;
for ( std::vector<ByteStructure*>::iterator iter = FontTable->Data.begin();!bDocumentCodePage && iter != FontTable->Data.end(); iter++ )
for ( std::vector<ByteStructure*>::iterator iter = FontTable->Data.begin(); !bFontsCodePage && iter != FontTable->Data.end(); iter++ )
{
FontFamilyName* font = dynamic_cast<FontFamilyName*>( *iter );
if (!font) continue;
@ -429,8 +448,8 @@ namespace DocFileFormat
{
if (aCodePages[i][0] == font->chs && font->chs != 0)
{
nDocumentCodePage = aCodePages[i][1];
bDocumentCodePage = true;
nFontsCodePage = aCodePages[i][1];
bFontsCodePage = true;
break;
}
}
@ -445,19 +464,26 @@ namespace DocFileFormat
m_PieceTable = new PieceTable (FIB, TableStream, WordDocumentStream );
Text = m_PieceTable->GetAllEncodingText (WordDocumentStream);
}
else
if (FIB->m_FibWord97.lcbClx < 1 || ((Text) && (Text->empty())))
{
int cb = FIB->m_FibBase.fcMac - FIB->m_FibBase.fcMin;
unsigned char *bytes = new unsigned char[cb];
if (cb > 0)
{
FIB->m_FibBase.fComplex = false;
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);
Text = new std::vector<wchar_t>();
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t> >(Text, bytes, cb, nDocumentCodePage);
RELEASEOBJECT(Text);
Text = new std::vector<wchar_t>();
RELEASEARRAYOBJECTS(bytes);
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t>>(Text, bytes, cb, nFontsCodePage != ENCODING_WINDOWS_1250 ? nFontsCodePage : nDocumentCodePage);
RELEASEARRAYOBJECTS(bytes);
}
}
if (BookmarkNames)
@ -521,13 +547,13 @@ namespace DocFileFormat
int cp = SectionPlex->CharacterPositions[i + 1];
//Get the SEPX
VirtualStreamReader wordReader( WordDocumentStream, sed->fcSepx, bOlderVersion);
VirtualStreamReader wordReader( WordDocumentStream, sed->fcSepx, nWordVersion);
//!!!TODO: cbSepx is the size in bytes of the rest properties part!!!
short cbSepx = wordReader.ReadInt16();
unsigned char* bytes = wordReader.ReadBytes( ( cbSepx /*- 2*/ ), true );
short cbSepx = nWordVersion == 2 ? wordReader.ReadByte() : wordReader.ReadInt16();
unsigned char* bytes = wordReader.ReadBytes( ( cbSepx /*- 2*/ ), true );
AllSepx->insert( std::pair<int, SectionPropertyExceptions*>( cp, new SectionPropertyExceptions( bytes, ( cbSepx /*- 2*/ ), bOlderVersion ) ) );
AllSepx->insert( std::pair<int, SectionPropertyExceptions*>( cp, new SectionPropertyExceptions( bytes, ( cbSepx /*- 2*/ ), nWordVersion ) ) );
RELEASEARRAYOBJECTS( bytes );
}
@ -549,6 +575,70 @@ 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())
@ -610,6 +700,7 @@ 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;
@ -682,7 +773,7 @@ namespace DocFileFormat
if ( std::wstring::npos != streamName_open.find(L"WordDocument") )
{
size_data_store = bOlderVersion ? 36 : 68;
size_data_store = (nWordVersion > 0) ? 36 : 68;
data_store = new unsigned char[size_data_store];
}
@ -692,7 +783,7 @@ namespace DocFileFormat
size_t size_block = 0x200;
unsigned long block = 0;
for (POLE::uint64 pos = /*bOlderVersion ? size_data_store :*/ 0; pos < size_stream; pos += size_block, block++)
for (POLE::uint64 pos = /*(nWordVersion > 0) ? size_data_store :*/ 0; pos < size_stream; pos += size_block, block++)
{
if (pos + size_block > size_stream)
size_block = size_stream - pos;
@ -722,7 +813,7 @@ namespace DocFileFormat
void WordDocument::Clear()
{
bOlderVersion = false;
nWordVersion = 0;
if (AllPapxFkps)
{

View File

@ -94,17 +94,24 @@ namespace DocFileFormat
WordDocument (const ProgressCallback* pCallFunc, const std::wstring & tempFolder );
virtual ~WordDocument();
long LoadDocument (const std::wstring & fileName, const std::wstring & password);
int LoadDocument(const std::wstring & fileName, const std::wstring & password);
bool bOlderVersion;
int nWordVersion;
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->data);
SaveEmbeddedObject(fileName, *iter);
}
else
{

View File

@ -21,13 +21,7 @@ include($$PWD/../../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE \
_UNICODE \
_USE_LIBXML2_READER_ \
LIBXML_READER_ENABLED \
DONT_WRITE_EMBEDDED_FONTS \
INCLUDEPATH += \
../../../DesktopEditor/freetype-2.5.2/include \
../../../DesktopEditor/xml/libxml2/include
DONT_WRITE_EMBEDDED_FONTS
core_mac {
#QMAKE_MAC_SDK = macosx10.11

View File

@ -47,7 +47,7 @@
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;PPTX_DEF;PPT_DEF;ENABLE_PPT_TO_PPTX_CONVERT;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"

View File

@ -7,66 +7,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DocFormatLib", "..\DocForma
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D} = {77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "graphics", "..\..\DesktopEditor\graphics\graphics_vs2005.vcproj", "{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}"
ProjectSection(ProjectDependencies) = postProject
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540} = {9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD} = {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B} = {78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}
{C739151F-5384-41DF-A1A6-F089E2C1AD56} = {C739151F-5384-41DF-A1A6-F089E2C1AD56}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OfficeUtilsLib", "..\..\OfficeUtils\win32\OfficeUtilsLib.vcproj", "{F8274B05-168E-4D6E-B843-AA7510725363}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "raster", "..\..\DesktopEditor\raster\raster_vs2005.vcproj", "{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}"
ProjectSection(ProjectDependencies) = postProject
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1} = {EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cximage", "..\..\DesktopEditor\cximage\CxImage\cximage_vs2005.vcproj", "{BC52A07C-A797-423D-8C4F-8678805BBB36}"
ProjectSection(ProjectDependencies) = postProject
{818753F2-DBB9-4D3B-898A-A604309BE470} = {818753F2-DBB9-4D3B-898A-A604309BE470}
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D} = {FFDA5DA1-BB65-4695-B678-BE59B4A1355D}
{9A037A69-D1DF-4505-AB2A-6CB3641C476E} = {9A037A69-D1DF-4505-AB2A-6CB3641C476E}
{40A69F40-063E-43FD-8543-455495D8733E} = {40A69F40-063E-43FD-8543-455495D8733E}
{0588563C-F05C-428C-B21A-DD74756628B3} = {0588563C-F05C-428C-B21A-DD74756628B3}
{DF861D33-9BC1-418C-82B1-581F590FE169} = {DF861D33-9BC1-418C-82B1-581F590FE169}
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239} = {764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7} = {43A0E60E-5C4A-4C09-A29B-7683F503BBD7}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jasper", "..\..\DesktopEditor\cximage\jasper\jasper_vs2005.vcproj", "{FFDA5DA1-BB65-4695-B678-BE59B4A1355D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jbig", "..\..\DesktopEditor\cximage\jbig\jbig_vs2005.vcproj", "{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jpeg", "..\..\DesktopEditor\cximage\jpeg\Jpeg_vs2005.vcproj", "{818753F2-DBB9-4D3B-898A-A604309BE470}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpsd", "..\..\DesktopEditor\cximage\libpsd\libpsd_vs2005.vcproj", "{9A037A69-D1DF-4505-AB2A-6CB3641C476E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mng", "..\..\DesktopEditor\cximage\mng\mng_vs2005.vcproj", "{40A69F40-063E-43FD-8543-455495D8733E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "png", "..\..\DesktopEditor\cximage\png\png_vs2005.vcproj", "{43A0E60E-5C4A-4C09-A29B-7683F503BBD7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libdcr", "..\..\DesktopEditor\cximage\raw\libdcr_vs2005.vcproj", "{DF861D33-9BC1-418C-82B1-581F590FE169}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tiff", "..\..\DesktopEditor\cximage\tiff\Tiff_vs2005.vcproj", "{0588563C-F05C-428C-B21A-DD74756628B3}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jbig2", "..\..\DesktopEditor\raster\JBig2\win32\jbig2.vcproj", "{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XlsFormat", "..\..\ASCOfficeXlsFile2\source\win32\XlsFormat.vcproj", "{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DocFormatTest", "DocFormatTest.vcproj", "{0F49D5D1-A8D3-4F97-8BC1-E2F65BB00C10}"
ProjectSection(ProjectDependencies) = postProject
{21663823-DE45-479B-91D0-B4FEF4916EF0} = {21663823-DE45-479B-91D0-B4FEF4916EF0}
{36636678-AE25-4BE6-9A34-2561D1BCF302} = {36636678-AE25-4BE6-9A34-2561D1BCF302}
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
{A100103A-353E-45E8-A9B8-90B87CC5C0B0} = {A100103A-353E-45E8-A9B8-90B87CC5C0B0}
{F8274B05-168E-4D6E-B843-AA7510725363} = {F8274B05-168E-4D6E-B843-AA7510725363}
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF} = {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}
{C27E9A9F-3A17-4482-9C5F-BF15C01E747C} = {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540} = {9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2} = {37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}
{C5371405-338F-4B70-83BD-2A5CDF64F383} = {C5371405-338F-4B70-83BD-2A5CDF64F383}
EndProjectSection
EndProject
@ -78,17 +26,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cryptlib", "..\..\Common\3d
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PPTXFormat", "..\..\ASCOfficePPTXFile\PPTXLib\PPTXFormat.vcproj", "{36636678-AE25-4BE6-9A34-2561D1BCF302}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "agg2d", "..\..\DesktopEditor\agg-2.4\agg_vs2005.vcproj", "{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "font_engine", "..\..\DesktopEditor\fontengine\font_engine_vs2005.vcproj", "{C739151F-5384-41DF-A1A6-F089E2C1AD56}"
ProjectSection(ProjectDependencies) = postProject
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B} = {78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "freetype", "..\..\DesktopEditor\freetype-2.5.2\builds\windows\vc2005\freetype.vcproj", "{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libxml2", "..\..\DesktopEditor\xml\build\vs2005\libxml2.vcproj", "{21663823-DE45-479B-91D0-B4FEF4916EF0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -105,110 +42,6 @@ Global
{C5371405-338F-4B70-83BD-2A5CDF64F383}.Release|Win32.Build.0 = Release|Win32
{C5371405-338F-4B70-83BD-2A5CDF64F383}.Release|x64.ActiveCfg = Release|x64
{C5371405-338F-4B70-83BD-2A5CDF64F383}.Release|x64.Build.0 = Release|x64
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}.Debug|Win32.ActiveCfg = Debug|Win32
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}.Debug|Win32.Build.0 = Debug|Win32
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}.Debug|x64.ActiveCfg = Debug|x64
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}.Debug|x64.Build.0 = Debug|x64
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}.Release|Win32.ActiveCfg = Release|Win32
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}.Release|Win32.Build.0 = Release|Win32
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}.Release|x64.ActiveCfg = Release|x64
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}.Release|x64.Build.0 = Release|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.Debug|Win32.ActiveCfg = Debug|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.Debug|Win32.Build.0 = Debug|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.Debug|x64.ActiveCfg = Debug|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.Debug|x64.Build.0 = Debug|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.Release|Win32.ActiveCfg = Release|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.Release|Win32.Build.0 = Release|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.Release|x64.ActiveCfg = Release|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.Release|x64.Build.0 = Release|x64
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}.Debug|Win32.ActiveCfg = Debug|Win32
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}.Debug|Win32.Build.0 = Debug|Win32
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}.Debug|x64.ActiveCfg = Debug|x64
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}.Debug|x64.Build.0 = Debug|x64
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}.Release|Win32.ActiveCfg = Release|Win32
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}.Release|Win32.Build.0 = Release|Win32
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}.Release|x64.ActiveCfg = Release|x64
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}.Release|x64.Build.0 = Release|x64
{BC52A07C-A797-423D-8C4F-8678805BBB36}.Debug|Win32.ActiveCfg = Debug|Win32
{BC52A07C-A797-423D-8C4F-8678805BBB36}.Debug|Win32.Build.0 = Debug|Win32
{BC52A07C-A797-423D-8C4F-8678805BBB36}.Debug|x64.ActiveCfg = Debug|x64
{BC52A07C-A797-423D-8C4F-8678805BBB36}.Debug|x64.Build.0 = Debug|x64
{BC52A07C-A797-423D-8C4F-8678805BBB36}.Release|Win32.ActiveCfg = Release|Win32
{BC52A07C-A797-423D-8C4F-8678805BBB36}.Release|Win32.Build.0 = Release|Win32
{BC52A07C-A797-423D-8C4F-8678805BBB36}.Release|x64.ActiveCfg = Release|x64
{BC52A07C-A797-423D-8C4F-8678805BBB36}.Release|x64.Build.0 = Release|x64
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D}.Debug|Win32.ActiveCfg = Debug|Win32
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D}.Debug|Win32.Build.0 = Debug|Win32
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D}.Debug|x64.ActiveCfg = Debug|x64
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D}.Debug|x64.Build.0 = Debug|x64
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D}.Release|Win32.ActiveCfg = Release|Win32
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D}.Release|Win32.Build.0 = Release|Win32
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D}.Release|x64.ActiveCfg = Release|x64
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D}.Release|x64.Build.0 = Release|x64
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}.Debug|Win32.ActiveCfg = Debug|Win32
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}.Debug|Win32.Build.0 = Debug|Win32
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}.Debug|x64.ActiveCfg = Debug|x64
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}.Debug|x64.Build.0 = Debug|x64
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}.Release|Win32.ActiveCfg = Release|Win32
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}.Release|Win32.Build.0 = Release|Win32
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}.Release|x64.ActiveCfg = Release|x64
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}.Release|x64.Build.0 = Release|x64
{818753F2-DBB9-4D3B-898A-A604309BE470}.Debug|Win32.ActiveCfg = Debug|Win32
{818753F2-DBB9-4D3B-898A-A604309BE470}.Debug|Win32.Build.0 = Debug|Win32
{818753F2-DBB9-4D3B-898A-A604309BE470}.Debug|x64.ActiveCfg = Debug|x64
{818753F2-DBB9-4D3B-898A-A604309BE470}.Debug|x64.Build.0 = Debug|x64
{818753F2-DBB9-4D3B-898A-A604309BE470}.Release|Win32.ActiveCfg = Release|Win32
{818753F2-DBB9-4D3B-898A-A604309BE470}.Release|Win32.Build.0 = Release|Win32
{818753F2-DBB9-4D3B-898A-A604309BE470}.Release|x64.ActiveCfg = Release|x64
{818753F2-DBB9-4D3B-898A-A604309BE470}.Release|x64.Build.0 = Release|x64
{9A037A69-D1DF-4505-AB2A-6CB3641C476E}.Debug|Win32.ActiveCfg = Debug|Win32
{9A037A69-D1DF-4505-AB2A-6CB3641C476E}.Debug|Win32.Build.0 = Debug|Win32
{9A037A69-D1DF-4505-AB2A-6CB3641C476E}.Debug|x64.ActiveCfg = Debug|x64
{9A037A69-D1DF-4505-AB2A-6CB3641C476E}.Debug|x64.Build.0 = Debug|x64
{9A037A69-D1DF-4505-AB2A-6CB3641C476E}.Release|Win32.ActiveCfg = Release|Win32
{9A037A69-D1DF-4505-AB2A-6CB3641C476E}.Release|Win32.Build.0 = Release|Win32
{9A037A69-D1DF-4505-AB2A-6CB3641C476E}.Release|x64.ActiveCfg = Release|x64
{9A037A69-D1DF-4505-AB2A-6CB3641C476E}.Release|x64.Build.0 = Release|x64
{40A69F40-063E-43FD-8543-455495D8733E}.Debug|Win32.ActiveCfg = Debug|Win32
{40A69F40-063E-43FD-8543-455495D8733E}.Debug|Win32.Build.0 = Debug|Win32
{40A69F40-063E-43FD-8543-455495D8733E}.Debug|x64.ActiveCfg = Debug|x64
{40A69F40-063E-43FD-8543-455495D8733E}.Debug|x64.Build.0 = Debug|x64
{40A69F40-063E-43FD-8543-455495D8733E}.Release|Win32.ActiveCfg = Release|Win32
{40A69F40-063E-43FD-8543-455495D8733E}.Release|Win32.Build.0 = Release|Win32
{40A69F40-063E-43FD-8543-455495D8733E}.Release|x64.ActiveCfg = Release|x64
{40A69F40-063E-43FD-8543-455495D8733E}.Release|x64.Build.0 = Release|x64
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7}.Debug|Win32.ActiveCfg = Debug|Win32
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7}.Debug|Win32.Build.0 = Debug|Win32
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7}.Debug|x64.ActiveCfg = Debug|x64
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7}.Debug|x64.Build.0 = Debug|x64
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7}.Release|Win32.ActiveCfg = Release|Win32
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7}.Release|Win32.Build.0 = Release|Win32
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7}.Release|x64.ActiveCfg = Release|x64
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7}.Release|x64.Build.0 = Release|x64
{DF861D33-9BC1-418C-82B1-581F590FE169}.Debug|Win32.ActiveCfg = Debug|Win32
{DF861D33-9BC1-418C-82B1-581F590FE169}.Debug|Win32.Build.0 = Debug|Win32
{DF861D33-9BC1-418C-82B1-581F590FE169}.Debug|x64.ActiveCfg = Debug|x64
{DF861D33-9BC1-418C-82B1-581F590FE169}.Debug|x64.Build.0 = Debug|x64
{DF861D33-9BC1-418C-82B1-581F590FE169}.Release|Win32.ActiveCfg = Release|Win32
{DF861D33-9BC1-418C-82B1-581F590FE169}.Release|Win32.Build.0 = Release|Win32
{DF861D33-9BC1-418C-82B1-581F590FE169}.Release|x64.ActiveCfg = Release|x64
{DF861D33-9BC1-418C-82B1-581F590FE169}.Release|x64.Build.0 = Release|x64
{0588563C-F05C-428C-B21A-DD74756628B3}.Debug|Win32.ActiveCfg = Debug|Win32
{0588563C-F05C-428C-B21A-DD74756628B3}.Debug|Win32.Build.0 = Debug|Win32
{0588563C-F05C-428C-B21A-DD74756628B3}.Debug|x64.ActiveCfg = Debug|x64
{0588563C-F05C-428C-B21A-DD74756628B3}.Debug|x64.Build.0 = Debug|x64
{0588563C-F05C-428C-B21A-DD74756628B3}.Release|Win32.ActiveCfg = Release|Win32
{0588563C-F05C-428C-B21A-DD74756628B3}.Release|Win32.Build.0 = Release|Win32
{0588563C-F05C-428C-B21A-DD74756628B3}.Release|x64.ActiveCfg = Release|x64
{0588563C-F05C-428C-B21A-DD74756628B3}.Release|x64.Build.0 = Release|x64
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}.Debug|Win32.ActiveCfg = Debug|Win32
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}.Debug|Win32.Build.0 = Debug|Win32
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}.Debug|x64.ActiveCfg = Debug|x64
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}.Debug|x64.Build.0 = Debug|x64
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}.Release|Win32.ActiveCfg = Release|Win32
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}.Release|Win32.Build.0 = Release|Win32
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}.Release|x64.ActiveCfg = Release|x64
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}.Release|x64.Build.0 = Release|x64
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}.Debug|Win32.ActiveCfg = Debug|Win32
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}.Debug|Win32.Build.0 = Debug|Win32
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}.Debug|x64.ActiveCfg = Debug|x64
@ -255,38 +88,6 @@ Global
{36636678-AE25-4BE6-9A34-2561D1BCF302}.Release|Win32.Build.0 = Release|Win32
{36636678-AE25-4BE6-9A34-2561D1BCF302}.Release|x64.ActiveCfg = Release|x64
{36636678-AE25-4BE6-9A34-2561D1BCF302}.Release|x64.Build.0 = Release|x64
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Debug|Win32.ActiveCfg = Debug|Win32
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Debug|Win32.Build.0 = Debug|Win32
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Debug|x64.ActiveCfg = Debug|x64
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Debug|x64.Build.0 = Debug|x64
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Release|Win32.ActiveCfg = Release|Win32
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Release|Win32.Build.0 = Release|Win32
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Release|x64.ActiveCfg = Release|x64
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}.Release|x64.Build.0 = Release|x64
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Debug|Win32.ActiveCfg = Debug|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Debug|Win32.Build.0 = Debug|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Debug|x64.ActiveCfg = Debug|x64
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Debug|x64.Build.0 = Debug|x64
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Release|Win32.ActiveCfg = Release|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Release|Win32.Build.0 = Release|Win32
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Release|x64.ActiveCfg = Release|x64
{C739151F-5384-41DF-A1A6-F089E2C1AD56}.Release|x64.Build.0 = Release|x64
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug|Win32.ActiveCfg = Debug|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug|Win32.Build.0 = Debug|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug|x64.ActiveCfg = Debug|x64
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug|x64.Build.0 = Debug|x64
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release|Win32.ActiveCfg = Release|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release|Win32.Build.0 = Release|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release|x64.ActiveCfg = Release|x64
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release|x64.Build.0 = Release|x64
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Debug|Win32.ActiveCfg = Debug|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Debug|Win32.Build.0 = Debug|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Debug|x64.ActiveCfg = Debug|x64
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Debug|x64.Build.0 = Debug|x64
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Release|Win32.ActiveCfg = Release|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Release|Win32.Build.0 = Release|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Release|x64.ActiveCfg = Release|x64
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -31,6 +31,8 @@
*/
#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"
@ -44,11 +46,28 @@
#if defined(_WIN64)
#pragma comment(lib, "../../build/bin/icu/win_64/icuuc.lib")
#elif defined (_WIN32)
#if defined(_DEBUG)
#pragma comment(lib, "../../build/lib/win_32/DEBUG/graphics.lib")
#pragma comment(lib, "../../build/lib/win_32/DEBUG/kernel.lib")
#pragma comment(lib, "../../build/lib/win_32/DEBUG/UnicodeConverter.lib")
#else
#pragma comment(lib, "../../build/lib/win_32/graphics.lib")
#pragma comment(lib, "../../build/lib/win_32/kernel.lib")
#pragma comment(lib, "../../build/lib/win_32/UnicodeConverter.lib")
#endif
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
#endif
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);
@ -74,7 +93,7 @@ HRESULT convert_single(std::wstring srcFileName)
if (hRes == S_OK)
{
COfficeUtils oCOfficeUtils(NULL);
hRes = oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstPath, -1);
hRes = oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstPath, true);
}
NSDirectory::DeleteDirectory(dstTempPath);

View File

@ -48,7 +48,7 @@
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;USE_ATL_CSTRINGS;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;DONT_WRITE_EMBEDDED_FONTS"
MinimalRebuild="false"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
@ -341,6 +341,10 @@
<Filter
Name="Common"
>
<File
RelativePath="..\..\DesktopEditor\common\Base64.cpp"
>
</File>
<File
RelativePath="..\..\ASCOfficeDocxFile2\BinWriter\BinWriters.cpp"
>
@ -385,6 +389,10 @@
RelativePath="..\..\ASCOfficeDocxFile2\DocWrapper\FontProcessor.cpp"
>
</File>
<File
RelativePath="..\..\Common\3dParty\pole\pole.cpp"
>
</File>
<File
RelativePath="..\..\ASCOfficeDocxFile2\BinReader\Readers.cpp"
>
@ -442,30 +450,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\Common\FileDownloader\FileDownloader_win.cpp"
>
</File>
<File
RelativePath="..\..\Common\OfficeFileFormatChecker2.cpp"
>
</File>
<File
RelativePath="..\..\Common\3dParty\pole\pole.cpp"
>
</File>
<File
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
>
</File>
<File
RelativePath="..\..\DesktopEditor\xml\src\xmldom.cpp"
>
</File>
<File
RelativePath="..\..\DesktopEditor\xml\src\xmllight.cpp"
>
</File>
</Files>
<Globals>
</Globals>

View File

@ -69,7 +69,7 @@ namespace Writers
{
rewind(pFile);
BYTE* pData = new BYTE[size];
DWORD dwSizeRead = (DWORD)fread((void*)pData, 1, size, pFile);
_UINT32 dwSizeRead = (_UINT32)fread((void*)pData, 1, size, pFile);
if(dwSizeRead > 0)
{
std::wstring sNewImagePath = AddImageGetNewPath();

View File

@ -783,6 +783,7 @@ public:
bool bDefault;
std::wstring BasedOn;
std::wstring NextId;
std::wstring Link;
bool qFormat;
long uiPriority;
bool hidden;
@ -842,6 +843,12 @@ 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

@ -53,6 +53,8 @@
#include "../../DesktopEditor/common/ASCVariant.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
#include "../../DesktopEditor/common/Directory.h"
namespace BinDocxRW {
enum ETblStyleOverrideType
@ -2791,6 +2793,10 @@ 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;
@ -7505,7 +7511,7 @@ public:
oXlsx.Write(strDstEmbeddedTemp, *oSaveParams.pContentTypes);
COfficeUtils oOfficeUtils(NULL);
oOfficeUtils.CompressFileOrDirectory(strDstEmbeddedTemp, strDstEmbedded + FILE_SEPARATOR_STR + sXlsxFilename, -1);
oOfficeUtils.CompressFileOrDirectory(strDstEmbeddedTemp, strDstEmbedded + FILE_SEPARATOR_STR + sXlsxFilename, true);
std::wstring sEmbWorksheetRelsName = L"embeddings/" + sXlsxFilename;
std::wstring bstrEmbWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();

View File

@ -33,8 +33,7 @@
#define FONT_TABLE_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
#include "../../DesktopEditor/fontengine/FontManager.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
#include "../../DesktopEditor/graphics/pro/Fonts.h"
#include <boost/unordered_map.hpp>
namespace Writers
@ -46,32 +45,28 @@ namespace Writers
{
XmlUtils::CStringWriter m_oWriter;
std::wstring m_sDir;
CApplicationFonts m_oApplicationFonts;
CFontManager* m_pFontManager;
NSFonts::IApplicationFonts* m_pApplicationFonts;
NSFonts::IFontManager* m_pFontManager;
public:
boost::unordered_map<std::wstring, int> m_mapFonts;
FontTableWriter(std::wstring sDir, std::wstring sFontDir, bool bNoFontDir):m_sDir(sDir)
{
m_pApplicationFonts = NSFonts::NSApplication::Create();
m_pFontManager = NULL;
if(!bNoFontDir)
{
if(sFontDir.empty())
m_oApplicationFonts.Initialize();
m_pApplicationFonts->Initialize();
else
m_oApplicationFonts.InitializeFromFolder(sFontDir);
CFontList* pFontList = m_oApplicationFonts.GetList();
if(NULL != pFontList)
{
std::wstring sDefaultFont(_T("Arial"));
pFontList->SetDefaultFont(sDefaultFont);
}
m_pFontManager = m_oApplicationFonts.GenerateFontManager();
m_pApplicationFonts->InitializeFromFolder(sFontDir);
m_pFontManager = m_pApplicationFonts->GenerateFontManager();
}
}
~FontTableWriter()
{
RELEASEOBJECT(m_pFontManager);
RELEASEOBJECT(m_pApplicationFonts);
}
void Write()
@ -116,11 +111,11 @@ namespace Writers
bool bUsePanose = false;
if(NULL != m_pFontManager)
{
CFontSelectFormat oFontSelectFormat;
NSFonts::CFontSelectFormat oFontSelectFormat;
oFontSelectFormat.wsName = new std::wstring;
*oFontSelectFormat.wsName = sFontName;
CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat);
NSFonts::CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat);
if(NULL != pFontInfo)
{
for (size_t i = 0; i < 10; ++i)

View File

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

View File

@ -2506,6 +2506,13 @@ 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

@ -599,7 +599,7 @@ namespace BinXlsxRW{
//как в CsvReader - подозрительный код
WCHAR *pEndPtr;
wcstod(val.c_str(), &pEndPtr);
if (NULL != *pEndPtr)
if (0 != *pEndPtr)
{
// Не число
aSharedStrings.push_back(val);

View File

@ -67,7 +67,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const std::wstring& sSrcFileName, co
COfficeFontPicker* pFontPicker = new COfficeFontPicker();
pFontPicker->Init(m_sFontDir);
CFontManager* pFontManager = pFontPicker->get_FontManager();
NSFonts::IFontManager* pFontManager = pFontPicker->get_FontManager();
DocWrapper::FontProcessor fp;
fp.setFontManager(pFontManager);

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