diff --git a/OOXML/Binary/Document/BinReader/Readers.cpp b/OOXML/Binary/Document/BinReader/Readers.cpp index 689c0ea7ad..9d56fa52fd 100644 --- a/OOXML/Binary/Document/BinReader/Readers.cpp +++ b/OOXML/Binary/Document/BinReader/Readers.cpp @@ -35,8 +35,6 @@ #include "../BinWriter/BinReaderWriterDefines.h" #include "../../Sheets/Writer/BinaryReader.h" -#include "../../../PPTXFormat/App.h" -#include "../../../PPTXFormat/Core.h" #include "../../../PPTXFormat/Logic/HeadingVariant.h" #include "../../../DocxFormat/Settings/Settings.h" @@ -10200,20 +10198,16 @@ int BinaryFileReader::ReadMainTable() // break; case c_oSerTableTypes::App: { - PPTX::App oApp(NULL); - oApp.fromPPTY(&m_oBufferedStream); OOX::CApp* pApp = new OOX::CApp(NULL); - pApp->FromPptxApp(&oApp); + pApp->fromPPTY(&m_oBufferedStream); pApp->SetRequiredDefaults(); m_oFileWriter.m_pApp = pApp; } break; case c_oSerTableTypes::Core: { - PPTX::Core oCore(NULL); - oCore.fromPPTY(&m_oBufferedStream); OOX::CCore* pCore = new OOX::CCore(NULL); - pCore->FromPptxCore(&oCore); + pCore->fromPPTY(&m_oBufferedStream); pCore->SetRequiredDefaults(); m_oFileWriter.m_pCore = pCore; } diff --git a/OOXML/Binary/Document/BinWriter/BinWriters.cpp b/OOXML/Binary/Document/BinWriter/BinWriters.cpp index 2599d73734..9028b19b3a 100644 --- a/OOXML/Binary/Document/BinWriter/BinWriters.cpp +++ b/OOXML/Binary/Document/BinWriter/BinWriters.cpp @@ -36,8 +36,6 @@ #include "../../../../Common/OfficeFileFormatChecker.h" #include "../../Presentation/FontCutter.h" -#include "../../../PPTXFormat/App.h" -#include "../../../PPTXFormat/Core.h" #include "../../../PPTXFormat/Logic/HeadingVariant.h" #include "../../Sheets/Reader/BinaryWriter.h" #include "BinEquationWriter.h" @@ -9653,18 +9651,14 @@ void BinaryFileWriter::intoBindoc(const std::wstring& sSrcPath) if ((pDocx) && (pDocx->m_pApp)) { nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::App); - PPTX::App* pAppTmp = pDocx->m_pApp->ToPptxApp(); - pAppTmp->toPPTY(&oBufferedStream); - delete pAppTmp; + pDocx->m_pApp->toPPTY(&oBufferedStream); this->WriteTableEnd(nCurPos); } if ((pDocx) && (pDocx->m_pCore)) { nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Core); - PPTX::Core* pCoreTmp = pDocx->m_pCore->ToPptxCore(); - pCoreTmp->toPPTY(&oBufferedStream); - delete pCoreTmp; + pDocx->m_pCore->toPPTY(&oBufferedStream); this->WriteTableEnd(nCurPos); } if (NULL != m_oParamsWriter.m_pTheme) diff --git a/OOXML/Binary/Presentation/Converter.cpp b/OOXML/Binary/Presentation/Converter.cpp index 9d7698deec..e63dbeecea 100644 --- a/OOXML/Binary/Presentation/Converter.cpp +++ b/OOXML/Binary/Presentation/Converter.cpp @@ -254,7 +254,7 @@ namespace PPTX2EditorAdvanced oBinaryWriter.WriteULONG(0); // App - smart_ptr app = oFolder.Get(OOX::FileTypes::App).smart_dynamic_cast(); + smart_ptr app = oFolder.Get(OOX::FileTypes::App).smart_dynamic_cast(); if (app.is_init()) { oBinaryWriter.StartMainRecord(NSBinPptxRW::NSMainTables::App); @@ -262,7 +262,7 @@ namespace PPTX2EditorAdvanced } // Core - smart_ptr core = oFolder.Get(OOX::FileTypes::Core).smart_dynamic_cast(); + smart_ptr core = oFolder.Get(OOX::FileTypes::Core).smart_dynamic_cast(); if (core.is_init()) { oBinaryWriter.StartMainRecord(NSBinPptxRW::NSMainTables::Core); diff --git a/OOXML/Binary/Presentation/PPTXWriter.cpp b/OOXML/Binary/Presentation/PPTXWriter.cpp index 47d45c37b0..27a937c557 100644 --- a/OOXML/Binary/Presentation/PPTXWriter.cpp +++ b/OOXML/Binary/Presentation/PPTXWriter.cpp @@ -1109,7 +1109,7 @@ namespace NSBinPptxRW } void CPPTXWriter::SetRequiredDefaultsApp() { - m_oApp.AppVersion.reset(NULL); + m_oApp.m_sAppVersion.reset(NULL); std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvApplicationName); if (sApplication.empty()) sApplication = NSSystemUtils::gc_EnvApplicationNameDefault; @@ -1117,20 +1117,20 @@ namespace NSBinPptxRW std::string s = VALUE2STR(INTVER); sApplication += L"/" + std::wstring(s.begin(), s.end()); #endif - m_oApp.Application = sApplication; + m_oApp.m_sApplication = sApplication; } void CPPTXWriter::CreateDefaultApp() { - m_oApp.TotalTime = 0; - m_oApp.Words = 0; + m_oApp.m_nTotalTime = 0; + m_oApp.m_nWords = 0; SetRequiredDefaultsApp(); - m_oApp.PresentationFormat = L"On-screen Show (4:3)"; - m_oApp.Paragraphs = 0; - m_oApp.Slides = (int)m_arSlides.size(); - m_oApp.Notes = (int)m_arSlides.size(); - m_oApp.HiddenSlides = 0; - m_oApp.MMClips = 2; - m_oApp.ScaleCrop = false; + m_oApp.m_sPresentationForm = L"On-screen Show (4:3)"; + m_oApp.m_nParagraphs = 0; + m_oApp.m_nSlides = (int)m_arSlides.size(); + m_oApp.m_nNotes = (int)m_arSlides.size(); + m_oApp.m_nHiddenSlides = 0; + m_oApp.m_nMMClips = 2; + m_oApp.m_bScaleCrop = false; int nCountThemes = (int)m_arSlideMasters.size(); int nCountSlides = (int)m_arSlides.size(); @@ -1162,35 +1162,35 @@ namespace NSBinPptxRW m_oApp.TitlesOfParts[nCountThemes + i].m_title = s; } - m_oApp.LinksUpToDate = false; - m_oApp.SharedDoc = false; - m_oApp.HyperlinksChanged = false; + m_oApp.m_bLinksUpToDate = false; + m_oApp.m_bSharedDoc = false; + m_oApp.m_bHyperlinksChanged = false; } void CPPTXWriter::SetRequiredDefaultsCore() { - if (!m_oCore.creator.IsInit()) + if (!m_oCore.m_sCreator.IsInit()) { std::wstring sCreator = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvCreator); if (!sCreator.empty()) - m_oCore.creator = sCreator; + m_oCore.m_sCreator = sCreator; } - if (!m_oCore.created.IsInit()) + if (!m_oCore.m_sCreated.IsInit()) { std::wstring sCreated = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvCreated); if (!sCreated.empty()) - m_oCore.created = sCreated; + m_oCore.m_sCreated = sCreated; } std::wstring sLastModifiedBy = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvLastModifiedBy); if (!sLastModifiedBy.empty()) - m_oCore.lastModifiedBy = sLastModifiedBy; + m_oCore.m_sLastModifiedBy = sLastModifiedBy; std::wstring sModified = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvModified); if (!sModified.empty()) - m_oCore.modified = sModified; + m_oCore.m_sModified = sModified; } void CPPTXWriter::CreateDefaultCore() { // m_oCore.creator = _T(""); - m_oCore.lastModifiedBy = _T(""); + m_oCore.m_sLastModifiedBy = _T(""); } void CPPTXWriter::CreateDefaultViewProps() { diff --git a/OOXML/Binary/Presentation/PPTXWriter.h b/OOXML/Binary/Presentation/PPTXWriter.h index b14c951cfa..02429183f9 100644 --- a/OOXML/Binary/Presentation/PPTXWriter.h +++ b/OOXML/Binary/Presentation/PPTXWriter.h @@ -72,8 +72,8 @@ namespace NSBinPptxRW PPTX::Presentation m_oPresentation; PPTX::TableStyles m_oTableStyles; OOX::CVmlDrawing m_oVmlDrawing; - PPTX::App m_oApp; - PPTX::Core m_oCore; + OOX::CApp m_oApp; + OOX::CCore m_oCore; nullable m_oCustomProperties; PPTX::ViewProps m_oViewProps; PPTX::PresProps m_oPresProps; diff --git a/OOXML/Binary/Sheets/Reader/BinaryWriter.cpp b/OOXML/Binary/Sheets/Reader/BinaryWriter.cpp index bb746eede8..311c7c7d1b 100644 --- a/OOXML/Binary/Sheets/Reader/BinaryWriter.cpp +++ b/OOXML/Binary/Sheets/Reader/BinaryWriter.cpp @@ -38,8 +38,6 @@ #include "../../../../Common/OfficeFileErrorDescription.h" #include "../../Presentation/FontCutter.h" -#include "../../../PPTXFormat/App.h" -#include "../../../PPTXFormat/Core.h" #include "../../../PPTXFormat/Logic/HeadingVariant.h" #include "../../../XlsxFormat/Xlsx.h" @@ -8777,14 +8775,14 @@ void BinaryFileWriter::WriteContent(OOX::Document *pDocument, NSFontCutter::CEmb if(pXlsx && pXlsx->m_pApp) { nCurPos = this->WriteTableStart(c_oSerTableTypes::App); - pXlsx->m_pApp->ToPptxApp()->toPPTY(&m_oBcw->m_oStream); + pXlsx->m_pApp->toPPTY(&m_oBcw->m_oStream); this->WriteTableEnd(nCurPos); } if(pXlsx && pXlsx->m_pCore) { nCurPos = this->WriteTableStart(c_oSerTableTypes::Core); - pXlsx->m_pCore->ToPptxCore()->toPPTY(&m_oBcw->m_oStream); + pXlsx->m_pCore->toPPTY(&m_oBcw->m_oStream); this->WriteTableEnd(nCurPos); } diff --git a/OOXML/Binary/Sheets/Writer/BinaryReader.cpp b/OOXML/Binary/Sheets/Writer/BinaryReader.cpp index bd4047514f..0e94b1be81 100644 --- a/OOXML/Binary/Sheets/Writer/BinaryReader.cpp +++ b/OOXML/Binary/Sheets/Writer/BinaryReader.cpp @@ -47,8 +47,6 @@ #include "../../../PPTXFormat/Theme.h" #include "../../../../MsBinaryFile/Common/Vml/toVmlConvert.h" -#include "../../../PPTXFormat/App.h" -#include "../../../PPTXFormat/Core.h" #include "../../../PPTXFormat/Logic/HeadingVariant.h" #include "../../../PPTXFormat/Logic/Shape.h" @@ -8864,11 +8862,8 @@ int BinaryFileReader::ReadMainTable(OOX::Spreadsheet::CXlsx& oXlsx, NSBinPptxRW: { case c_oSerTableTypes::App: { - PPTX::App oApp(NULL); - oApp.fromPPTY(&oBufferedStream); - OOX::CApp* pApp = new OOX::CApp(NULL); - pApp->FromPptxApp(&oApp); + pApp->fromPPTY(&oBufferedStream); pApp->SetRequiredDefaults(); oXlsx.m_pApp = pApp; smart_ptr oCurFile(pApp); @@ -8876,11 +8871,8 @@ int BinaryFileReader::ReadMainTable(OOX::Spreadsheet::CXlsx& oXlsx, NSBinPptxRW: }break; case c_oSerTableTypes::Core: { - PPTX::Core oCore(NULL); - oCore.fromPPTY(&oBufferedStream); - OOX::CCore* pCore = new OOX::CCore(NULL); - pCore->FromPptxCore(&oCore); + pCore->fromPPTY(&oBufferedStream); pCore->SetRequiredDefaults(); oXlsx.m_pCore = pCore; smart_ptr oCurFile(pCore); diff --git a/OOXML/DocxFormat/App.cpp b/OOXML/DocxFormat/App.cpp index d2fe46c880..bf0440af27 100644 --- a/OOXML/DocxFormat/App.cpp +++ b/OOXML/DocxFormat/App.cpp @@ -32,9 +32,9 @@ #include "App.h" #include "Docx.h" #include "../XlsxFormat/Xlsx.h" -#include "../PPTXFormat/App.h" #include "../Common/SimpleTypes_Word.h" #include "../../DesktopEditor/common/SystemUtils.h" +#include "../../DesktopEditor/xml/include/xmlutils.h" namespace OOX { @@ -57,106 +57,6 @@ namespace OOX CApp::~CApp() { } - PPTX::App* CApp::ToPptxApp() - { - PPTX::App* res = new PPTX::App(NULL); - if(m_sTemplate.IsInit()) - res->Template = m_sTemplate.get(); - if(m_nTotalTime.IsInit()) - res->TotalTime = m_nTotalTime.get(); - if(m_nWords.IsInit()) - res->Words = m_nWords.get(); - if(m_sApplication.IsInit()) - res->Application = m_sApplication.get(); - if(m_sPresentationForm.IsInit()) - res->PresentationFormat = m_sPresentationForm.get(); - if(m_nParagraphs.IsInit()) - res->Paragraphs = m_nParagraphs.get(); - if(m_nSlides.IsInit()) - res->Slides = m_nSlides.get(); - if(m_nNotes.IsInit()) - res->Notes = m_nNotes.get(); - if(m_nHiddenSlides.IsInit()) - res->HiddenSlides = m_nHiddenSlides.get(); - if(m_nMMClips.IsInit()) - res->MMClips = m_nMMClips.get(); - if(m_bScaleCrop.IsInit()) - res->ScaleCrop = m_bScaleCrop.get(); - if(m_sCompany.IsInit()) - res->Company = m_sCompany.get(); - if(m_bLinksUpToDate.IsInit()) - res->LinksUpToDate = m_bLinksUpToDate.get(); - if(m_bSharedDoc.IsInit()) - res->SharedDoc = m_bSharedDoc.get(); - if(m_bHyperlinksChanged.IsInit()) - res->HyperlinksChanged = m_bHyperlinksChanged.get(); - if(m_sAppVersion.IsInit()) - res->AppVersion = m_sAppVersion.get(); - if(m_nCharacters.IsInit()) - res->Characters = m_nCharacters.get(); - if(m_nCharactersWithSpaces.IsInit()) - res->CharactersWithSpaces = m_nCharactersWithSpaces.get(); - if(m_nDocSecurity.IsInit()) - res->DocSecurity = m_nDocSecurity.get(); - if(m_sHyperlinkBase.IsInit()) - res->HyperlinkBase = m_sHyperlinkBase.get(); - if(m_nLines.IsInit()) - res->Lines = m_nLines.get(); - if(m_sManager.IsInit()) - res->Manager = m_sManager.get(); - if(m_nPages.IsInit()) - res->Pages = m_nPages.get(); - return res; - } - void CApp::FromPptxApp(PPTX::App* pApp) - { - if(pApp->Template.IsInit()) - m_sTemplate = pApp->Template.get(); - if(pApp->TotalTime.IsInit()) - m_nTotalTime = pApp->TotalTime.get(); - if(pApp->Words.IsInit()) - m_nWords = pApp->Words.get(); - if(pApp->Application.IsInit()) - m_sApplication = pApp->Application.get(); - if(pApp->PresentationFormat.IsInit()) - m_sPresentationForm = pApp->PresentationFormat.get(); - if(pApp->Paragraphs.IsInit()) - m_nParagraphs = pApp->Paragraphs.get(); - if(pApp->Slides.IsInit()) - m_nSlides = pApp->Slides.get(); - if(pApp->Notes.IsInit()) - m_nNotes = pApp->Notes.get(); - if(pApp->HiddenSlides.IsInit()) - m_nHiddenSlides = pApp->HiddenSlides.get(); - if(pApp->MMClips.IsInit()) - m_nMMClips = pApp->MMClips.get(); - if(pApp->ScaleCrop.IsInit()) - m_bScaleCrop = pApp->ScaleCrop.get(); - if(pApp->Company.IsInit()) - m_sCompany = pApp->Company.get(); - if(pApp->LinksUpToDate.IsInit()) - m_bLinksUpToDate = pApp->LinksUpToDate.get(); - if(pApp->SharedDoc.IsInit()) - m_bSharedDoc = pApp->SharedDoc.get(); - if(pApp->HyperlinksChanged.IsInit()) - m_bHyperlinksChanged = pApp->HyperlinksChanged.get(); - if(pApp->AppVersion.IsInit()) - m_sAppVersion = pApp->AppVersion.get(); - if(pApp->Characters.IsInit()) - m_nCharacters = pApp->Characters.get(); - if(pApp->CharactersWithSpaces.IsInit()) - m_nCharactersWithSpaces = pApp->CharactersWithSpaces.get(); - if(pApp->DocSecurity.IsInit()) - m_nDocSecurity = pApp->DocSecurity.get(); - if(pApp->HyperlinkBase.IsInit()) - m_sHyperlinkBase = pApp->HyperlinkBase.get(); - if(pApp->Lines.IsInit()) - m_nLines = pApp->Lines.get(); - if(pApp->Manager.IsInit()) - m_sManager = pApp->Manager.get(); - if(pApp->Pages.IsInit()) - m_nPages = pApp->Pages.get(); - } void CApp::read(const CPath& oPath) { XmlUtils::CXmlNode oProperties; @@ -231,6 +131,22 @@ namespace OOX if ( oProperties.GetNode( _T("Words"), oItem ) ) m_nWords = oItem.GetText(); + + XmlUtils::CXmlNode oHP = oProperties.ReadNode(_T("HeadingPairs")); + XmlUtils::CXmlNode oNodeVector1; + if (oHP.GetNode(_T("vt:vector"), oNodeVector1)) + { + XmlMacroReadAttributeBase(oNodeVector1, _T("size"), m_Headings); + XmlMacroLoadArray(oNodeVector1, _T("vt:variant"), HeadingPairs, PPTX::Logic::HeadingVariant); + } + + XmlUtils::CXmlNode oTP = oProperties.ReadNode(_T("TitlesOfParts")); + XmlUtils::CXmlNode oNodeVector2; + if (oTP.GetNode(_T("vt:vector"), oNodeVector2)) + { + XmlMacroReadAttributeBase(oNodeVector2, _T("size"), m_VectorSize); + XmlMacroLoadArray(oNodeVector2, _T("vt:variant"), TitlesOfParts, PPTX::Logic::PartTitle); + } } } void CApp::write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const @@ -238,169 +154,10 @@ namespace OOX std::wstring sXml; sXml = _T(""); - if ( m_sApplication.IsInit() ) - { - sXml += _T(""); - sXml += XmlUtils::EncodeXmlString(m_sApplication.get()); - if ( m_sAppVersion.IsInit() ) - { - sXml += L"/"; - sXml += XmlUtils::EncodeXmlString(m_sAppVersion.get()); - } - sXml += _T(""); - } + NSBinPptxRW::CXmlWriter oWriter; + toXmlWriter(&oWriter); - //if ( m_sAppVersion.IsInit() ) - only for ms editors versions - //{ - // sXml += _T(""); - // sXml += m_sAppVersion.get(); // error in ms editors - "2.4.510.0" - // sXml += _T(""); - //} - - if ( m_nCharacters.IsInit() ) - { - sXml += _T(""); - sXml += std::to_wstring(*m_nCharacters); - sXml += _T(""); - } - - if ( m_nCharactersWithSpaces.IsInit() ) - { - sXml += _T(""); - sXml += std::to_wstring(*m_nCharactersWithSpaces); - sXml += _T(""); - } - - if ( m_sCompany.IsInit() ) - { - sXml += _T(""); - sXml += XmlUtils::EncodeXmlString(m_sCompany.get()); - sXml += _T(""); - } - - if ( m_nDocSecurity.IsInit() ) - { - sXml += _T(""); - sXml += std::to_wstring(*m_nDocSecurity); - sXml += _T(""); - } - - if ( m_nHiddenSlides.IsInit() ) - { - sXml += _T(""); - sXml += std::to_wstring(*m_nHiddenSlides); - sXml += _T(""); - } - - if ( m_sHyperlinkBase.IsInit() ) - { - sXml += _T(""); - sXml += XmlUtils::EncodeXmlString(m_sHyperlinkBase.get()); - sXml += _T(""); - } - - if ( m_bHyperlinksChanged.IsInit() ) - { - sXml += _T(""); - sXml += *m_bHyperlinksChanged ? L"true" : L"false"; - sXml += _T(""); - } - - if ( m_nLines.IsInit() ) - { - sXml += _T(""); - sXml += std::to_wstring(*m_nLines); - sXml += _T(""); - } - - if ( m_bLinksUpToDate.IsInit() ) - { - sXml += _T(""); - sXml += *m_bLinksUpToDate ? L"true" : L"false";; - sXml += _T(""); - } - - if ( m_sManager.IsInit() ) - { - sXml += _T(""); - sXml += XmlUtils::EncodeXmlString(m_sManager.get()); - sXml += _T(""); - } - - if ( m_nMMClips.IsInit() ) - { - sXml += _T(""); - sXml += std::to_wstring(*m_nMMClips); - sXml += _T(""); - } - - if ( m_nNotes.IsInit() ) - { - sXml += _T(""); - sXml += std::to_wstring(*m_nNotes); - sXml += _T(""); - } - - if ( m_nPages.IsInit() ) - { - sXml += _T(""); - sXml += std::to_wstring(*m_nPages); - sXml += _T(""); - } - - if ( m_nParagraphs.IsInit() ) - { - sXml += _T(""); - sXml += std::to_wstring(*m_nParagraphs); - sXml += _T(""); - } - - if ( m_bScaleCrop.IsInit() ) - { - sXml += _T(""); - sXml += *m_bScaleCrop ? L"true" : L"false";; - sXml += _T(""); - } - - if ( m_bSharedDoc.IsInit() ) - { - sXml += _T(""); - sXml += *m_bSharedDoc ? L"true" : L"false";; - sXml += _T(""); - } - - if ( m_nSlides.IsInit() ) - { - SimpleTypes::CDecimalNumber oNum; - oNum.SetValue( m_nSlides.get() ); - - sXml += _T(""); - sXml += std::to_wstring(*m_nSlides); - sXml += _T(""); - } - - if ( m_sTemplate.IsInit() ) - { - sXml += _T(""); - } - - if ( m_nTotalTime.IsInit() ) - { - sXml += _T(""); - sXml += std::to_wstring(*m_nTotalTime); - sXml += _T(""); - } - - if ( m_nWords.IsInit() ) - { - sXml += _T(""); - sXml += std::to_wstring(*m_nWords); - sXml += _T(""); - } - - sXml += _T(""); + sXml += oWriter.GetXmlString(); NSFile::CFileBinary::SaveToFile( oPath.GetPath(), sXml ); oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() ); @@ -440,4 +197,191 @@ namespace OOX m_sApplication = sApplication; } + void CApp::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->StartRecord(NSBinPptxRW::NSMainTables::App); + + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + + pWriter->WriteString2(0, m_sTemplate); + pWriter->WriteString2(1, m_sApplication); + pWriter->WriteString2(2, m_sPresentationForm); + pWriter->WriteString2(3, m_sCompany); + pWriter->WriteString2(4, m_sAppVersion); + + pWriter->WriteInt2(5, m_nTotalTime); + pWriter->WriteInt2(6, m_nWords); + pWriter->WriteInt2(7, m_nParagraphs); + pWriter->WriteInt2(8, m_nSlides); + pWriter->WriteInt2(9, m_nNotes); + pWriter->WriteInt2(10, m_nHiddenSlides); + pWriter->WriteInt2(11, m_nMMClips); + + pWriter->WriteBool2(12, m_bScaleCrop); + pWriter->WriteBool2(13, m_bLinksUpToDate); + pWriter->WriteBool2(14, m_bSharedDoc); + pWriter->WriteBool2(15, m_bHyperlinksChanged); + + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + //start new record because new attributes is incompatible with previous versions + pWriter->StartRecord(0); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + + pWriter->WriteInt2(16, m_nCharacters); + pWriter->WriteInt2(17, m_nCharactersWithSpaces); + pWriter->WriteInt2(18, m_nDocSecurity); + pWriter->WriteString2(19, m_sHyperlinkBase); + pWriter->WriteInt2(20, m_nLines); + pWriter->WriteString2(21, m_sManager); + pWriter->WriteInt2(22, m_nPages); + + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + pWriter->EndRecord(); + + pWriter->EndRecord(); + } + void CApp::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + pReader->Skip(1); // type + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: m_sTemplate = pReader->GetString2(); break; + case 1: m_sApplication = pReader->GetString2(); break; + case 2: m_sPresentationForm = pReader->GetString2(); break; + case 3: m_sCompany = pReader->GetString2(); break; + case 4: m_sAppVersion = pReader->GetString2(); break; + case 5: m_nTotalTime = pReader->GetULong(); break; + case 6: m_nWords = pReader->GetULong(); break; + case 7: m_nParagraphs = pReader->GetULong(); break; + case 8: m_nSlides = pReader->GetULong(); break; + case 9: m_nNotes = pReader->GetULong(); break; + case 10: m_nHiddenSlides = pReader->GetULong(); break; + case 11: m_nMMClips = pReader->GetULong(); break; + case 12: m_bScaleCrop = pReader->GetBool(); break; + case 13: m_bLinksUpToDate = pReader->GetBool(); break; + case 14: m_bSharedDoc = pReader->GetBool(); break; + case 15: m_bHyperlinksChanged = pReader->GetBool(); break; + default: break; + } + } + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 16: m_nCharacters = pReader->GetULong(); break; + case 17: m_nCharactersWithSpaces = pReader->GetULong(); break; + case 18: m_nDocSecurity = pReader->GetULong(); break; + case 19: m_sHyperlinkBase = pReader->GetString2(); break; + case 20: m_nLines = pReader->GetULong(); break; + case 21: m_sManager = pReader->GetString2(); break; + case 22: m_nPages = pReader->GetULong(); break; + default: break; + } + } + + pReader->Seek(_end_rec2); + } + break; + default: + { + pReader->SkipRecord(); + break; + } + } + } + + pReader->Seek(_end_rec); + } + void CApp::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("Properties")); + + pWriter->StartAttributes(); + + pWriter->WriteAttribute(_T("xmlns"), PPTX::g_Namespaces.xmlns.m_strLink); + pWriter->WriteAttribute(_T("xmlns:vt"), PPTX::g_Namespaces.vt.m_strLink); + + pWriter->EndAttributes(); + + pWriter->WriteNodeValue2(_T("Template"), m_sTemplate); + pWriter->WriteNodeValue(_T("TotalTime"), m_nTotalTime); + pWriter->WriteNodeValue(_T("Pages"), m_nPages); + pWriter->WriteNodeValue(_T("Words"), m_nWords); + pWriter->WriteNodeValue(_T("Characters"), m_nCharacters); + pWriter->WriteNodeValue(_T("CharactersWithSpaces"), m_nCharactersWithSpaces); + pWriter->WriteNodeValue2(_T("Application"), m_sApplication); + pWriter->WriteNodeValue(_T("DocSecurity"), m_nDocSecurity); + pWriter->WriteNodeValue2(_T("PresentationFormat"), m_sPresentationForm); + pWriter->WriteNodeValue(_T("Lines"), m_nLines); + pWriter->WriteNodeValue(_T("Paragraphs"), m_nParagraphs); + pWriter->WriteNodeValue(_T("Slides"), m_nSlides); + pWriter->WriteNodeValue(_T("Notes"), m_nNotes); + pWriter->WriteNodeValue(_T("HiddenSlides"), m_nHiddenSlides); + pWriter->WriteNodeValue(_T("MMClips"), m_nMMClips); + pWriter->WriteNodeValue(_T("ScaleCrop"), m_bScaleCrop); + + pWriter->StartNode(_T("HeadingPairs")); + pWriter->EndAttributes(); + + pWriter->StartNode(_T("vt:vector")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("size"), (int)HeadingPairs.size()); + pWriter->WriteAttribute(_T("baseType"), (std::wstring)_T("variant")); + pWriter->EndAttributes(); + + pWriter->WriteArray2(HeadingPairs); + + pWriter->EndNode(_T("vt:vector")); + pWriter->EndNode(_T("HeadingPairs")); + + pWriter->StartNode(_T("TitlesOfParts")); + pWriter->EndAttributes(); + + pWriter->StartNode(_T("vt:vector")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("size"), (int)TitlesOfParts.size()); + pWriter->WriteAttribute(_T("baseType"), (std::wstring)_T("lpstr")); + pWriter->EndAttributes(); + + pWriter->WriteArray2(TitlesOfParts); + + pWriter->EndNode(_T("vt:vector")); + pWriter->EndNode(_T("TitlesOfParts")); + + pWriter->WriteNodeValue2(_T("Manager"), m_sManager); + pWriter->WriteNodeValue2(_T("Company"), m_sCompany); + pWriter->WriteNodeValue(_T("LinksUpToDate"), m_bLinksUpToDate); + pWriter->WriteNodeValue(_T("SharedDoc"), m_bSharedDoc); + pWriter->WriteNodeValue2(_T("HyperlinkBase"), m_sHyperlinkBase); + pWriter->WriteNodeValue(_T("HyperlinksChanged"), m_bHyperlinksChanged); + pWriter->WriteNodeValue2(_T("AppVersion"), m_sAppVersion); + + pWriter->EndNode(_T("Properties")); + } } // namespace OOX diff --git a/OOXML/DocxFormat/App.h b/OOXML/DocxFormat/App.h index f844045502..6d36895334 100644 --- a/OOXML/DocxFormat/App.h +++ b/OOXML/DocxFormat/App.h @@ -32,12 +32,12 @@ #pragma once #include "File.h" +#include "WritingElement.h" #include "../Base/Nullable.h" -namespace PPTX -{ - class App; -} +#include "../PPTXFormat/Logic/PartTitle.h" +#include "../PPTXFormat/Logic/HeadingVariant.h" + namespace OOX { class CApp : public OOX::File @@ -58,37 +58,43 @@ namespace OOX void SetDefaults(); void SetRequiredDefaults(); - PPTX::App* ToPptxApp(); - void FromPptxApp(PPTX::App* pApp); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; // TO DO: DigSig - // HeadingPairs // HLinks - // TitlesOfParts - nullable_string m_sApplication; + nullable_string m_sApplication; nullable_string m_sAppVersion; nullable_int m_nCharacters; nullable_int m_nCharactersWithSpaces; - nullable_string m_sCompany; + nullable_string m_sCompany; nullable_int m_nDocSecurity; nullable_int m_nHiddenSlides; - nullable_string m_sHyperlinkBase; + nullable_string m_sHyperlinkBase; nullable_bool m_bHyperlinksChanged; nullable_int m_nLines; nullable_bool m_bLinksUpToDate; - nullable_string m_sManager; + nullable_string m_sManager; nullable_int m_nMMClips; nullable_int m_nNotes; nullable_int m_nPages; nullable_int m_nParagraphs; - nullable_string m_sPresentationForm; + nullable_string m_sPresentationForm; nullable_bool m_bScaleCrop; nullable_bool m_bSharedDoc; nullable_int m_nSlides; - nullable_string m_sTemplate; + nullable_string m_sTemplate; nullable_int m_nTotalTime; nullable_int m_nWords; + + std::vector HeadingPairs; + std::vector TitlesOfParts; + private: + nullable_int m_VectorSize; + nullable_int m_Headings; }; + } // namespace OOX diff --git a/OOXML/DocxFormat/Core.cpp b/OOXML/DocxFormat/Core.cpp index 2b8b76ebbb..24d54078e0 100644 --- a/OOXML/DocxFormat/Core.cpp +++ b/OOXML/DocxFormat/Core.cpp @@ -33,7 +33,6 @@ #include "Core.h" #include "Docx.h" #include "../XlsxFormat/Xlsx.h" -#include "../PPTXFormat/Core.h" #include "../../DesktopEditor/common/SystemUtils.h" @@ -270,73 +269,152 @@ xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"); { m_sLastModifiedBy = sVal; } + void CCore::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->StartRecord(NSBinPptxRW::NSMainTables::Core); - PPTX::Core* CCore::ToPptxCore() - { - PPTX::Core* res = new PPTX::Core(NULL); - if (m_sCategory.IsInit()) - res->category = m_sCategory.get(); - if (m_sContentStatus.IsInit()) - res->contentStatus = m_sContentStatus.get(); - if (m_sCreated.IsInit()) - res->created = m_sCreated.get(); - if (m_sCreator.IsInit()) - res->creator = m_sCreator.get(); - if (m_sDescription.IsInit()) - res->description = m_sDescription.get(); - if (m_sIdentifier.IsInit()) - res->identifier = m_sIdentifier.get(); - if (m_sKeywords.IsInit()) - res->keywords = m_sKeywords.get(); - if (m_sLanguage.IsInit()) - res->language = m_sLanguage.get(); - if (m_sLastModifiedBy.IsInit()) - res->lastModifiedBy = m_sLastModifiedBy.get(); - if (m_sLastPrinted.IsInit()) - res->lastPrinted = m_sLastPrinted.get(); - if (m_sModified.IsInit()) - res->modified = m_sModified.get(); - if (m_sRevision.IsInit()) - res->revision = m_sRevision.get(); - if (m_sSubject.IsInit()) - res->subject = m_sSubject.get(); - if (m_sTitle.IsInit()) - res->title = m_sTitle.get(); - if (m_sVersion.IsInit()) - res->version = m_sVersion.get(); - return res; + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + + pWriter->WriteString2(0, m_sTitle); + pWriter->WriteString2(1, m_sCreator); + pWriter->WriteString2(2, m_sLastModifiedBy); + pWriter->WriteString2(3, m_sRevision); + pWriter->WriteString2(4, m_sCreated); + pWriter->WriteString2(5, m_sModified); + + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + //start new record because new attributes is incompatible with previous versions + pWriter->StartRecord(0); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + + pWriter->WriteString2(6, m_sCategory); + pWriter->WriteString2(7, m_sContentStatus); + pWriter->WriteString2(8, m_sDescription); + pWriter->WriteString2(9, m_sIdentifier); + pWriter->WriteString2(10, m_sKeywords); + pWriter->WriteString2(11, m_sLanguage); + pWriter->WriteString2(12, m_sLastPrinted); + pWriter->WriteString2(13, m_sSubject); + pWriter->WriteString2(14, m_sVersion); + + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + pWriter->EndRecord(); + + pWriter->EndRecord(); } - void CCore::FromPptxCore(PPTX::Core* pCore) + void CCore::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) { - if(pCore->category.IsInit()) - m_sCategory = pCore->category.get(); - if(pCore->contentStatus.IsInit()) - m_sContentStatus = pCore->contentStatus.get(); - if(pCore->created.IsInit()) - m_sCreated = pCore->created.get(); - if(pCore->creator.IsInit()) - m_sCreator = pCore->creator.get(); - if(pCore->description.IsInit()) - m_sDescription = pCore->description.get(); - if(pCore->identifier.IsInit()) - m_sIdentifier = pCore->identifier.get(); - if(pCore->keywords.IsInit()) - m_sKeywords = pCore->keywords.get(); - if(pCore->language.IsInit()) - m_sLanguage = pCore->language.get(); - if(pCore->lastModifiedBy.IsInit()) - m_sLastModifiedBy = pCore->lastModifiedBy.get(); - if(pCore->lastPrinted.IsInit()) - m_sLastPrinted = pCore->lastPrinted.get(); - if(pCore->modified.IsInit()) - m_sModified = pCore->modified.get(); - if(pCore->revision.IsInit()) - m_sRevision = pCore->revision.get(); - if(pCore->subject.IsInit()) - m_sSubject = pCore->subject.get(); - if(pCore->title.IsInit()) - m_sTitle = pCore->title.get(); - if(pCore->version.IsInit()) - m_sVersion = pCore->version.get(); + pReader->Skip(1); // type + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: m_sTitle = pReader->GetString2(); break; + case 1: m_sCreator = pReader->GetString2(); break; + case 2: m_sLastModifiedBy = pReader->GetString2(); break; + case 3: m_sRevision = pReader->GetString2(); break; + case 4: m_sCreated = pReader->GetString2(); break; + case 5: m_sModified = pReader->GetString2(); break; + default: break; + } + } + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 6: m_sCategory = pReader->GetString2(); break; + case 7: m_sContentStatus = pReader->GetString2(); break; + case 8: m_sDescription = pReader->GetString2(); break; + case 9: m_sIdentifier = pReader->GetString2(); break; + case 10: m_sKeywords = pReader->GetString2(); break; + case 11: m_sLanguage = pReader->GetString2(); break; + case 12: m_sLastPrinted = pReader->GetString2(); break; + case 13: m_sSubject = pReader->GetString2(); break; + case 14: m_sVersion = pReader->GetString2(); break; + } + } + + pReader->Seek(_end_rec2); + } + break; + default: + { + pReader->SkipRecord(); + break; + } + } + } + + pReader->Seek(_end_rec); + } + void CCore::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("cp:coreProperties")); + + pWriter->StartAttributes(); + + pWriter->WriteAttribute(_T("xmlns:cp"), PPTX::g_Namespaces.cp.m_strLink); + pWriter->WriteAttribute(_T("xmlns:dc"), PPTX::g_Namespaces.dc.m_strLink); + pWriter->WriteAttribute(_T("xmlns:dcterms"), PPTX::g_Namespaces.dcterms.m_strLink); + pWriter->WriteAttribute(_T("xmlns:dcmitype"), PPTX::g_Namespaces.dcmitype.m_strLink); + pWriter->WriteAttribute(_T("xmlns:xsi"), PPTX::g_Namespaces.xsi.m_strLink); + + pWriter->EndAttributes(); + + pWriter->WriteNodeValue2(_T("dc:title"), m_sTitle); + pWriter->WriteNodeValue2(_T("dc:subject"), m_sSubject); + pWriter->WriteNodeValue2(_T("dc:creator"), m_sCreator); + pWriter->WriteNodeValue2(_T("cp:keywords"), m_sKeywords); + pWriter->WriteNodeValue2(_T("dc:description"), m_sDescription); + pWriter->WriteNodeValue2(_T("dc:identifier"), m_sIdentifier); + pWriter->WriteNodeValue2(_T("dc:language"), m_sLanguage); + pWriter->WriteNodeValue2(_T("cp:lastModifiedBy"), m_sLastModifiedBy); + pWriter->WriteNodeValue2(_T("cp:revision"), m_sRevision); + + if ((m_sLastPrinted.IsInit()) && (false == m_sLastPrinted->empty())) + { + pWriter->WriteNodeValue2(_T("cp:lastPrinted"), m_sLastPrinted); + } + if ((m_sCreated.IsInit()) && (false == m_sCreated->empty())) + { + pWriter->WriteNodeBegin(_T("dcterms:created xsi:type=\"dcterms:W3CDTF\"")); + pWriter->WriteStringXML(*m_sCreated); + pWriter->WriteNodeEnd(_T("dcterms:created")); + } + if ((m_sModified.IsInit()) && (false == m_sModified->empty())) + { + pWriter->WriteNodeBegin(_T("dcterms:modified xsi:type=\"dcterms:W3CDTF\"")); + pWriter->WriteStringXML(*m_sModified); + pWriter->WriteNodeEnd(_T("dcterms:modified")); + } + pWriter->WriteNodeValue2(_T("cp:category"), m_sCategory); + pWriter->WriteNodeValue2(_T("cp:contentStatus"), m_sContentStatus); + pWriter->WriteNodeValue2(_T("cp:version"), m_sVersion); + + pWriter->EndNode(_T("cp:coreProperties")); } } // namespace OOX diff --git a/OOXML/DocxFormat/Core.h b/OOXML/DocxFormat/Core.h index bb1872c86a..44e971c118 100644 --- a/OOXML/DocxFormat/Core.h +++ b/OOXML/DocxFormat/Core.h @@ -60,8 +60,9 @@ namespace OOX void SetCreator(std::wstring sVal); void SetLastModifiedBy(std::wstring sVal); - PPTX::Core* ToPptxCore(); - void FromPptxCore(PPTX::Core* pCore); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; nullable_string m_sCategory; nullable_string m_sContentStatus; diff --git a/OOXML/PPTXFormat/Core.cpp b/OOXML/PPTXFormat/Core.cpp deleted file mode 100644 index 010f767eb3..0000000000 --- a/OOXML/PPTXFormat/Core.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * 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-6 Ernesta Birznieka-Upish - * 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 "Core.h" - -namespace PPTX -{ - Core::Core(OOX::Document* pMain) : WrapperFile(pMain) - { - } - Core::Core(OOX::Document* pMain, const OOX::CPath& filename, FileMap& map) : WrapperFile(pMain) - { - read(filename, map); - } - Core::~Core() - { - } - void Core::read(const OOX::CPath& filename, FileMap& map) - { - XmlUtils::CXmlNode oNode; - oNode.FromXmlFile(filename.m_strFilename); - - XmlMacroReadNodeValueBase(oNode, _T("cp:category"), category); - XmlMacroReadNodeValueBase(oNode, _T("cp:contentStatus"), contentStatus); - XmlMacroReadNodeValueBase(oNode, _T("dcterms:created"), created); - //created = PPTX::DateTime::Parse(document.Root.element("created").text().ToString()); - XmlMacroReadNodeValueBase(oNode, _T("dc:creator"), creator); - XmlMacroReadNodeValueBase(oNode, _T("dc:description"), description); - XmlMacroReadNodeValueBase(oNode, _T("dc:identifier"), identifier); - //todo keywords is complex by spec there is no real example - XmlMacroReadNodeValueBase(oNode, _T("cp:keywords"), keywords); - XmlMacroReadNodeValueBase(oNode, _T("dc:language"), language); - XmlMacroReadNodeValueBase(oNode, _T("cp:lastModifiedBy"), lastModifiedBy); - XmlMacroReadNodeValueBase(oNode, _T("cp:lastPrinted"), lastPrinted); - //lastPrinted = PPTX::DateTime::Parse(document.Root.element("lastPrinted").text().ToString()); - XmlMacroReadNodeValueBase(oNode, _T("dcterms:modified"), modified); - //modified = PPTX::DateTime::Parse(document.Root.element("modified").text().ToString()); - XmlMacroReadNodeValueBase(oNode, _T("cp:revision"), revision); - XmlMacroReadNodeValueBase(oNode, _T("dc:subject"), subject); - XmlMacroReadNodeValueBase(oNode, _T("dc:title"), title); - XmlMacroReadNodeValueBase(oNode, _T("cp:version"), version); - } - void Core::write(const OOX::CPath& filename, const OOX::CPath& directory, OOX::CContentTypes& content)const - { - WrapperFile::write(filename, directory, content); - } - const OOX::FileType Core::type() const - { - return OOX::FileTypes::Core; - } - const OOX::CPath Core::DefaultDirectory() const - { - return type().DefaultDirectory(); - } - const OOX::CPath Core::DefaultFileName() const - { - return type().DefaultFileName(); - } - void Core::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->StartRecord(NSBinPptxRW::NSMainTables::Core); - - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - - pWriter->WriteString2(0, title); - pWriter->WriteString2(1, creator); - pWriter->WriteString2(2, lastModifiedBy); - pWriter->WriteString2(3, revision); - pWriter->WriteString2(4, created); - pWriter->WriteString2(5, modified); - - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - //start new record because new attributes is incompatible with previous versions - pWriter->StartRecord(0); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - - pWriter->WriteString2(6, category); - pWriter->WriteString2(7, contentStatus); - pWriter->WriteString2(8, description); - pWriter->WriteString2(9, identifier); - pWriter->WriteString2(10, keywords); - pWriter->WriteString2(11, language); - pWriter->WriteString2(12, lastPrinted); - pWriter->WriteString2(13, subject); - pWriter->WriteString2(14, version); - - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - pWriter->EndRecord(); - - pWriter->EndRecord(); - } - void Core::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - pReader->Skip(1); // type - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: title = pReader->GetString2(); break; - case 1: creator = pReader->GetString2(); break; - case 2: lastModifiedBy = pReader->GetString2(); break; - case 3: revision = pReader->GetString2(); break; - case 4: created = pReader->GetString2(); break; - case 5: modified = pReader->GetString2(); break; - default: break; - } - } - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 6: category = pReader->GetString2(); break; - case 7: contentStatus = pReader->GetString2(); break; - case 8: description = pReader->GetString2(); break; - case 9: identifier = pReader->GetString2(); break; - case 10: keywords = pReader->GetString2(); break; - case 11: language = pReader->GetString2(); break; - case 12: lastPrinted = pReader->GetString2(); break; - case 13: subject = pReader->GetString2(); break; - case 14: version = pReader->GetString2(); break; - } - } - - pReader->Seek(_end_rec2); - } - break; - default: - { - pReader->SkipRecord(); - break; - } - } - } - - pReader->Seek(_end_rec); - } - void Core::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("cp:coreProperties")); - - pWriter->StartAttributes(); - - pWriter->WriteAttribute(_T("xmlns:cp"), PPTX::g_Namespaces.cp.m_strLink); - pWriter->WriteAttribute(_T("xmlns:dc"), PPTX::g_Namespaces.dc.m_strLink); - pWriter->WriteAttribute(_T("xmlns:dcterms"), PPTX::g_Namespaces.dcterms.m_strLink); - pWriter->WriteAttribute(_T("xmlns:dcmitype"), PPTX::g_Namespaces.dcmitype.m_strLink); - pWriter->WriteAttribute(_T("xmlns:xsi"), PPTX::g_Namespaces.xsi.m_strLink); - - pWriter->EndAttributes(); - - pWriter->WriteNodeValue2(_T("dc:title"), title); - pWriter->WriteNodeValue2(_T("dc:subject"), subject); - pWriter->WriteNodeValue2(_T("dc:creator"), creator); - pWriter->WriteNodeValue2(_T("cp:keywords"), keywords); - pWriter->WriteNodeValue2(_T("dc:description"), description); - pWriter->WriteNodeValue2(_T("dc:identifier"), identifier); - pWriter->WriteNodeValue2(_T("dc:language"), language); - pWriter->WriteNodeValue2(_T("cp:lastModifiedBy"), lastModifiedBy); - pWriter->WriteNodeValue2(_T("cp:revision"), revision); - - if ((lastPrinted.IsInit()) && (false == lastPrinted->empty())) - { - pWriter->WriteNodeValue2(_T("cp:lastPrinted"), lastPrinted); - } - if ((created.IsInit()) && (false == created->empty())) - { - pWriter->WriteNodeBegin(_T("dcterms:created xsi:type=\"dcterms:W3CDTF\"")); - pWriter->WriteStringXML(*created); - pWriter->WriteNodeEnd(_T("dcterms:created")); - } - if ((modified.IsInit()) && (false == modified->empty())) - { - pWriter->WriteNodeBegin(_T("dcterms:modified xsi:type=\"dcterms:W3CDTF\"")); - pWriter->WriteStringXML(*modified); - pWriter->WriteNodeEnd(_T("dcterms:modified")); - } - pWriter->WriteNodeValue2(_T("cp:category"), category); - pWriter->WriteNodeValue2(_T("cp:contentStatus"), contentStatus); - pWriter->WriteNodeValue2(_T("cp:version"), version); - - pWriter->EndNode(_T("cp:coreProperties")); - } -} // namespace PPTX diff --git a/OOXML/PPTXFormat/Core.h b/OOXML/PPTXFormat/Core.h deleted file mode 100644 index 709993b5ae..0000000000 --- a/OOXML/PPTXFormat/Core.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2023 - * - * 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-6 Ernesta Birznieka-Upish - * 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 "WrapperFile.h" -#include "../DocxFormat/WritingElement.h" - -#include "Limit/ContentStatus.h" -#include "FileTypes.h" - -namespace PPTX -{ - class Core : public WrapperFile - { - public: - Core(OOX::Document* pMain); - Core(OOX::Document* pMain, const OOX::CPath& filename, FileMap& map); - virtual ~Core(); - - public: - virtual void read(const OOX::CPath& filename, FileMap& map); - virtual void write(const OOX::CPath& filename, const OOX::CPath& directory, OOX::CContentTypes& content) const; - - public: - virtual const OOX::FileType type() const; - - virtual const OOX::CPath DefaultDirectory() const; - virtual const OOX::CPath DefaultFileName() const; - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - - public: - nullable_string category; - nullable_string contentStatus; - //nullable_property contentStatus; - nullable_string created; - //nullable_property created; - nullable_string creator; - nullable_string description; - nullable_string identifier; - nullable_string keywords; - nullable_string language; - nullable_string lastModifiedBy; - nullable_string lastPrinted; - nullable_string modified; - //nullable_property modified; - nullable_string revision; - nullable_string subject; - nullable_string title; - nullable_string version; - }; -} // namespace PPTX diff --git a/OOXML/PPTXFormat/FileFactory.cpp b/OOXML/PPTXFormat/FileFactory.cpp index ae8c756d92..7795fec0e4 100644 --- a/OOXML/PPTXFormat/FileFactory.cpp +++ b/OOXML/PPTXFormat/FileFactory.cpp @@ -34,8 +34,6 @@ #include "FileMap.h" #include "FileTypes.h" -#include "App.h" -#include "Core.h" #include "Theme.h" #include "HandoutMaster.h" #include "Presentation.h" @@ -72,7 +70,8 @@ #include "../DocxFormat/External/HyperLink.h" #include "../DocxFormat/UnknowTypeFile.h" #include "../DocxFormat/CustomXml.h" - +#include "../DocxFormat/App.h" +#include "../DocxFormat/Core.h" namespace PPTX { @@ -84,9 +83,9 @@ namespace PPTX } if (relation.Type() == OOX::FileTypes::App) - return smart_ptr(new PPTX::App(pMain, filename, map)); + return smart_ptr(new OOX::CApp(pMain, filename)); else if (relation.Type() == OOX::FileTypes::Core) - return smart_ptr(new PPTX::Core(pMain, filename, map)); + return smart_ptr(new OOX::CCore(pMain, filename)); else if (relation.Type() == OOX::FileTypes::CustomProperties) return smart_ptr(new PPTX::CustomProperties(pMain, filename, map)); else if (relation.Type() == OOX::Presentation::FileTypes::Presentation || diff --git a/OOXML/PPTXFormat/Logic/HeadingVariant.h b/OOXML/PPTXFormat/Logic/HeadingVariant.h index 398c06ea8b..e8a9b144f6 100644 --- a/OOXML/PPTXFormat/Logic/HeadingVariant.h +++ b/OOXML/PPTXFormat/Logic/HeadingVariant.h @@ -52,12 +52,10 @@ namespace PPTX public: PPTX_LOGIC_BASE(HeadingVariant) - public: virtual void fromXML(XmlUtils::CXmlNode& node); virtual std::wstring toXML() const; virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - public: nullable_limit m_type; nullable_string m_strContent; nullable_int m_iContent; @@ -71,14 +69,12 @@ namespace PPTX public: PPTX_LOGIC_BASE(CVariantVStream) - public: virtual void fromXML(XmlUtils::CXmlNode& node); virtual std::wstring toXML() const; virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; - public: nullable_string m_strVersion; nullable_string m_strContent; protected: @@ -90,7 +86,6 @@ namespace PPTX public: PPTX_LOGIC_BASE(CVariant) - public: virtual void fromXML(XmlUtils::CXmlNode& node); virtual std::wstring toXML() const; virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; @@ -100,7 +95,7 @@ namespace PPTX eVariantType getVariantType() const; static eVariantType getTypeByString(const std::wstring& sName); static std::wstring getStringByType(const eVariantType& eType); - public: + nullable m_eType; nullable_string m_strContent; nullable_int m_iContent; @@ -120,14 +115,13 @@ namespace PPTX public: PPTX_LOGIC_BASE(CVariantVector) - public: virtual void fromXML(XmlUtils::CXmlNode& node); virtual std::wstring toXML() const; virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; eVariantType getVariantType() const; - public: + nullable m_eBaseType; nullable_int m_nSize; @@ -141,14 +135,13 @@ namespace PPTX public: PPTX_LOGIC_BASE(CVariantArray) - public: virtual void fromXML(XmlUtils::CXmlNode& node); virtual std::wstring toXML() const; virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; eVariantType getVariantType() const; - public: + nullable m_eBaseType; nullable_string m_strLBounds; nullable_string m_strUBounds; @@ -163,20 +156,18 @@ namespace PPTX public: PPTX_LOGIC_BASE(CustomProperty) - public: virtual void fromXML(XmlUtils::CXmlNode& node); virtual std::wstring toXML() const; virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; - public: - nullable_string m_strFmtid; - nullable_string m_strLinkTarget; - nullable_string m_strName; - nullable_int m_nPid; + nullable_string m_strFmtid; + nullable_string m_strLinkTarget; + nullable_string m_strName; + nullable_int m_nPid; - nullable m_oContent; + nullable m_oContent; protected: virtual void FillParentPointersForChilds(){}; }; diff --git a/OOXML/PPTXFormat/Logic/pri/pptx_format_logic.cpp b/OOXML/PPTXFormat/Logic/pri/pptx_format_logic.cpp index bf450c4de1..3fa8863b7b 100644 --- a/OOXML/PPTXFormat/Logic/pri/pptx_format_logic.cpp +++ b/OOXML/PPTXFormat/Logic/pri/pptx_format_logic.cpp @@ -290,8 +290,6 @@ #include "../../../PPTXFormat/Namespaces.cpp" #include "../../../PPTXFormat/LegacyDiagramText.cpp" #include "../../../PPTXFormat/HandoutMaster.cpp" -#include "../../../PPTXFormat/Core.cpp" -#include "../../../PPTXFormat/App.cpp" #include "../../../PPTXFormat/WrapperWritingElement.cpp" #include "../../../PPTXFormat/Comments.cpp" #include "../../../PPTXFormat/CommentAuthors.cpp" diff --git a/OOXML/PPTXFormat/Logic/pri/pptx_logic.pri b/OOXML/PPTXFormat/Logic/pri/pptx_logic.pri index 1576587720..8ccbee8afc 100644 --- a/OOXML/PPTXFormat/Logic/pri/pptx_logic.pri +++ b/OOXML/PPTXFormat/Logic/pri/pptx_logic.pri @@ -268,8 +268,6 @@ SOURCES += \ ../../../PPTXFormat/Namespaces.cpp \ ../../../PPTXFormat/LegacyDiagramText.cpp \ ../../../PPTXFormat/HandoutMaster.cpp \ - ../../../PPTXFormat/Core.cpp \ - ../../../PPTXFormat/App.cpp \ ../../../PPTXFormat/WrapperWritingElement.cpp \ ../../../PPTXFormat/Comments.cpp \ ../../../PPTXFormat/CommentAuthors.cpp @@ -515,11 +513,9 @@ HEADERS += \ $$LOGIC_DIR/Xfrm.h \ $$LOGIC_DIR/XmlId.h \ \ - ../../../PPTXFormat/App.h \ ../../../PPTXFormat/CommentAuthors.h \ ../../../PPTXFormat/Comments.h \ ../../../PPTXFormat/LegacyDiagramText.h \ - ../../../PPTXFormat/Core.h \ ../../../PPTXFormat/FileContainer.h \ ../../../PPTXFormat/FileFactory.h \ ../../../PPTXFormat/FileMap.h \ diff --git a/OOXML/PPTXFormat/PPTX.h b/OOXML/PPTXFormat/PPTX.h index 8516967c34..bf2952e8e0 100644 --- a/OOXML/PPTXFormat/PPTX.h +++ b/OOXML/PPTXFormat/PPTX.h @@ -37,8 +37,6 @@ #include "SlideLayout.h" #include "SlideMaster.h" #include "NotesMaster.h" -#include "App.h" -#include "Core.h" #include "ViewProps.h" #include "PresProps.h" #include "TableStyles.h" @@ -69,3 +67,5 @@ #include "Logic/XmlId.h" #include "../DocxFormat/CustomXml.h" +#include "../DocxFormat/App.h" +#include "../DocxFormat/Core.h" \ No newline at end of file diff --git a/OOXML/Projects/Windows/PPTXFormatLib/PPTXFormat.vcxproj b/OOXML/Projects/Windows/PPTXFormatLib/PPTXFormat.vcxproj index f6ce77d168..f3c84171d6 100644 --- a/OOXML/Projects/Windows/PPTXFormatLib/PPTXFormat.vcxproj +++ b/OOXML/Projects/Windows/PPTXFormatLib/PPTXFormat.vcxproj @@ -289,10 +289,8 @@ - - @@ -922,10 +920,8 @@ - - diff --git a/OOXML/Projects/Windows/PPTXFormatLib/PPTXFormat.vcxproj.filters b/OOXML/Projects/Windows/PPTXFormatLib/PPTXFormat.vcxproj.filters index 9388d090ed..e68dab9209 100644 --- a/OOXML/Projects/Windows/PPTXFormatLib/PPTXFormat.vcxproj.filters +++ b/OOXML/Projects/Windows/PPTXFormatLib/PPTXFormat.vcxproj.filters @@ -1,10 +1,8 @@  - - @@ -1932,10 +1930,8 @@ Logic\Transition - - diff --git a/OdfFile/Reader/Format/office_meta.cpp b/OdfFile/Reader/Format/office_meta.cpp index 5252d8c638..47b3ec5230 100644 --- a/OdfFile/Reader/Format/office_meta.cpp +++ b/OdfFile/Reader/Format/office_meta.cpp @@ -174,6 +174,7 @@ const wchar_t * meta_user_defined::name = L"user-defined"; void meta_user_defined::add_attributes( const xml::attributes_wc_ptr & Attributes ) { CP_APPLY_ATTR(L"meta:name", meta_name_, std::wstring(L"")); + CP_APPLY_ATTR(L"meta:value-type", meta_value_type_); } void meta_user_defined::add_text(const std::wstring & text) diff --git a/OdfFile/Reader/Format/office_meta.h b/OdfFile/Reader/Format/office_meta.h index 5bb06292d9..2293ee0aa2 100644 --- a/OdfFile/Reader/Format/office_meta.h +++ b/OdfFile/Reader/Format/office_meta.h @@ -246,6 +246,7 @@ public: std::wstring meta_name_; std::wstring content_; + _CP_OPT(odf_types::office_value_type) meta_value_type_; private: virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); diff --git a/OdfFile/Writer/Converter/Converter.cpp b/OdfFile/Writer/Converter/Converter.cpp index 0c78a1219e..632a775a2f 100644 --- a/OdfFile/Writer/Converter/Converter.cpp +++ b/OdfFile/Writer/Converter/Converter.cpp @@ -70,6 +70,7 @@ #include "../../../OOXML/PPTXFormat/Logic/Effects/AlphaModFix.h" #include "../../../OOXML/PPTXFormat/Logic/Effects/Grayscl.h" #include "../../../OOXML/PPTXFormat/Logic/Effects/Duotone.h" +#include "../../../OOXML/PPTXFormat/Logic/HeadingVariant.h" #include "../../../OOXML/XlsxFormat/Worksheets/Sparkline.h" #include "../../../OfficeCryptReader/source/CryptTransform.h" @@ -360,6 +361,66 @@ void OoxConverter::convert_meta(OOX::CApp *app, OOX::CCore *core) odf_context()->add_meta(L"dc", L"language", *core->m_sLanguage); } } +void OoxConverter::convert_customs(OOX::IFileContainer* container) +{ + if (!container) return; + smart_ptr customProperties = container->Find(OOX::FileTypes::CustomProperties).smart_dynamic_cast(); + + if (false == customProperties.IsInit()) return; + + for (auto prop : customProperties->m_arProperties) + { + if (prop.m_strName.IsInit()) + { + std::wstring content; + if (prop.m_oContent.IsInit()) + { + switch (prop.m_oContent->getVariantType()) + { + case PPTX::Logic::vtLpstr: + case PPTX::Logic::vtLpwstr: + case PPTX::Logic::vtBstr: + { + if (prop.m_oContent->m_strContent.IsInit()) + content = *prop.m_oContent->m_strContent; + }break; + case PPTX::Logic::vtI1: + case PPTX::Logic::vtI2: + case PPTX::Logic::vtI4: + case PPTX::Logic::vtI8: + case PPTX::Logic::vtDecimal: + case PPTX::Logic::vtInt: + { + if (prop.m_oContent->m_iContent.IsInit()) + content = std::to_wstring(*prop.m_oContent->m_uContent); + }break; + case PPTX::Logic::vtUi1: + case PPTX::Logic::vtUi2: + case PPTX::Logic::vtUi4: + case PPTX::Logic::vtUi8: + { + if (prop.m_oContent->m_uContent.IsInit()) + content = std::to_wstring(*prop.m_oContent->m_uContent); + }break; + case PPTX::Logic::vtR4: + { + if (prop.m_oContent->m_dContent.IsInit()) + content = std::to_wstring(*prop.m_oContent->m_dContent); + }break; + case PPTX::Logic::vtBool: + { + if (prop.m_oContent->m_bContent.IsInit()) + content = std::to_wstring(*prop.m_oContent->m_bContent); + }break; + } + } + odf_context()->add_meta_user_define(*prop.m_strName, content); + + } + //nullable_string m_strFmtid; + //nullable_string m_strLinkTarget; + } +} void OoxConverter::convert(OOX::WritingElement *oox_unknown) { try diff --git a/OdfFile/Writer/Converter/Converter.h b/OdfFile/Writer/Converter/Converter.h index 1f127c87a2..72b6617e26 100644 --- a/OdfFile/Writer/Converter/Converter.h +++ b/OdfFile/Writer/Converter/Converter.h @@ -498,6 +498,7 @@ public: OOX::IFileContainer *oox_current_child_document; + void convert_customs(OOX::IFileContainer* container); void convert_meta(OOX::CApp *app, OOX::CCore *core); void convert (OOX::JsaProject *jsaProject); void convert (double oox_font_size, _CP_OPT(cpdoccore::odf_types::font_size) & odf_font_size); diff --git a/OdfFile/Writer/Converter/DocxConverter.cpp b/OdfFile/Writer/Converter/DocxConverter.cpp index 577df40dd1..643cbd2f32 100644 --- a/OdfFile/Writer/Converter/DocxConverter.cpp +++ b/OdfFile/Writer/Converter/DocxConverter.cpp @@ -222,6 +222,7 @@ bool DocxConverter::convertDocument() convert_settings(); convert_meta(app, core); + convert_customs(docx_document); convert_document(); diff --git a/OdfFile/Writer/Converter/PptxConverter.cpp b/OdfFile/Writer/Converter/PptxConverter.cpp index 343efc3814..a1a1e76585 100644 --- a/OdfFile/Writer/Converter/PptxConverter.cpp +++ b/OdfFile/Writer/Converter/PptxConverter.cpp @@ -40,8 +40,6 @@ #include "../../../OOXML/PPTXFormat/NotesMaster.h" #include "../../../OOXML/PPTXFormat/NotesSlide.h" #include "../../../OOXML/PPTXFormat/TableStyles.h" -#include "../../../OOXML/PPTXFormat/App.h" -#include "../../../OOXML/PPTXFormat/Core.h" #include "../../../OOXML/PPTXFormat/Logic/Table/Table.h" #include "../../../OOXML/PPTXFormat/Logic/Timing/Par.h" @@ -78,6 +76,8 @@ #include "../../../OOXML/PPTXFormat/Presentation/SldSz.h" #include "../../../OOXML/PPTXFormat/Presentation/NotesSz.h" +#include "../../../OOXML/DocxFormat/Core.h" +#include "../../../OOXML/DocxFormat/App.h" #include "../Format/odp_conversion_context.h" @@ -212,10 +212,11 @@ bool PptxConverter::convertDocument() convert_styles(); convert_settings(); - smart_ptr app_ptr = pptx_document->Get(OOX::FileTypes::App).smart_dynamic_cast(); - smart_ptr core_ptr = pptx_document->Get(OOX::FileTypes::Core).smart_dynamic_cast(); + smart_ptr app_ptr = pptx_document->Get(OOX::FileTypes::App).smart_dynamic_cast(); + smart_ptr core_ptr = pptx_document->Get(OOX::FileTypes::Core).smart_dynamic_cast(); - //convert_meta(app_ptr.GetPointer(), core_ptr.GetPointer()); -> привести к OOX::... + convert_meta(app_ptr.GetPointer(), core_ptr.GetPointer()); + convert_customs(pptx_document); convert_masters_and_layouts(); convert_slides(); diff --git a/OdfFile/Writer/Converter/XlsxConverter.cpp b/OdfFile/Writer/Converter/XlsxConverter.cpp index 053cadb4b5..7c73ed9aed 100644 --- a/OdfFile/Writer/Converter/XlsxConverter.cpp +++ b/OdfFile/Writer/Converter/XlsxConverter.cpp @@ -170,6 +170,7 @@ bool XlsxConverter::convertDocument() ods_context->start_document(); convert_meta(xlsx_document->m_pApp, xlsx_document->m_pCore); + convert_customs(xlsx_document); convert_styles(); convert_sheets(); diff --git a/OdfFile/Writer/Format/odf_conversion_context.cpp b/OdfFile/Writer/Format/odf_conversion_context.cpp index 6b3ede1376..e0204e020f 100644 --- a/OdfFile/Writer/Format/odf_conversion_context.cpp +++ b/OdfFile/Writer/Format/odf_conversion_context.cpp @@ -35,6 +35,7 @@ #include "office_spreadsheet.h" #include "office_scripts.h" #include "office_chart.h" +#include "office_meta.h" #include "office_elements_create.h" @@ -525,6 +526,21 @@ void odf_conversion_context::add_meta(const office_element_ptr& elm) if (!elm) return; objects_[current_object_]->meta.push_back(elm); } +void odf_conversion_context::add_meta_user_define(const std::wstring& name, const std::wstring& content) +{ + office_element_ptr elm; + create_element(L"meta", L"user-defined", elm, this, true); + + meta_user_defined* meta_user = dynamic_cast(elm.get()); + if (meta_user) + { + meta_user->meta_name_ = name; + meta_user->content_ = content; + meta_user->meta_value_type_ = odf_types::office_value_type::String; + + add_meta(elm); + } +} void odf_conversion_context::add_meta(const std::wstring & ns, const std::wstring & name, const std::wstring & content) { if (name.empty()) return; diff --git a/OdfFile/Writer/Format/odf_conversion_context.h b/OdfFile/Writer/Format/odf_conversion_context.h index 542c278920..a067b4190c 100644 --- a/OdfFile/Writer/Format/odf_conversion_context.h +++ b/OdfFile/Writer/Format/odf_conversion_context.h @@ -128,6 +128,7 @@ public: void add_meta(const std::wstring & ns, const std::wstring & name, const std::wstring & content); void add_meta(const office_element_ptr &elm); + void add_meta_user_define(const std::wstring& name, const std::wstring& content); virtual odf_style_context_ptr styles_context(); virtual void set_styles_context(odf_style_context_ptr styles_context); diff --git a/OdfFile/Writer/Format/odt_conversion_context.cpp b/OdfFile/Writer/Format/odt_conversion_context.cpp index 134761cf27..4eccc6afc6 100644 --- a/OdfFile/Writer/Format/odt_conversion_context.cpp +++ b/OdfFile/Writer/Format/odt_conversion_context.cpp @@ -139,15 +139,7 @@ void odt_conversion_context::end_document() office_element_ptr elm; for (std::map::iterator it = mapUserDefineds.begin(); it != mapUserDefineds.end(); ++it) { - create_element(L"meta", L"user-defined", elm, this, true); - - meta_user_defined * meta_user = dynamic_cast(elm.get()); - if (meta_user) - { - meta_user->meta_name_ = it->first; - meta_user->add_text(it->second); - add_meta(elm); - } + add_meta_user_define(it->first, it->second); } } if (controls_context()->is_exist_content()) diff --git a/OdfFile/Writer/Format/office_meta.cpp b/OdfFile/Writer/Format/office_meta.cpp index cac13508ed..4574c33cbe 100644 --- a/OdfFile/Writer/Format/office_meta.cpp +++ b/OdfFile/Writer/Format/office_meta.cpp @@ -229,14 +229,12 @@ void meta_user_defined::serialize(std::wostream & _Wostream) CP_XML_NODE_SIMPLE() { CP_XML_ATTR(L"meta:name", meta_name_); + CP_XML_ATTR(L"meta:value-type", meta_value_type_); CP_XML_STREAM() << XmlUtils::EncodeXmlString(content_); } } } -void meta_user_defined::add_text(const std::wstring & text) -{ - content_ = text; -} + } } diff --git a/OdfFile/Writer/Format/office_meta.h b/OdfFile/Writer/Format/office_meta.h index 58f8d8c186..e61351269b 100644 --- a/OdfFile/Writer/Format/office_meta.h +++ b/OdfFile/Writer/Format/office_meta.h @@ -40,6 +40,9 @@ #include "office_elements.h" #include "office_elements_create.h" +#include "../../DataTypes/common_attlists.h" +#include "../../DataTypes/officevaluetype.h" + namespace cpdoccore { namespace odf_writer { @@ -267,7 +270,8 @@ public: _CP_OPT(int) syllable_count_; virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name) {} - virtual void add_child_element(const office_element_ptr & child_element) {} virtual void serialize(std::wostream & _Wostream); + virtual void add_child_element(const office_element_ptr & child_element) {} + virtual void serialize(std::wostream & _Wostream); }; CP_REGISTER_OFFICE_ELEMENT2(meta_document_statistic); @@ -281,10 +285,11 @@ public: static const ElementType type = typeOfficeMetaUserDefined; std::wstring meta_name_; - std::wstring content_; + std::wstring content_; + _CP_OPT(odf_types::office_value_type) meta_value_type_; virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name) {} - virtual void add_child_element(const office_element_ptr & child_element) {} virtual void add_text(const std::wstring & Text); + virtual void add_child_element(const office_element_ptr & child_element) {} virtual void serialize(std::wostream & _Wostream); }; CP_REGISTER_OFFICE_ELEMENT2(meta_user_defined);