From 237d20eed25343ec9165353c10835f9416c32403 Mon Sep 17 00:00:00 2001 From: Vikulov Dmitry Date: Thu, 8 Dec 2022 14:31:37 +0300 Subject: [PATCH] RtfFile refact OOXml/Writer folder --- RtfFile/OOXml/Writer/OOXCommentsWriter.cpp | 208 ++++++++++++++++++ RtfFile/OOXml/Writer/OOXCommentsWriter.h | 182 +-------------- .../OOXml/Writer/OOXContentTypesWriter.cpp | 101 +++++++++ RtfFile/OOXml/Writer/OOXContentTypesWriter.h | 71 +----- RtfFile/OOXml/Writer/OOXDocumentWriter.cpp | 24 ++ RtfFile/OOXml/Writer/OOXDocumentWriter.h | 31 +-- RtfFile/OOXml/Writer/OOXFontTableWriter.cpp | 83 +++++++ RtfFile/OOXml/Writer/OOXFontTableWriter.h | 53 +---- RtfFile/OOXml/Writer/OOXFootnoteWriter.cpp | 169 ++++++++++++++ RtfFile/OOXml/Writer/OOXFootnoteWriter.h | 140 +----------- RtfFile/OOXml/Writer/OOXNumberingWriter.cpp | 79 +++++++ RtfFile/OOXml/Writer/OOXNumberingWriter.h | 49 +---- RtfFile/OOXml/Writer/OOXRelsWriter.cpp | 94 ++++++++ RtfFile/OOXml/Writer/OOXRelsWriter.h | 65 +----- RtfFile/OOXml/Writer/OOXSettingsWriter.cpp | 107 +++++++++ RtfFile/OOXml/Writer/OOXSettingsWriter.h | 81 +------ RtfFile/OOXml/Writer/OOXStylesWriter.cpp | 83 +++++++ RtfFile/OOXml/Writer/OOXStylesWriter.h | 53 +---- RtfFile/OOXml/Writer/OOXThemeWriter.cpp | 59 +++++ RtfFile/OOXml/Writer/OOXThemeWriter.h | 28 +-- RtfFile/Projects/Linux/RtfFormatLib.pro | 14 +- RtfFile/Projects/Linux/rtffile_source.cpp | 10 + 22 files changed, 1100 insertions(+), 684 deletions(-) create mode 100644 RtfFile/OOXml/Writer/OOXCommentsWriter.cpp create mode 100644 RtfFile/OOXml/Writer/OOXContentTypesWriter.cpp create mode 100644 RtfFile/OOXml/Writer/OOXFontTableWriter.cpp create mode 100644 RtfFile/OOXml/Writer/OOXFootnoteWriter.cpp create mode 100644 RtfFile/OOXml/Writer/OOXNumberingWriter.cpp create mode 100644 RtfFile/OOXml/Writer/OOXRelsWriter.cpp create mode 100644 RtfFile/OOXml/Writer/OOXSettingsWriter.cpp create mode 100644 RtfFile/OOXml/Writer/OOXStylesWriter.cpp create mode 100644 RtfFile/OOXml/Writer/OOXThemeWriter.cpp diff --git a/RtfFile/OOXml/Writer/OOXCommentsWriter.cpp b/RtfFile/OOXml/Writer/OOXCommentsWriter.cpp new file mode 100644 index 0000000000..e6c8ec3d8c --- /dev/null +++ b/RtfFile/OOXml/Writer/OOXCommentsWriter.cpp @@ -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::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::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::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::iterator pFind = m_mapComments.find(ref); + + if (pFind != m_mapComments.end()) + { + pFind->second.nParentID = boost::lexical_cast(parent); + } + } + void OOXCommentsWriter::AddCommentDate( const std::wstring & ref, const std::wstring & date) + { + std::map::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"\n"; + + sResult += L""; + + for (std::map::iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it) + { + sResult += L"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""; +//-------------------------------------------------------- + m_sCommentsExtended += L"second.paraId + L"\""; + if (it->second.nParentID != 0) + { + it->second.nParentID = it->second.nID + it->second.nParentID; + + std::map::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""; + return sResult; + } + std::wstring OOXCommentsWriter::CreateXmlExtended() + { + std::wstring sResult; + sResult += L"\n"; + + sResult += L""; + sResult += m_sCommentsExtended; + sResult += L""; + return sResult; + } diff --git a/RtfFile/OOXml/Writer/OOXCommentsWriter.h b/RtfFile/OOXml/Writer/OOXCommentsWriter.h index dd915d12a8..ef2ac4f309 100644 --- a/RtfFile/OOXml/Writer/OOXCommentsWriter.h +++ b/RtfFile/OOXml/Writer/OOXCommentsWriter.h @@ -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::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::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::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::iterator pFind = m_mapComments.find(ref); - - if (pFind != m_mapComments.end()) - { - pFind->second.nParentID = boost::lexical_cast(parent); - } - } - void AddCommentDate( const std::wstring & ref, const std::wstring & date) - { - std::map::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 m_mapComments; + private: RtfDocument& m_oDocument; OOXWriter& m_oWriter; @@ -153,84 +73,6 @@ private: std::wstring m_sCommentsExtended; std::map m_mapCommentsParent; - std::wstring CreateXml() - { - std::wstring sResult = L"\n"; - - sResult += L""; - - for (std::map::iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it) - { - sResult += L"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""; -//-------------------------------------------------------- - m_sCommentsExtended += L"second.paraId + L"\""; - if (it->second.nParentID != 0) - { - it->second.nParentID = it->second.nID + it->second.nParentID; - - std::map::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""; - return sResult; - } - std::wstring CreateXmlExtended() - { - std::wstring sResult; - sResult += L"\n"; - - sResult += L""; - sResult += m_sCommentsExtended; - sResult += L""; - return sResult; - } - + std::wstring CreateXml(); + std::wstring CreateXmlExtended(); }; diff --git a/RtfFile/OOXml/Writer/OOXContentTypesWriter.cpp b/RtfFile/OOXml/Writer/OOXContentTypesWriter.cpp new file mode 100644 index 0000000000..e9b78a859a --- /dev/null +++ b/RtfFile/OOXml/Writer/OOXContentTypesWriter.cpp @@ -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("\n"); + + sResult += _T(""); + + sResult += _T(""); + sResult += _T(""); + + for (size_t i = 0; i < m_aExtensions.size(); i++ ) + { + sResult += _T(""); + } + + for (size_t i = 0; i < m_aTargets.size(); i++ ) + { + sResult += _T(""); + } + sResult += _T(""); + return sResult; +} + diff --git a/RtfFile/OOXml/Writer/OOXContentTypesWriter.h b/RtfFile/OOXml/Writer/OOXContentTypesWriter.h index 35b6e6b631..677cd2c499 100644 --- a/RtfFile/OOXml/Writer/OOXContentTypesWriter.h +++ b/RtfFile/OOXml/Writer/OOXContentTypesWriter.h @@ -31,44 +31,16 @@ */ #pragma once +#include +#include 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("\n"); - - sResult += _T(""); - - sResult += _T(""); - sResult += _T(""); - - for (size_t i = 0; i < m_aExtensions.size(); i++ ) - { - sResult += _T(""); - } - - for (size_t i = 0; i < m_aTargets.size(); i++ ) - { - sResult += _T(""); - } - sResult += _T(""); - return sResult; - } + std::wstring CreateXml(); }; diff --git a/RtfFile/OOXml/Writer/OOXDocumentWriter.cpp b/RtfFile/OOXml/Writer/OOXDocumentWriter.cpp index 42da9abb14..903cc097ae 100644 --- a/RtfFile/OOXml/Writer/OOXDocumentWriter.cpp +++ b/RtfFile/OOXml/Writer/OOXDocumentWriter.cpp @@ -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; +} diff --git a/RtfFile/OOXml/Writer/OOXDocumentWriter.h b/RtfFile/OOXml/Writer/OOXDocumentWriter.h index a0e7d9ef0c..b0d2a7cf54 100644 --- a/RtfFile/OOXml/Writer/OOXDocumentWriter.h +++ b/RtfFile/OOXml/Writer/OOXDocumentWriter.h @@ -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(); }; diff --git a/RtfFile/OOXml/Writer/OOXFontTableWriter.cpp b/RtfFile/OOXml/Writer/OOXFontTableWriter.cpp new file mode 100644 index 0000000000..a011ad4633 --- /dev/null +++ b/RtfFile/OOXml/Writer/OOXFontTableWriter.cpp @@ -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("") ); + sResult.append( _T("") ); + sResult.append( m_sFileXml); + sResult.append( _T("") ); + return sResult; +} diff --git a/RtfFile/OOXml/Writer/OOXFontTableWriter.h b/RtfFile/OOXml/Writer/OOXFontTableWriter.h index ae39bc756c..22bf852024 100644 --- a/RtfFile/OOXml/Writer/OOXFontTableWriter.h +++ b/RtfFile/OOXml/Writer/OOXFontTableWriter.h @@ -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("") ); - sResult.append( _T("") ); - sResult.append( m_sFileXml); - sResult.append( _T("") ); - return sResult; - } + std::wstring CreateXml(); }; diff --git a/RtfFile/OOXml/Writer/OOXFootnoteWriter.cpp b/RtfFile/OOXml/Writer/OOXFootnoteWriter.cpp new file mode 100644 index 0000000000..51819369aa --- /dev/null +++ b/RtfFile/OOXml/Writer/OOXFootnoteWriter.cpp @@ -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(""); + sFootnote += sText; + sFootnote += _T(""); + + m_sFootnotes.insert( m_sFootnotes.begin() , sFootnote.begin(), sFootnote.end() ); +} +void OOXFootnoteWriter::AddFootnote( std::wstring sType, int nID, std::wstring sText ) +{ + m_sFootnotes += _T(""); + m_sFootnotes += sText; + m_sFootnotes += _T(""); +} +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("\n"); + + sResult += _T(""); + sResult += m_sFootnotes; + sResult += _T(""); + 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(""); + sEndnote += sText; + sEndnote += _T(""); + + m_sEndnotes.insert( m_sEndnotes.begin() , sEndnote.begin(), sEndnote.end() ); +} +void OOXEndnoteWriter::AddEndnote( std::wstring sType, int nID, std::wstring sText ) +{ + m_sEndnotes += _T(""); + m_sEndnotes += sText; + m_sEndnotes += _T(""); +} +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(""); + sResult += _T(""); + sResult += m_sEndnotes; + sResult += _T(""); + + return NSFile::CUtf8Converter::GetUtf8StringFromUnicode( sResult); +} diff --git a/RtfFile/OOXml/Writer/OOXFootnoteWriter.h b/RtfFile/OOXml/Writer/OOXFootnoteWriter.h index 89c9975b53..8cf85726a7 100644 --- a/RtfFile/OOXml/Writer/OOXFootnoteWriter.h +++ b/RtfFile/OOXml/Writer/OOXFootnoteWriter.h @@ -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(""); - sFootnote += sText; - sFootnote += _T(""); + 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(""); - m_sFootnotes += sText; - m_sFootnotes += _T(""); - } - 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("\n"); - - sResult += _T(""); - sResult += m_sFootnotes; - sResult += _T(""); - 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(""); - sEndnote += sText; - sEndnote += _T(""); - m_sEndnotes.insert( m_sEndnotes.begin() , sEndnote.begin(), sEndnote.end() ); - } - void AddEndnote( std::wstring sType, int nID, std::wstring sText ) - { - m_sEndnotes += _T(""); - m_sEndnotes += sText; - m_sEndnotes += _T(""); - } - 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(""); - sResult += _T(""); - sResult += m_sEndnotes; - sResult += _T(""); - - return NSFile::CUtf8Converter::GetUtf8StringFromUnicode( sResult); - } + std::string CreateXml(); }; diff --git a/RtfFile/OOXml/Writer/OOXNumberingWriter.cpp b/RtfFile/OOXml/Writer/OOXNumberingWriter.cpp new file mode 100644 index 0000000000..0f68871029 --- /dev/null +++ b/RtfFile/OOXml/Writer/OOXNumberingWriter.cpp @@ -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("") ); + sResult.append( _T("\n") ); + sResult.append( _T("") ); + sResult.append( m_sFileXml ); + sResult.append( _T("") ); + return sResult; +} diff --git a/RtfFile/OOXml/Writer/OOXNumberingWriter.h b/RtfFile/OOXml/Writer/OOXNumberingWriter.h index dc366eab47..7b23af853c 100644 --- a/RtfFile/OOXml/Writer/OOXNumberingWriter.h +++ b/RtfFile/OOXml/Writer/OOXNumberingWriter.h @@ -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("") ); - sResult.append( _T("\n") ); - sResult.append( _T("") ); - sResult.append( m_sFileXml ); - sResult.append( _T("") ); - return sResult; - } + std::wstring CreateXml(); }; diff --git a/RtfFile/OOXml/Writer/OOXRelsWriter.cpp b/RtfFile/OOXml/Writer/OOXRelsWriter.cpp new file mode 100644 index 0000000000..a9144e764f --- /dev/null +++ b/RtfFile/OOXml/Writer/OOXRelsWriter.cpp @@ -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("\n"); + + sResult += _T(""); + + for (size_t i = 0; i < m_aTargets.size(); i++ ) + { + sResult += _T(""); + } + sResult += _T(""); + 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; +} diff --git a/RtfFile/OOXml/Writer/OOXRelsWriter.h b/RtfFile/OOXml/Writer/OOXRelsWriter.h index ac314df9fb..5da2a23772 100644 --- a/RtfFile/OOXml/Writer/OOXRelsWriter.h +++ b/RtfFile/OOXml/Writer/OOXRelsWriter.h @@ -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("\n"); - - sResult += _T(""); - - for (size_t i = 0; i < m_aTargets.size(); i++ ) - { - sResult += _T(""); - } - sResult += _T(""); - 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 OOXRelsWriterPtr; diff --git a/RtfFile/OOXml/Writer/OOXSettingsWriter.cpp b/RtfFile/OOXml/Writer/OOXSettingsWriter.cpp new file mode 100644 index 0000000000..5d2a3bf1ad --- /dev/null +++ b/RtfFile/OOXml/Writer/OOXSettingsWriter.cpp @@ -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("") ); + sResult.append( _T("\n") ); + sResult.append( _T("") ); + sResult.append( m_sFileXml ); + sResult.append( _T("") ); + 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(""); + // //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(); +} diff --git a/RtfFile/OOXml/Writer/OOXSettingsWriter.h b/RtfFile/OOXml/Writer/OOXSettingsWriter.h index e2bf2eadf3..0bc073878b 100644 --- a/RtfFile/OOXml/Writer/OOXSettingsWriter.h +++ b/RtfFile/OOXml/Writer/OOXSettingsWriter.h @@ -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("") ); - sResult.append( _T("\n") ); - sResult.append( _T("") ); - sResult.append( m_sFileXml ); - sResult.append( _T("") ); - 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(""); - // //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(); }; diff --git a/RtfFile/OOXml/Writer/OOXStylesWriter.cpp b/RtfFile/OOXml/Writer/OOXStylesWriter.cpp new file mode 100644 index 0000000000..9820400cf5 --- /dev/null +++ b/RtfFile/OOXml/Writer/OOXStylesWriter.cpp @@ -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"" ); + sResult.append( L"\n" ); + sResult.append( L"" ); + sResult.append( m_sFileXml ); + sResult.append( L"" ); + return sResult; +} diff --git a/RtfFile/OOXml/Writer/OOXStylesWriter.h b/RtfFile/OOXml/Writer/OOXStylesWriter.h index 0f302e83cd..77c5dbeee8 100644 --- a/RtfFile/OOXml/Writer/OOXStylesWriter.h +++ b/RtfFile/OOXml/Writer/OOXStylesWriter.h @@ -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"" ); - sResult.append( L"\n" ); - sResult.append( L"" ); - sResult.append( m_sFileXml ); - sResult.append( L"" ); - return sResult; - } + std::wstring CreateXml(); }; diff --git a/RtfFile/OOXml/Writer/OOXThemeWriter.cpp b/RtfFile/OOXml/Writer/OOXThemeWriter.cpp new file mode 100644 index 0000000000..252199c9f2 --- /dev/null +++ b/RtfFile/OOXml/Writer/OOXThemeWriter.cpp @@ -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; +} diff --git a/RtfFile/OOXml/Writer/OOXThemeWriter.h b/RtfFile/OOXml/Writer/OOXThemeWriter.h index 38bab70607..49d20dcf22 100644 --- a/RtfFile/OOXml/Writer/OOXThemeWriter.h +++ b/RtfFile/OOXml/Writer/OOXThemeWriter.h @@ -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 доделать очистку поле ошибок }; diff --git a/RtfFile/Projects/Linux/RtfFormatLib.pro b/RtfFile/Projects/Linux/RtfFormatLib.pro index 046af54cc1..7c6d21e883 100644 --- a/RtfFile/Projects/Linux/RtfFormatLib.pro +++ b/RtfFile/Projects/Linux/RtfFormatLib.pro @@ -68,7 +68,16 @@ SOURCES += \ ../../OOXml/Reader/OOXTextItemReader.cpp \ \ ../../OOXml/Writer/OOXDocumentWriter.cpp \ - ../../OOXml/Writer/OOXWriter.cpp + ../../OOXml/Writer/OOXWriter.cpp \ + ../../OOXml/Writer/OOXCommentsWriter.cpp \ + ../../OOXml/Writer/OOXContentTypesWriter.cpp \ + ../../OOXml/Writer/OOXFontTableWriter.cpp \ + ../../OOXml/Writer/OOXFootnoteWriter.cpp \ + ../../OOXml/Writer/OOXNumberingWriter.cpp \ + ../../OOXml/Writer/OOXRelsWriter.cpp \ + ../../OOXml/Writer/OOXSettingsWriter.cpp \ + ../../OOXml/Writer/OOXStylesWriter.cpp \ + ../../OOXml/Writer/OOXThemeWriter.cpp } SOURCES += \ @@ -164,4 +173,5 @@ HEADERS += \ ../../OOXml/Writer/OOXSettingsWriter.h \ ../../OOXml/Writer/OOXStylesWriter.h \ ../../OOXml/Writer/OOXThemeWriter.h \ - ../../OOXml/Writer/OOXWriter.h + ../../OOXml/Writer/OOXWriter.h \ + ../../OOXml/Writer/OOXCommentsWriter.h diff --git a/RtfFile/Projects/Linux/rtffile_source.cpp b/RtfFile/Projects/Linux/rtffile_source.cpp index 486cde2b6b..d8b996824b 100644 --- a/RtfFile/Projects/Linux/rtffile_source.cpp +++ b/RtfFile/Projects/Linux/rtffile_source.cpp @@ -67,3 +67,13 @@ #include "../../OOXml/Writer/OOXDocumentWriter.cpp" #include "../../OOXml/Writer/OOXWriter.cpp" +#include "../../OOXml/Writer/OOXCommentsWriter.cpp" +#include "../../OOXml/Writer/OOXContentTypesWriter.cpp" +#include "../../OOXml/Writer/OOXFontTableWriter.cpp" +#include "../../OOXml/Writer/OOXFootnoteWriter.cpp" +#include "../../OOXml/Writer/OOXNumberingWriter.cpp" +#include "../../OOXml/Writer/OOXRelsWriter.cpp" +#include "../../OOXml/Writer/OOXSettingsWriter.cpp" +#include "../../OOXml/Writer/OOXStylesWriter.cpp" +#include "../../OOXml/Writer/OOXThemeWriter.cpp" +