Compare commits

..

1 Commits

Author SHA1 Message Date
94548131a1 v5.1.5 2018-07-17 17:08:49 +03:00
1646 changed files with 65941 additions and 110176 deletions

2
.gitignore vendored
View File

@ -35,7 +35,6 @@ Common/3dParty/openssl/openssl
.idea
.svn
.DS_Store
.qmake.stash
Thumbs.db
*.xcuserstate
*.xcuserdatad
@ -56,4 +55,3 @@ X2tConverter/**/Makefile.*
*.zip
*.tar.gz
**/*.build/

View File

@ -641,12 +641,14 @@ namespace DocFileFormat
else
{
std::string sCodePage;
std::map<int, std::string>::const_iterator pFind = NSUnicodeConverter::mapEncodingsICU.find(code_page);
if (pFind != NSUnicodeConverter::mapEncodingsICU.end())
for (int i = 0; i < UNICODE_CONVERTER_ENCODINGS_COUNT; ++i)
{
sCodePage = pFind->second;
if (code_page == NSUnicodeConverter::Encodings[i].WindowsCodePage)
{
sCodePage = NSUnicodeConverter::Encodings[i].Name;
break;
}
}
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_nWordVersion);
VirtualStreamReader reader(tableStream, fib->m_FibWord97.fcGrpXstAtnOwners, fib->m_bOlderVersion);
if (fib->m_FibWord97.fcGrpXstAtnOwners > reader.GetSize()) return;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -89,11 +89,6 @@ namespace DocFileFormat
//if cp is the last char of a section, the next section will start at cp +1
size_t current = 0;
if (m_document->SectionPlex->CharacterPositions.empty())
{
return cp;
}
for (std::vector<int>::iterator iter = m_document->SectionPlex->CharacterPositions.begin() + 1; iter != m_document->SectionPlex->CharacterPositions.end(); ++iter)
{
if (cp < *iter)
@ -145,7 +140,7 @@ namespace DocFileFormat
// Writes a Paragraph that starts at the given cp and
// ends at the next paragraph end mark or section end mark
int DocumentMapping::writeParagraph(int cp, int cpEnd)
int DocumentMapping::writeParagraph(int cp)
{
//search the paragraph end
int cpParaEnd = cp;
@ -175,7 +170,7 @@ namespace DocFileFormat
{
cpParaEnd++;
return writeParagraph(cp, (std::min)(cpEnd, cpParaEnd), false);
return writeParagraph(cp, cpParaEnd, false);
}
}
@ -191,8 +186,8 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos(cp);
int fcEnd = m_document->FindFileCharPos(cpEnd);
if (fc < 0 || fcEnd < 0 || fc == fcEnd)
return -1;
if (fc < 0 || fcEnd < 0)
return 0;
ParagraphPropertyExceptions* papx = findValidPapx(fc);
@ -538,7 +533,8 @@ namespace DocFileFormat
}
else if (TextMark::PageBreakOrSectionMark == code)
{
if (_isSectionPageBreak == 0)
//write page break, section breaks are written by writeParagraph() method
if (/*!isSectionEnd(c)*/_isSectionPageBreak == 0)
{
writeTextElement(text, textType);
@ -575,23 +571,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 embed ( L"embed" );
std::wstring LINK ( L"LINK" );
std::wstring FORM ( L"FORM" );
std::wstring Excel ( L"Excel" );
std::wstring Word ( L"Word" );
std::wstring opendocument(L"opendocument" );
std::wstring Equation ( L"Equation" );
std::wstring MERGEFORMAT( L"MERGEFORMAT" );
std::wstring QUOTE ( L"QUOTE" );
std::wstring EMBED ( L" EMBED" );
std::wstring LINK ( L" LINK" );
std::wstring FORM ( L" FORM" );
std::wstring Excel ( L" Excel" );
std::wstring Word ( L" Word" );
std::wstring opendocument(L" opendocument" );
std::wstring Equation ( L" Equation" );
std::wstring MERGEFORMAT( L" MERGEFORMAT" );
std::wstring QUOTE ( L" QUOTE" );
std::wstring chart ( L"Chart" );
std::wstring PBrush ( L"PBrush" );
std::wstring TOC ( L"TOC" );
std::wstring HYPERLINK ( L"HYPERLINK" );
std::wstring PAGEREF ( L"PAGEREF" );
std::wstring PBrush ( L" PBrush" );
std::wstring TOC ( L" TOC" );
std::wstring HYPERLINK ( L" HYPERLINK" );
std::wstring PAGEREF ( L" PAGEREF" );
std::wstring PAGE ( L"PAGE" );
std::wstring SHAPE ( L"SHAPE" );
if (arField.empty() == false)
f = arField[0];
@ -599,8 +593,7 @@ namespace DocFileFormat
f = sFieldString;
bool bChart = search( f.begin(), f.end(), chart.begin(), chart.end()) != f.end();
bool bEMBED = search( f.begin(), f.end(), EMBED.begin(), EMBED.end()) != f.end() ||
search( f.begin(), f.end(), embed.begin(), embed.end()) != f.end();
bool bEMBED = search( f.begin(), f.end(), EMBED.begin(), EMBED.end()) != f.end();
bool bLINK = search( f.begin(), f.end(), LINK.begin(), LINK.end()) != f.end();
bool bOpendocument = search( f.begin(), f.end(), opendocument.begin(), opendocument.end()) != f.end();
bool bFORM = search( f.begin(), f.end(), FORM.begin(), FORM.end()) != f.end();
@ -612,7 +605,6 @@ namespace DocFileFormat
bool bEquation = search( f.begin(), f.end(), Equation.begin(), Equation.end()) != f.end();
bool bPAGE = search( f.begin(), f.end(), PAGE.begin(), PAGE.end()) != f.end();
bool bTOC = search( f.begin(), f.end(), TOC.begin(), TOC.end()) != f.end();
bool bSHAPE = search( f.begin(), f.end(), SHAPE.begin(), SHAPE.end()) != f.end();
bool bPAGEREF = false;
if (bHYPERLINK && arField.size() > 1)
@ -695,6 +687,13 @@ 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];
@ -768,9 +767,9 @@ namespace DocFileFormat
if (!m_shapeIdOwner.empty()) //4571833.doc
oVmlMapper.m_shapeId = m_shapeIdOwner;
if (m_document->nWordVersion > 0)
{
OleObject ole ( chpxObj, m_document);
if (m_document->bOlderVersion)
{
OleObject ole ( chpxObj, m_document->GetStorage(), m_document->bOlderVersion);
oleWriter.WriteNodeBegin (L"w:object", true);
oleWriter.WriteAttribute( L"w:dxaOrig", FormatUtils::IntToWideString( ( ole.pictureDesciptor.dxaGoal + ole.pictureDesciptor.dxaOrigin ) ));
@ -786,7 +785,7 @@ namespace DocFileFormat
}
else
{
PictureDescriptor pic(chpxObj, m_document->DataStream, 0x7fffffff, m_document->nWordVersion);
PictureDescriptor pic(chpxObj, m_document->DataStream, 0x7fffffff, m_document->bOlderVersion);
oleWriter.WriteNodeBegin (L"w:object", true);
oleWriter.WriteAttribute( L"w:dxaOrig", FormatUtils::IntToWideString( ( pic.dxaGoal + pic.dxaOrigin ) ) );
@ -804,7 +803,7 @@ namespace DocFileFormat
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions( fcFieldSep, ( fcFieldSep + 1 ) );
CharacterPropertyExceptions* chpxSep = chpxs->front();
OleObject ole ( chpxSep, m_document);
OleObject ole ( chpxSep, m_document->GetStorage(), m_document->bOlderVersion);
OleObjectMapping oleObjectMapping( &oleObjectWriter, m_context, &pic, _caller, oVmlMapper.m_shapeId );
if (oVmlMapper.m_isEmbedded)
@ -915,10 +914,10 @@ namespace DocFileFormat
if (pSpa)
{
PictureDescriptor pictDiscr(chpx, m_document->WordDocumentStream, 0x7fffffff, m_document->nWordVersion);
PictureDescriptor pictDiscr(chpx, m_document->WordDocumentStream, 0x7fffffff, m_document->bOlderVersion);
ShapeContainer* pShape = m_document->GetOfficeArt()->GetShapeContainer(pSpa->GetShapeID());
if ((pShape) /*&& (false == pShape->isLastIdentify())*/)
if (pShape)
{
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, &pictDiscr, _caller);
@ -937,9 +936,9 @@ namespace DocFileFormat
}
}
}
else if (TextMark::Picture == code && fSpec)
else if ((TextMark::Picture == code) && fSpec )
{
PictureDescriptor oPicture (chpx, m_document->nWordVersion > 0 ? m_document->WordDocumentStream : m_document->DataStream, 0x7fffffff, m_document->nWordVersion);
PictureDescriptor oPicture (chpx, m_document->bOlderVersion ? m_document->WordDocumentStream : m_document->DataStream, 0x7fffffff, m_document->bOlderVersion);
bool isInline = _isTextBoxContent;
@ -952,59 +951,55 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd (L"w:pict");
}
else if ((oPicture.mfp.mm > 98) && (NULL != oPicture.shapeContainer)/* && (false == oPicture.shapeContainer->isLastIdentify())*/)
else if ((oPicture.mfp.mm > 98) && (NULL != oPicture.shapeContainer))
{
bool bPicture = true;
bool m_bSkip = false;
bool bFormula = false;
XMLTools::CStringXmlWriter pictWriter;
pictWriter.WriteNodeBegin (L"w:pict");
bool picture = true;
if (oPicture.shapeContainer)
{
if (oPicture.shapeContainer->m_nShapeType != msosptPictureFrame)
bPicture = false;//шаблон 1.doc картинка в колонтитуле
int shape_type = oPicture.shapeContainer->getShapeType();
m_bSkip = oPicture.shapeContainer->m_bSkip;
if (shape_type != msosptPictureFrame) picture = false;//шаблон 1.doc картинка в колонтитуле
}
if (!m_bSkip)
if (picture)
{
bool bFormula = false;
XMLTools::CStringXmlWriter pictWriter;
pictWriter.WriteNodeBegin (L"w:pict");
if (bPicture)
{
VMLPictureMapping oVmlMapper(m_context, &pictWriter, false, _caller, isInline);
oPicture.Convert (&oVmlMapper);
if (oVmlMapper.m_isEmbedded)
{
OleObject ole ( chpx, m_document);
OleObjectMapping oleObjectMapping( &pictWriter, m_context, &oPicture, _caller, oVmlMapper.m_shapeId );
ole.isEquation = oVmlMapper.m_isEquation;
ole.isEmbedded = oVmlMapper.m_isEmbedded;
ole.emeddedData = oVmlMapper.m_embeddedData;
ole.Convert( &oleObjectMapping );
}
else if (oVmlMapper.m_isEquation)
{
//нельзя в Run писать oMath
//m_pXmlWriter->WriteString(oVmlMapper.m_equationXml);
_writeAfterRun = oVmlMapper.m_equationXml;
bFormula = true;
}
}
else
{
VMLShapeMapping oVmlMapper(m_context, &pictWriter, NULL, &oPicture, _caller, isInline);
oPicture.shapeContainer->Convert(&oVmlMapper);
}
VMLPictureMapping oVmlMapper(m_context, &pictWriter, false, _caller, isInline);
oPicture.Convert (&oVmlMapper);
pictWriter.WriteNodeEnd (L"w:pict");
if (!bFormula)
m_pXmlWriter->WriteString(pictWriter.GetXmlString());
if (oVmlMapper.m_isEmbedded)
{
OleObject ole ( chpx, m_document->GetStorage(), m_document->bOlderVersion);
OleObjectMapping oleObjectMapping( &pictWriter, m_context, &oPicture, _caller, oVmlMapper.m_shapeId );
ole.isEquation = oVmlMapper.m_isEquation;
ole.isEmbedded = oVmlMapper.m_isEmbedded;
ole.emeddedData = oVmlMapper.m_embeddedData;
ole.Convert( &oleObjectMapping );
}
else if (oVmlMapper.m_isEquation)
{
//нельзя в Run писать oMath
//m_pXmlWriter->WriteString(oVmlMapper.m_equationXml);
_writeAfterRun = oVmlMapper.m_equationXml;
bFormula = true;
}
}else
{
VMLShapeMapping oVmlMapper(m_context, &pictWriter, NULL, &oPicture, _caller, isInline);
oPicture.shapeContainer->Convert(&oVmlMapper);
}
pictWriter.WriteNodeEnd (L"w:pict");
if (!bFormula)
m_pXmlWriter->WriteString(pictWriter.GetXmlString());
}
}
@ -1227,8 +1222,7 @@ namespace DocFileFormat
int fc2 = m_document->FindFileCharPos( cp );
int fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
//build the table grid
std::vector<short> grid;
@ -1237,7 +1231,7 @@ namespace DocFileFormat
//find first row end
int fcRowEnd = findRowEndFc( cp, nestingLevel );
TablePropertyExceptions row1Tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->nWordVersion);
TablePropertyExceptions row1Tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->bOlderVersion);
//start table
m_pXmlWriter->WriteNodeBegin( L"w:tbl" );
@ -1260,7 +1254,7 @@ namespace DocFileFormat
//?fc = m_document->FindFileCharPos(cp );
fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
}
}
else
@ -1273,7 +1267,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
}
}
@ -1294,80 +1288,60 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
int fcRowEnd = findRowEndFc( cp, cp, nestingLevel );
ParagraphPropertyExceptions* papx_prev = NULL;
short max_boundary = -1;
bool fEndNestingLevel = false;
unsigned int iTap_current = 1;
short count_column = 0;
while ( tai.fInTable )
{
iTap_current = 1;
short current_count_column = 0;
//check all SPRMs of this TAPX
for ( std::list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ )
{
//find the tDef SPRM
DWORD code = iter->OpCode;
switch(iter->OpCode)
{
case sprmPFInnerTableCell:
case sprmPFInnerTtp:
case sprmTDefTable:
case sprmOldTDefTable:
{
fEndNestingLevel = ( iter->Arguments[0] == 1 ) ? (true) : (false);
}break;
//SprmTDefTable tdef(iter->Arguments, iter->argumentsSize);
//int itcMac = tdef.numberOfColumns;
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;
unsigned char itcMac = iter->Arguments[0];
switch(iter->OpCode)
{
case sprmTDefTable:
case sprmOldTDefTable:
short boundary1, boundary2;
for (unsigned char i = 0; i < itcMac; i++)
{
unsigned char itcMac = iter->Arguments[0];
boundary1 = FormatUtils::BytesToInt16( iter->Arguments + 1, i * 2 , iter->argumentsSize );
boundary2 = FormatUtils::BytesToInt16( iter->Arguments + 1, ( i + 1 ) * 2, iter->argumentsSize );
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(boundary1, boundary2, boundaries);
}
if (max_boundary < boundary2)
max_boundary = boundary2;
AddBoundary(boundary2, max_boundary, boundaries);
}break;
}
AddBoundary(boundary2, max_boundary, boundaries);
}break;
}
}
if (nestingLevel > 1 && fEndNestingLevel && !boundaries.empty())
break;
if (current_count_column > count_column)
count_column = current_count_column;
//get the next papx
papx = findValidPapx( fcRowEnd );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
fcRowEnd = findRowEndFc( cp, cp, nestingLevel );
if (papx_prev && papx_prev == papx )
break;//file(12).doc
papx_prev = papx;
}
if ( !boundaries.empty() )
@ -1384,7 +1358,7 @@ namespace DocFileFormat
void DocumentMapping::AddBoundary(short boundary1, short boundary2, std::map<short, short> &boundaries)
{
if (boundary2 - boundary1 < 3)
if (boundary2 - boundary1 < 10)
return;
std::map<short, short>::iterator pFind = boundaries.find(boundary1);
@ -1423,7 +1397,7 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
if ( nestingLevel > 1 )
{
@ -1439,7 +1413,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
cp++;
}
@ -1462,7 +1436,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
cp++;
}
}
@ -1481,7 +1455,7 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
if ( nestingLevel > 1 )
{
@ -1501,7 +1475,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
cp++;
}
@ -1524,7 +1498,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
cp++;
}
}
@ -1539,14 +1513,14 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
//start w:tr
m_pXmlWriter->WriteNodeBegin( L"w:tr" );
//convert the properties
int fcRowEnd = findRowEndFc( cp, nestingLevel );
TablePropertyExceptions tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->nWordVersion);
TablePropertyExceptions tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->bOlderVersion);
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions( fcRowEnd, fcRowEnd + 1 );
TableRowPropertiesMapping* trpMapping = new TableRowPropertiesMapping( m_pXmlWriter, *(chpxs->begin()) );
@ -1570,7 +1544,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos(cp );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
}
}
else
@ -1587,7 +1561,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
}
}
@ -1608,8 +1582,10 @@ namespace DocFileFormat
int cp = initialCp;
int cpCellEnd = findCellEndCp( initialCp, nestingLevel );
XMLTools::CStringXmlWriter writerTcPr;
TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( &writerTcPr, grid, gridIndex, cellIndex, nestingLevel );
//start w:tc
m_pXmlWriter->WriteNodeBegin( L"w:tc" );
TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( m_pXmlWriter, grid, gridIndex, cellIndex );
if ( tapx != NULL )
{
@ -1618,19 +1594,8 @@ 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 )
{
@ -1638,7 +1603,7 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos( cp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
//cp = writeParagraph(cp);
@ -1658,7 +1623,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph( cp, 0x7fffffff );
cp = writeParagraph( cp );
}
}
@ -1677,7 +1642,7 @@ namespace DocFileFormat
int fc = m_document->FindFileCharPos( initialCp );
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
while ( !tai.fInnerTableCell )
{
@ -1686,7 +1651,7 @@ namespace DocFileFormat
fc = m_document->FindFileCharPos( cpCellEnd );
papx = findValidPapx( fc );
tai = TableInfo( papx, m_document->nWordVersion );
tai = TableInfo( papx );
}
cpCellEnd++;
@ -1807,8 +1772,13 @@ namespace DocFileFormat
// Checks if the CHPX is special
bool DocumentMapping::isSpecial(CharacterPropertyExceptions* chpx)
{
if (!chpx) return false;
if (!chpx->grpprl) return false;
/*
for (list<SinglePropertyModifier>::iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); ++iter)
{
short value = FormatUtils::BytesToInt16 (iter->Arguments, 0, iter->argumentsSize);
int c = 0;
}
*/
for (std::list<SinglePropertyModifier>::iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); ++iter)
{
@ -1878,11 +1848,6 @@ namespace DocFileFormat
{
SectionPropertyExceptions* ret = NULL;
if (!m_document->AllSepx)
{
return ret;
}
try
{
ret = m_document->AllSepx->operator [](cp);

View File

@ -87,7 +87,7 @@ namespace DocFileFormat
bool isSectionEnd ( int cp );
// Writes a Paragraph that starts at the given cp and
// ends at the next paragraph end mark or section end mark
int writeParagraph( int cp, int cpEnd );
int writeParagraph( int cp );
// Writes a Paragraph that starts at the given cpStart and
// ends at the given cpEnd
int writeParagraph( int initialCp, int cpEnd, bool sectionEnd, bool lastBad = false );

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -63,35 +63,7 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( L"xmlns:o", OpenXmlNamespaces::Office );
m_pXmlWriter->WriteAttribute( L"xmlns:w10", OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute( L"xmlns:r", OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteAttribute( L"xmlns:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" );
m_pXmlWriter->WriteAttribute( L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
m_pXmlWriter->WriteAttribute( L"xmlns:wp14", L"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
m_pXmlWriter->WriteAttribute( L"xmlns:wp", L"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
m_pXmlWriter->WriteAttribute( L"xmlns:w14", L"http://schemas.microsoft.com/office/word/2010/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:wpg", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" );
m_pXmlWriter->WriteAttribute( L"xmlns:wpi", L"http://schemas.microsoft.com/office/word/2010/wordprocessingInk" );
m_pXmlWriter->WriteAttribute( L"xmlns:wne", L"http://schemas.microsoft.com/office/word/2006/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:wps", L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape" );
m_pXmlWriter->WriteAttribute( L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main" );
m_pXmlWriter->WriteAttribute( L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math" );
m_pXmlWriter->WriteAttribute( L"mc:Ignorable", L"w14 wp14" );
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
//m_pXmlWriter->WriteNodeBegin( L"w:footnote", TRUE );
//m_pXmlWriter->WriteAttribute( L"w:type", L"separator");
//m_pXmlWriter->WriteAttribute( L"w:id", L"-1");
//m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
//m_pXmlWriter->WriteString(L"<w:p><w:pPr><w:spacing w:lineRule=\"auto\" w:line=\"240\" w:after=\"0\"/></w:pPr><w:r></w:r><w:r><w:separator/></w:r></w:p>");
//m_pXmlWriter->WriteNodeEnd( L"w:footnote");
//m_pXmlWriter->WriteNodeBegin( L"w:footnote", TRUE );
//m_pXmlWriter->WriteAttribute( L"w:type", L"continuationSeparator");
//m_pXmlWriter->WriteAttribute( L"w:id", L"0");
//m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
//m_pXmlWriter->WriteString(L"<w:p><w:pPr><w:spacing w:lineRule=\"auto\" w:line=\"240\" w:after=\"0\"/></w:pPr><w:r></w:r><w:r><w:continuationSeparator/></w:r></w:p>");
//m_pXmlWriter->WriteNodeEnd( L"w:footnote");
int cp = m_document->FIB->m_RgLw97.ccpText;
@ -109,7 +81,7 @@ namespace DocFileFormat
if (fc < 0) break;
ParagraphPropertyExceptions* papx = findValidPapx( fc );
TableInfo tai( papx, m_document->nWordVersion );
TableInfo tai( papx );
if ( tai.fInTable )
{
@ -121,7 +93,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph( cp, 0x7fffffff );
cp = writeParagraph( cp );
}
while (cp <= cpStart) //conv_fQioC665ib4ngHkDGY4__docx.doc
cp++;

View File

@ -46,7 +46,7 @@ std::wstring readXstz(VirtualStreamReader *reader)
std::wstring ret;
if (cch > 0 && cch < 0x0fff)
if (cch > 0)
{
std::shared_ptr<unsigned char>data = std::shared_ptr<unsigned char>(reader->ReadBytes(cch * 2, true));
#if defined(_WIN32) || defined(_WIN64)
@ -98,7 +98,7 @@ void FormFieldData::_FFData::read(VirtualStreamReader *reader)
xstzEntryMcr = readXstz(reader);
xstzExitMcr = readXstz(reader);
}
FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, int nWordVersion )
FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, bool bOlderVersion_ )
{
binary_data_size = 0;
@ -139,7 +139,7 @@ FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx,
if (fc >= 0 && bNilPICFAndBinData)
{
VirtualStreamReader reader(stream, fc, nWordVersion);
VirtualStreamReader reader(stream, fc, bOlderVersion_);
int sz_stream = reader.GetSize();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -32,8 +32,6 @@
#include "ListData.h"
#include <boost/make_shared.hpp>
#include <algorithm>
#include <functional>
#include <cctype>
@ -48,11 +46,6 @@ namespace DocFileFormat
RELEASEOBJECT(rglvl);
}
ListDataPtr ListData::create(VirtualStreamReader* reader, int length)
{
return boost::make_shared<ListData>(reader, length);
}
// Parses the StreamReader to retrieve a ListData
ListData::ListData(VirtualStreamReader* reader, int length) : rglvl(NULL)
@ -87,85 +80,9 @@ namespace DocFileFormat
grfhic = reader->ReadByte();
}
NumberingDescriptorPtr NumberingDescriptor::create(unsigned char * data, int length)
{
return boost::make_shared<NumberingDescriptor>(data, length);
}
bool NumberingDescriptor::operator == (const NumberingDescriptor & val) const
{
const bool res =
nfc == val.nfc &&
cbTextBefore == val.cbTextBefore &&
cbTextAfter == val.cbTextAfter &&
jc == val.jc &&
fPrev == val.fPrev &&
fHang == val.fHang &&
fSetBold == val.fSetBold &&
fSetItalic == val.fSetItalic &&
fSetSmallCaps == val.fSetSmallCaps &&
fSetCaps == val.fSetCaps &&
fSetStrike == val.fSetStrike &&
fSetKul == val.fSetKul &&
fPrevSpace == val.fPrevSpace &&
fBold == val.fBold &&
fItalic == val.fItalic &&
fSmallCaps == val.fSmallCaps &&
fCaps == val.fCaps &&
fStrike == val.fStrike &&
kul == val.kul &&
ico == val.ico &&
ftc == val.ftc &&
hps == val.hps &&
iStartAt == val.iStartAt &&
dxaIndent == val.dxaIndent &&
dxaSpace == val.dxaSpace &&
fNumber1 == val.fNumber1 &&
fNumberAcross == val.fNumberAcross &&
fRestartHdn == val.fRestartHdn &&
fSpareX == val.fSpareX;
return res;
}
bool NumberingDescriptor::operator == (const NumberingDescriptorPtr & val) const
{
if (!val) return false;
const bool res =
nfc == val->nfc &&
cbTextBefore == val->cbTextBefore &&
cbTextAfter == val->cbTextAfter &&
jc == val->jc &&
fPrev == val->fPrev &&
fHang == val->fHang &&
fSetBold == val->fSetBold &&
fSetItalic == val->fSetItalic &&
fSetSmallCaps == val->fSetSmallCaps &&
fSetCaps == val->fSetCaps &&
fSetStrike == val->fSetStrike &&
fSetKul == val->fSetKul &&
fPrevSpace == val->fPrevSpace &&
fBold == val->fBold &&
fItalic == val->fItalic &&
fSmallCaps == val->fSmallCaps &&
fCaps == val->fCaps &&
fStrike == val->fStrike &&
kul == val->kul &&
ico == val->ico &&
ftc == val->ftc &&
hps == val->hps &&
iStartAt == val->iStartAt &&
dxaIndent == val->dxaIndent &&
dxaSpace == val->dxaSpace &&
fNumber1 == val->fNumber1 &&
fNumberAcross == val->fNumberAcross &&
fRestartHdn == val->fRestartHdn &&
fSpareX == val->fSpareX;
return res;
}
NumberingDescriptor::NumberingDescriptor( unsigned char * data, int length )
{
id = 0;
nfc = FormatUtils::BytesToUChar(data, 0, length);
cbTextBefore = FormatUtils::BytesToUChar(data, 1, length);
cbTextAfter = FormatUtils::BytesToUChar(data, 2, length);
@ -235,53 +152,37 @@ namespace DocFileFormat
}
OutlineListDescriptor::OutlineListDescriptor( unsigned char * data, int length )
{
if (length < 212)
int pos = 0;
for (int i = 0 ; i < 9; i++)
{
//int sz = FormatUtils::BytesToUChar(data, 0, length);
int pos = 0;
for (int i = 0 ; i < 9; i++)
{
lvl[i].Parse(data + pos, 1);
pos += 1;
}
lvl[i].Parse(data + pos, length - pos);
pos += 16;
}
else
fRestartHdr = FormatUtils::BytesToUChar(data, pos, length); pos += 2;
fSpareOlst2 = FormatUtils::BytesToUChar(data, pos, length); pos += 2;
fSpareOlst3 = FormatUtils::BytesToUChar(data, pos, length); pos += 2;
fSpareOlst4 = FormatUtils::BytesToUChar(data, pos, length); pos += 2;
short strLen = length - pos;
while (strLen > 0)
{
int pos = 0;
for (int i = 0 ; i < 9; i++)
{
lvl[i].Parse(data + pos, length - pos);
pos += 16;
}
fRestartHdr = FormatUtils::BytesToUChar(data, pos, length); pos += 2;
fSpareOlst2 = FormatUtils::BytesToUChar(data, pos, length); pos += 2;
fSpareOlst3 = FormatUtils::BytesToUChar(data, pos, length); pos += 2;
fSpareOlst4 = FormatUtils::BytesToUChar(data, pos, length); pos += 2;
short strLen = length - pos;
while (strLen > 0)
{
if (data[strLen + 20 - 1] != 0)
break;
strLen--;
}
if (strLen > 0)
{
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(xst), data + 20, ( strLen ), ENCODING_WINDOWS_1250);
}
if (data[strLen + 20 - 1] != 0)
break;
strLen--;
}
if (strLen > 0)
{
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &(xst), data + 20, ( strLen ), ENCODING_WINDOWS_1250);
}
}
ByteStructure* OutlineListDescriptor::ConstructObject(VirtualStreamReader* reader, int length)
{
int sz = GetSize(reader->nWordVersion);
unsigned char *data = reader->ReadBytes(sz, true);
OutlineListDescriptor *newObject = new OutlineListDescriptor(data, sz);
unsigned char *data = reader->ReadBytes(212, true);
OutlineListDescriptor *newObject = new OutlineListDescriptor(data, 212);
delete []data;

View File

@ -36,9 +36,6 @@
namespace DocFileFormat
{
class ListData;
typedef class boost::shared_ptr<ListData> ListDataPtr;
class ListData
{
friend class ListTable;
@ -77,20 +74,15 @@ namespace DocFileFormat
virtual ~ListData();
ListData( VirtualStreamReader* reader, int length );
static ListDataPtr create(VirtualStreamReader* reader, int length);
};
class NumberingDescriptor;
typedef class boost::shared_ptr<NumberingDescriptor> NumberingDescriptorPtr;
class NumberingDescriptor : public IVisitable
{
friend class ListTable;
friend class NumberingMapping;
private:
size_t id;
unsigned char nfc;
unsigned char cbTextBefore;
unsigned char cbTextAfter;
@ -129,15 +121,9 @@ namespace DocFileFormat
std::wstring xst; //32 chars ansi
public:
bool operator == (const NumberingDescriptor & val) const;
bool operator == (const NumberingDescriptorPtr & val) const;
virtual ~NumberingDescriptor(){}
// Parses the given StreamReader to retrieve a ANLD struct
NumberingDescriptor( unsigned char * data, int length ); //cbANLD (count of bytes of ANLD) is 52
static NumberingDescriptorPtr create(unsigned char * data, int length);
};
@ -157,13 +143,8 @@ namespace DocFileFormat
std::wstring xst; //64 chars ansi
public:
static const int STRUCTURE_SIZE = 212;
static const int STRUCTURE_SIZE_OLD = 10;
public:
static const int GetSize(int nWordVersion)
{
return (nWordVersion == 2) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length );
virtual ~OutlineListDescriptor();

View File

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

View File

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

View File

@ -38,13 +38,14 @@ namespace DocFileFormat
{
ListTable::~ListTable()
{
for_each( this->listData.begin(), this->listData.end(), DeleteDynamicObject() );
}
ListTable::ListTable( FileInformationBlock* fib, POLE::Stream* tableStream )
{
if ( fib->m_FibWord97.lcbPlfLst > 0 )
{
VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLst, fib->m_nWordVersion);
VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLst, fib->m_bOlderVersion);
if (fib->m_FibWord97.fcPlfLst > reader.GetSize()) return;
@ -58,32 +59,23 @@ namespace DocFileFormat
//read the LSTF structs
for ( int i = 0; i < count; i++ )
{
listData.push_back( ListData::create( &reader, ListData::VARIABLE_LENGTH ) );
listData.push_back( new ListData( &reader, ListData::VARIABLE_LENGTH ) );
}
//read the LVLF structs
for ( size_t i = 0; i < listData.size(); ++i)
for ( std::list<ListData*>::iterator iter = listData.begin(); iter != listData.end(); iter++ )
{
for ( size_t j = 0; j < listData[i]->rglvl->size(); j++ )
for ( unsigned int j = 0; j < (*iter)->rglvl->size(); j++ )
{
listData[i]->rglvl->operator []( j ) = new ListLevel( &reader, ListData::VARIABLE_LENGTH );
(*iter)->rglvl->operator []( j ) = new ListLevel( &reader, ListData::VARIABLE_LENGTH );
}
}
}
}
size_t ListTable::appendNumbering( NumberingDescriptorPtr &desc )
void ListTable::appendNumbering( const NumberingDescriptor & desc )
{
for (size_t i = 0; i < listNumbering.size(); ++i)
{
if (listNumbering[i]->operator==(desc))
{
return listNumbering[i]->id;
}
}
desc->id = listData.size() + listNumbering.size()/* + 1*/;
listNumbering.push_back(desc);
return desc->id;
}
}

View File

@ -41,12 +41,12 @@ namespace DocFileFormat
class ListTable: public IVisitable
{
public:
std::vector<ListDataPtr> listData;
std::vector<NumberingDescriptorPtr> listNumbering;
std::list<ListData*> listData;
std::list<NumberingDescriptor> listNumbering;
virtual ~ListTable();
ListTable( FileInformationBlock* fib, POLE::Stream* tableStream );
size_t appendNumbering( NumberingDescriptorPtr &desc );
void appendNumbering( const NumberingDescriptor & desc );
};
}

View File

@ -59,27 +59,22 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute(L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
m_pXmlWriter->WriteAttribute(L"xmlns:v", OpenXmlNamespaces::VectorML );
m_pXmlWriter->WriteAttribute(L"xmlns:o", OpenXmlNamespaces::Office );
m_pXmlWriter->WriteAttribute(L"xmlns:r", OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteAttribute(L"xmlns:w10", OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute(L"xmlns:r", OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteAttribute(L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math");
m_pXmlWriter->WriteAttribute(L"xmlns:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
m_pXmlWriter->WriteAttribute(L"xmlns:cx", L"http://schemas.microsoft.com/office/drawing/2014/chartex");
m_pXmlWriter->WriteAttribute(L"xmlns:cx1", L"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex");
m_pXmlWriter->WriteAttribute(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
m_pXmlWriter->WriteAttribute(L"xmlns:wp14", L"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
m_pXmlWriter->WriteAttribute(L"xmlns:wp", L"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
m_pXmlWriter->WriteAttribute(L"xmlns:w14", L"http://schemas.microsoft.com/office/word/2010/wordml");
m_pXmlWriter->WriteAttribute(L"xmlns:w15", L"http://schemas.microsoft.com/office/word/2012/wordml");
m_pXmlWriter->WriteAttribute(L"xmlns:w16se", L"http://schemas.microsoft.com/office/word/2015/wordml/symex");
m_pXmlWriter->WriteAttribute(L"xmlns:wpg", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
m_pXmlWriter->WriteAttribute(L"xmlns:wpi", L"http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
m_pXmlWriter->WriteAttribute(L"xmlns:wne", L"http://schemas.microsoft.com/office/word/2006/wordml");
m_pXmlWriter->WriteAttribute(L"xmlns:wps", L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
m_pXmlWriter->WriteAttribute(L"mc:Ignorable", L"w14 w15 w16se wp14");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
//m_pXmlWriter->WriteAttribute(L"xmlns:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
//m_pXmlWriter->WriteAttribute(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
//m_pXmlWriter->WriteAttribute(L"xmlns:wp14", L"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
//m_pXmlWriter->WriteAttribute(L"xmlns:wp", L"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
//m_pXmlWriter->WriteAttribute(L"xmlns:w14", L"http://schemas.microsoft.com/office/word/2010/wordml");
//m_pXmlWriter->WriteAttribute(L"xmlns:wpg", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
//m_pXmlWriter->WriteAttribute(L"xmlns:wpi", L"http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
//m_pXmlWriter->WriteAttribute(L"xmlns:wne", L"http://schemas.microsoft.com/office/word/2006/wordml");
//m_pXmlWriter->WriteAttribute(L"xmlns:wps", L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
//m_pXmlWriter->WriteAttribute(L"mc:Ignorable", L"w14 wp14");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
if ((m_document->GetOfficeArt()) && (m_document->GetOfficeArt()->GetShapeBackgound()))
{
@ -115,7 +110,7 @@ namespace DocFileFormat
int countText = m_document->FIB->m_RgLw97.ccpText;
int countTextRel = m_document->FIB->m_RgLw97.ccpText - 1;
while (cp < countText && cp >= 0)
while (cp < countText)
{
fc = m_document->FindFileCharPos(cp);
@ -125,7 +120,7 @@ namespace DocFileFormat
if (papx)
{
TableInfo tai(papx, m_document->nWordVersion);
TableInfo tai(papx);
if (tai.fInTable)
{
int cpStart = cp;
@ -140,7 +135,7 @@ namespace DocFileFormat
else
{
//this PAPX is for a normal paragraph
cp = writeParagraph(cp, countTextRel);
cp = writeParagraph(cp);
}
}
else

View File

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

View File

@ -72,42 +72,33 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( L"xmlns:o", OpenXmlNamespaces::Office );
m_pXmlWriter->WriteAttribute( L"xmlns:w10", OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute( L"xmlns:r", OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteAttribute( L"xmlns:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" );
m_pXmlWriter->WriteAttribute( L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
m_pXmlWriter->WriteAttribute( L"xmlns:wp14", L"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
m_pXmlWriter->WriteAttribute( L"xmlns:wp", L"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
m_pXmlWriter->WriteAttribute( L"xmlns:w14", L"http://schemas.microsoft.com/office/word/2010/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:wpg", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" );
m_pXmlWriter->WriteAttribute( L"xmlns:wpi", L"http://schemas.microsoft.com/office/word/2010/wordprocessingInk" );
m_pXmlWriter->WriteAttribute( L"xmlns:wne", L"http://schemas.microsoft.com/office/word/2006/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:wps", L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape" );
m_pXmlWriter->WriteAttribute( L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main" );
m_pXmlWriter->WriteAttribute( L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math" );
m_pXmlWriter->WriteAttribute( L"mc:Ignorable", L"w14 wp14" );
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
PictureBulletsMapping();
for (size_t i = 0; i < rglst->listData.size(); ++i)
int i = 0;
for (std::list<ListData*>::iterator iter = rglst->listData.begin(); iter != rglst->listData.end(); ++iter, ++i)
{
//start abstractNum
m_pXmlWriter->WriteNodeBegin( L"w:abstractNum", TRUE );
m_pXmlWriter->WriteAttribute( L"w:abstractNumId", FormatUtils::IntToWideString( i /*+ 1 */));
m_pXmlWriter->WriteAttribute( L"w:abstractNumId", FormatUtils::IntToWideString( i ));
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
//nsid
m_pXmlWriter->WriteNodeBegin( L"w:nsid", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToFormattedWideString( rglst->listData[i]->lsid, L"%08x" ));
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToFormattedWideString( (*iter)->lsid, L"%08x" ));
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
//multiLevelType
m_pXmlWriter->WriteNodeBegin( L"w:multiLevelType", TRUE );
if ( rglst->listData[i]->fHybrid )
if ( (*iter)->fHybrid )
{
m_pXmlWriter->WriteAttribute( L"w:val", L"hybridMultilevel" );
}
else if ( rglst->listData[i]->fSimpleList )
else if ( (*iter)->fSimpleList )
{
m_pXmlWriter->WriteAttribute( L"w:val", L"singleLevel" );
}
@ -120,32 +111,32 @@ namespace DocFileFormat
//template
m_pXmlWriter->WriteNodeBegin( L"w:tmpl", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToFormattedWideString( rglst->listData[i]->tplc, L"%08x"));
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToFormattedWideString( (*iter)->tplc, L"%08x"));
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
// writes the levels
size_t length = rglst->listData[i]->rglvl->size();
size_t length = (*iter)->rglvl->size();
for (size_t j = 0; j < length; ++j)
{
ListLevel* lvl = rglst->listData[i]->rglvl->at(j);
LevelMapping(lvl, j, rglst->listData[i]->rgistd[j]);
ListLevel* lvl = (*iter)->rglvl->at(j);
LevelMapping(lvl, j, (*iter)->rgistd[j]);
}
//end abstractNum
m_pXmlWriter->WriteNodeEnd( L"w:abstractNum" );
}
//write old style numbering (сложносоставных не сущестует)
for (size_t i = 0; i < rglst->listNumbering.size(); ++i)
for (std::list<NumberingDescriptor>::iterator iter = rglst->listNumbering.begin(); iter != rglst->listNumbering.end(); ++iter, ++i)
{
//start abstractNum
m_pXmlWriter->WriteNodeBegin( L"w:abstractNum", TRUE );
m_pXmlWriter->WriteAttribute( L"w:abstractNumId", FormatUtils::IntToWideString( rglst->listNumbering[i]->id ));
m_pXmlWriter->WriteAttribute( L"w:abstractNumId", FormatUtils::IntToWideString( i ));
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
////nsid
//m_pXmlWriter->WriteNodeBegin( L"w:nsid", TRUE );
//m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToFormattedWideString( rglst->listNumbering[i]->lsid, L"%08x" ) ));
//m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToFormattedWideString( (*iter)->lsid, L"%08x" ) ));
//m_pXmlWriter->WriteNodeEnd( L"", TRUE );
//multiLevelType
@ -156,14 +147,14 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
LevelMapping(rglst->listNumbering[i], 0);
LevelMapping(*iter, 0);
//end abstractNum
m_pXmlWriter->WriteNodeEnd( L"w:abstractNum" );
}
//write the overrides
for (size_t i = 0; i < m_document->listFormatOverrideTable->size(); ++i)
for (unsigned int i = 0; i < m_document->listFormatOverrideTable->size(); ++i)
{
ListFormatOverride* lfo = m_document->listFormatOverrideTable->at(i);
@ -202,15 +193,16 @@ namespace DocFileFormat
if (m_document->listFormatOverrideTable->empty() && !rglst->listNumbering.empty())
{
for (size_t i = 0; i < rglst->listNumbering.size(); ++i)
i = 0;
for (std::list<NumberingDescriptor>::iterator iter = rglst->listNumbering.begin(); iter != rglst->listNumbering.end(); ++iter, ++i)
{
m_pXmlWriter->WriteNodeBegin( L"w:num", TRUE );
m_pXmlWriter->WriteAttribute( L"w:numId", FormatUtils::IntToWideString(rglst->listNumbering[i]->id));
m_pXmlWriter->WriteAttribute( L"w:numId", FormatUtils::IntToWideString(i+1));
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteNodeBegin( L"w:abstractNumId", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToWideString( rglst->listNumbering[i]->id ));
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToWideString( i ));
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
m_pXmlWriter->WriteNodeEnd(L"w:num");
@ -223,20 +215,21 @@ namespace DocFileFormat
}
}
int NumberingMapping::FindIndexbyId(std::vector<ListDataPtr>& listData, int lsid)
int NumberingMapping::FindIndexbyId(const std::list<ListData*>& listData, int id)
{
int ret = -1;
int i = 0;
for (size_t i = 0; i < listData.size(); ++i)
for (std::list<ListData*>::const_iterator iter = listData.begin(); iter != listData.end(); ++iter, ++i)
{
if (listData[i]->lsid == lsid)
if ((*iter)->lsid == id)
{
return i;
ret = i;
break;
}
}
return -1;
return ret;
}
// Converts the number text of the binary format to the number text of OOXML.
@ -295,17 +288,15 @@ namespace DocFileFormat
return ret;
}
std::wstring NumberingMapping::GetLvlText(NumberingDescriptorPtr& lvl, bool bIsSymbol, int Before, int After) const
std::wstring NumberingMapping::GetLvlText(const NumberingDescriptor& lvl, bool bIsSymbol, int Before, int After) const
{
if (!lvl)return L"";
std::wstring ret;
if (lvl->nfc == 0xff)
if (lvl.nfc == 0xff)
{
if (!lvl->xst.empty())
if (!lvl.xst.empty())
{
wchar_t xchBullet = lvl->xst[0];
wchar_t xchBullet = lvl.xst[0];
// В символьном шрифте обрезать надо, в других случаях - нет
if (bIsSymbol && (xchBullet & 0xF000) != 0)
@ -315,7 +306,7 @@ namespace DocFileFormat
if (!FormatUtils::IsControlSymbol(xchBullet))
{
ret.push_back(lvl->xst[0]);
ret.push_back(lvl.xst[0]);
}
}
else
@ -325,8 +316,8 @@ namespace DocFileFormat
}
else
{
std::wstring strBefore = lvl->xst.substr(0, Before);
std::wstring strAfter = lvl->xst.substr(Before, After);
std::wstring strBefore = lvl.xst.substr(0, Before);
std::wstring strAfter = lvl.xst.substr(Before, After);
ret = strBefore + L"%1" + strAfter ;
}
@ -347,9 +338,9 @@ namespace DocFileFormat
}
std::wstring NumberingMapping::GetNumberFormatWideString(int nfc, int nWordVersion)
std::wstring NumberingMapping::GetNumberFormatWideString(int nfc, bool bOlderVersion)
{
if (nWordVersion > 0 && nfc > 5)
if (bOlderVersion && nfc > 5)
{
if (nfc == 0xff) return std::wstring( L"bullet");
else return std::wstring( L"none");
@ -482,16 +473,14 @@ namespace DocFileFormat
}
}
void NumberingMapping::LevelMapping(NumberingDescriptorPtr & lvl, unsigned int level)
void NumberingMapping::LevelMapping(const NumberingDescriptor& lvl, unsigned int level)
{
if (!lvl) return;
std::wstring fontFamily;
bool isSymbol = false;
if( lvl->ftc < m_document->FontTable->Data.size() )
if( lvl.ftc < m_document->FontTable->Data.size() )
{
FontFamilyName* ffn = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( lvl->ftc ) );
FontFamilyName* ffn = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( lvl.ftc ) );
isSymbol = (ffn->chs == 2);
fontFamily = FormatUtils::XmlEncode(ffn->xszFtn);
}
@ -502,22 +491,22 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteNodeBegin( L"w:start", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToWideString(lvl->iStartAt));
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToWideString(lvl.iStartAt));
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
m_pXmlWriter->WriteNodeBegin( L"w:numFmt", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", GetNumberFormatWideString(lvl->nfc, true));
m_pXmlWriter->WriteAttribute( L"w:val", GetNumberFormatWideString(lvl.nfc, true));
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
//// suffix
// m_pXmlWriter->WriteNodeBegin( L"w:suff", TRUE );
// m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::MapValueToWideString(lvl->ixchFollow, &FollowingCharMap[0][0], 3, 8));
// m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::MapValueToWideString(lvl.ixchFollow, &FollowingCharMap[0][0], 3, 8));
// m_pXmlWriter->WriteNodeEnd( L"", TRUE );
// Number level text
std::wstring lvlText = GetLvlText(lvl, isSymbol, lvl->cbTextBefore, lvl->cbTextAfter);
std::wstring lvlText = GetLvlText(lvl, isSymbol, lvl.cbTextBefore, lvl.cbTextAfter);
//if (lvlText.empty() && lvl->ftc == 0)//auto
//if (lvlText.empty() && lvl.ftc == 0)//auto
//{
// lvlText.push_back(L'\xF0B7');
// lvlText.push_back(L'\0');
@ -533,7 +522,7 @@ namespace DocFileFormat
// jc
m_pXmlWriter->WriteNodeBegin( L"w:lvlJc", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::MapValueToWideString(lvl->jc, &LevelJustificationMap[0][0], 3, 7));
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::MapValueToWideString(lvl.jc, &LevelJustificationMap[0][0], 3, 7));
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
// pPr
m_pXmlWriter->WriteNodeBegin( L"w:pPr", FALSE );
@ -644,7 +633,7 @@ namespace DocFileFormat
if ((chpxs != NULL) && (!chpxs->empty()))
{
PictureDescriptor pict(chpxs->front(), m_document->DataStream, fcEnd - fc, m_document->nWordVersion);
PictureDescriptor pict(chpxs->front(), m_document->DataStream, fcEnd - fc, m_document->FIB->m_bOlderVersion);
if ((pict.mfp.mm > 98) && (pict.shapeContainer != NULL))
{

View File

@ -63,9 +63,9 @@ namespace DocFileFormat
NumberingMapping(ConversionContext* ctx);
void Apply(IVisitable* visited);
static int FindIndexbyId(std::vector<ListDataPtr>& listData, int id);
static int FindIndexbyId(const std::list<ListData*>& listData, int id);
/// Converts the number format code of the binary format.
static std::wstring GetNumberFormatWideString(int nfc, int nWordVersion = 0);
static std::wstring GetNumberFormatWideString(int nfc, bool bOlderVersion = false);
virtual ~NumberingMapping();
@ -73,12 +73,12 @@ namespace DocFileFormat
// Converts the number text of the binary format to the number text of OOXML.
// OOXML uses different placeholders for the numbers.
std::wstring GetLvlText(const ListLevel* lvl, bool bIsSymbol) const;
std::wstring GetLvlText(NumberingDescriptorPtr& lvl, bool bIsSymbol, int Before, int After) const;
std::wstring GetLvlText(const NumberingDescriptor& lvl, bool bIsSymbol, int Before, int After) const;
static bool IsPlaceholder(wchar_t symbol);
void LevelMapping(const ListLevel* lvl, unsigned int level, short styleIndex);
void LevelMapping(NumberingDescriptorPtr & lvl, unsigned int level);
void LevelMapping(const NumberingDescriptor& lvl, unsigned int level);
void PictureBulletsMapping();
void WriteLevelPictureBullet(const CharacterPropertyExceptions* grpprlChpx);

View File

@ -58,9 +58,9 @@ namespace DocFileFormat
public:
OfficeArtContent (const FileInformationBlock* pFIB, POLE::Stream* pStream): m_pDrawingGroupData(NULL), m_pBackgroud(NULL), m_uLastShapeId(1024)
OfficeArtContent (const FileInformationBlock* pFIB, POLE::Stream* pStream): m_pDrawingGroupData(NULL), m_pBackgroud(NULL)
{
VirtualStreamReader oStearmReader(pStream, 0 , pFIB->m_nWordVersion);
VirtualStreamReader oStearmReader(pStream, 0 , pFIB->m_bOlderVersion);
if (pFIB->m_FibWord97.fcDggInfo > oStearmReader.GetSize()) return;
@ -86,6 +86,7 @@ namespace DocFileFormat
{
if (GroupContainer::TYPE_CODE_0xF003 == groupChild->TypeCode)
{
// the child is a subgroup
GroupContainer* group = static_cast<GroupContainer*>(groupChild);
if (group)
{
@ -94,24 +95,17 @@ namespace DocFileFormat
}
else if (ShapeContainer::TYPE_CODE_0xF004 == groupChild->TypeCode)
{
// the child is a shape
ShapeContainer* shape = static_cast<ShapeContainer*>(groupChild);
if (shape)
{
shape->m_nIndex = i;
if (shape->m_bBackground)
shape->Index = i;
if (shape->isBackground())
{
m_pBackgroud = shape;
}
}
}
else if (DrawingRecord::TYPE_CODE_0xF008 == groupChild->TypeCode)
{
DrawingRecord* dr = static_cast<DrawingRecord*>(groupChild);
if (dr)
{
m_uLastShapeId = dr->spidCur;
}
}
}
}
@ -189,7 +183,7 @@ namespace DocFileFormat
{
return m_pDrawingGroupData;
}
unsigned int m_uLastShapeId;
private:
ShapeContainer* m_pBackgroud;
DrawingGroup* m_pDrawingGroupData;

View File

@ -40,13 +40,13 @@ namespace DocFileFormat
public:
static const unsigned short TYPE_CODE_0xF010 = 0xF010;
ClientAnchor() : Record(), value(0)
ClientAnchor() : Record(), clientanchor(0)
{
}
ClientAnchor (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance), value(0)
ClientAnchor (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance), clientanchor(0)
{
value = Reader->ReadInt32(); //index PlcfSpa
clientanchor = Reader->ReadInt32();
}
virtual ~ClientAnchor()
@ -58,6 +58,8 @@ namespace DocFileFormat
return new ClientAnchor (_reader, bodySize, typeCode, version, instance);
}
unsigned int value;
private:
int clientanchor;
};
}

View File

@ -38,30 +38,30 @@ namespace DocFileFormat
class DrawingRecord: public Record
{
public:
static const unsigned short TYPE_CODE_0xF008 = 0xF008;
static const unsigned short TYPE_CODE_0xF008 = 0xF008;
unsigned int csp; // The number of shapes in this drawing
unsigned int spidCur; // The last MSOSPID given to an SP in this DG
unsigned int csp; // The number of shapes in this drawing
int spidCur; // The last MSOSPID given to an SP in this DG
DrawingRecord():
Record(), csp(0), spidCur(0)
{
}
DrawingRecord():
Record(), csp(0), spidCur(0)
{
}
DrawingRecord( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ):
Record( _reader, size, typeCode, version, instance )
{
DrawingRecord( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ):
Record( _reader, size, typeCode, version, instance )
{
csp = Reader->ReadUInt32();
spidCur = Reader->ReadInt32();
}
}
virtual ~DrawingRecord()
{
}
virtual ~DrawingRecord()
{
}
virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance )
{
return new DrawingRecord( _reader, bodySize, typeCode, version, instance );
}
virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance )
{
return new DrawingRecord( _reader, bodySize, typeCode, version, instance );
}
};
}

View File

@ -65,7 +65,7 @@ namespace DocFileFormat
{
// the child is a shape
ShapeContainer* shape = static_cast<ShapeContainer*>(groupChild);
shape->m_nIndex = i;
shape->Index = i;
this->Children[i] = shape;
}
}

View File

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

View File

@ -50,9 +50,13 @@ namespace DocFileFormat
/*========================================================================================================*/
Record::Record( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ):
HeaderSize(Record::HEADER_SIZE_IN_BYTES), BodySize(bodySize), RawData(NULL), SiblingIdx(0), TypeCode(typeCode), Version(version), Instance(instance), Reader(NULL),
HeaderSize(0), BodySize(0), RawData(NULL), SiblingIdx(0), TypeCode(0), Version(0), Instance(0), Reader(NULL),
_ParentRecord(NULL)
{
BodySize = bodySize;
TypeCode = typeCode;
Version = version;
Instance = instance;
HeaderSize = Record::HEADER_SIZE_IN_BYTES;
int real_size = _reader->GetSize() - _reader->GetPosition();

View File

@ -76,7 +76,7 @@ namespace DocFileFormat
{
result = pRecord->NewObject (reader, size, typeCode, version, instance);
if (result)
result->SiblingIdx = siblingIdx;
result->SiblingIdx = siblingIdx;
RELEASEOBJECT(pRecord);
}
}

View File

@ -84,11 +84,11 @@ namespace DocFileFormat
{
T* firstChildWithType = NULL;
for ( size_t i = 0; i < this->Children.size(); ++i )
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
{
if ( (this->Children[i] != NULL) && (typeid(T) == typeid(*(this->Children[i]))) )
if ( (*iter != NULL) && (typeid(T) == typeid(**iter)) )
{
firstChildWithType = static_cast<T*>(this->Children[i]);
firstChildWithType = static_cast<T*>(*iter);
break;
}

View File

@ -34,7 +34,6 @@
#include "RegularContainer.h"
#include "ShapeOptions.h"
#include "Shape.h"
#include "ClientAnchor.h"
namespace DocFileFormat
{
@ -43,35 +42,30 @@ namespace DocFileFormat
public:
static const unsigned short TYPE_CODE_0xF004 = 0xF004;
int m_nIndex;
unsigned int m_nShapeType;
bool m_bBackground;
bool m_bOLE;
bool m_bSkip;
int Index;
ShapeContainer():
RegularContainer(), m_nIndex(0), m_nShapeType(0), m_bSkip(false), m_bBackground(false), m_bOLE(false)
RegularContainer(), Index(0)
{
}
ShapeContainer( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ) :
m_bSkip(false), m_bBackground(false), m_bOLE(false), m_nIndex(0), m_nShapeType(0), RegularContainer( _reader, size, typeCode, version, instance )
ShapeContainer( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ):
RegularContainer( _reader, size, typeCode, version, instance ), Index(0)
{
for ( size_t i = 0; i < this->Children.size(); ++i )
{
ClientAnchor *clientAnchor = dynamic_cast<ClientAnchor*>( this->Children[i] );
if ( (clientAnchor) && (clientAnchor->value == 0x80000000))
m_bSkip = true;
}
Shape* sh = dynamic_cast<Shape*>( this->Children[i] );
int getShapeType()
{
int ret = 0;
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
{
Shape* sh = dynamic_cast<Shape*>( *iter );
if (sh)
{
m_bBackground = sh->fBackground;
m_bOLE = sh->fOleShape;
if (sh->shapeType)
{
m_nShapeType = sh->shapeType->GetTypeCode();
return sh->shapeType->GetTypeCode();
}
else
{
@ -82,16 +76,44 @@ namespace DocFileFormat
{
if (sh_options->OptionsByID.end() != sh_options->OptionsByID.find(Pib))
{
m_nShapeType = msosptPictureFrame;
return msosptPictureFrame;
}
}
}
return 0;
}
}
}
return 0;
}
bool isBackground()
{
int ret = 0;
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
{
Shape* sh = dynamic_cast<Shape*>( *iter );
if (sh)
{
return sh->fBackground;
}
}
return false;
}
bool isOLE()
{
int ret = 0;
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
{
Shape* sh = dynamic_cast<Shape*>( *iter );
if (sh)
{
return sh->fOleShape;
}
}
return false;
}
virtual ~ShapeContainer()
{
}
@ -106,9 +128,9 @@ namespace DocFileFormat
std::vector<OptionEntryPtr> ret;
//build the list of all option entries of this shape
for ( size_t i = 0; i < this->Children.size(); ++i )
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
{
ShapeOptions* opt = dynamic_cast<ShapeOptions*>( this->Children[i] );
ShapeOptions* opt = dynamic_cast<ShapeOptions*>( *iter );
if ( opt == NULL ) continue;

View File

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

View File

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

View File

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

View File

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

View File

@ -102,16 +102,17 @@ namespace DocFileFormat
struct OleObjectFileStructure
{
bool bNativeOnly = false;
std::wstring ext;
std::wstring objectID;
std::wstring clsid;
std::string data;
OleObjectFileStructure(){}
OleObjectFileStructure( const std::wstring& _ext, const std::wstring& _objectID, const std::wstring&/*REFCLSID*/ _clsid ):
ext(_ext), objectID(_objectID), clsid(_clsid){}
ext(_ext), objectID(_objectID), clsid(_clsid){}
};
@ -161,8 +162,8 @@ namespace DocFileFormat
void SaveToFile( const std::wstring& outputDir, const std::wstring& fileName, const std::wstring& XMLContent );
void SaveToFile( const std::wstring& outputDir, const std::wstring& fileName, const void* buf, unsigned int size );
bool SaveOLEObject( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure );
bool SaveEmbeddedObject( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure );
HRESULT SaveOLEObject ( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure );
HRESULT SaveEmbeddedObject ( const std::wstring& fileName, const std::string& data );
void RegisterDocPr();
void RegisterDocument();

View File

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

View File

@ -422,11 +422,12 @@ namespace DocFileFormat
//numbering
case sprmOldPAnld:
{
NumberingDescriptorPtr desc = NumberingDescriptor::create( iter->Arguments, iter->argumentsSize );
NumberingDescriptor desc( iter->Arguments, iter->argumentsSize );
if (m_document->listTable)
{
unsigned short numId = m_document->listTable->appendNumbering( desc );
m_document->listTable->appendNumbering( desc );
short numId = static_cast<short>(m_document->listTable->listNumbering.size());
appendValueElement( &numPr, L"numId", numId, true );
}
}break;
@ -459,8 +460,7 @@ namespace DocFileFormat
//Todo разобраться с закоментированным кодом
if (NULL != m_document->listTable && false == m_document->listTable->listData.empty())
{
unsigned short numId = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueElement( &numPr, L"numId", numId, true );
appendValueElement( &numPr, L"numId", FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize ), true );
}
//check if there is a ilvl reference, if not, check the count of LVLs.
@ -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" );
@ -566,35 +566,14 @@ namespace DocFileFormat
case sprmOldPDxaAbs:
case sprmPDxaAbs:
{
unsigned short val = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
switch (val)
{
case 0x0000: break; //left
case 0xfffc: appendValueAttribute( _framePr, L"w:xAlign", L"center"); break;
case 0xfff8: appendValueAttribute( _framePr, L"w:xAlign", L"right"); break;
case 0xfff4: appendValueAttribute( _framePr, L"w:xAlign", L"inside"); break;
case 0xfff0: appendValueAttribute( _framePr, L"w:xAlign", L"outside"); break;
default:
appendValueAttribute( _framePr, L"w:x", (short)val);
}
}break;
appendValueAttribute( _framePr, L"w:x", FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
break;
case sprmOldPDyaAbs:
case sprmPDyaAbs:
{
unsigned short val = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
switch (val)
{
case 0x0000: break; //inline
case 0xfffc: appendValueAttribute( _framePr, L"w:yAlign", L"top"); break;
case 0xfff8: appendValueAttribute( _framePr, L"w:yAlign", L"center"); break;
case 0xfff4: appendValueAttribute( _framePr, L"w:yAlign", L"bottom"); break;
case 0xfff0: appendValueAttribute( _framePr, L"w:yAlign", L"inside"); break;
case 0xffec: appendValueAttribute( _framePr, L"w:yAlign", L"outside"); break;
default:
appendValueAttribute( _framePr, L"w:y", (short)val );
}
}break;
appendValueAttribute( _framePr, L"w:y", FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
break;
case sprmPWHeightAbs:
appendValueAttribute( _framePr, L"w:h", FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
break;

View File

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

View File

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

View File

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

View File

@ -83,16 +83,16 @@ namespace DocFileFormat
public:
// Parses the CHPX for a fcPic an loads the PictureDescriptor at this offset
PictureDescriptor ( );
PictureDescriptor ( CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size, int nWordVersion);
PictureDescriptor ( CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size, bool oldVersion);
virtual ~PictureDescriptor();
void parse( POLE::Stream* stream, int fc, int sz, int nWordVersion);
void parse( POLE::Stream* stream, int fc, int sz, bool oldVersion);
private:
// Returns the fcPic into the "data" stream, where the PIC begins.
// Returns -1 if the CHPX has no fcPic.
static int GetFcPic( const CharacterPropertyExceptions* chpx );
private:
void Clear();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -35,8 +35,8 @@
namespace DocFileFormat
{
std::map<std::wstring, std::wstring> StyleSheetMapping::m_mapStyleId;
NSCriticalSection::CRITICAL_SECTION_SMART StyleSheetMapping::m_mapStyleIdLock;
std::map<std::wstring, std::wstring> StyleSheetMapping::m_mapStyleId;
OfficeCriticalSection StyleSheetMapping::m_mapStyleIdLock;
StyleSheetMapping::StyleSheetMapping( ConversionContext* ctx ) : AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() )
{
@ -234,44 +234,41 @@ namespace DocFileFormat
void StyleSheetMapping::writeRunDefaults( StyleSheet* sheet )
{
if ((sheet->stshi) && (!sheet->stshi->rgftcStandardChpStsh.empty()))
{
m_pXmlWriter->WriteNodeBegin( L"w:rPrDefault" );
m_pXmlWriter->WriteNodeBegin( L"w:rPr" );
m_pXmlWriter->WriteNodeBegin( L"w:rPrDefault" );
m_pXmlWriter->WriteNodeBegin( L"w:rPr" );
//write default fonts
m_pXmlWriter->WriteNodeBegin( L"w:rFonts", TRUE );
//write default fonts
m_pXmlWriter->WriteNodeBegin( L"w:rFonts", TRUE );
FontFamilyName* ffnAscii = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[0] ) );
if (ffnAscii)
m_pXmlWriter->WriteAttribute( L"w:ascii", FormatUtils::XmlEncode(ffnAscii->xszFtn, true));
FontFamilyName* ffnAscii = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[0] ) );
if (ffnAscii)
m_pXmlWriter->WriteAttribute( L"w:ascii", FormatUtils::XmlEncode(ffnAscii->xszFtn, true));
FontFamilyName* ffnAsia = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[1] ) );
if (ffnAsia)
m_pXmlWriter->WriteAttribute( L"w:eastAsia", FormatUtils::XmlEncode(ffnAsia->xszFtn, true));
FontFamilyName* ffnAsia = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[1] ) );
if (ffnAsia)
m_pXmlWriter->WriteAttribute( L"w:eastAsia", FormatUtils::XmlEncode(ffnAsia->xszFtn, true));
FontFamilyName* ffnAnsi = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[2] ) );
if (ffnAnsi)
m_pXmlWriter->WriteAttribute( L"w:hAnsi", FormatUtils::XmlEncode(ffnAnsi->xszFtn, true));
FontFamilyName* ffnAnsi = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[2] ) );
if (ffnAnsi)
m_pXmlWriter->WriteAttribute( L"w:hAnsi", FormatUtils::XmlEncode(ffnAnsi->xszFtn, true));
FontFamilyName* ffnComplex = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[3] ) );
if (ffnComplex)
m_pXmlWriter->WriteAttribute( L"w:cs", FormatUtils::XmlEncode(ffnComplex->xszFtn, true));
FontFamilyName* ffnComplex = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[3] ) );
if (ffnComplex)
m_pXmlWriter->WriteAttribute( L"w:cs", FormatUtils::XmlEncode(ffnComplex->xszFtn, true));
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( L"w:rFonts" );
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( L"w:rFonts" );
LanguageId langid(this->m_document->FIB->m_FibBase.lid);
std::wstring langcode = LanguageIdMapping::getLanguageCode( &langid );
LanguageId langid(this->m_document->FIB->m_FibBase.lid);
std::wstring langcode = LanguageIdMapping::getLanguageCode( &langid );
m_pXmlWriter->WriteNodeBegin( L"w:lang", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", langcode);
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( L"w:lang" );
m_pXmlWriter->WriteNodeBegin( L"w:lang", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", langcode);
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( L"w:lang" );
m_pXmlWriter->WriteNodeEnd( L"w:rPr" );
m_pXmlWriter->WriteNodeEnd( L"w:rPrDefault" );
}
m_pXmlWriter->WriteNodeEnd( L"w:rPr" );
m_pXmlWriter->WriteNodeEnd( L"w:rPrDefault" );
}
/*========================================================================================================*/

View File

@ -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 NSCriticalSection::CRITICAL_SECTION_SMART m_mapStyleIdLock;
static OfficeCriticalSection m_mapStyleIdLock;
virtual ~StyleSheetMapping();
private:
@ -67,4 +67,4 @@ namespace DocFileFormat
/// Writes the "NormalTable" default style
void writeNormalTableStyle();
};
}
}

View File

@ -35,11 +35,9 @@
namespace DocFileFormat
{
TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter,
const std::vector<short>* grid, int gridIndex, int cellIndex, unsigned int depth) :
TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, int gridIndex, int cellIndex) :
PropertiesMapping(pWriter)
{
_depth = depth;
_width = 0;
_gridIndex = gridIndex;
@ -77,25 +75,9 @@ namespace DocFileFormat
TablePropertyExceptions* tapx = static_cast<TablePropertyExceptions*>(visited);
int nComputedCellWidth = 0;
_gridSpan = 0;
_bCoverCell = false;
_gridSpan = 1;
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)
@ -131,39 +113,16 @@ 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 sz = tdef.rgdxaCenter[ ind1 + 1] - tdef.rgdxaCenter[ ind1 ] ;
// if (sz > 1)
// break;
// ind1++;
//}
if (tdef.rgTc80[_cellIndex].horzMerge == 1)
int ind = (std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1);
int ind1 = ind;
while (ind1 < tdef.rgdxaCenter.size() - 1)
{
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 ] ;
int sz = tdef.rgdxaCenter[ ind1 + 1] - tdef.rgdxaCenter[ ind1 ] ;
if (sz > 1)
break;
ind1++;
}
nComputedCellWidth = tdef.rgdxaCenter[ ind1 + 1] - tdef.rgdxaCenter[ ind ] ;
if (!IsTableBordersDefined(tapx->grpprl))
{
@ -320,32 +279,19 @@ namespace DocFileFormat
break;
}
}
if (_gridSpan <= 1 && nComputedCellWidth > _width && _width > 1)
{
int width_current = 0;
for (int i = _gridIndex; i < _grid->size(); i++)
{
width_current += _grid->at(i);
if (width_current >= nComputedCellWidth)
break;
_gridSpan++;
}
_width = nComputedCellWidth;
}
XMLTools::XMLElement tcW ( L"w:tcW" );
XMLTools::XMLAttribute tcWVal ( L"w:w", FormatUtils::IntToWideString( _width > 1 ? _width : nComputedCellWidth) );
XMLTools::XMLAttribute tcWType ( L"w:type", _width > 1 ? FormatUtils::MapValueToWideString( _ftsWidth, &Global::CellWidthTypeMap[0][0], 4, 5 ) :
(nComputedCellWidth > 0 ? L"dxa" : L"auto"));
XMLTools::XMLAttribute tcWType ( L"w:type", _width > 1 ? FormatUtils::MapValueToWideString( _ftsWidth, &Global::CellWidthTypeMap[0][0], 4, 5 ) : L"dxa" );
tcW.AppendAttribute( tcWType );
tcW.AppendAttribute( tcWVal );
_tcPr->AppendChild( tcW );
if ( _gridSpan == 1 && ( _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 );
@ -361,9 +307,7 @@ namespace DocFileFormat
break;
}
}
}
if (_gridSpan > 1)
{
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, unsigned int depth);
TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, int gridIndex, int cellIndex);
virtual void Apply( IVisitable* visited );
inline int GetGridSpan() const
@ -66,11 +66,6 @@ namespace DocFileFormat
return _gridSpan;
}
inline bool IsCoverCell() const
{
return _bCoverCell;
}
private:
void apppendCellShading (unsigned char* sprmArg, int size, int cellIndex);
@ -84,20 +79,18 @@ 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;
unsigned int _depth;
short _width;
Global::CellWidthType _ftsWidth;
TC80 _tcDef;
BorderCode* _brcTop;
BorderCode* _brcLeft;
BorderCode* _brcRight;
BorderCode* _brcBottom;
int _gridSpan;
bool _bCoverCell;
int _gridSpan;
};
}

View File

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

View File

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

View File

@ -75,8 +75,6 @@ namespace DocFileFormat
BYTE itcFirst = 0;
BYTE itcLim = 0;
bool bTableW = false;
for ( std::list<SinglePropertyModifier>::iterator iter = tapx->grpprl->begin(); iter != tapx->grpprl->end(); iter++ )
{
switch( iter->OpCode )
@ -107,8 +105,8 @@ namespace DocFileFormat
break;
case sprmTTableWidth:
{
//preferred table width
{ //preferred table width
unsigned char fts = iter->Arguments[0];
short width = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize );
@ -121,8 +119,6 @@ namespace DocFileFormat
tblW.AppendAttribute( w );
_tblPr->AppendChild( tblW );
bTableW = true;
}
break;
case sprmTMerge:
@ -390,20 +386,8 @@ namespace DocFileFormat
break;
}
}
if (false == bTableW)
{
XMLTools::XMLElement tblW( L"w:tblW");
XMLTools::XMLAttribute w( L"w:w", L"0");
XMLTools::XMLAttribute type( L"w:type", L"auto" );
tblW.AppendAttribute( type );
tblW.AppendAttribute( w );
_tblPr->AppendChild( tblW );
}
//indent
//indent
if ( tblIndent != 0 )
{
XMLTools::XMLElement tblInd( L"w:tblInd");
@ -417,7 +401,7 @@ namespace DocFileFormat
_tblPr->AppendChild( tblInd );
}
//append floating props
//append floating props
if ( tblpPr.GetAttributeCount() > 0 )
{
_tblPr->AppendChild( tblpPr );

View File

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

View File

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

View File

@ -142,7 +142,7 @@ namespace DocFileFormat
{
newXmlString.clear();
std::wstring sTempFolder = m_context->_doc->m_sTempFolder;
std::wstring sTempFolder = m_ctx->_doc->m_sTempFolder;
if (sTempFolder.empty())
{
sTempFolder = NSFile::CFileBinary::GetTempPath();
@ -211,7 +211,7 @@ namespace DocFileFormat
VMLPictureMapping::VMLPictureMapping(ConversionContext* ctx, XMLTools::CStringXmlWriter* writer, bool olePreview, IMapping* caller, bool isInlinePicture) : PropertiesMapping(writer)
{
m_context = ctx;
m_ctx = ctx;
m_isOlePreview = olePreview;
m_imageData = NULL;
m_nImageId = 0;
@ -229,18 +229,7 @@ namespace DocFileFormat
{
RELEASEOBJECT(m_imageData);
}
std::wstring VMLPictureMapping::GetShapeID(const Shape* pShape) const
{
std::wstring strXmlAttr;
if (NULL != pShape)
{
strXmlAttr += std::wstring(L"_x0000_i");
strXmlAttr += FormatUtils::IntToWideString(pShape->GetShapeID());
}
return strXmlAttr;
}
void VMLPictureMapping::Apply( IVisitable* visited )
{
PictureDescriptor* pict = dynamic_cast<PictureDescriptor*>(visited);
@ -259,14 +248,13 @@ namespace DocFileFormat
std::vector<OptionEntryPtr> options;
PictureFrameType type;
Shape* pShape = NULL;
if ((pict->shapeContainer || pict->blipStoreEntry) && pict->shapeContainer->Children.size() > 0)
{
pShape = static_cast<Shape*>(*(pict->shapeContainer->Children.begin()));
options = pict->shapeContainer->ExtractOptions();
Shape* shape = static_cast<Shape*>(*(pict->shapeContainer->Children.begin()));
options = pict->shapeContainer->ExtractOptions();
//v:shapetype
type.SetType(pShape->Instance);
type.SetType(shape->Instance);
VMLShapeTypeMapping* vmlShapeTypeMapping = new VMLShapeTypeMapping( m_pXmlWriter, m_isInlinePicture );
@ -277,16 +265,13 @@ namespace DocFileFormat
{
type.SetType(msosptPictureFrame);
}
m_pXmlWriter->WriteNodeBegin( L"v:shape", true );
//m_shapeId = GetShapeID(pShape); - todooo одинаковые картинки (одинаковый spid) - Anexo№3.doc
m_pXmlWriter->WriteNodeBegin( L"v:shape", true );
count_vml_objects++;
if (m_shapeId.empty())
{
m_context->_doc->GetOfficeArt()->m_uLastShapeId++;
m_shapeId = L"_x0000_i" + FormatUtils::IntToWideString(m_context->_doc->GetOfficeArt()->m_uLastShapeId);
}
m_shapeId = L"_x0000_s" + FormatUtils::IntToWideString(1024 + count_vml_objects);
m_pXmlWriter->WriteAttribute( L"id", m_shapeId);
@ -324,28 +309,24 @@ namespace DocFileFormat
}break;
//BORDERS
case borderBottomColor:
if (!pict->brcBottom)
{
RGBColor bottomColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( L"o:borderbottomcolor", L"#" + bottomColor.SixDigitHexCode);
}
break;
case borderLeftColor:
if (!pict->brcLeft)
{
RGBColor leftColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( L"o:borderleftcolor", L"#" + leftColor.SixDigitHexCode);
}
break;
case borderRightColor:
if (!pict->brcRight)
{
RGBColor rightColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( L"o:borderrightcolor", L"#" + rightColor.SixDigitHexCode);
}
break;
case borderTopColor:
if (!pict->brcTop)
{
RGBColor topColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( L"o:bordertopcolor", L"#" + topColor.SixDigitHexCode);
@ -433,7 +414,6 @@ namespace DocFileFormat
}
strStyle += L"width:" + strWidth + L"pt;" + L"height:" + strHeight + L"pt;";
m_pXmlWriter->WriteAttribute( L"style", strStyle);
if (m_isOlePreview)
@ -445,37 +425,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 );
//v:imageData
if (CopyPicture(pict))
{
//v:imageData
appendValueAttribute(m_imageData, L"r:id", L"rId" + FormatUtils::IntToWideString(m_nImageId));
appendValueAttribute(m_imageData, L"o:title", L"" );
m_pXmlWriter->WriteString(m_imageData->GetXMLString());
}
{//borders
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" );
@ -512,16 +476,12 @@ namespace DocFileFormat
WmfPlaceableFileHeader oWmfHeader = {};
oMetaHeader.ToWMFHeader(&oWmfHeader);
int lLenHeader = 22 + (pict->embeddedDataHeader ? 114 : 0);
int lLenHeader = 114 + 22;
unsigned char *newData = new unsigned char[pict->embeddedDataSize + lLenHeader];
memcpy(newData, (unsigned char *)(&oWmfHeader), 22);
if (pict->embeddedDataHeader)
{
memcpy(newData + 22, pict->embeddedDataHeader, 114 );
}
memcpy(newData + 22, pict->embeddedDataHeader, 114 );
memcpy(newData + lLenHeader, pict->embeddedData, pict->embeddedDataSize);
@ -530,10 +490,10 @@ namespace DocFileFormat
pict->embeddedData = newData;
}
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(Global::msoblipDIB),
m_ctx->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(Global::msoblipDIB),
std::vector<unsigned char>(pict->embeddedData, (pict->embeddedData + pict->embeddedDataSize)), Global::msoblipDIB));
m_nImageId = m_context->_docx->RegisterImage(m_caller, btWin32);
m_nImageId = m_ctx->_docx->RegisterImage(m_caller, btWin32);
result = true;
}
else if ((oBlipEntry != NULL) && (oBlipEntry->Blip != NULL))
@ -550,7 +510,7 @@ namespace DocFileFormat
unsigned char *newData = NULL;
int newDataSize = metaBlip->oMetaFile.ToBuffer(newData);
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlipEntry->btWin32), std::vector<unsigned char>(newData, (newData + newDataSize))));
m_ctx->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlipEntry->btWin32), std::vector<unsigned char>(newData, (newData + newDataSize))));
RELEASEARRAYOBJECTS(newData);
}
@ -566,7 +526,7 @@ namespace DocFileFormat
BitmapBlip* bitBlip = static_cast<BitmapBlip*>(oBlipEntry->Blip);
if (bitBlip)
{
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlipEntry->btWin32),
m_ctx->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlipEntry->btWin32),
std::vector<unsigned char>(bitBlip->m_pvBits, (bitBlip->m_pvBits + bitBlip->pvBitsSize)), oBlipEntry->btWin32));
}
}break;
@ -577,7 +537,7 @@ namespace DocFileFormat
}break;
}
m_nImageId = m_context->_docx->RegisterImage(m_caller, oBlipEntry->btWin32);
m_nImageId = m_ctx->_docx->RegisterImage(m_caller, oBlipEntry->btWin32);
result = true;
}

View File

@ -58,7 +58,6 @@ namespace DocFileFormat
void writePictureBorder (const std::wstring & name, const BorderCode* brc);
void appendStyleProperty( std::wstring* b, const std::wstring& propName, const std::wstring& propValue ) const;
bool ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString );
std::wstring GetShapeID(const Shape* pShape) const;
protected:
/// Copies the picture from the binary stream to the zip archive
/// and creates the relationships for the image.
@ -78,7 +77,7 @@ namespace DocFileFormat
std::wstring m_shapeId;
private:
ConversionContext* m_context;
ConversionContext* m_ctx;
IMapping* m_caller;
int m_nImageId;

View File

@ -235,11 +235,10 @@ namespace DocFileFormat
m_shapeId = GetShapeID(pShape);
count_vml_objects++;
if (m_shapeId.empty())
{
m_context->_doc->GetOfficeArt()->m_uLastShapeId++;
m_shapeId = std::wstring(L"_x0000_s") + FormatUtils::IntToWideString(m_context->_doc->GetOfficeArt()->m_uLastShapeId);
}
m_shapeId = std::wstring(L"_x0000_s") + FormatUtils::IntToWideString(1024 + count_vml_objects);
m_pXmlWriter->WriteAttribute ( L"id", m_shapeId );
@ -250,7 +249,7 @@ namespace DocFileFormat
freeform = false;
m_pXmlWriter->WriteAttribute( L"type", (std::wstring(L"#") + VMLShapeTypeMapping::GenerateTypeId(pShape->GetShapeType())));
}
m_pXmlWriter->WriteAttribute( L"style", FormatUtils::XmlEncode(buildStyle(pShape, pAnchor, options, pContainer->m_nIndex)));
m_pXmlWriter->WriteAttribute( L"style", FormatUtils::XmlEncode(buildStyle(pShape, pAnchor, options, pContainer->Index)));
if (pShape->is<LineType>())
{
@ -1313,7 +1312,7 @@ namespace DocFileFormat
//write the blip
if (oBlip)
{
VirtualStreamReader reader(m_context->_doc->WordDocumentStream, oBlip->foDelay, m_context->_doc->nWordVersion);
VirtualStreamReader reader(m_context->_doc->WordDocumentStream, oBlip->foDelay, m_context->_doc->FIB->m_bOlderVersion);
switch (oBlip->btWin32)
{
@ -2266,10 +2265,9 @@ namespace DocFileFormat
TwipsValue w( primitive->dxa );
TwipsValue h( primitive->dya );
m_context->_doc->GetOfficeArt()->m_uLastShapeId++;
std::wstring strId = std::wstring(L"_x0000_s") + FormatUtils::IntToWideString(m_context->_doc->GetOfficeArt()->m_uLastShapeId);
std::wstring strId = std::wstring(L"_x0000_s") + FormatUtils::IntToWideString(1024 + count_vml_objects);
count_vml_objects++;
//m_pXmlWriter->WriteAttribute ( L"id") , strId);
m_pXmlWriter->WriteAttribute ( L"o:spid", strId);

View File

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

View File

@ -124,12 +124,12 @@ namespace DocFileFormat
else if (_isInlineShape)
{
m_pXmlWriter->WriteString(L"<v:formulas><v:f eqn=\"if lineDrawn pixelLineWidth 0\"/>\
<v:f eqn=\"sum @0 1 0\"/><v:f eqn=\"sum 0 0 @1\"/>\
<v:f eqn=\"prod @2 1 2\"/><v:f eqn=\"prod @3 21600 pixelWidth\"/>\
<v:f eqn=\"prod @3 21600 pixelHeight\"/><v:f eqn=\"sum @0 0 1\"/>\
<v:f eqn=\"prod @6 1 2\"/><v:f eqn=\"prod @7 21600 pixelWidth\"/>\
<v:f eqn=\"sum @8 21600 0\"/><v:f eqn=\"prod @7 21600 pixelHeight\"/>\
<v:f eqn=\"sum @10 21600 0\"/></v:formulas>");
<v:f eqn=\"sum @0 1 0\"/><v:f eqn=\"sum 0 0 @1\"/>\
<v:f eqn=\"prod @2 1 2\"/><v:f eqn=\"prod @3 21600 pixelWidth\"/>\
<v:f eqn=\"prod @3 21600 pixelHeight\"/><v:f eqn=\"sum @0 0 1\"/>\
<v:f eqn=\"prod @6 1 2\"/><v:f eqn=\"prod @7 21600 pixelWidth\"/>\
<v:f eqn=\"sum @8 21600 0\"/><v:f eqn=\"prod @7 21600 pixelHeight\"/>\
<v:f eqn=\"sum @10 21600 0\"/></v:formulas>");
}
// Path

View File

@ -37,6 +37,8 @@
namespace DocFileFormat
{
static int count_vml_objects = 0;
class VMLShapeTypeMapping: public PropertiesMapping, public IMapping
{
private:

View File

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

View File

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

View File

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

View File

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

View File

@ -34,7 +34,6 @@
#include "../../DesktopEditor/raster/BgraFrame.h"
#include "../../DesktopEditor/common/Directory.h"
#include "../../DesktopEditor/common/SystemUtils.h"
#include "../../Common/DocxFormat/Source/DocxFormat/App.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Core.h"
@ -225,10 +224,7 @@ namespace DocFileFormat
OOX::CApp* pApp = new OOX::CApp(NULL);
if (pApp)
{
std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvApplicationName);
if (sApplication.empty())
sApplication = NSSystemUtils::gc_EnvApplicationNameDefault;
pApp->SetApplication(sApplication);
pApp->SetApplication(L"ONLYOFFICE");
#if defined(INTVER)
pApp->SetAppVersion(VALUE2STR(INTVER));
#endif
@ -308,7 +304,7 @@ namespace DocFileFormat
if (!iter->data.empty())
{
SaveEmbeddedObject(fileName, *iter);
SaveEmbeddedObject(fileName, iter->data);
}
else
{

View File

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

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