mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
RtfFile refact
OOXml/Writer folder
This commit is contained in:
208
RtfFile/OOXml/Writer/OOXCommentsWriter.cpp
Normal file
208
RtfFile/OOXml/Writer/OOXCommentsWriter.cpp
Normal file
@ -0,0 +1,208 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* 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 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* 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 "OOXCommentsWriter.h"
|
||||
|
||||
OOXCommentsWriter::OOXCommentsWriter( OOXWriter& oWriter, RtfDocument& oDocument ) : m_oWriter(oWriter), m_oDocument(oDocument)
|
||||
{
|
||||
m_oRelsWriter = OOXRelsWriterPtr( new OOXRelsWriter( _T("comments.xml"), oDocument ) );
|
||||
oWriter.m_oCustomRelsWriter.push_back( m_oRelsWriter );
|
||||
}
|
||||
void OOXCommentsWriter::SetCommentEnd(const std::wstring & ref) //for author
|
||||
{
|
||||
m_sCurrent_ref = ref;
|
||||
}
|
||||
void OOXCommentsWriter::AddComment( const std::wstring & ref, int nID)
|
||||
{
|
||||
_comment comment(nID);
|
||||
m_mapComments.insert(std::make_pair(ref, comment));
|
||||
}
|
||||
void OOXCommentsWriter::AddCommentID( const std::wstring & id)
|
||||
{
|
||||
std::map<std::wstring, _comment>::iterator pFind = m_mapComments.find(m_sCurrent_ref);
|
||||
|
||||
if (pFind != m_mapComments.end())
|
||||
{
|
||||
pFind->second.authorId = id;
|
||||
}
|
||||
}
|
||||
void OOXCommentsWriter::AddCommentAuthor( const std::wstring & author)
|
||||
{
|
||||
std::map<std::wstring, _comment>::iterator pFind = m_mapComments.find(m_sCurrent_ref);
|
||||
|
||||
if (pFind != m_mapComments.end())
|
||||
{
|
||||
pFind->second.author = author;
|
||||
}
|
||||
}
|
||||
void OOXCommentsWriter::AddCommentContent( const std::wstring & ref, const std::wstring & paraId, const std::wstring & content)
|
||||
{
|
||||
std::map<std::wstring, _comment>::iterator pFind = m_mapComments.find(ref);
|
||||
|
||||
if (pFind != m_mapComments.end())
|
||||
{
|
||||
pFind->second.content = content;
|
||||
pFind->second.paraId = paraId;
|
||||
|
||||
m_mapCommentsParent.insert(std::make_pair(pFind->second.nID, paraId));
|
||||
}
|
||||
}
|
||||
void OOXCommentsWriter::AddCommentParent( const std::wstring & ref, const std::wstring & parent)
|
||||
{
|
||||
std::map<std::wstring, _comment>::iterator pFind = m_mapComments.find(ref);
|
||||
|
||||
if (pFind != m_mapComments.end())
|
||||
{
|
||||
pFind->second.nParentID = boost::lexical_cast<int>(parent);
|
||||
}
|
||||
}
|
||||
void OOXCommentsWriter::AddCommentDate( const std::wstring & ref, const std::wstring & date)
|
||||
{
|
||||
std::map<std::wstring, _comment>::iterator pFind = m_mapComments.find(ref);
|
||||
|
||||
if (pFind != m_mapComments.end())
|
||||
{
|
||||
pFind->second.date = date;
|
||||
}
|
||||
}
|
||||
bool OOXCommentsWriter::Save( std::wstring sFolder )
|
||||
{
|
||||
if( m_mapComments.empty() ) return false;
|
||||
|
||||
NSFile::CFileBinary file;
|
||||
if (false == file.CreateFile(sFolder + FILE_SEPARATOR_STR + _T("comments.xml"))) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"), _T("comments.xml") );
|
||||
m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"), _T("/word/comments.xml") );
|
||||
|
||||
std::wstring sXml = CreateXml();
|
||||
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
|
||||
file.CloseFile();
|
||||
//-------------------------------------------------------------------------------------------------------------------------
|
||||
if (false == file.CreateFile(sFolder + FILE_SEPARATOR_STR + L"commentsExtended.xml")) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( L"http://schemas.microsoft.com/office/2011/relationships/commentsExtended", L"commentsExtended.xml" );
|
||||
m_oWriter.m_oContentTypes.AddContent( L"application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml", L"/word/commentsExtended.xml" );
|
||||
|
||||
sXml = CreateXmlExtended();
|
||||
|
||||
sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
|
||||
file.CloseFile();
|
||||
return true;
|
||||
}
|
||||
|
||||
std::wstring OOXCommentsWriter::CreateXml()
|
||||
{
|
||||
std::wstring sResult = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
|
||||
|
||||
sResult += L"<w:comments \
|
||||
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
|
||||
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
|
||||
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
|
||||
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
|
||||
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
|
||||
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
|
||||
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
|
||||
mc:Ignorable=\"w14 w15 wp14\">";
|
||||
|
||||
for (std::map<std::wstring, _comment>::iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
|
||||
{
|
||||
sResult += L"<w:comment w:id=\"" + std::to_wstring(it->second.nID) + L"\" w:author=\"" +
|
||||
it->second.author + L"\" w:date=\"" + it->second.date + L"\" w:initials=\"" + it->second.authorId + L"\">";
|
||||
sResult += it->second.content;
|
||||
|
||||
sResult += L"</w:comment>";
|
||||
//--------------------------------------------------------
|
||||
m_sCommentsExtended += L"<w15:commentEx w15:paraId=\"" + it->second.paraId + L"\"";
|
||||
if (it->second.nParentID != 0)
|
||||
{
|
||||
it->second.nParentID = it->second.nID + it->second.nParentID;
|
||||
|
||||
std::map<int, std::wstring>::iterator pFind = m_mapCommentsParent.find(it->second.nParentID);
|
||||
|
||||
if (pFind != m_mapCommentsParent.end())
|
||||
{
|
||||
m_sCommentsExtended += L" w15:paraIdParent=\"" + pFind->second + L"\"";
|
||||
}
|
||||
}
|
||||
m_sCommentsExtended += L" w15:done=\"0\"/>";
|
||||
|
||||
}
|
||||
sResult += L"</w:comments>";
|
||||
return sResult;
|
||||
}
|
||||
std::wstring OOXCommentsWriter::CreateXmlExtended()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult += L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
|
||||
|
||||
sResult += L"<w15:commentsEx \
|
||||
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" \
|
||||
xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
|
||||
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
|
||||
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
|
||||
xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" \
|
||||
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
|
||||
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
|
||||
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
|
||||
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
|
||||
mc:Ignorable=\"w14 w15 w16se wp14\">";
|
||||
sResult += m_sCommentsExtended;
|
||||
sResult += L"</w15:commentsEx>";
|
||||
return sResult;
|
||||
}
|
||||
@ -38,100 +38,19 @@ class OOXCommentsWriter
|
||||
public:
|
||||
OOXRelsWriterPtr m_oRelsWriter;
|
||||
|
||||
OOXCommentsWriter( OOXWriter& oWriter, RtfDocument& oDocument ) : m_oWriter(oWriter), m_oDocument(oDocument)
|
||||
{
|
||||
m_oRelsWriter = OOXRelsWriterPtr( new OOXRelsWriter( _T("comments.xml"), oDocument ) );
|
||||
oWriter.m_oCustomRelsWriter.push_back( m_oRelsWriter );
|
||||
}
|
||||
void SetCommentEnd(const std::wstring & ref) //for author
|
||||
{
|
||||
m_sCurrent_ref = ref;
|
||||
}
|
||||
void AddComment( const std::wstring & ref, int nID)
|
||||
{
|
||||
_comment comment(nID);
|
||||
m_mapComments.insert(std::make_pair(ref, comment));
|
||||
}
|
||||
void AddCommentID( const std::wstring & id)
|
||||
{
|
||||
std::map<std::wstring, _comment>::iterator pFind = m_mapComments.find(m_sCurrent_ref);
|
||||
OOXCommentsWriter( OOXWriter& oWriter, RtfDocument& oDocument );
|
||||
|
||||
if (pFind != m_mapComments.end())
|
||||
{
|
||||
pFind->second.authorId = id;
|
||||
}
|
||||
}
|
||||
void AddCommentAuthor( const std::wstring & author)
|
||||
{
|
||||
std::map<std::wstring, _comment>::iterator pFind = m_mapComments.find(m_sCurrent_ref);
|
||||
void SetCommentEnd(const std::wstring & ref); //for author
|
||||
|
||||
if (pFind != m_mapComments.end())
|
||||
{
|
||||
pFind->second.author = author;
|
||||
}
|
||||
}
|
||||
void AddCommentContent( const std::wstring & ref, const std::wstring & paraId, const std::wstring & content)
|
||||
{
|
||||
std::map<std::wstring, _comment>::iterator pFind = m_mapComments.find(ref);
|
||||
void AddComment( const std::wstring & ref, int nID);
|
||||
void AddCommentID( const std::wstring & id);
|
||||
void AddCommentAuthor( const std::wstring & author);
|
||||
void AddCommentContent( const std::wstring & ref, const std::wstring & paraId, const std::wstring & content);
|
||||
void AddCommentParent( const std::wstring & ref, const std::wstring & parent);
|
||||
void AddCommentDate( const std::wstring & ref, const std::wstring & date);
|
||||
|
||||
if (pFind != m_mapComments.end())
|
||||
{
|
||||
pFind->second.content = content;
|
||||
pFind->second.paraId = paraId;
|
||||
bool Save( std::wstring sFolder );
|
||||
|
||||
m_mapCommentsParent.insert(std::make_pair(pFind->second.nID, paraId));
|
||||
}
|
||||
}
|
||||
void AddCommentParent( const std::wstring & ref, const std::wstring & parent)
|
||||
{
|
||||
std::map<std::wstring, _comment>::iterator pFind = m_mapComments.find(ref);
|
||||
|
||||
if (pFind != m_mapComments.end())
|
||||
{
|
||||
pFind->second.nParentID = boost::lexical_cast<int>(parent);
|
||||
}
|
||||
}
|
||||
void AddCommentDate( const std::wstring & ref, const std::wstring & date)
|
||||
{
|
||||
std::map<std::wstring, _comment>::iterator pFind = m_mapComments.find(ref);
|
||||
|
||||
if (pFind != m_mapComments.end())
|
||||
{
|
||||
pFind->second.date = date;
|
||||
}
|
||||
}
|
||||
bool Save( std::wstring sFolder )
|
||||
{
|
||||
if( m_mapComments.empty() ) return false;
|
||||
|
||||
NSFile::CFileBinary file;
|
||||
if (false == file.CreateFile(sFolder + FILE_SEPARATOR_STR + _T("comments.xml"))) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"), _T("comments.xml") );
|
||||
m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"), _T("/word/comments.xml") );
|
||||
|
||||
std::wstring sXml = CreateXml();
|
||||
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
|
||||
file.CloseFile();
|
||||
//-------------------------------------------------------------------------------------------------------------------------
|
||||
if (false == file.CreateFile(sFolder + FILE_SEPARATOR_STR + L"commentsExtended.xml")) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( L"http://schemas.microsoft.com/office/2011/relationships/commentsExtended", L"commentsExtended.xml" );
|
||||
m_oWriter.m_oContentTypes.AddContent( L"application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml", L"/word/commentsExtended.xml" );
|
||||
|
||||
sXml = CreateXmlExtended();
|
||||
|
||||
sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
|
||||
file.CloseFile();
|
||||
return true;
|
||||
}
|
||||
struct _comment
|
||||
{
|
||||
_comment(int id) : nID(id) {}
|
||||
@ -145,6 +64,7 @@ public:
|
||||
|
||||
};
|
||||
std::map<std::wstring, _comment> m_mapComments;
|
||||
|
||||
private:
|
||||
RtfDocument& m_oDocument;
|
||||
OOXWriter& m_oWriter;
|
||||
@ -153,84 +73,6 @@ private:
|
||||
std::wstring m_sCommentsExtended;
|
||||
std::map<int, std::wstring> m_mapCommentsParent;
|
||||
|
||||
std::wstring CreateXml()
|
||||
{
|
||||
std::wstring sResult = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
|
||||
|
||||
sResult += L"<w:comments \
|
||||
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
|
||||
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
|
||||
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
|
||||
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
|
||||
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
|
||||
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
|
||||
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
|
||||
mc:Ignorable=\"w14 w15 wp14\">";
|
||||
|
||||
for (std::map<std::wstring, _comment>::iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
|
||||
{
|
||||
sResult += L"<w:comment w:id=\"" + std::to_wstring(it->second.nID) + L"\" w:author=\"" +
|
||||
it->second.author + L"\" w:date=\"" + it->second.date + L"\" w:initials=\"" + it->second.authorId + L"\">";
|
||||
sResult += it->second.content;
|
||||
|
||||
sResult += L"</w:comment>";
|
||||
//--------------------------------------------------------
|
||||
m_sCommentsExtended += L"<w15:commentEx w15:paraId=\"" + it->second.paraId + L"\"";
|
||||
if (it->second.nParentID != 0)
|
||||
{
|
||||
it->second.nParentID = it->second.nID + it->second.nParentID;
|
||||
|
||||
std::map<int, std::wstring>::iterator pFind = m_mapCommentsParent.find(it->second.nParentID);
|
||||
|
||||
if (pFind != m_mapCommentsParent.end())
|
||||
{
|
||||
m_sCommentsExtended += L" w15:paraIdParent=\"" + pFind->second + L"\"";
|
||||
}
|
||||
}
|
||||
m_sCommentsExtended += L" w15:done=\"0\"/>";
|
||||
|
||||
}
|
||||
sResult += L"</w:comments>";
|
||||
return sResult;
|
||||
}
|
||||
std::wstring CreateXmlExtended()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult += L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
|
||||
|
||||
sResult += L"<w15:commentsEx \
|
||||
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" \
|
||||
xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
|
||||
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
|
||||
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
|
||||
xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" \
|
||||
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
|
||||
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
|
||||
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
|
||||
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
|
||||
mc:Ignorable=\"w14 w15 w16se wp14\">";
|
||||
sResult += m_sCommentsExtended;
|
||||
sResult += L"</w15:commentsEx>";
|
||||
return sResult;
|
||||
}
|
||||
|
||||
std::wstring CreateXml();
|
||||
std::wstring CreateXmlExtended();
|
||||
};
|
||||
|
||||
101
RtfFile/OOXml/Writer/OOXContentTypesWriter.cpp
Normal file
101
RtfFile/OOXml/Writer/OOXContentTypesWriter.cpp
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* 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 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* 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 "OOXContentTypesWriter.h"
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
#include "../../../OOXML/Base/Base.h"
|
||||
|
||||
void OOXContentTypesWriter::AddWriter()
|
||||
{
|
||||
}
|
||||
void OOXContentTypesWriter::AddContent( std::wstring sType, std::wstring sTarget )
|
||||
{
|
||||
for (size_t i = 0 ;i < (int)m_aTargets.size(); i++ )
|
||||
if( sTarget == m_aTargets[i] )
|
||||
return;
|
||||
m_aTargets.push_back( sTarget );
|
||||
m_aTypes.push_back( sType );
|
||||
}
|
||||
void OOXContentTypesWriter::AddExtension( std::wstring sType, std::wstring sTarget )
|
||||
{
|
||||
for (size_t i = 0 ;i < (int)m_aExtensions.size(); i++ )
|
||||
if( sTarget == m_aExtensions[i] )
|
||||
return;
|
||||
m_aExtensions.push_back( sTarget );
|
||||
m_aExtTypes.push_back( sType );
|
||||
}
|
||||
bool OOXContentTypesWriter::Save(std::wstring sFolder)
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
|
||||
if (false == file.CreateFile(sFolder + FILE_SEPARATOR_STR + _T("[Content_Types].xml"))) return false;
|
||||
|
||||
std::wstring sXml = CreateXml();
|
||||
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((const void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
|
||||
file.CloseFile();
|
||||
return true;
|
||||
}
|
||||
std::wstring OOXContentTypesWriter::CreateXml()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult += _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n");
|
||||
|
||||
sResult += _T("<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">");
|
||||
|
||||
sResult += _T("<Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>");
|
||||
sResult += _T("<Default Extension=\"xml\" ContentType=\"application/xml\"/>");
|
||||
|
||||
for (size_t i = 0; i < m_aExtensions.size(); i++ )
|
||||
{
|
||||
sResult += _T("<Default Extension=\"");
|
||||
sResult += m_aExtensions[i];
|
||||
sResult += _T("\" ContentType=\"");
|
||||
sResult += m_aExtTypes[i];
|
||||
sResult += _T("\"/>");
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_aTargets.size(); i++ )
|
||||
{
|
||||
sResult += _T("<Override PartName=\"");
|
||||
sResult += m_aTargets[i];
|
||||
sResult += _T("\" ContentType=\"");
|
||||
sResult += m_aTypes[i];
|
||||
sResult += _T("\"/>");
|
||||
}
|
||||
sResult += _T("</Types>");
|
||||
return sResult;
|
||||
}
|
||||
|
||||
@ -31,44 +31,16 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class OOXContentTypesWriter
|
||||
{
|
||||
public:
|
||||
void AddWriter()
|
||||
{
|
||||
}
|
||||
void AddContent( std::wstring sType, std::wstring sTarget )
|
||||
{
|
||||
for (size_t i = 0 ;i < (int)m_aTargets.size(); i++ )
|
||||
if( sTarget == m_aTargets[i] )
|
||||
return;
|
||||
m_aTargets.push_back( sTarget );
|
||||
m_aTypes.push_back( sType );
|
||||
}
|
||||
void AddExtension( std::wstring sType, std::wstring sTarget )
|
||||
{
|
||||
for (size_t i = 0 ;i < (int)m_aExtensions.size(); i++ )
|
||||
if( sTarget == m_aExtensions[i] )
|
||||
return;
|
||||
m_aExtensions.push_back( sTarget );
|
||||
m_aExtTypes.push_back( sType );
|
||||
}
|
||||
bool Save(std::wstring sFolder)
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
|
||||
if (false == file.CreateFile(sFolder + FILE_SEPARATOR_STR + _T("[Content_Types].xml"))) return false;
|
||||
|
||||
std::wstring sXml = CreateXml();
|
||||
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((const void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
|
||||
file.CloseFile();
|
||||
return true;
|
||||
}
|
||||
void AddWriter();
|
||||
void AddContent( std::wstring sType, std::wstring sTarget );
|
||||
void AddExtension( std::wstring sType, std::wstring sTarget );
|
||||
bool Save(std::wstring sFolder);
|
||||
|
||||
private:
|
||||
std::vector< std::wstring > m_aTargets;
|
||||
@ -77,34 +49,5 @@ private:
|
||||
std::vector< std::wstring > m_aExtensions;
|
||||
std::vector< std::wstring > m_aExtTypes;
|
||||
|
||||
std::wstring CreateXml()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult += _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n");
|
||||
|
||||
sResult += _T("<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">");
|
||||
|
||||
sResult += _T("<Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>");
|
||||
sResult += _T("<Default Extension=\"xml\" ContentType=\"application/xml\"/>");
|
||||
|
||||
for (size_t i = 0; i < m_aExtensions.size(); i++ )
|
||||
{
|
||||
sResult += _T("<Default Extension=\"");
|
||||
sResult += m_aExtensions[i];
|
||||
sResult += _T("\" ContentType=\"");
|
||||
sResult += m_aExtTypes[i];
|
||||
sResult += _T("\"/>");
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_aTargets.size(); i++ )
|
||||
{
|
||||
sResult += _T("<Override PartName=\"");
|
||||
sResult += m_aTargets[i];
|
||||
sResult += _T("\" ContentType=\"");
|
||||
sResult += m_aTypes[i];
|
||||
sResult += _T("\"/>");
|
||||
}
|
||||
sResult += _T("</Types>");
|
||||
return sResult;
|
||||
}
|
||||
std::wstring CreateXml();
|
||||
};
|
||||
|
||||
@ -40,6 +40,16 @@
|
||||
#include "OOXFootnoteWriter.h"
|
||||
#include "OOXStylesWriter.h"
|
||||
|
||||
OOXDocumentWriter::OOXDocumentWriter( OOXWriter& oWriter,RtfDocument& oDocument ): m_oWriter(oWriter), m_oDocument(oDocument)
|
||||
{
|
||||
m_oFileWriter = NULL;
|
||||
m_bFirst = true;
|
||||
}
|
||||
OOXDocumentWriter::~OOXDocumentWriter()
|
||||
{
|
||||
RELEASEOBJECT( m_oFileWriter );
|
||||
}
|
||||
|
||||
std::wstring OOXDocumentWriter::CreateXmlStart()
|
||||
{
|
||||
//пишем Footnotes
|
||||
@ -424,3 +434,17 @@ bool OOXDocumentWriter::SaveByItemEnd()
|
||||
RELEASEOBJECT( m_oFileWriter );
|
||||
return true;
|
||||
}
|
||||
|
||||
int OOXDocumentWriter::GetCountSections()
|
||||
{
|
||||
return m_oDocument.GetCount();
|
||||
}
|
||||
int OOXDocumentWriter::GetCount()
|
||||
{
|
||||
int nCount = 0;
|
||||
for( int i = 0; i < m_oDocument.GetCount(); i++ )
|
||||
{
|
||||
nCount += m_oDocument[i].props->GetCount();
|
||||
}
|
||||
return nCount;
|
||||
}
|
||||
|
||||
@ -42,18 +42,12 @@ private:
|
||||
RtfDocument& m_oDocument;
|
||||
NFileWriter::CBufferedFileWriter* m_oFileWriter;
|
||||
bool m_bFirst; //один параграф пишем другой храним в памяти
|
||||
public:
|
||||
OOXDocumentWriter( OOXWriter& oWriter,RtfDocument& oDocument ): m_oWriter(oWriter), m_oDocument(oDocument)
|
||||
{
|
||||
m_oFileWriter = NULL;
|
||||
m_bFirst = true;
|
||||
}
|
||||
~OOXDocumentWriter()
|
||||
{
|
||||
RELEASEOBJECT( m_oFileWriter );
|
||||
}
|
||||
std::wstring CreateXmlStart();
|
||||
|
||||
public:
|
||||
OOXDocumentWriter( OOXWriter& oWriter,RtfDocument& oDocument );
|
||||
~OOXDocumentWriter();
|
||||
|
||||
std::wstring CreateXmlStart();
|
||||
std::wstring CreateXmlEnd( );
|
||||
|
||||
bool SaveByItemStart( std::wstring sFolder );
|
||||
@ -62,17 +56,6 @@ public:
|
||||
|
||||
bool SaveBySection();
|
||||
|
||||
int GetCountSections()
|
||||
{
|
||||
return m_oDocument.GetCount();
|
||||
}
|
||||
int GetCount()
|
||||
{
|
||||
int nCount = 0;
|
||||
for( int i = 0; i < m_oDocument.GetCount(); i++ )
|
||||
{
|
||||
nCount += m_oDocument[i].props->GetCount();
|
||||
}
|
||||
return nCount;
|
||||
}
|
||||
int GetCountSections();
|
||||
int GetCount();
|
||||
};
|
||||
|
||||
83
RtfFile/OOXml/Writer/OOXFontTableWriter.cpp
Normal file
83
RtfFile/OOXml/Writer/OOXFontTableWriter.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* 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 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* 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 "OOXFontTableWriter.h"
|
||||
|
||||
OOXFontTableWriter::OOXFontTableWriter(OOXWriter& oWriter,RtfDocument& oDocument ):m_oWriter(oWriter)
|
||||
{
|
||||
m_oRelsWriter = OOXRelsWriterPtr( new OOXRelsWriter( _T("fontTable.xml"), oDocument ) );
|
||||
oWriter.m_oCustomRelsWriter.push_back( m_oRelsWriter );
|
||||
}
|
||||
void OOXFontTableWriter::AddContent( std::wstring sText )
|
||||
{
|
||||
m_sFileXml += sText;
|
||||
}
|
||||
bool OOXFontTableWriter::Save( std::wstring sFolder )
|
||||
{
|
||||
std::wstring pathWord = sFolder + FILE_SEPARATOR_STR + _T("word");
|
||||
|
||||
if( false == m_sFileXml.empty() )
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
if (false == file.CreateFile(pathWord + FILE_SEPARATOR_STR + _T("fontTable.xml"))) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"), _T("fontTable.xml") );
|
||||
m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"), _T("/word/fontTable.xml") );
|
||||
|
||||
std::wstring sXml = CreateXml();
|
||||
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
|
||||
file.CloseFile();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//todooo - default fontTable !!!
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool OOXFontTableWriter::IsEmpty()
|
||||
{
|
||||
return m_sFileXml.empty();
|
||||
}
|
||||
std::wstring OOXFontTableWriter::CreateXml()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult.append( _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>") );
|
||||
sResult.append( _T("<w:fonts xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">") );
|
||||
sResult.append( m_sFileXml);
|
||||
sResult.append( _T("</w:fonts>") );
|
||||
return sResult;
|
||||
}
|
||||
@ -31,65 +31,24 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "OOXWriter.h"
|
||||
#include "OOXRelsWriter.h"
|
||||
|
||||
class OOXFontTableWriter
|
||||
{
|
||||
public:
|
||||
OOXRelsWriterPtr m_oRelsWriter;
|
||||
OOXFontTableWriter(OOXWriter& oWriter,RtfDocument& oDocument ):m_oWriter(oWriter)
|
||||
{
|
||||
m_oRelsWriter = OOXRelsWriterPtr( new OOXRelsWriter( _T("fontTable.xml"), oDocument ) );
|
||||
oWriter.m_oCustomRelsWriter.push_back( m_oRelsWriter );
|
||||
}
|
||||
|
||||
void AddContent( std::wstring sText )
|
||||
{
|
||||
m_sFileXml += sText;
|
||||
}
|
||||
bool Save( std::wstring sFolder )
|
||||
{
|
||||
std::wstring pathWord = sFolder + FILE_SEPARATOR_STR + _T("word");
|
||||
OOXFontTableWriter(OOXWriter& oWriter,RtfDocument& oDocument );
|
||||
|
||||
if( false == m_sFileXml.empty() )
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
if (false == file.CreateFile(pathWord + FILE_SEPARATOR_STR + _T("fontTable.xml"))) return false;
|
||||
void AddContent( std::wstring sText );
|
||||
bool Save( std::wstring sFolder );
|
||||
bool IsEmpty();
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"), _T("fontTable.xml") );
|
||||
m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"), _T("/word/fontTable.xml") );
|
||||
|
||||
std::wstring sXml = CreateXml();
|
||||
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
|
||||
file.CloseFile();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//todooo - default fontTable !!!
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool IsEmpty()
|
||||
{
|
||||
return m_sFileXml.empty();
|
||||
}
|
||||
private:
|
||||
std::wstring m_sFileXml;
|
||||
|
||||
OOXWriter& m_oWriter;
|
||||
|
||||
std::wstring CreateXml()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult.append( _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>") );
|
||||
sResult.append( _T("<w:fonts xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">") );
|
||||
sResult.append( m_sFileXml);
|
||||
sResult.append( _T("</w:fonts>") );
|
||||
return sResult;
|
||||
}
|
||||
std::wstring CreateXml();
|
||||
};
|
||||
|
||||
169
RtfFile/OOXml/Writer/OOXFootnoteWriter.cpp
Normal file
169
RtfFile/OOXml/Writer/OOXFootnoteWriter.cpp
Normal file
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* 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 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* 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 "OOXFootnoteWriter.h"
|
||||
|
||||
OOXFootnoteWriter::OOXFootnoteWriter( OOXWriter& oWriter,RtfDocument& oDocument ):m_oWriter(oWriter),m_oDocument(oDocument)
|
||||
{
|
||||
m_oRelsWriter = OOXRelsWriterPtr( new OOXRelsWriter( _T("footnotes.xml"), oDocument ) );
|
||||
oWriter.m_oCustomRelsWriter.push_back( m_oRelsWriter );
|
||||
}
|
||||
void OOXFootnoteWriter::AddFootnoteBegin( std::wstring sType, int nID, std::wstring sText )
|
||||
{
|
||||
std::wstring sFootnote;
|
||||
sFootnote += _T("<w:footnote");
|
||||
if( false == sType.empty() )
|
||||
{
|
||||
sFootnote += _T(" w:type=\"");
|
||||
sFootnote += sType;
|
||||
sFootnote += _T("\"");
|
||||
|
||||
}
|
||||
if( PROP_DEF != nID )
|
||||
sFootnote += L" w:id=\"" + std::to_wstring(nID) + L"\"";
|
||||
sFootnote += _T(">");
|
||||
sFootnote += sText;
|
||||
sFootnote += _T("</w:footnote>");
|
||||
|
||||
m_sFootnotes.insert( m_sFootnotes.begin() , sFootnote.begin(), sFootnote.end() );
|
||||
}
|
||||
void OOXFootnoteWriter::AddFootnote( std::wstring sType, int nID, std::wstring sText )
|
||||
{
|
||||
m_sFootnotes += _T("<w:footnote");
|
||||
if( !sType.empty() )
|
||||
{
|
||||
m_sFootnotes += _T(" w:type=\"");
|
||||
m_sFootnotes += sType;
|
||||
m_sFootnotes += _T("\"");
|
||||
}
|
||||
if( PROP_DEF != nID )
|
||||
m_sFootnotes += L" w:id=\"" + std::to_wstring(nID) + L"\"";
|
||||
m_sFootnotes += _T(">");
|
||||
m_sFootnotes += sText;
|
||||
m_sFootnotes += _T("</w:footnote>");
|
||||
}
|
||||
bool OOXFootnoteWriter::Save( std::wstring sFolder )
|
||||
{
|
||||
if( m_sFootnotes.empty() ) return false;
|
||||
|
||||
NSFile::CFileBinary file;
|
||||
if (false == file.CreateFile(sFolder + FILE_SEPARATOR_STR + _T("footnotes.xml"))) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"), _T("footnotes.xml") );
|
||||
m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"), _T("/word/footnotes.xml") );
|
||||
|
||||
std::wstring sXml = CreateXml();
|
||||
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
|
||||
file.CloseFile();
|
||||
return true;
|
||||
}
|
||||
std::wstring OOXFootnoteWriter::CreateXml()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult += _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
|
||||
|
||||
sResult += _T("<w:footnotes xmlns:wpc=\"http://schemas.microsoft.com/office/word/2008/6/28/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2008/9/16/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2009/2/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2008/6/28/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2008/6/28/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2008/6/28/wordprocessingShape\" >");
|
||||
sResult += m_sFootnotes;
|
||||
sResult += _T("</w:footnotes>");
|
||||
return sResult;
|
||||
}
|
||||
|
||||
OOXEndnoteWriter::OOXEndnoteWriter( OOXWriter& oWriter,RtfDocument& oDocument ):m_oWriter(oWriter),m_oDocument(oDocument)
|
||||
{
|
||||
m_oRelsWriter = OOXRelsWriterPtr( new OOXRelsWriter( _T("endnotes.xml"), oDocument ) );
|
||||
oWriter.m_oCustomRelsWriter.push_back( m_oRelsWriter );
|
||||
}
|
||||
void OOXEndnoteWriter::AddEndnoteBegin( std::wstring sType, int nID, std::wstring sText )
|
||||
{
|
||||
std::wstring sEndnote;
|
||||
sEndnote += _T("<w:endnote");
|
||||
if( false == sType.empty() )
|
||||
{
|
||||
sEndnote += _T(" w:type=\"");
|
||||
sEndnote += sType;
|
||||
sEndnote += _T("\"");
|
||||
}
|
||||
if( -2 != nID )
|
||||
sEndnote += L" w:id=\"" + std::to_wstring(nID) + L"\"";
|
||||
sEndnote += _T(">");
|
||||
sEndnote += sText;
|
||||
sEndnote += _T("</w:endnote>");
|
||||
|
||||
m_sEndnotes.insert( m_sEndnotes.begin() , sEndnote.begin(), sEndnote.end() );
|
||||
}
|
||||
void OOXEndnoteWriter::AddEndnote( std::wstring sType, int nID, std::wstring sText )
|
||||
{
|
||||
m_sEndnotes += _T("<w:endnote");
|
||||
if( false == sType.empty() )
|
||||
{
|
||||
m_sEndnotes += _T(" w:type=\"");
|
||||
m_sEndnotes += sType;
|
||||
m_sEndnotes += _T("\"");
|
||||
|
||||
}
|
||||
if( -2 != nID )
|
||||
m_sEndnotes += L" w:id=\"" + std::to_wstring(nID) + L"\"";
|
||||
m_sEndnotes += _T(">");
|
||||
m_sEndnotes += sText;
|
||||
m_sEndnotes += _T("</w:endnote>");
|
||||
}
|
||||
bool OOXEndnoteWriter::Save( std::wstring sFolder )
|
||||
{
|
||||
if( m_sEndnotes.empty() ) return false;
|
||||
|
||||
NSFile::CFileBinary file;
|
||||
if (false == file.CreateFile(sFolder + FILE_SEPARATOR_STR + _T("endnotes.xml"))) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes"), _T("endnotes.xml") );
|
||||
m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"), _T("/word/endnotes.xml") );
|
||||
|
||||
std::string sXml = CreateXml();
|
||||
|
||||
file.WriteFile(sXml.c_str(), (DWORD)sXml.length());
|
||||
file.CloseFile();
|
||||
return true;
|
||||
}
|
||||
std::string OOXEndnoteWriter::CreateXml()
|
||||
{
|
||||
std::wstring sResult;
|
||||
|
||||
sResult += _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
|
||||
sResult += _T("<w:endnotes xmlns:wpc=\"http://schemas.microsoft.com/office/word/2008/6/28/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2008/9/16/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2009/2/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2008/6/28/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2008/6/28/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2008/6/28/wordprocessingShape\" >");
|
||||
sResult += m_sEndnotes;
|
||||
sResult += _T("</w:endnotes>");
|
||||
|
||||
return NSFile::CUtf8Converter::GetUtf8StringFromUnicode( sResult);
|
||||
}
|
||||
@ -37,155 +37,37 @@ class OOXFootnoteWriter
|
||||
{
|
||||
public:
|
||||
OOXRelsWriterPtr m_oRelsWriter;
|
||||
OOXFootnoteWriter( OOXWriter& oWriter,RtfDocument& oDocument ):m_oWriter(oWriter),m_oDocument(oDocument)
|
||||
{
|
||||
m_oRelsWriter = OOXRelsWriterPtr( new OOXRelsWriter( _T("footnotes.xml"), oDocument ) );
|
||||
oWriter.m_oCustomRelsWriter.push_back( m_oRelsWriter );
|
||||
}
|
||||
void AddFootnoteBegin( std::wstring sType, int nID, std::wstring sText )
|
||||
{
|
||||
std::wstring sFootnote;
|
||||
sFootnote += _T("<w:footnote");
|
||||
if( false == sType.empty() )
|
||||
{
|
||||
sFootnote += _T(" w:type=\"");
|
||||
sFootnote += sType;
|
||||
sFootnote += _T("\"");
|
||||
|
||||
}
|
||||
if( PROP_DEF != nID )
|
||||
sFootnote += L" w:id=\"" + std::to_wstring(nID) + L"\"";
|
||||
sFootnote += _T(">");
|
||||
sFootnote += sText;
|
||||
sFootnote += _T("</w:footnote>");
|
||||
OOXFootnoteWriter( OOXWriter& oWriter,RtfDocument& oDocument );
|
||||
|
||||
m_sFootnotes.insert( m_sFootnotes.begin() , sFootnote.begin(), sFootnote.end() );
|
||||
}
|
||||
void AddFootnote( std::wstring sType, int nID, std::wstring sText )
|
||||
{
|
||||
m_sFootnotes += _T("<w:footnote");
|
||||
if( !sType.empty() )
|
||||
{
|
||||
m_sFootnotes += _T(" w:type=\"");
|
||||
m_sFootnotes += sType;
|
||||
m_sFootnotes += _T("\"");
|
||||
}
|
||||
if( PROP_DEF != nID )
|
||||
m_sFootnotes += L" w:id=\"" + std::to_wstring(nID) + L"\"";
|
||||
m_sFootnotes += _T(">");
|
||||
m_sFootnotes += sText;
|
||||
m_sFootnotes += _T("</w:footnote>");
|
||||
}
|
||||
bool Save( std::wstring sFolder )
|
||||
{
|
||||
if( m_sFootnotes.empty() ) return false;
|
||||
void AddFootnoteBegin( std::wstring sType, int nID, std::wstring sText );
|
||||
void AddFootnote( std::wstring sType, int nID, std::wstring sText );
|
||||
bool Save( std::wstring sFolder );
|
||||
|
||||
NSFile::CFileBinary file;
|
||||
if (false == file.CreateFile(sFolder + FILE_SEPARATOR_STR + _T("footnotes.xml"))) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"), _T("footnotes.xml") );
|
||||
m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"), _T("/word/footnotes.xml") );
|
||||
|
||||
std::wstring sXml = CreateXml();
|
||||
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
|
||||
file.CloseFile();
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
RtfDocument& m_oDocument;
|
||||
OOXWriter& m_oWriter;
|
||||
|
||||
std::wstring m_sFootnotes;
|
||||
|
||||
std::wstring CreateXml()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult += _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
|
||||
|
||||
sResult += _T("<w:footnotes xmlns:wpc=\"http://schemas.microsoft.com/office/word/2008/6/28/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2008/9/16/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2009/2/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2008/6/28/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2008/6/28/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2008/6/28/wordprocessingShape\" >");
|
||||
sResult += m_sFootnotes;
|
||||
sResult += _T("</w:footnotes>");
|
||||
return sResult;
|
||||
}
|
||||
|
||||
std::wstring CreateXml();
|
||||
};
|
||||
|
||||
class OOXEndnoteWriter
|
||||
{
|
||||
public:
|
||||
OOXRelsWriterPtr m_oRelsWriter;
|
||||
OOXEndnoteWriter( OOXWriter& oWriter,RtfDocument& oDocument ):m_oWriter(oWriter),m_oDocument(oDocument)
|
||||
{
|
||||
m_oRelsWriter = OOXRelsWriterPtr( new OOXRelsWriter( _T("endnotes.xml"), oDocument ) );
|
||||
oWriter.m_oCustomRelsWriter.push_back( m_oRelsWriter );
|
||||
}
|
||||
void AddEndnoteBegin( std::wstring sType, int nID, std::wstring sText )
|
||||
{
|
||||
std::wstring sEndnote;
|
||||
sEndnote += _T("<w:endnote");
|
||||
if( false == sType.empty() )
|
||||
{
|
||||
sEndnote += _T(" w:type=\"");
|
||||
sEndnote += sType;
|
||||
sEndnote += _T("\"");
|
||||
}
|
||||
if( -2 != nID )
|
||||
sEndnote += L" w:id=\"" + std::to_wstring(nID) + L"\"";
|
||||
sEndnote += _T(">");
|
||||
sEndnote += sText;
|
||||
sEndnote += _T("</w:endnote>");
|
||||
|
||||
m_sEndnotes.insert( m_sEndnotes.begin() , sEndnote.begin(), sEndnote.end() );
|
||||
}
|
||||
void AddEndnote( std::wstring sType, int nID, std::wstring sText )
|
||||
{
|
||||
m_sEndnotes += _T("<w:endnote");
|
||||
if( false == sType.empty() )
|
||||
{
|
||||
m_sEndnotes += _T(" w:type=\"");
|
||||
m_sEndnotes += sType;
|
||||
m_sEndnotes += _T("\"");
|
||||
OOXEndnoteWriter( OOXWriter& oWriter,RtfDocument& oDocument );
|
||||
|
||||
}
|
||||
if( -2 != nID )
|
||||
m_sEndnotes += L" w:id=\"" + std::to_wstring(nID) + L"\"";
|
||||
m_sEndnotes += _T(">");
|
||||
m_sEndnotes += sText;
|
||||
m_sEndnotes += _T("</w:endnote>");
|
||||
}
|
||||
bool Save( std::wstring sFolder )
|
||||
{
|
||||
if( m_sEndnotes.empty() ) return false;
|
||||
void AddEndnoteBegin( std::wstring sType, int nID, std::wstring sText );
|
||||
void AddEndnote( std::wstring sType, int nID, std::wstring sText );
|
||||
bool Save( std::wstring sFolder );
|
||||
|
||||
NSFile::CFileBinary file;
|
||||
if (false == file.CreateFile(sFolder + FILE_SEPARATOR_STR + _T("endnotes.xml"))) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes"), _T("endnotes.xml") );
|
||||
m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"), _T("/word/endnotes.xml") );
|
||||
|
||||
std::string sXml = CreateXml();
|
||||
|
||||
file.WriteFile(sXml.c_str(), (DWORD)sXml.length());
|
||||
file.CloseFile();
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
RtfDocument& m_oDocument;
|
||||
OOXWriter& m_oWriter;
|
||||
std::wstring m_sEndnotes;
|
||||
|
||||
std::string CreateXml()
|
||||
{
|
||||
std::wstring sResult;
|
||||
|
||||
sResult += _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
|
||||
sResult += _T("<w:endnotes xmlns:wpc=\"http://schemas.microsoft.com/office/word/2008/6/28/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2008/9/16/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2009/2/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2008/6/28/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2008/6/28/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2008/6/28/wordprocessingShape\" >");
|
||||
sResult += m_sEndnotes;
|
||||
sResult += _T("</w:endnotes>");
|
||||
|
||||
return NSFile::CUtf8Converter::GetUtf8StringFromUnicode( sResult);
|
||||
}
|
||||
std::string CreateXml();
|
||||
};
|
||||
|
||||
79
RtfFile/OOXml/Writer/OOXNumberingWriter.cpp
Normal file
79
RtfFile/OOXml/Writer/OOXNumberingWriter.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* 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 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* 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 "OOXNumberingWriter.h"
|
||||
|
||||
OOXNumberingWriter::OOXNumberingWriter(OOXWriter& oWriter,RtfDocument& oDocument ):m_oWriter(oWriter)
|
||||
{
|
||||
m_oRelsWriter = OOXRelsWriterPtr( new OOXRelsWriter( _T("numbering.xml"), oDocument ) );
|
||||
oWriter.m_oCustomRelsWriter.push_back( m_oRelsWriter );
|
||||
//m_sFileXml += oDocument.RenderToOOX(&oWriter,&oDocument,"numbering.xml","");
|
||||
}
|
||||
void OOXNumberingWriter::AddNumbering( std::wstring sText )
|
||||
{
|
||||
m_sFileXml += sText;
|
||||
}
|
||||
bool OOXNumberingWriter::Save( std::wstring sFolder )
|
||||
{
|
||||
if( false == m_sFileXml.empty() )
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
|
||||
if (false == file.CreateFile(sFolder + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("numbering.xml"))) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"), _T("numbering.xml") );
|
||||
m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"), _T("/word/numbering.xml") );
|
||||
|
||||
std::wstring sXml = CreateXml();
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
file.CloseFile();
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool OOXNumberingWriter::IsEmpty()
|
||||
{
|
||||
return m_sFileXml.empty();
|
||||
}
|
||||
std::wstring OOXNumberingWriter::CreateXml()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult.append( _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>") );
|
||||
sResult.append( _T("\n") );
|
||||
sResult.append( _T("<w:numbering xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\">") );
|
||||
sResult.append( m_sFileXml );
|
||||
sResult.append( _T("</w:numbering>") );
|
||||
return sResult;
|
||||
}
|
||||
@ -38,54 +38,15 @@ class OOXNumberingWriter
|
||||
public:
|
||||
OOXRelsWriterPtr m_oRelsWriter;
|
||||
|
||||
OOXNumberingWriter(OOXWriter& oWriter,RtfDocument& oDocument ):m_oWriter(oWriter)
|
||||
{
|
||||
m_oRelsWriter = OOXRelsWriterPtr( new OOXRelsWriter( _T("numbering.xml"), oDocument ) );
|
||||
oWriter.m_oCustomRelsWriter.push_back( m_oRelsWriter );
|
||||
//m_sFileXml += oDocument.RenderToOOX(&oWriter,&oDocument,"numbering.xml","");
|
||||
}
|
||||
void AddNumbering( std::wstring sText )
|
||||
{
|
||||
m_sFileXml += sText;
|
||||
}
|
||||
bool Save( std::wstring sFolder )
|
||||
{
|
||||
if( false == m_sFileXml.empty() )
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
OOXNumberingWriter(OOXWriter& oWriter,RtfDocument& oDocument );
|
||||
|
||||
if (false == file.CreateFile(sFolder + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("numbering.xml"))) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"), _T("numbering.xml") );
|
||||
m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"), _T("/word/numbering.xml") );
|
||||
void AddNumbering( std::wstring sText );
|
||||
bool Save( std::wstring sFolder );
|
||||
bool IsEmpty();
|
||||
|
||||
std::wstring sXml = CreateXml();
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
file.CloseFile();
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool IsEmpty()
|
||||
{
|
||||
return m_sFileXml.empty();
|
||||
}
|
||||
private:
|
||||
std::wstring m_sFileXml;
|
||||
|
||||
OOXWriter& m_oWriter;
|
||||
|
||||
std::wstring CreateXml()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult.append( _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>") );
|
||||
sResult.append( _T("\n") );
|
||||
sResult.append( _T("<w:numbering xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\">") );
|
||||
sResult.append( m_sFileXml );
|
||||
sResult.append( _T("</w:numbering>") );
|
||||
return sResult;
|
||||
}
|
||||
std::wstring CreateXml();
|
||||
};
|
||||
|
||||
94
RtfFile/OOXml/Writer/OOXRelsWriter.cpp
Normal file
94
RtfFile/OOXml/Writer/OOXRelsWriter.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* 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 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* 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 "OOXRelsWriter.h"
|
||||
|
||||
OOXRelsWriter::OOXRelsWriter( std::wstring sFileName, RtfDocument& oDocument ):m_oDocument(oDocument)
|
||||
{
|
||||
m_sFileName = sFileName;
|
||||
}
|
||||
std::wstring OOXRelsWriter::AddRelationship( std::wstring sType, std::wstring sTarget, bool bTargetModeInternal )
|
||||
{
|
||||
for (size_t i = 0 ;i < m_aTargets.size(); i++ )
|
||||
{
|
||||
if( sTarget == m_aTargets[i] )
|
||||
return m_aIDs[i];
|
||||
}
|
||||
m_aTargets.push_back( sTarget );
|
||||
m_aTypes.push_back( sType );
|
||||
std::wstring sId = m_oDocument.m_oIdGenerator.Generate_rId();
|
||||
m_aIDs.push_back( sId );
|
||||
m_aModes.push_back( bTargetModeInternal );
|
||||
return sId;
|
||||
}
|
||||
std::wstring OOXRelsWriter::CreateXml()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult += _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
|
||||
|
||||
sResult += _T("<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">");
|
||||
|
||||
for (size_t i = 0; i < m_aTargets.size(); i++ )
|
||||
{
|
||||
sResult += _T("<Relationship Id=\"");
|
||||
sResult += m_aIDs[i];
|
||||
sResult += _T("\" Type=\"");
|
||||
sResult += m_aTypes[i];
|
||||
sResult += _T("\" Target=\"");
|
||||
sResult += m_aTargets[i];
|
||||
sResult += _T("\"");
|
||||
if( false == m_aModes[i] )
|
||||
sResult += _T(" TargetMode=\"External\"");
|
||||
sResult += _T("/>");
|
||||
}
|
||||
sResult += _T("</Relationships>");
|
||||
return sResult;
|
||||
}
|
||||
bool OOXRelsWriter::Save( std::wstring sFolder )
|
||||
{
|
||||
if( m_aTargets.size() < 1 )return false;
|
||||
|
||||
std::wstring pathRels = sFolder + FILE_SEPARATOR_STR + _T("_rels");
|
||||
NSDirectory::CreateDirectory(pathRels) ;
|
||||
|
||||
NSFile::CFileBinary file;
|
||||
if (false == file.CreateFile(pathRels + FILE_SEPARATOR_STR + m_sFileName + _T(".rels"))) return false;
|
||||
|
||||
std::wstring sXml = CreateXml();
|
||||
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
file.CloseFile();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -45,67 +45,10 @@ private:
|
||||
RtfDocument& m_oDocument;
|
||||
|
||||
public:
|
||||
OOXRelsWriter( std::wstring sFileName, RtfDocument& oDocument ):m_oDocument(oDocument)
|
||||
{
|
||||
m_sFileName = sFileName;
|
||||
}
|
||||
OOXRelsWriter( std::wstring sFileName, RtfDocument& oDocument );
|
||||
|
||||
std::wstring AddRelationship( std::wstring sType, std::wstring sTarget, bool bTargetModeInternal = true )
|
||||
{
|
||||
for (size_t i = 0 ;i < m_aTargets.size(); i++ )
|
||||
{
|
||||
if( sTarget == m_aTargets[i] )
|
||||
return m_aIDs[i];
|
||||
}
|
||||
m_aTargets.push_back( sTarget );
|
||||
m_aTypes.push_back( sType );
|
||||
std::wstring sId = m_oDocument.m_oIdGenerator.Generate_rId();
|
||||
m_aIDs.push_back( sId );
|
||||
m_aModes.push_back( bTargetModeInternal );
|
||||
return sId;
|
||||
}
|
||||
std::wstring CreateXml()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult += _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
|
||||
|
||||
sResult += _T("<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">");
|
||||
|
||||
for (size_t i = 0; i < m_aTargets.size(); i++ )
|
||||
{
|
||||
sResult += _T("<Relationship Id=\"");
|
||||
sResult += m_aIDs[i];
|
||||
sResult += _T("\" Type=\"");
|
||||
sResult += m_aTypes[i];
|
||||
sResult += _T("\" Target=\"");
|
||||
sResult += m_aTargets[i];
|
||||
sResult += _T("\"");
|
||||
if( false == m_aModes[i] )
|
||||
sResult += _T(" TargetMode=\"External\"");
|
||||
sResult += _T("/>");
|
||||
}
|
||||
sResult += _T("</Relationships>");
|
||||
return sResult;
|
||||
}
|
||||
|
||||
bool Save( std::wstring sFolder )
|
||||
{
|
||||
if( m_aTargets.size() < 1 )return false;
|
||||
|
||||
std::wstring pathRels = sFolder + FILE_SEPARATOR_STR + _T("_rels");
|
||||
NSDirectory::CreateDirectory(pathRels) ;
|
||||
|
||||
NSFile::CFileBinary file;
|
||||
if (false == file.CreateFile(pathRels + FILE_SEPARATOR_STR + m_sFileName + _T(".rels"))) return false;
|
||||
|
||||
std::wstring sXml = CreateXml();
|
||||
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
file.CloseFile();
|
||||
|
||||
return true;
|
||||
}
|
||||
std::wstring AddRelationship( std::wstring sType, std::wstring sTarget, bool bTargetModeInternal = true );
|
||||
std::wstring CreateXml();
|
||||
bool Save( std::wstring sFolder );
|
||||
};
|
||||
typedef boost::shared_ptr<OOXRelsWriter> OOXRelsWriterPtr;
|
||||
|
||||
107
RtfFile/OOXml/Writer/OOXSettingsWriter.cpp
Normal file
107
RtfFile/OOXml/Writer/OOXSettingsWriter.cpp
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* 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 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* 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 "OOXSettingsWriter.h"
|
||||
|
||||
std::wstring OOXSettingsWriter::CreateXml()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult.append( _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>") );
|
||||
sResult.append( _T("\n") );
|
||||
sResult.append( _T("<w:settings xmlns:w = \"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:m = \"http://schemas.openxmlformats.org/officeDocument/2006/math\">") );
|
||||
sResult.append( m_sFileXml );
|
||||
sResult.append( _T("</w:settings>") );
|
||||
return sResult;
|
||||
}
|
||||
OOXSettingsWriter::OOXSettingsWriter(OOXWriter& oWriter,RtfDocument& oDocument ):m_oWriter(oWriter)
|
||||
{
|
||||
m_oRelsWriter = OOXRelsWriterPtr( new OOXRelsWriter( _T("settings.xml"), oDocument ) );
|
||||
oWriter.m_oCustomRelsWriter.push_back( m_oRelsWriter );
|
||||
}
|
||||
void OOXSettingsWriter::AddContent( std::wstring sText )
|
||||
{
|
||||
m_sFileXml += sText;
|
||||
}
|
||||
bool OOXSettingsWriter::Save( std::wstring sFolder )
|
||||
{
|
||||
std::wstring pathWord = sFolder + FILE_SEPARATOR_STR + _T("word");
|
||||
|
||||
if ( false == m_sFileXml.empty() )
|
||||
{
|
||||
//генерируем свою xml
|
||||
std::wstring sXml = CreateXml();
|
||||
|
||||
//todoooo ПЕРЕПИСАТЬ
|
||||
|
||||
////берем xml из шаблона
|
||||
//std::wstring sFilename = sFolder + _T("\\word\\settings.xml");
|
||||
//if( true == RtfUtility:: SaveResourceToFile( IDR_SETTINGS, L"XML", sFilename ) )
|
||||
//{
|
||||
// XmlUtils::CXmlLiteReader oXmlReader1;
|
||||
// XmlUtils::CXmlLiteReader oXmlReader2;
|
||||
|
||||
// if( TRUE == oXmlReader1.OpenFromFile( sFilename ) && TRUE == oXmlReader2.OpenFromXmlString( sXml ) &&
|
||||
// TRUE == oXmlReader1.ReadRootNode( _T("w:settings") ) && TRUE == oXmlReader2.ReadRootNode( _T("w:settings") ) )
|
||||
// {
|
||||
// sXml = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>");
|
||||
// //sXml += RtfUtility::MergeXml( oXmlReader1, oXmlReader2 );
|
||||
// }
|
||||
//}
|
||||
|
||||
NSFile::CFileBinary file;
|
||||
if (false == file.CreateFile(pathWord + FILE_SEPARATOR_STR + _T("settings.xml"))) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"), _T("settings.xml") );
|
||||
m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"), _T("/word/settings.xml") );
|
||||
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
|
||||
file.CloseFile();
|
||||
;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//if( true == RtfUtility:: SaveResourceToFile( IDR_SETTINGS, L"XML", sFolder + _T("\\word\\settings.xml") ) )
|
||||
//{
|
||||
// m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"), _T("settings.xml") );
|
||||
// m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"), _T("/word/settings.xml") );
|
||||
//}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool OOXSettingsWriter::IsEmpty()
|
||||
{
|
||||
return m_sFileXml.empty();
|
||||
}
|
||||
@ -30,6 +30,8 @@
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "OOXWriter.h"
|
||||
#include "OOXRelsWriter.h"
|
||||
|
||||
class OOXSettingsWriter
|
||||
@ -38,81 +40,14 @@ private:
|
||||
std::wstring m_sFileXml;
|
||||
OOXWriter& m_oWriter;
|
||||
|
||||
std::wstring CreateXml()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult.append( _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>") );
|
||||
sResult.append( _T("\n") );
|
||||
sResult.append( _T("<w:settings xmlns:w = \"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:m = \"http://schemas.openxmlformats.org/officeDocument/2006/math\">") );
|
||||
sResult.append( m_sFileXml );
|
||||
sResult.append( _T("</w:settings>") );
|
||||
return sResult;
|
||||
}
|
||||
std::wstring CreateXml();
|
||||
|
||||
public:
|
||||
OOXRelsWriterPtr m_oRelsWriter;
|
||||
|
||||
OOXSettingsWriter(OOXWriter& oWriter,RtfDocument& oDocument ):m_oWriter(oWriter)
|
||||
{
|
||||
m_oRelsWriter = OOXRelsWriterPtr( new OOXRelsWriter( _T("settings.xml"), oDocument ) );
|
||||
oWriter.m_oCustomRelsWriter.push_back( m_oRelsWriter );
|
||||
}
|
||||
void AddContent( std::wstring sText )
|
||||
{
|
||||
m_sFileXml += sText;
|
||||
}
|
||||
bool Save( std::wstring sFolder )
|
||||
{
|
||||
std::wstring pathWord = sFolder + FILE_SEPARATOR_STR + _T("word");
|
||||
OOXSettingsWriter(OOXWriter& oWriter,RtfDocument& oDocument );
|
||||
|
||||
if ( false == m_sFileXml.empty() )
|
||||
{
|
||||
//генерируем свою xml
|
||||
std::wstring sXml = CreateXml();
|
||||
|
||||
//todoooo ПЕРЕПИСАТЬ
|
||||
|
||||
////берем xml из шаблона
|
||||
//std::wstring sFilename = sFolder + _T("\\word\\settings.xml");
|
||||
//if( true == RtfUtility:: SaveResourceToFile( IDR_SETTINGS, L"XML", sFilename ) )
|
||||
//{
|
||||
// XmlUtils::CXmlLiteReader oXmlReader1;
|
||||
// XmlUtils::CXmlLiteReader oXmlReader2;
|
||||
|
||||
// if( TRUE == oXmlReader1.OpenFromFile( sFilename ) && TRUE == oXmlReader2.OpenFromXmlString( sXml ) &&
|
||||
// TRUE == oXmlReader1.ReadRootNode( _T("w:settings") ) && TRUE == oXmlReader2.ReadRootNode( _T("w:settings") ) )
|
||||
// {
|
||||
// sXml = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>");
|
||||
// //sXml += RtfUtility::MergeXml( oXmlReader1, oXmlReader2 );
|
||||
// }
|
||||
//}
|
||||
|
||||
NSFile::CFileBinary file;
|
||||
if (false == file.CreateFile(pathWord + FILE_SEPARATOR_STR + _T("settings.xml"))) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"), _T("settings.xml") );
|
||||
m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"), _T("/word/settings.xml") );
|
||||
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
|
||||
file.CloseFile();
|
||||
;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//if( true == RtfUtility:: SaveResourceToFile( IDR_SETTINGS, L"XML", sFolder + _T("\\word\\settings.xml") ) )
|
||||
//{
|
||||
// m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"), _T("settings.xml") );
|
||||
// m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"), _T("/word/settings.xml") );
|
||||
//}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsEmpty()
|
||||
{
|
||||
return m_sFileXml.empty();
|
||||
}
|
||||
void AddContent( std::wstring sText );
|
||||
bool Save( std::wstring sFolder );
|
||||
bool IsEmpty();
|
||||
};
|
||||
|
||||
83
RtfFile/OOXml/Writer/OOXStylesWriter.cpp
Normal file
83
RtfFile/OOXml/Writer/OOXStylesWriter.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* 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 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* 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 "OOXStylesWriter.h"
|
||||
|
||||
OOXStylesWriter::OOXStylesWriter(OOXWriter& oWriter,RtfDocument& oDocument ):m_oWriter(oWriter)
|
||||
{
|
||||
m_oRelsWriter = OOXRelsWriterPtr( new OOXRelsWriter( L"styles.xml", oDocument ) );
|
||||
oWriter.m_oCustomRelsWriter.push_back( m_oRelsWriter );
|
||||
}
|
||||
OOXStylesWriter::~OOXStylesWriter()
|
||||
{
|
||||
int i = 0;
|
||||
}
|
||||
void OOXStylesWriter::AddContent( std::wstring sText )
|
||||
{
|
||||
m_sFileXml += sText;
|
||||
}
|
||||
bool OOXStylesWriter::Save( std::wstring sFolder )
|
||||
{
|
||||
std::wstring pathWord = sFolder + FILE_SEPARATOR_STR + L"word";
|
||||
|
||||
//if( false == m_sFileXml.empty() )
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
if (false == file.CreateFile(pathWord + FILE_SEPARATOR_STR + L"styles.xml")) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", L"styles.xml" );
|
||||
m_oWriter.m_oContentTypes.AddContent( L"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml", L"/word/styles.xml" );
|
||||
|
||||
std::wstring sXml = CreateXml();
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
|
||||
file.CloseFile();
|
||||
return true;
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// //todooo default style !!
|
||||
//}
|
||||
return false;
|
||||
}
|
||||
std::wstring OOXStylesWriter::CreateXml()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult.append( L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>" );
|
||||
sResult.append( L"\n" );
|
||||
sResult.append( L"<w:styles xmlns:w = \"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">" );
|
||||
sResult.append( m_sFileXml );
|
||||
sResult.append( L"</w:styles>" );
|
||||
return sResult;
|
||||
}
|
||||
@ -38,57 +38,16 @@ class OOXStylesWriter
|
||||
{
|
||||
public:
|
||||
OOXRelsWriterPtr m_oRelsWriter;
|
||||
OOXStylesWriter(OOXWriter& oWriter,RtfDocument& oDocument ):m_oWriter(oWriter)
|
||||
{
|
||||
m_oRelsWriter = OOXRelsWriterPtr( new OOXRelsWriter( L"styles.xml", oDocument ) );
|
||||
oWriter.m_oCustomRelsWriter.push_back( m_oRelsWriter );
|
||||
}
|
||||
~OOXStylesWriter()
|
||||
{
|
||||
int i = 0;
|
||||
}
|
||||
void AddContent( std::wstring sText )
|
||||
{
|
||||
m_sFileXml += sText;
|
||||
}
|
||||
bool Save( std::wstring sFolder )
|
||||
{
|
||||
std::wstring pathWord = sFolder + FILE_SEPARATOR_STR + L"word";
|
||||
|
||||
//if( false == m_sFileXml.empty() )
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
if (false == file.CreateFile(pathWord + FILE_SEPARATOR_STR + L"styles.xml")) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", L"styles.xml" );
|
||||
m_oWriter.m_oContentTypes.AddContent( L"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml", L"/word/styles.xml" );
|
||||
OOXStylesWriter(OOXWriter& oWriter,RtfDocument& oDocument );
|
||||
~OOXStylesWriter();
|
||||
|
||||
std::wstring sXml = CreateXml();
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
void AddContent( std::wstring sText );
|
||||
bool Save( std::wstring sFolder );
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
|
||||
file.CloseFile();
|
||||
return true;
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// //todooo default style !!
|
||||
//}
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
std::wstring m_sFileXml;
|
||||
OOXWriter& m_oWriter;
|
||||
OOXWriter& m_oWriter;
|
||||
|
||||
std::wstring CreateXml()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult.append( L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>" );
|
||||
sResult.append( L"\n" );
|
||||
sResult.append( L"<w:styles xmlns:w = \"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">" );
|
||||
sResult.append( m_sFileXml );
|
||||
sResult.append( L"</w:styles>" );
|
||||
return sResult;
|
||||
}
|
||||
std::wstring CreateXml();
|
||||
};
|
||||
|
||||
59
RtfFile/OOXml/Writer/OOXThemeWriter.cpp
Normal file
59
RtfFile/OOXml/Writer/OOXThemeWriter.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* 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 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* 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 "OOXThemeWriter.h"
|
||||
#include "../../../DesktopEditor/common/Directory.h"
|
||||
#include "../../../OOXML/Base/Base.h"
|
||||
|
||||
OOXThemeWriter::OOXThemeWriter(OOXWriter& oWriter,RtfDocument& oDocument ):m_oWriter(oWriter)
|
||||
{
|
||||
}
|
||||
bool OOXThemeWriter::Save( std::wstring sFolder ) //todo доделать очистку поле ошибок
|
||||
{
|
||||
std::wstring pathWord = sFolder + FILE_SEPARATOR_STR + _T("word");
|
||||
|
||||
NSDirectory::CreateDirectory(pathWord) ;
|
||||
NSDirectory::CreateDirectory(pathWord + FILE_SEPARATOR_STR + _T("theme")) ;
|
||||
|
||||
//todooo default theme !!!!!
|
||||
//
|
||||
//if( true == RtfUtility:: SaveResourceToFile( IDR_THEME, L"XML", sFolder + _T("\\word\\theme\\theme1.xml") ) )
|
||||
//{
|
||||
// m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"), _T("theme/theme1.xml") );
|
||||
// m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.theme+xml"), _T("/word/theme/theme1.xml") );
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// RemoveDirectory( sFolder + _T("\\word\\theme") );
|
||||
//}
|
||||
return true;
|
||||
}
|
||||
@ -31,34 +31,16 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "OOXWriter.h"
|
||||
#include "../../Format/IdGenerator.h"
|
||||
|
||||
class OOXThemeWriter
|
||||
{
|
||||
private:
|
||||
OOXWriter& m_oWriter;
|
||||
public:
|
||||
OOXThemeWriter(OOXWriter& oWriter,RtfDocument& oDocument ):m_oWriter(oWriter)
|
||||
{
|
||||
}
|
||||
bool Save( std::wstring sFolder ) //todo доделать очистку поле ошибок
|
||||
{
|
||||
std::wstring pathWord = sFolder + FILE_SEPARATOR_STR + _T("word");
|
||||
|
||||
NSDirectory::CreateDirectory(pathWord) ;
|
||||
NSDirectory::CreateDirectory(pathWord + FILE_SEPARATOR_STR + _T("theme")) ;
|
||||
|
||||
//todooo default theme !!!!!
|
||||
//
|
||||
//if( true == RtfUtility:: SaveResourceToFile( IDR_THEME, L"XML", sFolder + _T("\\word\\theme\\theme1.xml") ) )
|
||||
//{
|
||||
// m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"), _T("theme/theme1.xml") );
|
||||
// m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.theme+xml"), _T("/word/theme/theme1.xml") );
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// RemoveDirectory( sFolder + _T("\\word\\theme") );
|
||||
//}
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
OOXThemeWriter(OOXWriter& oWriter,RtfDocument& oDocument );
|
||||
|
||||
bool Save( std::wstring sFolder ); //todo доделать очистку поле ошибок
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user