/* * (c) Copyright Ascensio System SIA 2010-2014 * * 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 * */ #pragma once #include "Common.h" namespace Writers { class DocumentRelsWriter { CStringWriter m_oWriter; CString m_sDir; int m_nRid; CAtlArray m_aRels; bool bDocumentRels; public: DocumentRelsWriter(CString sDir, bool bDocumentRels, int nRid = 1):m_sDir(sDir),bDocumentRels(bDocumentRels) { m_nRid = nRid; } void Write(CString sFileName) { CString s_dr_Start; CString s_dr_End; if(true == bDocumentRels) { s_dr_Start = _T(""); s_dr_End = _T(""); } else { s_dr_Start = _T(""); s_dr_End = _T(""); } if(m_nRid > 1) { m_oWriter.WriteString(s_dr_Start); for(int i = 0, length = m_aRels.GetCount(); i < length; ++i) { m_oWriter.WriteString(m_aRels[i]); } m_oWriter.WriteString(s_dr_End); CFile oFile; oFile.CreateFile(m_sDir + _T("\\word\\_rels\\") + sFileName); oFile.WriteStringUTF8(m_oWriter.GetData()); oFile.CloseFile(); } } CString AddRels(CString sType, CString sTarget, bool bExternal = false) { CorrectString(sType); CorrectString(sTarget); CString srId;srId.Format(_T("rId%d"), m_nRid); CString sRels; if(bExternal) sRels.Format(_T(""), srId, sType, sTarget); else sRels.Format(_T(""), srId, sType, sTarget); m_nRid++; m_aRels.Add(sRels); return srId; } }; }