/* * (c) Copyright Ascensio System SIA 2010-2016 * * 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) * 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 * that Ascensio System SIA expressly excludes the warranty of non-infringement * of any third-party rights. * * This program is distributed WITHOUT ANY WARRANTY; without even the implied * 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 * * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, * EU, LV-1021. * * The interactive user interfaces in modified source and object code versions * of the Program must display Appropriate Legal Notices, as required under * Section 5 of the GNU AGPL version 3. * * 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 * grant you any rights under trademark law for use of our trademarks. * * All the Product's GUI elements, including illustrations and icon sets, as * well as technical writing content are licensed under the terms of the * Creative Commons Attribution-ShareAlike 4.0 International. See the License * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ #include "OOXDocumentWriter.h" //#include "OOXContentTypesWriter.h" #include "OOXRelsWriter.h" #include "OOXDocumentWriter.h" #include "OOXNumberingWriter.h" #include "OOXFontTableWriter.h" #include "OOXStylesWriter.h" #include "OOXSettingsWriter.h" #include "OOXThemeWriter.h" #include "OOXFootnoteWriter.h" #include "OOXStylesWriter.h" //#include "../../../../ASCOfficeDocxFile2/BinReader/ContentTypesWriter.h" CString OOXDocumentWriter::CreateXmlStart() { //пишем Footnotes RenderParameter oNewParam; oNewParam.poDocument = &m_oDocument; oNewParam.poWriter = &m_oWriter; oNewParam.poRels = &m_oWriter.m_oDocRels; oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN; //пишем document.xml CString sResult = _T("\n"); sResult.Append( _T("") ); sResult.Append( _T("") ); return sResult; } CString OOXDocumentWriter::CreateXmlEnd( ) { CString sResult ; //пишем все кроме document.xml RenderParameter oNewParam; oNewParam.poDocument = &m_oDocument; oNewParam.poWriter = &m_oWriter; oNewParam.poRels = &m_oWriter.m_oDocRels; oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN; OOXEndnoteWriter* poEndnoteWriter = static_cast( m_oWriter.m_poEndnoteWriter ); OOXFootnoteWriter* poFootnoteWriter = static_cast( m_oWriter.m_poFootnoteWriter ); if( NULL != m_oDocument.m_oFootnoteCon ) { oNewParam.poRels = poFootnoteWriter->m_oRelsWriter.get(); oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN; poFootnoteWriter->AddFootnoteBegin( _T("continuationSeparator"), 1, m_oDocument.m_oFootnoteCon->RenderToOOX( oNewParam ) ); } if( NULL != m_oDocument.m_oFootnoteSep ) { oNewParam.poRels = poFootnoteWriter->m_oRelsWriter.get(); oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN; poFootnoteWriter->AddFootnoteBegin( _T("separator"), 0, m_oDocument.m_oFootnoteSep->RenderToOOX(oNewParam) ); } if( NULL != m_oDocument.m_oEndnoteCon ) { oNewParam.poRels = poEndnoteWriter->m_oRelsWriter.get(); oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN; poEndnoteWriter->AddEndnoteBegin( _T("continuationSeparator"), 1, m_oDocument.m_oEndnoteSep->RenderToOOX(oNewParam) ); } if( NULL != m_oDocument.m_oEndnoteSep ) { oNewParam.poRels = poEndnoteWriter->m_oRelsWriter.get(); oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN; poEndnoteWriter->AddEndnoteBegin( _T("separator"), 0, m_oDocument.m_oEndnoteSep->RenderToOOX(oNewParam) ); } //fontTable.xml OOXFontTableWriter* poFontTableWriter = static_cast( m_oWriter.m_poFontTableWriter ); oNewParam.poRels = poFontTableWriter->m_oRelsWriter.get(); oNewParam.nType = RENDER_TO_OOX_PARAM_FONTTABLE; poFontTableWriter->AddContent( m_oDocument.m_oFontTable.RenderToOOX( oNewParam ) ); //settings.xml OOXSettingsWriter* poSettingsWriter = static_cast( m_oWriter.m_poSettingsWriter ); oNewParam.poRels = poSettingsWriter->m_oRelsWriter.get(); oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN; poSettingsWriter->AddContent( m_oDocument.m_oProperty.RenderToOOX(oNewParam) ); //poSettingsWriter->AddContent( m_oDocument.m_oColorSchemeMapping.RenderToOOX(oNewParam) ); poSettingsWriter->AddContent( m_oDocument.m_oMathProp.RenderToOOX(oNewParam) ); //numbering.xml OOXNumberingWriter* poNumberingWriter = static_cast( m_oWriter.m_poNumberingWriter ); oNewParam.poRels = poNumberingWriter->m_oRelsWriter.get(); oNewParam.nType = RENDER_TO_OOX_PARAM_NUMBERING; poNumberingWriter->AddNumbering( m_oDocument.m_oListTabel.RenderToOOX(oNewParam) ); poNumberingWriter->AddNumbering( m_oDocument.m_oListOverrideTabel.RenderToOOX(oNewParam) ); //style.xml OOXStylesWriter* poStylesWriter = static_cast( m_oWriter.m_poStylesWriter ); oNewParam.poRels = poNumberingWriter->m_oRelsWriter.get(); oNewParam.nType = RENDER_TO_OOX_PARAM_STYLES; CString sStyles; CString sTempParaDef = m_oDocument.m_oDefaultParagraphProp.RenderToOOX(oNewParam); CString sTempCharDef = m_oDocument.m_oDefaultCharProp.RenderToOOX(oNewParam); if( false == sTempParaDef.IsEmpty() || false == sTempCharDef.IsEmpty() ) { sStyles += _T(""); if( false == sTempCharDef.IsEmpty() ) { sStyles += _T(""); sStyles += sTempCharDef ; sStyles += _T(""); } if( false == sTempParaDef.IsEmpty() ) { sStyles += _T(""); sStyles += sTempParaDef; sStyles += _T(""); } sStyles.Append(_T("")); } sStyles += m_oDocument.m_oStyleTable.RenderToOOX(oNewParam); poStylesWriter->AddContent(sStyles); //core.xml oNewParam.poRels = NULL; oNewParam.nType = RENDER_TO_OOX_PARAM_CORE; oNewParam.poWriter = m_oWriter.m_poDocPropsCore; m_oDocument.m_oInformation.RenderToOOX(oNewParam); //app.xml oNewParam.poRels = NULL; oNewParam.nType = RENDER_TO_OOX_PARAM_APP; oNewParam.poWriter = m_oWriter.m_poDocPropsApp; m_oDocument.m_oInformation.RenderToOOX(oNewParam); //пишем финальные свойства секции oNewParam.poDocument = &m_oDocument; oNewParam.poWriter = &m_oWriter; oNewParam.poRels = &m_oWriter.m_oDocRels; oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN; sResult.Append( m_oDocument[0]->m_oProperty.RenderToOOX(oNewParam) ); sResult.Append( _T("") ); sResult.Append( _T("") ); return sResult; }