Commit bb6e95ce authored by ElenaSubbotina's avatar ElenaSubbotina

DocFormatReader - refactoring + fix errors

parent 69d98238
......@@ -125,7 +125,7 @@ namespace DocFormatUtils
if(bDeleteNoUnicode)
{
for(size_t pos = 0; pos != data.size(); ++pos)
for(size_t pos = 0; pos < data.size(); ++pos)
{
switch(data[pos])
{
......@@ -157,7 +157,7 @@ namespace DocFormatUtils
}
else
{
for(size_t pos = 0; pos != data.size(); ++pos)
for(size_t pos = 0; pos < data.size(); ++pos)
{
switch(data[pos])
{
......@@ -166,6 +166,8 @@ namespace DocFormatUtils
case '\'': buffer.append(L"&apos;"); break;
case '<': buffer.append(L"&lt;"); break;
case '>': buffer.append(L"&gt;"); break;
case '\0':
return buffer;
default: buffer.append(&data[pos], 1); break;
}
}
......
......@@ -85,7 +85,7 @@ namespace DocFileFormat
if (author_str)
{
XMLTools::XMLAttribute author( _T( "w:author" ), FormatUtils::XmlEncode(*author_str).c_str());
XMLTools::XMLAttribute author( _T( "w:author" ), FormatUtils::XmlEncode(*author_str));
rPrChange.AppendAttribute( author );
}
......@@ -98,7 +98,7 @@ namespace DocFileFormat
//write properties
if ( ( m_pXmlWriter != NULL ) && ( ( _rPr->GetChildCount() > 0 ) || ( _rPr->GetAttributeCount() > 0 ) ) )
{
m_pXmlWriter->WriteString( _rPr->GetXMLString().c_str() );
m_pXmlWriter->WriteString( _rPr->GetXMLString());
}
}
......@@ -144,7 +144,7 @@ namespace DocFileFormat
_currentIstd = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if (_currentIstd < _doc->Styles->Styles->size())
{
appendValueElement( parent, _T( "rStyle" ), StyleSheetMapping::MakeStyleId( _doc->Styles->Styles->at( _currentIstd ) ).c_str(), true );
appendValueElement( parent, _T( "rStyle" ), StyleSheetMapping::MakeStyleId( _doc->Styles->Styles->at( _currentIstd ) ), true );
}
}
}break;
......@@ -232,7 +232,7 @@ namespace DocFileFormat
case sprmOldCIss:
case sprmCIss:
appendValueElement( parent, _T( "vertAlign" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &SuperscriptIndex[0][0], 3, 12 ).c_str(), true );
appendValueElement( parent, _T( "vertAlign" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &SuperscriptIndex[0][0], 3, 12 ), true );
break;
case sprmCRgLid0_80:
......@@ -292,7 +292,7 @@ namespace DocFileFormat
case sprmCIco:
case sprmCIcoBi:
{//color
colorVal->SetValue( FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::ColorIdentifier[0][0], 17, 12 ).c_str() );
colorVal->SetValue( FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::ColorIdentifier[0][0], 17, 12 ));
}break;
case sprmCCv:
......@@ -305,17 +305,17 @@ namespace DocFileFormat
case sprmCOldHighlight:
{
appendValueElement( parent, _T( "highlight" ), FormatUtils::MapValueToWideString( iter->Arguments[1], &Global::ColorIdentifier[0][0], 17, 12 ).c_str(), true );
appendValueElement( parent, _T( "highlight" ), FormatUtils::MapValueToWideString( iter->Arguments[1], &Global::ColorIdentifier[0][0], 17, 12 ), true );
}break;
case sprmCHighlight:
{
appendValueElement( parent, _T( "highlight" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::ColorIdentifier[0][0], 17, 12 ).c_str(), true );
appendValueElement( parent, _T( "highlight" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::ColorIdentifier[0][0], 17, 12 ), true );
}break;
case sprmOldCDxaSpace:
case sprmCDxaSpace:
{
appendValueElement( parent, _T( "spacing" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
appendValueElement( parent, _T( "spacing" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
case sprmCFtcBi :
......@@ -332,20 +332,20 @@ namespace DocFileFormat
case sprmCHpsBi :
{
appendValueElement( parent, _T( "szCs" ),
FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
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, _T( "sz" ),
FormatUtils::IntToWideString (FormatUtils::BytesToUChar (iter->Arguments, 0, iter->argumentsSize) ).c_str(),
FormatUtils::IntToWideString (FormatUtils::BytesToUChar (iter->Arguments, 0, iter->argumentsSize) ),
true );
}break;
case sprmCHps :
{
appendValueElement (parent, _T( "sz" ),
FormatUtils::IntToWideString (FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize) ).c_str(), true );
FormatUtils::IntToWideString (FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize) ), true );
}break;
case sprmCMajority :
......@@ -366,7 +366,7 @@ namespace DocFileFormat
case sprmOldCHpsKern:
case sprmCHpsKern:
{
appendValueElement( parent, _T( "kern" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
appendValueElement( parent, _T( "kern" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
case sprmOldCFtc:
......@@ -379,7 +379,7 @@ namespace DocFileFormat
XMLTools::XMLAttribute* ascii = new XMLTools::XMLAttribute( _T( "w:ascii" ) );
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
m_sAsciiFont = ffn->xszFtn;
ascii->SetValue( FormatUtils::XmlEncode(m_sAsciiFont).c_str() );
ascii->SetValue( FormatUtils::XmlEncode(m_sAsciiFont, true));
rFonts->AppendAttribute( *ascii );
RELEASEOBJECT( ascii );
}
......@@ -393,7 +393,7 @@ namespace DocFileFormat
XMLTools::XMLAttribute* eastAsia = new XMLTools::XMLAttribute( _T( "w:eastAsia" ) );
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
m_sEastAsiaFont = ffn->xszFtn;
eastAsia->SetValue( FormatUtils::XmlEncode(m_sEastAsiaFont).c_str() );
eastAsia->SetValue( FormatUtils::XmlEncode(m_sEastAsiaFont));
rFonts->AppendAttribute( *eastAsia );
RELEASEOBJECT( eastAsia );
}
......@@ -408,7 +408,7 @@ namespace DocFileFormat
XMLTools::XMLAttribute* ansi = new XMLTools::XMLAttribute( _T( "w:hAnsi" ) );
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
m_shAnsiFont = ffn->xszFtn;
ansi->SetValue( FormatUtils::XmlEncode(m_shAnsiFont).c_str() );
ansi->SetValue( FormatUtils::XmlEncode(m_shAnsiFont));
rFonts->AppendAttribute( *ansi );
RELEASEOBJECT( ansi );
}
......@@ -417,18 +417,18 @@ namespace DocFileFormat
case sprmOldCKul:
case sprmCKul:
{ //Underlining
appendValueElement( parent, _T( "u" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::UnderlineCode[0][0], 56, 16 ).c_str(), true );
appendValueElement( parent, _T( "u" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::UnderlineCode[0][0], 56, 16 ), true );
}
break;
case sprmCCharScale:
{ //char width
appendValueElement( parent, _T( "w" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
appendValueElement( parent, _T( "w" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
case sprmCSfxText:
{ //animation
appendValueElement( parent, _T( "effect" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::TextAnimation[0][0], 7, 16 ).c_str(), true );
appendValueElement( parent, _T( "effect" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::TextAnimation[0][0], 7, 16 ), true );
}break;
case sprmCIdctHint:
......@@ -483,7 +483,7 @@ namespace DocFileFormat
if (!m_sDefaultFont.empty() && m_sAsciiFont.empty() && m_sEastAsiaFont.empty() && m_shAnsiFont.empty())
{//????
XMLTools::XMLAttribute* ascii = new XMLTools::XMLAttribute( _T( "w:ascii" ) );
ascii->SetValue( FormatUtils::XmlEncode(m_sDefaultFont).c_str() );
ascii->SetValue( FormatUtils::XmlEncode(m_sDefaultFont));
//rFonts->AppendAttribute( *ascii );
RELEASEOBJECT( ascii );
}
......
......@@ -73,10 +73,10 @@ namespace DocFileFormat
AnnotationReferenceDescriptor* atrdPre10 = static_cast<AnnotationReferenceDescriptor*>(m_document->AnnotationsReferencePlex->Elements[index]);
m_pXmlWriter->WriteNodeBegin( _T( "w:comment" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( index ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( index ));
m_pXmlWriter->WriteAttribute( _T( "w:author" ),
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( atrdPre10->GetAuthorIndex() ) ).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:initials" ), atrdPre10->GetUserInitials().c_str() );
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( atrdPre10->GetAuthorIndex() ) ));
m_pXmlWriter->WriteAttribute( _T( "w:initials" ), atrdPre10->GetUserInitials());
//!!!TODO!!!
/*//ATRDpost10 is optional and not saved in all files
......
......@@ -70,7 +70,7 @@ namespace DocFileFormat
while ( cp <= ( m_document->FIB->m_RgLw97.ccpText + m_document->FIB->m_RgLw97.ccpFtn + m_document->FIB->m_RgLw97.ccpHdr + m_document->FIB->m_RgLw97.ccpAtn + m_document->FIB->m_RgLw97.ccpEdn - 2 ) )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:endnote" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( id ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( id ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
while ( ( cp - m_document->FIB->m_RgLw97.ccpText - m_document->FIB->m_RgLw97.ccpFtn - m_document->FIB->m_RgLw97.ccpHdr - m_document->FIB->m_RgLw97.ccpAtn ) < (*m_document->IndividualEndnotesPlex)[id + 1] )
......
......@@ -59,34 +59,39 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( _T( "xmlns:w" ), OpenXmlNamespaces::WordprocessingML );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
int sz_fonts = table->Data.size();
int sz_fonts = table->Data.size();
int users_fonts = 0;
for ( std::vector<ByteStructure*>::iterator iter = table->Data.begin(); iter != table->Data.end(); iter++ )
{
FontFamilyName* font = dynamic_cast<FontFamilyName*>( *iter );
m_pXmlWriter->WriteNodeBegin( _T( "w:font" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:name" ), FormatUtils::XmlEncode(font->xszFtn, true).c_str());
std::wstring name_ = FormatUtils::XmlEncode(font->xszFtn, true);
if (name_.empty())
name_ = L"UserFont_" + std::to_wstring(++users_fonts);
m_pXmlWriter->WriteAttribute( _T( "w:name" ), name_);
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
//alternative name
if ( ( font->xszAlt != std::wstring( _T( "" ) ) ) && ( font->xszAlt.length() > 0 ) )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:altName" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(font->xszAlt, true).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(font->xszAlt, true));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:altName" ) );
}
//charset
m_pXmlWriter->WriteNodeBegin( _T("w:charset" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToFormattedWideString( font->chs, _T( "%02x" ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::IntToFormattedWideString( font->chs, _T( "%02x" ) ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:charset" ) );
//font family
m_pXmlWriter->WriteNodeBegin( _T("w:family"), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString( font->ff, &FontFamily[0][0], 6, 11 ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString( font->ff, &FontFamily[0][0], 6, 11 ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:family" ) );
......@@ -100,13 +105,13 @@ namespace DocFileFormat
wstr += FormatUtils::IntToFormattedWideString( font->panose[i], _T( "%02x" ) );
}
m_pXmlWriter->WriteAttribute( _T( "w:val" ), wstr.c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), wstr);
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:panose1" ) );
//pitch
m_pXmlWriter->WriteNodeBegin( _T("w:pitch"), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString( font->prq, &FontPitch[0][0], 3, 9 ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString( font->prq, &FontPitch[0][0], 3, 9 ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:pitch" ) );
......@@ -121,12 +126,12 @@ namespace DocFileFormat
//font signature
m_pXmlWriter->WriteNodeBegin( _T("w:sig"), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:usb0" ), FormatUtils::IntToFormattedWideString( font->fs.UnicodeSubsetBitfield0, _T( "%08x" ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:usb1" ), FormatUtils::IntToFormattedWideString( font->fs.UnicodeSubsetBitfield1, _T( "%08x" ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:usb2" ), FormatUtils::IntToFormattedWideString( font->fs.UnicodeSubsetBitfield2, _T( "%08x" ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:usb3" ), FormatUtils::IntToFormattedWideString( font->fs.UnicodeSubsetBitfield3, _T( "%08x" ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:csb0" ), FormatUtils::IntToFormattedWideString( font->fs.CodePageBitfield0, _T( "%08x" ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:csb1" ), FormatUtils::IntToFormattedWideString( font->fs.CodePageBitfield1, _T( "%08x" ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:usb0" ), FormatUtils::IntToFormattedWideString( font->fs.UnicodeSubsetBitfield0, _T( "%08x" ) ));
m_pXmlWriter->WriteAttribute( _T( "w:usb1" ), FormatUtils::IntToFormattedWideString( font->fs.UnicodeSubsetBitfield1, _T( "%08x" ) ));
m_pXmlWriter->WriteAttribute( _T( "w:usb2" ), FormatUtils::IntToFormattedWideString( font->fs.UnicodeSubsetBitfield2, _T( "%08x" ) ));
m_pXmlWriter->WriteAttribute( _T( "w:usb3" ), FormatUtils::IntToFormattedWideString( font->fs.UnicodeSubsetBitfield3, _T( "%08x" ) ));
m_pXmlWriter->WriteAttribute( _T( "w:csb0" ), FormatUtils::IntToFormattedWideString( font->fs.CodePageBitfield0, _T( "%08x" ) ));
m_pXmlWriter->WriteAttribute( _T( "w:csb1" ), FormatUtils::IntToFormattedWideString( font->fs.CodePageBitfield1, _T( "%08x" ) ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:sig" ) );
......
......@@ -70,7 +70,7 @@ namespace DocFileFormat
while ( cp <= ( m_document->FIB->m_RgLw97.ccpText + m_document->FIB->m_RgLw97.ccpFtn - 2 ) )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:footnote" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( id ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( id ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
while ( ( cp - m_document->FIB->m_RgLw97.ccpText ) < (*m_document->IndividualFootnotesPlex)[id + 1] )
......
......@@ -65,25 +65,25 @@ namespace DocFileFormat
{
case Default:
{
att = new XMLTools::XMLAttribute( L"w:val", langcode.c_str() );
att = new XMLTools::XMLAttribute( L"w:val", langcode);
}
break;
case EastAsian:
{
att = new XMLTools::XMLAttribute( L"w:eastAsia", langcode.c_str() );
att = new XMLTools::XMLAttribute( L"w:eastAsia", langcode);
}
break;
case Complex:
{
att = new XMLTools::XMLAttribute( L"w:bidi", langcode.c_str() );
att = new XMLTools::XMLAttribute( L"w:bidi", langcode);
}
break;
default:
{
att = new XMLTools::XMLAttribute( L"w:val", langcode.c_str() );
att = new XMLTools::XMLAttribute( L"w:val", langcode);
}
break;
}
......@@ -91,7 +91,7 @@ namespace DocFileFormat
if (m_pXmlWriter)
{
// !!!TODO!!!
m_pXmlWriter->WriteString( att->GetXMLString().c_str() );
m_pXmlWriter->WriteString( att->GetXMLString());
}
else if ( _parent != NULL )
{
......
......@@ -71,9 +71,9 @@ namespace DocFileFormat
{
int relID = m_context->_docx->RegisterExternalOLEObject(_caller, ole->ClipboardFormat, ole->Link);
m_pXmlWriter->WriteAttribute( _T( "r:id" ), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "r:id" ), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ));
m_pXmlWriter->WriteAttribute( _T( "Type" ), _T( "Link" ) );
m_pXmlWriter->WriteAttribute( _T( "UpdateMode" ), ole->UpdateMode.c_str() );
m_pXmlWriter->WriteAttribute( _T( "UpdateMode" ), ole->UpdateMode);
}
else
{
......@@ -84,16 +84,16 @@ namespace DocFileFormat
else
relID = m_context->_docx->RegisterOLEObject(_caller, ole->ClipboardFormat);
m_pXmlWriter->WriteAttribute( _T( "r:id" ), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "r:id" ), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ));
m_pXmlWriter->WriteAttribute( _T( "Type" ), _T( "Embed" ) );
copyEmbeddedObject( ole );
}
m_pXmlWriter->WriteAttribute( _T( "ProgID" ), ole->Program.c_str() );
m_pXmlWriter->WriteAttribute( _T( "ShapeID" ), _shapeId.c_str() );
m_pXmlWriter->WriteAttribute( _T( "ProgID" ), ole->Program);
m_pXmlWriter->WriteAttribute( _T( "ShapeID" ), _shapeId);
m_pXmlWriter->WriteAttribute( _T( "DrawAspect" ), _T( "Content" ) );
m_pXmlWriter->WriteAttribute( _T( "ObjectID" ), ole->ObjectId.c_str() );
m_pXmlWriter->WriteAttribute( _T( "ObjectID" ), ole->ObjectId);
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "o:OLEObject" ) );
......
......@@ -224,7 +224,7 @@ namespace DocFileFormat
{
HeaderRelationshipsFiles.push_back( RelationshipsFile( ( std::wstring( _T( "word/_rels/header" ) ) + FormatUtils::IntToWideString( ++_headerCounter ) + std::wstring( _T( ".xml.rels" ) ) ) ) );
return AddPart( _T( "word" ), ( std::wstring( _T( "header" ) ) + FormatUtils::IntToWideString( _headerCounter ) + std::wstring( _T( ".xml" ) ) ).c_str(), WordprocessingMLContentTypes::Header, OpenXmlRelationshipTypes::Header );
return AddPart( _T( "word" ), ( std::wstring( _T( "header" ) ) + FormatUtils::IntToWideString( _headerCounter ) + std::wstring( _T( ".xml" ) ) ), WordprocessingMLContentTypes::Header, OpenXmlRelationshipTypes::Header );
}
int OpenXmlPackage::AddHeaderPart( const std::wstring& fileName, const std::wstring& relationshipType, const std::wstring& targetMode )
......@@ -245,7 +245,7 @@ namespace DocFileFormat
{
FooterRelationshipsFiles.push_back( RelationshipsFile( ( std::wstring( _T( "word/_rels/footer" ) ) + FormatUtils::IntToWideString( ++_footerCounter ) + std::wstring( _T( ".xml.rels" ) ) ) ) );
return AddPart( _T( "word" ), ( std::wstring( _T( "footer" ) ) + FormatUtils::IntToWideString( _footerCounter ) + std::wstring( _T( ".xml" ) ) ).c_str(), WordprocessingMLContentTypes::Footer, OpenXmlRelationshipTypes::Footer );
return AddPart( _T( "word" ), ( std::wstring( _T( "footer" ) ) + FormatUtils::IntToWideString( _footerCounter ) + std::wstring( _T( ".xml" ) ) ), WordprocessingMLContentTypes::Footer, OpenXmlRelationshipTypes::Footer );
}
int OpenXmlPackage::AddFooterPart( const std::wstring& fileName, const std::wstring& relationshipType, const std::wstring& targetMode )
......@@ -322,13 +322,13 @@ namespace DocFileFormat
for ( std::list<Relationship>::const_iterator iter = relationshipsFile.Relationships.begin(); iter != relationshipsFile.Relationships.end(); iter++ )
{
writer.WriteNodeBegin( _T( "Relationship" ), TRUE );
writer.WriteAttribute( _T( "Id" ), iter->Id.c_str() );
writer.WriteAttribute( _T( "Type" ), iter->Type.c_str() );
writer.WriteAttribute( _T( "Target" ), iter->Target.c_str() );
writer.WriteAttribute( _T( "Id" ), iter->Id );
writer.WriteAttribute( _T( "Type" ), iter->Type );
writer.WriteAttribute( _T( "Target" ), iter->Target );
if ( !iter->TargetMode.empty() )
{
writer.WriteAttribute( _T( "TargetMode" ), iter->TargetMode.c_str() );
writer.WriteAttribute( _T( "TargetMode" ), iter->TargetMode );
}
writer.WriteNodeEnd( _T( "" ), TRUE );
......@@ -358,16 +358,16 @@ namespace DocFileFormat
for ( std::map<std::wstring, std::wstring>::iterator iter = DocumentContentTypesFile._defaultTypes.begin(); iter != DocumentContentTypesFile._defaultTypes.end(); iter++ )
{
writer.WriteNodeBegin( _T( "Default" ), TRUE );
writer.WriteAttribute( _T( "Extension" ), iter->first.c_str() );
writer.WriteAttribute( _T( "ContentType" ), DocumentContentTypesFile._defaultTypes[iter->first].c_str() );
writer.WriteAttribute( _T( "Extension" ), iter->first );
writer.WriteAttribute( _T( "ContentType" ), DocumentContentTypesFile._defaultTypes[iter->first] );
writer.WriteNodeEnd( _T( "" ), TRUE );
}
for ( std::map<std::wstring, std::wstring>::iterator iter = DocumentContentTypesFile._partOverrides.begin(); iter != DocumentContentTypesFile._partOverrides.end(); iter++ )
{
writer.WriteNodeBegin( _T( "Override" ), TRUE );
writer.WriteAttribute( _T( "PartName" ), iter->first.c_str() );
writer.WriteAttribute( _T( "ContentType" ), DocumentContentTypesFile._partOverrides[iter->first].c_str() );
writer.WriteAttribute( _T( "PartName" ), iter->first );
writer.WriteAttribute( _T( "ContentType" ), DocumentContentTypesFile._partOverrides[iter->first] );
writer.WriteNodeEnd( _T( "" ), TRUE );
}
......
......@@ -96,7 +96,7 @@ namespace DocFileFormat
if ( papx->istd < m_document->Styles->Styles->size() )
{
styleId.SetValue( FormatUtils::XmlEncode(StyleSheetMapping::MakeStyleId( m_document->Styles->Styles->at( papx->istd ) )).c_str() );
styleId.SetValue( FormatUtils::XmlEncode(StyleSheetMapping::MakeStyleId( m_document->Styles->Styles->at( papx->istd ) )) );
}
pStyle.AppendAttribute( styleId );
......@@ -139,7 +139,7 @@ namespace DocFileFormat
{
case sprmPIpgp:
{
appendValueElement(_pPr, _T( "divId" ), FormatUtils::IntToWideString( FormatUtils::BytesToUInt32(iter->Arguments, 0, iter->argumentsSize)).c_str(), true);
appendValueElement(_pPr, _T( "divId" ), FormatUtils::IntToWideString( FormatUtils::BytesToUInt32(iter->Arguments, 0, iter->argumentsSize)), true);
}break;
case sprmPFAutoSpaceDE:
......@@ -242,7 +242,7 @@ namespace DocFileFormat
flValue *= -1;
}
appendValueAttribute( &ind, flName.c_str(), flValue );
appendValueAttribute( &ind, flName, flValue );
}break;
case sprmPDxcLeft1:
......@@ -283,7 +283,7 @@ namespace DocFileFormat
{
LineSpacingDescriptor lspd( iter->Arguments, iter->argumentsSize );
XMLTools::XMLAttribute line( _T( "w:line" ), FormatUtils::IntToWideString( abs( lspd.dyaLine ) ).c_str() );
XMLTools::XMLAttribute line( _T( "w:line" ), FormatUtils::IntToWideString( abs( lspd.dyaLine ) ));
spacing.AppendAttribute( line );
XMLTools::XMLAttribute lineRule( _T( "w:lineRule" ), _T( "auto" ) );
......@@ -314,7 +314,7 @@ namespace DocFileFormat
jc = new XMLTools::XMLElement( L"w:jc" );
if ( jc )
{
XMLTools::XMLAttribute jcVal( L"w:val", FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::JustificationCode[0][0], 10, 15 ).c_str() );
XMLTools::XMLAttribute jcVal( L"w:val", FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::JustificationCode[0][0], 10, 15 ));
jc->AppendAttribute( jcVal );
}
}break;
......@@ -438,10 +438,13 @@ namespace DocFileFormat
}break;
case sprmOldPNLvlAnm:
{ short level = FormatUtils::BytesToUChar( iter->Arguments, 0, iter->argumentsSize) - 1;
{
short level = FormatUtils::BytesToUChar( iter->Arguments, 0, iter->argumentsSize) - 1;
if (level > 0 && level < 10)
appendValueElement( _pPr, _T( "outlineLvl" ), level, false );
}break; case sprmOldPFNoLineNumb:
}break;
case sprmOldPFNoLineNumb:
{
}break;
......@@ -498,7 +501,7 @@ namespace DocFileFormat
tab.AppendAttribute( tabsVal );
//position
XMLTools::XMLAttribute tabsPos( _T( "w:pos" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, pos, iter->argumentsSize ) ).c_str() );
XMLTools::XMLAttribute tabsPos( _T( "w:pos" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, pos, iter->argumentsSize ) ) );
tab.AppendAttribute( tabsPos );
tabs.AppendChild( tab );
......@@ -515,9 +518,9 @@ namespace DocFileFormat
}
//read the added tabs
unsigned char itbdAddMax = iter->Arguments[pos];
unsigned char itbdAddMax = pos < iter->argumentsSize ? iter->Arguments[pos] : 0;
pos++;
if (itbdAddMax > 0) pos++;
for ( int i = 0; i < itbdAddMax; i++ )
{
......@@ -526,15 +529,15 @@ namespace DocFileFormat
XMLTools::XMLElement tab( _T( "w:tab" ) );
//justification
XMLTools::XMLAttribute tabsVal( _T( "w:val" ), FormatUtils::MapValueToWideString( tbd.jc, &Global::TabStop[0][0], 7, 8 ).c_str() );
XMLTools::XMLAttribute tabsVal( _T( "w:val" ), FormatUtils::MapValueToWideString( tbd.jc, &Global::TabStop[0][0], 7, 8 ) );
tab.AppendAttribute( tabsVal );
//tab leader type
XMLTools::XMLAttribute leader( _T( "w:leader" ), FormatUtils::MapValueToWideString( tbd.tlc, &Global::TabLeader[0][0], 8, 11 ).c_str() );
XMLTools::XMLAttribute leader( _T( "w:leader" ), FormatUtils::MapValueToWideString( tbd.tlc, &Global::TabLeader[0][0], 8, 11 ) );
tab.AppendAttribute( leader );
//position
XMLTools::XMLAttribute tabsPos( _T( "w:pos" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, ( pos + (i * 2) ), iter->argumentsSize ) ).c_str() );
XMLTools::XMLAttribute tabsPos( _T( "w:pos" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, ( pos + (i * 2) ), iter->argumentsSize ) ) );
tab.AppendAttribute( tabsPos );
tabs.AppendChild( tab );
......@@ -551,14 +554,14 @@ namespace DocFileFormat
//position code
unsigned char flag = iter->Arguments[0];
appendValueAttribute (_framePr, _T( "w:hAnchor" ), FormatUtils::MapValueToWideString( ( ( flag & 0xC0 ) >> 6 ), &Global::HorizontalPositionCode[0][0], 4, 7 ).c_str() );
appendValueAttribute (_framePr, _T( "w:vAnchor" ), FormatUtils::MapValueToWideString( ( ( flag & 0x30 ) >> 4 ), &Global::VerticalPositionCode[0][0], 4, 7 ).c_str() );
appendValueAttribute (_framePr, _T( "w:hAnchor" ), FormatUtils::MapValueToWideString( ( ( flag & 0xC0 ) >> 6 ), &Global::HorizontalPositionCode[0][0], 4, 7 ) );
appendValueAttribute (_framePr, _T( "w:vAnchor" ), FormatUtils::MapValueToWideString( ( ( flag & 0x30 ) >> 4 ), &Global::VerticalPositionCode[0][0], 4, 7 ) );
}
break;
case sprmOldPWr:
case sprmPWr:
appendValueAttribute( _framePr, _T( "w:wrap" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::TextFrameWrapping[0][0], 6, 10 ).c_str() );
appendValueAttribute( _framePr, _T( "w:wrap" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::TextFrameWrapping[0][0], 6, 10 ) );
break;
case sprmOldPDxaAbs:
......@@ -595,7 +598,7 @@ namespace DocFileFormat
{
short pDcs = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueAttribute( _framePr, _T( "w:dropCap" ), FormatUtils::MapValueToWideString( ( pDcs & 0x07 ), &Global::TextFrameDropCapLocation[0][0], 3, 7 ).c_str() );
appendValueAttribute( _framePr, _T( "w:dropCap" ), FormatUtils::MapValueToWideString( ( pDcs & 0x07 ), &Global::TextFrameDropCapLocation[0][0], 3, 7 ) );
appendValueAttribute( _framePr, _T( "w:lines" ), (unsigned char)( ( pDcs & 0xF8 ) >> 3 ) );
}
......@@ -678,7 +681,7 @@ namespace DocFileFormat
//write Properties
if ( ( _pPr->GetChildCount() > 0 ) || ( _pPr->GetAttributeCount() > 0 ) )
{
m_pXmlWriter->WriteString( _pPr->GetXMLString().c_str() );
m_pXmlWriter->WriteString( _pPr->GetXMLString() );
}
}
}
......@@ -51,24 +51,26 @@ namespace DocFileFormat
protected:
static void init();
void appendFlagAttribute( XMLTools::XMLElement* node, const SinglePropertyModifier& sprm, const wchar_t* attributeName );
virtual void appendFlagElement( XMLTools::XMLElement* node, const SinglePropertyModifier& sprm, const wchar_t* elementName, bool unique );
void appendValueAttribute( XMLTools::XMLElement* node, const wchar_t* attributeName, const wchar_t* attributeValue );
void appendValueAttribute( XMLTools::XMLElement* node, const wchar_t* attributeName, int attributeValue );
void appendValueAttribute( XMLTools::XMLElement* node, const wchar_t* attributeName, short attributeValue );
void appendValueAttribute( XMLTools::XMLElement* node, const wchar_t* attributeName, unsigned short attributeValue );
void appendValueAttribute( XMLTools::XMLElement* node, const wchar_t* attributeName, unsigned char attributeValue );
void appendValueElement( XMLTools::XMLElement* node, const wchar_t* elementName, const wchar_t* elementValue, bool unique );
void appendValueElement( XMLTools::XMLElement* node, const wchar_t* elementName, short elementValue, bool unique );
void appendValueElement( XMLTools::XMLElement* node, const wchar_t* elementName, unsigned short elementValue, bool unique );
void appendValueElement( XMLTools::XMLElement* node, const wchar_t* elementName, unsigned char elementValue, bool unique );
void appendBorderAttributes( BorderCode* brc, XMLTools::XMLElement* border );
void appendShading( XMLTools::XMLElement* parent, const ShadingDescriptor& desc );
std::wstring getBorderType( unsigned char type );
std::wstring getShadingPattern( const ShadingDescriptor& shd );
void appendDxaElement( XMLTools::XMLElement* node, const wchar_t* elementName, const wchar_t* elementValue, bool unique );
void addOrSetBorder( XMLTools::XMLElement* pBdr, const XMLTools::XMLElement* border );
virtual void appendFlagElement( XMLTools::XMLElement* node, const SinglePropertyModifier& sprm, const std::wstring & elementName, bool unique );
void appendFlagAttribute ( XMLTools::XMLElement* node, const SinglePropertyModifier& sprm, const std::wstring & attributeName );
void appendValueAttribute ( XMLTools::XMLElement* node, const std::wstring & attributeName, const std::wstring & attributeValue );
void appendValueAttribute ( XMLTools::XMLElement* node, const std::wstring & attributeName, int attributeValue );
void appendValueAttribute ( XMLTools::XMLElement* node, const std::wstring & ttributeName, short attributeValue );
void appendValueAttribute ( XMLTools::XMLElement* node, const std::wstring & attributeName, unsigned short attributeValue );
void appendValueAttribute ( XMLTools::XMLElement* node, const std::wstring & attributeName, unsigned char attributeValue );
void appendValueElement ( XMLTools::XMLElement* node, const std::wstring & elementName, const std::wstring & elementValue, bool unique );
void appendValueElement ( XMLTools::XMLElement* node, const std::wstring & elementName, short elementValue, bool unique );
void appendValueElement ( XMLTools::XMLElement* node, const std::wstring & elementName, unsigned short elementValue, bool unique );
void appendValueElement ( XMLTools::XMLElement* node, const std::wstring & elementName, unsigned char elementValue, bool unique );
void appendShading ( XMLTools::XMLElement* parent, const ShadingDescriptor& desc );
void appendDxaElement ( XMLTools::XMLElement* node, const std::wstring & elementName, const std::wstring & elementValue, bool unique );
void addOrSetBorder ( XMLTools::XMLElement* pBdr, const XMLTools::XMLElement* border );
void appendBorderAttributes ( BorderCode* brc, XMLTools::XMLElement* border );
std::wstring getBorderType ( unsigned char type );
std::wstring getShadingPattern ( const ShadingDescriptor& shd );
protected:
XMLTools::CStringXmlWriter* m_pXmlWriter;
......
......@@ -167,7 +167,7 @@ namespace DocFileFormat
const std::wstring & get_section_type();
private:
void AppendRef (XMLTools::XMLElement* pBaseNode, const wchar_t* element, const wchar_t* refType, const wchar_t* refId);
void AppendRef (XMLTools::XMLElement* pBaseNode, const std::wstring& element, const std::wstring& refType, const std::wstring& refId);
bool WriteSectionStory (CharacterRange* pRange, const std::wstring& StoryType, const std::wstring& Story);
......
......@@ -56,11 +56,11 @@ namespace DocFileFormat
//zoom
m_oXmlWriter.WriteNodeBegin ( L"w:zoom", TRUE );
m_oXmlWriter.WriteAttribute ( L"w:percent", FormatUtils::IntToWideString( dop->wScaleSaved ).c_str() );
m_oXmlWriter.WriteAttribute ( L"w:percent", FormatUtils::IntToWideString( dop->wScaleSaved ) );
if ( dop->zkSaved != 0 )
{
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::MapValueToWideString( dop->zkSaved, &ZoomTypeMap[0][0], 3, 9 ).c_str() );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::MapValueToWideString( dop->zkSaved, &ZoomTypeMap[0][0], 3, 9 ) );
}
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
......@@ -104,31 +104,31 @@ namespace DocFileFormat
if ( proofState.GetAttributeCount() > 0 )
{
m_oXmlWriter.WriteString( proofState.GetXMLString().c_str() );
m_oXmlWriter.WriteString( proofState.GetXMLString() );
}
//stylePaneFormatFilter
if ( dop->grfFmtFilter != 0 )
{
m_oXmlWriter.WriteNodeBegin( L"w:stylePaneFormatFilter", TRUE );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::IntToFormattedWideString( dop->grfFmtFilter, L"%04x" ).c_str() );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::IntToFormattedWideString( dop->grfFmtFilter, L"%04x" ) );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
//default tab stop
m_oXmlWriter.WriteNodeBegin( L"w:defaultTabStop", TRUE );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::IntToWideString( dop->dxaTab ).c_str() );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::IntToWideString( dop->dxaTab ) );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
//drawing grid
if( dop->dogrid != NULL )
{
m_oXmlWriter.WriteNodeBegin( L"w:displayHorizontalDrawingGridEvery", TRUE );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::IntToWideString( dop->dogrid->dxGridDisplay ).c_str() );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::IntToWideString( dop->dogrid->dxGridDisplay ) );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:displayVerticalDrawingGridEvery", TRUE );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::IntToWideString( dop->dogrid->dyGridDisplay ).c_str() );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::IntToWideString( dop->dogrid->dyGridDisplay ) );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
if ( dop->dogrid->fFollowMargins == false )
......@@ -153,22 +153,22 @@ namespace DocFileFormat
if ( dop->nFtn != 0 )
{
appendValueAttribute( &footnotePr, L"w:numStart", FormatUtils::IntToWideString( dop->nFtn ).c_str() );
appendValueAttribute( &footnotePr, L"w:numStart", FormatUtils::IntToWideString( dop->nFtn ) );
}
if ( dop->rncFtn != 0 )
{
appendValueAttribute( &footnotePr, L"w:numRestart", FormatUtils::IntToWideString( dop->rncFtn ).c_str() );
appendValueAttribute( &footnotePr, L"w:numRestart", FormatUtils::IntToWideString( dop->rncFtn ) );
}
if ( dop->Fpc != 0 )
{
appendValueAttribute( &footnotePr, L"w:pos", FormatUtils::MapValueToWideString( dop->Fpc, &FootnotePositionMap[0][0], 4, 12 ).c_str() );
appendValueAttribute( &footnotePr, L"w:pos", FormatUtils::MapValueToWideString( dop->Fpc, &FootnotePositionMap[0][0], 4, 12 ) );
}
if ( footnotePr.GetAttributeCount() > 0 )
{
m_oXmlWriter.WriteString( footnotePr.GetXMLString().c_str() );
m_oXmlWriter.WriteString( footnotePr.GetXMLString() );
}
......
......@@ -86,7 +86,7 @@ namespace DocFileFormat
{
m_pXmlWriter->WriteNodeBegin( _T( "w:style" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:type" ), FormatUtils::MapValueToWideString( (*iter)->stk, &StyleKindMap[0][0], 5, 10 ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:type" ), FormatUtils::MapValueToWideString( (*iter)->stk, &StyleKindMap[0][0], 5, 10 ));
//!!!TODO: There is NO default styles in DOC file. So, we can't choose one of them!!!
/*if ( ( (*iter)->sti != Null ) && ( (*iter)->sti != User ) )
......@@ -95,19 +95,19 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( _T( "w:default" ), _T( "1" ) );
}*/
m_pXmlWriter->WriteAttribute( _T( "w:styleId" ), FormatUtils::XmlEncode(MakeStyleId( *iter )).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:styleId" ), FormatUtils::XmlEncode(MakeStyleId( *iter )));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
// <w:name val="" />
m_pXmlWriter->WriteNodeBegin( _T( "w:name" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(getStyleName( *iter ), true ).c_str());
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(getStyleName( *iter ), true ));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
// <w:basedOn val="" />
if ( ( (*iter)->istdBase != 4095 ) && ( (*iter)->istdBase < sheet->Styles->size() ) )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:basedOn" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(MakeStyleId( sheet->Styles->at( (*iter)->istdBase ) )).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(MakeStyleId( sheet->Styles->at( (*iter)->istdBase ) )));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
}
......@@ -115,7 +115,7 @@ namespace DocFileFormat
if ( (*iter)->istdNext < sheet->Styles->size() )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:next" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(MakeStyleId( sheet->Styles->at( (*iter)->istdNext ) )).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(MakeStyleId( sheet->Styles->at( (*iter)->istdNext ) )));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
}
......@@ -123,7 +123,7 @@ namespace DocFileFormat
if ( (*iter)->istdLink < sheet->Styles->size() )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:link" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(MakeStyleId( sheet->Styles->at( (*iter)->istdLink ) )).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(MakeStyleId( sheet->Styles->at( (*iter)->istdLink ) )));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
}
......@@ -242,19 +242,19 @@ namespace DocFileFormat
FontFamilyName* ffnAscii = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[0] ) );
if (ffnAscii)
m_pXmlWriter->WriteAttribute( _T( "w:ascii" ), FormatUtils::XmlEncode(ffnAscii->xszFtn).c_str() );
m_pXmlWriter->WriteAttribute( _T( "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( _T( "w:eastAsia" ), FormatUtils::XmlEncode(ffnAsia->xszFtn).c_str() );
m_pXmlWriter->WriteAttribute( _T( "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( _T( "w:hAnsi" ), FormatUtils::XmlEncode(ffnAnsi->xszFtn).c_str() );
m_pXmlWriter->WriteAttribute( _T( "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( _T( "w:cs" ), FormatUtils::XmlEncode(ffnComplex->xszFtn).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:cs" ), FormatUtils::XmlEncode(ffnComplex->xszFtn, true));
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:rFonts" ) );
......@@ -263,7 +263,7 @@ namespace DocFileFormat
std::wstring langcode = LanguageIdMapping::getLanguageCode( &langid );
m_pXmlWriter->WriteNodeBegin( _T( "w:lang" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), langcode.c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), langcode);
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:lang" ) );
......
......@@ -89,7 +89,7 @@ namespace DocFileFormat
_tGrid = tdef.rgdxaCenter;
_tcDef = tdef.rgTc80[(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1)]; // NOTE: fix for crash
appendValueElement( _tcPr, L"textDirection", FormatUtils::MapValueToWideString( _tcDef.textFlow, &Global::TextFlowMap[0][0], 6, 6 ).c_str(), false );
appendValueElement( _tcPr, L"textDirection", FormatUtils::MapValueToWideString( _tcDef.textFlow, &Global::TextFlowMap[0][0], 6, 6 ), false );
if ( _tcDef.vertMerge == Global::fvmMerge )
{
......@@ -100,7 +100,7 @@ namespace DocFileFormat
appendValueElement( _tcPr, L"vMerge", L"restart", false );
}
appendValueElement( _tcPr, L"vAlign", FormatUtils::MapValueToWideString( _tcDef.vertAlign, &Global::VerticalAlignMap[0][0], 3, 7 ).c_str(), false );
appendValueElement( _tcPr, L"vAlign", FormatUtils::MapValueToWideString( _tcDef.vertAlign, &Global::VerticalAlignMap[0][0], 3, 7 ), false );
if ( _tcDef.fFitText )
{
......@@ -145,22 +145,22 @@ namespace DocFileFormat
{
if ( FormatUtils::GetBitFromInt( iter->Arguments[2], 0 ) == true )
{
appendDxaElement( _tcMar, L"top", FormatUtils::IntToWideString( wMargin ).c_str(), true );
appendDxaElement( _tcMar, L"top", FormatUtils::IntToWideString( wMargin ), true );
}
if ( FormatUtils::GetBitFromInt( iter->Arguments[2], 1 ) == true )
{
appendDxaElement( _tcMar, L"left", FormatUtils::IntToWideString( wMargin ).c_str(), true );
appendDxaElement( _tcMar, L"left", FormatUtils::IntToWideString( wMargin ), true );
}
if ( FormatUtils::GetBitFromInt( iter->Arguments[2], 2 ) == true )
{
appendDxaElement( _tcMar, L"bottom", FormatUtils::IntToWideString( wMargin ).c_str(), true );
appendDxaElement( _tcMar, L"bottom", FormatUtils::IntToWideString( wMargin ), true );
}
if ( FormatUtils::GetBitFromInt( iter->Arguments[2], 3 ) == true )
{
appendDxaElement( _tcMar, L"right", FormatUtils::IntToWideString( wMargin ).c_str(), true );
appendDxaElement( _tcMar, L"right", FormatUtils::IntToWideString( wMargin ), true );
}
}
}
......@@ -210,7 +210,7 @@ namespace DocFileFormat
if ((_cellIndex >= first) && (_cellIndex < lim))
{
appendValueElement(_tcPr, L"vAlign", FormatUtils::MapValueToWideString( (VerticalCellAlignment)iter->Arguments[2], &VerticalCellAlignmentMap[0][0], 3, 7 ).c_str(), true );
appendValueElement(_tcPr, L"vAlign", FormatUtils::MapValueToWideString( (VerticalCellAlignment)iter->Arguments[2], &VerticalCellAlignmentMap[0][0], 3, 7 ), true );
}
}
break;
......@@ -222,7 +222,7 @@ namespace DocFileFormat
if ( ( _cellIndex >= first ) && ( _cellIndex < lim ) )
{
appendValueElement( _tcPr, L"tcFitText", FormatUtils::IntToWideString( iter->Arguments[2] ).c_str(), true );
appendValueElement( _tcPr, L"tcFitText", FormatUtils::IntToWideString( iter->Arguments[2] ), true );
}
}
break;
......@@ -299,7 +299,7 @@ namespace DocFileFormat
}
}
appendValueElement( _tcPr, L"gridSpan", FormatUtils::IntToWideString( _gridSpan ).c_str(), true );
appendValueElement( _tcPr, L"gridSpan", FormatUtils::IntToWideString( _gridSpan ), true );
}
//append margins
......@@ -344,7 +344,7 @@ namespace DocFileFormat
//write Properties
if ((_tcPr->GetChildCount() > 0) || (_tcPr->GetAttributeCount() > 0))
m_pXmlWriter->WriteString(_tcPr->GetXMLString().c_str());
m_pXmlWriter->WriteString(_tcPr->GetXMLString());
}
void TableCellPropertiesMapping::apppendCellShading (unsigned char* sprmArg, int size, int cellIndex)
......
......@@ -111,8 +111,8 @@ namespace DocFileFormat
XMLTools::XMLElement tblW( _T( "w:tblW" ) );
XMLTools::XMLAttribute w( _T( "w:w" ), FormatUtils::IntToWideString( width ).c_str() );
XMLTools::XMLAttribute type( _T( "w:type" ), FormatUtils::MapValueToWideString( fts, &WidthType[0][0], 4, 5 ).c_str() );
XMLTools::XMLAttribute w( _T( "w:w" ), FormatUtils::IntToWideString( width ) );
XMLTools::XMLAttribute type( _T( "w:type" ), FormatUtils::MapValueToWideString( fts, &WidthType[0][0], 4, 5 ) );
tblW.AppendAttribute( type );
tblW.AppendAttribute( w );
......@@ -126,7 +126,7 @@ namespace DocFileFormat
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 ), true );
}
break;
......@@ -150,7 +150,7 @@ namespace DocFileFormat
if( id != std::wstring( _T( "TableNormal" )) && !id.empty() )
{
appendValueElement( _tblPr, _T( "tblStyle" ), id.c_str(), true );
appendValueElement( _tblPr, _T( "tblStyle" ), id, true );
}
}
}
......@@ -168,7 +168,7 @@ namespace DocFileFormat
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" ) ), true );
}
break;
......@@ -194,7 +194,7 @@ namespace DocFileFormat
if ( FormatUtils::BitmaskToBool( (int)grfbrc, 0x01 ) )
{
appendDxaElement( &tblCellMar, _T( "top" ), strValue.c_str(), true );
appendDxaElement( &tblCellMar, _T( "top" ), strValue, true );
}
if ( FormatUtils::BitmaskToBool( (int)grfbrc, 0x02 ) )
......@@ -204,7 +204,7 @@ namespace DocFileFormat
if ( FormatUtils::BitmaskToBool( (int)grfbrc, 0x04 ) )
{
appendDxaElement( &tblCellMar, _T( "bottom" ), strValue.c_str(), true );
appendDxaElement( &tblCellMar, _T( "bottom" ), strValue, true );
}
if ( FormatUtils::BitmaskToBool( (int)grfbrc, 0x08 ) )
......@@ -238,7 +238,7 @@ namespace DocFileFormat
tblOverlapVal = std::wstring( _T( "never" ) );
}
appendValueElement( _tblPr, _T( "tblOverlap" ), tblOverlapVal.c_str(), true );
appendValueElement( _tblPr, _T( "tblOverlap" ), tblOverlapVal, true );
}
break;
......@@ -332,11 +332,11 @@ namespace DocFileFormat
{
unsigned char flag = ( iter->Arguments[0] & 0x30 ) >> 4;
appendValueAttribute( &tblpPr, _T( "w:vertAnchor" ), FormatUtils::MapValueToWideString( flag, &Global::VerticalPositionCode[0][0], 4, 7 ).c_str() );
appendValueAttribute( &tblpPr, _T( "w:vertAnchor" ), FormatUtils::MapValueToWideString( flag, &Global::VerticalPositionCode[0][0], 4, 7 ) );
flag = ( iter->Arguments[0] & 0xC0 ) >> 6;
appendValueAttribute( &tblpPr, _T( "w:horzAnchor" ), FormatUtils::MapValueToWideString( flag, &Global::HorizontalPositionCode[0][0], 4, 7 ).c_str() );
appendValueAttribute( &tblpPr, _T( "w:horzAnchor" ), FormatUtils::MapValueToWideString( flag, &Global::HorizontalPositionCode[0][0], 4, 7 ) );
}
break;
......@@ -383,7 +383,7 @@ namespace DocFileFormat
{
XMLTools::XMLElement tblInd( _T( "w:tblInd" ) );
XMLTools::XMLAttribute tblIndW( _T( "w:w" ),FormatUtils::IntToWideString( tblIndent ).c_str() );
XMLTools::XMLAttribute tblIndW( _T( "w:w" ),FormatUtils::IntToWideString( tblIndent ) );
tblInd.AppendAttribute( tblIndW );
XMLTools::XMLAttribute tblIndType( _T( "w:type" ), _T( "dxa" ) );
......@@ -453,20 +453,20 @@ namespace DocFileFormat
//append margins
if ( ( marginLeft == 0 ) && ( gabHalf != 0 ) )
{
appendDxaElement( &tblCellMar, _T( "left" ), FormatUtils::IntToWideString( gabHalf ).c_str(), true );
appendDxaElement( &tblCellMar, _T( "left" ), FormatUtils::IntToWideString( gabHalf ), true );
}
else
{
appendDxaElement( &tblCellMar, _T( "left" ), FormatUtils::IntToWideString( marginLeft ).c_str(), true );
appendDxaElement( &tblCellMar, _T( "left" ), FormatUtils::IntToWideString( marginLeft ), true );
}
if ( ( marginRight == 0 ) && ( gabHalf != 0 ) )
{
appendDxaElement( &tblCellMar, _T( "right" ), FormatUtils::IntToWideString( gabHalf ).c_str(), true );
appendDxaElement( &tblCellMar, _T( "right" ), FormatUtils::IntToWideString( gabHalf ), true );
}
else
{
appendDxaElement( &tblCellMar, _T( "right" ), FormatUtils::IntToWideString( marginRight ).c_str(), true );
appendDxaElement( &tblCellMar, _T( "right" ), FormatUtils::IntToWideString( marginRight ), true );
}
_tblPr->AppendChild( tblCellMar );
......@@ -474,7 +474,7 @@ namespace DocFileFormat
//write Properties
if ( ( _tblPr->GetChildCount() > 0 ) || ( _tblPr->GetAttributeCount() > 0 ) )
{
m_pXmlWriter->WriteString( _tblPr->GetXMLString().c_str() );
m_pXmlWriter->WriteString( _tblPr->GetXMLString() );
}
//append the grid
......@@ -500,12 +500,12 @@ namespace DocFileFormat
for ( unsigned int i = 0; i < _grid->size(); i++ )
{
XMLTools::XMLElement gridCol( _T( "w:gridCol" ) );
XMLTools::XMLAttribute gridColW( _T( "w:w" ), FormatUtils::IntToWideString( _grid->at( i ) ).c_str() );
XMLTools::XMLAttribute gridColW( _T( "w:w" ), FormatUtils::IntToWideString( _grid->at( i ) ) );
gridCol.AppendAttribute( gridColW );
_tblGrid->AppendChild( gridCol );
}
}
m_pXmlWriter->WriteString( _tblGrid->GetXMLString().c_str() );
m_pXmlWriter->WriteString( _tblGrid->GetXMLString() );
}
}
......@@ -90,7 +90,7 @@ namespace DocFileFormat
case sprmTWidthAfter:
{ //width after
XMLTools::XMLElement wAfter( L"w:wAfter" );
XMLTools::XMLAttribute wAfterValue( L"w:w", FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize ) ).c_str() );
XMLTools::XMLAttribute wAfterValue( L"w:w", FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize ) ) );
wAfter.AppendAttribute( wAfterValue );
XMLTools::XMLAttribute wAfterType( L"w:type", L"dxa" );
......@@ -106,7 +106,7 @@ namespace DocFileFormat
if ( before != 0 )
{
XMLTools::XMLElement wBefore( L"w:wBefore" );
XMLTools::XMLAttribute wBeforeValue( L"w:w", FormatUtils::IntToWideString( before ).c_str() );
XMLTools::XMLAttribute wBeforeValue( L"w:w", FormatUtils::IntToWideString( before ) );
wBefore.AppendAttribute( wBeforeValue );
XMLTools::XMLAttribute wBeforeType( L"w:type", L"dxa" );
......@@ -128,7 +128,7 @@ namespace DocFileFormat
if ( rH > 0 )
{
rowHeightRule.SetValue( L"atLeast" );
rowHeightVal.SetValue( FormatUtils::IntToWideString( rH ).c_str() );
rowHeightVal.SetValue( FormatUtils::IntToWideString( rH ) );
rowHeight.AppendAttribute( rowHeightVal );
}
else if( rH == 0 )
......@@ -139,7 +139,7 @@ namespace DocFileFormat
{
rowHeightRule.SetValue( L"exact" );
rH *= -1;
rowHeightVal.SetValue( FormatUtils::IntToWideString( rH ).c_str() );
rowHeightVal.SetValue( FormatUtils::IntToWideString( rH ) );
rowHeight.AppendAttribute( rowHeightVal );
}
......@@ -158,7 +158,7 @@ namespace DocFileFormat
//div id
case sprmTIpgp:
{
appendValueElement( _trPr, L"divId", FormatUtils::IntToWideString( FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
appendValueElement( _trPr, L"divId", FormatUtils::IntToWideString( FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
//borders 80 exceptions
......@@ -260,7 +260,7 @@ namespace DocFileFormat
//write Properties
if ( ( _trPr->GetChildCount() > 0 ) || ( _trPr->GetAttributeCount() > 0 ) )
{
m_pXmlWriter->WriteString( _trPr->GetXMLString().c_str() );
m_pXmlWriter->WriteString( _trPr->GetXMLString() );
}
}
}
......@@ -58,21 +58,21 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeBegin( L"v:shapetype", true );
// ID
m_pXmlWriter->WriteAttribute( L"id", GenerateTypeId( pShape ).c_str() );
m_pXmlWriter->WriteAttribute( L"id", GenerateTypeId( pShape ));
// Coordinate System
m_pXmlWriter->WriteAttribute( L"coordsize", L"21600,21600");
// Shape Code
m_pXmlWriter->WriteAttribute( L"o:spt", FormatUtils::IntToWideString( pShape->GetTypeCode() ).c_str() );
m_pXmlWriter->WriteAttribute( L"o:spt", FormatUtils::IntToWideString( pShape->GetTypeCode() ));
// Adj
if (pShape->AdjustmentValues.length())
m_pXmlWriter->WriteAttribute( L"adj", pShape->AdjustmentValues.c_str() );
m_pXmlWriter->WriteAttribute( L"adj", pShape->AdjustmentValues);
// Path
if (!pShape->Path.empty())
m_pXmlWriter->WriteAttribute( L"path", pShape->Path.c_str() );
m_pXmlWriter->WriteAttribute( L"path", pShape->Path);
else if (_isInlineShape)
m_pXmlWriter->WriteAttribute( L"path", L"m@4@5l@4@11@9@11@9@5xe");
......@@ -99,12 +99,12 @@ namespace DocFileFormat
if (!pShape->Textpath.empty())
{
m_pXmlWriter->WriteNodeBegin( L"v:textpath", true );
m_pXmlWriter->WriteString( pShape->Textpath.c_str() );
m_pXmlWriter->WriteString( pShape->Textpath );
m_pXmlWriter->WriteNodeEnd( L"", true );
}
// Stroke
m_pXmlWriter->WriteNodeBegin( L"v:stroke", true );
m_pXmlWriter->WriteAttribute( L"joinstyle", FormatUtils::MapValueToWideString( pShape->Joins, &JoinStyleMap[0][0], 3, 6 ).c_str() );
m_pXmlWriter->WriteAttribute( L"joinstyle", FormatUtils::MapValueToWideString( pShape->Joins, &JoinStyleMap[0][0], 3, 6 ));
m_pXmlWriter->WriteNodeEnd( L"", true );
// Formulas
......@@ -115,7 +115,7 @@ namespace DocFileFormat
for ( std::list<std::wstring>::iterator iter = pShape->Formulas.begin(); iter != pShape->Formulas.end(); iter++ )
{
m_pXmlWriter->WriteNodeBegin( L"v:f", true );
m_pXmlWriter->WriteAttribute( L"eqn", iter->c_str() );
m_pXmlWriter->WriteAttribute( L"eqn", *iter );
m_pXmlWriter->WriteNodeEnd( L"", true );
}
......@@ -147,19 +147,19 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( L"gradientshapeok", L"t" );
if (pShape->Limo.length())
m_pXmlWriter->WriteAttribute( L"limo", pShape->Limo.c_str() );
m_pXmlWriter->WriteAttribute( L"limo", pShape->Limo );
if (pShape->ConnectorLocations.length())
{
m_pXmlWriter->WriteAttribute( L"o:connecttype", L"custom");
m_pXmlWriter->WriteAttribute( L"o:connectlocs", pShape->ConnectorLocations.c_str() );
m_pXmlWriter->WriteAttribute( L"o:connectlocs", pShape->ConnectorLocations);
}
if (pShape->TextBoxRectangle.length())
m_pXmlWriter->WriteAttribute( L"textboxrect", pShape->TextBoxRectangle.c_str() );
m_pXmlWriter->WriteAttribute( L"textboxrect", pShape->TextBoxRectangle);
if (pShape->ConnectorAngles.length())
m_pXmlWriter->WriteAttribute( L"o:connectangles", pShape->ConnectorAngles.c_str() );
m_pXmlWriter->WriteAttribute( L"o:connectangles", pShape->ConnectorAngles);
}
WordArtTextType* wordArt = dynamic_cast<WordArtTextType*>(pShape);
if (wordArt)
......@@ -177,7 +177,7 @@ namespace DocFileFormat
if ( _lock->GetAttributeCount() > 1 )
{
m_pXmlWriter->WriteString( _lock->GetXMLString().c_str() );
m_pXmlWriter->WriteString( _lock->GetXMLString() );
}
// Handles
......@@ -190,22 +190,22 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeBegin( L"v:h", true );
if (iter->position.length())
m_pXmlWriter->WriteAttribute( L"position", iter->position.c_str() );
m_pXmlWriter->WriteAttribute( L"position", iter->position);
if (iter->switchHandle.length())
m_pXmlWriter->WriteAttribute( L"switch", iter->switchHandle.c_str() );
m_pXmlWriter->WriteAttribute( L"switch", iter->switchHandle);
if (iter->xrange.length())
m_pXmlWriter->WriteAttribute( L"xrange", iter->xrange.c_str() );
m_pXmlWriter->WriteAttribute( L"xrange", iter->xrange);
if (iter->yrange.length())
m_pXmlWriter->WriteAttribute( L"yrange", iter->yrange.c_str() );
m_pXmlWriter->WriteAttribute( L"yrange", iter->yrange);
if (iter->polar.length())
m_pXmlWriter->WriteAttribute( L"polar", iter->polar.c_str() );
m_pXmlWriter->WriteAttribute( L"polar", iter->polar);
if (iter->radiusrange.length())
m_pXmlWriter->WriteAttribute( L"radiusrange", iter->radiusrange.c_str() );
m_pXmlWriter->WriteAttribute( L"radiusrange", iter->radiusrange );
m_pXmlWriter->WriteNodeEnd( L"", true );
}
......
......@@ -183,7 +183,7 @@ namespace DocFileFormat
void WordprocessingDocument::SaveDocument()
{
std::wstring pathWord = m_strOutputPath + FILE_SEPARATOR_STR + _T( "word" ) ;
//OOX::CPath pathWord = CString(m_strOutputPath.c_str()) + FILE_SEPARATOR_STR + _T( "word" );
//OOX::CPath pathWord = CString(m_strOutputPath) + FILE_SEPARATOR_STR + _T( "word" );
//FileSystem::Directory::CreateDirectory( pathWord.GetPath() );
NSDirectory::CreateDirectory( pathWord );
......
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