From a438ae3d2e2f71354f5f57039beae2c8d2cdbf3d Mon Sep 17 00:00:00 2001 From: Elena Subbotina Date: Tue, 11 Mar 2025 22:06:23 +0300 Subject: [PATCH] . --- OOXML/Common/SimpleTypes_Draw.cpp | 37 +- OOXML/Common/SimpleTypes_Draw.h | 13 +- OOXML/DocxFormat/Media/Media.cpp | 5 + OOXML/DocxFormat/WritingElement.h | 5 +- .../Linux/DocxFormatLib/DocxFormatLib.pro | 2 + .../Linux/DocxFormatLib/vsdx_format_logic.cpp | 1 + .../DocxFormatLib/DocxFormatLib.vcxproj | 2 + .../DocxFormatLib.vcxproj.filters | 6 + OOXML/VsdxFormat/FileFactory_Draw.cpp | 10 +- OOXML/VsdxFormat/FileTypes_Draw.cpp | 8 + OOXML/VsdxFormat/FileTypes_Draw.h | 4 + OOXML/VsdxFormat/Shapes.cpp | 169 +++++--- OOXML/VsdxFormat/Shapes.h | 26 +- OOXML/VsdxFormat/VisioConnections.cpp | 1 + OOXML/VsdxFormat/VisioDocument.cpp | 157 ++++++- OOXML/VsdxFormat/VisioDocument.h | 28 +- OOXML/VsdxFormat/VisioOthers.cpp | 386 ++++++++++++++++++ OOXML/VsdxFormat/VisioOthers.h | 136 ++++++ OOXML/VsdxFormat/VisioPages.cpp | 25 +- 19 files changed, 921 insertions(+), 100 deletions(-) create mode 100644 OOXML/VsdxFormat/VisioOthers.cpp create mode 100644 OOXML/VsdxFormat/VisioOthers.h diff --git a/OOXML/Common/SimpleTypes_Draw.cpp b/OOXML/Common/SimpleTypes_Draw.cpp index 30377800e0..0a3c914ee2 100644 --- a/OOXML/Common/SimpleTypes_Draw.cpp +++ b/OOXML/Common/SimpleTypes_Draw.cpp @@ -40,6 +40,7 @@ namespace Draw if (L"Bitmap" == sValue) this->m_eValue = typeBitmap; else if (L"EnhMetaFile" == sValue) this->m_eValue = typeEnhMetaFile; else if (L"Ink" == sValue) this->m_eValue = typeInk; + else if (L"Object" == sValue) this->m_eValue = typeObject; else this->m_eValue = typeBitmap; return this->m_eValue; @@ -51,10 +52,35 @@ namespace Draw case typeBitmap: return L"Bitmap"; case typeEnhMetaFile: return L"EnhMetaFile"; case typeInk: return L"Ink"; + case typeObject: return L"Object"; default: return L"Bitmap"; } } + ECompressionType CCompressionType::FromString(const std::wstring& sValue) + { + if (L"JPEG" == sValue || L"JPG" == sValue) this->m_eValue = typeJPEG; + else if (L"DIB" == sValue) this->m_eValue = typeDIB; + else if (L"PNG" == sValue) this->m_eValue = typePNG; + else if (L"TIFF" == sValue) this->m_eValue = typeTIFF; + else if (L"GIF" == sValue) this->m_eValue = typeGIF; + else this->m_eValue = typeJPEG; + + return this->m_eValue; + } + std::wstring CCompressionType::ToString() const + { + switch (this->m_eValue) + { + case typeJPEG: return L"JPEG"; + case typeDIB: return L"DIB"; + case typePNG: return L"PNG"; + case typeTIFF: return L"TIFF"; + case typeGIF: return L"GIF"; + default: return L"JPEG"; + + } + } EShapeType CShapeType::FromString(const std::wstring& sValue) { if (L"Group" == sValue) this->m_eValue = typeGroup; @@ -98,8 +124,10 @@ namespace Draw EWindowType CWindowType::FromString(const std::wstring& sValue) { - if (L"Drawing" == sValue) this->m_eValue = typeDrawing; - else this->m_eValue = EWindowType::typeSheet; + if (L"Drawing" == sValue) this->m_eValue = EWindowType::typeDrawing; + else if (L"Sheet" == sValue) this->m_eValue = EWindowType::typeSheet; + else if (L"Stencil" == sValue) this->m_eValue = EWindowType::typeStencil; + else this->m_eValue = EWindowType::typeSheet; return this->m_eValue; } @@ -107,8 +135,9 @@ namespace Draw { switch (this->m_eValue) { - case typeDrawing: return L"Drawing"; - case typeSheet: return L"Sheet"; + case EWindowType::typeDrawing: return L"Drawing"; + case EWindowType::typeSheet: return L"Sheet"; + case EWindowType::typeStencil: return L"Stencil"; default: return L"Sheet"; } diff --git a/OOXML/Common/SimpleTypes_Draw.h b/OOXML/Common/SimpleTypes_Draw.h index 316c965249..67a2e12f90 100644 --- a/OOXML/Common/SimpleTypes_Draw.h +++ b/OOXML/Common/SimpleTypes_Draw.h @@ -46,6 +46,16 @@ namespace Draw }; DEFINE_SIMPLE_TYPE(CForeignType, EForeignType, typeBitmap) + enum ECompressionType + { + typeJPEG = 0, + typeDIB = 1, + typePNG = 2, + typeTIFF = 3, + typeGIF = 4 + }; + DEFINE_SIMPLE_TYPE(CCompressionType, ECompressionType, typeJPEG) + enum EShapeType { typeGroup = 0, @@ -58,7 +68,8 @@ namespace Draw enum EWindowType { typeDrawing = 0, - typeSheet = 1 + typeSheet = 1, + typeStencil =2 }; DEFINE_SIMPLE_TYPE(CWindowType, EWindowType, typeDrawing) diff --git a/OOXML/DocxFormat/Media/Media.cpp b/OOXML/DocxFormat/Media/Media.cpp index f6e5638ce1..2de34e98de 100644 --- a/OOXML/DocxFormat/Media/Media.cpp +++ b/OOXML/DocxFormat/Media/Media.cpp @@ -112,6 +112,11 @@ namespace OOX copy_to(newFilePath); } } + else + { + std::wstring ext = filename.GetExtention(); + if (false == ext.empty()) content.AddDefault(ext.substr(1)); + } } void Media::set_filename(const std::wstring & file_path, bool bExternal) { diff --git a/OOXML/DocxFormat/WritingElement.h b/OOXML/DocxFormat/WritingElement.h index 1e42e8a339..a38204d613 100644 --- a/OOXML/DocxFormat/WritingElement.h +++ b/OOXML/DocxFormat/WritingElement.h @@ -1570,6 +1570,7 @@ namespace OOX et_dr_text_pp, et_dr_text_tp, et_dr_text_fld, + et_dr_text_text, et_dr_ForeignData, et_dr_Rel, et_dr_RefBy, @@ -1589,7 +1590,9 @@ namespace OOX et_dr_RowKeyValue, et_dr_RowMap, et_dr_Windows, - et_dr_Window + et_dr_Window, + et_dr_Solutions, + et_dr_Solution }; class File; diff --git a/OOXML/Projects/Linux/DocxFormatLib/DocxFormatLib.pro b/OOXML/Projects/Linux/DocxFormatLib/DocxFormatLib.pro index eb5bdbe622..20137857c5 100644 --- a/OOXML/Projects/Linux/DocxFormatLib/DocxFormatLib.pro +++ b/OOXML/Projects/Linux/DocxFormatLib/DocxFormatLib.pro @@ -193,6 +193,7 @@ SOURCES += \ ../../../VsdxFormat/VisioPages.cpp \ ../../../VsdxFormat/VisioDocument.cpp \ ../../../VsdxFormat/VisioConnections.cpp \ + ../../../VsdxFormat/VisioOthers.cpp \ ../../../VsdxFormat/Shapes.cpp \ ../../../VsdxFormat/FileFactory_Draw.cpp \ ../../../VsdxFormat/FileTypes_Draw.cpp @@ -396,6 +397,7 @@ HEADERS += \ ../../../VsdxFormat/VisioPages.h \ ../../../VsdxFormat/VisioDocument.h \ ../../../VsdxFormat/VisioConnections.h \ + ../../../VsdxFormat/VisioOthers.h \ ../../../VsdxFormat/Shapes.h \ ../../../VsdxFormat/FileFactory_Draw.h \ ../../../VsdxFormat/FileTypes_Draw.h \ diff --git a/OOXML/Projects/Linux/DocxFormatLib/vsdx_format_logic.cpp b/OOXML/Projects/Linux/DocxFormatLib/vsdx_format_logic.cpp index 4995c59277..d18d8d3111 100644 --- a/OOXML/Projects/Linux/DocxFormatLib/vsdx_format_logic.cpp +++ b/OOXML/Projects/Linux/DocxFormatLib/vsdx_format_logic.cpp @@ -34,6 +34,7 @@ #include "../../../VsdxFormat/VisioPages.cpp" #include "../../../VsdxFormat/VisioDocument.cpp" #include "../../../VsdxFormat/VisioConnections.cpp" +#include "../../../VsdxFormat/VisioOthers.cpp" #include "../../../VsdxFormat/Shapes.cpp" #include "../../../VsdxFormat/FileFactory_Draw.cpp" #include "../../../VsdxFormat/FileTypes_Draw.cpp" diff --git a/OOXML/Projects/Windows/DocxFormatLib/DocxFormatLib.vcxproj b/OOXML/Projects/Windows/DocxFormatLib/DocxFormatLib.vcxproj index f3200456d7..a69b1c5530 100644 --- a/OOXML/Projects/Windows/DocxFormatLib/DocxFormatLib.vcxproj +++ b/OOXML/Projects/Windows/DocxFormatLib/DocxFormatLib.vcxproj @@ -333,6 +333,7 @@ + @@ -507,6 +508,7 @@ + diff --git a/OOXML/Projects/Windows/DocxFormatLib/DocxFormatLib.vcxproj.filters b/OOXML/Projects/Windows/DocxFormatLib/DocxFormatLib.vcxproj.filters index 9362160f72..a298957e5b 100644 --- a/OOXML/Projects/Windows/DocxFormatLib/DocxFormatLib.vcxproj.filters +++ b/OOXML/Projects/Windows/DocxFormatLib/DocxFormatLib.vcxproj.filters @@ -580,6 +580,9 @@ VsdxFormat + + VsdxFormat + @@ -1026,5 +1029,8 @@ VsdxFormat + + VsdxFormat + \ No newline at end of file diff --git a/OOXML/VsdxFormat/FileFactory_Draw.cpp b/OOXML/VsdxFormat/FileFactory_Draw.cpp index 5700a29dd9..e6e947c03c 100644 --- a/OOXML/VsdxFormat/FileFactory_Draw.cpp +++ b/OOXML/VsdxFormat/FileFactory_Draw.cpp @@ -34,6 +34,7 @@ #include "VisioDocument.h" #include "VisioConnections.h" #include "VisioPages.h" +#include "VisioOthers.h" //#include "Comments.h" #include "../DocxFormat/Rels.h" @@ -83,6 +84,10 @@ namespace OOX return smart_ptr(new CValidation(pMain, oRootPath, oFileName)); else if (oRelation.Type() == FileTypes::Comments) return smart_ptr(new CComments(pMain, oRootPath, oFileName)); + else if (oRelation.Type() == FileTypes::Solutions) + return smart_ptr(new CSolutionsFile(pMain, oRootPath, oFileName)); + else if (oRelation.Type() == FileTypes::Solution) + return smart_ptr(new CSolutionFile(pMain, oRootPath, oFileName)); return smart_ptr( new UnknowTypeFile(pMain) ); } @@ -126,7 +131,10 @@ namespace OOX return smart_ptr(new CRecordsetsFile(pMain, oRootPath, oFileName)); else if (pRelation->Type() == FileTypes::Recordset) return smart_ptr(new CRecordsetFile(pMain, oRootPath, oFileName)); - + else if (pRelation->Type() == FileTypes::Solutions) + return smart_ptr(new CSolutionsFile(pMain, oRootPath, oFileName)); + else if (pRelation->Type() == FileTypes::Solution) + return smart_ptr(new CSolutionFile(pMain, oRootPath, oFileName)); return smart_ptr( new UnknowTypeFile(pMain) ); } } diff --git a/OOXML/VsdxFormat/FileTypes_Draw.cpp b/OOXML/VsdxFormat/FileTypes_Draw.cpp index 78e6fa6a33..80f98237d8 100644 --- a/OOXML/VsdxFormat/FileTypes_Draw.cpp +++ b/OOXML/VsdxFormat/FileTypes_Draw.cpp @@ -75,6 +75,10 @@ namespace OOX L"application/vnd.ms-visio.recordsets+xml", L"http://schemas.microsoft.com/visio/2010/relationships/recordsets"); + const FileType Solutions (L"solutions", L"solutions.xml", + L"application/vnd.ms-visio.solutions+xml", + L"http://schemas.microsoft.com/visio/2010/relationships/solutions"); + const FileType Page (L"", L"page.xml", L"application/vnd.ms-visio.page+xml", L"http://schemas.microsoft.com/visio/2010/relationships/page", @@ -90,6 +94,10 @@ namespace OOX L"http://schemas.microsoft.com/visio/2010/relationships/recordset", L"data/recordset", true); + const FileType Solution (L"", L"solution.xml", + L"application/vnd.ms-visio.solution+xml", + L"http://schemas.microsoft.com/visio/2010/relationships/solution", + L"solutions/solution", true); } // namespace FileTypes } } // namespace OOX diff --git a/OOXML/VsdxFormat/FileTypes_Draw.h b/OOXML/VsdxFormat/FileTypes_Draw.h index 2d21a382af..7b9fa0add7 100644 --- a/OOXML/VsdxFormat/FileTypes_Draw.h +++ b/OOXML/VsdxFormat/FileTypes_Draw.h @@ -61,6 +61,10 @@ namespace OOX extern const FileType Recordsets; extern const FileType Recordset; + + extern const FileType Solutions; + + extern const FileType Solution; } // namespace FileTypes } } // namespace OOX diff --git a/OOXML/VsdxFormat/Shapes.cpp b/OOXML/VsdxFormat/Shapes.cpp index ddb347cb3b..73a383cbdd 100644 --- a/OOXML/VsdxFormat/Shapes.cpp +++ b/OOXML/VsdxFormat/Shapes.cpp @@ -59,30 +59,6 @@ namespace OOX if (oReader.IsEmptyNode()) return; } - void CRel::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - void CRel::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - 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: - { - }break; - } - } - pReader->Seek(_end_rec); - } void CRel::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const { pWriter->StartNode(L"Rel"); @@ -127,6 +103,8 @@ namespace OOX { WritingElement_ReadAttributes_StartChar_No_NS(oReader) WritingElement_ReadAttributes_Read_ifChar(oReader, "ForeignType", ForeignType) + WritingElement_ReadAttributes_Read_else_ifChar(oReader, "CompressionType", CompressionType) + WritingElement_ReadAttributes_Read_else_ifChar(oReader, "CompressionLevel", CompressionLevel) WritingElement_ReadAttributes_Read_else_ifChar(oReader, "ObjectType", ObjectType) WritingElement_ReadAttributes_Read_else_ifChar(oReader, "ShowAsIcon", ShowAsIcon) WritingElement_ReadAttributes_Read_else_ifChar(oReader, "ObjectWidth", ObjectWidth) @@ -135,6 +113,8 @@ namespace OOX WritingElement_ReadAttributes_Read_else_ifChar(oReader, "ExtentY", ExtentY) WritingElement_ReadAttributes_EndChar_No_NS(oReader) } + nullable CompressionType; + nullable_double CompressionLevel; void CForeignData::fromXML(XmlUtils::CXmlLiteReader& oReader) { ReadAttributes(oReader); @@ -162,6 +142,8 @@ namespace OOX pWriter->WriteDoubleReal2(4, ObjectHeight); pWriter->WriteDoubleReal2(5, ExtentX); pWriter->WriteDoubleReal2(6, ExtentY); + if (CompressionType.IsInit()) pWriter->WriteByte1(7, CompressionType->GetValue()); + pWriter->WriteDoubleReal2(8, CompressionLevel); pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); if (Rel.IsInit() && Rel->Rid.IsInit()) @@ -245,6 +227,15 @@ namespace OOX { ExtentY = pReader->GetDoubleReal(); }break; + case 7: + { + CompressionType.Init(); + CompressionType->SetValueFromByte(pReader->GetUChar()); + }break; + case 8: + { + CompressionLevel = pReader->GetDoubleReal(); + }break; } } while (pReader->GetPos() < _end_rec) @@ -302,7 +293,7 @@ namespace OOX NSFile::CFileBinary::Copy(srcMedia + media_filename, pReader->m_pRels->m_pManager->GetDstMedia() + FILE_SEPARATOR_STR + media_filename); Image* pImage = new Image(NULL, false); - pImage->set_filename(pReader->m_pRels->m_pManager->GetDstMedia() + media_filename, false); + pImage->set_filename(pReader->m_pRels->m_pManager->GetDstMedia() + FILE_SEPARATOR_STR + media_filename, false); smart_ptr oFile(pImage); Rel.Init(); Rel->Rid.Init(); @@ -314,6 +305,8 @@ namespace OOX pWriter->StartNode(L"ForeignData"); pWriter->StartAttributes(); if (ForeignType.IsInit()) pWriter->WriteAttribute(L"ForeignType", ForeignType->ToString()); + if (CompressionType.IsInit()) pWriter->WriteAttribute(L"CompressionType", CompressionType->ToString()); + pWriter->WriteAttribute(L"CompressionLevel", CompressionLevel); pWriter->WriteAttribute2(L"ObjectType", ObjectType); pWriter->WriteAttribute(L"ShowAsIcon", ShowAsIcon); pWriter->WriteAttribute(L"ObjectWidth", ObjectWidth); @@ -340,37 +333,51 @@ namespace OOX if (oReader.IsEmptyNode()) return; - int nParentDepth = oReader.GetDepth(); - while (oReader.ReadNextSiblingNode(nParentDepth)) + int nDepth = oReader.GetDepth(); + XmlUtils::XmlNodeType eNodeType = XmlUtils::XmlNodeType_EndElement; + + while (oReader.Read(eNodeType) && oReader.GetDepth() >= nDepth && XmlUtils::XmlNodeType_EndElement != eNodeType) { - std::wstring sName = oReader.GetName(); + if (eNodeType == XmlUtils::XmlNodeType_Text + || eNodeType == XmlUtils::XmlNodeType_Whitespace + || eNodeType == XmlUtils::XmlNodeType_SIGNIFICANT_WHITESPACE + || eNodeType == XmlUtils::XmlNodeType_CDATA) + { + const char* pValue = oReader.GetTextChar(); - WritingElement* pItem = NULL; - if (L"cp" == sName) - { - pItem = new CText_cp(); + if ('\0' != pValue[0]) + { + CText_text* pText = new CText_text(); + NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)pValue, (LONG)strlen(pValue), pText->content); + m_arrItems.push_back(pText); + } } - else if (L"pp" == sName) + else if (eNodeType == XmlUtils::XmlNodeType_Element) { - pItem = new CText_pp(); - } - else if (L"tp" == sName) - { - pItem = new CText_tp(); - } - else if (L"fld" == sName) - { - pItem = new CText_fld(); - } - else - { - content += oReader.GetText2(); - } - content += oReader.GetText2(); - if (pItem) - { - pItem->fromXML(oReader); - m_arrItems.push_back(pItem); + std::wstring sName = oReader.GetName(); + + WritingElement* pItem = NULL; + if (L"cp" == sName) + { + pItem = new CText_cp(); + } + else if (L"pp" == sName) + { + pItem = new CText_pp(); + } + else if (L"tp" == sName) + { + pItem = new CText_tp(); + } + else if (L"fld" == sName) + { + pItem = new CText_fld(); + } + if (pItem) + { + pItem->fromXML(oReader); + m_arrItems.push_back(pItem); + } } } } @@ -385,6 +392,7 @@ namespace OOX case et_dr_text_pp: type = 1; break; case et_dr_text_tp: type = 2; break; case et_dr_text_fld: type = 3; break; + case et_dr_text_text: type = 4; break; } if (type != 0xff) pWriter->WriteRecord2(type, dynamic_cast(m_arrItems[i])); @@ -418,6 +426,11 @@ namespace OOX m_arrItems.push_back(new CText_fld()); m_arrItems.back()->fromPPTY(pReader); }break; + case 4: + { + m_arrItems.push_back(new CText_text()); + m_arrItems.back()->fromPPTY(pReader); + }break; default: { pReader->SkipRecord(); @@ -436,10 +449,42 @@ namespace OOX { m_arrItems[i]->toXmlWriter(pWriter); } - pWriter->WriteString(content); pWriter->WriteNodeEnd(L"Text"); } + EElementType CText_text::getType() const + { + return et_dr_text_text; + } + void CText_text::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteString1(0, content); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void CText_text::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + 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: + { + content = pReader->GetString2(); + }break; + } + } + pReader->Seek(_end_rec); + } + void CText_text::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->WriteStringXML(content); + } EElementType CText_fld::getType() const { return et_dr_text_fld; @@ -456,7 +501,7 @@ namespace OOX if (oReader.IsEmptyNode()) return; - content = oReader.GetText(); + content = oReader.GetText2(); } void CText_fld::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const { @@ -495,7 +540,7 @@ namespace OOX pWriter->WriteAttribute2(L"IX", IX); pWriter->EndAttributes(); - pWriter->WriteString(content); + pWriter->WriteStringXML(content); pWriter->WriteNodeEnd(L"fld"); } @@ -771,8 +816,8 @@ namespace OOX pWriter->StartAttributes(); pWriter->WriteAttribute2(L"N", N); pWriter->WriteAttribute2(L"LocalName", LocalName); - pWriter->WriteAttribute2(L"IX", IX); pWriter->WriteAttribute2(L"T", T); + pWriter->WriteAttribute2(L"IX", IX); pWriter->WriteAttribute(L"Del", Del); pWriter->EndAttributes(); @@ -903,8 +948,8 @@ namespace OOX { pWriter->StartNode(L"Section"); pWriter->StartAttributes(); - pWriter->WriteAttribute2(L"IX", IX); pWriter->WriteAttribute2(L"N", N); + pWriter->WriteAttribute2(L"IX", IX); pWriter->WriteAttribute(L"Del", Del); pWriter->EndAttributes(); @@ -964,8 +1009,8 @@ namespace OOX { pWriter->StartNode(L"RefBy"); pWriter->StartAttributes(); - pWriter->WriteAttribute2(L"ID", ID); pWriter->WriteAttribute2(L"T", T); + pWriter->WriteAttribute2(L"ID", ID); pWriter->EndAttributes(); pWriter->WriteNodeEnd(L"RefBy"); } @@ -1073,10 +1118,11 @@ namespace OOX pWriter->WriteAttribute2(L"E", E); pWriter->WriteAttribute2(L"F", F); pWriter->EndAttributes(); - pWriter->WriteNodeEnd(L"Cell"); if (RefBy.IsInit()) RefBy->toXmlWriter(pWriter); + + pWriter->WriteNodeEnd(L"Cell"); } EElementType CTrigger::getType() const { @@ -1155,10 +1201,11 @@ namespace OOX pWriter->WriteAttribute2(L"N", N); pWriter->EndAttributes(); - pWriter->WriteNodeEnd(L"Trigger"); if (RefBy.IsInit()) RefBy->toXmlWriter(pWriter); + + pWriter->WriteNodeEnd(L"Trigger"); } EElementType CShape::getType() const { @@ -1379,12 +1426,12 @@ namespace OOX pWriter->StartAttributes(); pWriter->WriteAttribute2(L"ID", ID); pWriter->WriteAttribute2(L"OriginalID", OriginalID); + if (Type.IsInit()) pWriter->WriteAttribute2(L"Type", Type->ToString()); pWriter->WriteAttribute(L"Del", Del); pWriter->WriteAttribute2(L"MasterShape", MasterShape); pWriter->WriteAttribute2(L"UniqueID", UniqueID); pWriter->WriteAttribute2(L"NameU", NameU); pWriter->WriteAttribute2(L"Name", Name); - if (Type.IsInit()) pWriter->WriteAttribute2(L"Type", Type->ToString()); pWriter->WriteAttribute(L"IsCustomName", IsCustomName); pWriter->WriteAttribute(L"IsCustomNameU", IsCustomNameU); pWriter->WriteAttribute2(L"Master", Master); diff --git a/OOXML/VsdxFormat/Shapes.h b/OOXML/VsdxFormat/Shapes.h index ba00f2117b..502895a382 100644 --- a/OOXML/VsdxFormat/Shapes.h +++ b/OOXML/VsdxFormat/Shapes.h @@ -58,8 +58,6 @@ namespace OOX virtual EElementType getType() const; - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; private: @@ -111,6 +109,8 @@ namespace OOX public: nullable ForeignType; + nullable CompressionType; + nullable_double CompressionLevel; nullable_uint ObjectType; nullable_bool ShowAsIcon; nullable_double ObjectWidth; @@ -217,6 +217,26 @@ namespace OOX nullable_uint IX; std::wstring content; }; + class CText_text : public WritingElement + { + public: + WritingElement_AdditionMethods(CText_text) + CText_text() {} + virtual ~CText_text() {} + + virtual std::wstring toXML() const { return L""; } + + virtual void fromXML(XmlUtils::CXmlNode& node) {} + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) {} + + virtual EElementType getType() const; + + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + + std::wstring content; + }; class CText : public WritingElementWithChilds<> { public: @@ -235,8 +255,6 @@ namespace OOX virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); virtual EElementType getType() const; - - std::wstring content; // todooo !!! }; class CRow : public WritingElementWithChilds<> { diff --git a/OOXML/VsdxFormat/VisioConnections.cpp b/OOXML/VsdxFormat/VisioConnections.cpp index c669474e1f..a3a3b0faf2 100644 --- a/OOXML/VsdxFormat/VisioConnections.cpp +++ b/OOXML/VsdxFormat/VisioConnections.cpp @@ -161,6 +161,7 @@ namespace Draw oFile.WriteFile((BYTE*)m_sXmlA.c_str(), m_sXmlA.length()); oFile.CloseFile(); } + oContent.Registration(type().OverrideType(), oDirectory, oFilePath.GetFilename()); } const OOX::FileType OOX::Draw::CRecordsetFile::type() const { diff --git a/OOXML/VsdxFormat/VisioDocument.cpp b/OOXML/VsdxFormat/VisioDocument.cpp index 21c26ea675..99e01e89bb 100644 --- a/OOXML/VsdxFormat/VisioDocument.cpp +++ b/OOXML/VsdxFormat/VisioDocument.cpp @@ -32,6 +32,7 @@ #include "VisioDocument.h" #include "VisioPages.h" #include "VisioConnections.h" +#include "VisioOthers.h" #include "Shapes.h" #include "../PPTXFormat/Theme.h" #include "../../DesktopEditor/common/SystemUtils.h" @@ -1317,6 +1318,14 @@ namespace Draw pReader->GetRels()->Add(oFile); }break; + case 11: + { + CSolutionsFile* pSolutions = new CSolutionsFile(((OOX::File*)this)->m_pMainDocument); + pSolutions->fromPPTY(pReader); + smart_ptr oFile(pSolutions); + + pReader->GetRels()->Add(oFile); + }break; case 14: { CWindowsFile* pWindows = new CWindowsFile(((OOX::File*)this)->m_pMainDocument); @@ -1391,6 +1400,15 @@ namespace Draw pRecordsets->toPPTY(pWriter); pWriter->EndRecord(); } + + pFile = this->Find(OOX::Draw::FileTypes::Solutions); + CSolutionsFile* pSolutions = dynamic_cast(pFile.GetPointer()); + if (pSolutions) + { + pWriter->StartRecord(11); + pSolutions->toPPTY(pWriter); + pWriter->EndRecord(); + } pFile = this->Find(OOX::Draw::FileTypes::Windows); CWindowsFile* pWindows = dynamic_cast(pFile.GetPointer()); @@ -1475,6 +1493,65 @@ namespace Draw if (oReader.IsEmptyNode()) return; + int nParentDepth = oReader.GetDepth(); + while (oReader.ReadNextSiblingNode(nParentDepth)) + { + std::wstring sName = oReader.GetName(); + + if (L"ShowRulers" == sName) + { + ShowRulers = oReader.GetText2(); + } + else if (L"ShowGrid" == sName) + { + ShowGrid = oReader.GetText2(); + } + else if (L"ShowPageBreaks" == sName) + { + ShowPageBreaks = oReader.GetText2(); + } + else if (L"GlueSettings" == sName) + { + GlueSettings = oReader.GetText2(); + } + else if (L"ShowGuides" == sName) + { + ShowGuides = oReader.GetText2(); + } + else if (L"ShowConnectionPoints" == sName) + { + ShowConnectionPoints = oReader.GetText2(); + } + else if (L"SnapSettings" == sName) + { + SnapSettings = oReader.GetText2(); + } + else if (L"SnapExtensions" == sName) + { + SnapExtensions = oReader.GetText2(); + } + else if (L"SnapAngles" == sName) + { + SnapAngles = oReader.GetText2(); + } + else if (L"DynamicGridEnabled" == sName) + { + DynamicGridEnabled = oReader.GetText2(); + } + else if (L"TabSplitterPos" == sName) + { + TabSplitterPos = oReader.GetText2(); + } + else if (L"StencilGroup" == sName) + { + StencilGroup = oReader.GetText2(); + } + else if (L"StencilGroupPos" == sName) + { + StencilGroupPos = oReader.GetText2(); + } + } + } void CWindow::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const { @@ -1496,6 +1573,19 @@ namespace Draw pWriter->WriteString2(14, Document); pWriter->WriteUInt2(15, ParentWindow); pWriter->WriteBool2(16, ReadOnly); + pWriter->WriteBool2(17, ShowRulers); + pWriter->WriteBool2(18, ShowGrid); + pWriter->WriteBool2(19, ShowPageBreaks); + pWriter->WriteBool2(20, ShowGuides); + pWriter->WriteBool2(21, ShowConnectionPoints); + pWriter->WriteUInt2(22, GlueSettings); + pWriter->WriteUInt2(23, SnapSettings); + pWriter->WriteUInt2(24, SnapExtensions); + pWriter->WriteBool2(25, SnapAngles); + pWriter->WriteBool2(26, DynamicGridEnabled); + pWriter->WriteDoubleReal2(27, TabSplitterPos); + pWriter->WriteUInt2(28, StencilGroup); + pWriter->WriteUInt2(29, StencilGroupPos); pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); } @@ -1578,11 +1668,62 @@ namespace Draw { ReadOnly = pReader->GetBool(); }break; + case 17: + { + ShowRulers = pReader->GetBool(); + }break; + case 18: + { + ShowGrid = pReader->GetBool(); + }break; + case 19: + { + ShowPageBreaks = pReader->GetBool(); + }break; + case 20: + { + ShowGuides = pReader->GetBool(); + }break; + case 21: + { + ShowConnectionPoints = pReader->GetBool(); + }break; + case 22: + { + GlueSettings = pReader->GetULong(); + }break; + case 23: + { + SnapSettings = pReader->GetULong(); + }break; + case 24: + { + SnapExtensions = pReader->GetULong(); + }break; + case 25: + { + SnapAngles = pReader->GetBool(); + }break; + case 26: + { + DynamicGridEnabled = pReader->GetBool(); + }break; + case 27: + { + TabSplitterPos = pReader->GetDoubleReal(); + }break; + case 28: + { + StencilGroup = pReader->GetULong(); + }break; + case 29: + { + StencilGroupPos = pReader->GetULong(); + }break; } } pReader->Seek(_end_rec); } - void CWindow::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const { pWriter->StartNode(L"Window"); @@ -1608,6 +1749,20 @@ namespace Draw pWriter->WriteAttribute(L"ReadOnly", ReadOnly); pWriter->EndAttributes(); + pWriter->WriteNodeValue(L"ShowRulers", ShowRulers); + pWriter->WriteNodeValue(L"ShowGrid", ShowGrid); + pWriter->WriteNodeValue(L"ShowPageBreaks", ShowPageBreaks); + pWriter->WriteNodeValue(L"ShowGuides", ShowGuides); + pWriter->WriteNodeValue(L"ShowConnectionPoints", ShowConnectionPoints); + pWriter->WriteNodeValue(L"GlueSettings", GlueSettings); + pWriter->WriteNodeValue(L"SnapSettings", SnapSettings); + pWriter->WriteNodeValue(L"SnapExtensions", SnapExtensions); + pWriter->WriteNodeValue(L"SnapAngles", SnapAngles); + pWriter->WriteNodeValue(L"DynamicGridEnabled", DynamicGridEnabled); + pWriter->WriteNodeValue(L"TabSplitterPos", TabSplitterPos); + pWriter->WriteNodeValue(L"StencilGroup", StencilGroup); + pWriter->WriteNodeValue(L"StencilGroupPos", StencilGroupPos); + pWriter->WriteNodeEnd(L"Window"); } //----------------------------------------------------------------------------------------------------------------------------- diff --git a/OOXML/VsdxFormat/VisioDocument.h b/OOXML/VsdxFormat/VisioDocument.h index cb67b29d31..5bda579414 100644 --- a/OOXML/VsdxFormat/VisioDocument.h +++ b/OOXML/VsdxFormat/VisioDocument.h @@ -364,21 +364,19 @@ namespace OOX nullable_uint ParentWindow; nullable_bool ReadOnly; - //nullable_bool ShowRulers; - //nullable_bool ShowGrid; - //nullable_bool ShowPageBreaks; - //nullable_bool ShowGuides; - //nullable_bool ShowConnectionPoints; - //nullable_bool ShowGuides; - //nullable_bool ShowGuides; - //nullable_uint GlueSettings; - //nullable_uint SnapSettings; - //nullable_uint SnapExtensions; - //nullable_bool SnapAngles; - //nullable_bool DynamicGridEnabled; - //nullable_double TabSplitterPos; - //nullable_uint StencilGroup; - //nullable_uint StencilGroupPos + nullable_bool ShowRulers; + nullable_bool ShowGrid; + nullable_bool ShowPageBreaks; + nullable_bool ShowGuides; + nullable_bool ShowConnectionPoints; + nullable_uint GlueSettings; + nullable_uint SnapSettings; + nullable_uint SnapExtensions; + nullable_bool SnapAngles; + nullable_bool DynamicGridEnabled; + nullable_double TabSplitterPos; + nullable_uint StencilGroup; + nullable_uint StencilGroupPos; }; class CWindows : public WritingElementWithChilds { diff --git a/OOXML/VsdxFormat/VisioOthers.cpp b/OOXML/VsdxFormat/VisioOthers.cpp new file mode 100644 index 0000000000..18e6ca2dfe --- /dev/null +++ b/OOXML/VsdxFormat/VisioOthers.cpp @@ -0,0 +1,386 @@ +/* + * (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 "VisioOthers.h" +#include "Shapes.h" +#include "../../DesktopEditor/common/SystemUtils.h" +#include "../Binary/Presentation/BinaryFileReaderWriter.h" +#include "../Binary/Presentation/XmlWriter.h" + +namespace OOX +{ +namespace Draw +{ + OOX::Draw::CSolutionFile::CSolutionFile(OOX::Document* pMain) : OOX::File(pMain) + { + } + OOX::Draw::CSolutionFile::CSolutionFile(OOX::Document* pMain, const CPath& uri) : OOX::File(pMain) + { + read(uri.GetDirectory(), uri); + } + OOX::Draw::CSolutionFile::CSolutionFile(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::File(pMain) + { + read(oRootPath, oPath); + } + OOX::Draw::CSolutionFile::~CSolutionFile() + { + } + void OOX::Draw::CSolutionFile::read(const CPath& oFilePath) + { + CPath oRootPath; + read(oRootPath, oFilePath); + } + void OOX::Draw::CSolutionFile::read(const CPath& oRootPath, const CPath& oFilePath) + { + NSFile::CFileBinary::ReadAllTextUtf8A(oFilePath.GetPath(), m_sXmlA); + } + void OOX::Draw::CSolutionFile::write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const + { + NSFile::CFileBinary oFile; + if (true == oFile.CreateFileW(oFilePath.GetPath())) + { + if (false == m_sXmlA.empty()) + oFile.WriteFile((BYTE*)m_sXmlA.c_str(), m_sXmlA.length()); + oFile.CloseFile(); + } + oContent.Registration(type().OverrideType(), oDirectory, oFilePath.GetFilename()); + } + const OOX::FileType OOX::Draw::CSolutionFile::type() const + { + return FileTypes::Solution; + } + const OOX::CPath OOX::Draw::CSolutionFile::DefaultDirectory() const + { + return type().DefaultDirectory(); + } + const OOX::CPath OOX::Draw::CSolutionFile::DefaultFileName() const + { + return type().DefaultFileName(); + } + void OOX::Draw::CSolutionFile::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG end = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < end) + { + BYTE _rec = pReader->GetUChar(); + + switch (_rec) + { + case 0: + { + pReader->Skip(4); // len + m_sXmlA = pReader->GetString2A(); + }break; + default: + { + pReader->SkipRecord(); + }break; + } + } + pReader->Seek(end); + } + void OOX::Draw::CSolutionFile::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) + { + pWriter->StartRecord(0); + pWriter->WriteStringA(m_sXmlA); + pWriter->EndRecord(); + } +//----------------------------------------------------------------------------------------------------------------------------- + OOX::Draw::CSolutionsFile::CSolutionsFile(OOX::Document* pMain) : OOX::IFileContainer(pMain), OOX::File(pMain) + { + m_bVisioPages = true; + } + OOX::Draw::CSolutionsFile::CSolutionsFile(OOX::Document* pMain, const CPath& uri) : OOX::IFileContainer(pMain), OOX::File(pMain) + { + m_bVisioPages = true; + read(uri.GetDirectory(), uri); + } + OOX::Draw::CSolutionsFile::CSolutionsFile(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::IFileContainer(pMain), OOX::File(pMain) + { + m_bVisioPages = true; + + read(oRootPath, oPath); + } + OOX::Draw::CSolutionsFile::~CSolutionsFile() + { + } + void OOX::Draw::CSolutionsFile::read(const CPath& oFilePath) + { + CPath oRootPath; + read(oRootPath, oFilePath); + } + void OOX::Draw::CSolutionsFile::read(const CPath& oRootPath, const CPath& oFilePath) + { + IFileContainer::Read(oRootPath, oFilePath); + + XmlUtils::CXmlLiteReader oReader; + + if (!oReader.FromFile(oFilePath.GetPath())) + return; + + if (!oReader.ReadNextNode()) + return; + + m_strFilename = oFilePath.GetPath(); + + Solutions = oReader; + } + void OOX::Draw::CSolutionsFile::write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const + { + NSBinPptxRW::CXmlWriter oXmlWriter; + oXmlWriter.WriteString((L"")); + + oXmlWriter.m_lDocType = XMLWRITER_DOC_TYPE_VSDX; + toXmlWriter(&oXmlWriter); + + NSFile::CFileBinary::SaveToFile(oFilePath.GetPath(), oXmlWriter.GetXmlString()); + + oContent.Registration(type().OverrideType(), oDirectory, oFilePath.GetFilename()); + IFileContainer::Write(oFilePath, oDirectory, oContent); + } + const OOX::FileType OOX::Draw::CSolutionsFile::type() const + { + return FileTypes::Solutions; + } + const OOX::CPath OOX::Draw::CSolutionsFile::DefaultDirectory() const + { + return type().DefaultDirectory(); + } + const OOX::CPath OOX::Draw::CSolutionsFile::DefaultFileName() const + { + return type().DefaultFileName(); + } + void OOX::Draw::CSolutionsFile::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + smart_ptr rels_old = pReader->GetRels(); + pReader->SetRels(dynamic_cast((CSolutionsFile*)this)); + + LONG end = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < end) + { + BYTE _rec = pReader->GetUChar(); + + switch (_rec) + { + case 0: + { + Solutions.Init(); + Solutions->fromPPTY(pReader); + }break; + default: + { + pReader->SkipRecord(); + }break; + } + } + pReader->Seek(end); + pReader->SetRels(rels_old); + } + void OOX::Draw::CSolutionsFile::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + smart_ptr rels_old = pWriter->GetRels(); + pWriter->SetRels(dynamic_cast((CSolutionsFile*)this)); + + pWriter->WriteRecord2(0, Solutions); + + pWriter->SetRels(rels_old); + } + void OOX::Draw::CSolutionsFile::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + if (Solutions.IsInit()) + Solutions->toXmlWriter(pWriter); + } +//----------------------------------------------------------------------------------------------------------------------------- + EElementType CSolution::getType() const + { + return et_dr_Solution; + } + void CSolution::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_StartChar_No_NS(oReader) + WritingElement_ReadAttributes_Read_ifChar(oReader, "Name", Name) + WritingElement_ReadAttributes_EndChar_No_NS(oReader) + } + void CSolution::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes(oReader); + + if (oReader.IsEmptyNode()) + return; + + int nCurDepth = oReader.GetDepth(); + while (oReader.ReadNextSiblingNode(nCurDepth)) + { + const char* sName = XmlUtils::GetNameNoNS(oReader.GetNameChar()); + if (strcmp("Rel", sName) == 0) + { + Rel = oReader; + } + } + } + void CSolution::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteString2(0, Name); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + if (Rel.IsInit() && Rel->Rid.IsInit()) + { + smart_ptr pFile = pWriter->GetRels()->Find(Rel->Rid->GetValue()); + CSolutionFile* pSolution = dynamic_cast(pFile.GetPointer()); + if (pSolution) + { + pWriter->StartRecord(0); + pSolution->toPPTY(pWriter); + pWriter->EndRecord(); + } + } + } + void CSolution::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + 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: + { + Name = pReader->GetString2(); + }break; + } + } + while (pReader->GetPos() < _end_rec) + { + BYTE _rec = pReader->GetUChar(); + switch (_rec) + { + case 0: + { + CSolutionFile* pSolution = new CSolutionFile(NULL); + pSolution->fromPPTY(pReader); + smart_ptr oFile(pSolution); + + Rel.Init(); Rel->Rid.Init(); + Rel->Rid->SetValue(pReader->GetRels()->Add(oFile).get()); + }break; + default: + { + pReader->SkipRecord(); + }break; + } + } + pReader->Seek(_end_rec); + } + void CSolution::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(L"Solution"); + pWriter->StartAttributes(); + pWriter->WriteAttribute2(L"Name", Name); + pWriter->EndAttributes(); + + if (Rel.IsInit()) + Rel->toXmlWriter(pWriter); + + pWriter->WriteNodeEnd(L"Solution"); + } +//----------------------------------------------------------------------------------------------------------------------------- + void CSolutions::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + if (oReader.IsEmptyNode()) + return; + + int nParentDepth = oReader.GetDepth(); + while (oReader.ReadNextSiblingNode(nParentDepth)) + { + std::wstring sName = oReader.GetName(); + + if (L"Solution" == sName) + { + CSolution* pItem = new CSolution(); + *pItem = oReader; + + if (pItem) + m_arrItems.push_back(pItem); + } + } + } + EElementType CSolutions::getType() const + { + return et_dr_Solutions; + } + void CSolutions::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG end = pReader->GetPos() + pReader->GetRecordSize() + 4; + while (pReader->GetPos() < end) + { + BYTE _rec = pReader->GetUChar(); + switch (_rec) + { + case 0: + { + m_arrItems.push_back(new CSolution()); + m_arrItems.back()->fromPPTY(pReader); + }break; + default: + { + pReader->SkipRecord(); + }break; + } + } + pReader->Seek(end); + } + void CSolutions::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + for (size_t i = 0; i < m_arrItems.size(); ++i) + pWriter->WriteRecord2(0, dynamic_cast(m_arrItems[i])); + } + void CSolutions::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(L"Solutions"); + pWriter->StartAttributes(); + pWriter->WriteAttribute2(L"xmlns", L"http://schemas.microsoft.com/office/visio/2012/main"); + pWriter->WriteAttribute2(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships"); + pWriter->WriteAttribute2(L"xml:space", L"preserve"); + pWriter->EndAttributes(); + + for (size_t i = 0; i < m_arrItems.size(); ++i) + m_arrItems[i]->toXmlWriter(pWriter); + + pWriter->WriteNodeEnd(L"Solutions"); + } +} +} // namespace OOX diff --git a/OOXML/VsdxFormat/VisioOthers.h b/OOXML/VsdxFormat/VisioOthers.h new file mode 100644 index 0000000000..4c8738b779 --- /dev/null +++ b/OOXML/VsdxFormat/VisioOthers.h @@ -0,0 +1,136 @@ +/* + * (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 "../Base/Nullable.h" + +#include "FileTypes_Draw.h" +#include "../DocxFormat/IFileContainer.h" + +namespace OOX +{ + namespace Draw + { + class CRel; + + class CSolution : public WritingElement + { + public: + WritingElement_AdditionMethods(CSolution) + CSolution() {} + virtual ~CSolution() {} + + virtual void fromXML(XmlUtils::CXmlNode& node) {} + virtual std::wstring toXML() const { return L""; } + + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual EElementType getType() const; + + nullable_string Name; + nullable Rel; + }; + class CSolutions : public WritingElementWithChilds + { + public: + WritingElement_AdditionMethods(CSolutions) + CSolutions() {} + virtual ~CSolutions() {} + + virtual std::wstring toXML() const { return L""; } + virtual void fromXML(XmlUtils::CXmlNode& node) {} + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + + virtual EElementType getType() const; + + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + }; + +//------------------------------------------------------------------------------------------------------------------------------ + class CSolutionsFile : public OOX::IFileContainer, public OOX::File + { + public: + CSolutionsFile(OOX::Document* pMain); + CSolutionsFile(OOX::Document* pMain, const CPath& uri); + CSolutionsFile(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath); + virtual ~CSolutionsFile(); + + virtual void read(const CPath& oFilePath); + virtual void read(const CPath& oRootPath, const CPath& oFilePath); + virtual void write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const; + + virtual const OOX::FileType type() const; + + virtual const CPath DefaultDirectory() const; + virtual const CPath DefaultFileName() const; + + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + + std::wstring m_strFilename; + + nullable Solutions; + }; + class CSolutionFile : public OOX::File + { + public: + CSolutionFile(OOX::Document* pMain); + CSolutionFile(OOX::Document* pMain, const CPath& uri); + CSolutionFile(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath); + virtual ~CSolutionFile(); + + virtual void read(const CPath& oFilePath); + virtual void read(const CPath& oRootPath, const CPath& oFilePath); + virtual void write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const; + + virtual const OOX::FileType type() const; + + virtual const CPath DefaultDirectory() const; + virtual const CPath DefaultFileName() const; + + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter); + + std::wstring m_strFilename; + + std::string m_sXmlA; + }; + } //Draw +} // namespace OOX diff --git a/OOXML/VsdxFormat/VisioPages.cpp b/OOXML/VsdxFormat/VisioPages.cpp index fb13319e9e..459843ace7 100644 --- a/OOXML/VsdxFormat/VisioPages.cpp +++ b/OOXML/VsdxFormat/VisioPages.cpp @@ -109,6 +109,7 @@ namespace Draw NSFile::CFileBinary::SaveToFile(oFilePath.GetPath(), oXmlWriter.GetXmlString()); oContent.Registration(type().OverrideType(), oDirectory, oFilePath.GetFilename()); + IFileContainer::Write(oFilePath, oDirectory, oContent); } const OOX::FileType CMasterFile::type() const { @@ -908,10 +909,10 @@ namespace Draw pWriter->StartNode(L"Page"); pWriter->StartAttributes(); pWriter->WriteAttribute2(L"ID", ID); - pWriter->WriteAttribute2(L"Name", Name); pWriter->WriteAttribute2(L"NameU", NameU); - pWriter->WriteAttribute(L"IsCustomName", IsCustomName); pWriter->WriteAttribute(L"IsCustomNameU", IsCustomNameU); + pWriter->WriteAttribute2(L"Name", Name); + pWriter->WriteAttribute(L"IsCustomName", IsCustomName); pWriter->WriteAttribute(L"Background", Background); pWriter->WriteAttribute2(L"BackPage", BackPage); pWriter->WriteAttribute(L"ViewScale", ViewScale); @@ -1143,19 +1144,19 @@ namespace Draw pWriter->StartNode(L"Master"); pWriter->StartAttributes(); pWriter->WriteAttribute2(L"ID", ID); - pWriter->WriteAttribute2(L"Name", Name); pWriter->WriteAttribute2(L"NameU", NameU); - pWriter->WriteAttribute2(L"BaseID", BaseID); - pWriter->WriteAttribute2(L"UniqueID", UniqueID); - pWriter->WriteAttribute(L"MatchByName", MatchByName); - pWriter->WriteAttribute(L"IsCustomName", IsCustomName); pWriter->WriteAttribute(L"IsCustomNameU", IsCustomNameU); - pWriter->WriteAttribute2(L"IconSize", IconSize); - pWriter->WriteAttribute2(L"PatternFlags", PatternFlags); + pWriter->WriteAttribute2(L"Name", Name); + pWriter->WriteAttribute(L"IsCustomName", IsCustomName); pWriter->WriteAttribute2(L"Prompt", Prompt); - pWriter->WriteAttribute(L"Hidden", Hidden); - pWriter->WriteAttribute(L"IconUpdate", IconUpdate); + pWriter->WriteAttribute2(L"IconSize", IconSize); pWriter->WriteAttribute2(L"AlignName", AlignName); + pWriter->WriteAttribute(L"MatchByName", MatchByName); + pWriter->WriteAttribute(L"IconUpdate", IconUpdate); + pWriter->WriteAttribute2(L"UniqueID", UniqueID); + pWriter->WriteAttribute2(L"BaseID", BaseID); + pWriter->WriteAttribute2(L"PatternFlags", PatternFlags); + pWriter->WriteAttribute(L"Hidden", Hidden); pWriter->WriteAttribute2(L"MasterType", MasterType); pWriter->EndAttributes(); @@ -1298,10 +1299,10 @@ namespace Draw { pWriter->StartNode(L"PageSheet"); pWriter->StartAttributes(); - pWriter->WriteAttribute2(L"UniqueID", UniqueID); pWriter->WriteAttribute2(L"LineStyle", LineStyle); pWriter->WriteAttribute2(L"FillStyle", FillStyle); pWriter->WriteAttribute2(L"TextStyle", TextStyle); + pWriter->WriteAttribute2(L"UniqueID", UniqueID); pWriter->EndAttributes(); for (size_t i = 0; i < m_arrItems.size(); ++i)