Commit ab2461a5 authored by ElenaSubbotina's avatar ElenaSubbotina

DocFormatReader - format before 1996 - fix formating text

parent 6f9ce15f
This diff is collapsed.
...@@ -644,7 +644,7 @@ namespace DocFileFormat ...@@ -644,7 +644,7 @@ namespace DocFileFormat
CharacterPropertyExceptions* chpxPic = chpxs->front(); CharacterPropertyExceptions* chpxPic = chpxs->front();
PictureDescriptor pic(chpxPic, m_document->DataStream, 0x7fffffff, m_document->FIB->m_bOlderVersion); PictureDescriptor pic(chpxPic, m_document->DataStream, 0x7fffffff, m_document->bOlderVersion);
RevisionData oData = RevisionData(chpxPic); RevisionData oData = RevisionData(chpxPic);
...@@ -782,9 +782,9 @@ namespace DocFileFormat ...@@ -782,9 +782,9 @@ namespace DocFileFormat
} }
} }
} }
else if ((TextMark::Picture == c) && fSpec) else if ((TextMark::Picture == c) && fSpec )
{ {
PictureDescriptor oPicture (chpx, m_document->DataStream, 0x7fffffff, m_document->FIB->m_bOlderVersion); PictureDescriptor oPicture (chpx, m_document->bOlderVersion ? m_document->WordDocumentStream : m_document->DataStream, 0x7fffffff, m_document->bOlderVersion);
if ((oPicture.mfp.mm > 98) && (NULL != oPicture.shapeContainer)) if ((oPicture.mfp.mm > 98) && (NULL != oPicture.shapeContainer))
{ {
...@@ -1041,7 +1041,7 @@ namespace DocFileFormat ...@@ -1041,7 +1041,7 @@ namespace DocFileFormat
//find first row end //find first row end
int fcRowEnd = findRowEndFc( cp, nestingLevel ); int fcRowEnd = findRowEndFc( cp, nestingLevel );
TablePropertyExceptions row1Tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->FIB->m_bOlderVersion); TablePropertyExceptions row1Tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->bOlderVersion);
//start table //start table
m_pXmlWriter->WriteNodeBegin( _T( "w:tbl" ) ); m_pXmlWriter->WriteNodeBegin( _T( "w:tbl" ) );
...@@ -1291,7 +1291,7 @@ namespace DocFileFormat ...@@ -1291,7 +1291,7 @@ namespace DocFileFormat
//convert the properties //convert the properties
int fcRowEnd = findRowEndFc( cp, nestingLevel ); int fcRowEnd = findRowEndFc( cp, nestingLevel );
TablePropertyExceptions tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->FIB->m_bOlderVersion); TablePropertyExceptions tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->bOlderVersion);
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions( fcRowEnd, fcRowEnd + 1 ); std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions( fcRowEnd, fcRowEnd + 1 );
TableRowPropertiesMapping* trpMapping = new TableRowPropertiesMapping( m_pXmlWriter, *(chpxs->begin()) ); TableRowPropertiesMapping* trpMapping = new TableRowPropertiesMapping( m_pXmlWriter, *(chpxs->begin()) );
...@@ -1523,11 +1523,13 @@ namespace DocFileFormat ...@@ -1523,11 +1523,13 @@ namespace DocFileFormat
{ {
return true; return true;
} }
else if (sprmCSymbol == iter->OpCode) // SYMBOL else if ( sprmCSymbol == iter->OpCode ||
sprmOldCSymbol == iter->OpCode) // SYMBOL
{ {
return true; return true;
} }
else if (sprmCFSpec == iter->OpCode) // SPECIAL OBJECT else if ( sprmOldCFSpec == iter->OpCode ||
sprmCFSpec == iter->OpCode) // SPECIAL OBJECT
{ {
return ((0 != iter->Arguments[0]) ? true : false); return ((0 != iter->Arguments[0]) ? true : false);
} }
......
...@@ -52,7 +52,7 @@ namespace DocFileFormat ...@@ -52,7 +52,7 @@ namespace DocFileFormat
/*========================================================================================================*/ /*========================================================================================================*/
FormattedDiskPagePAPX::FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, bool oldVersion): FormattedDiskPagePAPX::FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, bool oldVersion, bool fComplex):
FormattedDiskPage(), rgbx(NULL), grppapxSize(0), grppapx(NULL) FormattedDiskPage(), rgbx(NULL), grppapxSize(0), grppapx(NULL)
{ {
Type = Paragraph; Type = Paragraph;
...@@ -100,15 +100,29 @@ namespace DocFileFormat ...@@ -100,15 +100,29 @@ namespace DocFileFormat
for ( int i = 0; i < crun; i++ ) for ( int i = 0; i < crun; i++ )
{ {
memcpy( phe, ( bytes + j + 1 ), 12 );
//fill the rgbx array
BX bx; BX bx;
bx.wordOffset = bytes[j]; bx.wordOffset = bytes[j];
j++;
if (fComplex || !oldVersion)
{
memcpy( phe, ( bytes + j), 12 );
//fill the rgbx array
bx.phe = ParagraphHeight( phe, 12, false ); bx.phe = ParagraphHeight( phe, 12, false );
j += 12;
}
else
{
memcpy( phe, ( bytes + j), 6);
//fill the rgbx array
bx.phe = ParagraphHeight( phe, 6, false );
j += 6;
}
rgbx[i] = bx; rgbx[i] = bx;
j += 13;
if ( bx.wordOffset != 0 ) if ( bx.wordOffset != 0 )
{ {
...@@ -188,7 +202,7 @@ namespace DocFileFormat ...@@ -188,7 +202,7 @@ namespace DocFileFormat
int offset = fkpnr * 512; int offset = fkpnr * 512;
//parse the FKP and add it to the list //parse the FKP and add it to the list
PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_bOlderVersion) ); PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_bOlderVersion, fib->m_FibBase.fComplex) );
} }
//if (PAPXlist->back()->rgfc[PAPXlist->back()->rgfcSize-1] < last) //if (PAPXlist->back()->rgfc[PAPXlist->back()->rgfcSize-1] < last)
...@@ -212,7 +226,7 @@ namespace DocFileFormat ...@@ -212,7 +226,7 @@ namespace DocFileFormat
int offset = fkpnr * 512; int offset = fkpnr * 512;
//parse the FKP and add it to the list //parse the FKP and add it to the list
PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_bOlderVersion) ); PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_bOlderVersion, fib->m_FibBase.fComplex) );
} }
} }
......
...@@ -63,7 +63,7 @@ namespace DocFileFormat ...@@ -63,7 +63,7 @@ namespace DocFileFormat
public: public:
virtual ~FormattedDiskPagePAPX(); virtual ~FormattedDiskPagePAPX();
FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, bool oldVersion); FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, bool oldVersion, bool fComplex);
/// Parses the 0Table (or 1Table) for FKP _entries containing PAPX /// 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); 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. /// Returns a list of all PAPX FCs between they given boundaries.
......
/* /*
* (c) Copyright Ascensio System SIA 2010-2016 * (c) Copyright Ascensio System SIA 2010-2016
* *
* This program is a free software product. You can redistribute it and/or * This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL) * modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with * version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement * that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights. * of any third-party rights.
* *
* This program is distributed WITHOUT ANY WARRANTY; without even the implied * This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
* *
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021. * EU, LV-1021.
* *
* The interactive user interfaces in modified source and object code versions * The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under * of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3. * Section 5 of the GNU AGPL version 3.
* *
* Pursuant to Section 7(b) of the License you must retain the original Product * Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to * logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks. * grant you any rights under trademark law for use of our trademarks.
* *
* All the Product's GUI elements, including illustrations and icon sets, as * All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the * well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License * Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
* *
*/ */
#pragma once #pragma once
namespace DocFileFormat namespace DocFileFormat
...@@ -43,27 +43,24 @@ namespace DocFileFormat ...@@ -43,27 +43,24 @@ namespace DocFileFormat
public: public:
/// Creates a new LineSpacingDescriptor with empty values /// Creates a new LineSpacingDescriptor with empty values
LineSpacingDescriptor(): LineSpacingDescriptor(): dyaLine(0), fMultLinespace(false)
dyaLine(0), fMultLinespace(false)
{ {
} }
/// Parses the bytes to retrieve a LineSpacingDescriptor /// Parses the bytes to retrieve a LineSpacingDescriptor
LineSpacingDescriptor( unsigned char* bytes, int size ): LineSpacingDescriptor( unsigned char* bytes, int size ) : dyaLine(0), fMultLinespace(false)
dyaLine(0), fMultLinespace(false)
{ {
if ( size == 4 ) if ( size == 4 )
{ {
this->dyaLine = FormatUtils::BytesToInt16( bytes, 0, size ); dyaLine = FormatUtils::BytesToInt16( bytes, 0, size );
if ( FormatUtils::BytesToInt16( bytes, 2, size ) == 1 ) if ( FormatUtils::BytesToInt16( bytes, 2, size ) == 1 )
{ {
this->fMultLinespace = true; fMultLinespace = true;
} }
} }
else else
{ {
//throw new ByteParseException("Cannot parse the struct LSPD, the length of the struct doesn't match");
} }
} }
}; };
......
...@@ -66,7 +66,7 @@ namespace DocFileFormat ...@@ -66,7 +66,7 @@ namespace DocFileFormat
//m_pXmlWriter->WriteAttribute(_T("xmlns:wpc"), _T("http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas")); //m_pXmlWriter->WriteAttribute(_T("xmlns:wpc"), _T("http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:mc"), _T("http://schemas.openxmlformats.org/markup-compatibility/2006")); //m_pXmlWriter->WriteAttribute(_T("xmlns:mc"), _T("http://schemas.openxmlformats.org/markup-compatibility/2006"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:wp14"), _T("http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing")); //m_pXmlWriter->WriteAttribute(_T("xmlns:wp14"),_T("http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:wp"), _T("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing")); //m_pXmlWriter->WriteAttribute(_T("xmlns:wp"), _T("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:w14"), _T("http://schemas.microsoft.com/office/word/2010/wordml")); //m_pXmlWriter->WriteAttribute(_T("xmlns:w14"), _T("http://schemas.microsoft.com/office/word/2010/wordml"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:wpg"), _T("http://schemas.microsoft.com/office/word/2010/wordprocessingGroup")); //m_pXmlWriter->WriteAttribute(_T("xmlns:wpg"), _T("http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"));
......
...@@ -518,14 +518,17 @@ namespace DocFileFormat ...@@ -518,14 +518,17 @@ namespace DocFileFormat
for (std::list<SinglePropertyModifier>::const_iterator iter = grpprlChpx->grpprl->begin(); iter != grpprlChpx->grpprl->end(); ++iter) for (std::list<SinglePropertyModifier>::const_iterator iter = grpprlChpx->grpprl->begin(); iter != grpprlChpx->grpprl->end(); ++iter)
{ {
if ((int)(iter->OpCode) == sprmCPbiIBullet) switch(iter->OpCode)
{
case sprmCPbiIBullet:
{ {
cp = FormatUtils::BytesToUInt32(iter->Arguments, 0, iter->argumentsSize); cp = FormatUtils::BytesToUInt32(iter->Arguments, 0, iter->argumentsSize);
} }break;
if ((int)(iter->OpCode) == sprmCPbiGrf) case sprmCPbiGrf:
{ {
isPictureBullet = FormatUtils::BitmaskToBool(FormatUtils::BytesToUInt16(iter->Arguments, 0, iter->argumentsSize), 0x1); isPictureBullet = FormatUtils::BitmaskToBool(FormatUtils::BytesToUInt16(iter->Arguments, 0, iter->argumentsSize), 0x1);
}break;
} }
} }
......
...@@ -48,49 +48,57 @@ namespace DocFileFormat ...@@ -48,49 +48,57 @@ namespace DocFileFormat
//set default values //set default values
setDefaultValues(); setDefaultValues();
if ( size == 12 )
{
// The ParagraphHeight is placed in a ParagraphProperties whose fTtp field is set, // The ParagraphHeight is placed in a ParagraphProperties whose fTtp field is set,
//so used another bit setting //so used another bit setting
if ( size == 12 )
{
if ( fTtpMode ) if ( fTtpMode )
{ {
this->fSpare = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0001 ); fSpare = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0001 );
this->fUnk = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0002 ); fUnk = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0002 );
this->dcpTtpNext = FormatUtils::BytesToInt16( bytes, 0, size ); dcpTtpNext = FormatUtils::BytesToInt16( bytes, 0, size );
this->dxaCol = FormatUtils::BytesToInt32( bytes, 4, size ); dxaCol = FormatUtils::BytesToInt32( bytes, 4, size );
this->dymTableHeight = FormatUtils::BytesToInt32( bytes, 8, size ); dymTableHeight = FormatUtils::BytesToInt32( bytes, 8, size );
} }
else else
{ {
this->fVolatile = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0001 ); fVolatile = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0001 );
this->fUnk = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0002 ); fUnk = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0002 );
this->fDiffLines = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0004 ); fDiffLines = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0004 );
this->clMac = FormatUtils::BytesToUInt16( bytes, 0, size ) & 0x00FF; clMac = FormatUtils::BytesToUInt16( bytes, 0, size ) & 0x00FF;
this->dxaCol = FormatUtils::BytesToInt32( bytes, 4, size ); dxaCol = FormatUtils::BytesToInt32( bytes, 4, size );
this->dymLine = FormatUtils::BytesToInt32( bytes, 8, size ); dymLine = FormatUtils::BytesToInt32( bytes, 8, size );
this->dymHeight = FormatUtils::BytesToInt32( bytes, 8, size ); dymHeight = FormatUtils::BytesToInt32( bytes, 8, size );
} }
} }
else else if (size == 6)
{ {
//throw new ByteParseException("Cannot parse the struct ParagraphHeight, the length of the struct doesn't match"); 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 = FormatUtils::BytesToInt16( bytes, 4, size );
} }
} }
/*========================================================================================================*/ /*========================================================================================================*/
void ParagraphHeight::setDefaultValues() void ParagraphHeight::setDefaultValues()
{ {
this->clMac = 0; clMac = 0;
this->dcpTtpNext = 0; dcpTtpNext = 0;
this->dxaCol = 0; dxaCol = 0;
this->dymHeight = 0; dymHeight = 0;
this->dymLine = 0; dymLine = 0;
this->dymTableHeight = 0; dymTableHeight = 0;
this->fDiffLines = false; fDiffLines = false;
this->fSpare = false; fSpare = false;
this->fUnk = false; fUnk = false;
this->fVolatile = false; fVolatile = false;
} }
} }
\ No newline at end of file
...@@ -136,6 +136,8 @@ namespace DocFileFormat ...@@ -136,6 +136,8 @@ namespace DocFileFormat
std::list<SinglePropertyModifier>::iterator end = papx->grpprl->end(); std::list<SinglePropertyModifier>::iterator end = papx->grpprl->end();
for (std::list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != end; ++iter) for (std::list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != end; ++iter)
{ {
int nProperty = 0; //for unknown test
switch ( iter->OpCode ) switch ( iter->OpCode )
{ {
case sprmPIpgp: case sprmPIpgp:
...@@ -170,10 +172,12 @@ namespace DocFileFormat ...@@ -170,10 +172,12 @@ namespace DocFileFormat
} }
break; break;
case sprmOldPFKeep:
case sprmPFKeep: case sprmPFKeep:
appendFlagElement( _pPr, *iter, _T( "keepLines" ), true ); appendFlagElement( _pPr, *iter, _T( "keepLines" ), true );
break; break;
case sprmOldPFKeepFollow:
case sprmPFKeepFollow: case sprmPFKeepFollow:
appendFlagElement( _pPr, *iter, _T( "keepNext" ), true ); appendFlagElement( _pPr, *iter, _T( "keepNext" ), true );
break; break;
...@@ -215,6 +219,8 @@ namespace DocFileFormat ...@@ -215,6 +219,8 @@ namespace DocFileFormat
break; break;
//indentation //indentation
case sprmOldPDxaLeft:
case sprmOldPNest:
case sprmPDxaLeft: case sprmPDxaLeft:
case sprmPDxaLeft80: case sprmPDxaLeft80:
case sprmPNest: case sprmPNest:
...@@ -226,6 +232,7 @@ namespace DocFileFormat ...@@ -226,6 +232,7 @@ namespace DocFileFormat
appendValueAttribute( &ind, _T( "w:leftChars" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ); appendValueAttribute( &ind, _T( "w:leftChars" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
break; break;
case sprmOldPDxaLeft1:
case sprmPDxaLeft1: case sprmPDxaLeft1:
case sprmPDxaLeft180: case sprmPDxaLeft180:
{ {
...@@ -250,6 +257,7 @@ namespace DocFileFormat ...@@ -250,6 +257,7 @@ namespace DocFileFormat
appendValueAttribute( &ind, _T( "w:firstLineChars" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ); appendValueAttribute( &ind, _T( "w:firstLineChars" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
break; break;
case sprmOldPDxaRight:
case sprmPDxaRight: case sprmPDxaRight:
case sprmPDxaRight80: case sprmPDxaRight80:
appendValueAttribute( &ind, _T( "w:right" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ); appendValueAttribute( &ind, _T( "w:right" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
...@@ -260,10 +268,12 @@ namespace DocFileFormat ...@@ -260,10 +268,12 @@ namespace DocFileFormat
break; break;
//spacing //spacing
case sprmOldPDyaBefore:
case sprmPDyaBefore: case sprmPDyaBefore:
appendValueAttribute( &spacing, _T( "w:before" ), FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize ) ); appendValueAttribute( &spacing, _T( "w:before" ), FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize ) );
break; break;
case sprmOldPDyaAfter:
case sprmPDyaAfter: case sprmPDyaAfter:
appendValueAttribute( &spacing, _T( "w:after" ), FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize ) ); appendValueAttribute( &spacing, _T( "w:after" ), FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize ) );
break; break;
...@@ -276,6 +286,7 @@ namespace DocFileFormat ...@@ -276,6 +286,7 @@ namespace DocFileFormat
appendValueAttribute( &spacing, _T( "w:beforeAutospacing" ), iter->Arguments[0] ); appendValueAttribute( &spacing, _T( "w:beforeAutospacing" ), iter->Arguments[0] );
break; break;
case sprmOldPDyaLine:
case sprmPDyaLine: case sprmPDyaLine:
{ {
LineSpacingDescriptor lspd( iter->Arguments, iter->argumentsSize ); LineSpacingDescriptor lspd( iter->Arguments, iter->argumentsSize );
...@@ -300,6 +311,7 @@ namespace DocFileFormat ...@@ -300,6 +311,7 @@ namespace DocFileFormat
break; break;
//justification code //justification code
case sprmOldPJc:
case sprmPJc: case sprmPJc:
case sprmPJc80: case sprmPJc80:
{ {
...@@ -316,6 +328,7 @@ namespace DocFileFormat ...@@ -316,6 +328,7 @@ namespace DocFileFormat
//borders //borders
//case 0x461C: //case 0x461C:
case sprmOldPBrcTop:
case sprmPBrcTop: case sprmPBrcTop:
//case 0x4424: //case 0x4424:
case sprmPBrcTop80: case sprmPBrcTop80:
...@@ -331,6 +344,7 @@ namespace DocFileFormat ...@@ -331,6 +344,7 @@ namespace DocFileFormat
break; break;
//case 0x461D: //case 0x461D:
case sprmOldPBrcLeft:
case sprmPBrcLeft: case sprmPBrcLeft:
//case 0x4425: //case 0x4425:
case sprmPBrcLeft80: case sprmPBrcLeft80:
...@@ -346,6 +360,7 @@ namespace DocFileFormat ...@@ -346,6 +360,7 @@ namespace DocFileFormat
break; break;
//case 0x461E: //case 0x461E:
case sprmOldPBrcBottom:
case sprmPBrcBottom: case sprmPBrcBottom:
//case 0x4426: //case 0x4426:
case sprmPBrcBottom80: case sprmPBrcBottom80:
...@@ -361,6 +376,7 @@ namespace DocFileFormat ...@@ -361,6 +376,7 @@ namespace DocFileFormat
break; break;
//case 0x461F: //case 0x461F:
case sprmOldPBrcRight:
case sprmPBrcRight: case sprmPBrcRight:
//case 0x4427: //case 0x4427:
case sprmPBrcRight80: case sprmPBrcRight80:
...@@ -376,6 +392,7 @@ namespace DocFileFormat ...@@ -376,6 +392,7 @@ namespace DocFileFormat
break; break;
//case 0x4620: //case 0x4620:
case sprmOldPBrcBetween:
case sprmPBrcBetween: case sprmPBrcBetween:
//case 0x4428: //case 0x4428:
case sprmPBrcBetween80: case sprmPBrcBetween80:
...@@ -391,6 +408,7 @@ namespace DocFileFormat ...@@ -391,6 +408,7 @@ namespace DocFileFormat
break; break;
//case 0x4621: //case 0x4621:
case sprmOldPBrcBar:
case sprmPBrcBar: case sprmPBrcBar:
//case 0x4629: //case 0x4629:
case sprmPBrcBar80: case sprmPBrcBar80:
...@@ -445,6 +463,7 @@ namespace DocFileFormat ...@@ -445,6 +463,7 @@ namespace DocFileFormat
break; break;
//tabs //tabs
case sprmOldPChgTabs:
case sprmPChgTabsPapx: case sprmPChgTabsPapx:
case sprmPChgTabs: case sprmPChgTabs:
{ {
...@@ -513,6 +532,7 @@ namespace DocFileFormat ...@@ -513,6 +532,7 @@ namespace DocFileFormat
break; break;
//frame properties //frame properties
case sprmOldPPc:
case sprmPPc: case sprmPPc:
{ {
//position code //position code
...@@ -523,14 +543,17 @@ namespace DocFileFormat ...@@ -523,14 +543,17 @@ namespace DocFileFormat
} }
break; break;
case sprmOldPWr:
case sprmPWr: case sprmPWr:
appendValueAttribute( this->_framePr, _T( "w:wrap" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::TextFrameWrapping[0][0], 6, 10 ).c_str() ); appendValueAttribute( this->_framePr, _T( "w:wrap" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::TextFrameWrapping[0][0], 6, 10 ).c_str() );
break; break;
case sprmOldPDxaAbs:
case sprmPDxaAbs: case sprmPDxaAbs:
appendValueAttribute( this->_framePr, _T( "w:x" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ); appendValueAttribute( this->_framePr, _T( "w:x" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
break; break;
case sprmOldPDyaAbs:
case sprmPDyaAbs: case sprmPDyaAbs:
appendValueAttribute( this->_framePr, _T( "w:y" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ); appendValueAttribute( this->_framePr, _T( "w:y" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
break; break;
...@@ -539,18 +562,22 @@ namespace DocFileFormat ...@@ -539,18 +562,22 @@ namespace DocFileFormat
appendValueAttribute( this->_framePr, _T( "w:h" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ); appendValueAttribute( this->_framePr, _T( "w:h" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
break; break;
case sprmOldPDxaWidth:
case sprmPDxaWidth: case sprmPDxaWidth:
appendValueAttribute( this->_framePr, _T( "w:w" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ); appendValueAttribute( this->_framePr, _T( "w:w" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
break; break;
case sprmOldPDxaFromText:
case sprmPDxaFromText: case sprmPDxaFromText:
appendValueAttribute( this->_framePr, _T( "w:hSpace" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ); appendValueAttribute( this->_framePr, _T( "w:hSpace" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
break; break;
case sprmOldPDyaFromText:
case sprmPDyaFromText: case sprmPDyaFromText:
appendValueAttribute( this->_framePr, _T( "w:vSpace" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ); appendValueAttribute( this->_framePr, _T( "w:vSpace" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
break; break;
case sprmOldPDcs:
case sprmPDcs: case sprmPDcs:
{ {
short pDcs = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ); short pDcs = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
...@@ -567,10 +594,13 @@ namespace DocFileFormat ...@@ -567,10 +594,13 @@ namespace DocFileFormat
break; break;
default: default:
if (iter->argumentsSize == 2)
{
nProperty = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
}else
if (iter->argumentsSize == 1)
{ {
#ifdef _DEBUG nProperty = FormatUtils::BytesToUChar( iter->Arguments, 0, iter->argumentsSize );
// //ATLTRACE (_T("ParagraphPropertiesMapping - UNKNOWN SPRM : 0x%x\n"), iter->OpCode);
#endif
} }
break; break;
} }
......
...@@ -39,14 +39,14 @@ namespace DocFileFormat ...@@ -39,14 +39,14 @@ namespace DocFileFormat
{ {
if ( size != 0 ) if ( size != 0 )
{ {
this->istd = FormatUtils::BytesToUInt16( bytes, 0, size ); istd = FormatUtils::BytesToUInt16( bytes, 0, size );
} }
VirtualStreamReader *reader = NULL; VirtualStreamReader *reader = NULL;
//There is a SPRM that points to an offset in the data stream, //There is a SPRM that points to an offset in the data stream,
//where a list of SPRM is saved. //where a list of SPRM is saved.
for ( std::list<SinglePropertyModifier>::iterator iter = this->grpprl->begin(); iter != this->grpprl->end(); iter++ ) for ( std::list<SinglePropertyModifier>::iterator iter = grpprl->begin(); iter != grpprl->end(); iter++ )
{ {
SinglePropertyModifier sprm( *iter ); SinglePropertyModifier sprm( *iter );
...@@ -68,11 +68,11 @@ namespace DocFileFormat ...@@ -68,11 +68,11 @@ namespace DocFileFormat
PropertyExceptions externalPx( grpprlBytes, grpprlsize, oldVersion ); PropertyExceptions externalPx( grpprlBytes, grpprlsize, oldVersion );
//assign the external grpprl //assign the external grpprl
RELEASEOBJECT( this->grpprl ); RELEASEOBJECT( grpprl );
this->grpprl = new std::list<SinglePropertyModifier>( *(externalPx.grpprl) ); grpprl = new std::list<SinglePropertyModifier>( *(externalPx.grpprl) );
//remove the sprmPHugePapx //remove the sprmPHugePapx
this->grpprl->remove( sprm ); grpprl->remove( sprm );
RELEASEARRAYOBJECTS( grpprlBytes ); RELEASEARRAYOBJECTS( grpprlBytes );
RELEASEOBJECT( reader ) RELEASEOBJECT( reader )
......
...@@ -90,14 +90,14 @@ namespace DocFileFormat ...@@ -90,14 +90,14 @@ namespace DocFileFormat
if (lcb >= 10) if (lcb >= 10)
{ {
unsigned short cbHeader = reader.ReadUInt16(); int cbHeader = reader.ReadUInt16();
mfp.mm = reader.ReadInt16(); mfp.mm = reader.ReadInt16();
mfp.xExt = reader.ReadInt16(); mfp.xExt = reader.ReadInt16();
mfp.yExt = reader.ReadInt16(); mfp.yExt = reader.ReadInt16();
mfp.hMf = reader.ReadInt16(); mfp.hMf = reader.ReadInt16();
if (mfp.mm > 98) if (mfp.mm >= 98 || oldVersion)
{ {
unsigned char* bytes = reader.ReadBytes(14, true); unsigned char* bytes = reader.ReadBytes(14, true);
rcWinMf = std::vector<unsigned char>(bytes, (bytes + 14)); rcWinMf = std::vector<unsigned char>(bytes, (bytes + 14));
...@@ -154,6 +154,30 @@ namespace DocFileFormat ...@@ -154,6 +154,30 @@ namespace DocFileFormat
} }
} }
if (oldVersion)
{
////blipStoreEntry = new BlipStoreEntry();
//blipStoreEntry = new BlipStoreEntry(&reader,lcb, Global::msoblipDIB,0,0);
//long pos = reader.GetPosition();
//unsigned char* pPicData = reader.ReadBytes(lcb - pos, true);
//int pos1 = 0;
//BITMAPINFOHEADER *bm = (BITMAPINFOHEADER *)(pPicData + pos1);
//NSFile::CFileBinary f;
//
//f.CreateFile(L"d:\\test.jpg");
//f.WriteFile(pPicData + pos1, lcb - pos - pos1);
//f.CloseFile();
//RELEASEARRAYOBJECTS(pPicData);
}
else
{
//Parse the OfficeDrawing Stuff //Parse the OfficeDrawing Stuff
shapeContainer = dynamic_cast<ShapeContainer*>(RecordFactory::ReadRecord(&reader, 0)); shapeContainer = dynamic_cast<ShapeContainer*>(RecordFactory::ReadRecord(&reader, 0));
...@@ -175,6 +199,7 @@ namespace DocFileFormat ...@@ -175,6 +199,7 @@ namespace DocFileFormat
} }
} }
} }
}
/// Returns the fcPic into the "data" stream, where the PIC begins. /// Returns the fcPic into the "data" stream, where the PIC begins.
/// Returns -1 if the CHPX has no fcPic. /// Returns -1 if the CHPX has no fcPic.
...@@ -186,6 +211,7 @@ namespace DocFileFormat ...@@ -186,6 +211,7 @@ namespace DocFileFormat
{ {
switch ( iter->OpCode ) switch ( iter->OpCode )
{ {
case sprmOldCPicLocation:
case sprmCPicLocation: case sprmCPicLocation:
ret = FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize ); ret = FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize );
break; break;
...@@ -194,6 +220,7 @@ namespace DocFileFormat ...@@ -194,6 +220,7 @@ namespace DocFileFormat
ret = FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize ); ret = FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize );
break; break;
case sprmOldCFData:
case sprmCFData: case sprmCFData:
break; break;
} }
......
...@@ -41,24 +41,18 @@ namespace DocFileFormat ...@@ -41,24 +41,18 @@ namespace DocFileFormat
RELEASEOBJECT( this->grpprl ); RELEASEOBJECT( this->grpprl );
} }
/*========================================================================================================*/
PropertyExceptions::PropertyExceptions(): grpprl(NULL) PropertyExceptions::PropertyExceptions(): grpprl(NULL)
{ {
this->grpprl = new std::list<SinglePropertyModifier>(); this->grpprl = new std::list<SinglePropertyModifier>();
} }
/*========================================================================================================*/
PropertyExceptions::PropertyExceptions( const std::list<SinglePropertyModifier>& grpprl ) PropertyExceptions::PropertyExceptions( const std::list<SinglePropertyModifier>& grpprl )
{ {
this->grpprl = new std::list<SinglePropertyModifier>( grpprl ); this->grpprl = new std::list<SinglePropertyModifier>( grpprl );
} }
/*========================================================================================================*/ PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool oldVersion ) : grpprl(NULL)
{
PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool oldVersion ): grpprl(NULL)
{
this->grpprl = new std::list<SinglePropertyModifier>(); this->grpprl = new std::list<SinglePropertyModifier>();
if ( ( bytes == NULL ) || ( size == 0 ) ) return; if ( ( bytes == NULL ) || ( size == 0 ) ) return;
...@@ -68,17 +62,27 @@ PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool old ...@@ -68,17 +62,27 @@ PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool old
int sprmStart = 0; int sprmStart = 0;
bool goOn = true; bool goOn = true;
int opCodeSize = (oldVersion ? 1 : 2);
while ( goOn ) while ( goOn )
{ {
//enough bytes to read? //enough bytes to read?
if ( ( sprmStart + 2 ) < size ) if ( ( sprmStart + opCodeSize ) < size )
{ {
//make spra OperationCode opCode = oldVersion ? (OperationCode)FormatUtils::BytesToUChar ( bytes, sprmStart, size ) :
OperationCode opCode = (OperationCode)FormatUtils::BytesToUInt16( bytes, sprmStart, size ); (OperationCode)FormatUtils::BytesToUInt16 ( bytes, sprmStart, size ) ;
unsigned char spra = (unsigned char)( (int)opCode >> 13 );
short opSize = -1;
// get size of operand if (oldVersion)
short opSize = (short)SinglePropertyModifier::GetOperandSize( spra ); {
opSize = (short)SinglePropertyModifier::GetOldOperandSize( (unsigned char)opCode );
}
else
{
unsigned char spra = (unsigned char)( (int)opCode >> 13 );
opSize = (short)SinglePropertyModifier::GetOperandSize( spra );
}
unsigned char lenByte = 0; unsigned char lenByte = 0;
//operand has variable size //operand has variable size
...@@ -96,8 +100,7 @@ PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool old ...@@ -96,8 +100,7 @@ PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool old
//Word adds an additional unsigned char to the opSize to compensate the additional //Word adds an additional unsigned char to the opSize to compensate the additional
//unsigned char needed for the length //unsigned char needed for the length
opSize--; opSize--;
} }break;
break;
case sprmPChgTabs: case sprmPChgTabs:
{ {
...@@ -112,13 +115,19 @@ PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool old ...@@ -112,13 +115,19 @@ PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool old
unsigned char itbdAddMax = bytes[sprmStart + 3 + 2 * itbdDelMax]; unsigned char itbdAddMax = bytes[sprmStart + 3 + 2 * itbdDelMax];
opSize = (short)( ( itbdDelMax * 4 + itbdAddMax * 3 ) - 1 ); opSize = (short)( ( itbdDelMax * 4 + itbdAddMax * 3 ) - 1 );
} }
} }break;
break;
case sprmOldPAnld:
{
lenByte = 1;
opSize = bytes[sprmStart + opCodeSize];
}break;
default: default:
{ //The variable length stand in the unsigned char after the opcode {
//The variable length stand in the unsigned char after the opcode
lenByte = 1; lenByte = 1;
opSize = bytes[sprmStart + 2]; opSize = bytes[sprmStart + opCodeSize];
} }
break; break;
} }
...@@ -126,7 +135,7 @@ PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool old ...@@ -126,7 +135,7 @@ PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool old
//copy sprm to array //copy sprm to array
//length is 2byte for the opCode, lenByte for the length, opSize for the length of the operand //length is 2byte for the opCode, lenByte for the length, opSize for the length of the operand
int sprmBytesSize = 2 + lenByte + opSize; int sprmBytesSize = opCodeSize + lenByte + opSize;
unsigned char* sprmBytes = NULL; unsigned char* sprmBytes = NULL;
sprmBytes = new unsigned char[sprmBytesSize]; sprmBytes = new unsigned char[sprmBytesSize];
...@@ -136,7 +145,7 @@ PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool old ...@@ -136,7 +145,7 @@ PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool old
memcpy( sprmBytes, ( bytes + sprmStart ), sprmBytesSize ); memcpy( sprmBytes, ( bytes + sprmStart ), sprmBytesSize );
//parse //parse
SinglePropertyModifier sprm( sprmBytes, sprmBytesSize ); SinglePropertyModifier sprm( sprmBytes, sprmBytesSize, oldVersion );
grpprl->push_back( sprm ); grpprl->push_back( sprm );
sprmStart += sprmBytesSize; sprmStart += sprmBytesSize;
...@@ -154,4 +163,5 @@ PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool old ...@@ -154,4 +163,5 @@ PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool old
} }
} }
} }
} }
\ No newline at end of file
...@@ -127,6 +127,7 @@ namespace DocFileFormat ...@@ -127,6 +127,7 @@ namespace DocFileFormat
switch (iter->OpCode) switch (iter->OpCode)
{ {
//page margins //page margins
case sprmOldSDxaLeft:
case sprmSDxaLeft: case sprmSDxaLeft:
{ {
//left margin //left margin
...@@ -135,6 +136,7 @@ namespace DocFileFormat ...@@ -135,6 +136,7 @@ namespace DocFileFormat
} }
break; break;
case sprmOldSDxaRight:
case sprmSDxaRight: case sprmSDxaRight:
{ {
//right margin //right margin
...@@ -143,32 +145,38 @@ namespace DocFileFormat ...@@ -143,32 +145,38 @@ namespace DocFileFormat
} }
break; break;
case sprmOldSDyaTop:
case sprmSDyaTop: case sprmSDyaTop:
//top margin //top margin
appendValueAttribute( &pgMar, _T( "w:top" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() ); appendValueAttribute( &pgMar, _T( "w:top" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break; break;
case sprmOldSDyaBottom:
case sprmSDyaBottom: case sprmSDyaBottom:
//bottom margin //bottom margin
appendValueAttribute( &pgMar, _T( "w:bottom" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() ); appendValueAttribute( &pgMar, _T( "w:bottom" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break; break;
case sprmOldSDzaGutter:
case sprmSDzaGutter: case sprmSDzaGutter:
//gutter margin //gutter margin
appendValueAttribute( &pgMar, _T( "w:gutter" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() ); appendValueAttribute( &pgMar, _T( "w:gutter" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break; break;
case sprmOldSDyaHdrTop:
case sprmSDyaHdrTop: case sprmSDyaHdrTop:
//header margin //header margin
appendValueAttribute( &pgMar, _T( "w:header"), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() ); appendValueAttribute( &pgMar, _T( "w:header"), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break; break;
case sprmOldSDyaHdrBottom:
case sprmSDyaHdrBottom: case sprmSDyaHdrBottom:
//footer margin //footer margin
appendValueAttribute( &pgMar, _T( "w:footer" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() ); appendValueAttribute( &pgMar, _T( "w:footer" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break; break;
//page size and orientation //page size and orientation
case sprmOldSXaPage:
case sprmSXaPage: case sprmSXaPage:
{ {
//width //width
...@@ -177,21 +185,25 @@ namespace DocFileFormat ...@@ -177,21 +185,25 @@ namespace DocFileFormat
} }
break; break;
case sprmOldSYaPage:
case sprmSYaPage: case sprmSYaPage:
//height //height
appendValueAttribute( &pgSz, _T( "w:h" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() ); appendValueAttribute( &pgSz, _T( "w:h" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break; break;
case sprmOldSBOrientation:
case sprmSBOrientation: case sprmSBOrientation:
//orientation //orientation
appendValueAttribute( &pgSz, _T( "w:orient" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &PageOrientationMap[0][0], 3, 10 ).c_str() ); appendValueAttribute( &pgSz, _T( "w:orient" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &PageOrientationMap[0][0], 3, 10 ).c_str() );
break; break;
//paper source //paper source
case sprmOldSDmBinFirst:
case sprmSDmBinFirst: case sprmSDmBinFirst:
appendValueAttribute( &paperSrc, _T( "w:first" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() ); appendValueAttribute( &paperSrc, _T( "w:first" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break; break;
case sprmOldSDmBinOther:
case sprmSDmBinOther: case sprmSDmBinOther:
appendValueAttribute( &paperSrc, _T( "w:other" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() ); appendValueAttribute( &paperSrc, _T( "w:other" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break; break;
...@@ -306,6 +318,7 @@ namespace DocFileFormat ...@@ -306,6 +318,7 @@ namespace DocFileFormat
break; break;
// Columns // Columns
case sprmOldSCcolumns:
case sprmSCcolumns: case sprmSCcolumns:
{ {
m_nColumns = static_cast<int> (FormatUtils::BytesToInt16 (iter->Arguments, 0, iter->argumentsSize) + 1); m_nColumns = static_cast<int> (FormatUtils::BytesToInt16 (iter->Arguments, 0, iter->argumentsSize) + 1);
...@@ -317,11 +330,13 @@ namespace DocFileFormat ...@@ -317,11 +330,13 @@ namespace DocFileFormat
} }
break; break;
case sprmOldSDxaColumns:
case sprmSDxaColumns: case sprmSDxaColumns:
//evenly spaced columns //evenly spaced columns
appendValueAttribute (&cols, _T( "w:space" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() ); appendValueAttribute (&cols, _T( "w:space" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break; break;
case sprmOldSDxaColWidth:
case sprmSDxaColWidth: case sprmSDxaColWidth:
{ {
// there is at least one width set, so create the array // there is at least one width set, so create the array
...@@ -336,6 +351,7 @@ namespace DocFileFormat ...@@ -336,6 +351,7 @@ namespace DocFileFormat
} }
break; break;
case sprmOldSDxaColSpacing:
case sprmSDxaColSpacing: case sprmSDxaColSpacing:
{ {
// there is at least one space set, so create the array // there is at least one space set, so create the array
...@@ -356,6 +372,7 @@ namespace DocFileFormat ...@@ -356,6 +372,7 @@ namespace DocFileFormat
break; break;
//title page //title page
case sprmOldSFTitlePage:
case sprmSFTitlePage: case sprmSFTitlePage:
appendFlagElement (m_pXmlNode, *iter, _T( "titlePg" ), true ); appendFlagElement (m_pXmlNode, *iter, _T( "titlePg" ), true );
break; break;
...@@ -366,6 +383,7 @@ namespace DocFileFormat ...@@ -366,6 +383,7 @@ namespace DocFileFormat
break; break;
//type //type
case sprmOldSBkc:
case sprmSBkc: case sprmSBkc:
{ {
this->_type = FormatUtils::MapValueToWideString( iter->Arguments[0], &SectionTypeMap[0][0], 5, 11 ); this->_type = FormatUtils::MapValueToWideString( iter->Arguments[0], &SectionTypeMap[0][0], 5, 11 );
...@@ -373,25 +391,30 @@ namespace DocFileFormat ...@@ -373,25 +391,30 @@ namespace DocFileFormat
break; break;
//align //align
case sprmOldSVjc:
case sprmSVjc: case sprmSVjc:
appendValueElement (m_pXmlNode, _T( "vAlign" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &TextVerticalAlignment[0][0], 4, 7 ).c_str(), true ); appendValueElement (m_pXmlNode, _T( "vAlign" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &TextVerticalAlignment[0][0], 4, 7 ).c_str(), true );
break; break;
//pgNumType //pgNumType
case sprmOldSNfcPgn:
case sprmSNfcPgn: case sprmSNfcPgn:
appendValueAttribute( &pgNumType, _T( "w:fmt" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &PageNumberFormatCodeMap[0][0], 42, 29 ).c_str() ); appendValueAttribute( &pgNumType, _T( "w:fmt" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &PageNumberFormatCodeMap[0][0], 42, 29 ).c_str() );
break; break;
case sprmOldSPgnStart:
case sprmSPgnStart: case sprmSPgnStart:
wsSprmSPgnStart = FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ); wsSprmSPgnStart = FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
break; break;
case sprmOldSFPgnRestart:
case sprmSFPgnRestart: case sprmSFPgnRestart:
bWasSprmSFPgnRestart = true; bWasSprmSFPgnRestart = true;
break; break;
// <w:lnNumType> - Line Numbering Settings // <w:lnNumType> - Line Numbering Settings
case sprmOldSLnnMin :
case sprmSLnnMin : case sprmSLnnMin :
{ {
unsigned short start = FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize); unsigned short start = FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize);
...@@ -401,6 +424,7 @@ namespace DocFileFormat ...@@ -401,6 +424,7 @@ namespace DocFileFormat
} }
break; break;
case sprmOldSLnc :
case sprmSLnc : case sprmSLnc :
{ {
SLncOperand mode = (SLncOperand)FormatUtils::BytesToUChar (iter->Arguments, 0, iter->argumentsSize); SLncOperand mode = (SLncOperand)FormatUtils::BytesToUChar (iter->Arguments, 0, iter->argumentsSize);
...@@ -410,6 +434,7 @@ namespace DocFileFormat ...@@ -410,6 +434,7 @@ namespace DocFileFormat
} }
break; break;
case sprmOldSNLnnMod :
case sprmSNLnnMod : case sprmSNLnnMod :
{ {
short countBy = FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize); short countBy = FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize);
......
...@@ -36,38 +36,51 @@ ...@@ -36,38 +36,51 @@
namespace DocFileFormat namespace DocFileFormat
{ {
SinglePropertyModifier::SinglePropertyModifier() : Arguments(NULL), OpCode(sprmPIstd), fSpec(false), Type(PAP), argumentsSize(0) SinglePropertyModifier::SinglePropertyModifier( bool oldVersion_) :
Arguments(NULL), OpCode(sprmPIstd), fSpec(false), Type(PAP), argumentsSize(0), oldVersion (oldVersion_)
{ {
} }
/// parses the unsigned char to retrieve a SPRM SinglePropertyModifier::SinglePropertyModifier(unsigned char* bytes, int size, bool oldVersion_) :
SinglePropertyModifier::SinglePropertyModifier(unsigned char* bytes, int size) : Arguments(NULL), OpCode(sprmPIstd), fSpec(false), Type(PAP), argumentsSize(0) Arguments(NULL), OpCode(sprmPIstd), fSpec(false), Type(PAP), argumentsSize(0), oldVersion (oldVersion_)
{ {
unsigned char opSize = 0;
unsigned char opCodeSize = 0;
if (oldVersion)
{
opCodeSize = 1;
//first 1 byte are the operation code ...
OpCode = (OperationCode)FormatUtils::BytesToUChar( bytes, 0, size );
opSize = GetOldOperandSize( (unsigned char)OpCode );
}
else
{
opCodeSize = 2;
//first 2 bytes are the operation code ... //first 2 bytes are the operation code ...
this->OpCode = (OperationCode)FormatUtils::BytesToUInt16( bytes, 0, size ); OpCode = (OperationCode)FormatUtils::BytesToUInt16( bytes, 0, size );
//... whereof bit 9 is fSpec ... //... whereof bit 9 is fSpec ...
unsigned int j = (unsigned int)this->OpCode << 22; unsigned int j = (unsigned int)this->OpCode << 22;
j = j >> 31; j = j >> 31;
if ( j == 1 ) if ( j == 1 )
{ {
this->fSpec = true; fSpec = true;
} }
else else
{ {
this->fSpec = false; fSpec = false;
} }
//... and bits 10,11,12 are the type ... //... and bits 10,11,12 are the type ...
unsigned int i = (unsigned int)this->OpCode << 19; unsigned int i = (unsigned int)OpCode << 19;
i = i >> 29; i = i >> 29;
this->Type = (SprmType)i; Type = (SprmType)i;
//... and last 3 bits are the spra //... and last 3 bits are the spra
unsigned char spra = (unsigned char)( (int)this->OpCode >> 13 ); unsigned char spra = (unsigned char)( (int)OpCode >> 13 );
unsigned char opSize = GetOperandSize( spra ); opSize = GetOperandSize( spra );
}
if ( opSize == 255 ) if ( opSize == 255 )
{ {
...@@ -77,31 +90,31 @@ namespace DocFileFormat ...@@ -77,31 +90,31 @@ namespace DocFileFormat
case sprmTDefTable10: case sprmTDefTable10:
{ {
//the variable length stand in the bytes 2 and 3 //the variable length stand in the bytes 2 and 3
short opSizeTable = FormatUtils::BytesToInt16( bytes, 2, size ); short opSizeTable = FormatUtils::BytesToInt16( bytes, opCodeSize, size );
this->argumentsSize = opSizeTable-1; argumentsSize = opSizeTable-1;
//and the arguments start at the unsigned char after that (byte3) //and the arguments start at the unsigned char after that (byte3)
this->Arguments = new unsigned char[this->argumentsSize]; Arguments = new unsigned char[argumentsSize];
//Arguments start at unsigned char 4 //Arguments start at unsigned char 4
memcpy( this->Arguments, ( bytes + 4 ), this->argumentsSize ); memcpy( Arguments, ( bytes + opCodeSize + 2 ), argumentsSize );
} }
break; break;
case sprmPChgTabs: case sprmPChgTabs:
{ {
this->argumentsSize = bytes[2]; argumentsSize = bytes[2];
this->Arguments = new unsigned char[this->argumentsSize]; Arguments = new unsigned char[argumentsSize];
memcpy( this->Arguments, ( bytes + 3 ), this->argumentsSize ); memcpy( Arguments, ( bytes + opCodeSize + 1 ), argumentsSize );
} }
break; break;
default: default:
{ {
//the variable length stand in the unsigned char after the opcode (byte2) //the variable length stand in the unsigned char after the opcode (byte2)
opSize = bytes[2]; opSize = bytes[opCodeSize];
this->argumentsSize = opSize; argumentsSize = opSize;
//and the arguments start at the unsigned char after that (byte3) //and the arguments start at the unsigned char after that (byte3)
this->Arguments = new unsigned char[this->argumentsSize]; Arguments = new unsigned char[argumentsSize];
memcpy( this->Arguments, ( bytes + 3 ), this->argumentsSize ); memcpy( Arguments, ( bytes + opCodeSize + 1 ), argumentsSize );
} }
break; break;
...@@ -109,9 +122,9 @@ namespace DocFileFormat ...@@ -109,9 +122,9 @@ namespace DocFileFormat
} }
else else
{ {
this->argumentsSize = opSize; argumentsSize = opSize;
this->Arguments = new unsigned char[this->argumentsSize]; Arguments = new unsigned char[argumentsSize];
memcpy( this->Arguments, ( bytes + 2 ), this->argumentsSize ); memcpy( Arguments, ( bytes + opCodeSize ), argumentsSize );
} }
} }
...@@ -119,19 +132,20 @@ namespace DocFileFormat ...@@ -119,19 +132,20 @@ namespace DocFileFormat
{ {
if ( spm.Arguments != NULL ) if ( spm.Arguments != NULL )
{ {
this->argumentsSize = spm.argumentsSize; argumentsSize = spm.argumentsSize;
this->Arguments = new unsigned char[this->argumentsSize]; Arguments = new unsigned char[argumentsSize];
memcpy( this->Arguments, spm.Arguments, this->argumentsSize ); memcpy( Arguments, spm.Arguments, argumentsSize );
this->fSpec = spm.fSpec; fSpec = spm.fSpec;
this->OpCode = spm.OpCode; OpCode = spm.OpCode;
this->Type = spm.Type; Type = spm.Type;
oldVersion = spm.oldVersion;
} }
} }
bool SinglePropertyModifier::operator == (const SinglePropertyModifier& spm) const bool SinglePropertyModifier::operator == (const SinglePropertyModifier& spm) const
{ {
if ( ( this->argumentsSize == spm.argumentsSize ) && ( memcmp( this->Arguments, spm.Arguments, this->argumentsSize ) == 0 ) && if ( ( argumentsSize == spm.argumentsSize ) && ( memcmp( Arguments, spm.Arguments, argumentsSize ) == 0 ) &&
( this->fSpec == spm.fSpec ) && ( this->OpCode == spm.OpCode ) && ( this->Type == spm.Type ) ) ( fSpec == spm.fSpec ) && ( OpCode == spm.OpCode ) && ( Type == spm.Type ) )
{ {
return true; return true;
} }
...@@ -156,8 +170,10 @@ namespace DocFileFormat ...@@ -156,8 +170,10 @@ namespace DocFileFormat
fSpec = spm.fSpec; fSpec = spm.fSpec;
Type = spm.Type; Type = spm.Type;
argumentsSize = spm.argumentsSize; argumentsSize = spm.argumentsSize;
oldVersion = spm.oldVersion;
Arguments = new unsigned char[argumentsSize]; Arguments = new unsigned char[argumentsSize];
memcpy(Arguments, spm.Arguments, spm.argumentsSize); memcpy(Arguments, spm.Arguments, spm.argumentsSize);
} }
...@@ -187,4 +203,15 @@ namespace DocFileFormat ...@@ -187,4 +203,15 @@ namespace DocFileFormat
default: return 0; default: return 0;
} }
} }
static const unsigned char OldOperandSizeTable[] =
{
0, 0, 2, 255, 1, 1, 1, 1, 1, 1, 1, 1, 255, 1, 1, 255, 2, 2, 2, 2, 4, 2, 2, 255, 1, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 255, 2, 4, 1, 2, 3, 255, 1, 0, 0, 0, 0, 2, 255, 255, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 3, 2, 2, 1, 1, 1, 1, 1, 255, 1, 255, 255, 2, 255, 2, 2, 0, 0, 0, 0, 0, 0, 1, 1, 1, 255, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 1, 1, 255, 0, 0, 3, 3, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 1, 1, 12, 255, 2, 0, 0, 4, 5, 4, 2, 4, 2, 2, 5, 4, 0, 0, 0, 0, 0, 0, 0, 0
};
unsigned char SinglePropertyModifier::GetOldOperandSize(unsigned char code)
{
if (code < 2 || code > 207) return -1;
return OldOperandSizeTable [code];
}
} }
...@@ -48,6 +48,7 @@ namespace DocFileFormat ...@@ -48,6 +48,7 @@ namespace DocFileFormat
class SinglePropertyModifier class SinglePropertyModifier
{ {
public: public:
bool oldVersion;
/// The operation code identifies the property of the /// The operation code identifies the property of the
/// PAP/CHP/PIC/SEP/TAP which sould be modified /// PAP/CHP/PIC/SEP/TAP which sould be modified
OperationCode OpCode; OperationCode OpCode;
...@@ -60,10 +61,11 @@ namespace DocFileFormat ...@@ -60,10 +61,11 @@ namespace DocFileFormat
/// The Arguments size /// The Arguments size
unsigned int argumentsSize; unsigned int argumentsSize;
SinglePropertyModifier(); SinglePropertyModifier(bool oldVersion);
/// parses the unsigned char to retrieve a SPRM /// parses the unsigned char to retrieve a SPRM
SinglePropertyModifier( unsigned char* bytes, int size ); SinglePropertyModifier( unsigned char* bytes, int size, bool oldVersion );
SinglePropertyModifier( const SinglePropertyModifier& spm ); SinglePropertyModifier( const SinglePropertyModifier& spm);
bool operator == ( const SinglePropertyModifier& spm ) const; bool operator == ( const SinglePropertyModifier& spm ) const;
bool operator != ( const SinglePropertyModifier& spm ) const; bool operator != ( const SinglePropertyModifier& spm ) const;
SinglePropertyModifier& operator = ( const SinglePropertyModifier& spm ); SinglePropertyModifier& operator = ( const SinglePropertyModifier& spm );
...@@ -71,5 +73,6 @@ namespace DocFileFormat ...@@ -71,5 +73,6 @@ namespace DocFileFormat
/// Get be used to get the size of the sprm's operand. /// Get be used to get the size of the sprm's operand.
/// Returns 0 if the Operation failed and 255 if the size is variable /// Returns 0 if the Operation failed and 255 if the size is variable
static unsigned char GetOperandSize( unsigned char spra ); static unsigned char GetOperandSize( unsigned char spra );
static unsigned char GetOldOperandSize( unsigned char code);
}; };
} }
...@@ -35,14 +35,14 @@ ...@@ -35,14 +35,14 @@
namespace DocFileFormat namespace DocFileFormat
{ {
TablePropertiesMapping::TablePropertiesMapping (XmlUtils::CXmlWriter* pWriter, StyleSheet* styles, std::vector<short>* grid, bool isTableStyleNeeded ): TablePropertiesMapping::TablePropertiesMapping (XmlUtils::CXmlWriter* pWriter, StyleSheet* styles, std::vector<short>* grid, bool isTableStyleNeeded ):
PropertiesMapping(pWriter), _tblPr(NULL), _tblGrid(NULL), _tblBorders(NULL), _grid(NULL), PropertiesMapping(pWriter), _tblPr(NULL), _tblGrid(NULL), _tblBorders(NULL), _grid(NULL),
brcLeft(NULL), brcTop(NULL), brcBottom(NULL), brcRight(NULL), brcHorz(NULL), brcVert(NULL), _styles(NULL), brcLeft(NULL), brcTop(NULL), brcBottom(NULL), brcRight(NULL), brcHorz(NULL), brcVert(NULL), _styles(NULL),
_isTableStyleNeeded(isTableStyleNeeded) _isTableStyleNeeded(isTableStyleNeeded)
{ {
_styles = styles; _styles = styles;
this->_tblPr = new XMLTools::XMLElement<wchar_t>( _T( "w:tblPr" ) ); _tblPr = new XMLTools::XMLElement<wchar_t>( _T( "w:tblPr" ) );
this->_tblBorders = new XMLTools::XMLElement<wchar_t>( _T( "w:tblBorders" ) ); _tblBorders = new XMLTools::XMLElement<wchar_t>( _T( "w:tblBorders" ) );
this->_grid = grid; _grid = grid;
} }
TablePropertiesMapping::~TablePropertiesMapping() TablePropertiesMapping::~TablePropertiesMapping()
{ {
...@@ -63,10 +63,10 @@ namespace DocFileFormat ...@@ -63,10 +63,10 @@ namespace DocFileFormat
{ {
TablePropertyExceptions* tapx = static_cast<TablePropertyExceptions*>( visited ); TablePropertyExceptions* tapx = static_cast<TablePropertyExceptions*>( visited );
XMLTools::XMLElement<wchar_t> tblCellMar( _T( "w:tblCellMar" ) ); XMLTools::XMLElement<wchar_t> tblCellMar ( _T( "w:tblCellMar" ) );
XMLTools::XMLElement<wchar_t> tblLayout( _T( "w:tblLayout" ) ); XMLTools::XMLElement<wchar_t> tblLayout ( _T( "w:tblLayout" ) );
XMLTools::XMLElement<wchar_t> tblpPr( _T( "w:tblpPr" ) ); XMLTools::XMLElement<wchar_t> tblpPr ( _T( "w:tblpPr" ) );
XMLTools::XMLAttribute<wchar_t> layoutType( _T( "w:type" ), _T( "fixed" ) ); XMLTools::XMLAttribute<wchar_t> layoutType ( _T( "w:type" ), _T( "fixed" ) );
bool bLayoutFixed = true; bool bLayoutFixed = true;
short tblIndent = 0; short tblIndent = 0;
...@@ -78,15 +78,17 @@ namespace DocFileFormat ...@@ -78,15 +78,17 @@ namespace DocFileFormat
{ {
switch( iter->OpCode ) switch( iter->OpCode )
{ {
case sprmOldTDxaGapHalf:
case sprmTDxaGapHalf: case sprmTDxaGapHalf:
{ {
gabHalf = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ); gabHalf = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
} }
break; break;
//table definition case sprmOldTDefTable:
case sprmTDefTable: case sprmTDefTable:
{ { //table definition
SprmTDefTable tDef( iter->Arguments, iter->argumentsSize ); SprmTDefTable tDef( iter->Arguments, iter->argumentsSize );
//Workaround for retrieving the indent of the table: //Workaround for retrieving the indent of the table:
//In some files there is a indent but no sprmTWidthIndent is set. //In some files there is a indent but no sprmTWidthIndent is set.
...@@ -97,14 +99,13 @@ namespace DocFileFormat ...@@ -97,14 +99,13 @@ namespace DocFileFormat
tblIndent += gabHalf; tblIndent += gabHalf;
//If there follows a real sprmTWidthIndent, this value will be overwritten //If there follows a real sprmTWidthIndent, this value will be overwritten
///<<<<FIXED
tblIndent = (std::max)((int)tblIndent,0); tblIndent = (std::max)((int)tblIndent,0);
} }
break; break;
//preferred table width
case sprmTTableWidth: case sprmTTableWidth:
{ { //preferred table width
unsigned char fts = iter->Arguments[0]; unsigned char fts = iter->Arguments[0];
short width = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize ); short width = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize );
...@@ -120,27 +121,28 @@ namespace DocFileFormat ...@@ -120,27 +121,28 @@ namespace DocFileFormat
} }
break; break;
//justification case sprmOldTJc:
case sprmTJc: case sprmTJc:
case sprmTJcRow: case sprmTJcRow:
{ { //justification
appendValueElement( _tblPr, _T( "jc" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::JustificationCode[0][0], 10, 15 ).c_str(), true ); appendValueElement( _tblPr, _T( "jc" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::JustificationCode[0][0], 10, 15 ).c_str(), true );
} }
break; break;
//indent
case sprmTWidthIndent: case sprmTWidthIndent:
{ { //indent
tblIndent = FtsWWidth_Indent(iter->Arguments).wWidth; tblIndent = FtsWWidth_Indent(iter->Arguments).wWidth;
// tblIndent = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize ); // tblIndent = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize );
} }
break; break;
//style
case sprmTIstd: case sprmTIstd:
case sprmTIstdPermute: case sprmTIstdPermute:
{ { //style
if ( this->_isTableStyleNeeded )
if ( _isTableStyleNeeded )
{ {
int ind = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ); int ind = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
...@@ -154,24 +156,25 @@ namespace DocFileFormat ...@@ -154,24 +156,25 @@ namespace DocFileFormat
} }
break; break;
//bidi
case sprmTFBiDi: case sprmTFBiDi:
case sprmTFBiDi90: case sprmTFBiDi90:
{ { //bidi
appendValueElement( _tblPr, _T( "bidiVisual" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ), true ); appendValueElement( _tblPr, _T( "bidiVisual" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ), true );
} }
break; break;
//table look case sprmOldTTlp:
case sprmTTlp: case sprmTTlp:
{ { //table look
appendValueElement( _tblPr, _T( "tblLook" ), FormatUtils::IntToFormattedWideString( FormatUtils::BytesToInt16( iter->Arguments, 2, iter->argumentsSize ), _T( "%04x" ) ).c_str(), true ); appendValueElement( _tblPr, _T( "tblLook" ), FormatUtils::IntToFormattedWideString( FormatUtils::BytesToInt16( iter->Arguments, 2, iter->argumentsSize ), _T( "%04x" ) ).c_str(), true );
} }
break; break;
//autofit
case sprmTFAutofit: case sprmTFAutofit:
{ { //autofit
if ( iter->Arguments[0] == 1 ) if ( iter->Arguments[0] == 1 )
{ {
layoutType.SetValue( _T( "auto" ) ); layoutType.SetValue( _T( "auto" ) );
...@@ -180,11 +183,11 @@ namespace DocFileFormat ...@@ -180,11 +183,11 @@ namespace DocFileFormat
} }
break; break;
//default cell padding (margin)
case sprmTCellPadding: case sprmTCellPadding:
case sprmTCellPaddingDefault: case sprmTCellPaddingDefault:
case sprmTCellPaddingOuter: case sprmTCellPaddingOuter:
{ { //default cell padding (margin)
unsigned char grfbrc = iter->Arguments[2]; unsigned char grfbrc = iter->Arguments[2];
short wMar = FormatUtils::BytesToInt16( iter->Arguments, 4, iter->argumentsSize ); short wMar = FormatUtils::BytesToInt16( iter->Arguments, 4, iter->argumentsSize );
std::wstring strValue = FormatUtils::IntToWideString( wMar ); std::wstring strValue = FormatUtils::IntToWideString( wMar );
...@@ -211,23 +214,23 @@ namespace DocFileFormat ...@@ -211,23 +214,23 @@ namespace DocFileFormat
} }
break; break;
//row count
case sprmTCHorzBands: case sprmTCHorzBands:
{ { //row count
appendValueElement( _tblPr, _T( "tblStyleRowBandSize" ), iter->Arguments[0], true ); appendValueElement( _tblPr, _T( "tblStyleRowBandSize" ), iter->Arguments[0], true );
} }
break; break;
//col count
case sprmTCVertBands: case sprmTCVertBands:
{ { //col count
appendValueElement( _tblPr, _T( "tblStyleColBandSize" ), iter->Arguments[0], true ); appendValueElement( _tblPr, _T( "tblStyleColBandSize" ), iter->Arguments[0], true );
} }
break; break;
//overlap
case sprmTFNoAllowOverlap: case sprmTFNoAllowOverlap:
{ { //overlap
std::wstring tblOverlapVal = std::wstring( _T( "overlap" ) ); std::wstring tblOverlapVal = std::wstring( _T( "overlap" ) );
if ( iter->Arguments[0] ) if ( iter->Arguments[0] )
...@@ -239,16 +242,17 @@ namespace DocFileFormat ...@@ -239,16 +242,17 @@ namespace DocFileFormat
} }
break; break;
//shading case sprmOldTSetShd :
case sprmTSetShdTable: case sprmTSetShdTable :
{ { //shading
appendShading( _tblPr, ShadingDescriptor( iter->Arguments, iter->argumentsSize ) ); appendShading( _tblPr, ShadingDescriptor( iter->Arguments, iter->argumentsSize ) );
} }
break; break;
//borders 80 exceptions
case sprmTTableBorders80: case sprmTTableBorders80:
{ { //borders 80 exceptions
const int size = 4; const int size = 4;
unsigned char brc80[size]; unsigned char brc80[size];
...@@ -285,6 +289,7 @@ namespace DocFileFormat ...@@ -285,6 +289,7 @@ namespace DocFileFormat
break; break;
//border exceptions //border exceptions
case sprmOldTTableBorders:
case sprmTTableBorders: case sprmTTableBorders:
{ {
const int size = 8; const int size = 8;
......
...@@ -54,53 +54,53 @@ namespace DocFileFormat ...@@ -54,53 +54,53 @@ namespace DocFileFormat
TablePropertyExceptions* tapx = static_cast<TablePropertyExceptions*>( visited ); TablePropertyExceptions* tapx = static_cast<TablePropertyExceptions*>( visited );
//delete infos //delete infos
RevisionData rev( this->_rowEndChpx ); RevisionData rev( _rowEndChpx );
if ( ( this->_rowEndChpx != NULL ) && ( rev.Type == Deleted ) ) if ( ( _rowEndChpx != NULL ) && ( rev.Type == Deleted ) )
{ {
XMLTools::XMLElement<wchar_t> del( _T( "w:del" ) ); XMLTools::XMLElement<wchar_t> del( _T( "w:del" ) );
this->_trPr->AppendChild( del ); _trPr->AppendChild( del );
} }
for ( std::list<SinglePropertyModifier>::iterator iter = tapx->grpprl->begin(); iter != tapx->grpprl->end(); iter++ ) for ( std::list<SinglePropertyModifier>::iterator iter = tapx->grpprl->begin(); iter != tapx->grpprl->end(); iter++ )
{ {
switch ( iter->OpCode ) switch ( iter->OpCode )
{ {
case sprmOldTDefTable:
case sprmTDefTable: case sprmTDefTable:
{ {
//SprmTDefTable tdef = new SprmTDefTable(sprm.Arguments); //SprmTDefTable tdef = new SprmTDefTable(sprm.Arguments);
} }
break; break;
//header row case sprmOldTTableHeader:
case sprmTTableHeader: case sprmTTableHeader:
{ { //header row
bool fHeader = ( iter->Arguments[0] != 0 ) ? (true) : (false); bool fHeader = ( iter->Arguments[0] != 0 ) ? (true) : (false);
if ( fHeader ) if ( fHeader )
{ {
XMLTools::XMLElement<wchar_t> header( _T( "w:tblHeader" ) ); XMLTools::XMLElement<wchar_t> header( _T( "w:tblHeader" ) );
this->_trPr->AppendChild( header ); _trPr->AppendChild( header );
} }
} }
break; break;
//width after
case sprmTWidthAfter: case sprmTWidthAfter:
{ { //width after
XMLTools::XMLElement<wchar_t> wAfter( _T( "w:wAfter" ) ); XMLTools::XMLElement<wchar_t> wAfter( _T( "w:wAfter" ) );
XMLTools::XMLAttribute<wchar_t> wAfterValue( _T( "w:w" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize ) ).c_str() ); XMLTools::XMLAttribute<wchar_t> wAfterValue( _T( "w:w" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize ) ).c_str() );
wAfter.AppendAttribute( wAfterValue ); wAfter.AppendAttribute( wAfterValue );
XMLTools::XMLAttribute<wchar_t> wAfterType( _T( "w:type" ), _T( "dxa" ) ); XMLTools::XMLAttribute<wchar_t> wAfterType( _T( "w:type" ), _T( "dxa" ) );
wAfter.AppendAttribute( wAfterType ); wAfter.AppendAttribute( wAfterType );
this->_trPr->AppendChild( wAfter ); _trPr->AppendChild( wAfter );
} }
break; break;
//width before
case sprmTWidthBefore: case sprmTWidthBefore:
{ { //width before
short before = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize ); short before = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize );
if ( before != 0 ) if ( before != 0 )
...@@ -111,14 +111,14 @@ namespace DocFileFormat ...@@ -111,14 +111,14 @@ namespace DocFileFormat
XMLTools::XMLAttribute<wchar_t> wBeforeType( _T( "w:type" ), _T( "dxa" ) ); XMLTools::XMLAttribute<wchar_t> wBeforeType( _T( "w:type" ), _T( "dxa" ) );
wBefore.AppendAttribute( wBeforeType ); wBefore.AppendAttribute( wBeforeType );
this->_trPr->AppendChild( wBefore ); _trPr->AppendChild( wBefore );
} }
} }
break; break;
//row height case sprmOldTDyaRowHeight:
case sprmTDyaRowHeight: case sprmTDyaRowHeight:
{ { //row height
XMLTools::XMLElement<wchar_t> rowHeight( _T( "w:trHeight" ) ); XMLTools::XMLElement<wchar_t> rowHeight( _T( "w:trHeight" ) );
XMLTools::XMLAttribute<wchar_t> rowHeightVal( _T( "w:val" ) ); XMLTools::XMLAttribute<wchar_t> rowHeightVal( _T( "w:val" ) );
XMLTools::XMLAttribute<wchar_t> rowHeightRule( _T( "w:hRule" ) ); XMLTools::XMLAttribute<wchar_t> rowHeightRule( _T( "w:hRule" ) );
...@@ -144,20 +144,22 @@ namespace DocFileFormat ...@@ -144,20 +144,22 @@ namespace DocFileFormat
} }
rowHeight.AppendAttribute( rowHeightRule ); rowHeight.AppendAttribute( rowHeightRule );
this->_trPr->AppendChild( rowHeight ); _trPr->AppendChild( rowHeight );
} }
break; break;
//can't split case sprmOldTFCantSplit:
case sprmTFCantSplit: case sprmTFCantSplit:
case sprmTFCantSplit90: case sprmTFCantSplit90:
appendFlagElement( this->_trPr, *iter, _T( "cantSplit" ), true ); { //can't split
break; appendFlagElement( _trPr, *iter, _T( "cantSplit" ), true );
}break;
//div id //div id
case sprmTIpgp: case sprmTIpgp:
appendValueElement( this->_trPr, _T( "divId" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true ); {
break; appendValueElement( _trPr, _T( "divId" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
}break;
//borders 80 exceptions //borders 80 exceptions
//case SinglePropertyModifier.OperationCode.sprmTTableBorders80: //case SinglePropertyModifier.OperationCode.sprmTTableBorders80:
...@@ -250,15 +252,15 @@ namespace DocFileFormat ...@@ -250,15 +252,15 @@ namespace DocFileFormat
//} //}
//set exceptions //set exceptions
if ( this->_tblPrEx->GetChildCount() > 0 ) if ( _tblPrEx->GetChildCount() > 0 )
{ {
this->_trPr->AppendChild( *(this->_tblPrEx) ); _trPr->AppendChild( *(_tblPrEx) );
} }
//write Properties //write Properties
if ( ( this->_trPr->GetChildCount() > 0 ) || ( this->_trPr->GetAttributeCount() > 0 ) ) if ( ( _trPr->GetChildCount() > 0 ) || ( _trPr->GetAttributeCount() > 0 ) )
{ {
m_pXmlWriter->WriteString( this->_trPr->GetXMLString().c_str() ); m_pXmlWriter->WriteString( _trPr->GetXMLString().c_str() );
} }
} }
} }
\ No newline at end of file
...@@ -31,14 +31,15 @@ ...@@ -31,14 +31,15 @@
*/ */
#include "WordDocument.h" #include "WordDocument.h"
#include "../../Common/OfficeFileErrorDescription.h" #include "../../Common/OfficeFileErrorDescription.h"
#include "../../ASCOfficeXlsFile2/source/XlsFormat/Logic/SummaryInformationStream/SummaryInformation.h" #include "../../ASCOfficeXlsFile2/source/XlsFormat/Logic/SummaryInformationStream/SummaryInformation.h"
#include "../../ASCOfficeXlsFile2/source/XlsFormat/Binary/CFStream.h" #include "../../ASCOfficeXlsFile2/source/XlsFormat/Binary/CFStream.h"
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h" #include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#include "../../DesktopEditor/common/File.h" #include "../../DesktopEditor/common/File.h"
namespace DocFileFormat namespace DocFileFormat
{ {
WordDocument::WordDocument (const ProgressCallback* pCallFunc, const std::wstring & sTempFolder ) : WordDocument::WordDocument (const ProgressCallback* pCallFunc, const std::wstring & sTempFolder ) :
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment