From 47ffdae8cc294d4634d680a5bc314b86dfe0bcb4 Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Fri, 2 Jun 2017 14:35:41 +0300 Subject: [PATCH] PptxFormat - partly fix 35054 --- .../PPTXFormat/Logic/Bullets/Bullet.h | 21 ++- .../PPTXFormat/Logic/Fills/Blip.cpp | 124 ++++++++++++++++++ .../PPTXFormat/Logic/Fills/Blip.h | 1 + .../PPTXFormat/Logic/Fills/BlipFill.h | 2 +- XlsxSerializerCom/Reader/BinaryWriter.h | 1 - 5 files changed, 145 insertions(+), 4 deletions(-) diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/Bullet.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/Bullet.h index 5355735b93..97b125e500 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/Bullet.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/Bullet.h @@ -187,8 +187,25 @@ namespace PPTX break; } case BULLET_TYPE_BULLET_BLIP: - // TODO: - break; + { + pReader->Skip(5); // len + type + start attr + + Logic::BuBlip *pBuBlip = new Logic::BuBlip(); + pBuBlip->blip.fromPPTY(pReader); + + if (pBuBlip->blip.embed.IsInit()) + { + m_Bullet.reset(pBuBlip); + } + else + {//??? сбой ??? + delete pBuBlip; + + Logic::BuChar *pBuChar = new Logic::BuChar(); + pBuChar->Char = wchar_t(L'\x2022'); + m_Bullet.reset(pBuChar); + } + }break; default: m_Bullet.reset(new Logic::BuNone()); break; diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/Blip.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/Blip.cpp index fd8bd883c4..07c214bb26 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/Blip.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/Blip.cpp @@ -257,5 +257,129 @@ namespace PPTX pWriter->EndRecord(); } + void Blip::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _s2 = pReader->GetPos(); + LONG _e2 = _s2 + pReader->GetLong() + 4; + + pReader->Skip(1); + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (NSBinPptxRW::g_nodeAttributeEnd == _at) + break; + + if (_at == 0) + pReader->Skip(1); + } + + while (pReader->GetPos() < _e2) + { + BYTE _t = pReader->GetUChar(); + + switch (_t) + { + case 0: + case 1: + { + // id. embed / link + pReader->Skip(4); + break; + } + case 10: + case 11: + { + // id. embed / link + pReader->GetString2(); + break; + } + case 2: + { + pReader->Skip(4); + ULONG count_effects = pReader->GetULong(); + for (ULONG _eff = 0; _eff < count_effects; ++_eff) + { + pReader->Skip(1); // type + ULONG rec_len = pReader->GetULong(); + if (0 == rec_len) + continue; + + BYTE rec = pReader->GetUChar(); + + if (rec == EFFECT_TYPE_ALPHAMODFIX) + { + // alpha!!! + LONG _e22 = pReader->GetPos() + pReader->GetLong() + 4; + + pReader->Skip(1); // startattr + + PPTX::Logic::AlphaModFix* pEffect = new PPTX::Logic::AlphaModFix(); + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (NSBinPptxRW::g_nodeAttributeEnd == _at) + break; + + if (_at == 0) + pEffect->amt = pReader->GetLong(); + } + + Effects.push_back(UniEffect()); + Effects[0].InitPointer(pEffect); + + pReader->Seek(_e22); + } + else + { + pReader->SkipRecord(); + } + } + break; + } + case 3: + { + pReader->Skip(6); // len + start attributes + type + + std::wstring strImagePath = pReader->GetString2(); + + if (0 != strImagePath.find(_T("http:")) && + 0 != strImagePath.find(_T("https:")) && + 0 != strImagePath.find(_T("ftp:")) && + 0 != strImagePath.find(_T("file:"))) + { + if (0 == strImagePath.find(_T("theme"))) + { + strImagePath = pReader->m_strFolderExternalThemes + FILE_SEPARATOR_STR + strImagePath; + } + else + { + strImagePath = pReader->m_strFolder + FILE_SEPARATOR_STR + _T("media") + FILE_SEPARATOR_STR + strImagePath; + } + + OOX::CPath pathUrl = strImagePath; + strImagePath = pathUrl.GetPath(); + } + + smart_ptr additionalFile; + NSBinPptxRW::_relsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteImage(strImagePath, additionalFile, L"", L""); + + if (oRelsGeneratorInfo.nImageRId > 0) + { + embed = new OOX::RId((size_t)oRelsGeneratorInfo.nImageRId); + } + pReader->Skip(1); // end attribute + break; + } + default: + { + pReader->SkipRecord(); + break; + } + } + } + + pReader->Seek(_e2); + } } // namespace Logic } // namespace PPTX \ No newline at end of file diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/Blip.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/Blip.h index 047ce1520e..0fb11ec47d 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/Blip.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/Blip.h @@ -91,6 +91,7 @@ namespace PPTX virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); virtual std::wstring GetFullPicName(OOX::IFileContainer* pRels = NULL)const; virtual std::wstring GetFullOleName(const OOX::RId& pRId, OOX::IFileContainer* pRels = NULL)const; diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/BlipFill.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/BlipFill.h index f7d948f405..a6424e2ada 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/BlipFill.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/BlipFill.h @@ -447,7 +447,7 @@ namespace PPTX if (!blip.is_init()) blip = new PPTX::Logic::Blip(); - if (oRelsGeneratorInfo.nImageRId >= 0) + if (oRelsGeneratorInfo.nImageRId > 0) { blip->embed = new OOX::RId((size_t)oRelsGeneratorInfo.nImageRId); } diff --git a/XlsxSerializerCom/Reader/BinaryWriter.h b/XlsxSerializerCom/Reader/BinaryWriter.h index ff89e57cfa..64c2150f35 100644 --- a/XlsxSerializerCom/Reader/BinaryWriter.h +++ b/XlsxSerializerCom/Reader/BinaryWriter.h @@ -2717,7 +2717,6 @@ namespace BinXlsxRW if (pFile.IsInit() && ( OOX::FileTypes::Image == pFile->type())) { pImageFileCache = static_cast(pFile.operator->()); - break; } } }