handout binary

This commit is contained in:
Elena Subbotina
2026-02-02 22:36:39 +03:00
parent d286b8459b
commit 64c7b7a3fd
13 changed files with 445 additions and 103 deletions

View File

@ -43,6 +43,7 @@
#include "Slide.h"
#include "NotesMaster.h"
#include "NotesSlide.h"
#include "HandoutMaster.h"
#include <map>
@ -152,6 +153,18 @@ namespace PPTX
}
}
for (std::map<std::wstring, smart_ptr<OOX::File>>::const_iterator pPair = map.m_map.begin(); pPair != map.m_map.end(); ++pPair)
{
const OOX::FileType& curType = pPair->second->type();
if (OOX::Presentation::FileTypes::HandoutMaster == curType)
{
smart_ptr<PPTX::HandoutMaster> pointer = pPair->second.smart_dynamic_cast<PPTX::HandoutMaster>();
if (pointer.is_init())
pointer->ApplyRels();
}
}
for (std::map<std::wstring, smart_ptr<OOX::File>>::const_iterator pPair = map.m_map.begin(); pPair != map.m_map.end(); ++pPair)
{
const OOX::FileType& curType = pPair->second->type();

View File

@ -51,17 +51,90 @@ namespace PPTX
XmlUtils::CXmlNode oNode;
oNode.FromXmlFile(filename.m_strFilename);
cSld = oNode.ReadNode(_T("p:cSld"));
cSld = oNode.ReadNode(L"p:cSld");
cSld.SetParentFilePointer(this);
clrMap = oNode.ReadNode(_T("p:clrMap"));
clrMap = oNode.ReadNode(L"p:clrMap");
clrMap.SetParentFilePointer(this);
hf = oNode.ReadNode(_T("p:hf"));
hf = oNode.ReadNode(L"p:hf");
if (hf.is_init())
hf->SetParentFilePointer(this);
}
void HandoutMaster::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->StartRecord(NSBinPptxRW::NSMainTables::HandoutMasters);
pWriter->WriteRecord1(0, cSld);
pWriter->WriteRecord1(1, clrMap);
pWriter->WriteRecord2(2, hf);
pWriter->EndRecord();
}
void HandoutMaster::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
pWriter->StartNode(L"p:handoutMaster");
pWriter->StartAttributes();
pWriter->WriteAttribute(L"xmlns:a", PPTX::g_Namespaces.a.m_strLink);
pWriter->WriteAttribute(L"xmlns:r", PPTX::g_Namespaces.r.m_strLink);
pWriter->WriteAttribute(L"xmlns:p", PPTX::g_Namespaces.p.m_strLink);
pWriter->EndAttributes();
cSld.toXmlWriter(pWriter);
clrMap.toXmlWriter(pWriter);
pWriter->Write(hf);
pWriter->EndNode(L"p:handoutMaster");
}
void HandoutMaster::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
pReader->Skip(1); // type
LONG end = pReader->GetPos() + pReader->GetRecordSize() + 4;
while (pReader->GetPos() < end)
{
BYTE _rec = pReader->GetUChar();
switch (_rec)
{
case 0:
{
cSld.fromPPTY(pReader);
break;
}
case 1:
{
clrMap.fromPPTY(pReader);
break;
}
case 2:
{
hf = new Logic::HF();
hf->fromPPTY(pReader);
break;
}
default:
{
pReader->SkipRecord();
break;
}
}
}
pReader->Seek(end);
}
void HandoutMaster::ApplyRels()
{
theme_ = (FileContainer::Get(OOX::FileTypes::Theme)).smart_dynamic_cast<PPTX::Theme>();
if (theme_.IsInit())
{
theme_->SetColorMap(clrMap);
}
}
void HandoutMaster::write(const OOX::CPath& filename, const OOX::CPath& directory, OOX::CContentTypes& content)const
{
WrapperFile::write(filename, directory, content);

View File

@ -52,19 +52,24 @@ namespace PPTX
HandoutMaster(OOX::Document* pMain, const OOX::CPath& filename, FileMap& map);
virtual ~HandoutMaster();
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;
public:
Logic::CSld cSld;
Logic::ClrMap clrMap;
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
void ApplyRels();
Logic::CSld cSld;
Logic::ClrMap clrMap;
nullable<Logic::HF> hf;
smart_ptr<Theme> theme_;
};
} // namespace PPTX

View File

@ -56,17 +56,17 @@ namespace PPTX
XmlUtils::CXmlNode oNode;
oNode.FromXmlFile(filename.m_strFilename);
cSld = oNode.ReadNode(_T("p:cSld"));
cSld = oNode.ReadNode(L"p:cSld");
cSld.SetParentFilePointer(this);
clrMap = oNode.ReadNode(_T("p:clrMap"));
clrMap = oNode.ReadNode(L"p:clrMap");
clrMap.SetParentFilePointer(this);
hf = oNode.ReadNode(_T("p:hf"));
hf = oNode.ReadNode(L"p:hf");
if (hf.IsInit())
hf->SetParentFilePointer(this);
notesStyle = oNode.ReadNode(_T("p:notesStyle"));
notesStyle = oNode.ReadNode(L"p:notesStyle");
if (notesStyle.is_init())
notesStyle->SetParentFilePointer(this);
}
@ -111,12 +111,12 @@ namespace PPTX
}
void NotesMaster::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
pWriter->StartNode(_T("p:notesMaster"));
pWriter->StartNode(L"p:notesMaster");
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(L"xmlns:a", PPTX::g_Namespaces.a.m_strLink);
pWriter->WriteAttribute(L"xmlns:r", PPTX::g_Namespaces.r.m_strLink);
pWriter->WriteAttribute(L"xmlns:p", PPTX::g_Namespaces.p.m_strLink);
pWriter->EndAttributes();
cSld.toXmlWriter(pWriter);
@ -125,7 +125,7 @@ namespace PPTX
pWriter->Write(hf);
pWriter->Write(notesStyle);
pWriter->EndNode(_T("p:notesMaster"));
pWriter->EndNode(L"p:notesMaster");
}
void NotesMaster::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
@ -198,8 +198,8 @@ namespace PPTX
{
if (pMasterShape->nvSpPr.nvPr.ph.is_init())
{
std::wstring lIdx = pMasterShape->nvSpPr.nvPr.ph->idx.get_value_or(_T(""));
std::wstring lType = pMasterShape->nvSpPr.nvPr.ph->type.get_value_or(_T("body"));
std::wstring lIdx = pMasterShape->nvSpPr.nvPr.ph->idx.get_value_or(L"");
std::wstring lType = pMasterShape->nvSpPr.nvPr.ph->type.get_value_or(L"body");
if (lType == L"ctrTitle") lType = L"title";

View File

@ -30,8 +30,6 @@
*
*/
#pragma once
#ifndef PPTX_SLIDES_NOTESSLIDE_INCLUDE_H_
#define PPTX_SLIDES_NOTESSLIDE_INCLUDE_H_
#include "WrapperFile.h"
#include "FileContainer.h"
@ -79,5 +77,3 @@ namespace PPTX
smart_ptr<Theme> theme_;
};
} // namespace PPTX
#endif // PPTX_SLIDES_NOTESSLIDE_INCLUDE_H_