From 8a000efb7f9945d9327df2089116bd83360b826d Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Wed, 20 Nov 2024 18:59:09 +0300 Subject: [PATCH] fill stretch --- OOXML/PPTXFormat/Logic/Fills/BlipFill.cpp | 38 ++++---------- OOXML/PPTXFormat/Logic/Fills/Stretch.cpp | 24 +++++++++ OOXML/PPTXFormat/Logic/Fills/Stretch.h | 6 +-- OOXML/PPTXFormat/Logic/Fills/Tile.h | 4 -- OOXML/PPTXFormat/Logic/UniFill.cpp | 64 +++++++++-------------- 5 files changed, 60 insertions(+), 76 deletions(-) diff --git a/OOXML/PPTXFormat/Logic/Fills/BlipFill.cpp b/OOXML/PPTXFormat/Logic/Fills/BlipFill.cpp index c818ea1305..fa2c493172 100644 --- a/OOXML/PPTXFormat/Logic/Fills/BlipFill.cpp +++ b/OOXML/PPTXFormat/Logic/Fills/BlipFill.cpp @@ -185,20 +185,7 @@ namespace PPTX pWriter->EndAttributes(); pWriter->Write(blip); - - if (srcRect.is_init()) - { - pWriter->StartNode(L"a:srcRect"); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(L"l", srcRect->l); - pWriter->WriteAttribute(L"t", srcRect->t); - pWriter->WriteAttribute(L"r", srcRect->r); - pWriter->WriteAttribute(L"b", srcRect->b); - pWriter->EndAttributes(); - - pWriter->EndNode(L"a:srcRect"); - } + pWriter->Write(srcRect); pWriter->Write(tile); pWriter->Write(stretch); @@ -455,31 +442,26 @@ namespace PPTX } } } - - pReader->Seek(_e2); - break; - } + pReader->Seek(_e2); + }break; case 1: { srcRect = new PPTX::Logic::Rect(); - srcRect->fromPPTY(pReader); - break; - } + srcRect->m_name = L"a:srcRect"; + srcRect->fromPPTY(pReader); + }break; case 2: { tile = new PPTX::Logic::Tile(); - tile->fromPPTY(pReader); - break; - } + tile->fromPPTY(pReader); + }break; case 3: { stretch = new PPTX::Logic::Stretch(); - pReader->SkipRecord(); - break; - } + stretch->fromPPTY(pReader); + }break; default: { - // пока никаких настроек градиента нет pReader->SkipRecord(); } } diff --git a/OOXML/PPTXFormat/Logic/Fills/Stretch.cpp b/OOXML/PPTXFormat/Logic/Fills/Stretch.cpp index ab6091a206..1752d200bc 100644 --- a/OOXML/PPTXFormat/Logic/Fills/Stretch.cpp +++ b/OOXML/PPTXFormat/Logic/Fills/Stretch.cpp @@ -98,6 +98,30 @@ namespace PPTX pWriter->EndNode(strName); } + void Stretch::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < _end_rec) + { + BYTE rec = pReader->GetUChar(); + + switch (rec) + { + case 0: + { + fillRect = new PPTX::Logic::Rect(); + fillRect->m_name = L"a:fillRect"; + fillRect->fromPPTY(pReader); + }break; + default: + { + pReader->SkipRecord(); + } + } + } + pReader->Seek(_end_rec); + } void Stretch::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const { pWriter->WriteRecord2(0, fillRect); diff --git a/OOXML/PPTXFormat/Logic/Fills/Stretch.h b/OOXML/PPTXFormat/Logic/Fills/Stretch.h index 5fa14ff07e..0e0bcc3a5f 100644 --- a/OOXML/PPTXFormat/Logic/Fills/Stretch.h +++ b/OOXML/PPTXFormat/Logic/Fills/Stretch.h @@ -30,8 +30,6 @@ * */ #pragma once -#ifndef PPTX_LOGIC_STRETCH_INCLUDE_H_ -#define PPTX_LOGIC_STRETCH_INCLUDE_H_ #include "./../../WrapperWritingElement.h" #include "./../Rect.h" @@ -56,8 +54,8 @@ namespace PPTX virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - public: nullable fillRect; protected: @@ -65,5 +63,3 @@ namespace PPTX }; } // namespace Logic } // namespace PPTX - -#endif // PPTX_LOGIC_STRETCH_INCLUDE_H_ diff --git a/OOXML/PPTXFormat/Logic/Fills/Tile.h b/OOXML/PPTXFormat/Logic/Fills/Tile.h index c586abff0d..02eb970c74 100644 --- a/OOXML/PPTXFormat/Logic/Fills/Tile.h +++ b/OOXML/PPTXFormat/Logic/Fills/Tile.h @@ -30,8 +30,6 @@ * */ #pragma once -#ifndef PPTX_LOGIC_TILE_INCLUDE_H_ -#define PPTX_LOGIC_TILE_INCLUDE_H_ #include "./../../WrapperWritingElement.h" #include "./../../Limit/RectAlign.h" @@ -61,7 +59,6 @@ namespace PPTX virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - public: nullable_limit algn; nullable_limit flip; nullable_int sx; @@ -75,4 +72,3 @@ namespace PPTX } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_TILE_INCLUDE_H_ diff --git a/OOXML/PPTXFormat/Logic/UniFill.cpp b/OOXML/PPTXFormat/Logic/UniFill.cpp index 8eea42bca1..38c07f5527 100644 --- a/OOXML/PPTXFormat/Logic/UniFill.cpp +++ b/OOXML/PPTXFormat/Logic/UniFill.cpp @@ -256,16 +256,14 @@ namespace PPTX case 1: { // id. embed / link - pReader->Skip(4); - break; - } + pReader->Skip(4); + }break; case 10: case 11: { // id. embed / link - pReader->GetString2(); - break; - } + pReader->GetString2(); + }break; case 2: { if (!pFill->blip.is_init()) @@ -415,41 +413,35 @@ namespace PPTX pFill->blip->mediaRid = OOX::RId((size_t)oRelsGeneratorInfo.nMediaRId).get(); pFill->blip->mediaFilepath = oRelsGeneratorInfo.sFilepathMedia; } - pReader->Skip(1); // end attribute - break; - } + pReader->Skip(1); // end attribute + }break; default: { - pReader->SkipRecord(); - break; - } + pReader->SkipRecord(); + }break; } } - pReader->Seek(_e2); - break; - } + pReader->Seek(_e2); + }break; case 1: { pFill->srcRect = new PPTX::Logic::Rect(); + pFill->srcRect->m_name = L"a:srcRect"; pFill->srcRect->fromPPTY(pReader); - break; - } + }break; case 2: { pFill->tile = new PPTX::Logic::Tile(); - pFill->tile->fromPPTY(pReader); - break; - } + pFill->tile->fromPPTY(pReader); + }break; case 3: { pFill->stretch = new PPTX::Logic::Stretch(); - pReader->SkipRecord(); - break; - } + pFill->stretch->fromPPTY(pReader); + }break; default: { - // пока никаких настроек градиента нет pReader->SkipRecord(); } } @@ -517,33 +509,27 @@ namespace PPTX pFill->GsLst[_countGs].color.fromPPTY(pReader); } - pReader->Seek(_e1); - break; - } + pReader->Seek(_e1); + }break; case 1: { pFill->lin = new PPTX::Logic::Lin(); - pFill->lin->fromPPTY(pReader); - break; - } + pFill->lin->fromPPTY(pReader); + }break; case 2: { pFill->path = new PPTX::Logic::Path(); - pFill->path->fromPPTY(pReader); - break; - } + pFill->path->fromPPTY(pReader); + }break; case 3: { pFill->tileRect = new PPTX::Logic::Rect(); - pFill->tileRect->fromPPTY(pReader); - pFill->tileRect->m_name = _T("a:tileRect"); - break; - } + pFill->tileRect->m_name = L"a:tileRect"; + pFill->tileRect->fromPPTY(pReader); + }break; default: { - // пока никаких настроек градиента нет pReader->SkipRecord(); - break; } } }