Commit 652fc292 authored by ElenaSubbotina's avatar ElenaSubbotina

DocFormatReader - same bugs fix

parent 2ff5bd59
......@@ -318,10 +318,13 @@ namespace DocFileFormat
iter->Arguments[0] = (iter->Arguments[0] == 0 ? 2 : 0);
}
RELEASEOBJECT( jc );
jc = new XMLTools::XMLElement<wchar_t>( _T( "w:jc" ) );
XMLTools::XMLAttribute<wchar_t> jcVal( _T( "w:val" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::JustificationCode[0][0], 10, 15 ).c_str() );
jc = new XMLTools::XMLElement<wchar_t>( L"w:jc" );
if ( jc )
{
XMLTools::XMLAttribute<wchar_t> jcVal( L"w:val", FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::JustificationCode[0][0], 10, 15 ).c_str() );
jc->AppendAttribute( jcVal );
}
}
break;
//borders
......@@ -485,8 +488,8 @@ namespace DocFileFormat
}
break;
//tabs
case sprmOldPChgTabs:
case sprmOldPChgTabs: //tabs
case sprmPChgTabsPapx:
case sprmPChgTabs:
{
......@@ -664,27 +667,23 @@ namespace DocFileFormat
_pPr->AppendChild( ind );
}
//append spacing
if ( spacing.GetAttributeCount() > 0 )
if ( spacing.GetAttributeCount() > 0 )//append spacing
{
_pPr->AppendChild( spacing );
}
//append justification
if ( jc != NULL )
if ( jc ) //append justification
{
_pPr->AppendChild( *jc );
RELEASEOBJECT( jc );
}
//append numPr
if ( numPr.GetChildCount() > 0 )
if ( numPr.GetChildCount() > 0 )//append numPr
{
_pPr->AppendChild( numPr );
}
//append borders
if ( pBdr.GetChildCount() > 0 )
if ( pBdr.GetChildCount() > 0 ) //append borders
{
_pPr->AppendChild( pBdr );
}
......
......@@ -46,8 +46,8 @@ namespace DocFileFormat
class ParagraphPropertiesMapping: public PropertiesMapping, public IMapping
{
public:
ParagraphPropertiesMapping( XMLTools::CStringXmlWriter* writer, ConversionContext* ctx, WordDocument* document, CharacterPropertyExceptions* paraEndChpx, bool isBidi, bool isParagraphStyleNeeded = true );
ParagraphPropertiesMapping( XMLTools::CStringXmlWriter* writer, ConversionContext* ctx, WordDocument* document, CharacterPropertyExceptions* paraEndChpx, bool isBidi, SectionPropertyExceptions* sepx, int sectionNr, bool isParagraphStyleNeeded = true );
ParagraphPropertiesMapping ( XMLTools::CStringXmlWriter* writer, ConversionContext* ctx, WordDocument* document, CharacterPropertyExceptions* paraEndChpx, bool isBidi, bool isParagraphStyleNeeded = true );
ParagraphPropertiesMapping ( XMLTools::CStringXmlWriter* writer, ConversionContext* ctx, WordDocument* document, CharacterPropertyExceptions* paraEndChpx, bool isBidi, SectionPropertyExceptions* sepx, int sectionNr, bool isParagraphStyleNeeded = true );
virtual ~ParagraphPropertiesMapping();
void Apply(IVisitable* visited);
......@@ -65,7 +65,6 @@ namespace DocFileFormat
bool _isParagraphStyleNeeded;
bool _isBidi;
int _isSectionPageBreak;
};
}
......@@ -35,7 +35,6 @@
namespace DocFileFormat
{
// Creates a new SectionPropertiesMapping which writes the properties to the given writer
SectionPropertiesMapping::SectionPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, ConversionContext* pContext, int nSelectProperties) : PropertiesMapping (pWriter)
{
m_bDeleteNode = TRUE;
......@@ -54,7 +53,6 @@ namespace DocFileFormat
_type = std::wstring (_T("nextPage"));
}
// Creates a new SectionPropertiesMapping which appends the properties to a given node.
SectionPropertiesMapping::SectionPropertiesMapping (XMLTools::XMLElement<wchar_t>* pBaseNode, ConversionContext* pContext, int nSelectProperties) : PropertiesMapping(NULL)
{
m_bDeleteNode = FALSE;
......@@ -85,7 +83,6 @@ namespace DocFileFormat
namespace DocFileFormat
{
// Converts the given SectionPropertyExceptions
void SectionPropertiesMapping::Apply (IVisitable* visited)
{
SectionPropertyExceptions* sepx = static_cast<SectionPropertyExceptions*>(visited);
......@@ -156,11 +153,9 @@ namespace DocFileFormat
{
switch (iter->OpCode)
{
//page margins
case sprmOldSDxaLeft:
case sprmSDxaLeft:
{
//left margin
_marLeft = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueAttribute( &pgMar, _T( "w:left" ), FormatUtils::IntToWideString( _marLeft ).c_str() );
}
......@@ -169,7 +164,6 @@ namespace DocFileFormat
case sprmOldSDxaRight:
case sprmSDxaRight:
{
//right margin
_marRight = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueAttribute( &pgMar, _T( "w:right" ), FormatUtils::IntToWideString( _marRight ).c_str() );
}
......@@ -177,39 +171,38 @@ namespace DocFileFormat
case sprmOldSDyaTop:
case sprmSDyaTop:
//top margin
//top margin
appendValueAttribute( &pgMar, _T( "w:top" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break;
case sprmOldSDyaBottom:
case sprmSDyaBottom:
//bottom margin
//bottom margin
appendValueAttribute( &pgMar, _T( "w:bottom" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break;
case sprmOldSDzaGutter:
case sprmSDzaGutter:
//gutter margin
//gutter margin
appendValueAttribute( &pgMar, _T( "w:gutter" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break;
case sprmOldSDyaHdrTop:
case sprmSDyaHdrTop:
//header margin
//header margin
appendValueAttribute( &pgMar, _T( "w:header"), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break;
case sprmOldSDyaHdrBottom:
case sprmSDyaHdrBottom:
//footer margin
//footer margin
appendValueAttribute( &pgMar, _T( "w:footer" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break;
//page size and orientation
//page size and orientation
case sprmOldSXaPage:
case sprmSXaPage:
{
//width
_pgWidth = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueAttribute( &pgSz, _T( "w:w" ), FormatUtils::IntToWideString( _pgWidth ).c_str() );
}
......@@ -217,7 +210,6 @@ namespace DocFileFormat
case sprmOldSYaPage:
case sprmSYaPage:
//height
appendValueAttribute( &pgSz, _T( "w:h" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break;
......@@ -227,7 +219,7 @@ namespace DocFileFormat
appendValueAttribute( &pgSz, _T( "w:orient" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &PageOrientationMap[0][0], 3, 10 ).c_str() );
break;
//paper source
//paper source
case sprmOldSDmBinFirst:
case sprmSDmBinFirst:
appendValueAttribute( &paperSrc, _T( "w:first" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
......@@ -238,7 +230,7 @@ namespace DocFileFormat
appendValueAttribute( &paperSrc, _T( "w:other" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break;
//page borders
//page borders
case sprmSBrcTop80:
case sprmSBrcTop:
{
......@@ -253,7 +245,6 @@ namespace DocFileFormat
case sprmSBrcLeft80:
case sprmSBrcLeft:
{
//left
XMLTools::XMLElement<wchar_t> leftBorder( _T( "w:left" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &leftBorder);
......@@ -283,13 +274,11 @@ namespace DocFileFormat
}
break;
//footnote properties
case sprmSRncFtn:
//restart code
appendValueElement( &footnotePr, _T( "numRestart" ), FormatUtils::MapValueToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ), &FootnoteRestartCodeMap[0][0], 3, 11 ).c_str(), true );
break;
//endnote properties
case sprmSRncEdn:
//restart code
appendValueElement( &endnotePr, _T( "numRestart" ), FormatUtils::MapValueToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ), &EndnoteRestartCodeMap[0][0], 3, 11 ).c_str(), true );
......@@ -313,16 +302,13 @@ namespace DocFileFormat
{
appendValueElement( &footnotePr, _T( "pos" ), _T( "beneathText" ), true );
}
}
break;
}break;
case sprmSNfcFtnRef:
//number format
appendValueElement( &footnotePr, _T( "numFmt" ), NumberingMapping::GetNumberFormatWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
break;
case sprmSNfcEdnRef:
//number format
appendValueElement( &endnotePr, _T( "numFmt" ), NumberingMapping::GetNumberFormatWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
break;
......@@ -334,7 +320,6 @@ namespace DocFileFormat
appendValueElement( &endnotePr, _T( "numStart" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
break;
//doc grid
case sprmSDyaLinePitch:
appendValueAttribute( &docGrid, _T( "w:linePitch" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break;
......@@ -347,7 +332,6 @@ namespace DocFileFormat
appendValueAttribute( &docGrid, _T( "w:type" ), FormatUtils::MapValueToWideString( FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize ), &DocGridTypeMap[0][0], 4, 14 ).c_str() );
break;
// Columns
case sprmOldSCcolumns:
case sprmSCcolumns:
{
......@@ -369,8 +353,7 @@ namespace DocFileFormat
case sprmOldSDxaColWidth:
case sprmSDxaColWidth:
{
// there is at least one width set, so create the array
if (m_nColumns)
if (m_nColumns) // there is at least one width set, so create the array
{
if (NULL == m_arrWidth)
m_arrWidth = new short [m_nColumns];
......@@ -393,26 +376,24 @@ namespace DocFileFormat
unsigned char nInd = iter->Arguments[0];
m_arrSpace [nInd] = FormatUtils::BytesToInt16 (iter->Arguments, 1, iter->argumentsSize);
}
}
break;
}break;
//bidi
case sprmSFBiDi:
appendFlagElement (m_pXmlNode, *iter, _T( "bidi" ), true );
break;
{
appendFlagElement (m_pXmlNode, *iter, _T( "bidi" ), iter->argumentsSize > 0 ? iter->Arguments[0] : true );
}break;
//title page
case sprmOldSFTitlePage:
case sprmSFTitlePage:
appendFlagElement (m_pXmlNode, *iter, _T( "titlePg" ), true );
break;
{
appendFlagElement (m_pXmlNode, *iter, _T( "titlePg" ), iter->argumentsSize > 0 ? iter->Arguments[0] : true );
}break;
//RTL gutter
case sprmSFRTLGutter:
appendFlagElement (m_pXmlNode, *iter, _T( "rtlGutter" ), true );
break;
{
appendFlagElement (m_pXmlNode, *iter, _T( "rtlGutter" ), iter->argumentsSize > 0 ? iter->Arguments[0] : true );
}break;
//type
case sprmOldSBkc:
case sprmSBkc:
{
......@@ -420,13 +401,11 @@ namespace DocFileFormat
}
break;
//align
case sprmOldSVjc:
case sprmSVjc:
appendValueElement (m_pXmlNode, _T( "vAlign" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &TextVerticalAlignment[0][0], 4, 7 ).c_str(), true );
break;
//pgNumType
case sprmOldSNfcPgn:
case sprmSNfcPgn:
appendValueAttribute( &pgNumType, _T( "w:fmt" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &PageNumberFormatCodeMap[0][0], 42, 29 ).c_str() );
......@@ -442,7 +421,7 @@ namespace DocFileFormat
bWasSprmSFPgnRestart = true;
break;
// <w:lnNumType> - Line Numbering Settings
// <w:lnNumType> - Line Numbering Settings
case sprmOldSLnnMin :
case sprmSLnnMin :
......@@ -487,7 +466,6 @@ namespace DocFileFormat
// build the columns
if (m_arrWidth)
{
//set to unequal width
XMLTools::XMLAttribute<wchar_t> equalWidth( _T( "w:equalWidth" ), _T( "0" ) );
cols.AppendAttribute( equalWidth );
......@@ -506,7 +484,6 @@ namespace DocFileFormat
m_arrWidth [m_nColumns - 1] = lastColWidth;
}
// append the xml elements
for (int i = 0; i < m_nColumns; ++i)
{
XMLTools::XMLElement<wchar_t> col (_T( "w:col" ));
......@@ -519,46 +496,35 @@ namespace DocFileFormat
}
}
//append the section type
appendValueElement (m_pXmlNode, _T( "type" ), _type.c_str(), true );
// Document-Wide Footnote Properties
if (footnotePr.GetChildCount())
m_pXmlNode->AppendChild (footnotePr);
// Document-Wide Endnote Properties
if (endnotePr.GetChildCount())
m_pXmlNode->AppendChild (endnotePr);
// Page Size
if (pgSz.GetAttributeCount())
m_pXmlNode->AppendChild (pgSz);
// Page Borders
if (pgBorders.GetChildCount())
m_pXmlNode->AppendChild (pgBorders);
// Page Margins
if (pgMar.GetAttributeCount())
m_pXmlNode->AppendChild (pgMar);
// Line Numbering Settings
if (lnNumType.GetAttributeCount())
m_pXmlNode->AppendChild (lnNumType);
// Paper Source Information
if (paperSrc.GetAttributeCount())
m_pXmlNode->AppendChild (paperSrc);
// Single Column Definition)
if (cols.GetAttributeCount() || cols.GetChildCount())
m_pXmlNode->AppendChild (cols);
// Document Grid
if (docGrid.GetAttributeCount())
m_pXmlNode->AppendChild (docGrid);
// Page Numbering Settings
if (pgNumType.GetAttributeCount())
m_pXmlNode->AppendChild (pgNumType);
......
......@@ -42,11 +42,11 @@ namespace DocFileFormat
SectionPropertyExceptions( unsigned char* bytes, int size, bool oldVersion ):
PropertyExceptions( bytes, size, oldVersion ), isBidi(false)
{
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 );
if( sprm.OpCode == sprmSFBiDi )
if( sprm.OpCode == sprmSFBiDi && sprm.Arguments[0] != 0)
{
isBidi = true;
}
......
......@@ -1047,7 +1047,7 @@ namespace DocFileFormat
//ShapeType
if (NULL != pShape->GetShapeType() /* && !m_isInlineShape*/) //bullete only???
{
VMLShapeTypeMapping oXmlMapper(m_pXmlWriter);
VMLShapeTypeMapping oXmlMapper(m_pXmlWriter, m_isInlineShape);
pShape->GetShapeType()->Convert(&oXmlMapper);
}
}
......
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