mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
60 Commits
v99.99.99.
...
v7.2.0.28
| Author | SHA1 | Date | |
|---|---|---|---|
| bb657dc536 | |||
| 3b581bf5e3 | |||
| 5bd69e0b73 | |||
| 5510223302 | |||
| 78b7fcd7ae | |||
| fee2eb653f | |||
| 8bc77fa710 | |||
| e111568c34 | |||
| 500a32a1dc | |||
| 5387175ed1 | |||
| 63a3da31a9 | |||
| 8555b7d5fe | |||
| 18de7c5da1 | |||
| 5e052325ea | |||
| ffebbbe0af | |||
| 03b25199d9 | |||
| 1569b58dab | |||
| a2614b0020 | |||
| 01d20d1b13 | |||
| f4c6818570 | |||
| 709ac68a97 | |||
| c6a4f83a9d | |||
| d7bd15b4e2 | |||
| 1937f47043 | |||
| f2b19e9701 | |||
| 9cbbca4712 | |||
| 319c9d3522 | |||
| a33cf2fc7f | |||
| 830aee3ae4 | |||
| 9ae72e5a74 | |||
| 92e3d6d3cc | |||
| a6fd52ae70 | |||
| 089f817962 | |||
| 97653a5be7 | |||
| 9c81eb5bd1 | |||
| 543c5a59d9 | |||
| 3517208b92 | |||
| 172308579a | |||
| 9860be4434 | |||
| 8ae061d50b | |||
| 00de58f59d | |||
| 98ad73ce7d | |||
| 7f12d47f7b | |||
| df1bac754b | |||
| be72b15872 | |||
| 700e91629d | |||
| 95e747e400 | |||
| 1ba4412bd4 | |||
| 6d69fc21d5 | |||
| 53a0196dea | |||
| 2e3e75a39c | |||
| 525f318e17 | |||
| a3d083e7bd | |||
| 2267f1bca2 | |||
| 85baa9afc7 | |||
| 8f97f55e67 | |||
| 19070ca5c9 | |||
| 32ac61f890 | |||
| ce2727862d | |||
| b1a044ba14 |
@ -55,7 +55,6 @@ namespace DocFileFormat
|
||||
{
|
||||
m_context->_docx->RegisterComments();
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?");
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:comments", TRUE );
|
||||
|
||||
m_pXmlWriter->WriteAttribute( L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
|
||||
@ -148,7 +147,6 @@ namespace DocFileFormat
|
||||
{
|
||||
m_context->_docx->RegisterCommentsExtended();
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?");
|
||||
m_pXmlWriter->WriteNodeBegin( L"w15:commentsEx", TRUE );
|
||||
|
||||
m_pXmlWriter->WriteAttribute( L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
|
||||
|
||||
@ -91,7 +91,6 @@ namespace DocFileFormat
|
||||
doc->listTable->Convert( &numberingMapping );
|
||||
}
|
||||
|
||||
|
||||
//write the footnotes
|
||||
FootnotesMapping footnotesMapping( &context );
|
||||
doc->Convert( &footnotesMapping );
|
||||
|
||||
@ -54,7 +54,6 @@ namespace DocFileFormat
|
||||
|
||||
int id = 0;
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?");
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:endnotes", TRUE );
|
||||
|
||||
//write namespaces
|
||||
|
||||
@ -52,7 +52,6 @@ namespace DocFileFormat
|
||||
|
||||
_ctx->_docx->RegisterFontTable();
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?" );
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:fonts", TRUE );
|
||||
m_pXmlWriter->WriteAttribute( L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
|
||||
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
|
||||
|
||||
@ -54,7 +54,6 @@ namespace DocFileFormat
|
||||
|
||||
int id = 0;
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?" );
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:footnotes", TRUE );
|
||||
|
||||
//write namespaces
|
||||
|
||||
@ -45,7 +45,6 @@ namespace DocFileFormat
|
||||
m_document = static_cast<WordDocument*>( visited );
|
||||
|
||||
//start the document
|
||||
m_pXmlWriter->WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?");
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:hdr", TRUE );
|
||||
|
||||
//write namespaces
|
||||
|
||||
@ -51,7 +51,6 @@ namespace DocFileFormat
|
||||
m_document = static_cast<WordDocument*>(visited);
|
||||
|
||||
// Header
|
||||
m_pXmlWriter->WriteNodeBegin(L"?xml version=\"1.0\" encoding=\"UTF-8\"?");
|
||||
m_pXmlWriter->WriteNodeBegin(L"w:document", TRUE );
|
||||
|
||||
// Namespaces
|
||||
|
||||
@ -63,7 +63,6 @@ namespace DocFileFormat
|
||||
m_xmldocument->RegisterNumbering();
|
||||
|
||||
//start the document
|
||||
m_pXmlWriter->WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?" );
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:numbering", TRUE );
|
||||
|
||||
//write namespaces
|
||||
|
||||
@ -108,6 +108,8 @@ namespace DocFileFormat
|
||||
std::wstring pathFileName = outputDir + FILE_SEPARATOR_STR + fileName;
|
||||
if (file.CreateFileW(pathFileName))
|
||||
{
|
||||
std::string root = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
|
||||
file.WriteFile((BYTE*)root.c_str(), root.length());
|
||||
file.WriteStringUTF8(XMLContent);
|
||||
file.CloseFile();
|
||||
}
|
||||
@ -397,7 +399,6 @@ namespace DocFileFormat
|
||||
{
|
||||
XMLTools::CStringXmlWriter writer;
|
||||
|
||||
writer.WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?" );
|
||||
writer.WriteNodeBegin( L"Relationships", TRUE );
|
||||
|
||||
//write namespaces
|
||||
@ -433,7 +434,6 @@ namespace DocFileFormat
|
||||
XMLTools::CStringXmlWriter writer;
|
||||
|
||||
// write content types
|
||||
writer.WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?");
|
||||
writer.WriteNodeBegin( L"Types", TRUE );
|
||||
|
||||
//write namespaces
|
||||
|
||||
@ -76,7 +76,6 @@ namespace DocFileFormat
|
||||
_ctx->_docx->RegisterSettings();
|
||||
|
||||
//start w:settings
|
||||
m_oXmlWriter.WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?" );
|
||||
m_oXmlWriter.WriteNodeBegin( L"w:settings", TRUE );
|
||||
//write namespaces
|
||||
m_oXmlWriter.WriteAttribute( L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
|
||||
|
||||
@ -60,7 +60,6 @@ namespace DocFileFormat
|
||||
this->_ctx->_docx->RegisterStyleSheet();
|
||||
|
||||
//start the document
|
||||
m_pXmlWriter->WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?" );
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:styles", TRUE );
|
||||
|
||||
//write namespaces
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
#include "../../Common/OfficeFileErrorDescription.h"
|
||||
#include "../../Common/MS-LCID.h"
|
||||
|
||||
#include "../../ASCOfficeXlsFile2/source/XlsFormat/Logic/SummaryInformationStream/SummaryInformation.h"
|
||||
#include "../../ASCOfficeXlsFile2/source/XlsFormat/Logic/SummaryInformationStream/PropertySetStream.h"
|
||||
#include "../../ASCOfficeXlsFile2/source/XlsFormat/Binary/CFStream.h"
|
||||
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
@ -240,17 +240,20 @@ namespace DocFileFormat
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
POLE::Stream * Summary = NULL;
|
||||
POLE::Stream * DocSummary = NULL;
|
||||
POLE::Stream * Summary = NULL;
|
||||
POLE::Stream * DocSummary = NULL;
|
||||
|
||||
m_pStorage->GetStream (L"SummaryInformation", &Summary);
|
||||
m_pStorage->GetStream (L"DocumentSummaryInformation", &DocSummary);
|
||||
|
||||
OLEPS::PropertySetStream summary_info;
|
||||
|
||||
if ((Summary) && (Summary->size() > 0))
|
||||
{
|
||||
XLS::CFStreamPtr stream = XLS::CFStreamPtr(new XLS::CFStream(Summary));
|
||||
OLEPS::SummaryInformation summary_info(stream);
|
||||
int document_code_page1 = summary_info.GetCodePage(); //from software last open
|
||||
XLS::CFStreamPtr stream = XLS::CFStreamPtr(new XLS::CFStream(Summary));
|
||||
summary_info.read(stream);
|
||||
|
||||
int document_code_page1 = summary_info.GetCodePage();
|
||||
|
||||
if (document_code_page1 > 0)
|
||||
{
|
||||
@ -261,8 +264,9 @@ namespace DocFileFormat
|
||||
if ((DocSummary) && (DocSummary->size() > 0))
|
||||
{
|
||||
XLS::CFStreamPtr stream = XLS::CFStreamPtr(new XLS::CFStream(DocSummary));
|
||||
OLEPS::SummaryInformation doc_summary_info(stream);
|
||||
int document_code_page2 = doc_summary_info.GetCodePage();
|
||||
summary_info.read(stream, true);
|
||||
|
||||
int document_code_page2 = summary_info.GetCodePage();
|
||||
|
||||
if (document_code_page2 > 0)
|
||||
{
|
||||
@ -288,6 +292,8 @@ namespace DocFileFormat
|
||||
nDocumentCodePage = user_codepage;
|
||||
}
|
||||
}
|
||||
m_sXmlApp = summary_info.GetApp();
|
||||
m_sXmlCore = summary_info.GetCore();
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
try
|
||||
{
|
||||
|
||||
@ -88,7 +88,7 @@ namespace DocFileFormat
|
||||
friend class OpenXmlPackage;
|
||||
friend class TextboxMapping;
|
||||
friend class SettingsMapping;
|
||||
|
||||
friend class WordprocessingDocument;
|
||||
public:
|
||||
|
||||
WordDocument (const std::wstring & tempFolder, const int userLCID);
|
||||
@ -153,6 +153,8 @@ namespace DocFileFormat
|
||||
std::wstring m_sTempFolder;
|
||||
std::wstring m_sTempDecryptFileName;
|
||||
int m_nUserLCID;
|
||||
std::wstring m_sXmlApp;
|
||||
std::wstring m_sXmlCore;
|
||||
|
||||
POLE::Stream * WordDocumentStream; // The stream "WordDocument"
|
||||
POLE::Stream * TableStream; // The stream "0Table" or "1Table"
|
||||
|
||||
@ -72,7 +72,6 @@ namespace DocFileFormat
|
||||
|
||||
RegisterDocumentMacros();
|
||||
RegisterVbaProject();
|
||||
//output_document->get_xl_files().add_vba_project();
|
||||
}
|
||||
else bMacros = false;
|
||||
}
|
||||
@ -84,54 +83,68 @@ namespace DocFileFormat
|
||||
RegisterDocument();
|
||||
}
|
||||
OOX::CContentTypes oContentTypes;
|
||||
OOX::CPath pathDocProps = m_strOutputPath + FILE_SEPARATOR_STR + _T("docProps");
|
||||
OOX::CPath pathDocProps = m_strOutputPath + FILE_SEPARATOR_STR + L"docProps";
|
||||
NSDirectory::CreateDirectory(pathDocProps.GetPath());
|
||||
|
||||
OOX::CPath DocProps = std::wstring(_T("docProps"));
|
||||
OOX::CPath DocProps = std::wstring(L"docProps");
|
||||
|
||||
OOX::CApp* pApp = new OOX::CApp(NULL);
|
||||
if (pApp)
|
||||
if (docFile->m_sXmlApp.empty())
|
||||
{
|
||||
std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvApplicationName);
|
||||
if (sApplication.empty())
|
||||
sApplication = NSSystemUtils::gc_EnvApplicationNameDefault;
|
||||
pApp->SetApplication(sApplication);
|
||||
#if defined(INTVER)
|
||||
pApp->SetAppVersion(VALUE2STR(INTVER));
|
||||
#endif
|
||||
pApp->SetDocSecurity(0);
|
||||
pApp->SetScaleCrop(false);
|
||||
pApp->SetLinksUpToDate(false);
|
||||
pApp->SetSharedDoc(false);
|
||||
pApp->SetHyperlinksChanged(false);
|
||||
|
||||
pApp->write(pathDocProps + FILE_SEPARATOR_STR + _T("app.xml"), DocProps, oContentTypes);
|
||||
delete pApp;
|
||||
}
|
||||
OOX::CCore* pCore = new OOX::CCore(NULL);
|
||||
if (pCore)
|
||||
OOX::CApp* pApp = new OOX::CApp(NULL);
|
||||
if (pApp)
|
||||
{
|
||||
std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvApplicationName);
|
||||
if (sApplication.empty())
|
||||
sApplication = NSSystemUtils::gc_EnvApplicationNameDefault;
|
||||
pApp->SetApplication(sApplication);
|
||||
#if defined(INTVER)
|
||||
pApp->SetAppVersion(VALUE2STR(INTVER));
|
||||
#endif
|
||||
pApp->SetDocSecurity(0);
|
||||
pApp->SetScaleCrop(false);
|
||||
pApp->SetLinksUpToDate(false);
|
||||
pApp->SetSharedDoc(false);
|
||||
pApp->SetHyperlinksChanged(false);
|
||||
|
||||
pApp->write(pathDocProps + FILE_SEPARATOR_STR + L"app.xml", DocProps, oContentTypes);
|
||||
delete pApp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pCore->SetCreator(_T(""));
|
||||
pCore->SetLastModifiedBy(_T(""));
|
||||
pCore->write(pathDocProps + FILE_SEPARATOR_STR + _T("core.xml"), DocProps, oContentTypes);
|
||||
delete pCore;
|
||||
}
|
||||
SaveToFile(pathDocProps.GetPath(), L"app.xml", docFile->m_sXmlApp);
|
||||
}
|
||||
if (docFile->m_sXmlCore.empty())
|
||||
{
|
||||
OOX::CCore* pCore = new OOX::CCore(NULL);
|
||||
if (pCore)
|
||||
{
|
||||
pCore->SetCreator(L"");
|
||||
pCore->SetLastModifiedBy(L"");
|
||||
pCore->write(pathDocProps + FILE_SEPARATOR_STR + L"core.xml", DocProps, oContentTypes);
|
||||
delete pCore;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SaveToFile(pathDocProps.GetPath(), L"core.xml", docFile->m_sXmlCore);
|
||||
}
|
||||
RegisterDocPr();
|
||||
|
||||
WritePackage();
|
||||
|
||||
//Write main content. (word directory)
|
||||
|
||||
SaveToFile(pathWord, std::wstring( L"document.xml" ), DocumentXML );
|
||||
SaveToFile(pathWord, std::wstring( L"fontTable.xml" ), FontTableXML );
|
||||
SaveToFile(pathWord, std::wstring( L"styles.xml" ), StyleSheetXML );
|
||||
SaveToFile(pathWord, std::wstring( L"footnotes.xml" ), FootnotesXML );
|
||||
SaveToFile(pathWord, std::wstring( L"endnotes.xml" ), EndnotesXML );
|
||||
SaveToFile(pathWord, std::wstring( L"numbering.xml" ), NumberingXML );
|
||||
SaveToFile(pathWord, std::wstring( L"comments.xml" ), CommentsXML );
|
||||
SaveToFile(pathWord, std::wstring( L"commentsExtended.xml"),CommentsExtendedXML );
|
||||
SaveToFile(pathWord, std::wstring( L"settings.xml" ), SettingsXML );
|
||||
SaveToFile(pathWord, std::wstring( L"customizations.xml" ), CommandTableXML );
|
||||
SaveToFile(pathWord, L"document.xml", DocumentXML );
|
||||
SaveToFile(pathWord, L"fontTable.xml", FontTableXML );
|
||||
SaveToFile(pathWord, L"styles.xml", StyleSheetXML );
|
||||
SaveToFile(pathWord, L"footnotes.xml", FootnotesXML );
|
||||
SaveToFile(pathWord, L"endnotes.xml", EndnotesXML );
|
||||
SaveToFile(pathWord, L"numbering.xml", NumberingXML );
|
||||
SaveToFile(pathWord, L"comments.xml", CommentsXML );
|
||||
SaveToFile(pathWord, L"commentsExtended.xml", CommentsExtendedXML );
|
||||
SaveToFile(pathWord, L"settings.xml", SettingsXML );
|
||||
SaveToFile(pathWord, L"customizations.xml", CommandTableXML );
|
||||
|
||||
if (!ImagesList.empty())
|
||||
{
|
||||
@ -173,12 +186,12 @@ namespace DocFileFormat
|
||||
|
||||
for (std::list<std::wstring>::iterator iter = HeaderXMLList.begin(); iter != HeaderXMLList.end(); ++iter)
|
||||
{
|
||||
SaveToFile(pathWord, ( std::wstring( L"header" ) + FormatUtils::IntToWideString(++headersCount) + std::wstring( L".xml" ) ), *iter);
|
||||
SaveToFile(pathWord, ( L"header" + FormatUtils::IntToWideString(++headersCount) + L".xml"), *iter);
|
||||
}
|
||||
|
||||
for (std::list<std::wstring>::iterator iter = FooterXMLList.begin(); iter != FooterXMLList.end(); ++iter)
|
||||
{
|
||||
SaveToFile(pathWord, ( std::wstring( L"footer" ) + FormatUtils::IntToWideString(++footersCount) + std::wstring( L".xml" ) ), *iter);
|
||||
SaveToFile(pathWord, ( L"footer" + FormatUtils::IntToWideString(++footersCount) + L".xml" ), *iter);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -35,6 +35,8 @@
|
||||
#include "../../Common/Base64.h"
|
||||
#include "../../Common/OfficeFileFormatChecker.h"
|
||||
|
||||
#include "../../ASCOfficeXlsFile2/source/VbaFormat/VbaReader.h"
|
||||
|
||||
#include "../../ASCOfficePPTXFile/Editor/FontCutter.h"
|
||||
#include "../../ASCOfficePPTXFile/PPTXFormat/App.h"
|
||||
#include "../../ASCOfficePPTXFile/PPTXFormat/Core.h"
|
||||
@ -9329,6 +9331,18 @@ void BinaryFileWriter::intoBindoc(const std::wstring& sDir)
|
||||
m_oBcw.m_oStream.EndRecord();
|
||||
|
||||
this->WriteTableEnd(nCurPos);
|
||||
|
||||
CVbaReader vbaReader(pDocx->m_pVbaProject->filename().GetPath(), L"");
|
||||
std::wstring sXml = vbaReader.convert();
|
||||
|
||||
if (false == sXml.empty())
|
||||
{
|
||||
m_oBcw.m_oStream.StartRecord(1);
|
||||
m_oBcw.m_oStream.WriteStringW(sXml);
|
||||
m_oBcw.m_oStream.EndRecord();
|
||||
}
|
||||
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -116,6 +116,7 @@ enum ElementType
|
||||
typeDcDescription,
|
||||
typeDcSubject,
|
||||
typeDcTitle,
|
||||
typeDcLanguage,
|
||||
|
||||
typeDrawA,
|
||||
|
||||
@ -449,6 +450,9 @@ enum ElementType
|
||||
typeOfficeMetaKeyword,
|
||||
typeOfficeMetaEditingCycles,
|
||||
typeOfficeMetaEditingDuration,
|
||||
typeOfficeMetaCommon,
|
||||
typeOfficeMetaInitialCreator,
|
||||
typeOfficeMetaTemplate,
|
||||
|
||||
typeDrawBase,
|
||||
typeDrawG,
|
||||
|
||||
@ -51,6 +51,7 @@
|
||||
#include "oox_rels.h"
|
||||
#include "../../include/logging.h"
|
||||
|
||||
#include "../../../DesktopEditor/common/SystemUtils.h"
|
||||
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
#include "../../../Common/DocxFormat/Source/XML/Utils.h"
|
||||
|
||||
@ -744,7 +745,10 @@ void docx_conversion_context::end_document()
|
||||
get_mediaitems()->dump_rels(notes_context_.endnotesRels(), oox::endnote_place);
|
||||
|
||||
output_document_->get_word_files().set_notes(notes_context_);
|
||||
////////////////////////
|
||||
|
||||
output_document_->get_docProps_files().set_app(package::simple_element::create(L"app.xml", dump_settings_app()));
|
||||
output_document_->get_docProps_files().set_core(package::simple_element::create(L"core.xml", dump_settings_core()));
|
||||
|
||||
for (size_t i = 0; i < charts_.size(); i++)
|
||||
{
|
||||
package::chart_content_ptr content = package::chart_content::create();
|
||||
@ -755,10 +759,7 @@ void docx_conversion_context::end_document()
|
||||
output_document_->get_word_files().add_charts(content);
|
||||
|
||||
}
|
||||
////////////////////////////////
|
||||
output_document_->get_word_files().update_rels(*this);
|
||||
/////////////////////////////////////
|
||||
|
||||
}
|
||||
void docx_conversion_context::dump_bibliography()
|
||||
{
|
||||
@ -814,12 +815,185 @@ void docx_conversion_context::dump_bibliography()
|
||||
const std::wstring sFileRef = std::wstring(L"../customXml/item") + std::to_wstring(id) + L".xml";
|
||||
|
||||
output_document_->get_word_files().add_rels(relationship(sRId, sRel, sFileRef));
|
||||
|
||||
}
|
||||
std::wstring docx_conversion_context::dump_settings_app()
|
||||
{
|
||||
std::wstringstream output;
|
||||
CP_XML_WRITER(output)
|
||||
{
|
||||
CP_XML_NODE(L"Properties")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties");
|
||||
CP_XML_ATTR(L"xmlns:vt", L"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes");
|
||||
|
||||
if (!odf_document_->odf_context().DocProps().template_.empty())
|
||||
{
|
||||
CP_XML_NODE(L"Template")
|
||||
{
|
||||
CP_XML_STREAM() << odf_document_->odf_context().DocProps().template_;
|
||||
}
|
||||
}
|
||||
if (odf_document_->odf_context().DocProps().revision_)
|
||||
{
|
||||
CP_XML_NODE(L"TotalTime")
|
||||
{
|
||||
CP_XML_STREAM() << *odf_document_->odf_context().DocProps().revision_;
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"Application")
|
||||
{
|
||||
if (!odf_document_->odf_context().DocProps().application_.empty())
|
||||
{
|
||||
CP_XML_STREAM() << odf_document_->odf_context().DocProps().application_;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvApplicationName);
|
||||
if (sApplication.empty())
|
||||
sApplication = NSSystemUtils::gc_EnvApplicationNameDefault;
|
||||
CP_XML_STREAM() << sApplication;
|
||||
#if defined(INTVER)
|
||||
std::string s = VALUE2STR(INTVER);
|
||||
CP_XML_STREAM() << L"/" << std::wstring(s.begin(), s.end());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (odf_document_->odf_context().DocProps().page_count_)
|
||||
{
|
||||
CP_XML_NODE(L"Pages")
|
||||
{
|
||||
CP_XML_STREAM() << *odf_document_->odf_context().DocProps().page_count_;
|
||||
}
|
||||
}
|
||||
if (odf_document_->odf_context().DocProps().word_count_)
|
||||
{
|
||||
CP_XML_NODE(L"Words")
|
||||
{
|
||||
CP_XML_STREAM() << *odf_document_->odf_context().DocProps().word_count_;
|
||||
}
|
||||
}
|
||||
if (odf_document_->odf_context().DocProps().character_count_)
|
||||
{
|
||||
CP_XML_NODE(L"CharactersWithSpaces")
|
||||
{
|
||||
CP_XML_STREAM() << *odf_document_->odf_context().DocProps().character_count_;
|
||||
}
|
||||
}
|
||||
if (odf_document_->odf_context().DocProps().non_whitespace_character_count_)
|
||||
{
|
||||
CP_XML_NODE(L"Characters")
|
||||
{
|
||||
CP_XML_STREAM() << *odf_document_->odf_context().DocProps().non_whitespace_character_count_;
|
||||
}
|
||||
}
|
||||
if (odf_document_->odf_context().DocProps().paragraph_count_)
|
||||
{
|
||||
CP_XML_NODE(L"Paragraphs")
|
||||
{
|
||||
CP_XML_STREAM() << *odf_document_->odf_context().DocProps().paragraph_count_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return output.str();
|
||||
}
|
||||
std::wstring docx_conversion_context::dump_settings_core()
|
||||
{
|
||||
std::wstringstream output;
|
||||
|
||||
CP_XML_WRITER(output)
|
||||
{
|
||||
CP_XML_NODE(L"cp:coreProperties")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns:cp", L"http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
|
||||
CP_XML_ATTR(L"xmlns:xsi", L"http://www.w3.org/2001/XMLSchema-instance");
|
||||
CP_XML_ATTR(L"xmlns:dc", L"http://purl.org/dc/elements/1.1/");
|
||||
CP_XML_ATTR(L"xmlns:dcmitype", L"http://purl.org/dc/dcmitype/");
|
||||
CP_XML_ATTR(L"xmlns:dcterms", L"http://purl.org/dc/terms/");
|
||||
|
||||
if (!odf_document_->odf_context().DocProps().creation_date_.empty())
|
||||
{
|
||||
CP_XML_NODE(L"dcterms:created")
|
||||
{
|
||||
CP_XML_ATTR(L"xsi:type", L"dcterms:W3CDTF");
|
||||
CP_XML_STREAM() << odf_document_->odf_context().DocProps().creation_date_;
|
||||
}
|
||||
}
|
||||
if (!odf_document_->odf_context().DocProps().dc_date_.empty())
|
||||
{
|
||||
CP_XML_NODE(L"dcterms:modified")
|
||||
{
|
||||
CP_XML_ATTR(L"xsi:type", L"dcterms:W3CDTF");
|
||||
CP_XML_STREAM() << odf_document_->odf_context().DocProps().dc_date_;
|
||||
}
|
||||
}
|
||||
if (!odf_document_->odf_context().DocProps().dc_creator_.empty())
|
||||
{
|
||||
CP_XML_NODE(L"dc:creator")
|
||||
{
|
||||
CP_XML_STREAM() << odf_document_->odf_context().DocProps().dc_creator_;
|
||||
}
|
||||
}
|
||||
if (!odf_document_->odf_context().DocProps().dc_title_.empty())
|
||||
{
|
||||
CP_XML_NODE(L"dc:title")
|
||||
{
|
||||
CP_XML_STREAM() << odf_document_->odf_context().DocProps().dc_title_;
|
||||
}
|
||||
}
|
||||
if (!odf_document_->odf_context().DocProps().dc_subject_.empty())
|
||||
{
|
||||
CP_XML_NODE(L"dc:subject")
|
||||
{
|
||||
CP_XML_STREAM() << odf_document_->odf_context().DocProps().dc_subject_;
|
||||
}
|
||||
}
|
||||
if (!odf_document_->odf_context().DocProps().dc_description_.empty())
|
||||
{
|
||||
CP_XML_NODE(L"dc:description")
|
||||
{
|
||||
CP_XML_STREAM() << odf_document_->odf_context().DocProps().dc_description_;
|
||||
}
|
||||
}
|
||||
if (!odf_document_->odf_context().DocProps().dc_language_.empty())
|
||||
{
|
||||
CP_XML_NODE(L"dc:language")
|
||||
{
|
||||
CP_XML_STREAM() << odf_document_->odf_context().DocProps().dc_language_;
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"cp:lastModifiedBy")
|
||||
{
|
||||
std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvApplicationName);
|
||||
if (sApplication.empty())
|
||||
sApplication = NSSystemUtils::gc_EnvApplicationNameDefault;
|
||||
CP_XML_STREAM() << sApplication;
|
||||
#if defined(INTVER)
|
||||
std::string s = VALUE2STR(INTVER);
|
||||
CP_XML_STREAM() << L"/" << std::wstring(s.begin(), s.end());
|
||||
#endif
|
||||
}
|
||||
if (!odf_document_->odf_context().DocProps().keyword_.empty())
|
||||
{
|
||||
CP_XML_NODE(L"cp:keywords")
|
||||
{
|
||||
CP_XML_STREAM() << odf_document_->odf_context().DocProps().keyword_;
|
||||
}
|
||||
}
|
||||
if (odf_document_->odf_context().DocProps().revision_)
|
||||
{
|
||||
CP_XML_NODE(L"cp:revision")
|
||||
{
|
||||
CP_XML_STREAM() << *odf_document_->odf_context().DocProps().revision_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return output.str();
|
||||
}
|
||||
std::wstring docx_conversion_context::dump_settings_document()
|
||||
{
|
||||
std::wstringstream output(L"");
|
||||
std::wstringstream output;
|
||||
CP_XML_WRITER(output)
|
||||
{
|
||||
CP_XML_NODE(L"w:settings")
|
||||
|
||||
@ -795,7 +795,10 @@ public:
|
||||
_rels_type_place get_type_place();
|
||||
|
||||
void dump_bibliography();
|
||||
|
||||
std::wstring dump_settings_document();
|
||||
std::wstring dump_settings_app();
|
||||
std::wstring dump_settings_core();
|
||||
|
||||
bool next_dump_page_properties_;
|
||||
bool next_dump_section_;
|
||||
@ -998,7 +1001,7 @@ private:
|
||||
std::vector< const odf_reader::style_text_properties*> text_properties_stack_;
|
||||
}state_;
|
||||
std::vector<_context_state> keep_state_;
|
||||
|
||||
//---------------------------------------------------------
|
||||
std::wstringstream document_xml_;
|
||||
std::wstringstream styles_xml_;
|
||||
std::wstringstream fontTable_xml_;
|
||||
@ -1010,7 +1013,7 @@ private:
|
||||
std::wstringstream header_xml_;
|
||||
std::wstringstream settings_xml_;
|
||||
std::wstringstream meta_xml_;
|
||||
|
||||
//--------------------------------------------------------------
|
||||
xlsx_drawing_context_handle_ptr chart_drawing_handle_;
|
||||
|
||||
styles_context styles_context_;
|
||||
|
||||
@ -509,7 +509,7 @@ docx_document::docx_document()
|
||||
relationship(L"rId3", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", L"word/document.xml" )
|
||||
);
|
||||
|
||||
rels_files_.add_rel_file( relFile );
|
||||
get_rels_files().add_rel_file( relFile );
|
||||
|
||||
}
|
||||
int docx_document::add_customXml(customXml_content_ptr customXml)
|
||||
@ -523,10 +523,10 @@ void docx_document::write(const std::wstring & RootPath)
|
||||
content_type_file_.content()->get_override().push_back( override_content_type(L"/word/numbering.xml",
|
||||
L"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml") );
|
||||
}
|
||||
customXml_files_.write (RootPath);
|
||||
word_files_.write (RootPath);
|
||||
rels_files_.write (RootPath);
|
||||
docProps_files_.write (RootPath);
|
||||
customXml_files_.write (RootPath);
|
||||
word_files_.write (RootPath);
|
||||
get_rels_files().write (RootPath);
|
||||
get_docProps_files().write (RootPath);
|
||||
content_type_file_.write(RootPath);
|
||||
}
|
||||
|
||||
|
||||
@ -134,7 +134,7 @@ public:
|
||||
void set_fontTable (element_ptr Element);
|
||||
void set_numbering (element_ptr Element);
|
||||
void set_settings (element_ptr Element);
|
||||
bool has_numbering ();
|
||||
bool has_numbering ();
|
||||
void set_media (mediaitems_ptr & mediaitems_);
|
||||
void set_headers_footers(headers_footers & HeadersFooters);
|
||||
void set_notes (notes_context & notesContext);
|
||||
@ -183,8 +183,6 @@ private:
|
||||
docx_content_types_file content_type_file_;
|
||||
word_files word_files_;
|
||||
customXml_files customXml_files_;
|
||||
rels_files rels_files_;
|
||||
docProps_files docProps_files_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -312,8 +312,11 @@ simple_element_ptr simple_element::create(const std::wstring & FileName, const s
|
||||
return boost::make_shared<simple_element>(FileName, Content);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
docProps_files::docProps_files()
|
||||
{
|
||||
|
||||
void core_file::write(const std::wstring & RootPath)
|
||||
}
|
||||
std::wstring docProps_files::create_core()
|
||||
{
|
||||
std::wstringstream resStream;
|
||||
|
||||
@ -321,16 +324,13 @@ void core_file::write(const std::wstring & RootPath)
|
||||
L"xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcmitype=\"http://purl.org/dc/dcmitype/\" "
|
||||
L"xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" >";
|
||||
|
||||
//resStream << L"<dc:creator>ONLYOFFICE</dc:creator>";
|
||||
//resStream << L"<cp:lastModifiedBy>ONLYOFFICE</cp:lastModifiedBy>";
|
||||
resStream << L"<cp:revision>1</cp:revision>";
|
||||
resStream << L"</cp:coreProperties>";
|
||||
|
||||
simple_element elm(L"core.xml", resStream.str());
|
||||
elm.write(RootPath);
|
||||
return resStream.str();
|
||||
}
|
||||
|
||||
void app_file::write(const std::wstring & RootPath)
|
||||
std::wstring docProps_files::create_app()
|
||||
{
|
||||
std::wstringstream resStream;
|
||||
|
||||
@ -348,33 +348,31 @@ void app_file::write(const std::wstring & RootPath)
|
||||
#endif
|
||||
resStream << L"</Application></Properties>";
|
||||
|
||||
simple_element elm(L"app.xml", resStream.str());
|
||||
elm.write(RootPath);
|
||||
return resStream.str();
|
||||
}
|
||||
|
||||
////////////
|
||||
|
||||
docProps_files::docProps_files()
|
||||
void docProps_files::set_app(element_ptr Element)
|
||||
{
|
||||
|
||||
app_ = Element;
|
||||
}
|
||||
void docProps_files::set_core(element_ptr Element)
|
||||
{
|
||||
core_ = Element;
|
||||
}
|
||||
|
||||
void docProps_files::write(const std::wstring & RootPath)
|
||||
{
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"docProps";
|
||||
NSDirectory::CreateDirectory(path.c_str());
|
||||
NSDirectory::CreateDirectory(path.c_str());
|
||||
|
||||
core_.write(path);
|
||||
app_.write(path);
|
||||
if (!core_) core_ = simple_element::create(L"core.xml", create_core());
|
||||
if (!app_) app_ = simple_element::create(L"app.xml", create_app());
|
||||
|
||||
core_->write(path);
|
||||
app_->write(path);
|
||||
}
|
||||
|
||||
////////////
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
media::media(mediaitems_ptr & _mediaitems, NSFonts::IApplicationFonts *pAppFonts) : mediaItems_(_mediaitems), appFonts_(pAppFonts)
|
||||
{
|
||||
}
|
||||
|
||||
void media::write(const std::wstring & RootPath)
|
||||
{
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"media";
|
||||
|
||||
@ -193,39 +193,35 @@ public:
|
||||
static _CP_PTR(chart_content) create();
|
||||
private:
|
||||
std::wstringstream content_;
|
||||
rels_file_ptr rels_;
|
||||
rels_file_ptr rels_;
|
||||
};
|
||||
//------------------------------------------------------------------------
|
||||
class document : public element
|
||||
{
|
||||
public:
|
||||
virtual content_types_file & get_content_types_file() = 0;
|
||||
};
|
||||
|
||||
class core_file : public element
|
||||
{
|
||||
public:
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
};
|
||||
|
||||
class app_file : public element
|
||||
{
|
||||
public:
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
};
|
||||
|
||||
class docProps_files : public element
|
||||
{
|
||||
public:
|
||||
docProps_files();
|
||||
|
||||
public:
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
void set_app(element_ptr Element);
|
||||
void set_core(element_ptr Element);
|
||||
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
|
||||
private:
|
||||
core_file core_;
|
||||
app_file app_;
|
||||
std::wstring create_app();
|
||||
std::wstring create_core();
|
||||
|
||||
element_ptr core_;
|
||||
element_ptr app_;
|
||||
};
|
||||
class document : public element
|
||||
{
|
||||
public:
|
||||
virtual content_types_file & get_content_types_file() = 0;
|
||||
docProps_files & get_docProps_files() { return docProps_files_; }
|
||||
rels_files & get_rels_files() { return rels_files_; }
|
||||
private:
|
||||
docProps_files docProps_files_;
|
||||
rels_files rels_files_;
|
||||
};
|
||||
|
||||
class media : public element
|
||||
|
||||
@ -68,15 +68,15 @@ pptx_document::pptx_document()
|
||||
relFile->get_rels().add(relationship(L"rId2", L"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties", L"docProps/core.xml"));
|
||||
relFile->get_rels().add(relationship(L"rId3", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties", L"docProps/app.xml"));
|
||||
|
||||
rels_files_.add_rel_file( relFile );
|
||||
get_rels_files().add_rel_file( relFile );
|
||||
}
|
||||
|
||||
void pptx_document::write(const std::wstring & RootPath)
|
||||
{
|
||||
ppt_files_.write (RootPath);
|
||||
docProps_files_.write (RootPath);
|
||||
rels_files_.write (RootPath);
|
||||
content_type_file_.write(RootPath);
|
||||
ppt_files_.write (RootPath);
|
||||
get_docProps_files().write (RootPath);
|
||||
get_rels_files().write (RootPath);
|
||||
content_type_file_.write (RootPath);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
||||
@ -259,11 +259,8 @@ public:
|
||||
ppt_files & get_ppt_files() { return ppt_files_; }
|
||||
|
||||
private:
|
||||
pptx_content_types_file content_type_file_;
|
||||
ppt_files ppt_files_;
|
||||
docProps_files docProps_files_;
|
||||
rels_files rels_files_;
|
||||
|
||||
ppt_files ppt_files_;
|
||||
pptx_content_types_file content_type_file_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -73,16 +73,16 @@ xlsx_document::xlsx_document()
|
||||
relFile->get_rels().add(relationship(L"rId2", L"http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties", L"docProps/core.xml"));
|
||||
relFile->get_rels().add(relationship(L"rId3", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties", L"docProps/app.xml"));
|
||||
|
||||
rels_files_.add_rel_file( relFile );
|
||||
get_rels_files().add_rel_file( relFile );
|
||||
}
|
||||
|
||||
void xlsx_document::write(const std::wstring & RootPath)
|
||||
{
|
||||
_CP_LOG << L"[info][xlsx] process writing" << std::endl;
|
||||
|
||||
xl_files_.write (RootPath);
|
||||
docProps_files_.write (RootPath);
|
||||
rels_files_.write (RootPath);
|
||||
xl_files_.write (RootPath);
|
||||
get_docProps_files().write (RootPath);
|
||||
get_rels_files().write (RootPath);
|
||||
content_type_file_.write(RootPath);
|
||||
}
|
||||
|
||||
|
||||
@ -337,13 +337,9 @@ public:
|
||||
|
||||
virtual content_types_file & get_content_types_file() { return content_type_file_; }
|
||||
xl_files & get_xl_files() { return xl_files_; }
|
||||
rels_files & get_rels_files() { return rels_files_; }
|
||||
private:
|
||||
xlsx_content_types_file content_type_file_;
|
||||
xl_files xl_files_;
|
||||
docProps_files docProps_files_;
|
||||
rels_files rels_files_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -683,7 +683,6 @@ void odf_document::Impl::parse_settings(office_element *element)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void odf_document::Impl::parse_meta(office_element *element)
|
||||
{
|
||||
office_document_base * document = dynamic_cast<office_document_base *>( element );
|
||||
@ -699,8 +698,60 @@ void odf_document::Impl::parse_meta(office_element *element)
|
||||
|
||||
if (user_defined->meta_name_.empty()) continue;
|
||||
|
||||
context_->Settings().add_user_defined(user_defined->meta_name_, user_defined->content_);
|
||||
context_->DocProps().add_user_defined(user_defined->meta_name_, user_defined->content_);
|
||||
}
|
||||
|
||||
dc_creator * dc_creator_ = dynamic_cast<dc_creator*>(meta->dc_creator_.get());
|
||||
if (dc_creator_)
|
||||
context_->DocProps().dc_creator_ = dc_creator_->content_;
|
||||
|
||||
dc_date * dc_date_ = dynamic_cast<dc_date*>(meta->dc_date_.get());
|
||||
if (dc_date_)
|
||||
context_->DocProps().dc_date_ = dc_date_->content_;
|
||||
|
||||
dc_description * dc_description_ = dynamic_cast<dc_description*>(meta->dc_description_.get());
|
||||
if (dc_description_)
|
||||
context_->DocProps().dc_description_ = dc_description_->content_;
|
||||
|
||||
dc_language * dc_language_ = dynamic_cast<dc_language*>(meta->dc_language_.get());
|
||||
if (dc_language_)
|
||||
context_->DocProps().dc_language_ = dc_language_->content_;
|
||||
|
||||
dc_subject * dc_subject_ = dynamic_cast<dc_subject*>(meta->dc_subject_.get());
|
||||
if (dc_subject_)
|
||||
context_->DocProps().dc_subject_ = dc_subject_->content_;
|
||||
|
||||
dc_title * dc_title_ = dynamic_cast<dc_title*>(meta->dc_title_.get());
|
||||
if (dc_title_)
|
||||
context_->DocProps().dc_title_ = dc_title_->content_;
|
||||
|
||||
meta_generator * meta_generator_ = dynamic_cast<meta_generator*>(meta->meta_generator_.get());
|
||||
if (meta_generator_)
|
||||
context_->DocProps().application_ = meta_generator_->content_;
|
||||
|
||||
meta_template * meta_template_ = dynamic_cast<meta_template*>(meta->meta_template_.get());
|
||||
if (meta_template_)
|
||||
context_->DocProps().template_ = meta_generator_->content_;
|
||||
|
||||
meta_creation_date * meta_creation_date_ = dynamic_cast<meta_creation_date*>(meta->meta_creation_date_.get());
|
||||
if (meta_generator_)
|
||||
context_->DocProps().creation_date_ = meta_creation_date_->content_;
|
||||
|
||||
meta_keyword * meta_keyword_ = dynamic_cast<meta_keyword*>(meta->meta_keyword_.get());
|
||||
if (meta_keyword_)
|
||||
context_->DocProps().keyword_ = meta_keyword_->content_;
|
||||
meta_document_statistic * meta_document_statistic_ = dynamic_cast<meta_document_statistic*>(meta->meta_document_statistic_.get());
|
||||
if (meta_document_statistic_)
|
||||
{
|
||||
context_->DocProps().character_count_ = meta_document_statistic_->character_count_;
|
||||
context_->DocProps().page_count_ = meta_document_statistic_->page_count_;
|
||||
context_->DocProps().paragraph_count_ = meta_document_statistic_->paragraph_count_;
|
||||
context_->DocProps().word_count_ = meta_document_statistic_->word_count_;
|
||||
context_->DocProps().non_whitespace_character_count_ = meta_document_statistic_->non_whitespace_character_count_;
|
||||
}
|
||||
meta_editing_cycles * meta_editing_cycles_ = dynamic_cast<meta_editing_cycles*>(meta->meta_editing_cycles_.get());
|
||||
if (meta_keyword_)
|
||||
context_->DocProps().revision_ = XmlUtils::GetInteger(meta_editing_cycles_->content_);
|
||||
}
|
||||
|
||||
void odf_document::Impl::parse_styles(office_element *element)
|
||||
|
||||
@ -411,6 +411,7 @@ public:
|
||||
styles_lite_container& drawStyles() { return draw_style_container_; }
|
||||
styles_lite_container& Templates() { return template_container_; }
|
||||
settings_container& Settings() { return settings_container_; }
|
||||
doc_props_container& DocProps() { return doc_props_container_; }
|
||||
|
||||
private:
|
||||
styles_container major_style_container_;
|
||||
@ -424,7 +425,7 @@ private:
|
||||
styles_lite_container template_container_;
|
||||
|
||||
settings_container settings_container_;
|
||||
|
||||
doc_props_container doc_props_container_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@
|
||||
#include "draw_common.h"
|
||||
#include "calcs_styles.h"
|
||||
#include "../docx/xlsx_utils.h"
|
||||
#include "office_meta.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
@ -50,25 +51,6 @@ namespace cpdoccore {
|
||||
|
||||
namespace odf_reader {
|
||||
|
||||
// dc:date
|
||||
/////////////////////////////////////////////
|
||||
const wchar_t * dc_date::ns = L"dc";
|
||||
const wchar_t * dc_date::name = L"date";
|
||||
|
||||
void dc_date::add_text(const std::wstring & Text)
|
||||
{
|
||||
content_ = Text;
|
||||
}
|
||||
|
||||
// dc:creator
|
||||
///////////////////////////////////////////
|
||||
const wchar_t * dc_creator::ns = L"dc";
|
||||
const wchar_t * dc_creator::name = L"creator";
|
||||
|
||||
void dc_creator::add_text(const std::wstring & Text)
|
||||
{
|
||||
content_ = Text;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
void office_annotation_attr::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
|
||||
@ -56,51 +56,6 @@ public:
|
||||
_CP_OPT(std::wstring) draw_text_style_name_;
|
||||
_CP_OPT(std::wstring) draw_style_name_;
|
||||
};
|
||||
|
||||
// dc:date
|
||||
class dc_date : public office_element_impl<dc_date>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeDcDate;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context){}
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
|
||||
virtual void add_text(const std::wstring & Text);
|
||||
|
||||
std::wstring content_;
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ){}
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(dc_date);
|
||||
|
||||
// dc:creator
|
||||
class dc_creator : public office_element_impl<dc_creator>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeDcCreator;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context){}
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
|
||||
virtual void add_text(const std::wstring & Text);
|
||||
|
||||
std::wstring content_;
|
||||
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ){}
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(dc_creator);
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
// office:annotation-end
|
||||
class office_annotation_end : public office_element_impl<office_annotation_end>
|
||||
|
||||
@ -62,34 +62,108 @@ void office_meta::add_child_element( xml::sax * Reader, const std::wstring & Ns,
|
||||
{
|
||||
CP_CREATE_ELEMENT(meta_user_defined_);
|
||||
}
|
||||
else if (Ns == L"meta" && Name == L"creation-date")
|
||||
{
|
||||
CP_CREATE_ELEMENT(meta_creation_date_);
|
||||
}
|
||||
else if (Ns == L"meta" && Name == L"initial-creator")
|
||||
{
|
||||
CP_CREATE_ELEMENT(meta_initial_creator_);
|
||||
}
|
||||
else if (Ns == L"meta" && Name == L"template")
|
||||
{
|
||||
CP_CREATE_ELEMENT(meta_template_);
|
||||
}
|
||||
else if (Ns == L"dc" && Name == L"date")
|
||||
{
|
||||
CP_CREATE_ELEMENT(dc_date_);
|
||||
}
|
||||
else if (Ns == L"dc" && Name == L"creator")
|
||||
{
|
||||
CP_CREATE_ELEMENT(dc_creator_);
|
||||
}
|
||||
else if (Ns == L"dc" && Name == L"description")
|
||||
{
|
||||
CP_CREATE_ELEMENT(dc_description_);
|
||||
}
|
||||
else if (Ns == L"dc" && Name == L"language")
|
||||
{
|
||||
CP_CREATE_ELEMENT(dc_language_);
|
||||
}
|
||||
else if (Ns == L"dc" && Name == L"title")
|
||||
{
|
||||
CP_CREATE_ELEMENT(dc_title_);
|
||||
}
|
||||
else if (Ns == L"dc" && Name == L"subject")
|
||||
{
|
||||
CP_CREATE_ELEMENT(dc_subject_);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * meta_generator::ns = L"meta";
|
||||
const wchar_t * meta_generator::name = L"generator";
|
||||
|
||||
void meta_generator::add_text(const std::wstring & text)
|
||||
//-----------------------------------------------------------------------------------
|
||||
const wchar_t * meta_common::ns = L"meta";
|
||||
const wchar_t * meta_common::name = L"common";
|
||||
void meta_common::add_text(const std::wstring & text)
|
||||
{
|
||||
content_ = text;
|
||||
}
|
||||
const wchar_t * meta_generator::ns = L"meta";
|
||||
const wchar_t * meta_generator::name = L"generator";
|
||||
|
||||
// config_item
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * meta_initial_creator::ns = L"meta";
|
||||
const wchar_t * meta_initial_creator::name = L"initial-creator";
|
||||
|
||||
const wchar_t * meta_creation_date::ns = L"meta";
|
||||
const wchar_t * meta_creation_date::name = L"creation-date";
|
||||
|
||||
const wchar_t * meta_template::ns = L"meta";
|
||||
const wchar_t * meta_template::name = L"template";
|
||||
|
||||
const wchar_t * meta_keyword::ns = L"meta";
|
||||
const wchar_t * meta_keyword::name = L"keyword";
|
||||
|
||||
const wchar_t * meta_editing_cycles::ns = L"meta";
|
||||
const wchar_t * meta_editing_cycles::name = L"editing-cycles";
|
||||
|
||||
const wchar_t * dc_creator::ns = L"dc";
|
||||
const wchar_t * dc_creator::name = L"creator";
|
||||
|
||||
const wchar_t * dc_description::ns = L"dc";
|
||||
const wchar_t * dc_description::name = L"description";
|
||||
|
||||
const wchar_t * dc_language::ns = L"dc";
|
||||
const wchar_t * dc_language::name = L"language";
|
||||
|
||||
const wchar_t * dc_date::ns = L"dc";
|
||||
const wchar_t * dc_date::name = L"date";
|
||||
|
||||
const wchar_t * dc_title::ns = L"dc";
|
||||
const wchar_t * dc_title::name = L"title";
|
||||
|
||||
const wchar_t * dc_subject::ns = L"dc";
|
||||
const wchar_t * dc_subject::name = L"subject";
|
||||
//------------------------------------------------------------------------------------
|
||||
const wchar_t * meta_document_statistic::ns = L"meta";
|
||||
const wchar_t * meta_document_statistic::name = L"document-statistic";
|
||||
|
||||
void meta_document_statistic::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"meta:table-count", meta_table_count_);
|
||||
CP_APPLY_ATTR(L"meta:image-count", meta_image_count_);
|
||||
CP_APPLY_ATTR(L"meta:object-count", meta_object_count_);
|
||||
CP_APPLY_ATTR(L"meta:page-count", meta_page_count_);
|
||||
CP_APPLY_ATTR(L"meta:paragraph-count", meta_paragraph_count_);
|
||||
CP_APPLY_ATTR(L"meta:word-count", meta_word_count_);
|
||||
CP_APPLY_ATTR(L"meta:character-count", meta_character_count_);
|
||||
CP_APPLY_ATTR(L"meta:table-count", table_count_);
|
||||
CP_APPLY_ATTR(L"meta:image-count", image_count_);
|
||||
CP_APPLY_ATTR(L"meta:object-count", object_count_);
|
||||
CP_APPLY_ATTR(L"meta:page-count", page_count_);
|
||||
CP_APPLY_ATTR(L"meta:paragraph-count", paragraph_count_);
|
||||
CP_APPLY_ATTR(L"meta:word-count", word_count_);
|
||||
CP_APPLY_ATTR(L"meta:character-count", character_count_);
|
||||
CP_APPLY_ATTR(L"meta:ole-object-count", ole_object_count_);
|
||||
CP_APPLY_ATTR(L"meta:frame-count", frame_count_);
|
||||
CP_APPLY_ATTR(L"meta:row-count", row_count_);
|
||||
CP_APPLY_ATTR(L"meta:cell-count", cell_count_);
|
||||
CP_APPLY_ATTR(L"meta:non-whitespace-character-count", non_whitespace_character_count_);
|
||||
CP_APPLY_ATTR(L"meta:sentence-count", sentence_count_);
|
||||
CP_APPLY_ATTR(L"meta:syllable-count", syllable_count_);
|
||||
}
|
||||
|
||||
// meta_user_defined
|
||||
|
||||
@ -52,35 +52,156 @@ public:
|
||||
office_element_ptr_array meta_user_defined_;
|
||||
office_element_ptr meta_generator_;
|
||||
office_element_ptr meta_document_statistic_;
|
||||
|
||||
office_element_ptr meta_creation_date_;
|
||||
office_element_ptr meta_template_;
|
||||
office_element_ptr meta_printed_by_;
|
||||
office_element_ptr meta_print_date_;
|
||||
office_element_ptr meta_keyword_;
|
||||
office_element_ptr meta_initial_creator_;
|
||||
office_element_ptr meta_hyperlinkbehaviour_;
|
||||
office_element_ptr meta_editing_duration_;
|
||||
office_element_ptr meta_editing_cycles_;
|
||||
office_element_ptr meta_auto_reloads_;
|
||||
office_element_ptr dc_date_;
|
||||
office_element_ptr dc_description_;
|
||||
office_element_ptr dc_language_;
|
||||
office_element_ptr dc_subject_;
|
||||
office_element_ptr dc_title_;
|
||||
office_element_ptr dc_creator_;
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_text(const std::wstring & Text){}
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(office_meta);
|
||||
|
||||
// meta:generator
|
||||
class meta_generator : public office_element_impl<meta_generator>
|
||||
// base
|
||||
class meta_common : public office_element_impl<meta_common>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeOfficeMetaGenerator;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeOfficeMetaCommon;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
std::wstring content_;
|
||||
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ){}
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
virtual void add_attributes(const xml::attributes_wc_ptr & Attributes) {}
|
||||
virtual void add_child_element(xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) {}
|
||||
virtual void add_text(const std::wstring & Text);
|
||||
|
||||
};
|
||||
// meta:initial-creator
|
||||
class meta_initial_creator : public meta_common
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const ElementType type = typeOfficeMetaInitialCreator;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(meta_initial_creator);
|
||||
// meta:keyword
|
||||
class meta_keyword : public meta_common
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const ElementType type = typeOfficeMetaKeyword;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(meta_keyword);
|
||||
// meta:creation-date
|
||||
class meta_creation_date : public meta_common
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const ElementType type = typeOfficeMetaCreationDate;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(meta_creation_date);
|
||||
// meta:generator
|
||||
class meta_generator : public meta_common
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const ElementType type = typeOfficeMetaGenerator;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(meta_generator);
|
||||
|
||||
// meta:template
|
||||
class meta_template : public meta_common
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const ElementType type = typeOfficeMetaTemplate;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(meta_template);
|
||||
// meta:editing-cycles
|
||||
class meta_editing_cycles : public meta_common
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const ElementType type = typeOfficeMetaEditingCycles;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(meta_editing_cycles);
|
||||
//--------------------------------------------------------------------------
|
||||
// dc:creator
|
||||
class dc_creator : public meta_common
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const ElementType type = typeDcCreator;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(dc_creator);
|
||||
// dc:description
|
||||
class dc_description : public meta_common
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const ElementType type = typeDcDescription;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(dc_description);
|
||||
// dc:language
|
||||
class dc_language : public meta_common
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const ElementType type = typeDcLanguage;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(dc_language);
|
||||
// dc:date
|
||||
class dc_date : public meta_common
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const ElementType type = typeDcDate;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(dc_date);
|
||||
// dc:title
|
||||
class dc_title : public meta_common
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const ElementType type = typeDcTitle;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(dc_title);
|
||||
// dc:subject
|
||||
class dc_subject : public meta_common
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const ElementType type = typeDcSubject;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(dc_subject);
|
||||
//-----------------------------------------------------------------------------
|
||||
// meta:document-statistic
|
||||
class meta_document_statistic : public office_element_impl<meta_document_statistic>
|
||||
{
|
||||
@ -91,13 +212,21 @@ public:
|
||||
static const ElementType type = typeOfficeMetaDocumentStatistic;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
_CP_OPT(int) meta_table_count_;
|
||||
_CP_OPT(int) meta_image_count_;
|
||||
_CP_OPT(int) meta_object_count_;
|
||||
_CP_OPT(int) meta_page_count_;
|
||||
_CP_OPT(int) meta_paragraph_count_;
|
||||
_CP_OPT(int) meta_word_count_;
|
||||
_CP_OPT(int) meta_character_count_;
|
||||
_CP_OPT(int) image_count_;
|
||||
_CP_OPT(int) object_count_;
|
||||
_CP_OPT(int) page_count_;
|
||||
_CP_OPT(int) paragraph_count_;
|
||||
_CP_OPT(int) word_count_;
|
||||
_CP_OPT(int) character_count_;
|
||||
_CP_OPT(int) non_whitespace_character_count_;
|
||||
_CP_OPT(int) draw_count_;
|
||||
_CP_OPT(int) ole_object_count_;
|
||||
_CP_OPT(int) frame_count_;
|
||||
_CP_OPT(int) table_count_;
|
||||
_CP_OPT(int) row_count_;
|
||||
_CP_OPT(int) cell_count_;
|
||||
_CP_OPT(int) sentence_count_;
|
||||
_CP_OPT(int) syllable_count_;
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include "office_text.h"
|
||||
#include "office_annotation.h"
|
||||
#include "office_meta.h"
|
||||
|
||||
#include "../../include/xml/xmlchar.h"
|
||||
#include "../../include/xml/utils.h"
|
||||
|
||||
@ -1825,7 +1825,7 @@ void text_user_defined::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
odf_reader::odf_read_context & odfContext = Context.root()->odf_context();
|
||||
|
||||
std::wstring value = odfContext.Settings().get_user_defined(*text_name_);
|
||||
std::wstring value = odfContext.DocProps().get_user_defined(*text_name_);
|
||||
if (!value.empty())
|
||||
text_ = text::create(value) ;
|
||||
|
||||
|
||||
@ -82,6 +82,32 @@ office_element_ptr styles_lite_container::find_by_style_name(const std::wstring
|
||||
return office_element_ptr();
|
||||
}
|
||||
}
|
||||
class doc_props_container::Impl
|
||||
{
|
||||
public:
|
||||
Impl() {}
|
||||
|
||||
std::map<std::wstring, std::wstring> map_user_defineds;
|
||||
};
|
||||
|
||||
doc_props_container::doc_props_container() : impl_(new doc_props_container::Impl())
|
||||
{
|
||||
}
|
||||
|
||||
doc_props_container::~doc_props_container()
|
||||
{
|
||||
}
|
||||
void doc_props_container::add_user_defined(const std::wstring & name, const std::wstring & value)
|
||||
{
|
||||
impl_->map_user_defineds.insert(std::make_pair(name, value));
|
||||
}
|
||||
std::wstring doc_props_container::get_user_defined(const std::wstring & name)
|
||||
{
|
||||
std::map<std::wstring, std::wstring>::iterator pFind = impl_->map_user_defineds.find(name);
|
||||
|
||||
return pFind != impl_->map_user_defineds.end() ? pFind->second : L"";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
struct settings_value
|
||||
{
|
||||
@ -100,7 +126,7 @@ struct view_elm : settings_elm
|
||||
boost::unordered_map<std::wstring, int> map_tables;
|
||||
std::vector<settings_elm> tables;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
class settings_container::Impl
|
||||
{
|
||||
public:
|
||||
@ -266,16 +292,6 @@ _CP_OPT(std::wstring) settings_container::find_view_by_name(const std::wstring &
|
||||
}
|
||||
return value;
|
||||
}
|
||||
void settings_container::add_user_defined(const std::wstring & name, const std::wstring & value)
|
||||
{
|
||||
impl_->map_user_defineds.insert(std::make_pair(name, value));
|
||||
}
|
||||
std::wstring settings_container::get_user_defined(const std::wstring & name)
|
||||
{
|
||||
std::map<std::wstring, std::wstring>::iterator pFind = impl_->map_user_defineds.find(name);
|
||||
|
||||
return pFind != impl_->map_user_defineds.end() ? pFind->second : L"";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,6 +56,36 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class doc_props_container
|
||||
{
|
||||
public:
|
||||
doc_props_container();
|
||||
~doc_props_container();
|
||||
|
||||
void add_user_defined(const std::wstring & name, const std::wstring & value);
|
||||
std::wstring get_user_defined(const std::wstring & name);
|
||||
|
||||
std::wstring dc_creator_;
|
||||
std::wstring dc_date_;
|
||||
std::wstring dc_description_;
|
||||
std::wstring dc_language_;
|
||||
std::wstring dc_subject_;
|
||||
std::wstring dc_title_;
|
||||
std::wstring application_;
|
||||
std::wstring creation_date_;
|
||||
std::wstring keyword_;
|
||||
std::wstring template_;
|
||||
_CP_OPT(int) revision_;
|
||||
|
||||
_CP_OPT(int) page_count_;
|
||||
_CP_OPT(int) paragraph_count_;
|
||||
_CP_OPT(int) word_count_;
|
||||
_CP_OPT(int) character_count_;
|
||||
_CP_OPT(int) non_whitespace_character_count_;
|
||||
private:
|
||||
class Impl;
|
||||
_CP_SCOPED_PTR(Impl) impl_;
|
||||
};
|
||||
class settings_container
|
||||
{
|
||||
public:
|
||||
@ -80,8 +110,6 @@ public:
|
||||
|
||||
void add_view (const std::wstring & name, const std::wstring & value);
|
||||
|
||||
void add_user_defined(const std::wstring & name, const std::wstring & value);
|
||||
std::wstring get_user_defined(const std::wstring & name);
|
||||
private:
|
||||
class Impl;
|
||||
_CP_SCOPED_PTR(Impl) impl_;
|
||||
|
||||
@ -96,7 +96,6 @@ _UINT32 COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstr
|
||||
}
|
||||
|
||||
//pptReader->ReadEncryptedSummary();
|
||||
//pptReader->ReadDocumentSummary();
|
||||
pptReader->ReadDocument();
|
||||
|
||||
bMacros = pptReader->m_oDocumentInfo.m_bMacros;
|
||||
@ -132,7 +131,9 @@ _UINT32 COfficePPTFile::LoadFromFile(std::wstring sSrcFileName, std::wstring sDs
|
||||
PPT_FORMAT::CPPTXWriter oPPTXWriter;
|
||||
oPPTXWriter.m_strTempDirectory = sDstPath;
|
||||
|
||||
|
||||
oPPTXWriter.m_xmlApp = ((CPPTFileReader*)m_pReader)->m_oDocumentInfo.m_app_xml;
|
||||
oPPTXWriter.m_xmlCore = ((CPPTFileReader*)m_pReader)->m_oDocumentInfo.m_core_xml;
|
||||
|
||||
oPPTXWriter.CreateFile(((CPPTFileReader*)m_pReader)->m_oDocumentInfo.m_arUsers[0]);
|
||||
oPPTXWriter.CloseFile();
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ PPT_FORMAT::CPPTXWriter::~CPPTXWriter()
|
||||
RELEASEOBJECT(m_pShapeWriter);
|
||||
}
|
||||
|
||||
void PPT_FORMAT::CPPTXWriter::CreateFile(CPPTUserInfo* pUserInfo )
|
||||
void PPT_FORMAT::CPPTXWriter::CreateFile(CPPTUserInfo* pUserInfo)
|
||||
{
|
||||
m_pUserInfo = pUserInfo;
|
||||
|
||||
@ -136,8 +136,9 @@ void PPT_FORMAT::CPPTXWriter::CreateFile(CPPTUserInfo* pUserInfo )
|
||||
|
||||
// core
|
||||
oFile.CreateFileW(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("core.xml"));
|
||||
strMemory = NSPPTXWriterConst::g_string_core;
|
||||
oFile.WriteStringUTF8(strMemory);
|
||||
if (m_xmlCore.empty())
|
||||
m_xmlCore = NSPPTXWriterConst::g_string_core;
|
||||
oFile.WriteStringUTF8(m_xmlCore);
|
||||
oFile.CloseFile();
|
||||
|
||||
// app
|
||||
@ -299,142 +300,147 @@ void PPT_FORMAT::CPPTXWriter::WriteContentTypes()
|
||||
|
||||
void PPT_FORMAT::CPPTXWriter::WriteApp(NSFile::CFileBinary& oFile)
|
||||
{
|
||||
std::wstringstream strm;
|
||||
if (m_xmlApp.empty())
|
||||
{
|
||||
std::wstringstream strm;
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"Properties")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties");
|
||||
CP_XML_ATTR(L"xmlns:vt", L"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes");
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"Properties")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties");
|
||||
CP_XML_ATTR(L"xmlns:vt", L"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes");
|
||||
|
||||
CP_XML_NODE(L"TotalTime")
|
||||
{
|
||||
CP_XML_STREAM() << 0;
|
||||
}
|
||||
CP_XML_NODE(L"Words")
|
||||
{
|
||||
CP_XML_STREAM() << 0;
|
||||
}
|
||||
std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvApplicationName);
|
||||
if (sApplication.empty())
|
||||
sApplication = NSSystemUtils::gc_EnvApplicationNameDefault;
|
||||
CP_XML_NODE(L"TotalTime")
|
||||
{
|
||||
CP_XML_STREAM() << 0;
|
||||
}
|
||||
CP_XML_NODE(L"Words")
|
||||
{
|
||||
CP_XML_STREAM() << 0;
|
||||
}
|
||||
std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvApplicationName);
|
||||
if (sApplication.empty())
|
||||
sApplication = NSSystemUtils::gc_EnvApplicationNameDefault;
|
||||
#if defined(INTVER)
|
||||
std::string s = VALUE2STR(INTVER);
|
||||
sApplication += L"/" + std::wstring(s.begin(), s.end());
|
||||
std::string s = VALUE2STR(INTVER);
|
||||
sApplication += L"/" + std::wstring(s.begin(), s.end());
|
||||
#endif
|
||||
CP_XML_NODE(L"Application")
|
||||
{
|
||||
CP_XML_STREAM() << sApplication;
|
||||
}
|
||||
//CP_XML_NODE(L"AppVersion")
|
||||
//{
|
||||
// CP_XML_STREAM() << L"1.0";
|
||||
//}
|
||||
CP_XML_NODE(L"Paragraphs")
|
||||
{
|
||||
CP_XML_STREAM() << 0;
|
||||
}
|
||||
CP_XML_NODE(L"PresentationFormat")
|
||||
{
|
||||
CP_XML_STREAM() << L"On-screen Show (4:3)";
|
||||
}
|
||||
CP_XML_NODE(L"Slides")
|
||||
{
|
||||
CP_XML_STREAM() << m_pDocument->m_arSlides.size();
|
||||
}
|
||||
CP_XML_NODE(L"Notes")
|
||||
{
|
||||
CP_XML_STREAM() << m_pDocument->m_arNotes.size();
|
||||
}
|
||||
CP_XML_NODE(L"HiddenSlides")
|
||||
{
|
||||
CP_XML_STREAM() << 0;
|
||||
}
|
||||
CP_XML_NODE(L"MMClips")
|
||||
{
|
||||
CP_XML_STREAM() << 0;
|
||||
}
|
||||
CP_XML_NODE(L"ScaleCrop")
|
||||
{
|
||||
CP_XML_STREAM() << L"false";
|
||||
}
|
||||
CP_XML_NODE(L"HeadingPairs")
|
||||
{
|
||||
CP_XML_NODE(L"vt:vector")
|
||||
{
|
||||
CP_XML_ATTR(L"size", 4);
|
||||
CP_XML_ATTR(L"baseType", L"variant");
|
||||
CP_XML_NODE(L"Application")
|
||||
{
|
||||
CP_XML_STREAM() << sApplication;
|
||||
}
|
||||
//CP_XML_NODE(L"AppVersion")
|
||||
//{
|
||||
// CP_XML_STREAM() << L"1.0";
|
||||
//}
|
||||
CP_XML_NODE(L"Paragraphs")
|
||||
{
|
||||
CP_XML_STREAM() << 0;
|
||||
}
|
||||
CP_XML_NODE(L"PresentationFormat")
|
||||
{
|
||||
CP_XML_STREAM() << L"On-screen Show (4:3)";
|
||||
}
|
||||
CP_XML_NODE(L"Slides")
|
||||
{
|
||||
CP_XML_STREAM() << m_pDocument->m_arSlides.size();
|
||||
}
|
||||
CP_XML_NODE(L"Notes")
|
||||
{
|
||||
CP_XML_STREAM() << m_pDocument->m_arNotes.size();
|
||||
}
|
||||
CP_XML_NODE(L"HiddenSlides")
|
||||
{
|
||||
CP_XML_STREAM() << 0;
|
||||
}
|
||||
CP_XML_NODE(L"MMClips")
|
||||
{
|
||||
CP_XML_STREAM() << 0;
|
||||
}
|
||||
CP_XML_NODE(L"ScaleCrop")
|
||||
{
|
||||
CP_XML_STREAM() << L"false";
|
||||
}
|
||||
CP_XML_NODE(L"HeadingPairs")
|
||||
{
|
||||
CP_XML_NODE(L"vt:vector")
|
||||
{
|
||||
CP_XML_ATTR(L"size", 4);
|
||||
CP_XML_ATTR(L"baseType", L"variant");
|
||||
|
||||
CP_XML_NODE(L"vt:variant")
|
||||
{
|
||||
CP_XML_NODE(L"vt:lpstr")
|
||||
{
|
||||
CP_XML_STREAM() << L"Theme";
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"vt:variant")
|
||||
{
|
||||
CP_XML_NODE(L"vt:i4")
|
||||
{
|
||||
CP_XML_STREAM() << m_pDocument->m_arThemes.size();
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"vt:variant")
|
||||
{
|
||||
CP_XML_NODE(L"vt:lpstr")
|
||||
{
|
||||
CP_XML_STREAM() << L"Slide Titles";
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"vt:variant")
|
||||
{
|
||||
CP_XML_NODE(L"vt:i4")
|
||||
CP_XML_STREAM() << m_pDocument->m_arSlides.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"TitlesOfParts")
|
||||
{
|
||||
CP_XML_NODE(L"vt:vector")
|
||||
{
|
||||
CP_XML_ATTR(L"size", m_pDocument->m_arSlides.size() + m_pDocument->m_arThemes.size());
|
||||
CP_XML_ATTR(L"baseType", L"lpstr");
|
||||
CP_XML_NODE(L"vt:variant")
|
||||
{
|
||||
CP_XML_NODE(L"vt:lpstr")
|
||||
{
|
||||
CP_XML_STREAM() << L"Theme";
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"vt:variant")
|
||||
{
|
||||
CP_XML_NODE(L"vt:i4")
|
||||
{
|
||||
CP_XML_STREAM() << m_pDocument->m_arThemes.size();
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"vt:variant")
|
||||
{
|
||||
CP_XML_NODE(L"vt:lpstr")
|
||||
{
|
||||
CP_XML_STREAM() << L"Slide Titles";
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"vt:variant")
|
||||
{
|
||||
CP_XML_NODE(L"vt:i4")
|
||||
CP_XML_STREAM() << m_pDocument->m_arSlides.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"TitlesOfParts")
|
||||
{
|
||||
CP_XML_NODE(L"vt:vector")
|
||||
{
|
||||
CP_XML_ATTR(L"size", m_pDocument->m_arSlides.size() + m_pDocument->m_arThemes.size());
|
||||
CP_XML_ATTR(L"baseType", L"lpstr");
|
||||
|
||||
for (size_t i = 1; i <= m_pDocument->m_arThemes.size(); ++i)
|
||||
{
|
||||
CP_XML_NODE(L"vt:lpstr")
|
||||
{
|
||||
CP_XML_STREAM() << L"Theme " << i;
|
||||
}
|
||||
}
|
||||
for (size_t i = 1; i <= m_pDocument->m_arSlides.size(); ++i)
|
||||
{
|
||||
CP_XML_NODE(L"vt:lpstr")
|
||||
{
|
||||
CP_XML_STREAM() << L"Slide " << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t i = 1; i <= m_pDocument->m_arThemes.size(); ++i)
|
||||
{
|
||||
CP_XML_NODE(L"vt:lpstr")
|
||||
{
|
||||
CP_XML_STREAM() << L"Theme " << i;
|
||||
}
|
||||
}
|
||||
for (size_t i = 1; i <= m_pDocument->m_arSlides.size(); ++i)
|
||||
{
|
||||
CP_XML_NODE(L"vt:lpstr")
|
||||
{
|
||||
CP_XML_STREAM() << L"Slide " << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//CP_XML_NODE(L"Company");
|
||||
CP_XML_NODE(L"LinksUpToDate")
|
||||
{
|
||||
CP_XML_STREAM() << L"false";
|
||||
}
|
||||
CP_XML_NODE(L"SharedDoc")
|
||||
{
|
||||
CP_XML_STREAM() << L"false";
|
||||
}
|
||||
CP_XML_NODE(L"HyperlinksChanged")
|
||||
{
|
||||
CP_XML_STREAM() << L"false";
|
||||
}
|
||||
}
|
||||
}
|
||||
//CP_XML_NODE(L"Company");
|
||||
CP_XML_NODE(L"LinksUpToDate")
|
||||
{
|
||||
CP_XML_STREAM() << L"false";
|
||||
}
|
||||
CP_XML_NODE(L"SharedDoc")
|
||||
{
|
||||
CP_XML_STREAM() << L"false";
|
||||
}
|
||||
CP_XML_NODE(L"HyperlinksChanged")
|
||||
{
|
||||
CP_XML_STREAM() << L"false";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_xmlApp = strm.str();
|
||||
}
|
||||
oFile.WriteStringUTF8(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
|
||||
oFile.WriteStringUTF8(strm.str());
|
||||
oFile.WriteStringUTF8(m_xmlApp);
|
||||
}
|
||||
|
||||
void PPT_FORMAT::CPPTXWriter::WritePresInfo()
|
||||
|
||||
@ -70,6 +70,8 @@ namespace PPT_FORMAT
|
||||
void Write()
|
||||
{
|
||||
}
|
||||
std::wstring m_xmlApp;
|
||||
std::wstring m_xmlCore;
|
||||
|
||||
protected:
|
||||
void WriteApp (NSFile::CFileBinary& oFile);
|
||||
|
||||
@ -43,6 +43,9 @@ public:
|
||||
std::wstring m_strPassword;
|
||||
bool m_bMacros;
|
||||
|
||||
std::wstring m_app_xml;
|
||||
std::wstring m_core_xml;
|
||||
|
||||
CPPTDocumentInfo() : m_oCurrentUser(), m_bMacros(true)
|
||||
{
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
#include "PPTFileReader.h"
|
||||
|
||||
#include "../../../ASCOfficeXlsFile2/source/XlsFormat/Crypt/Decryptor.h"
|
||||
#include "../../../ASCOfficeXlsFile2/source/XlsFormat/Logic/SummaryInformationStream/SummaryInformation.h"
|
||||
#include "../../../ASCOfficeXlsFile2/source/XlsFormat/Logic/SummaryInformationStream/PropertySetStream.h"
|
||||
|
||||
#include "../../../DesktopEditor/common/Directory.h"
|
||||
#include "../Records/Drawing/ArtBlip.h"
|
||||
@ -48,6 +48,7 @@
|
||||
|
||||
#define ENCRYPTED_SUMMARY_STREAM L"EncryptedSummary"
|
||||
#define DOCUMENT_SUMMARY_STREAM L"DocumentSummaryInformation"
|
||||
#define SUMMARY_STREAM L"SummaryInformation"
|
||||
|
||||
CPPTFileReader::CPPTFileReader(POLE::Storage *pStorage, std::wstring strTemp):
|
||||
m_pStorage(pStorage),
|
||||
@ -121,6 +122,8 @@ bool CPPTFileReader::ReadPersists()
|
||||
void CPPTFileReader::ReadDocument()
|
||||
{
|
||||
ReadPictures();
|
||||
ReadDocumentSummary();
|
||||
|
||||
m_oDocumentInfo.LoadDocument(m_strTmpDirectory);
|
||||
}
|
||||
|
||||
@ -183,7 +186,14 @@ CFStreamPtr CPPTFileReader::GetEncryptedSummaryStream()
|
||||
}
|
||||
return m_pEncryptedSummaryStream;
|
||||
}
|
||||
|
||||
CFStreamPtr CPPTFileReader::GetSummaryStream()
|
||||
{
|
||||
if (!m_pDocumentSummaryStream)
|
||||
{
|
||||
m_pDocumentSummaryStream = GetStreamByName(SUMMARY_STREAM);
|
||||
}
|
||||
return m_pDocumentSummaryStream;
|
||||
}
|
||||
CFStreamPtr CPPTFileReader::GetDocumentSummaryStream()
|
||||
{
|
||||
if (!m_pDocumentSummaryStream)
|
||||
@ -210,15 +220,23 @@ void CPPTFileReader::ReadEncryptedSummary()
|
||||
|
||||
void CPPTFileReader::ReadDocumentSummary()
|
||||
{
|
||||
CFStreamPtr pStream = GetDocumentSummaryStream();
|
||||
if (!pStream) return;
|
||||
|
||||
OLEPS::SummaryInformation doc_summary_info(pStream);
|
||||
OLEPS::PropertySetStream summary_info;
|
||||
|
||||
m_nPresentationCodePage = doc_summary_info.GetCodePage();
|
||||
CFStreamPtr pStream = GetSummaryStream();
|
||||
if (pStream)
|
||||
summary_info.read(pStream);
|
||||
|
||||
pStream = GetDocumentSummaryStream();
|
||||
if (pStream)
|
||||
summary_info.read(pStream, true);
|
||||
|
||||
m_nPresentationCodePage = summary_info.GetCodePage();
|
||||
|
||||
if (m_nPresentationCodePage == 0)
|
||||
m_nPresentationCodePage = 1250;
|
||||
|
||||
m_oDocumentInfo.m_app_xml = summary_info.GetApp();
|
||||
m_oDocumentInfo.m_core_xml = summary_info.GetCore();
|
||||
}
|
||||
|
||||
void CPPTFileReader::ReadPictures()
|
||||
|
||||
@ -50,6 +50,7 @@ protected:
|
||||
CFStreamPtr GetPictureStream();
|
||||
CFStreamPtr GetEncryptedSummaryStream();
|
||||
CFStreamPtr GetDocumentSummaryStream();
|
||||
CFStreamPtr GetSummaryStream();
|
||||
|
||||
CFStreamPtr GetStreamByName(const std::wstring & name);
|
||||
|
||||
|
||||
448
ASCOfficePPTXFile/PPTXFormat/Presentation.cpp
Normal file
448
ASCOfficePPTXFile/PPTXFormat/Presentation.cpp
Normal file
@ -0,0 +1,448 @@
|
||||
/*
|
||||
* (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 "Presentation.h"
|
||||
#include "FileContainer.h"
|
||||
#include "FileTypes.h"
|
||||
|
||||
#include "Presentation/EmbeddedFont.h"
|
||||
#include "Presentation/Kinsoku.h"
|
||||
#include "Presentation/NotesSz.h"
|
||||
#include "Presentation/PhotoAlbum.h"
|
||||
#include "Presentation/SldSz.h"
|
||||
#include "CommentAuthors.h"
|
||||
|
||||
#include "Limit/Conformance.h"
|
||||
#include "Logic/TextListStyle.h"
|
||||
#include "Logic/ClrMap.h"
|
||||
#include "Logic/ExtP.h"
|
||||
#include "Theme/ClrScheme.h"
|
||||
#include "Comments.h"
|
||||
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Media/JsaProject.h"
|
||||
|
||||
#include "../../ASCOfficeXlsFile2/source/VbaFormat/VbaReader.h"
|
||||
|
||||
namespace PPTX
|
||||
{
|
||||
Presentation::Presentation(OOX::Document *pMain) : WrapperFile(pMain), PPTX::FileContainer(pMain)
|
||||
{
|
||||
m_bMacroEnabled = false;
|
||||
}
|
||||
Presentation::Presentation(OOX::Document *pMain, const OOX::CPath& filename, FileMap& map) : WrapperFile(pMain), PPTX::FileContainer(pMain)
|
||||
{
|
||||
m_bMacroEnabled = false;
|
||||
read(filename, map);
|
||||
}
|
||||
Presentation::~Presentation()
|
||||
{
|
||||
}
|
||||
void Presentation::read(const OOX::CPath& filename, FileMap& map)
|
||||
{
|
||||
XmlUtils::CXmlNode oNode;
|
||||
oNode.FromXmlFile(filename.m_strFilename);
|
||||
|
||||
XmlMacroReadAttributeBase(oNode, L"autoCompressPictures", attrAutoCompressPictures);
|
||||
XmlMacroReadAttributeBase(oNode, L"bookmarkIdSeed", attrBookmarkIdSeed);
|
||||
XmlMacroReadAttributeBase(oNode, L"compatMode", attrCompatMode);
|
||||
XmlMacroReadAttributeBase(oNode, L"conformance", attrConformance);
|
||||
XmlMacroReadAttributeBase(oNode, L"embedTrueTypeFonts", attrEmbedTrueTypeFonts);
|
||||
XmlMacroReadAttributeBase(oNode, L"firstSlideNum", attrFirstSlideNum);
|
||||
XmlMacroReadAttributeBase(oNode, L"removePersonalInfoOnSave", attrRemovePersonalInfoOnSave);
|
||||
XmlMacroReadAttributeBase(oNode, L"rtl", attrRtl);
|
||||
XmlMacroReadAttributeBase(oNode, L"saveSubsetFonts", attrSaveSubsetFonts);
|
||||
XmlMacroReadAttributeBase(oNode, L"serverZoom", attrServerZoom);
|
||||
XmlMacroReadAttributeBase(oNode, L"showSpecialPlsOnTitleSld", attrShowSpecialPlsOnTitleSld);
|
||||
XmlMacroReadAttributeBase(oNode, L"strictFirstAndLastChars", attrStrictFirstAndLastChars);
|
||||
|
||||
//custDataLst (Customer Data List)
|
||||
//custShowLst (List of Custom Shows)
|
||||
defaultTextStyle = oNode.ReadNode(_T("p:defaultTextStyle"));
|
||||
if (defaultTextStyle.is_init())
|
||||
defaultTextStyle->SetParentFilePointer(this);
|
||||
|
||||
embeddedFontLst.clear();
|
||||
XmlUtils::CXmlNode oNodeEmbeddedFonts;
|
||||
if (oNode.GetNode(_T("p:embeddedFontLst"), oNodeEmbeddedFonts))
|
||||
{
|
||||
XmlMacroLoadArray(oNodeEmbeddedFonts, _T("p:embeddedFont"), embeddedFontLst, nsPresentation::EmbeddedFont);
|
||||
|
||||
for (size_t i = 0; i < embeddedFontLst.size(); ++i)
|
||||
embeddedFontLst[i].SetParentFilePointer(this);
|
||||
}
|
||||
|
||||
handoutMasterIdLst.clear();
|
||||
XmlUtils::CXmlNode oNodeHMList;
|
||||
if (oNode.GetNode(_T("p:handoutMasterIdLst"), oNodeHMList))
|
||||
{
|
||||
XmlMacroLoadArray(oNodeHMList, _T("p:handoutMasterId"), handoutMasterIdLst, Logic::XmlId);
|
||||
|
||||
for (size_t i = 0; i < handoutMasterIdLst.size(); ++i)
|
||||
handoutMasterIdLst[i].SetParentFilePointer(this);
|
||||
}
|
||||
|
||||
|
||||
kinsoku = oNode.ReadNode(_T("p:kinsoku"));
|
||||
if (kinsoku.is_init())
|
||||
kinsoku->SetParentFilePointer(this);
|
||||
|
||||
//modifyVerifier (Modification Verifier)
|
||||
notesMasterIdLst.clear();
|
||||
XmlUtils::CXmlNode oNodeMIDList;
|
||||
if (oNode.GetNode(_T("p:notesMasterIdLst"), oNodeMIDList))
|
||||
{
|
||||
XmlMacroLoadArray(oNodeMIDList, _T("p:notesMasterId"), notesMasterIdLst, Logic::XmlId);
|
||||
|
||||
for (size_t i = 0; i < notesMasterIdLst.size(); ++i)
|
||||
notesMasterIdLst[i].SetParentFilePointer(this);
|
||||
}
|
||||
|
||||
notesSz = oNode.ReadNode(_T("p:notesSz"));
|
||||
if (notesSz.is_init())
|
||||
notesSz->SetParentFilePointer(this);
|
||||
|
||||
photoAlbum = oNode.ReadNode(_T("p:photoAlbum"));
|
||||
if (photoAlbum.is_init())
|
||||
photoAlbum->SetParentFilePointer(this);
|
||||
|
||||
sldIdLst.clear();
|
||||
XmlUtils::CXmlNode oNode_sldId;
|
||||
if (oNode.GetNode(_T("p:sldIdLst"), oNode_sldId))
|
||||
{
|
||||
XmlMacroLoadArray(oNode_sldId, _T("p:sldId"), sldIdLst, Logic::XmlId);
|
||||
|
||||
for (size_t i = 0; i < sldIdLst.size(); ++i)
|
||||
sldIdLst[i].SetParentFilePointer(this);
|
||||
}
|
||||
|
||||
sldMasterIdLst.clear();
|
||||
XmlUtils::CXmlNode oNode_sldM_Id;
|
||||
if (oNode.GetNode(_T("p:sldMasterIdLst"), oNode_sldM_Id))
|
||||
{
|
||||
XmlMacroLoadArray(oNode_sldM_Id, _T("p:sldMasterId"), sldMasterIdLst, Logic::XmlId);
|
||||
|
||||
for (size_t i = 0; i < sldMasterIdLst.size(); ++i)
|
||||
sldMasterIdLst[i].SetParentFilePointer(this);
|
||||
}
|
||||
|
||||
sldSz = oNode.ReadNode(_T("p:sldSz"));
|
||||
if (sldSz.is_init())
|
||||
sldSz->SetParentFilePointer(this);
|
||||
|
||||
XmlUtils::CXmlNode list = oNode.ReadNodeNoNS(_T("extLst"));
|
||||
if (list.IsValid())
|
||||
{
|
||||
XmlUtils::CXmlNodes oNodes;
|
||||
if (list.GetNodes(_T("*"), oNodes))
|
||||
{
|
||||
int nCount = oNodes.GetCount();
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
XmlUtils::CXmlNode oNode;
|
||||
oNodes.GetAt(i, oNode);
|
||||
|
||||
PPTX::Logic::Ext ext;
|
||||
ext.fromXML(oNode);
|
||||
if (ext.sectionLst.IsInit())
|
||||
{
|
||||
sectionLst = ext.sectionLst;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//smartTags (Smart Tags)
|
||||
Normalize();
|
||||
}
|
||||
void Presentation::write(const OOX::CPath& filename, const OOX::CPath& directory, OOX::CContentTypes& content)const
|
||||
{
|
||||
WrapperFile::write(filename, directory, content);
|
||||
FileContainer::write(filename, directory, content);
|
||||
}
|
||||
|
||||
void Presentation::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
pWriter->StartRecord(NSBinPptxRW::NSMainTables::Presentation);
|
||||
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
|
||||
|
||||
pWriter->WriteBool2(0, attrAutoCompressPictures);
|
||||
pWriter->WriteInt2(1, attrBookmarkIdSeed);
|
||||
pWriter->WriteBool2(2, attrCompatMode);
|
||||
pWriter->WriteLimit2(3, attrConformance);
|
||||
pWriter->WriteBool2(4, attrEmbedTrueTypeFonts);
|
||||
pWriter->WriteInt2(5, attrFirstSlideNum);
|
||||
pWriter->WriteBool2(6, attrRemovePersonalInfoOnSave);
|
||||
pWriter->WriteBool2(7, attrRtl);
|
||||
pWriter->WriteBool2(8, attrSaveSubsetFonts);
|
||||
pWriter->WriteString2(9, attrServerZoom);
|
||||
pWriter->WriteBool2(10, attrShowSpecialPlsOnTitleSld);
|
||||
pWriter->WriteBool2(11, attrStrictFirstAndLastChars);
|
||||
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
|
||||
|
||||
pWriter->WriteRecord2(0, defaultTextStyle);
|
||||
pWriter->WriteRecordArray(1, 0, embeddedFontLst);
|
||||
pWriter->WriteRecord2(2, kinsoku);
|
||||
pWriter->WriteRecord2(3, notesSz);
|
||||
pWriter->WriteRecord2(4, photoAlbum);
|
||||
pWriter->WriteRecord2(5, sldSz);
|
||||
|
||||
pWriter->WriteRecord2(6, commentAuthors);
|
||||
pWriter->WriteRecord2(7, sectionLst);
|
||||
|
||||
if (m_pVbaProject.IsInit())
|
||||
{
|
||||
pWriter->StartRecord(8);
|
||||
{
|
||||
m_pVbaProject->toPPTY(pWriter);
|
||||
}
|
||||
pWriter->EndRecord();
|
||||
}
|
||||
pWriter->WriteRecord2(9, m_pJsaProject);
|
||||
pWriter->WriteRecord2(10, comments);
|
||||
|
||||
if (m_pVbaProject.IsInit())
|
||||
{
|
||||
CVbaReader vbaReader(m_pVbaProject.smart_dynamic_cast<OOX::Media>()->filename().GetPath(), L"");
|
||||
std::wstring sXml = vbaReader.convert();
|
||||
|
||||
if (false == sXml.empty())
|
||||
{
|
||||
pWriter->StartRecord(11);
|
||||
pWriter->WriteStringW(sXml);
|
||||
pWriter->EndRecord();
|
||||
}
|
||||
}
|
||||
pWriter->EndRecord();
|
||||
}
|
||||
void Presentation::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
|
||||
{
|
||||
BYTE _type = pReader->GetUChar();
|
||||
LONG _len = pReader->GetULong();
|
||||
LONG _start_pos = pReader->GetPos();
|
||||
LONG _end_pos = _len + _start_pos;
|
||||
|
||||
// attributes
|
||||
BYTE _sa = pReader->GetUChar();
|
||||
|
||||
while (true)
|
||||
{
|
||||
BYTE _at = pReader->GetUChar_TypeNode();
|
||||
|
||||
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
|
||||
break;
|
||||
|
||||
switch (_at)
|
||||
{
|
||||
case 0: { attrAutoCompressPictures = pReader->GetBool(); break; }
|
||||
case 1: { attrBookmarkIdSeed = pReader->GetLong(); break; }
|
||||
case 2: { attrCompatMode = pReader->GetBool(); break; }
|
||||
case 3: { attrConformance = pReader->GetUChar(); break; }
|
||||
case 4: { attrEmbedTrueTypeFonts = pReader->GetBool(); break; }
|
||||
case 5: { attrFirstSlideNum = pReader->GetLong(); break; }
|
||||
case 6: { attrRemovePersonalInfoOnSave = pReader->GetBool(); break; }
|
||||
case 7: { attrRtl = pReader->GetBool(); break; }
|
||||
case 8: { attrSaveSubsetFonts = pReader->GetBool(); break; }
|
||||
case 9: { attrServerZoom = pReader->GetString2(); break; }
|
||||
case 10: { attrShowSpecialPlsOnTitleSld = pReader->GetBool(); break; }
|
||||
case 11: { attrStrictFirstAndLastChars = pReader->GetBool(); break; }
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
while (pReader->GetPos() < _end_pos)
|
||||
{
|
||||
_type = pReader->GetUChar();
|
||||
|
||||
switch (_type)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
defaultTextStyle = PPTX::Logic::TextListStyle();
|
||||
defaultTextStyle->m_name = _T("p:defaultTextStyle");
|
||||
defaultTextStyle->fromPPTY(pReader);
|
||||
break;
|
||||
}
|
||||
case 1: { pReader->SkipRecord(); break; }
|
||||
case 2: { pReader->SkipRecord(); break; }
|
||||
case 3:
|
||||
{
|
||||
notesSz = new nsPresentation::NotesSz();
|
||||
pReader->Skip(5); // len + start attributes
|
||||
|
||||
while (true)
|
||||
{
|
||||
BYTE _at = pReader->GetUChar_TypeNode();
|
||||
|
||||
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
|
||||
break;
|
||||
|
||||
switch (_at)
|
||||
{
|
||||
case 0: { notesSz->cx = pReader->GetLong(); break; }
|
||||
case 1: { notesSz->cy = pReader->GetLong(); break; }
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: { pReader->SkipRecord(); break; }
|
||||
case 5:
|
||||
{
|
||||
sldSz = new nsPresentation::SldSz();
|
||||
pReader->Skip(5); // len + start attributes
|
||||
|
||||
while (true)
|
||||
{
|
||||
BYTE _at = pReader->GetUChar_TypeNode();
|
||||
|
||||
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
|
||||
break;
|
||||
|
||||
switch (_at)
|
||||
{
|
||||
case 0: { sldSz->cx = pReader->GetLong(); break; }
|
||||
case 1: { sldSz->cy = pReader->GetLong(); break; }
|
||||
case 2: { sldSz->type = pReader->GetUChar(); break; }
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case 6:
|
||||
{
|
||||
commentAuthors = new PPTX::Authors(File::m_pMainDocument);
|
||||
commentAuthors->fromPPTY(pReader);
|
||||
}break;
|
||||
case 7:
|
||||
{
|
||||
sectionLst = new nsPresentation::SectionLst();
|
||||
sectionLst->fromPPTY(pReader);
|
||||
}break;
|
||||
case 8:
|
||||
{
|
||||
if (m_bMacroEnabled)
|
||||
{
|
||||
m_pVbaProject = new OOX::VbaProject(File::m_pMainDocument);
|
||||
m_pVbaProject->fromPPTY(pReader);
|
||||
|
||||
smart_ptr<OOX::File> file = m_pVbaProject.smart_dynamic_cast<OOX::File>();
|
||||
FileContainer::Add(file);
|
||||
}
|
||||
else
|
||||
pReader->SkipRecord();
|
||||
}break;
|
||||
case 9:
|
||||
{
|
||||
m_pJsaProject = new OOX::JsaProject(File::m_pMainDocument);
|
||||
m_pJsaProject->fromPPTY(pReader);
|
||||
|
||||
smart_ptr<OOX::File> file = m_pJsaProject.smart_dynamic_cast<OOX::File>();
|
||||
FileContainer::Add(file);
|
||||
}break;
|
||||
case 10:
|
||||
{
|
||||
comments = new PPTX::Comments(OOX::File::m_pMainDocument);
|
||||
comments->fromPPTY(pReader);
|
||||
}break;
|
||||
default:
|
||||
{
|
||||
pReader->SkipRecord();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pReader->Seek(_end_pos);
|
||||
}
|
||||
|
||||
void Presentation::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
|
||||
{
|
||||
pWriter->StartNode(_T("p:presentation"));
|
||||
|
||||
pWriter->StartAttributes();
|
||||
|
||||
pWriter->WriteAttribute(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink);
|
||||
pWriter->WriteAttribute(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink);
|
||||
pWriter->WriteAttribute(_T("xmlns:p"), PPTX::g_Namespaces.p.m_strLink);
|
||||
pWriter->WriteAttribute(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink);
|
||||
pWriter->WriteAttribute(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink);
|
||||
|
||||
pWriter->WriteAttribute(_T("autoCompressPictures"), attrAutoCompressPictures);
|
||||
pWriter->WriteAttribute(_T("bookmarkIdSeed"), attrBookmarkIdSeed);
|
||||
pWriter->WriteAttribute(_T("compatMode"), attrCompatMode);
|
||||
pWriter->WriteAttribute(_T("conformance"), attrConformance);
|
||||
pWriter->WriteAttribute(_T("embedTrueTypeFonts"), attrEmbedTrueTypeFonts);
|
||||
pWriter->WriteAttribute(_T("firstSlideNum"), attrFirstSlideNum);
|
||||
pWriter->WriteAttribute(_T("removePersonalInfoOnSave"), attrRemovePersonalInfoOnSave);
|
||||
pWriter->WriteAttribute(_T("rtl"), attrRtl);
|
||||
pWriter->WriteAttribute(_T("saveSubsetFonts"), attrSaveSubsetFonts);
|
||||
pWriter->WriteAttribute(_T("serverZoom"), attrServerZoom);
|
||||
pWriter->WriteAttribute(_T("showSpecialPlsOnTitleSld"), attrShowSpecialPlsOnTitleSld);
|
||||
pWriter->WriteAttribute(_T("strictFirstAndLastChars"), attrStrictFirstAndLastChars);
|
||||
|
||||
pWriter->EndAttributes();
|
||||
|
||||
pWriter->WriteArray(L"p:sldMasterIdLst", sldMasterIdLst);
|
||||
pWriter->WriteArray(L"p:notesMasterIdLst", notesMasterIdLst);
|
||||
pWriter->WriteArray(L"p:handoutMasterIdLst", handoutMasterIdLst);
|
||||
pWriter->WriteArray(L"p:embeddedFontLst", embeddedFontLst);
|
||||
pWriter->WriteArray(L"p:sldIdLst", sldIdLst);
|
||||
|
||||
pWriter->Write(sldSz);
|
||||
pWriter->Write(notesSz);
|
||||
pWriter->Write(photoAlbum);
|
||||
pWriter->Write(kinsoku);
|
||||
pWriter->Write(defaultTextStyle);
|
||||
|
||||
std::vector<Logic::Ext> extLst;
|
||||
|
||||
if (sectionLst.IsInit())
|
||||
{
|
||||
Logic::Ext exp;
|
||||
exp.sectionLst = sectionLst;
|
||||
extLst.push_back(exp);
|
||||
}
|
||||
pWriter->WriteArray(L"p:extLst", extLst);
|
||||
|
||||
pWriter->EndNode(L"p:presentation");
|
||||
}
|
||||
|
||||
AVSINLINE void Presentation::Normalize()
|
||||
{
|
||||
attrBookmarkIdSeed.normalize(1, 2147483647);
|
||||
attrFirstSlideNum.normalize_positive();
|
||||
}
|
||||
} // namespace PPTX
|
||||
@ -52,384 +52,22 @@
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Media/JsaProject.h"
|
||||
|
||||
|
||||
namespace PPTX
|
||||
{
|
||||
class Presentation : public WrapperFile, public PPTX::FileContainer
|
||||
{
|
||||
public:
|
||||
Presentation(OOX::Document *pMain) : WrapperFile(pMain), PPTX::FileContainer(pMain)
|
||||
{
|
||||
m_bMacroEnabled = false;
|
||||
}
|
||||
Presentation(OOX::Document *pMain, const OOX::CPath& filename, FileMap& map) : WrapperFile(pMain), PPTX::FileContainer(pMain)
|
||||
{
|
||||
m_bMacroEnabled = false;
|
||||
read(filename, map);
|
||||
}
|
||||
virtual ~Presentation()
|
||||
{
|
||||
}
|
||||
virtual void read(const OOX::CPath& filename, FileMap& map)
|
||||
{
|
||||
XmlUtils::CXmlNode oNode;
|
||||
oNode.FromXmlFile(filename.m_strFilename);
|
||||
Presentation(OOX::Document *pMain);
|
||||
Presentation(OOX::Document *pMain, const OOX::CPath& filename, FileMap& map);
|
||||
virtual ~Presentation();
|
||||
virtual void read(const OOX::CPath& filename, FileMap& map);
|
||||
virtual void write(const OOX::CPath& filename, const OOX::CPath& directory, OOX::CContentTypes& content)const;
|
||||
|
||||
XmlMacroReadAttributeBase(oNode, L"autoCompressPictures", attrAutoCompressPictures);
|
||||
XmlMacroReadAttributeBase(oNode, L"bookmarkIdSeed", attrBookmarkIdSeed);
|
||||
XmlMacroReadAttributeBase(oNode, L"compatMode", attrCompatMode);
|
||||
XmlMacroReadAttributeBase(oNode, L"conformance", attrConformance);
|
||||
XmlMacroReadAttributeBase(oNode, L"embedTrueTypeFonts", attrEmbedTrueTypeFonts);
|
||||
XmlMacroReadAttributeBase(oNode, L"firstSlideNum", attrFirstSlideNum);
|
||||
XmlMacroReadAttributeBase(oNode, L"removePersonalInfoOnSave", attrRemovePersonalInfoOnSave);
|
||||
XmlMacroReadAttributeBase(oNode, L"rtl", attrRtl);
|
||||
XmlMacroReadAttributeBase(oNode, L"saveSubsetFonts", attrSaveSubsetFonts);
|
||||
XmlMacroReadAttributeBase(oNode, L"serverZoom", attrServerZoom);
|
||||
XmlMacroReadAttributeBase(oNode, L"showSpecialPlsOnTitleSld", attrShowSpecialPlsOnTitleSld);
|
||||
XmlMacroReadAttributeBase(oNode, L"strictFirstAndLastChars", attrStrictFirstAndLastChars);
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
|
||||
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
|
||||
|
||||
//custDataLst (Customer Data List)
|
||||
//custShowLst (List of Custom Shows)
|
||||
defaultTextStyle = oNode.ReadNode(_T("p:defaultTextStyle"));
|
||||
if(defaultTextStyle.is_init())
|
||||
defaultTextStyle->SetParentFilePointer(this);
|
||||
|
||||
embeddedFontLst.clear();
|
||||
XmlUtils::CXmlNode oNodeEmbeddedFonts;
|
||||
if (oNode.GetNode(_T("p:embeddedFontLst"), oNodeEmbeddedFonts))
|
||||
{
|
||||
XmlMacroLoadArray(oNodeEmbeddedFonts, _T("p:embeddedFont"), embeddedFontLst, nsPresentation::EmbeddedFont);
|
||||
|
||||
for (size_t i = 0; i < embeddedFontLst.size(); ++i)
|
||||
embeddedFontLst[i].SetParentFilePointer(this);
|
||||
}
|
||||
|
||||
handoutMasterIdLst.clear();
|
||||
XmlUtils::CXmlNode oNodeHMList;
|
||||
if (oNode.GetNode(_T("p:handoutMasterIdLst"), oNodeHMList))
|
||||
{
|
||||
XmlMacroLoadArray(oNodeHMList, _T("p:handoutMasterId"), handoutMasterIdLst, Logic::XmlId);
|
||||
|
||||
for (size_t i = 0; i < handoutMasterIdLst.size(); ++i)
|
||||
handoutMasterIdLst[i].SetParentFilePointer(this);
|
||||
}
|
||||
|
||||
|
||||
kinsoku = oNode.ReadNode(_T("p:kinsoku"));
|
||||
if (kinsoku.is_init())
|
||||
kinsoku->SetParentFilePointer(this);
|
||||
|
||||
//modifyVerifier (Modification Verifier)
|
||||
notesMasterIdLst.clear();
|
||||
XmlUtils::CXmlNode oNodeMIDList;
|
||||
if (oNode.GetNode(_T("p:notesMasterIdLst"), oNodeMIDList))
|
||||
{
|
||||
XmlMacroLoadArray(oNodeMIDList, _T("p:notesMasterId"), notesMasterIdLst, Logic::XmlId);
|
||||
|
||||
for (size_t i = 0; i < notesMasterIdLst.size(); ++i)
|
||||
notesMasterIdLst[i].SetParentFilePointer(this);
|
||||
}
|
||||
|
||||
notesSz = oNode.ReadNode(_T("p:notesSz"));
|
||||
if (notesSz.is_init())
|
||||
notesSz->SetParentFilePointer(this);
|
||||
|
||||
photoAlbum = oNode.ReadNode(_T("p:photoAlbum"));
|
||||
if(photoAlbum.is_init())
|
||||
photoAlbum->SetParentFilePointer(this);
|
||||
|
||||
sldIdLst.clear();
|
||||
XmlUtils::CXmlNode oNode_sldId;
|
||||
if (oNode.GetNode(_T("p:sldIdLst"), oNode_sldId))
|
||||
{
|
||||
XmlMacroLoadArray(oNode_sldId, _T("p:sldId"), sldIdLst, Logic::XmlId);
|
||||
|
||||
for (size_t i = 0; i < sldIdLst.size(); ++i)
|
||||
sldIdLst[i].SetParentFilePointer(this);
|
||||
}
|
||||
|
||||
sldMasterIdLst.clear();
|
||||
XmlUtils::CXmlNode oNode_sldM_Id;
|
||||
if (oNode.GetNode(_T("p:sldMasterIdLst"), oNode_sldM_Id))
|
||||
{
|
||||
XmlMacroLoadArray(oNode_sldM_Id, _T("p:sldMasterId"), sldMasterIdLst, Logic::XmlId);
|
||||
|
||||
for (size_t i = 0; i < sldMasterIdLst.size(); ++i)
|
||||
sldMasterIdLst[i].SetParentFilePointer(this);
|
||||
}
|
||||
|
||||
sldSz = oNode.ReadNode(_T("p:sldSz"));
|
||||
if (sldSz.is_init())
|
||||
sldSz->SetParentFilePointer(this);
|
||||
|
||||
XmlUtils::CXmlNode list = oNode.ReadNodeNoNS(_T("extLst"));
|
||||
if (list.IsValid())
|
||||
{
|
||||
XmlUtils::CXmlNodes oNodes;
|
||||
if (list.GetNodes(_T("*"), oNodes))
|
||||
{
|
||||
int nCount = oNodes.GetCount();
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
XmlUtils::CXmlNode oNode;
|
||||
oNodes.GetAt(i, oNode);
|
||||
|
||||
PPTX::Logic::Ext ext;
|
||||
ext.fromXML(oNode);
|
||||
if (ext.sectionLst.IsInit())
|
||||
{
|
||||
sectionLst = ext.sectionLst;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//smartTags (Smart Tags)
|
||||
Normalize();
|
||||
}
|
||||
virtual void write(const OOX::CPath& filename, const OOX::CPath& directory, OOX::CContentTypes& content)const
|
||||
{
|
||||
WrapperFile::write(filename, directory, content);
|
||||
FileContainer::write(filename, directory, content);
|
||||
}
|
||||
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
pWriter->StartRecord(NSBinPptxRW::NSMainTables::Presentation);
|
||||
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
|
||||
|
||||
pWriter->WriteBool2(0, attrAutoCompressPictures);
|
||||
pWriter->WriteInt2(1, attrBookmarkIdSeed);
|
||||
pWriter->WriteBool2(2, attrCompatMode);
|
||||
pWriter->WriteLimit2(3, attrConformance);
|
||||
pWriter->WriteBool2(4, attrEmbedTrueTypeFonts);
|
||||
pWriter->WriteInt2(5, attrFirstSlideNum);
|
||||
pWriter->WriteBool2(6, attrRemovePersonalInfoOnSave);
|
||||
pWriter->WriteBool2(7, attrRtl);
|
||||
pWriter->WriteBool2(8, attrSaveSubsetFonts);
|
||||
pWriter->WriteString2(9, attrServerZoom);
|
||||
pWriter->WriteBool2(10, attrShowSpecialPlsOnTitleSld);
|
||||
pWriter->WriteBool2(11, attrStrictFirstAndLastChars);
|
||||
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
|
||||
|
||||
pWriter->WriteRecord2(0, defaultTextStyle);
|
||||
pWriter->WriteRecordArray(1, 0, embeddedFontLst);
|
||||
pWriter->WriteRecord2(2, kinsoku);
|
||||
pWriter->WriteRecord2(3, notesSz);
|
||||
pWriter->WriteRecord2(4, photoAlbum);
|
||||
pWriter->WriteRecord2(5, sldSz);
|
||||
|
||||
pWriter->WriteRecord2(6, commentAuthors);
|
||||
pWriter->WriteRecord2(7, sectionLst);
|
||||
|
||||
if (m_pVbaProject.IsInit())
|
||||
{
|
||||
pWriter->StartRecord(8);
|
||||
{
|
||||
m_pVbaProject->toPPTY(pWriter);
|
||||
}
|
||||
pWriter->EndRecord();
|
||||
}
|
||||
pWriter->WriteRecord2(9, m_pJsaProject);
|
||||
pWriter->WriteRecord2(10, comments);
|
||||
|
||||
pWriter->EndRecord();
|
||||
}
|
||||
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
|
||||
{
|
||||
BYTE _type = pReader->GetUChar();
|
||||
LONG _len = pReader->GetULong();
|
||||
LONG _start_pos = pReader->GetPos();
|
||||
LONG _end_pos = _len + _start_pos;
|
||||
|
||||
// attributes
|
||||
BYTE _sa = pReader->GetUChar();
|
||||
|
||||
while (true)
|
||||
{
|
||||
BYTE _at = pReader->GetUChar_TypeNode();
|
||||
|
||||
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
|
||||
break;
|
||||
|
||||
switch (_at)
|
||||
{
|
||||
case 0: { attrAutoCompressPictures = pReader->GetBool(); break; }
|
||||
case 1: { attrBookmarkIdSeed = pReader->GetLong(); break; }
|
||||
case 2: { attrCompatMode = pReader->GetBool(); break; }
|
||||
case 3: { attrConformance = pReader->GetUChar(); break; }
|
||||
case 4: { attrEmbedTrueTypeFonts = pReader->GetBool(); break; }
|
||||
case 5: { attrFirstSlideNum = pReader->GetLong(); break; }
|
||||
case 6: { attrRemovePersonalInfoOnSave = pReader->GetBool(); break; }
|
||||
case 7: { attrRtl = pReader->GetBool(); break; }
|
||||
case 8: { attrSaveSubsetFonts = pReader->GetBool(); break; }
|
||||
case 9: { attrServerZoom = pReader->GetString2(); break; }
|
||||
case 10: { attrShowSpecialPlsOnTitleSld = pReader->GetBool(); break; }
|
||||
case 11: { attrStrictFirstAndLastChars = pReader->GetBool(); break; }
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
while (pReader->GetPos() < _end_pos)
|
||||
{
|
||||
_type = pReader->GetUChar();
|
||||
|
||||
switch (_type)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
defaultTextStyle = PPTX::Logic::TextListStyle();
|
||||
defaultTextStyle->m_name = _T("p:defaultTextStyle");
|
||||
defaultTextStyle->fromPPTY(pReader);
|
||||
break;
|
||||
}
|
||||
case 1: { pReader->SkipRecord(); break; }
|
||||
case 2: { pReader->SkipRecord(); break; }
|
||||
case 3:
|
||||
{
|
||||
notesSz = new nsPresentation::NotesSz();
|
||||
pReader->Skip(5); // len + start attributes
|
||||
|
||||
while (true)
|
||||
{
|
||||
BYTE _at = pReader->GetUChar_TypeNode();
|
||||
|
||||
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
|
||||
break;
|
||||
|
||||
switch (_at)
|
||||
{
|
||||
case 0: { notesSz->cx = pReader->GetLong(); break; }
|
||||
case 1: { notesSz->cy = pReader->GetLong(); break; }
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: { pReader->SkipRecord(); break; }
|
||||
case 5:
|
||||
{
|
||||
sldSz = new nsPresentation::SldSz();
|
||||
pReader->Skip(5); // len + start attributes
|
||||
|
||||
while (true)
|
||||
{
|
||||
BYTE _at = pReader->GetUChar_TypeNode();
|
||||
|
||||
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
|
||||
break;
|
||||
|
||||
switch (_at)
|
||||
{
|
||||
case 0: { sldSz->cx = pReader->GetLong(); break; }
|
||||
case 1: { sldSz->cy = pReader->GetLong(); break; }
|
||||
case 2: { sldSz->type = pReader->GetUChar(); break; }
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case 6:
|
||||
{
|
||||
commentAuthors = new PPTX::Authors(File::m_pMainDocument);
|
||||
commentAuthors->fromPPTY(pReader);
|
||||
}break;
|
||||
case 7:
|
||||
{
|
||||
sectionLst = new nsPresentation::SectionLst();
|
||||
sectionLst->fromPPTY(pReader);
|
||||
}break;
|
||||
case 8:
|
||||
{
|
||||
if (m_bMacroEnabled)
|
||||
{
|
||||
m_pVbaProject = new OOX::VbaProject(File::m_pMainDocument);
|
||||
m_pVbaProject->fromPPTY(pReader);
|
||||
|
||||
smart_ptr<OOX::File> file = m_pVbaProject.smart_dynamic_cast<OOX::File>();
|
||||
FileContainer::Add(file);
|
||||
}
|
||||
else
|
||||
pReader->SkipRecord();
|
||||
}break;
|
||||
case 9:
|
||||
{
|
||||
m_pJsaProject = new OOX::JsaProject(File::m_pMainDocument);
|
||||
m_pJsaProject->fromPPTY(pReader);
|
||||
|
||||
smart_ptr<OOX::File> file = m_pJsaProject.smart_dynamic_cast<OOX::File>();
|
||||
FileContainer::Add(file);
|
||||
}break;
|
||||
case 10:
|
||||
{
|
||||
comments = new PPTX::Comments(OOX::File::m_pMainDocument);
|
||||
comments->fromPPTY(pReader);
|
||||
}break;
|
||||
default:
|
||||
{
|
||||
pReader->SkipRecord();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pReader->Seek(_end_pos);
|
||||
}
|
||||
|
||||
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
|
||||
{
|
||||
pWriter->StartNode(_T("p:presentation"));
|
||||
|
||||
pWriter->StartAttributes();
|
||||
|
||||
pWriter->WriteAttribute(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink);
|
||||
pWriter->WriteAttribute(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink);
|
||||
pWriter->WriteAttribute(_T("xmlns:p"), PPTX::g_Namespaces.p.m_strLink);
|
||||
pWriter->WriteAttribute(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink);
|
||||
pWriter->WriteAttribute(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink);
|
||||
|
||||
pWriter->WriteAttribute(_T("autoCompressPictures"), attrAutoCompressPictures);
|
||||
pWriter->WriteAttribute(_T("bookmarkIdSeed"), attrBookmarkIdSeed);
|
||||
pWriter->WriteAttribute(_T("compatMode"), attrCompatMode);
|
||||
pWriter->WriteAttribute(_T("conformance"), attrConformance);
|
||||
pWriter->WriteAttribute(_T("embedTrueTypeFonts"), attrEmbedTrueTypeFonts);
|
||||
pWriter->WriteAttribute(_T("firstSlideNum"), attrFirstSlideNum);
|
||||
pWriter->WriteAttribute(_T("removePersonalInfoOnSave"), attrRemovePersonalInfoOnSave);
|
||||
pWriter->WriteAttribute(_T("rtl"), attrRtl);
|
||||
pWriter->WriteAttribute(_T("saveSubsetFonts"), attrSaveSubsetFonts);
|
||||
pWriter->WriteAttribute(_T("serverZoom"), attrServerZoom);
|
||||
pWriter->WriteAttribute(_T("showSpecialPlsOnTitleSld"), attrShowSpecialPlsOnTitleSld);
|
||||
pWriter->WriteAttribute(_T("strictFirstAndLastChars"), attrStrictFirstAndLastChars);
|
||||
|
||||
pWriter->EndAttributes();
|
||||
|
||||
pWriter->WriteArray(L"p:sldMasterIdLst", sldMasterIdLst);
|
||||
pWriter->WriteArray(L"p:notesMasterIdLst", notesMasterIdLst);
|
||||
pWriter->WriteArray(L"p:handoutMasterIdLst", handoutMasterIdLst);
|
||||
pWriter->WriteArray(L"p:embeddedFontLst", embeddedFontLst);
|
||||
pWriter->WriteArray(L"p:sldIdLst", sldIdLst);
|
||||
|
||||
pWriter->Write(sldSz);
|
||||
pWriter->Write(notesSz);
|
||||
pWriter->Write(photoAlbum);
|
||||
pWriter->Write(kinsoku);
|
||||
pWriter->Write(defaultTextStyle);
|
||||
|
||||
std::vector<Logic::Ext> extLst;
|
||||
|
||||
if (sectionLst.IsInit())
|
||||
{
|
||||
Logic::Ext exp;
|
||||
exp.sectionLst = sectionLst;
|
||||
extLst.push_back(exp);
|
||||
}
|
||||
pWriter->WriteArray(L"p:extLst", extLst);
|
||||
|
||||
pWriter->EndNode(L"p:presentation");
|
||||
}
|
||||
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;
|
||||
|
||||
virtual const OOX::FileType type() const
|
||||
{
|
||||
@ -508,10 +146,6 @@ namespace PPTX
|
||||
}
|
||||
|
||||
private:
|
||||
AVSINLINE void Normalize()
|
||||
{
|
||||
attrBookmarkIdSeed.normalize(1, 2147483647);
|
||||
attrFirstSlideNum.normalize_positive();
|
||||
}
|
||||
AVSINLINE void Normalize();
|
||||
};
|
||||
} // namespace PPTX
|
||||
|
||||
@ -48,7 +48,7 @@ SOURCES += \
|
||||
../../../PPTXFormat/Logic/Colors/SchemeClr.cpp \
|
||||
../../../PPTXFormat/Logic/Fills/Blip.cpp \
|
||||
../../../PPTXFormat/Logic/Fills/BlipFill.cpp \
|
||||
../../../PPTXFormat/Logic/Table/TableCell.cpp \
|
||||
../../../PPTXFormat/Logic/Table/TableCell.cpp \
|
||||
../../../PPTXFormat/Logic/Timing/BuildNodeBase.cpp \
|
||||
../../../PPTXFormat/Logic/Timing/TimeNodeBase.cpp \
|
||||
../../../PPTXFormat/Logic/Transitions/TransitionBase.cpp \
|
||||
@ -62,7 +62,7 @@ SOURCES += \
|
||||
../../../PPTXFormat/Logic/EffectStyle.cpp \
|
||||
../../../PPTXFormat/Logic/Geometry.cpp \
|
||||
../../../PPTXFormat/Logic/GraphicFrame.cpp \
|
||||
../../../PPTXFormat/Logic/HeadingVariant.cpp \
|
||||
../../../PPTXFormat/Logic/HeadingVariant.cpp \
|
||||
../../../PPTXFormat/Logic/GrpSpPr.cpp \
|
||||
../../../PPTXFormat/Logic/Hyperlink.cpp \
|
||||
../../../PPTXFormat/Logic/NvGraphicFramePr.cpp \
|
||||
@ -79,6 +79,7 @@ SOURCES += \
|
||||
../../../PPTXFormat/Logic/UniEffect.cpp \
|
||||
../../../PPTXFormat/Logic/Runs/MathParaWrapper.cpp \
|
||||
../../../PPTXFormat/Logic/Controls.cpp \
|
||||
../../../PPTXFormat/Presentation.cpp \
|
||||
../../../PPTXFormat/FileContainer.cpp \
|
||||
../../../PPTXFormat/FileFactory.cpp \
|
||||
../../../PPTXFormat/FileMap.cpp \
|
||||
|
||||
@ -68,3 +68,4 @@
|
||||
#include "../../../PPTXFormat/FileFactory.cpp"
|
||||
#include "../../../PPTXFormat/FileMap.cpp"
|
||||
#include "../../../PPTXFormat/Folder.cpp"
|
||||
#include "../../../PPTXFormat/Presentation.cpp"
|
||||
|
||||
@ -339,6 +339,7 @@
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">./StdAfx.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\PPTXFormat\Logic\UniFill.cpp" />
|
||||
<ClCompile Include="..\PPTXFormat\Presentation.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\Common\DocxFormat\Source\DocxFormat\Namespaces.h" />
|
||||
|
||||
@ -275,6 +275,9 @@
|
||||
<ClCompile Include="..\PPTXFormat\Logic\HeadingVariant.cpp">
|
||||
<Filter>PPTX\Logic</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\PPTXFormat\Presentation.cpp">
|
||||
<Filter>PPTX\Presentation</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Editor\BinaryFileReaderWriter.h">
|
||||
|
||||
@ -36,9 +36,7 @@
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
|
||||
// Logical representation of Continue record in BIFF8
|
||||
class Continue: public BiffRecord
|
||||
class Continue: public BiffRecord
|
||||
{
|
||||
BIFF_RECORD_DEFINE_TYPE_INFO(Continue)
|
||||
BASE_OBJECT_DEFINE_CLASS_NAME(Continue)
|
||||
@ -47,7 +45,6 @@ public:
|
||||
~Continue();
|
||||
|
||||
BaseObjectPtr clone();
|
||||
|
||||
|
||||
void readFields(CFRecord& record);
|
||||
|
||||
|
||||
@ -35,27 +35,23 @@
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
PicF::PicF()
|
||||
{
|
||||
}
|
||||
PicF::PicF() {}
|
||||
PicF::~PicF() {}
|
||||
|
||||
BaseObjectPtr PicF::clone()
|
||||
{
|
||||
return BaseObjectPtr(new PicF(*this));
|
||||
}
|
||||
|
||||
PicF::~PicF()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BaseObjectPtr PicF::clone()
|
||||
{
|
||||
return BaseObjectPtr(new PicF(*this));
|
||||
}
|
||||
|
||||
|
||||
void PicF::readFields(CFRecord& record)
|
||||
{
|
||||
Log::error("PicF record is not implemented.");
|
||||
record.skipNunBytes(record.getDataSize() - record.getRdPtr());
|
||||
}
|
||||
void PicF::readFields(CFRecord& record)
|
||||
{
|
||||
unsigned short unused, flags;
|
||||
record >> ptyp >> unused >> flags >> numScale;
|
||||
|
||||
fTopBottom = GETBIT(flags, 9);
|
||||
fBackFront = GETBIT(flags, 10);
|
||||
fSide = GETBIT(flags, 11);
|
||||
}
|
||||
|
||||
} // namespace XLS
|
||||
|
||||
|
||||
@ -31,13 +31,10 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "BiffRecord.h"
|
||||
#include "../Biff_structures/Xnum.h"
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
|
||||
// Logical representation of PicF record in BIFF8
|
||||
class PicF: public BiffRecord
|
||||
{
|
||||
BIFF_RECORD_DEFINE_TYPE_INFO(PicF)
|
||||
@ -45,13 +42,20 @@ class PicF: public BiffRecord
|
||||
public:
|
||||
PicF();
|
||||
~PicF();
|
||||
|
||||
BaseObjectPtr clone();
|
||||
|
||||
|
||||
void readFields(CFRecord& record);
|
||||
|
||||
static const ElementType type = typePicF;
|
||||
static const ElementType type = typePicF;
|
||||
|
||||
unsigned short ptyp;
|
||||
|
||||
bool fTopBottom;
|
||||
bool fBackFront;
|
||||
bool fSide;
|
||||
|
||||
Xnum numScale;
|
||||
|
||||
};
|
||||
|
||||
} // namespace XLS
|
||||
|
||||
@ -120,11 +120,17 @@ void OfficeArtRGFOPTE::load(XLS::CFRecord& record)
|
||||
}
|
||||
//-----complex load
|
||||
|
||||
for(std::vector<OfficeArtFOPTEPtr>::iterator it = rgfopte.begin(), itEnd = rgfopte.end(); it != itEnd; ++it)
|
||||
for (size_t i = 0; i < rgfopte.size(); ++i)
|
||||
{
|
||||
if((*it)->fComplex && (*it)->op > 0)
|
||||
if (!rgfopte[i]) continue;
|
||||
|
||||
if (rgfopte[i]->fComplex)
|
||||
{
|
||||
(*it)->ReadComplexData(record);
|
||||
if (rgfopte[i]->op < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
rgfopte[i]->ReadComplexData(record);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -64,26 +64,24 @@ const bool GELFRAME::loadContent(BinProcessor& proc)
|
||||
{
|
||||
global_info = proc.getGlobalWorkbookInfo();
|
||||
|
||||
if(!proc.mandatory<GelFrame>())
|
||||
int count = proc.repeated<GelFrame>(1, 2);
|
||||
|
||||
if (elements_.empty()) return false;
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_GelFrame = elements_.back();
|
||||
elements_.pop_back();
|
||||
|
||||
if (proc.optional<GelFrame>())
|
||||
{
|
||||
GelFrame * base = dynamic_cast<GelFrame*>(m_GelFrame.get());
|
||||
GelFrame * addit = dynamic_cast<GelFrame*>(elements_.back().get());
|
||||
m_GelFrame = elements_.front();
|
||||
GelFrame * base = dynamic_cast<GelFrame*>(m_GelFrame.get());
|
||||
GelFrame * addit = count > 1 ? dynamic_cast<GelFrame*>(elements_.back().get()) : NULL;
|
||||
|
||||
if (base && addit)
|
||||
{
|
||||
base->concatinate(addit);
|
||||
}
|
||||
elements_.pop_back();
|
||||
elements_.clear();
|
||||
}
|
||||
//
|
||||
int count = proc.repeated<Continue>(0, 0);
|
||||
|
||||
count = proc.repeated<Continue>(0, 0);
|
||||
|
||||
if (proc.optional<PICF>())
|
||||
{
|
||||
|
||||
@ -36,8 +36,6 @@
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
|
||||
// Logical representation of PICF union of records
|
||||
class PICF: public CompositeObject
|
||||
{
|
||||
BASE_OBJECT_DEFINE_CLASS_NAME(PICF)
|
||||
|
||||
@ -37,37 +37,25 @@
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
|
||||
PICF::PICF()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PICF::~PICF()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BaseObjectPtr PICF::clone()
|
||||
{
|
||||
return BaseObjectPtr(new PICF(*this));
|
||||
}
|
||||
|
||||
|
||||
// PICF = Begin PicF End
|
||||
const bool PICF::loadContent(BinProcessor& proc)
|
||||
{
|
||||
if(!proc.mandatory<Begin>())
|
||||
PICF::PICF() {}
|
||||
PICF::~PICF() {}
|
||||
BaseObjectPtr PICF::clone()
|
||||
{
|
||||
return false;
|
||||
} elements_.pop_back();
|
||||
proc.mandatory<PicF>();
|
||||
m_PicF = elements_.back(); elements_.pop_back();
|
||||
proc.mandatory<End>(); elements_.pop_back();
|
||||
return BaseObjectPtr(new PICF(*this));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
// PICF = Begin PicF End
|
||||
const bool PICF::loadContent(BinProcessor& proc)
|
||||
{
|
||||
if (!proc.mandatory<Begin>())
|
||||
{
|
||||
return false;
|
||||
} elements_.pop_back();
|
||||
proc.mandatory<PicF>();
|
||||
m_PicF = elements_.back(); elements_.pop_back();
|
||||
proc.mandatory<End>(); elements_.pop_back();
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace XLS
|
||||
|
||||
|
||||
@ -33,8 +33,6 @@
|
||||
|
||||
#include "BaseObject.h"
|
||||
#include "Biff_structures/BiffAttribute.h"
|
||||
#include "Biff_structures/BiffStructure.h"
|
||||
#include "Biff_structures/BiffStructure.h"
|
||||
#include "GlobalWorkbookInfo.h"
|
||||
|
||||
namespace XLS
|
||||
|
||||
@ -0,0 +1,329 @@
|
||||
/*
|
||||
* (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 <string>
|
||||
|
||||
#include "CodePageOle.h"
|
||||
#include "../../Binary/CFStream.h"
|
||||
#include "../../Auxiliary/HelpFunc.h"
|
||||
#include "../../../Common/simple_xml_writer.h"
|
||||
|
||||
#include "../../../../../UnicodeConverter/UnicodeConverter.h"
|
||||
|
||||
#include <boost/date_time.hpp>
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
|
||||
bool PropertyCodePage::Read (XLS::CFStreamPtr stream)
|
||||
{
|
||||
if (value_type == Property::VT_I2)
|
||||
{
|
||||
*stream >> code_page;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
std::wstring PropertyCodePage::toString()
|
||||
{
|
||||
return std::to_wstring(code_page);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
bool PropertyString::Read (XLS::CFStreamPtr stream)
|
||||
{
|
||||
if (value_type != Property::VT_LPSTR) return false;
|
||||
|
||||
_INT32 size;
|
||||
*stream >> size;
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
char *s = new char[size];
|
||||
stream->read(s, size);
|
||||
|
||||
for (_INT32 i = size - 1; i >= 0; i--)
|
||||
{
|
||||
if (s[i] == 0) size--;
|
||||
}
|
||||
|
||||
value = size > 0 ? STR::toStdWString(std::string(s, size), code_page) : L"";
|
||||
delete[]s;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
std::wstring PropertyString::toString()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
bool PropertyWString::Read(XLS::CFStreamPtr stream)
|
||||
{
|
||||
if (value_type != Property::VT_LPWSTR) return false;
|
||||
|
||||
_INT32 size;
|
||||
*stream >> size;
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
char *s = new char[size];
|
||||
stream->read(s, size);
|
||||
|
||||
value = std::wstring((wchar_t*)s, size / 2);
|
||||
|
||||
delete[]s;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
std::wstring PropertyWString::toString()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
bool PropertyDTM::Read (XLS::CFStreamPtr stream)
|
||||
{
|
||||
dwLowDateTime = 0, dwHighDateTime = 0;
|
||||
if (value_type == Property::VT_FILETIME)
|
||||
{
|
||||
*stream >> dwLowDateTime >> dwHighDateTime;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
std::wstring PropertyDTM::toString()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
boost::winapi::FILETIME_ ft;
|
||||
ft.dwHighDateTime = dwHighDateTime;
|
||||
ft.dwLowDateTime = dwLowDateTime;
|
||||
|
||||
boost::posix_time::ptime date_time_ = boost::posix_time::from_ftime<boost::posix_time::ptime>(ft);
|
||||
|
||||
short Min = (short)date_time_.time_of_day().minutes();
|
||||
short Hour = (short)date_time_.time_of_day().hours();
|
||||
short Day = (short)date_time_.date().day();
|
||||
short Month = (short)date_time_.date().month().as_number();
|
||||
int Year = (short)date_time_.date().year();
|
||||
|
||||
std::wstring value = std::to_wstring(Year)
|
||||
+ L"-" + (Month < 10 ? L"0" : L"") + std::to_wstring(Month)
|
||||
+ L"-" + (Day < 10 ? L"0" : L"") + std::to_wstring(Day);
|
||||
|
||||
int hours = 0, minutes = 0;
|
||||
double sec = 0;
|
||||
|
||||
value += L"T";
|
||||
value += (Hour < 10 ? L"0" : L"") + std::to_wstring(Hour) + L":" +
|
||||
(Min < 10 ? L"0" : L"") + std::to_wstring(Min) + L":00Z";
|
||||
return value;
|
||||
#else
|
||||
return L"";
|
||||
#endif
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
bool PropertyInt::Read (XLS::CFStreamPtr stream)
|
||||
{
|
||||
value = 0;
|
||||
if (value_type == Property::VT_I4)
|
||||
{
|
||||
*stream >> value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
std::wstring PropertyInt::toString()
|
||||
{
|
||||
return std::to_wstring(value);
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
bool PropertyBool::Read (XLS::CFStreamPtr stream)
|
||||
{
|
||||
value = false;
|
||||
if (value_type == Property::VT_BOOL)
|
||||
{
|
||||
_UINT32 v;
|
||||
*stream >> v;
|
||||
|
||||
if (v != 0)
|
||||
value = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
std::wstring PropertyBool::toString()
|
||||
{
|
||||
return value ? L"1" : L"0";
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
bool PropertyVecString::Read(XLS::CFStreamPtr stream)
|
||||
{
|
||||
_INT32 count;
|
||||
*stream >> count;
|
||||
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
PropertyString str(0, 0x001E, code_page);
|
||||
str.Read(stream);
|
||||
|
||||
values.push_back(str.value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
std::wstring PropertyVecString::toString()
|
||||
{
|
||||
std::wstringstream output;
|
||||
CP_XML_WRITER(output)
|
||||
{
|
||||
CP_XML_NODE(L"vt:vector")
|
||||
{
|
||||
CP_XML_ATTR(L"size", values.size());
|
||||
CP_XML_ATTR(L"baseType", L"lpstr");
|
||||
|
||||
for (size_t i = 0; i < values.size(); ++i)
|
||||
{
|
||||
CP_XML_NODE(L"vt:lpstr")
|
||||
{
|
||||
CP_XML_STREAM() << values[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return output.str();
|
||||
}//-------------------------------------------------------------------
|
||||
bool PropertyVecHeadingPair::Read(XLS::CFStreamPtr stream)
|
||||
{
|
||||
_INT32 count;
|
||||
*stream >> count;
|
||||
|
||||
for (size_t i = 0; i < count / 2; ++i)
|
||||
{
|
||||
HeadingPair pair;
|
||||
|
||||
_INT16 type, padding;
|
||||
*stream >> type >> padding;
|
||||
|
||||
if (type == 0x001E)
|
||||
{
|
||||
PropertyString str(0, type, code_page);
|
||||
str.Read(stream);
|
||||
|
||||
pair.headingString = str.value;
|
||||
}
|
||||
else if (type == 0x001F)
|
||||
{
|
||||
PropertyWString str(0, type);
|
||||
str.Read(stream);
|
||||
|
||||
pair.headingString = str.value;
|
||||
}
|
||||
|
||||
*stream >> type >> padding >> pair.headerParts;
|
||||
|
||||
values.push_back(pair);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
std::wstring PropertyVecHeadingPair::toString()
|
||||
{
|
||||
std::wstringstream output;
|
||||
CP_XML_WRITER(output)
|
||||
{
|
||||
CP_XML_NODE(L"vt:vector")
|
||||
{
|
||||
CP_XML_ATTR(L"size", values.size() * 2);
|
||||
CP_XML_ATTR(L"baseType", L"variant");
|
||||
|
||||
for (size_t i = 0; i < values.size(); ++i)
|
||||
{
|
||||
CP_XML_NODE(L"vt:variant")
|
||||
{
|
||||
CP_XML_NODE(L"vt:lpstr")
|
||||
{
|
||||
CP_XML_STREAM() << values[i].headingString;
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"vt:variant")
|
||||
{
|
||||
CP_XML_NODE(L"vt:i4")
|
||||
{
|
||||
CP_XML_STREAM() << values[i].headerParts;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return output.str();
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
bool PropertyDigSig::Read(XLS::CFStreamPtr stream)
|
||||
{
|
||||
_INT32 cb;
|
||||
unsigned long pos_start = stream->getStreamPointer();
|
||||
*stream >> cb >> data.serializedPointer;
|
||||
|
||||
data.sigInfo.Read(stream);
|
||||
|
||||
stream->seekFromBegin(pos_start + cb);
|
||||
return true;
|
||||
}
|
||||
bool PropertyDigSig::SignatureInfo::Read(XLS::CFStreamPtr stream)
|
||||
{
|
||||
*stream >> cbSignature >> signatureOffset >> cbSigningCertStore >> certStoreOffset >> certStoreOffset >>
|
||||
cbProjectName >> projectNameOffset >> fTimestamp >> cbTimestampUrl >> timestampUrlOffset;
|
||||
|
||||
pbSignatureBuffer = boost::shared_array<char>(new char[cbSigningCertStore]);
|
||||
stream->read(pbSignatureBuffer.get(), cbSigningCertStore);
|
||||
|
||||
pbSigningCertStoreBuffer.Read(stream);
|
||||
|
||||
//rgchProjectNameBuffer; //null-terminate
|
||||
//rgchTimestampBuffer;
|
||||
return true;
|
||||
}
|
||||
bool PropertyDigSig::SerializedPropertyEntry::Read(XLS::CFStreamPtr stream)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool PropertyDigSig::SerializedCertificateEntry::Read(XLS::CFStreamPtr stream)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool PropertyDigSig::CertStoreCertificateGroup::Read(XLS::CFStreamPtr stream)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool PropertyDigSig::VBASigSerializedCertStore::Read(XLS::CFStreamPtr stream)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
std::wstring PropertyDigSig::toString()
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
|
||||
} // namespace OLEPS
|
||||
@ -0,0 +1,241 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#include "Property.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <boost/smart_ptr/shared_array.hpp>
|
||||
#include "../../../../../../Common/DocxFormat/Source/Base/Types_32.h"
|
||||
namespace OLEPS
|
||||
{
|
||||
|
||||
class PropertyCodePage : public Property
|
||||
{
|
||||
public:
|
||||
PropertyCodePage(unsigned int prop_type, const unsigned short value_type) : Property(prop_type, value_type), code_page(0)
|
||||
{
|
||||
}
|
||||
virtual bool Read(XLS::CFStreamPtr stream);
|
||||
virtual std::wstring toString();
|
||||
|
||||
static const unsigned short DefaultCodePage = 1250;
|
||||
unsigned short code_page;
|
||||
};
|
||||
typedef boost::shared_ptr<PropertyCodePage> PropertyCodePagePtr;
|
||||
//-----------------------------------------------------------------------------------------
|
||||
class PropertyString : public Property
|
||||
{
|
||||
public:
|
||||
PropertyString(unsigned int prop_type, const unsigned short value_type, unsigned short code_page_) : Property(prop_type, value_type)
|
||||
{
|
||||
code_page = code_page_;
|
||||
}
|
||||
|
||||
virtual bool Read(XLS::CFStreamPtr stream);
|
||||
virtual std::wstring toString();
|
||||
|
||||
std::wstring value;
|
||||
unsigned short code_page;
|
||||
};
|
||||
typedef boost::shared_ptr<PropertyString> PropertyStringPtr;
|
||||
//-----------------------------------------------------------------------------------------
|
||||
class PropertyWString : public Property
|
||||
{
|
||||
public:
|
||||
PropertyWString(unsigned int prop_type, const unsigned short value_type) : Property(prop_type, value_type)
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool Read(XLS::CFStreamPtr stream);
|
||||
virtual std::wstring toString();
|
||||
|
||||
std::wstring value;
|
||||
};
|
||||
typedef boost::shared_ptr<PropertyWString> PropertyWStringPtr;
|
||||
//-----------------------------------------------------------------------------------------
|
||||
class PropertyDTM : public Property
|
||||
{
|
||||
public:
|
||||
PropertyDTM(unsigned int prop_type, const unsigned short value_type) : Property(prop_type, value_type)
|
||||
{
|
||||
}
|
||||
|
||||
virtual std::wstring toString();
|
||||
virtual bool Read(XLS::CFStreamPtr stream);
|
||||
|
||||
_UINT32 dwLowDateTime;
|
||||
_UINT32 dwHighDateTime;
|
||||
};
|
||||
typedef boost::shared_ptr<PropertyDTM> PropertyDTMPtr;
|
||||
//-----------------------------------------------------------------------------------------
|
||||
class PropertyInt : public Property
|
||||
{
|
||||
public:
|
||||
PropertyInt(unsigned int prop_type, const unsigned short value_type) : Property(prop_type, value_type)
|
||||
{
|
||||
}
|
||||
virtual bool Read(XLS::CFStreamPtr stream);
|
||||
virtual std::wstring toString();
|
||||
|
||||
_UINT32 value;
|
||||
};
|
||||
typedef boost::shared_ptr<PropertyInt> PropertyIntPtr;
|
||||
//-----------------------------------------------------------------------------------------
|
||||
class PropertyBool : public Property
|
||||
{
|
||||
public:
|
||||
PropertyBool(unsigned int prop_type, const unsigned short value_type) : Property(prop_type, value_type)
|
||||
{
|
||||
}
|
||||
virtual bool Read(XLS::CFStreamPtr stream);
|
||||
virtual std::wstring toString();
|
||||
|
||||
bool value;
|
||||
};
|
||||
typedef boost::shared_ptr<PropertyDTM> PropertyDTMPtr;
|
||||
//----------------------------------------------------------------------------------
|
||||
class PropertyVecString : public Property
|
||||
{
|
||||
public:
|
||||
PropertyVecString(unsigned int prop_type, const unsigned short value_type, unsigned short code_page_) : Property(prop_type, value_type)
|
||||
{
|
||||
code_page = code_page_;
|
||||
}
|
||||
|
||||
virtual bool Read(XLS::CFStreamPtr stream);
|
||||
virtual std::wstring toString();
|
||||
|
||||
std::vector<std::wstring> values;
|
||||
unsigned short code_page;
|
||||
};
|
||||
typedef boost::shared_ptr<PropertyVecString> PropertyVecStringPtr;
|
||||
//----------------------------------------------------------------------------------
|
||||
class PropertyVecHeadingPair : public Property
|
||||
{
|
||||
public:
|
||||
struct HeadingPair
|
||||
{
|
||||
std::wstring headingString;
|
||||
_INT32 headerParts; // + TypeId(2) + Padding(2)
|
||||
};
|
||||
PropertyVecHeadingPair(unsigned int prop_type, const unsigned short value_type, unsigned short code_page_) : Property(prop_type, value_type)
|
||||
{
|
||||
code_page = code_page_;
|
||||
}
|
||||
|
||||
virtual bool Read(XLS::CFStreamPtr stream);
|
||||
virtual std::wstring toString();
|
||||
|
||||
std::vector<HeadingPair> values;
|
||||
unsigned short code_page;
|
||||
};
|
||||
typedef boost::shared_ptr<PropertyVecHeadingPair> PropertyVecHeadingPairPtr;
|
||||
//----------------------------------------------------------------------------------
|
||||
class PropertyDigSig : public Property
|
||||
{
|
||||
public:
|
||||
struct SerializedPropertyEntry
|
||||
{
|
||||
_UINT32 id = 0x00000020;
|
||||
_UINT32 encodingType;
|
||||
_UINT32 length;
|
||||
boost::shared_array<char> value; //ignored for read
|
||||
|
||||
bool Read(XLS::CFStreamPtr stream);
|
||||
};
|
||||
struct SerializedCertificateEntry
|
||||
{
|
||||
_UINT32 id = 0x00000020;
|
||||
_UINT32 encodingType;
|
||||
_UINT32 length;
|
||||
boost::shared_array<char> certificate; //ASN.1 [ITUX680-1994] DER encoding of an X.509 certificate as specified by [RFC3280].
|
||||
|
||||
bool Read(XLS::CFStreamPtr stream);
|
||||
};
|
||||
struct CertStoreCertificateGroup
|
||||
{
|
||||
std::vector<SerializedPropertyEntry> elementList; // until SerializedPropertyEntry.id == 0x00000020
|
||||
SerializedCertificateEntry certificateElement;
|
||||
|
||||
bool Read(XLS::CFStreamPtr stream);
|
||||
};
|
||||
struct EndElementMarkerEntry
|
||||
{
|
||||
_UINT32 id = 0x00000000;
|
||||
_UINT64 marker = 0x0000000000000000;
|
||||
};
|
||||
struct VBASigSerializedCertStore
|
||||
{
|
||||
_UINT32 version;
|
||||
_UINT32 fileType = 0x54524543;
|
||||
CertStoreCertificateGroup certGroup;
|
||||
EndElementMarkerEntry endMarkerElement;
|
||||
|
||||
bool Read(XLS::CFStreamPtr stream);
|
||||
};
|
||||
struct SignatureInfo
|
||||
{
|
||||
_UINT32 cbSignature;
|
||||
_UINT32 signatureOffset;
|
||||
_UINT32 cbSigningCertStore;
|
||||
_UINT32 certStoreOffset;
|
||||
_UINT32 cbProjectName;
|
||||
_UINT32 projectNameOffset;
|
||||
_UINT32 fTimestamp = 0; //reserved
|
||||
_UINT32 cbTimestampUrl = 0; //reserved
|
||||
_UINT32 timestampUrlOffset;
|
||||
|
||||
boost::shared_array<char> pbSignatureBuffer; //PKCS #7 SignedData (cbSigningCertStore)
|
||||
VBASigSerializedCertStore pbSigningCertStoreBuffer;
|
||||
|
||||
std::wstring rgchProjectNameBuffer; //null-terminate
|
||||
std::wstring rgchTimestampBuffer;
|
||||
|
||||
bool Read(XLS::CFStreamPtr stream);
|
||||
};
|
||||
struct DigSigBlob
|
||||
{
|
||||
_UINT32 cb;
|
||||
_UINT32 serializedPointer;
|
||||
SignatureInfo sigInfo;
|
||||
// padding; //skip for reading
|
||||
};
|
||||
PropertyDigSig(unsigned int prop_type, const unsigned short value_type) : Property(prop_type, value_type) {}
|
||||
|
||||
virtual bool Read(XLS::CFStreamPtr stream);
|
||||
virtual std::wstring toString();
|
||||
|
||||
DigSigBlob data;
|
||||
};
|
||||
typedef boost::shared_ptr<PropertyDigSig> PropertyDigSigPtr;
|
||||
} // namespace OLEPS
|
||||
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include "../../Binary/BinSmartPointers.h"
|
||||
#include <string>
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
enum Property_Identifier
|
||||
{
|
||||
//---------- ext - 2.3.3.2.1.1 PIDSI
|
||||
CODEPAGE = 0x0001,
|
||||
TITLE = 0x0002,
|
||||
SUBJECT = 0x0003,
|
||||
AUTHOR = 0x0004,
|
||||
KEYWORDS = 0x0005,
|
||||
COMMENTS = 0x0006,
|
||||
TEMPLATE = 0x0007,
|
||||
LASTAUTHOR = 0x0008,
|
||||
REVNUMBER = 0x0009,
|
||||
EDITTIME = 0x000A,
|
||||
LASTPRINTED = 0x000B,
|
||||
CREATE_DTM = 0x000C,
|
||||
LASTSAVE_DTM = 0x000D,
|
||||
PAGECOUNT = 0x000E,
|
||||
WORDCOUNT = 0x000F,
|
||||
CHARCOUNT = 0x0010,
|
||||
THUMBNAIL = 0x0011,
|
||||
APPNAME = 0x0012,
|
||||
DOC_SECURITY = 0x0013,
|
||||
//---------- ext - 2.3.3.2.2.1 PIDDSI
|
||||
CODEPAGEEXT = 0x1001,
|
||||
CATEGORY = 0x1002,
|
||||
PRESFORMAT = 0x1003,
|
||||
BYTECOUNT = 0x1004,
|
||||
LINECOUNT = 0x1005,
|
||||
PARACOUNT = 0x1006,
|
||||
SLIDECOUNT = 0x1007,
|
||||
NOTECOUNT = 0x1008,
|
||||
HIDDENCOUNT = 0x1009,
|
||||
MMCLIPCOUNT = 0x100A,
|
||||
SCALE = 0x100B,
|
||||
HEADINGPAIR = 0x100C,
|
||||
DOCPARTS = 0x100D,
|
||||
MANAGER = 0x100E,
|
||||
COMPANY = 0x100F,
|
||||
LINKSDIRTY = 0x1010,
|
||||
CCHWITHSPACES = 0x1011,
|
||||
SHAREDDOC = 0x1013,
|
||||
LINKBASE = 0x1014,
|
||||
HLINKS = 0x1015,
|
||||
HYPERLINKSCHANGED = 0x1016,
|
||||
VERSION = 0x1017,
|
||||
DIGSIG = 0x1018,
|
||||
CONTENTTYPE = 0x101A,
|
||||
CONTENTSTATUS = 0x101B,
|
||||
LANGUAGE = 0x101C,
|
||||
DOCVERSION = 0x101D
|
||||
};
|
||||
class Property
|
||||
{
|
||||
public:
|
||||
Property(unsigned int prop_type_, unsigned short value_type_) : prop_type(prop_type_), value_type(value_type_) {}
|
||||
virtual ~Property()
|
||||
{
|
||||
}
|
||||
virtual bool Read(XLS::CFStreamPtr stream) = 0;
|
||||
virtual std::wstring toString() = 0;
|
||||
|
||||
unsigned int prop_type;
|
||||
unsigned short value_type;
|
||||
|
||||
enum ValueTypes
|
||||
{
|
||||
VT_I2 = 0x0002,
|
||||
VT_I4 = 0x0003,
|
||||
VT_R4 = 0x0004,
|
||||
VT_R8 = 0x0005,
|
||||
VT_CY = 0x0006,
|
||||
VT_DATE = 0x0007,
|
||||
VT_BSTR = 0x0008,
|
||||
VT_ERROR = 0x000A,
|
||||
VT_BOOL = 0x000B,
|
||||
VT_DECIMAL = 0x000E,
|
||||
VT_I1 = 0x0010,
|
||||
VT_UI1 = 0x0011,
|
||||
VT_UI2 = 0x0012,
|
||||
VT_UI4 = 0x0013,
|
||||
VT_I8 = 0x0014,
|
||||
VT_UI8 = 0x0015,
|
||||
VT_INT = 0x0016,
|
||||
VT_UINT = 0x0017,
|
||||
VT_LPSTR = 0x001E,
|
||||
VT_LPWSTR = 0x001F,
|
||||
VT_FILETIME = 0x0040,
|
||||
VT_CF = 0x0047,
|
||||
VT_CLSID = 0x0047,
|
||||
};
|
||||
};
|
||||
typedef boost::shared_ptr<Property> PropertyPtr;
|
||||
} // namespace OLEPS
|
||||
@ -1,94 +1,112 @@
|
||||
/*
|
||||
* (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 "PropertyFactory.h"
|
||||
#include "CodePageOle.h"
|
||||
#include "../../../Binary/CFStream.h"
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
|
||||
PropertyPtr PropertyFactory::ReadProperty(const unsigned int prop_type, XLS::CFStreamPtr stream, const unsigned int property_offset)
|
||||
{
|
||||
stream->seekFromBegin(property_offset);
|
||||
unsigned short value_type;
|
||||
|
||||
if (stream->getStreamPointer() + 2 > stream->getStreamSize()) return PropertyPtr();
|
||||
*stream >> value_type;
|
||||
stream->seekFromCurForward(2); // Skip 2 reserved unsigned chars
|
||||
|
||||
value_type = value_type & 0x00ff;
|
||||
|
||||
PropertyPtr property_;
|
||||
|
||||
if (prop_type == 0x01)
|
||||
{
|
||||
property_ = PropertyPtr(new PropertyCodePage(prop_type, value_type));
|
||||
|
||||
PropertyCodePagePtr property_CodePage = boost::dynamic_pointer_cast<PropertyCodePage>(property_);
|
||||
if(property_CodePage)
|
||||
{
|
||||
property_CodePage->Read(stream);
|
||||
code_page = property_CodePage->code_page;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value_type == 0x001E)
|
||||
{
|
||||
property_ = PropertyPtr(new PropertyStr(prop_type, value_type, code_page));
|
||||
}
|
||||
else if (value_type == 0x0003)
|
||||
{
|
||||
property_ = PropertyPtr(new PropertyInt(prop_type, value_type));
|
||||
}
|
||||
else if (value_type == 0x000b)
|
||||
{
|
||||
property_ = PropertyPtr(new PropertyBool(prop_type, value_type));
|
||||
}
|
||||
else if (value_type == 0x0040)
|
||||
{
|
||||
property_ = PropertyPtr(new PropertyDTM(prop_type, value_type));
|
||||
}
|
||||
}
|
||||
if (property_)
|
||||
{
|
||||
property_->Read(stream);
|
||||
}
|
||||
|
||||
return property_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace OLEPS
|
||||
/*
|
||||
* (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 "PropertyFactory.h"
|
||||
#include "CodePageOle.h"
|
||||
#include "../../Binary/CFStream.h"
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
|
||||
PropertyPtr PropertyFactory::ReadProperty(const unsigned int prop_id, XLS::CFStreamPtr stream, const unsigned int property_offset)
|
||||
{
|
||||
stream->seekFromBegin(property_offset);
|
||||
unsigned short value_type;
|
||||
|
||||
if (stream->getStreamPointer() + 2 > stream->getStreamSize()) return PropertyPtr();
|
||||
*stream >> value_type;
|
||||
stream->seekFromCurForward(2); // Skip 2 reserved unsigned chars
|
||||
|
||||
value_type = value_type & 0x00ff;
|
||||
|
||||
PropertyPtr property_;
|
||||
|
||||
if (prop_id == 0x0001 || prop_id == 0x1001)
|
||||
{
|
||||
property_ = PropertyPtr(new PropertyCodePage(prop_id, value_type));
|
||||
property_->Read(stream);
|
||||
|
||||
PropertyCodePagePtr property_CodePage = boost::dynamic_pointer_cast<PropertyCodePage>(property_);
|
||||
if(property_CodePage)
|
||||
{
|
||||
code_page = property_CodePage->code_page;
|
||||
}
|
||||
}
|
||||
else if (prop_id == 0x100C)
|
||||
{
|
||||
property_ = PropertyPtr(new PropertyVecHeadingPair(prop_id, value_type, code_page));
|
||||
}
|
||||
else if (prop_id == 0x100D)
|
||||
{
|
||||
property_ = PropertyPtr(new PropertyVecString(prop_id, value_type, code_page));
|
||||
}
|
||||
else if (prop_id == 0x1018)
|
||||
{
|
||||
property_ = PropertyPtr(new PropertyDigSig(prop_id, value_type));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value_type == 0x001E)
|
||||
{
|
||||
property_ = PropertyPtr(new PropertyString(prop_id, value_type, code_page));
|
||||
}
|
||||
else if (value_type == 0x001F)
|
||||
{
|
||||
property_ = PropertyPtr(new PropertyWString(prop_id, value_type));
|
||||
}
|
||||
else if (value_type == 0x0003)
|
||||
{
|
||||
property_ = PropertyPtr(new PropertyInt(prop_id, value_type));
|
||||
}
|
||||
else if (value_type == 0x000b)
|
||||
{
|
||||
property_ = PropertyPtr(new PropertyBool(prop_id, value_type));
|
||||
}
|
||||
else if (value_type == 0x0040)
|
||||
{
|
||||
property_ = PropertyPtr(new PropertyDTM(prop_id, value_type));
|
||||
}
|
||||
else
|
||||
{
|
||||
//skip
|
||||
}
|
||||
}
|
||||
if (property_)
|
||||
{
|
||||
property_->Read(stream);
|
||||
}
|
||||
|
||||
return property_;
|
||||
}
|
||||
|
||||
} // namespace OLEPS
|
||||
@ -1,50 +1,50 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Property.h"
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
|
||||
class PropertyFactory
|
||||
{
|
||||
public:
|
||||
PropertyFactory() : code_page (0) {}
|
||||
|
||||
unsigned short code_page;
|
||||
|
||||
PropertyPtr ReadProperty(const unsigned int prop_type, XLS::CFStreamPtr stream, const unsigned int property_offset);
|
||||
|
||||
};
|
||||
|
||||
} // namespace OLEPS
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Property.h"
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
|
||||
class PropertyFactory
|
||||
{
|
||||
public:
|
||||
PropertyFactory() : code_page (0) {}
|
||||
|
||||
unsigned short code_page;
|
||||
|
||||
PropertyPtr ReadProperty(const unsigned int prop_id, XLS::CFStreamPtr stream, const unsigned int property_offset);
|
||||
|
||||
};
|
||||
|
||||
} // namespace OLEPS
|
||||
@ -1,85 +1,96 @@
|
||||
/*
|
||||
* (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 "PropertySet.h"
|
||||
#include "../../../Binary/CFStream.h"
|
||||
#include "PropertyFactory.h"
|
||||
#include "CodePageOle.h"
|
||||
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
|
||||
PropertySet::PropertySet(XLS::CFStreamPtr stream, const unsigned int property_set_offset)
|
||||
{
|
||||
stream->seekFromBegin(property_set_offset);
|
||||
|
||||
_UINT32 Size, NumProperties;
|
||||
|
||||
*stream >> Size;
|
||||
*stream >> NumProperties;
|
||||
|
||||
std::vector<PropertyIdentifierAndOffset> prop_offsets;
|
||||
for(unsigned int i = 0; i < NumProperties; ++i)
|
||||
{
|
||||
if (stream->getStreamPointer() + 8 > stream->getStreamSize())
|
||||
break;
|
||||
PropertyIdentifierAndOffset prop_offset;
|
||||
*stream >> prop_offset;
|
||||
|
||||
if (prop_offset.Offset/* - property_set_offset*/ > Size)
|
||||
break;
|
||||
prop_offsets.push_back(prop_offset);
|
||||
}
|
||||
|
||||
PropertyFactory factory;
|
||||
for(size_t i = 0; i < prop_offsets.size(); ++i)
|
||||
{
|
||||
if (stream->getStreamPointer() - property_set_offset > Size)
|
||||
break;
|
||||
PropertyPtr property_ = factory.ReadProperty(prop_offsets[i].PropertyIdentifier, stream, property_set_offset + prop_offsets[i].Offset);
|
||||
|
||||
if(property_) // Skip the property if the corresponding class is not implemented
|
||||
{
|
||||
properties.insert(std::make_pair(property_->prop_type, property_));
|
||||
}
|
||||
}
|
||||
code_page = factory.code_page;
|
||||
}
|
||||
|
||||
const unsigned short PropertySet::GetCodePage()
|
||||
{
|
||||
return code_page;
|
||||
}
|
||||
|
||||
} // namespace OLEPS
|
||||
/*
|
||||
* (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 "PropertySet.h"
|
||||
#include "../../Binary/CFStream.h"
|
||||
#include "PropertyFactory.h"
|
||||
#include "CodePageOle.h"
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
|
||||
PropertySet::PropertySet(XLS::CFStreamPtr stream, const unsigned int property_set_offset, bool ext)
|
||||
{
|
||||
stream->seekFromBegin(property_set_offset);
|
||||
|
||||
_UINT32 Size, NumProperties;
|
||||
|
||||
*stream >> Size;
|
||||
*stream >> NumProperties;
|
||||
|
||||
std::vector<PropIdAndOffset> prop_offsets;
|
||||
for(unsigned int i = 0; i < NumProperties; ++i)
|
||||
{
|
||||
if (stream->getStreamPointer() + 8 > stream->getStreamSize())
|
||||
break;
|
||||
PropIdAndOffset prop_offset;
|
||||
*stream >> prop_offset;
|
||||
|
||||
if (prop_offset.Offset/* - property_set_offset*/ > Size)
|
||||
break;
|
||||
prop_offsets.push_back(prop_offset);
|
||||
}
|
||||
|
||||
PropertyFactory factory;
|
||||
for(size_t i = 0; i < prop_offsets.size(); ++i)
|
||||
{
|
||||
if (stream->getStreamPointer() - property_set_offset > Size)
|
||||
break;
|
||||
|
||||
if (ext)
|
||||
prop_offsets[i].PropId += 0x1000;
|
||||
|
||||
PropertyPtr property_ = factory.ReadProperty(prop_offsets[i].PropId, stream, property_set_offset + prop_offsets[i].Offset);
|
||||
|
||||
if(property_)
|
||||
{
|
||||
properties.insert(std::make_pair(property_->prop_type, property_));
|
||||
}
|
||||
}
|
||||
code_page = factory.code_page;
|
||||
}
|
||||
PropertyPtr PropertySet::GetProperty(unsigned int id)
|
||||
{
|
||||
PropertyPtr prop;
|
||||
|
||||
std::map<unsigned int, PropertyPtr>::iterator pFind = properties.find(id);
|
||||
if (pFind != properties.end())
|
||||
prop = pFind->second;
|
||||
return prop;
|
||||
}
|
||||
const unsigned short PropertySet::GetCodePage()
|
||||
{
|
||||
return code_page;
|
||||
}
|
||||
|
||||
} // namespace OLEPS
|
||||
@ -1,66 +1,62 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Property.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
|
||||
class PropertySet
|
||||
{
|
||||
public:
|
||||
PropertySet(XLS::CFStreamPtr stream, const unsigned int property_set_offset);
|
||||
|
||||
const unsigned short GetCodePage();
|
||||
|
||||
std::map<unsigned int, PropertyPtr> properties;
|
||||
|
||||
private:
|
||||
unsigned short code_page;
|
||||
|
||||
#pragma pack(1)
|
||||
struct PropertyIdentifierAndOffset
|
||||
{
|
||||
unsigned int PropertyIdentifier;
|
||||
unsigned int Offset;
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<PropertySet> PropertySetPtr;
|
||||
|
||||
} // namespace OLEPS
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Property.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
class PropertySet
|
||||
{
|
||||
public:
|
||||
PropertySet(XLS::CFStreamPtr stream, const unsigned int property_set_offset, bool ext);
|
||||
const unsigned short GetCodePage();
|
||||
PropertyPtr GetProperty(unsigned int id);
|
||||
private:
|
||||
std::map<unsigned int, PropertyPtr> properties;
|
||||
unsigned short code_page;
|
||||
|
||||
#pragma pack(1)
|
||||
struct PropIdAndOffset
|
||||
{
|
||||
unsigned int PropId;
|
||||
unsigned int Offset;
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
};
|
||||
typedef boost::shared_ptr<PropertySet> PropertySetPtr;
|
||||
|
||||
} // namespace OLEPS
|
||||
@ -0,0 +1,464 @@
|
||||
/*
|
||||
* (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 "PropertySetStream.h"
|
||||
|
||||
#include "../../Binary/CFStream.h"
|
||||
#include "../../Auxiliary/HelpFunc.h"
|
||||
#include "../../../Common/simple_xml_writer.h"
|
||||
#include "../../../../../DesktopEditor/common/SystemUtils.h"
|
||||
#include "../../../../../Common/DocxFormat/Source/Base/Base.h"
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
void PropertySetStream::read(XLS::CFStreamPtr stream, bool ext)
|
||||
{
|
||||
unsigned short ByteOrder = 0;
|
||||
unsigned short Version = 0;
|
||||
_UINT32 SystemIdentifier = 0;
|
||||
_UINT32 NumPropertySets = 0;
|
||||
_GUID_ Clsid = {};
|
||||
|
||||
*stream >> ByteOrder >> Version >> SystemIdentifier;
|
||||
|
||||
if (ByteOrder != 0xFFFE) //file (53).xls
|
||||
return;
|
||||
|
||||
if (Version != 0x01 && Version != 0x00)
|
||||
return;
|
||||
|
||||
*stream >> SystemIdentifier >> Clsid;
|
||||
|
||||
*stream >> NumPropertySets;
|
||||
|
||||
if (NumPropertySets != 0x01 && NumPropertySets != 0x02)
|
||||
{
|
||||
NumPropertySets = 0x01;
|
||||
stream->seekFromBegin(28);
|
||||
}
|
||||
|
||||
std::vector<_UINT32> property_sets_offsets;
|
||||
for (_UINT32 i = 0; i < NumPropertySets; ++i)
|
||||
{
|
||||
_GUID_ FMTID;
|
||||
|
||||
_UINT32 Offset;
|
||||
*stream >> FMTID >> Offset;
|
||||
|
||||
if (Offset < stream->getStreamSize())
|
||||
property_sets_offsets.push_back(Offset);
|
||||
}
|
||||
|
||||
for (_UINT32 i = 0; i < NumPropertySets; ++i)
|
||||
{
|
||||
PropertySetPtr set = PropertySetPtr(new PropertySet(stream, property_sets_offsets[i], ext));
|
||||
|
||||
property_sets.push_back(set);
|
||||
}
|
||||
}
|
||||
PropertyPtr PropertySetStream::GetProperty(unsigned int id)
|
||||
{
|
||||
PropertyPtr prop;
|
||||
|
||||
for (size_t i = 0; i < property_sets.size(); ++i)
|
||||
{
|
||||
prop = property_sets[i]->GetProperty(id);
|
||||
if (prop)
|
||||
break;
|
||||
}
|
||||
return prop;
|
||||
}
|
||||
const unsigned short PropertySetStream::GetCodePage()
|
||||
{
|
||||
return 0 != property_sets.size() ? property_sets[0]->GetCodePage() : 0;
|
||||
}
|
||||
std::wstring PropertySetStream::GetApp()
|
||||
{
|
||||
if (property_sets.empty()) return L"";
|
||||
|
||||
PropertyPtr prop;
|
||||
|
||||
std::wstringstream output;
|
||||
CP_XML_WRITER(output)
|
||||
{
|
||||
CP_XML_NODE(L"Properties")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties");
|
||||
CP_XML_ATTR(L"xmlns:vt", L"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes");
|
||||
|
||||
prop = GetProperty(TEMPLATE);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"Template")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(MANAGER);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"Manager")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(COMPANY);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"Company")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(PAGECOUNT);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"Pages")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(WORDCOUNT);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"Words")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
//prop = GetProperty(CHARCOUNT);
|
||||
//if (prop)
|
||||
//{
|
||||
// CP_XML_NODE(L"CharactersWithSpaces")
|
||||
// {
|
||||
// CP_XML_STREAM() << prop->toString();
|
||||
// }
|
||||
//}
|
||||
prop = GetProperty(CHARCOUNT);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"Characters")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(PRESFORMAT);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"PresentationFormat")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(LINECOUNT);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"Lines")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(PARACOUNT);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"Paragraphs")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(SLIDECOUNT);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"Slides")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(NOTECOUNT);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"Notes")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(HIDDENCOUNT);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"HiddenSlides")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(MMCLIPCOUNT);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"MMClips")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(SCALE);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"ScaleCrop")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(HEADINGPAIR);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"HeadingPairs")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(DOCPARTS);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"TitlesOfParts")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(LINKBASE);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"LinksUpToDate")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(CCHWITHSPACES);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"CharactersWithSpaces")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(SHAREDDOC);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"SharedDoc")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
// LINKBASE = 0x1014,
|
||||
prop = GetProperty(HLINKS);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"HLinks")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(HYPERLINKSCHANGED);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"HyperlinksChanged")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
// DIGSIG = 0x1018,
|
||||
CP_XML_NODE(L"Application")
|
||||
{
|
||||
prop = GetProperty(APPNAME);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvApplicationName);
|
||||
if (sApplication.empty())
|
||||
sApplication = NSSystemUtils::gc_EnvApplicationNameDefault;
|
||||
CP_XML_STREAM() << sApplication;
|
||||
#if defined(INTVER)
|
||||
std::string s = VALUE2STR(INTVER);
|
||||
CP_XML_STREAM() << L"/" << std::wstring(s.begin(), s.end());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
prop = GetProperty(DOCVERSION);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"AppVersion")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(DOC_SECURITY);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"DocSecurity")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return output.str();
|
||||
}
|
||||
std::wstring PropertySetStream::GetCore()
|
||||
{
|
||||
if (property_sets.empty()) return L"";
|
||||
|
||||
std::wstringstream output;
|
||||
PropertyPtr prop;
|
||||
|
||||
CP_XML_WRITER(output)
|
||||
{
|
||||
CP_XML_NODE(L"cp:coreProperties")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns:cp", L"http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
|
||||
CP_XML_ATTR(L"xmlns:dc", L"http://purl.org/dc/elements/1.1/");
|
||||
CP_XML_ATTR(L"xmlns:dcterms", L"http://purl.org/dc/terms/");
|
||||
CP_XML_ATTR(L"xmlns:dcmitype", L"http://purl.org/dc/dcmitype/");
|
||||
CP_XML_ATTR(L"xmlns:xsi", L"http://www.w3.org/2001/XMLSchema-instance");
|
||||
|
||||
prop = GetProperty(TITLE);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"dc:title")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(SUBJECT);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"dc:subject")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(AUTHOR);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"dc:creator")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(KEYWORDS);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"cp:keywords")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(COMMENTS);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"dc:description")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(LANGUAGE);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"dc:language")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
} prop = GetProperty(VERSION);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"cp:version")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(LASTAUTHOR);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"cp:lastModifiedBy")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(REVNUMBER);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"cp:revision")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(CREATE_DTM);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"dcterms:created")
|
||||
{
|
||||
CP_XML_ATTR(L"xsi:type", L"dcterms:W3CDTF");
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(LASTSAVE_DTM);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"dcterms:modified")
|
||||
{
|
||||
CP_XML_ATTR(L"xsi:type", L"dcterms:W3CDTF");
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(CATEGORY);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"cp:category")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
prop = GetProperty(CONTENTSTATUS);
|
||||
if (prop)
|
||||
{
|
||||
CP_XML_NODE(L"cp:contentStatus")
|
||||
{
|
||||
CP_XML_STREAM() << prop->toString();
|
||||
}
|
||||
}
|
||||
// BYTECOUNT = 0x1004,
|
||||
// LINKSDIRTY = 0x1010,
|
||||
// CONTENTTYPE = 0x101A,
|
||||
}
|
||||
}
|
||||
return output.str();
|
||||
}
|
||||
} // namespace OLEPS
|
||||
@ -1,51 +1,56 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../../../Binary/BinSmartPointers.h"
|
||||
#include "PropertySet.h"
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
|
||||
class PropertySetStream
|
||||
{
|
||||
public:
|
||||
PropertySetStream(XLS::CFStreamPtr stream);
|
||||
|
||||
const unsigned short GetCodePage();
|
||||
|
||||
private:
|
||||
std::vector<PropertySetPtr> property_sets;
|
||||
};
|
||||
|
||||
} // namespace OLEPS
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../../Binary/BinSmartPointers.h"
|
||||
#include "PropertySet.h"
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
|
||||
class PropertySetStream
|
||||
{
|
||||
public:
|
||||
PropertySetStream() {}
|
||||
|
||||
void read(XLS::CFStreamPtr stream, bool ext = false);
|
||||
const unsigned short GetCodePage();
|
||||
|
||||
std::wstring GetCore();
|
||||
std::wstring GetApp();
|
||||
|
||||
private:
|
||||
std::vector<PropertySetPtr> property_sets;
|
||||
PropertyPtr GetProperty(unsigned int id);
|
||||
};
|
||||
|
||||
} // namespace OLEPS
|
||||
@ -1,107 +0,0 @@
|
||||
/*
|
||||
* (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 <string>
|
||||
|
||||
#include "CodePageOle.h"
|
||||
#include "../../../Binary/CFStream.h"
|
||||
#include "../../../Auxiliary/HelpFunc.h"
|
||||
|
||||
#include "../../../../../../UnicodeConverter/UnicodeConverter.h"
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
|
||||
bool PropertyCodePage::Read (XLS::CFStreamPtr stream)
|
||||
{
|
||||
if (value_type == Property::VT_I2)
|
||||
{
|
||||
*stream >> code_page;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool PropertyStr::Read (XLS::CFStreamPtr stream)
|
||||
{
|
||||
if (value_type == Property::VT_LPSTR)
|
||||
{
|
||||
_INT32 size;
|
||||
*stream >> size;
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
char *s = new char[size];
|
||||
stream->read(s, size);
|
||||
|
||||
for (_INT32 i = size - 1; i >= 0; i--)
|
||||
{
|
||||
if ( s[i] == 0 ) size--;
|
||||
}
|
||||
|
||||
value = size > 0 ? STR::toStdWString(std::string(s, size), code_page) : L"";
|
||||
delete []s;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool PropertyDTM::Read (XLS::CFStreamPtr stream)
|
||||
{
|
||||
_UINT32 dwLowDateTime = 0, dwHighDateTime = 0;
|
||||
if (value_type == Property::VT_FILETIME)
|
||||
{
|
||||
*stream >> dwLowDateTime >> dwHighDateTime;
|
||||
}
|
||||
//todoooo
|
||||
return true;
|
||||
}
|
||||
bool PropertyInt::Read (XLS::CFStreamPtr stream)
|
||||
{
|
||||
value = 0;
|
||||
if (value_type == Property::VT_I4)
|
||||
{
|
||||
*stream >> value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool PropertyBool::Read (XLS::CFStreamPtr stream)
|
||||
{
|
||||
value = false;
|
||||
if (value_type == Property::VT_BOOL)
|
||||
{
|
||||
_UINT32 v;
|
||||
*stream >> v;
|
||||
|
||||
if (v != 0)
|
||||
value = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace OLEPS
|
||||
@ -1,103 +0,0 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#include "Property.h"
|
||||
#include "../../../../../../Common/DocxFormat/Source/Base/Types_32.h"
|
||||
#include <string>
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
|
||||
class PropertyCodePage : public Property
|
||||
{
|
||||
public:
|
||||
PropertyCodePage(unsigned int prop_type, const unsigned short value_type) : Property(prop_type, value_type), code_page(0)
|
||||
{
|
||||
}
|
||||
virtual bool Read(XLS::CFStreamPtr stream);
|
||||
|
||||
static const unsigned short DefaultCodePage = 1250;
|
||||
unsigned short code_page;
|
||||
};
|
||||
typedef boost::shared_ptr<PropertyCodePage> PropertyCodePagePtr;
|
||||
//-----------------------------------------------------------------------------------------
|
||||
class PropertyStr : public Property
|
||||
{
|
||||
public:
|
||||
PropertyStr(unsigned int prop_type, const unsigned short value_type, unsigned short code_page_) : Property(prop_type, value_type)
|
||||
{
|
||||
code_page = code_page_;
|
||||
}
|
||||
|
||||
virtual bool Read(XLS::CFStreamPtr stream);
|
||||
|
||||
std::wstring value;
|
||||
unsigned short code_page;
|
||||
};
|
||||
typedef boost::shared_ptr<PropertyStr> PropertyStrPtr;
|
||||
//-----------------------------------------------------------------------------------------
|
||||
class PropertyDTM : public Property
|
||||
{
|
||||
public:
|
||||
PropertyDTM(unsigned int prop_type, const unsigned short value_type) : Property(prop_type, value_type)
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool Read(XLS::CFStreamPtr stream);
|
||||
std::wstring value;
|
||||
};
|
||||
typedef boost::shared_ptr<PropertyDTM> PropertyDTMPtr;
|
||||
//-----------------------------------------------------------------------------------------
|
||||
class PropertyInt : public Property
|
||||
{
|
||||
public:
|
||||
PropertyInt(unsigned int prop_type, const unsigned short value_type) : Property(prop_type, value_type)
|
||||
{
|
||||
}
|
||||
virtual bool Read(XLS::CFStreamPtr stream);
|
||||
|
||||
_UINT32 value;
|
||||
};
|
||||
typedef boost::shared_ptr<PropertyInt> PropertyIntPtr;
|
||||
//-----------------------------------------------------------------------------------------
|
||||
class PropertyBool : public Property
|
||||
{
|
||||
public:
|
||||
PropertyBool(unsigned int prop_type, const unsigned short value_type) : Property(prop_type, value_type)
|
||||
{
|
||||
}
|
||||
virtual bool Read(XLS::CFStreamPtr stream);
|
||||
|
||||
bool value;
|
||||
};
|
||||
typedef boost::shared_ptr<PropertyDTM> PropertyDTMPtr;
|
||||
} // namespace OLEPS
|
||||
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include "../../../Binary/BinSmartPointers.h"
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
class Property
|
||||
{
|
||||
public:
|
||||
Property(unsigned int prop_type_, unsigned short value_type_) : prop_type(prop_type_), value_type(value_type_) {}
|
||||
virtual ~Property()
|
||||
{
|
||||
}
|
||||
virtual bool Read(XLS::CFStreamPtr stream) = 0;
|
||||
|
||||
unsigned int prop_type;
|
||||
unsigned short value_type;
|
||||
|
||||
enum ValueTypes
|
||||
{
|
||||
VT_I2 = 0x0002,
|
||||
VT_I4 = 0x0003,
|
||||
VT_R4 = 0x0004,
|
||||
VT_R8 = 0x0005,
|
||||
VT_CY = 0x0006,
|
||||
VT_DATE = 0x0007,
|
||||
VT_BSTR = 0x0008,
|
||||
VT_ERROR = 0x000A,
|
||||
VT_BOOL = 0x000B,
|
||||
VT_DECIMAL = 0x000E,
|
||||
VT_I1 = 0x0010,
|
||||
VT_UI1 = 0x0011,
|
||||
VT_UI2 = 0x0012,
|
||||
VT_UI4 = 0x0013,
|
||||
VT_I8 = 0x0014,
|
||||
VT_UI8 = 0x0015,
|
||||
VT_INT = 0x0016,
|
||||
VT_UINT = 0x0017,
|
||||
VT_LPSTR = 0x001E,
|
||||
VT_LPWSTR = 0x001F,
|
||||
VT_FILETIME = 0x0040,
|
||||
VT_CF = 0x0047,
|
||||
VT_CLSID = 0x0047,
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<Property> PropertyPtr;
|
||||
|
||||
} // namespace OLEPS
|
||||
@ -1,92 +0,0 @@
|
||||
/*
|
||||
* (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 "PropertySetStream.h"
|
||||
|
||||
#include "../../../Binary/CFStream.h"
|
||||
#include "../../../Auxiliary/HelpFunc.h"
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
|
||||
PropertySetStream::PropertySetStream(XLS::CFStreamPtr stream)
|
||||
{
|
||||
unsigned short ByteOrder=0;
|
||||
unsigned short Version=0;
|
||||
_UINT32 SystemIdentifier=0;
|
||||
_UINT32 NumPropertySets=0;
|
||||
_GUID_ Clsid={};
|
||||
|
||||
*stream >> ByteOrder >> Version >> SystemIdentifier;
|
||||
|
||||
if (ByteOrder != 0xFFFE) //file (53).xls
|
||||
return;
|
||||
|
||||
if (Version != 0x01 && Version != 0x00)
|
||||
return;
|
||||
|
||||
*stream >> SystemIdentifier >> Clsid;
|
||||
|
||||
*stream >> NumPropertySets;
|
||||
|
||||
if (NumPropertySets != 0x01 && NumPropertySets != 0x02)
|
||||
{
|
||||
NumPropertySets = 0x01;
|
||||
stream->seekFromBegin(28);
|
||||
}
|
||||
|
||||
std::vector<_UINT32> property_sets_offsets;
|
||||
for(_UINT32 i = 0; i < NumPropertySets; ++i)
|
||||
{
|
||||
_GUID_ FMTID;
|
||||
|
||||
_UINT32 Offset;
|
||||
*stream >> FMTID >> Offset;
|
||||
|
||||
if (Offset < stream->getStreamSize())
|
||||
property_sets_offsets.push_back(Offset);
|
||||
}
|
||||
|
||||
for (_UINT32 i = 0; i < NumPropertySets; ++i)
|
||||
{
|
||||
PropertySetPtr set = PropertySetPtr(new PropertySet(stream, property_sets_offsets[i]));
|
||||
|
||||
property_sets.push_back(set);
|
||||
}
|
||||
}
|
||||
|
||||
const unsigned short PropertySetStream::GetCodePage()
|
||||
{
|
||||
return 0 != property_sets.size() ? property_sets[0]->GetCodePage() : 0;
|
||||
}
|
||||
|
||||
} // namespace OLEPS
|
||||
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* (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 "SummaryInformation.h"
|
||||
#include "../../Binary/CFStream.h"
|
||||
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
|
||||
SummaryInformation::SummaryInformation(XLS::CFStreamPtr stream) : property_set_stream(stream)
|
||||
{
|
||||
}
|
||||
|
||||
const unsigned short SummaryInformation::GetCodePage()
|
||||
{
|
||||
return property_set_stream.GetCodePage();
|
||||
}
|
||||
|
||||
} // namespace OLEPS
|
||||
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../../Binary/BinSmartPointers.h"
|
||||
#include "Structures/PropertySetStream.h"
|
||||
|
||||
namespace OLEPS
|
||||
{
|
||||
|
||||
// This class and the beneath tree is created for future full implementation
|
||||
// The current necessity is to extract code page from a SummaryInformation stream
|
||||
// If the rest of functionality is never used in the future then the whole tree may
|
||||
// be replaced with plain read implementation. But I doubt in any performance bonus.
|
||||
class SummaryInformation
|
||||
{
|
||||
public:
|
||||
SummaryInformation(XLS::CFStreamPtr stream);
|
||||
|
||||
const unsigned short GetCodePage();
|
||||
|
||||
private:
|
||||
PropertySetStream property_set_stream;
|
||||
};
|
||||
|
||||
} // namespace OLEPS
|
||||
@ -32,7 +32,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CompositeObject.h"
|
||||
#include "SummaryInformationStream/Structures/CodePageOle.h"
|
||||
#include "SummaryInformationStream/CodePageOle.h"
|
||||
#include "GlobalWorkbookInfo.h"
|
||||
|
||||
namespace XLS
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
#include "../XlsFormat/Logic/MacroSheetSubstream.h"
|
||||
|
||||
#include "../XlsFormat/Logic/BinProcessor.h"
|
||||
#include "../XlsFormat/Logic/SummaryInformationStream/SummaryInformation.h"
|
||||
#include "../XlsFormat/Logic/SummaryInformationStream/PropertySetStream.h"
|
||||
|
||||
#include "../XlsFormat/Logic/Biff_unions/FORMATTING.h"
|
||||
#include "../XlsFormat/Logic/Biff_unions/THEME.h"
|
||||
@ -101,6 +101,8 @@
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
#include "../../../DesktopEditor/raster/BgraFrame.h"
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
|
||||
typedef struct tagBITMAPINFOHEADER
|
||||
@ -195,22 +197,23 @@ XlsConverter::XlsConverter(const std::wstring & xlsFileName, const std::wstring
|
||||
}
|
||||
else
|
||||
{
|
||||
XLS::CFStreamPtr summary;
|
||||
XLS::CFStreamPtr doc_summary;
|
||||
OLEPS::PropertySetStream summary_info;
|
||||
|
||||
XLS::CFStreamPtr summary = xls_file->getNamedStream(L"SummaryInformation");
|
||||
XLS::CFStreamPtr doc_summary = xls_file->getNamedStream(L"DocumentSummaryInformation");
|
||||
|
||||
summary = xls_file->getNamedStream(L"SummaryInformation");
|
||||
doc_summary = xls_file->getNamedStream(L"DocumentSummaryInformation");
|
||||
if (summary)
|
||||
summary_info.read(summary);
|
||||
if (doc_summary)
|
||||
summary_info.read(doc_summary, true);
|
||||
|
||||
if(summary)
|
||||
{
|
||||
OLEPS::SummaryInformation summary_info(summary);
|
||||
workbook_code_page = summary_info.GetCodePage(); //from software last open
|
||||
}
|
||||
if(doc_summary)
|
||||
{
|
||||
OLEPS::SummaryInformation doc_summary_info(doc_summary);
|
||||
workbook_code_page = doc_summary_info.GetCodePage();
|
||||
workbook_code_page = summary_info.GetCodePage();
|
||||
|
||||
output_document->get_docProps_files().set_app_content(summary_info.GetApp());
|
||||
output_document->get_docProps_files().set_core_content(summary_info.GetCore());
|
||||
}
|
||||
|
||||
if( 0/*error*/ == workbook_code_page)//|| 65001 /*UTF-8*/ == workbook_code_page || 1200/* UTF-16 */ == workbook_code_page
|
||||
{
|
||||
workbook_code_page = XLS::WorkbookStreamObject::DefaultCodePage;
|
||||
|
||||
@ -232,30 +232,33 @@ _CP_PTR(chart_content) chart_content::create()
|
||||
return boost::make_shared<chart_content>();
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
void core_file::write(const std::wstring & RootPath)
|
||||
docProps_files::docProps_files()
|
||||
{
|
||||
std::wstringstream resStream;
|
||||
|
||||
resStream << L"<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" "
|
||||
L"xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcmitype=\"http://purl.org/dc/dcmitype/\" "
|
||||
L"xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" >";
|
||||
}
|
||||
std::wstring docProps_files::create_core()
|
||||
{
|
||||
std::wstringstream resStream;
|
||||
|
||||
resStream << L"<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" "
|
||||
L"xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcmitype=\"http://purl.org/dc/dcmitype/\" "
|
||||
L"xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" >";
|
||||
|
||||
//resStream << L"<dc:creator>ONLYOFFICE</dc:creator>";
|
||||
//resStream << L"<cp:lastModifiedBy>ONLYOFFICE</cp:lastModifiedBy>";
|
||||
resStream << L"<cp:revision>1</cp:revision>";
|
||||
resStream << L"</cp:coreProperties>";
|
||||
resStream << L"</cp:coreProperties>";
|
||||
|
||||
simple_element elm(L"core.xml", resStream.str());
|
||||
elm.write(RootPath);
|
||||
return resStream.str();
|
||||
}
|
||||
|
||||
void app_file::write(const std::wstring & RootPath)
|
||||
std::wstring docProps_files::create_app()
|
||||
{
|
||||
std::wstringstream resStream;
|
||||
std::wstringstream resStream;
|
||||
|
||||
resStream << L"<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\" "
|
||||
L"xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\" >";
|
||||
|
||||
resStream << L"<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\" "
|
||||
L"xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\" >";
|
||||
|
||||
resStream << L"<Application>";
|
||||
std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvApplicationName);
|
||||
if (sApplication.empty())
|
||||
@ -264,32 +267,31 @@ void app_file::write(const std::wstring & RootPath)
|
||||
#if defined(INTVER)
|
||||
std::string s = VALUE2STR(INTVER);
|
||||
resStream << L"/" << std::wstring(s.begin(), s.end());
|
||||
#endif
|
||||
#endif
|
||||
resStream << L"</Application></Properties>";
|
||||
|
||||
simple_element elm(L"app.xml", resStream.str());
|
||||
elm.write(RootPath);
|
||||
|
||||
return resStream.str();
|
||||
}
|
||||
|
||||
////////////
|
||||
|
||||
docProps_files::docProps_files()
|
||||
void docProps_files::set_app_content(const std::wstring & content)
|
||||
{
|
||||
|
||||
app_content_ = content;
|
||||
}
|
||||
void docProps_files::set_core_content(const std::wstring & content)
|
||||
{
|
||||
core_content_ = content;
|
||||
}
|
||||
|
||||
void docProps_files::write(const std::wstring & RootPath)
|
||||
{
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"docProps";
|
||||
NSDirectory::CreateDirectory(path.c_str());
|
||||
NSDirectory::CreateDirectory(path.c_str());
|
||||
|
||||
core_.write(path);
|
||||
app_.write(path);
|
||||
simple_element_ptr core = simple_element::create(L"core.xml", core_content_.empty() ? create_core() : core_content_);
|
||||
simple_element_ptr app = simple_element::create(L"app.xml", app_content_.empty() ? create_app() : app_content_);
|
||||
|
||||
core->write(path);
|
||||
app->write(path);
|
||||
}
|
||||
|
||||
////////////
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------
|
||||
media::media(external_items & _items) : items_(_items)
|
||||
{
|
||||
}
|
||||
|
||||
@ -231,36 +231,32 @@ private:
|
||||
std::string content_;
|
||||
};
|
||||
//------------------------------------------------------------------------
|
||||
class document : public element
|
||||
{
|
||||
public:
|
||||
virtual content_types_file & content_type() = 0;
|
||||
};
|
||||
|
||||
class core_file : public element
|
||||
{
|
||||
public:
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
};
|
||||
|
||||
class app_file : public element
|
||||
{
|
||||
public:
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
};
|
||||
|
||||
class docProps_files : public element
|
||||
{
|
||||
public:
|
||||
docProps_files();
|
||||
|
||||
public:
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
void set_app_content(const std::wstring & content);
|
||||
void set_core_content(const std::wstring & content);
|
||||
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
|
||||
private:
|
||||
core_file core_;
|
||||
app_file app_;
|
||||
std::wstring create_app();
|
||||
std::wstring create_core();
|
||||
|
||||
std::wstring core_content_;
|
||||
std::wstring app_content_;
|
||||
};
|
||||
class document : public element
|
||||
{
|
||||
public:
|
||||
virtual content_types_file & content_type() = 0;
|
||||
docProps_files & get_docProps_files() { return docProps_files_; }
|
||||
rels_files & get_rels_files() { return rels_files_; }
|
||||
private:
|
||||
docProps_files docProps_files_;
|
||||
rels_files rels_files_;
|
||||
};
|
||||
|
||||
class media : public element
|
||||
|
||||
@ -66,10 +66,11 @@ xlsx_document::xlsx_document()
|
||||
relFile->get_rels().add(relationship(L"rId2", L"http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties", L"docProps/core.xml"));
|
||||
relFile->get_rels().add(relationship(L"rId3", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties", L"docProps/app.xml"));
|
||||
|
||||
rels_files_.add_rel_file( relFile );
|
||||
get_rels_files().add_rel_file( relFile );
|
||||
|
||||
{
|
||||
xl_files_.set_main_document(this);
|
||||
get_docProps_files().set_main_document(this);
|
||||
}
|
||||
{
|
||||
customXml_files_.set_rels(xl_files_.get_rels());
|
||||
@ -85,10 +86,10 @@ void xlsx_document::write(const std::wstring & RootPath)
|
||||
xl_files_.write(RootPath);
|
||||
customXml_files_.write(RootPath);
|
||||
|
||||
docProps_files_.write(RootPath);
|
||||
get_docProps_files().write(RootPath);
|
||||
|
||||
content_type_.write(RootPath);
|
||||
rels_files_.write(RootPath);
|
||||
get_rels_files().write(RootPath);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
|
||||
@ -416,9 +416,6 @@ private:
|
||||
xlsx_content_types_file content_type_;
|
||||
xl_files xl_files_;
|
||||
xl_customXml_files customXml_files_;
|
||||
docProps_files docProps_files_;
|
||||
rels_files rels_files_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -785,10 +785,10 @@ SOURCES += \
|
||||
../XlsFormat/Logic/Biff_unions/SXFORMULA_bu.cpp \
|
||||
../XlsFormat/Logic/Biff_unions/SXOPER.cpp \
|
||||
../XlsFormat/Logic/Biff_unions/SXRANGE.cpp \
|
||||
../XlsFormat/Logic/SummaryInformationStream/Structures/PropertyFactory.cpp \
|
||||
../XlsFormat/Logic/SummaryInformationStream/Structures/PropertySet.cpp \
|
||||
../XlsFormat/Logic/SummaryInformationStream/Structures/PropertySetStream.cpp \
|
||||
../XlsFormat/Logic/SummaryInformationStream/SummaryInformation.cpp \
|
||||
../XlsFormat/Logic/SummaryInformationStream/PropertyFactory.cpp \
|
||||
../XlsFormat/Logic/SummaryInformationStream/PropertySet.cpp \
|
||||
../XlsFormat/Logic/SummaryInformationStream/PropertySetStream.cpp \
|
||||
../XlsFormat/Logic/SummaryInformationStream/CodePageOle.cpp \
|
||||
../XlsFormat/Logic/AnyObject.cpp \
|
||||
../XlsFormat/Logic/AnySubstream.cpp \
|
||||
../XlsFormat/Logic/BinProcessor.cpp \
|
||||
@ -800,7 +800,6 @@ SOURCES += \
|
||||
../XlsFormat/Logic/WorkbookStreamObject.cpp \
|
||||
../XlsFormat/Logic/WorksheetSubstream.cpp \
|
||||
../XlsFormat/Logic/CommonSubstream.cpp \
|
||||
../XlsFormat/Logic/SummaryInformationStream/Structures/CodePageOle.cpp \
|
||||
../XlsFormat/Logic/Biff_structures/SharedProperty.cpp \
|
||||
../XlsFormat/Logic/Biff_records/FrtWrapper.cpp \
|
||||
../XlsFormat/Logic/Biff_structures/AFDOperBoolErr.cpp \
|
||||
@ -1603,11 +1602,10 @@ HEADERS += \
|
||||
../XlsFormat/Logic/Biff_unions/UNKNOWNFRT.h \
|
||||
../XlsFormat/Logic/Biff_unions/WINDOW.h \
|
||||
../XlsFormat/Logic/Biff_unions/XFS.h \
|
||||
../XlsFormat/Logic/SummaryInformationStream/Structures/Property.h \
|
||||
../XlsFormat/Logic/SummaryInformationStream/Structures/PropertyFactory.h \
|
||||
../XlsFormat/Logic/SummaryInformationStream/Structures/PropertySet.h \
|
||||
../XlsFormat/Logic/SummaryInformationStream/Structures/PropertySetStream.h \
|
||||
../XlsFormat/Logic/SummaryInformationStream/SummaryInformation.h \
|
||||
../XlsFormat/Logic/SummaryInformationStream/Property.h \
|
||||
../XlsFormat/Logic/SummaryInformationStream/PropertyFactory.h \
|
||||
../XlsFormat/Logic/SummaryInformationStream/PropertySet.h \
|
||||
../XlsFormat/Logic/SummaryInformationStream/PropertySetStream.h \
|
||||
../Common/common.h \
|
||||
../Common/simple_xml_writer.h \
|
||||
../Common/utils.h \
|
||||
|
||||
@ -764,11 +764,10 @@
|
||||
#include "../XlsFormat/Logic/Biff_unions/SXOPER.cpp"
|
||||
#include "../XlsFormat/Logic/Biff_unions/SXRANGE.cpp"
|
||||
|
||||
#include "../XlsFormat/Logic/SummaryInformationStream/Structures/PropertyFactory.cpp"
|
||||
#include "../XlsFormat/Logic/SummaryInformationStream/Structures/PropertySet.cpp"
|
||||
#include "../XlsFormat/Logic/SummaryInformationStream/Structures/PropertySetStream.cpp"
|
||||
#include "../XlsFormat/Logic/SummaryInformationStream/Structures/CodePageOle.cpp"
|
||||
#include "../XlsFormat/Logic/SummaryInformationStream/SummaryInformation.cpp"
|
||||
#include "../XlsFormat/Logic/SummaryInformationStream/PropertyFactory.cpp"
|
||||
#include "../XlsFormat/Logic/SummaryInformationStream/PropertySet.cpp"
|
||||
#include "../XlsFormat/Logic/SummaryInformationStream/PropertySetStream.cpp"
|
||||
#include "../XlsFormat/Logic/SummaryInformationStream/CodePageOle.cpp"
|
||||
|
||||
#include "../XlsFormat/Logic/AnyObject.cpp"
|
||||
#include "../XlsFormat/Logic/AnySubstream.cpp"
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>VbaFormat</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
<ProjectName>VbaFormatLib</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
|
||||
@ -929,12 +929,11 @@
|
||||
<ClInclude Include="..\XlsFormat\Logic\GlobalsSubstream.h" />
|
||||
<ClInclude Include="..\XlsFormat\Logic\GlobalWorkbookInfo.h" />
|
||||
<ClInclude Include="..\XlsFormat\Logic\MacroSheetSubstream.h" />
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\CodePageOle.h" />
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\Property.h" />
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\PropertyFactory.h" />
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\PropertySet.h" />
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\PropertySetStream.h" />
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\SummaryInformation.h" />
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\CodePageOle.h" />
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\Property.h" />
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\PropertyFactory.h" />
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\PropertySet.h" />
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\PropertySetStream.h" />
|
||||
<ClInclude Include="..\XlsFormat\Logic\WorkbookStreamObject.h" />
|
||||
<ClInclude Include="..\XlsFormat\Logic\WorksheetSubstream.h" />
|
||||
<ClInclude Include="..\XlsFormat\Logic\XlsElementsType.h" />
|
||||
@ -1726,11 +1725,10 @@
|
||||
<ClCompile Include="..\XlsFormat\Logic\GlobalsSubstream.cpp" />
|
||||
<ClCompile Include="..\XlsFormat\Logic\GlobalWorkbookInfo.cpp" />
|
||||
<ClCompile Include="..\XlsFormat\Logic\MacroSheetSubstream.cpp" />
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\CodePageOle.cpp" />
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\PropertyFactory.cpp" />
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\PropertySet.cpp" />
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\PropertySetStream.cpp" />
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\SummaryInformation.cpp" />
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\CodePageOle.cpp" />
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\PropertyFactory.cpp" />
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\PropertySet.cpp" />
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\PropertySetStream.cpp" />
|
||||
<ClCompile Include="..\XlsFormat\Logic\WorkbookStreamObject.cpp" />
|
||||
<ClCompile Include="..\XlsFormat\Logic\WorksheetSubstream.cpp" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -23,9 +23,6 @@
|
||||
<Filter Include="Logic\SummaryInformationStream">
|
||||
<UniqueIdentifier>{f9665263-03ec-48bf-ba83-ea6231f129fa}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Logic\SummaryInformationStream\Structures">
|
||||
<UniqueIdentifier>{71eaddd1-b6ec-4839-b142-bb18a9b7315a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Auxiliary">
|
||||
<UniqueIdentifier>{79b675c6-723b-4624-b21f-c996458b2097}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@ -2374,24 +2371,6 @@
|
||||
<ClInclude Include="..\XlsFormat\Logic\Biff_unions\XFS.h">
|
||||
<Filter>Logic\Biff_unions</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\SummaryInformation.h">
|
||||
<Filter>Logic\SummaryInformationStream</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\CodePageOle.h">
|
||||
<Filter>Logic\SummaryInformationStream\Structures</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\Property.h">
|
||||
<Filter>Logic\SummaryInformationStream\Structures</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\PropertyFactory.h">
|
||||
<Filter>Logic\SummaryInformationStream\Structures</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\PropertySet.h">
|
||||
<Filter>Logic\SummaryInformationStream\Structures</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\PropertySetStream.h">
|
||||
<Filter>Logic\SummaryInformationStream\Structures</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\XlsFormat\Auxiliary\HelpFunc.h">
|
||||
<Filter>Auxiliary</Filter>
|
||||
</ClInclude>
|
||||
@ -2437,6 +2416,21 @@
|
||||
<ClInclude Include="..\XlsFormat\Logic\Biff_structures\PtgExtraList.h">
|
||||
<Filter>Logic\Biff_structures</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\CodePageOle.h">
|
||||
<Filter>Logic\SummaryInformationStream</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\Property.h">
|
||||
<Filter>Logic\SummaryInformationStream</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\PropertyFactory.h">
|
||||
<Filter>Logic\SummaryInformationStream</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\PropertySet.h">
|
||||
<Filter>Logic\SummaryInformationStream</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\XlsFormat\Logic\SummaryInformationStream\PropertySetStream.h">
|
||||
<Filter>Logic\SummaryInformationStream</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\XlsFormat\Binary\CFRecord.cpp">
|
||||
@ -4734,21 +4728,6 @@
|
||||
<ClCompile Include="..\XlsFormat\Logic\Biff_unions\XFS.cpp">
|
||||
<Filter>Logic\Biff_unions</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\SummaryInformation.cpp">
|
||||
<Filter>Logic\SummaryInformationStream</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\CodePageOle.cpp">
|
||||
<Filter>Logic\SummaryInformationStream\Structures</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\PropertyFactory.cpp">
|
||||
<Filter>Logic\SummaryInformationStream\Structures</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\PropertySet.cpp">
|
||||
<Filter>Logic\SummaryInformationStream\Structures</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\Structures\PropertySetStream.cpp">
|
||||
<Filter>Logic\SummaryInformationStream\Structures</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\XlsFormat\Auxiliary\HelpFunc.cpp">
|
||||
<Filter>Auxiliary</Filter>
|
||||
</ClCompile>
|
||||
@ -4791,5 +4770,17 @@
|
||||
<ClCompile Include="..\XlsFormat\Logic\Biff_structures\PtgExtraList.cpp">
|
||||
<Filter>Logic\Biff_structures</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\CodePageOle.cpp">
|
||||
<Filter>Logic\SummaryInformationStream</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\PropertyFactory.cpp">
|
||||
<Filter>Logic\SummaryInformationStream</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\PropertySet.cpp">
|
||||
<Filter>Logic\SummaryInformationStream</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\XlsFormat\Logic\SummaryInformationStream\PropertySetStream.cpp">
|
||||
<Filter>Logic\SummaryInformationStream</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
2
Common/3dParty/harfbuzz/.gitignore
vendored
Normal file
2
Common/3dParty/harfbuzz/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
harfbuzz/
|
||||
harfbuzz.pri
|
||||
91
Common/3dParty/harfbuzz/make.py
Executable file
91
Common/3dParty/harfbuzz/make.py
Executable file
@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append("../../../../build_tools/scripts")
|
||||
import base
|
||||
|
||||
# fetch harfbuzz
|
||||
if not base.is_dir("harfbuzz"):
|
||||
base.cmd("git", ["clone", "https://github.com/harfbuzz/harfbuzz.git"])
|
||||
os.chdir("harfbuzz")
|
||||
base.cmd("git", ["checkout", "8d1b000a3edc90c12267b836b4ef3f81c0e53edc"])
|
||||
os.chdir("../")
|
||||
|
||||
qmake_content_lines = []
|
||||
|
||||
qmake_content_lines.append("SRC_DIR = $$PWD/harfbuzz/src")
|
||||
qmake_content_lines.append("")
|
||||
qmake_content_lines.append("DEFINES += HAVE_FREETYPE")
|
||||
qmake_content_lines.append("")
|
||||
qmake_content_lines.append("INCLUDEPATH += \\")
|
||||
qmake_content_lines.append(" $$SRC_DIR \\")
|
||||
qmake_content_lines.append("")
|
||||
|
||||
all_files = os.listdir("./harfbuzz/src")
|
||||
headers_files = []
|
||||
sources_files = []
|
||||
|
||||
headers_exclude = []
|
||||
|
||||
sources_exclude = []
|
||||
sources_exclude.append("main.cc")
|
||||
sources_exclude.append("failing-alloc.c")
|
||||
|
||||
for item in all_files:
|
||||
arr_split = os.path.splitext(item)
|
||||
if len(arr_split) == 0:
|
||||
continue
|
||||
ext = arr_split[-1]
|
||||
if (ext == ".h") or (ext == ".hh") or (ext == ".c") or (ext == ".cc"):
|
||||
if (0 == os.path.basename(item).find("test")):
|
||||
sources_exclude.append(item)
|
||||
|
||||
for item in all_files:
|
||||
arr_split = os.path.splitext(item)
|
||||
if len(arr_split) == 0:
|
||||
continue
|
||||
ext = arr_split[-1]
|
||||
if (ext == ".h") or (ext == ".hh"):
|
||||
headers_files.append(item)
|
||||
if (ext == ".c") or (ext == ".cc"):
|
||||
sources_files.append(item)
|
||||
|
||||
qmake_content_lines.append("HEADERS += \\")
|
||||
for item in headers_files:
|
||||
if item in headers_exclude:
|
||||
continue
|
||||
qmake_content_lines.append(" $$SRC_DIR/" + item + " \\")
|
||||
qmake_content_lines[-1] = qmake_content_lines[-1].replace(" \\", "")
|
||||
|
||||
qmake_content_lines.append("")
|
||||
qmake_content_lines.append("SOURCES += \\")
|
||||
for item in sources_files:
|
||||
if item in sources_exclude:
|
||||
continue
|
||||
qmake_content_lines.append(" $$SRC_DIR/" + item + " \\")
|
||||
qmake_content_lines[-1] = qmake_content_lines[-1].replace(" \\", "")
|
||||
|
||||
qmake_content_lines.append("")
|
||||
|
||||
if len(headers_exclude) != 0:
|
||||
qmake_content_lines.append("#HEADERS += \\")
|
||||
for item in headers_exclude:
|
||||
qmake_content_lines.append("# $$SRC_DIR/" + item + " \\")
|
||||
qmake_content_lines[-1] = qmake_content_lines[-1].replace(" \\", "")
|
||||
qmake_content_lines.append("")
|
||||
|
||||
if len(sources_exclude) != 0:
|
||||
qmake_content_lines.append("#SOURCES += \\")
|
||||
for item in sources_exclude:
|
||||
qmake_content_lines.append("# $$SRC_DIR/" + item + " \\")
|
||||
qmake_content_lines[-1] = qmake_content_lines[-1].replace(" \\", "")
|
||||
qmake_content_lines.append("")
|
||||
else:
|
||||
qmake_content_lines.append("")
|
||||
|
||||
if (base.is_file("./harfbuzz.pri")):
|
||||
base.delete_file("./harfbuzz.pri")
|
||||
|
||||
with open("./harfbuzz.pri", "w") as file:
|
||||
file.write("\n".join(qmake_content_lines))
|
||||
@ -3,7 +3,7 @@
|
||||
var printErr = undefined;
|
||||
var print = undefined;
|
||||
|
||||
var fetch = self.fetch;
|
||||
var fetch = ("undefined" !== typeof window) ? window.fetch : (("undefined" !== typeof self) ? self.fetch : null);
|
||||
var getBinaryPromise = null;
|
||||
|
||||
function internal_isLocal()
|
||||
|
||||
@ -597,6 +597,9 @@ namespace NSEditorApi
|
||||
js_wrapper<std::string> m_sBase64;
|
||||
js_wrapper<CAscBinaryData> m_oBinaryData;
|
||||
js_wrapper<std::wstring> m_sAdditionalParams;
|
||||
js_wrapper<int> m_nPositionX;
|
||||
js_wrapper<int> m_nPositionY;
|
||||
js_wrapper<int> m_nWrapType;
|
||||
|
||||
public:
|
||||
CAscInsertImage()
|
||||
@ -612,6 +615,9 @@ namespace NSEditorApi
|
||||
LINK_PROPERTY_STRINGA_JS(Base64)
|
||||
LINK_PROPERTY_OBJECT_JS(CAscBinaryData, BinaryData)
|
||||
LINK_PROPERTY_STRING_JS(AdditionalParams)
|
||||
LINK_PROPERTY_INT_JS(PositionX)
|
||||
LINK_PROPERTY_INT_JS(PositionY)
|
||||
LINK_PROPERTY_INT_JS(WrapType)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -772,6 +772,7 @@
|
||||
#define ASC_MENU_EVENT_TYPE_USER_ZOOM 301
|
||||
|
||||
#define ASC_MENU_EVENT_TYPE_INSERT_CHART 400
|
||||
#define ASC_MENU_EVENT_TYPE_INSERT_SCREEN_IMAGE 401
|
||||
#define ASC_MENU_EVENT_TYPE_ADD_CHART_DATA 440
|
||||
#define ASC_MENU_EVENT_TYPE_GET_CHART_DATA 450
|
||||
#define ASC_MENU_EVENT_TYPE_SET_CHART_DATA 460
|
||||
|
||||
161
DesktopEditor/doctrenderer/config.h
Normal file
161
DesktopEditor/doctrenderer/config.h
Normal file
@ -0,0 +1,161 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#ifndef DOC_BUILDER_CONFIG
|
||||
#define DOC_BUILDER_CONFIG
|
||||
|
||||
#include "../xml/include/xmlutils.h"
|
||||
#include "../common/File.h"
|
||||
#include "../common/Directory.h"
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
class CDoctRendererConfig
|
||||
{
|
||||
public:
|
||||
std::vector<std::wstring> m_arrFiles;
|
||||
|
||||
std::vector<std::wstring> m_arDoctSDK;
|
||||
std::vector<std::wstring> m_arPpttSDK;
|
||||
std::vector<std::wstring> m_arXlstSDK;
|
||||
|
||||
std::wstring m_strAllFonts;
|
||||
bool m_bIsNotUseConfigAllFontsDir;
|
||||
|
||||
std::wstring m_sConsoleLogFile;
|
||||
std::wstring m_sErrorsLogFile;
|
||||
|
||||
public:
|
||||
CDoctRendererConfig() : m_bIsNotUseConfigAllFontsDir(false)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
std::wstring private_GetFile(const std::wstring& sConfigDir, const std::wstring& sFile)
|
||||
{
|
||||
if (NSFile::CFileBinary::Exists(sFile) && !NSFile::CFileBinary::Exists(sConfigDir + sFile))
|
||||
return sFile;
|
||||
return sConfigDir + sFile;
|
||||
}
|
||||
void private_LoadSDK_scripts(XmlUtils::CXmlNode& oNode, std::vector<std::wstring>& files, const std::wstring& sConfigDir)
|
||||
{
|
||||
XmlUtils::CXmlNodes oNodes;
|
||||
if (oNode.GetNodes(L"file", oNodes))
|
||||
{
|
||||
int nCount = oNodes.GetCount();
|
||||
XmlUtils::CXmlNode node;
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
oNodes.GetAt(i, node);
|
||||
files.push_back(private_GetFile(sConfigDir, node.GetText()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
void Parse(const std::wstring& sWorkDir)
|
||||
{
|
||||
m_arrFiles.clear();
|
||||
m_arDoctSDK.clear();
|
||||
m_arPpttSDK.clear();
|
||||
m_arXlstSDK.clear();
|
||||
|
||||
std::wstring sConfigDir = sWorkDir + L"/";
|
||||
std::wstring sConfigPath = sConfigDir + L"DoctRenderer.config";
|
||||
|
||||
XmlUtils::CXmlNode oNode;
|
||||
if (oNode.FromXmlFile(sConfigPath))
|
||||
{
|
||||
XmlUtils::CXmlNodes oNodes;
|
||||
if (oNode.GetNodes(L"file", oNodes))
|
||||
{
|
||||
int nCount = oNodes.GetCount();
|
||||
XmlUtils::CXmlNode node;
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
oNodes.GetAt(i, node);
|
||||
m_arrFiles.push_back(private_GetFile(sConfigDir, node.GetText()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_bIsNotUseConfigAllFontsDir)
|
||||
{
|
||||
std::wstring sAllFontsPath = oNode.ReadNodeText(L"allfonts");
|
||||
if (!sAllFontsPath.empty())
|
||||
{
|
||||
m_strAllFonts = sAllFontsPath;
|
||||
}
|
||||
}
|
||||
m_arrFiles.push_back(private_GetFile(sConfigDir, m_strAllFonts));
|
||||
}
|
||||
|
||||
std::wstring sSdkPath = oNode.ReadNodeText(L"sdkjs");
|
||||
if (!sSdkPath.empty())
|
||||
{
|
||||
if (!NSDirectory::Exists(sSdkPath))
|
||||
sSdkPath = sConfigDir + sSdkPath;
|
||||
|
||||
std::wstring sFontsPath = sSdkPath + L"/common/libfont/engine";
|
||||
if (!sFontsPath.empty())
|
||||
{
|
||||
#ifdef SUPPORT_HARFBUZZ_SHAPER
|
||||
sFontsPath += L"/fonts_native.js";
|
||||
#else
|
||||
sFontsPath += L"/fonts_ie.js";
|
||||
#endif
|
||||
}
|
||||
|
||||
m_arDoctSDK.push_back(sSdkPath + L"/word/sdk-all-min.js");
|
||||
m_arDoctSDK.push_back(sFontsPath);
|
||||
m_arDoctSDK.push_back(sSdkPath + L"/word/sdk-all.js");
|
||||
|
||||
m_arPpttSDK.push_back(sSdkPath + L"/slide/sdk-all-min.js");
|
||||
m_arPpttSDK.push_back(sFontsPath);
|
||||
m_arPpttSDK.push_back(sSdkPath + L"/slide/sdk-all.js");
|
||||
|
||||
m_arXlstSDK.push_back(sSdkPath + L"/cell/sdk-all-min.js");
|
||||
m_arXlstSDK.push_back(sFontsPath);
|
||||
m_arXlstSDK.push_back(sSdkPath + L"/cell/sdk-all.js");
|
||||
}
|
||||
|
||||
m_sConsoleLogFile = oNode.ReadNodeText(L"LogFileConsoleLog");
|
||||
m_sErrorsLogFile = oNode.ReadNodeText(L"LogFileErrors");
|
||||
|
||||
if (!m_sConsoleLogFile.empty())
|
||||
m_sConsoleLogFile = private_GetFile(sConfigDir, m_sConsoleLogFile);
|
||||
if (!m_sErrorsLogFile.empty())
|
||||
m_sErrorsLogFile = private_GetFile(sConfigDir, m_sErrorsLogFile);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // DOC_BUILDER_CONFIG
|
||||
@ -53,8 +53,8 @@ CV8RealTimeWorker::CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder)
|
||||
|
||||
m_context->CreateGlobalForContext();
|
||||
CNativeControlEmbed::CreateObjectBuilderInContext("CreateNativeEngine", m_context);
|
||||
CMemoryStreamEmbed::CreateObjectInContext ("CreateNativeMemoryStream", m_context);
|
||||
CGraphicsEmbed::CreateObjectInContext ("CreateNativeGraphics", m_context);
|
||||
CGraphicsEmbed::CreateObjectInContext("CreateNativeGraphics", m_context);
|
||||
NSJSBase::CreateDefaults(m_context);
|
||||
m_context->CreateContext();
|
||||
|
||||
JSSmart<CJSContextScope> context_scope = m_context->CreateContextScope();
|
||||
|
||||
@ -32,24 +32,21 @@
|
||||
#ifndef DOC_BUILDER_PRIVATE
|
||||
#define DOC_BUILDER_PRIVATE
|
||||
|
||||
#include "./config.h"
|
||||
#include "docbuilder.h"
|
||||
#include "doctrenderer.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
#include "../xml/include/xmlutils.h"
|
||||
#include "../common/File.h"
|
||||
#include "../common/Directory.h"
|
||||
|
||||
#include "../../Common/OfficeFileFormats.h"
|
||||
#include "../../Common/OfficeFileFormatChecker.h"
|
||||
|
||||
#include "js_internal/js_base.h"
|
||||
#include "embed/NativeBuilderEmbed.h"
|
||||
#include "embed/NativeControlEmbed.h"
|
||||
#include "embed/MemoryStreamEmbed.h"
|
||||
#include "embed/GraphicsEmbed.h"
|
||||
#include "embed/Default.h"
|
||||
#ifdef LINUX
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
@ -174,21 +171,12 @@ namespace NSDoctRenderer
|
||||
std::vector<std::wstring> m_arFontDirs;
|
||||
};
|
||||
|
||||
class CDocBuilder_Private
|
||||
class CDocBuilder_Private : public CDoctRendererConfig
|
||||
{
|
||||
public:
|
||||
std::vector<std::wstring> m_arrFiles;
|
||||
|
||||
std::vector<std::wstring> m_arDoctSDK;
|
||||
std::vector<std::wstring> m_arPpttSDK;
|
||||
std::vector<std::wstring> m_arXlstSDK;
|
||||
|
||||
std::wstring m_strEditorType;
|
||||
std::wstring m_strFilePath;
|
||||
|
||||
std::wstring m_strAllFonts;
|
||||
bool m_bIsNotUseConfigAllFontsDir;
|
||||
|
||||
std::wstring m_sTmpFolder;
|
||||
std::wstring m_sFileDir;
|
||||
int m_nFileType;
|
||||
@ -212,7 +200,7 @@ namespace NSDoctRenderer
|
||||
|
||||
NSDoctRenderer::CDocBuilder* m_pParent;
|
||||
public:
|
||||
CDocBuilder_Private() : m_bIsNotUseConfigAllFontsDir(false), m_sTmpFolder(NSFile::CFileBinary::GetTempPath()), m_nFileType(-1),
|
||||
CDocBuilder_Private() : CDoctRendererConfig(), m_sTmpFolder(NSFile::CFileBinary::GetTempPath()), m_nFileType(-1),
|
||||
m_pWorker(NULL), m_pAdditionalData(NULL), m_bIsInit(false), m_bIsCacheScript(true), m_bIsServerSafeVersion(false),
|
||||
m_sGlobalVariable(""), m_bIsGlobalVariableUse(false), m_pParent(NULL)
|
||||
{
|
||||
@ -251,57 +239,7 @@ namespace NSDoctRenderer
|
||||
|
||||
m_sX2tPath = sWorkDir;
|
||||
|
||||
std::wstring sConfigDir = sWorkDir + L"/";
|
||||
std::wstring sConfigPath = sConfigDir + L"DoctRenderer.config";
|
||||
|
||||
XmlUtils::CXmlNode oNode;
|
||||
if (oNode.FromXmlFile(sConfigPath))
|
||||
{
|
||||
XmlUtils::CXmlNodes oNodes;
|
||||
if (oNode.GetNodes(L"file", oNodes))
|
||||
{
|
||||
int nCount = oNodes.GetCount();
|
||||
XmlUtils::CXmlNode _node;
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
oNodes.GetAt(i, _node);
|
||||
std::wstring strFilePath = _node.GetText();
|
||||
|
||||
if (std::wstring::npos != strFilePath.find(L"AllFonts.js"))
|
||||
{
|
||||
if (!m_bIsNotUseConfigAllFontsDir)
|
||||
{
|
||||
m_strAllFonts = strFilePath;
|
||||
|
||||
if (!NSFile::CFileBinary::Exists(m_strAllFonts) || NSFile::CFileBinary::Exists(sConfigDir + m_strAllFonts))
|
||||
m_strAllFonts = sConfigDir + m_strAllFonts;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_arrFiles.push_back(m_strAllFonts);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (NSFile::CFileBinary::Exists(strFilePath) && !NSFile::CFileBinary::Exists(sConfigDir + strFilePath))
|
||||
m_arrFiles.push_back(strFilePath);
|
||||
else
|
||||
m_arrFiles.push_back(sConfigDir + strFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XmlUtils::CXmlNode oNodeSdk = oNode.ReadNode(L"DoctSdk");
|
||||
if (oNodeSdk.IsValid())
|
||||
LoadSDK_scripts(oNodeSdk, m_arDoctSDK, sConfigDir);
|
||||
|
||||
oNodeSdk = oNode.ReadNode(L"PpttSdk");
|
||||
if (oNodeSdk.IsValid())
|
||||
LoadSDK_scripts(oNodeSdk, m_arPpttSDK, sConfigDir);
|
||||
|
||||
oNodeSdk = oNode.ReadNode(L"XlstSdk");
|
||||
if (oNodeSdk.IsValid())
|
||||
LoadSDK_scripts(oNodeSdk, m_arXlstSDK, sConfigDir);
|
||||
CDoctRendererConfig::Parse(sWorkDir);
|
||||
|
||||
CheckFonts(m_oParams.m_bCheckFonts);
|
||||
|
||||
@ -315,37 +253,6 @@ namespace NSDoctRenderer
|
||||
RELEASEOBJECT(m_pAdditionalData);
|
||||
}
|
||||
|
||||
void LoadSDK_scripts(XmlUtils::CXmlNode& oNode, std::vector<std::wstring>& _files, const std::wstring& strConfigDir)
|
||||
{
|
||||
XmlUtils::CXmlNodes oNodes;
|
||||
if (oNode.GetNodes(L"file", oNodes))
|
||||
{
|
||||
int nCount = oNodes.GetCount();
|
||||
XmlUtils::CXmlNode _node;
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
oNodes.GetAt(i, _node);
|
||||
std::wstring strFilePath = _node.GetText();
|
||||
|
||||
if (NSFile::CFileBinary::Exists(strFilePath) &&
|
||||
!NSFile::CFileBinary::Exists(strConfigDir + strFilePath))
|
||||
_files.push_back(strFilePath);
|
||||
else
|
||||
_files.push_back(strConfigDir + strFilePath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring strFilePath = oNode.GetText();
|
||||
|
||||
if (NSFile::CFileBinary::Exists(strFilePath) &&
|
||||
!NSFile::CFileBinary::Exists(strConfigDir + strFilePath))
|
||||
_files.push_back(strFilePath);
|
||||
else
|
||||
_files.push_back(strConfigDir + strFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
void CheckFonts(bool bIsCheckFonts)
|
||||
{
|
||||
std::wstring sDirectory = NSFile::GetDirectoryName(m_strAllFonts);
|
||||
|
||||
@ -36,13 +36,11 @@
|
||||
#undef BOOL
|
||||
#endif
|
||||
|
||||
#include "embed/Default.h"
|
||||
#include "embed/NativeControlEmbed.h"
|
||||
#include "embed/MemoryStreamEmbed.h"
|
||||
#include "embed/GraphicsEmbed.h"
|
||||
#include "embed/ZipEmbed.h"
|
||||
|
||||
#include "../xml/include/xmlutils.h"
|
||||
|
||||
#include "./config.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace NSDoctRenderer
|
||||
@ -235,29 +233,18 @@ namespace NSDoctRenderer
|
||||
string_replace(text, L"\"", L""");
|
||||
}
|
||||
|
||||
class CDoctRenderer_Private
|
||||
class CDoctRenderer_Private : public CDoctRendererConfig
|
||||
{
|
||||
public:
|
||||
CExecuteParams m_oParams;
|
||||
|
||||
std::wstring m_strConfigDir;
|
||||
std::wstring m_strConfigPath;
|
||||
std::vector<std::wstring> m_arrFiles;
|
||||
|
||||
std::vector<std::wstring> m_arDoctSDK;
|
||||
std::vector<std::wstring> m_arPpttSDK;
|
||||
std::vector<std::wstring> m_arXlstSDK;
|
||||
|
||||
std::wstring m_strEditorType;
|
||||
std::wstring m_strFilePath;
|
||||
|
||||
std::vector<std::wstring> m_arImagesInChanges;
|
||||
|
||||
std::wstring m_sConsoleLogFile;
|
||||
std::wstring m_sErrorsLogFile;
|
||||
|
||||
public:
|
||||
CDoctRenderer_Private(const std::wstring& sAllFontsPath = L"")
|
||||
CDoctRenderer_Private(const std::wstring& sAllFontsPath = L"") : CDoctRendererConfig()
|
||||
{
|
||||
LoadConfig(NSFile::GetProcessDirectory(), sAllFontsPath);
|
||||
}
|
||||
@ -267,104 +254,13 @@ namespace NSDoctRenderer
|
||||
}
|
||||
void LoadConfig(const std::wstring& sConfigDir, const std::wstring& sAllFontsPath = L"")
|
||||
{
|
||||
m_arrFiles.clear();
|
||||
m_arDoctSDK.clear();
|
||||
m_arPpttSDK.clear();
|
||||
m_arXlstSDK.clear();
|
||||
|
||||
m_strConfigDir = sConfigDir + L"/";
|
||||
m_strConfigPath = m_strConfigDir + L"DoctRenderer.config";
|
||||
|
||||
XmlUtils::CXmlNode oNode;
|
||||
if (oNode.FromXmlFile(m_strConfigPath))
|
||||
if (!sAllFontsPath.empty())
|
||||
{
|
||||
XmlUtils::CXmlNodes oNodes;
|
||||
if (oNode.GetNodes(L"file", oNodes))
|
||||
{
|
||||
int nCount = oNodes.GetCount();
|
||||
XmlUtils::CXmlNode _node;
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
oNodes.GetAt(i, _node);
|
||||
std::wstring strFilePath = _node.GetText();
|
||||
|
||||
if (!sAllFontsPath.empty())
|
||||
{
|
||||
std::wstring::size_type nPos = strFilePath.rfind(L"AllFonts.js");
|
||||
if (nPos != std::wstring::npos && ((nPos + 11) == strFilePath.length())) // 11 = std::wstring(L"AllFonts.js").length();
|
||||
strFilePath = sAllFontsPath;
|
||||
}
|
||||
|
||||
if (NSFile::CFileBinary::Exists(strFilePath) &&
|
||||
!NSFile::CFileBinary::Exists(m_strConfigDir + strFilePath))
|
||||
m_arrFiles.push_back(strFilePath);
|
||||
else
|
||||
m_arrFiles.push_back(m_strConfigDir + strFilePath);
|
||||
}
|
||||
}
|
||||
m_strAllFonts = sAllFontsPath;
|
||||
m_bIsNotUseConfigAllFontsDir = true;
|
||||
}
|
||||
|
||||
XmlUtils::CXmlNode oNodeSdk = oNode.ReadNode(L"DoctSdk");
|
||||
if (oNodeSdk.IsValid())
|
||||
LoadSDK_scripts(oNodeSdk, m_arDoctSDK);
|
||||
|
||||
oNodeSdk = oNode.ReadNode(L"PpttSdk");
|
||||
if (oNodeSdk.IsValid())
|
||||
LoadSDK_scripts(oNodeSdk, m_arPpttSDK);
|
||||
|
||||
oNodeSdk = oNode.ReadNode(L"XlstSdk");
|
||||
if (oNodeSdk.IsValid())
|
||||
LoadSDK_scripts(oNodeSdk, m_arXlstSDK);
|
||||
|
||||
m_sConsoleLogFile = L"";
|
||||
m_sErrorsLogFile = L"";
|
||||
|
||||
XmlUtils::CXmlNode oNodeConsoleLogFile = oNode.ReadNode(L"LogFileConsoleLog");
|
||||
if (oNodeConsoleLogFile.IsValid())
|
||||
{
|
||||
m_sConsoleLogFile = oNodeConsoleLogFile.GetText();
|
||||
if (!NSFile::CFileBinary::Exists(m_sConsoleLogFile))
|
||||
m_sConsoleLogFile = m_strConfigDir + m_sConsoleLogFile;
|
||||
}
|
||||
|
||||
XmlUtils::CXmlNode oNodeErrorsLogFile = oNode.ReadNode(L"LogFileErrors");
|
||||
if (oNodeErrorsLogFile.IsValid())
|
||||
{
|
||||
m_sErrorsLogFile = oNodeErrorsLogFile.GetText();
|
||||
if (!NSFile::CFileBinary::Exists(m_sErrorsLogFile))
|
||||
m_sErrorsLogFile = m_strConfigDir + m_sErrorsLogFile;
|
||||
}
|
||||
}
|
||||
|
||||
void LoadSDK_scripts(XmlUtils::CXmlNode& oNode, std::vector<std::wstring>& _files)
|
||||
{
|
||||
XmlUtils::CXmlNodes oNodes;
|
||||
if (oNode.GetNodes(L"file", oNodes))
|
||||
{
|
||||
int nCount = oNodes.GetCount();
|
||||
XmlUtils::CXmlNode _node;
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
oNodes.GetAt(i, _node);
|
||||
std::wstring strFilePath = _node.GetText();
|
||||
|
||||
if (NSFile::CFileBinary::Exists(strFilePath) &&
|
||||
!NSFile::CFileBinary::Exists(m_strConfigDir + strFilePath))
|
||||
_files.push_back(strFilePath);
|
||||
else
|
||||
_files.push_back(m_strConfigDir + strFilePath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring strFilePath = oNode.GetText();
|
||||
|
||||
if (NSFile::CFileBinary::Exists(strFilePath) &&
|
||||
!NSFile::CFileBinary::Exists(m_strConfigDir + strFilePath))
|
||||
_files.push_back(strFilePath);
|
||||
else
|
||||
_files.push_back(m_strConfigDir + strFilePath);
|
||||
}
|
||||
CDoctRendererConfig::Parse(sConfigDir);
|
||||
}
|
||||
|
||||
public:
|
||||
@ -672,9 +568,8 @@ namespace NSDoctRenderer
|
||||
|
||||
context->CreateGlobalForContext();
|
||||
CNativeControlEmbed::CreateObjectBuilderInContext("CreateNativeEngine", context);
|
||||
CMemoryStreamEmbed::CreateObjectInContext ("CreateNativeMemoryStream", context);
|
||||
CGraphicsEmbed::CreateObjectInContext ("CreateNativeGraphics", context);
|
||||
CZipEmbed::CreateObjectInContext ("CreateNativeZip", context);
|
||||
CGraphicsEmbed::CreateObjectInContext("CreateNativeGraphics", context);
|
||||
NSJSBase::CreateDefaults(context);
|
||||
context->CreateContext();
|
||||
|
||||
JSSmart<CJSContextScope> context_scope = context->CreateContextScope();
|
||||
@ -1186,19 +1081,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
|
||||
std::wstring strFileName = m_pInternal->m_oParams.m_strSrcFilePath;
|
||||
size_t nFileNameLen = strFileName.length();
|
||||
if (4 < nFileNameLen)
|
||||
{
|
||||
const wchar_t* bufFileName = strFileName.c_str();
|
||||
if (bufFileName[nFileNameLen - 4] != '.' ||
|
||||
bufFileName[nFileNameLen - 3] != 'b' ||
|
||||
bufFileName[nFileNameLen - 2] != 'i' ||
|
||||
bufFileName[nFileNameLen - 1] != 'n')
|
||||
{
|
||||
strFileName += L"/Editor.bin";
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!NSFile::CFileBinary::Exists(strFileName))
|
||||
{
|
||||
strFileName += L"/Editor.bin";
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@ core_ios {
|
||||
CONFIG += doct_renderer_empty
|
||||
}
|
||||
core_android {
|
||||
DEFINES += DISABLE_MEMORY_LIMITATION
|
||||
CONFIG += doct_renderer_empty
|
||||
}
|
||||
|
||||
@ -48,24 +49,27 @@ SOURCES += \
|
||||
|
||||
HEADERS += \
|
||||
docbuilder_p.h \
|
||||
memorystream.h \
|
||||
nativecontrol.h \
|
||||
graphics.h
|
||||
|
||||
HEADERS += \
|
||||
embed/PointerEmbed.h \
|
||||
embed/ZipEmbed.h \
|
||||
embed/GraphicsEmbed.h \
|
||||
embed/MemoryStreamEmbed.h \
|
||||
embed/NativeControlEmbed.h \
|
||||
embed/NativeBuilderEmbed.h \
|
||||
embed/TextMeasurerEmbed.h \
|
||||
js_internal/js_base.h
|
||||
|
||||
SOURCES += \
|
||||
embed/PointerEmbed.cpp \
|
||||
embed/ZipEmbed.cpp \
|
||||
embed/GraphicsEmbed.cpp \
|
||||
embed/MemoryStreamEmbed.cpp \
|
||||
embed/NativeControlEmbed.cpp \
|
||||
embed/NativeBuilderEmbed.cpp
|
||||
embed/NativeBuilderEmbed.cpp \
|
||||
embed/TextMeasurerEmbed.cpp
|
||||
|
||||
core_mac {
|
||||
!use_v8:CONFIG += use_javascript_core
|
||||
@ -79,8 +83,10 @@ include($$PWD/js_internal/js_base.pri)
|
||||
embed/v8/v8_MemoryStream.cpp \
|
||||
embed/v8/v8_NativeControl.cpp \
|
||||
embed/v8/v8_NativeBuilder.cpp \
|
||||
embed/v8/v8_Graphics.cpp \
|
||||
embed/v8/v8_Zip.cpp
|
||||
embed/v8/v8_Graphics.cpp \
|
||||
embed/v8/v8_Zip.cpp \
|
||||
embed/v8/v8_Pointer.cpp \
|
||||
embed/v8/v8_TextMeasurer.cpp
|
||||
|
||||
build_xp:DESTDIR=$$DESTDIR/xp
|
||||
} else {
|
||||
@ -89,13 +95,17 @@ include($$PWD/js_internal/js_base.pri)
|
||||
embed/jsc/jsc_Graphics.mm \
|
||||
embed/jsc/jsc_MemoryStream.mm \
|
||||
embed/jsc/jsc_NativeControl.mm \
|
||||
embed/jsc/jsc_NativeBuilder.mm \
|
||||
embed/jsc/jsc_Zip.mm
|
||||
embed/jsc/jsc_NativeBuilder.mm \
|
||||
embed/jsc/jsc_Zip.mm \
|
||||
embed/jsc/jsc_Pointer.mm \
|
||||
embed/jsc/jsc_TextMeasurer.mm
|
||||
|
||||
LIBS += -framework Foundation
|
||||
}
|
||||
}
|
||||
|
||||
include(../graphics/pro/textshaper.pri)
|
||||
|
||||
# downloader
|
||||
DEFINES += BUIDLER_OPEN_DOWNLOAD_ENABLED
|
||||
DEFINES += BUIDLER_OPEN_BASE64_ENABLED
|
||||
|
||||
18
DesktopEditor/doctrenderer/embed/Default.h
Normal file
18
DesktopEditor/doctrenderer/embed/Default.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef _BUILD_NATIVE_DEFAULT_EMBED_H_
|
||||
#define _BUILD_NATIVE_DEFAULT_EMBED_H_
|
||||
|
||||
#include "./ZipEmbed.h"
|
||||
#include "./TextMeasurerEmbed.h"
|
||||
#include "./MemoryStreamEmbed.h"
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
static void CreateDefaults(JSSmart<CJSContext>& context)
|
||||
{
|
||||
CZipEmbed::CreateObjectInContext("CreateNativeZip", context);
|
||||
CTextMeasurerEmbed::CreateObjectInContext("CreateNativeTextMeasurer", context);
|
||||
CMemoryStreamEmbed::CreateObjectInContext("CreateNativeMemoryStream", context);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _BUILD_NATIVE_DEFAULT_EMBED_H_
|
||||
@ -1,7 +1,7 @@
|
||||
#ifndef _BUILD_NATIVE_MEMORYSTREAM_EMBED_H_
|
||||
#define _BUILD_NATIVE_MEMORYSTREAM_EMBED_H_
|
||||
|
||||
#include "../memorystream.h"
|
||||
#include "../../fontengine/MemoryStream.h"
|
||||
#include "../js_internal/js_base.h"
|
||||
|
||||
using namespace NSJSBase;
|
||||
|
||||
32
DesktopEditor/doctrenderer/embed/PointerEmbed.cpp
Normal file
32
DesktopEditor/doctrenderer/embed/PointerEmbed.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include "PointerEmbed.h"
|
||||
#include <memory>
|
||||
|
||||
namespace NSPointerObjectDeleters
|
||||
{
|
||||
void EmptyDeleter(void* data)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
void FreeDeleter(void* data)
|
||||
{
|
||||
free(data);
|
||||
}
|
||||
}
|
||||
|
||||
CPointerEmbedObject::CPointerEmbedObject(void* data, NSPointerObjectDeleters::PointerObjectDeleter deleter)
|
||||
{
|
||||
Data = data;
|
||||
Deleter = deleter;
|
||||
}
|
||||
|
||||
void CPointerEmbedObject::Free()
|
||||
{
|
||||
if (Data && Deleter)
|
||||
Deleter(Data);
|
||||
Data = nullptr;
|
||||
}
|
||||
|
||||
CPointerEmbedObject::~CPointerEmbedObject()
|
||||
{
|
||||
Free();
|
||||
}
|
||||
35
DesktopEditor/doctrenderer/embed/PointerEmbed.h
Normal file
35
DesktopEditor/doctrenderer/embed/PointerEmbed.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef _BUILD_NATIVE_POINTER_EMBED_H_
|
||||
#define _BUILD_NATIVE_POINTER_EMBED_H_
|
||||
|
||||
#include "../js_internal/js_base.h"
|
||||
|
||||
namespace NSPointerObjectDeleters
|
||||
{
|
||||
using PointerObjectDeleter = void (*)(void* data);
|
||||
|
||||
void EmptyDeleter(void* data);
|
||||
void FreeDeleter(void* data);
|
||||
}
|
||||
|
||||
#define POINTER_DELETER(CLASS_NAME, NAME) void NAME(void* data) { CLASS_NAME* p = (CLASS_NAME*)data; delete data; }
|
||||
|
||||
using namespace NSJSBase;
|
||||
class CPointerEmbedObject : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
void* Data;
|
||||
|
||||
private:
|
||||
NSPointerObjectDeleters::PointerObjectDeleter Deleter;
|
||||
|
||||
public:
|
||||
CPointerEmbedObject(void* data, NSPointerObjectDeleters::PointerObjectDeleter = nullptr);
|
||||
void Free();
|
||||
virtual ~CPointerEmbedObject();
|
||||
|
||||
virtual void* getObject() { return Data; }
|
||||
|
||||
JSSmart<CJSValue> createObject();
|
||||
};
|
||||
|
||||
#endif // _BUILD_NATIVE_POINTER_EMBED_H_
|
||||
170
DesktopEditor/doctrenderer/embed/TextMeasurerEmbed.cpp
Normal file
170
DesktopEditor/doctrenderer/embed/TextMeasurerEmbed.cpp
Normal file
@ -0,0 +1,170 @@
|
||||
#include "./TextMeasurerEmbed.h"
|
||||
#include "./../../fontengine/TextShaper.h"
|
||||
|
||||
#define RAW_POINTER(value) ((CPointerEmbedObject*)value->toObject()->getNative())->Data
|
||||
#define POINTER_OBJECT(value) ((CPointerEmbedObject*)value->toObject()->getNative())
|
||||
|
||||
class CExternalPointerJS : public NSShaper::CExternalPointer
|
||||
{
|
||||
public:
|
||||
CExternalPointerJS() : NSShaper::CExternalPointer() {}
|
||||
virtual ~CExternalPointerJS() {}
|
||||
|
||||
public:
|
||||
virtual void Alloc(const unsigned int& len)
|
||||
{
|
||||
Len = len;
|
||||
Data = NSAllocator::Alloc((size_t)Len);
|
||||
}
|
||||
virtual void Free()
|
||||
{
|
||||
if (Data)
|
||||
NSAllocator::Free(Data, (size_t)Len);
|
||||
}
|
||||
};
|
||||
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Malloc(JSSmart<CJSValue> typed_array_or_len)
|
||||
{
|
||||
void* pData = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
if (typed_array_or_len->isNumber())
|
||||
{
|
||||
len = (size_t)typed_array_or_len->toInt32();
|
||||
if (0 != len)
|
||||
pData = malloc((size_t)len);
|
||||
}
|
||||
else
|
||||
{
|
||||
CJSDataBuffer pBuffer = typed_array_or_len->toTypedArray()->getData();
|
||||
pData = malloc(pBuffer.Len);
|
||||
memcpy(pData, pBuffer.Data, pBuffer.Len);
|
||||
if (pBuffer.IsExternalize)
|
||||
pBuffer.Free();
|
||||
}
|
||||
|
||||
CPointerEmbedObject* pObject = new CPointerEmbedObject(pData, NSPointerObjectDeleters::FreeDeleter);
|
||||
return pObject->createObject();
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Free(JSSmart<CJSValue> pointer)
|
||||
{
|
||||
CPointerEmbedObject* pEmbed = (CPointerEmbedObject*)pointer->toObject()->getNative();
|
||||
pEmbed->Free();
|
||||
return CJSContext::createUndefined();
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Init()
|
||||
{
|
||||
CPointerEmbedObject* pointer = new CPointerEmbedObject(NSShaper::FT_Library_Init(), [](void* data) { NSShaper::FT_Library_Destroy(data); });
|
||||
return pointer->createObject();
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Set_TrueType_HintProp(JSSmart<CJSValue> library, JSSmart<CJSValue> tt_interpreter)
|
||||
{
|
||||
return CJSContext::createInt(NSShaper::FT_Set_TrueType_HintProp(RAW_POINTER(library), tt_interpreter->toUInt32()));
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Open_Face(JSSmart<CJSValue> library, JSSmart<CJSValue> memory, JSSmart<CJSValue> size, JSSmart<CJSValue> face_index)
|
||||
{
|
||||
void* face = NSShaper::FT_Open_Face(RAW_POINTER(library), (unsigned char*)RAW_POINTER(memory), size->toUInt32(), face_index->toInt32());
|
||||
CPointerEmbedObject* pointer = new CPointerEmbedObject(face, [](void* data) { NSShaper::FT_Done_Face(data); });
|
||||
return pointer->createObject();
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Open_Face2(JSSmart<CJSValue> library, JSSmart<CJSValue> array, JSSmart<CJSValue> face_index)
|
||||
{
|
||||
CJSDataBuffer buffer = array->toTypedArray()->getData();
|
||||
void* face = NSShaper::FT_Open_Face(RAW_POINTER(library), (unsigned char*)buffer.Data, (unsigned int)buffer.Len, face_index->toInt32());
|
||||
CPointerEmbedObject* pointer = new CPointerEmbedObject(face, NSPointerObjectDeleters::EmptyDeleter);
|
||||
return pointer->createObject();
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_GetFaceInfo(JSSmart<CJSValue> face)
|
||||
{
|
||||
CExternalPointerJS result;
|
||||
if (!NSShaper::FT_GetFaceInfo(RAW_POINTER(face), &result))
|
||||
return CJSContext::createNull();
|
||||
|
||||
return CJSContext::createUint8Array(result.Data, result.Len, false);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Load_Glyph(JSSmart<CJSValue> face, JSSmart<CJSValue> gid, JSSmart<CJSValue> mode)
|
||||
{
|
||||
return CJSContext::createInt(NSShaper::FT_Load_Glyph(RAW_POINTER(face), gid->toUInt32(), mode->toInt32()));
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Get_Glyph_Measure_Params(JSSmart<CJSValue> face, JSSmart<CJSValue> is_vector)
|
||||
{
|
||||
CExternalPointerJS result;
|
||||
if (!NSShaper::FT_Get_Glyph_Measure_Params(RAW_POINTER(face), is_vector->toBool(), &result))
|
||||
return CJSContext::createNull();
|
||||
|
||||
return CJSContext::createUint8Array(result.Data, result.Len, false);
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Get_Glyph_Render_Params(JSSmart<CJSValue> face, JSSmart<CJSValue> render_mode)
|
||||
{
|
||||
CExternalPointerJS result;
|
||||
if (!NSShaper::FT_Get_Glyph_Render_Params(RAW_POINTER(face), render_mode->toInt32(), &result))
|
||||
return CJSContext::createNull();
|
||||
|
||||
return CJSContext::createUint8Array(result.Data, result.Len, false);
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Get_Glyph_Render_Buffer(JSSmart<CJSValue> face, JSSmart<CJSValue> size)
|
||||
{
|
||||
void* Data = NSShaper::FT_Get_Glyph_Render_Buffer(RAW_POINTER(face));
|
||||
return CJSContext::createUint8Array((unsigned char*)Data, size->toInt32(), true);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Set_Transform(JSSmart<CJSValue> face, JSSmart<CJSValue> xx, JSSmart<CJSValue> yx, JSSmart<CJSValue> xy, JSSmart<CJSValue> yy)
|
||||
{
|
||||
NSShaper::FT_Set_Transform(RAW_POINTER(face), xx->toInt32(), yx->toInt32(), xy->toInt32(), yy->toInt32());
|
||||
return CJSContext::createUndefined();
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Set_Char_Size(JSSmart<CJSValue> face, JSSmart<CJSValue> char_width, JSSmart<CJSValue> char_height, JSSmart<CJSValue> hres, JSSmart<CJSValue> vres)
|
||||
{
|
||||
return CJSContext::createInt(NSShaper::FT_Set_Char_Size(RAW_POINTER(face), char_width->toInt32(), char_height->toInt32(), hres->toUInt32(), vres->toUInt32()));
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_SetCMapForCharCode(JSSmart<CJSValue> face, JSSmart<CJSValue> unicode)
|
||||
{
|
||||
return CJSContext::createUInt(NSShaper::FT_SetCMapForCharCode(RAW_POINTER(face), unicode->toUInt32()));
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_GetKerningX(JSSmart<CJSValue> face, JSSmart<CJSValue> gid1, JSSmart<CJSValue> gid2)
|
||||
{
|
||||
return CJSContext::createInt(NSShaper::FT_GetKerningX(RAW_POINTER(face), gid1->toUInt32(), gid2->toUInt32()));
|
||||
}
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::FT_GetFaceMaxAdvanceX(JSSmart<CJSValue> face)
|
||||
{
|
||||
return CJSContext::createInt(NSShaper::FT_GetFaceMaxAdvanceX(RAW_POINTER(face)));
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_HARFBUZZ_SHAPER
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::HB_LanguageFromString(JSSmart<CJSValue> language_bcp_47)
|
||||
{
|
||||
void* Data = NSShaper::HB_LanguageFromString(language_bcp_47->toStringA());
|
||||
CPointerEmbedObject* pObject = new CPointerEmbedObject(Data, [](void* data) { NSShaper::HB_free(data); });
|
||||
return pObject->createObject();
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::HB_ShapeText(JSSmart<CJSValue> face, JSSmart<CJSValue> font, JSSmart<CJSValue> text,
|
||||
JSSmart<CJSValue> nFeatures, JSSmart<CJSValue> nScript, JSSmart<CJSValue> nDirection, JSSmart<CJSValue> nLanguage)
|
||||
{
|
||||
CPointerEmbedObject* pFont = POINTER_OBJECT(font);
|
||||
CExternalPointerJS result;
|
||||
|
||||
CJSDataBuffer buffer = text->toTypedArray()->getData();
|
||||
char* pText = (char*)buffer.Data;
|
||||
|
||||
NSShaper::HB_ShapeText(RAW_POINTER(face), pFont->Data, pText,
|
||||
nFeatures->toUInt32(), nScript->toUInt32(), nDirection->toUInt32(), RAW_POINTER(nLanguage), &result);
|
||||
|
||||
if (buffer.IsExternalize)
|
||||
buffer.Free();
|
||||
|
||||
if (NULL == result.Data)
|
||||
return CJSContext::createNull();
|
||||
|
||||
return CJSContext::createUint8Array(result.Data, result.Len, false);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CTextMeasurerEmbed::HB_FontFree(JSSmart<CJSValue> font)
|
||||
{
|
||||
NSShaper::HB_FontFree(RAW_POINTER(font));
|
||||
return CJSContext::createUndefined();
|
||||
}
|
||||
#endif
|
||||
52
DesktopEditor/doctrenderer/embed/TextMeasurerEmbed.h
Normal file
52
DesktopEditor/doctrenderer/embed/TextMeasurerEmbed.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef _BUILD_NATIVE_TEXT_MEASURER_EMBED_H_
|
||||
#define _BUILD_NATIVE_TEXT_MEASURER_EMBED_H_
|
||||
|
||||
#include "../js_internal/js_base.h"
|
||||
#include "./PointerEmbed.h"
|
||||
|
||||
using namespace NSJSBase;
|
||||
class CTextMeasurerEmbed : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
CTextMeasurerEmbed()
|
||||
{
|
||||
}
|
||||
~CTextMeasurerEmbed()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
JSSmart<CJSValue> FT_Malloc(JSSmart<CJSValue> typed_array_or_len);
|
||||
JSSmart<CJSValue> FT_Free(JSSmart<CJSValue> pointer);
|
||||
|
||||
JSSmart<CJSValue> FT_Init();
|
||||
JSSmart<CJSValue> FT_Set_TrueType_HintProp(JSSmart<CJSValue> library, JSSmart<CJSValue> tt_interpreter);
|
||||
|
||||
JSSmart<CJSValue> FT_Open_Face(JSSmart<CJSValue> library, JSSmart<CJSValue> memory, JSSmart<CJSValue> size, JSSmart<CJSValue> face_index);
|
||||
JSSmart<CJSValue> FT_Open_Face2(JSSmart<CJSValue> library, JSSmart<CJSValue> array, JSSmart<CJSValue> face_index);
|
||||
JSSmart<CJSValue> FT_GetFaceInfo(JSSmart<CJSValue> face);
|
||||
|
||||
JSSmart<CJSValue> FT_Load_Glyph(JSSmart<CJSValue> face, JSSmart<CJSValue> gid, JSSmart<CJSValue> mode);
|
||||
JSSmart<CJSValue> FT_Get_Glyph_Measure_Params(JSSmart<CJSValue> face, JSSmart<CJSValue> is_vector);
|
||||
JSSmart<CJSValue> FT_Get_Glyph_Render_Params(JSSmart<CJSValue> face, JSSmart<CJSValue> render_mode);
|
||||
JSSmart<CJSValue> FT_Get_Glyph_Render_Buffer(JSSmart<CJSValue> face, JSSmart<CJSValue> size);
|
||||
|
||||
JSSmart<CJSValue> FT_Set_Transform(JSSmart<CJSValue> face, JSSmart<CJSValue> xx, JSSmart<CJSValue> yx, JSSmart<CJSValue> xy, JSSmart<CJSValue> yy);
|
||||
JSSmart<CJSValue> FT_Set_Char_Size(JSSmart<CJSValue> face, JSSmart<CJSValue> char_width, JSSmart<CJSValue> char_height, JSSmart<CJSValue> hres, JSSmart<CJSValue> vres);
|
||||
JSSmart<CJSValue> FT_SetCMapForCharCode(JSSmart<CJSValue> face, JSSmart<CJSValue> unicode);
|
||||
JSSmart<CJSValue> FT_GetKerningX(JSSmart<CJSValue> face, JSSmart<CJSValue> gid1, JSSmart<CJSValue> gid2);
|
||||
JSSmart<CJSValue> FT_GetFaceMaxAdvanceX(JSSmart<CJSValue> face);
|
||||
|
||||
#ifdef SUPPORT_HARFBUZZ_SHAPER
|
||||
JSSmart<CJSValue> HB_LanguageFromString(JSSmart<CJSValue> language_bcp_47);
|
||||
|
||||
JSSmart<CJSValue> HB_ShapeText(JSSmart<CJSValue> face, JSSmart<CJSValue> font, JSSmart<CJSValue> text,
|
||||
JSSmart<CJSValue> nFeatures, JSSmart<CJSValue> nScript, JSSmart<CJSValue> nDirection, JSSmart<CJSValue> nLanguage);
|
||||
|
||||
JSSmart<CJSValue> HB_FontFree(JSSmart<CJSValue> font);
|
||||
#endif
|
||||
|
||||
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
|
||||
};
|
||||
|
||||
#endif // _BUILD_NATIVE_TEXT_MEASURER_EMBED_H_
|
||||
@ -2,21 +2,35 @@
|
||||
|
||||
JSSmart<CJSValue> CZipEmbed::open(JSSmart<CJSValue> typedArray)
|
||||
{
|
||||
close();
|
||||
RELEASEOBJECT(m_pFolder);
|
||||
if (!typedArray->isTypedArray())
|
||||
return CJSContext::createBool(false);
|
||||
return CJSContext::createNull();
|
||||
|
||||
JSSmart<CJSTypedArray> pArray = typedArray->toTypedArray();
|
||||
CJSDataBuffer buffer = pArray->getData();
|
||||
|
||||
m_pFolder = new CZipFolderMemory(buffer.Data, (DWORD)buffer.Len);
|
||||
buffer.Free();
|
||||
m_pFolder = new CZipFolderMemory(buffer.Data, (DWORD)buffer.Len);
|
||||
if (buffer.IsExternalize)
|
||||
buffer.Free();
|
||||
|
||||
return CJSContext::createBool(true);
|
||||
std::vector<std::wstring> arFiles = m_pFolder->getFiles(L"", true);
|
||||
if (arFiles.empty())
|
||||
return CJSContext::createNull();
|
||||
|
||||
JSSmart<CJSArray> retFiles = CJSContext::createArray((int)arFiles.size());
|
||||
|
||||
int nCurCount = 0;
|
||||
for (std::vector<std::wstring>::const_iterator i = arFiles.begin(); i != arFiles.end(); i++)
|
||||
{
|
||||
const std::wstring& val = *i;
|
||||
retFiles->set(nCurCount++, CJSContext::createString(val.empty() ? val : val.substr(1)));
|
||||
}
|
||||
|
||||
return retFiles->toValue();
|
||||
}
|
||||
JSSmart<CJSValue> CZipEmbed::create()
|
||||
{
|
||||
close();
|
||||
RELEASEOBJECT(m_pFolder);
|
||||
m_pFolder = new CZipFolderMemory();
|
||||
return CJSContext::createBool(true);
|
||||
}
|
||||
@ -26,11 +40,13 @@ JSSmart<CJSValue> CZipEmbed::save()
|
||||
return CJSContext::createNull();
|
||||
|
||||
IFolder::CBuffer* pBuffer = m_pFolder->finalize();
|
||||
BYTE* pMemory = NSJSBase::NSAllocator::Alloc((size_t)pBuffer->Size);
|
||||
memcpy(pMemory, pBuffer->Buffer, (size_t)pBuffer->Size);
|
||||
|
||||
size_t nBufferSize = (size_t)pBuffer->Size;
|
||||
BYTE* pMemory = NSJSBase::NSAllocator::Alloc(nBufferSize);
|
||||
memcpy(pMemory, pBuffer->Buffer, nBufferSize);
|
||||
RELEASEOBJECT(pBuffer);
|
||||
|
||||
return NSJSBase::CJSContext::createUint8Array(pMemory, (int)pBuffer->Size, false);
|
||||
return NSJSBase::CJSContext::createUint8Array(pMemory, (int)nBufferSize, false);
|
||||
}
|
||||
JSSmart<CJSValue> CZipEmbed::getFile(JSSmart<CJSValue> filePath)
|
||||
{
|
||||
@ -39,14 +55,15 @@ JSSmart<CJSValue> CZipEmbed::getFile(JSSmart<CJSValue> filePath)
|
||||
|
||||
std::wstring sFilePath = filePath->toStringW();
|
||||
IFolder::CBuffer* pBuffer;
|
||||
if (m_pFolder->read(sFilePath, pBuffer))
|
||||
if (!m_pFolder->read(sFilePath, pBuffer))
|
||||
return CJSContext::createNull();
|
||||
|
||||
BYTE* pMemory = NSJSBase::NSAllocator::Alloc((size_t)pBuffer->Size);
|
||||
memcpy(pMemory, pBuffer->Buffer, (size_t)pBuffer->Size);
|
||||
size_t nBufferSize = (size_t)pBuffer->Size;
|
||||
BYTE* pMemory = NSJSBase::NSAllocator::Alloc(nBufferSize);
|
||||
memcpy(pMemory, pBuffer->Buffer, nBufferSize);
|
||||
RELEASEOBJECT(pBuffer);
|
||||
|
||||
return NSJSBase::CJSContext::createUint8Array(pMemory, (int)pBuffer->Size, false);
|
||||
return NSJSBase::CJSContext::createUint8Array(pMemory, (int)nBufferSize, false);
|
||||
}
|
||||
JSSmart<CJSValue> CZipEmbed::addFile(JSSmart<CJSValue> filePath, JSSmart<CJSValue> typedArray)
|
||||
{
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#ifndef _BUILD_NATIVE_ZIP_EMBED_H_
|
||||
#define _BUILD_NATIVE_ZIP_EMBED_H_
|
||||
|
||||
#include "../../OfficeUtils/src/ZipFolder.h"
|
||||
#include "../../../OfficeUtils/src/ZipFolder.h"
|
||||
#include "../js_internal/js_base.h"
|
||||
|
||||
using namespace NSJSBase;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user