From 6d27231e151e4e38de8d23d42bb2dee492af86de Mon Sep 17 00:00:00 2001 From: Viktor Andreev Date: Mon, 15 Sep 2025 21:11:32 +0600 Subject: [PATCH] add OfficeArtFOPT writing --- .../Format/Logic/Biff_records/MsoDrawing.cpp | 7 ++++ .../Biff_structures/ODRAW/OfficeArtFOPT.cpp | 18 +++++++++ .../Biff_structures/ODRAW/OfficeArtFOPT.h | 1 + .../Biff_structures/ODRAW/OfficeArtFOPTE.cpp | 8 ++++ .../Biff_structures/ODRAW/OfficeArtFOPTE.h | 1 + .../ODRAW/OfficeArtRGFOPTE.cpp | 38 +++++++++++++++++++ .../Biff_structures/ODRAW/OfficeArtRGFOPTE.h | 1 + .../ODRAW/SimpleOfficeArtContainers.cpp | 3 ++ .../ODRAW/SimpleOfficeArtContainers.h | 1 + 9 files changed, 78 insertions(+) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MsoDrawing.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MsoDrawing.cpp index b9b3bbf942..9f91137b1f 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MsoDrawing.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/MsoDrawing.cpp @@ -36,6 +36,7 @@ #include "../Biff_structures/ODRAW/OfficeArtFSP.h" #include "../Biff_structures/ODRAW/OfficeArtFSPGR.h" #include "../Biff_structures/ODRAW/SimpleOfficeArtContainers.h" +#include "../Biff_structures/ODRAW/OfficeArtFOPT.h" namespace XLS { @@ -170,6 +171,12 @@ void MsoDrawing::prepareComment(const unsigned int CommentId) fsprPtr->spid = CommentId+1; fsprPtr->fHaveAnchor = true; fsprPtr->fHaveSpt = true; + + + { + //todo add mandatory optrions writing + //auto textboxOpt = new ODRAW::OfficeArtFOPT; + } } diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtFOPT.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtFOPT.cpp index 3d6a58658f..22b7b763ad 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtFOPT.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtFOPT.cpp @@ -53,6 +53,24 @@ void OfficeArtFOPT::loadFields(XLS::CFRecord& record) record >> fopt; } +void OfficeArtFOPT::save(XLS::CFRecord& record) +{ + rh_own.recVer = 3; + rh_own.recType = 0xF00B; + rh_own.recInstance = fopt.options_count; + record << rh_own; + + auto sizePos = record.getRdPtr(); + + record << fopt; + //calculating size + rh_own.recLen = record.getRdPtr() - sizePos; + record.RollRdPtrBack(rh_own.recLen + 4); + auto recLen = rh_own.recLen; + record << recLen; + record.skipNunBytes(rh_own.recLen); +} + const unsigned short OfficeArtFOPT::GetInstanceToStore() { diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtFOPT.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtFOPT.h index 1be66c09f9..552e85fc1a 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtFOPT.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtFOPT.h @@ -53,6 +53,7 @@ public: static const XLS::ElementType type = XLS::typeOfficeArtFOPT; virtual void loadFields(XLS::CFRecord& record); + virtual void save(XLS::CFRecord& record); const unsigned short GetInstanceToStore(); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtFOPTE.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtFOPTE.cpp index 64994ee8e1..7b238f332c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtFOPTE.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtFOPTE.cpp @@ -124,6 +124,14 @@ void OfficeArtFOPTE::load(IBinaryReader* _reader) fBid = GETBIT(flags, 14); fComplex = GETBIT(flags, 15); } +void OfficeArtFOPTE::save(XLS::CFRecord& record) +{ + unsigned short flags = 0; + SETBITS(flags, 0, 13, opid) + SETBIT(flags, 14, fBid) + SETBIT(flags, 15, fComplex) + record << flags << op; +} void OfficeArtFOPTE::load(XLS::CFRecord& record) { unsigned short flags; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtFOPTE.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtFOPTE.h index 7f97701ee1..f9cfeda544 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtFOPTE.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtFOPTE.h @@ -63,6 +63,7 @@ protected: virtual void load(XLS::CFRecord& record); void load(IBinaryReader* reader); public: + void save(XLS::CFRecord& record); XLS::BiffStructurePtr clone(); static const XLS::ElementType type = XLS::typeOfficeArtFOPTE; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtRGFOPTE.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtRGFOPTE.cpp index a9c56904f8..c39b6310ef 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtRGFOPTE.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtRGFOPTE.cpp @@ -141,6 +141,44 @@ void OfficeArtRGFOPTE::load(XLS::CFRecord& record) rgfopte.clear(); } + +void OfficeArtRGFOPTE::save(XLS::CFRecord& record) +{ + for(auto i : GroupShape_props) + if(i != nullptr) + i->save(record); + for(auto i : Shape_props) + if(i != nullptr) + i->save(record); + for(auto i : Blip_props) + if(i != nullptr) + i->save(record); + for(auto i : Text_props) + if(i != nullptr) + i->save(record); + for(auto i : Geometry_props) + if(i != nullptr) + i->save(record); + for(auto i : GeometryText_props) + if(i != nullptr) + i->save(record); + for(auto i : FillStyle_props) + if(i != nullptr) + i->save(record); + for(auto i : LineStyle_props) + if(i != nullptr) + i->save(record); + for(auto i : Shadow_props) + if(i != nullptr) + i->save(record); + for(auto i : Transform_props) + if(i != nullptr) + i->save(record); + for(auto i : Other_props) + if(i != nullptr) + i->save(record); +} + void OfficeArtRGFOPTE::SetOptionsCount(const unsigned short count) { options_count = count; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtRGFOPTE.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtRGFOPTE.h index c5d2894904..593b6337c3 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtRGFOPTE.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/OfficeArtRGFOPTE.h @@ -49,6 +49,7 @@ public: XLS::BiffStructurePtr clone(); virtual void load(XLS::CFRecord& record); + virtual void save(XLS::CFRecord& record); static const XLS::ElementType type = XLS::typeOfficeArtRGFOPTE; diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/SimpleOfficeArtContainers.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/SimpleOfficeArtContainers.cpp index d12a301d77..e87929d8b6 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/SimpleOfficeArtContainers.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/SimpleOfficeArtContainers.cpp @@ -188,9 +188,12 @@ void OfficeArtSpContainer::save(XLS::CFRecord& record) m_OfficeArtFSPGR->save(record); if(m_OfficeArtFSP != nullptr) m_OfficeArtFSP->save(record); + if(m_oOfficeArtFOPT != nullptr) + m_oOfficeArtFOPT->save(record); if(m_OfficeArtAnchor != nullptr) m_OfficeArtAnchor->save(record); + //calculating size rh_own.recLen = record.getRdPtr() - sizePos; record.RollRdPtrBack(rh_own.recLen + 4); diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/SimpleOfficeArtContainers.h b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/SimpleOfficeArtContainers.h index f6c74abe62..58e4befad0 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/SimpleOfficeArtContainers.h +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/ODRAW/SimpleOfficeArtContainers.h @@ -96,6 +96,7 @@ public: OfficeArtRecordPtr m_OfficeArtFSPGR; OfficeArtRecordPtr m_OfficeArtFSP; OfficeArtRecordPtr m_OfficeArtAnchor; + OfficeArtRecordPtr m_oOfficeArtFOPT; }; class OfficeArtClientData : public OfficeArtRecord