Commit 1244048c authored by ElenaSubbotina's avatar ElenaSubbotina

x2t - binary - read/write audio/video content for presentation

parent a62b69fb
...@@ -186,6 +186,8 @@ namespace NSBinPptxRW ...@@ -186,6 +186,8 @@ namespace NSBinPptxRW
#define SPTREE_TYPE_SPTREE 4 #define SPTREE_TYPE_SPTREE 4
#define SPTREE_TYPE_GRFRAME 5 #define SPTREE_TYPE_GRFRAME 5
#define SPTREE_TYPE_OLE 6 #define SPTREE_TYPE_OLE 6
#define SPTREE_TYPE_VIDEO 7
#define SPTREE_TYPE_AUDIO 8
static BYTE SchemeClr_GetBYTECode(const std::wstring& sValue) static BYTE SchemeClr_GetBYTECode(const std::wstring& sValue)
{ {
......
...@@ -48,7 +48,7 @@ class COfficeFontPicker; ...@@ -48,7 +48,7 @@ class COfficeFontPicker;
namespace OOX namespace OOX
{ {
class OleObject; class File;
class CContentTypes; class CContentTypes;
class WritingElement; class WritingElement;
class IFileContainer; class IFileContainer;
...@@ -91,7 +91,7 @@ namespace NSBinPptxRW ...@@ -91,7 +91,7 @@ namespace NSBinPptxRW
struct _imageManager2Info struct _imageManager2Info
{ {
std::wstring sFilepathOle; std::wstring sFilepathAdditional;
std::wstring sFilepathImage; std::wstring sFilepathImage;
}; };
...@@ -99,7 +99,9 @@ namespace NSBinPptxRW ...@@ -99,7 +99,9 @@ namespace NSBinPptxRW
{ {
int nImageRId; int nImageRId;
int nOleRId; int nOleRId;
int nMediaRId;
std::wstring sFilepathMedia;
std::wstring sFilepathOle; std::wstring sFilepathOle;
std::wstring sFilepathImage; std::wstring sFilepathImage;
...@@ -107,6 +109,7 @@ namespace NSBinPptxRW ...@@ -107,6 +109,7 @@ namespace NSBinPptxRW
{ {
nImageRId = -1; nImageRId = -1;
nOleRId = -1; nOleRId = -1;
nMediaRId = -1;
} }
}; };
...@@ -158,17 +161,13 @@ namespace NSBinPptxRW ...@@ -158,17 +161,13 @@ namespace NSBinPptxRW
NSShapeImageGen::CImageManager* m_pImageManager; NSShapeImageGen::CImageManager* m_pImageManager;
//NSFontCutter::CFontDstManager m_oFontPicker;
NSFontCutter::CFontDstManager* m_pNativePicker; NSFontCutter::CFontDstManager* m_pNativePicker;
COfficeFontPicker* m_pFontPicker; COfficeFontPicker* m_pFontPicker;
bool m_bDeleteFontPicker; bool m_bDeleteFontPicker;
public:
CCommonWriter(); CCommonWriter();
~CCommonWriter(); ~CCommonWriter();
public:
void CreateFontPicker(COfficeFontPicker* pPicker); void CreateFontPicker(COfficeFontPicker* pPicker);
void CheckFontPicker(); void CheckFontPicker();
}; };
...@@ -178,7 +177,7 @@ namespace NSBinPptxRW ...@@ -178,7 +177,7 @@ namespace NSBinPptxRW
private: private:
std::map<std::wstring, _imageManager2Info> m_mapImages; std::map<std::wstring, _imageManager2Info> m_mapImages;
_INT32 m_lIndexNextImage; _INT32 m_lIndexNextImage;
_INT32 m_lIndexNextOle; _INT32 m_lIndexCounter;
std::wstring m_strDstMedia; std::wstring m_strDstMedia;
std::wstring m_strDstEmbed; std::wstring m_strDstEmbed;
public: public:
...@@ -197,8 +196,8 @@ namespace NSBinPptxRW ...@@ -197,8 +196,8 @@ namespace NSBinPptxRW
int IsDisplayedImage(const std::wstring& strInput); int IsDisplayedImage(const std::wstring& strInput);
_imageManager2Info GenerateImage(const std::wstring& strInput, NSCommon::smart_ptr<OOX::OleObject> & oleFile, const std::wstring& oleData, std::wstring strBase64Image); _imageManager2Info GenerateImage(const std::wstring& strInput, NSCommon::smart_ptr<OOX::File> & additionalFile, const std::wstring& oleData, std::wstring strBase64Image);
_imageManager2Info GenerateImageExec(const std::wstring& strInput, const std::wstring& strExts, const std::wstring& strOleImage, const std::wstring& oleData); _imageManager2Info GenerateImageExec(const std::wstring& strInput, const std::wstring& strExts, const std::wstring& strAdditionalImage, int nAdditionalType, const std::wstring& oleData);
void SaveImageAsPng(const std::wstring& strFileSrc, const std::wstring& strFileDst); void SaveImageAsPng(const std::wstring& strFileSrc, const std::wstring& strFileDst);
void SaveImageAsJPG(const std::wstring& strFileSrc, const std::wstring& strFileDst); void SaveImageAsJPG(const std::wstring& strFileSrc, const std::wstring& strFileDst);
...@@ -426,7 +425,7 @@ namespace NSBinPptxRW ...@@ -426,7 +425,7 @@ namespace NSBinPptxRW
void AddRels (const std::wstring& strRels); void AddRels (const std::wstring& strRels);
void SaveRels (const std::wstring& strFile); void SaveRels (const std::wstring& strFile);
_relsGeneratorInfo WriteImage (const std::wstring& strImage, NSCommon::smart_ptr<OOX::OleObject>& strOle, const std::wstring& oleData, std::wstring strBase64Image); _relsGeneratorInfo WriteImage (const std::wstring& strImage, NSCommon::smart_ptr<OOX::File>& additionalFile, const std::wstring& oleData, std::wstring strBase64Image);
}; };
class CBinaryFileReader class CBinaryFileReader
......
...@@ -104,16 +104,14 @@ namespace NSShapeImageGen ...@@ -104,16 +104,14 @@ namespace NSShapeImageGen
return *this; return *this;
} }
void SetNameModificator(NSShapeImageGen::ImageType eType, bool bOle) void SetNameModificator(NSShapeImageGen::ImageType eType, int typeAdditionalFile )
{ {
std::wstring sPrefix;
int nRes = 0; int nRes = 0;
if(itWMF == eType) if(itWMF == eType) nRes += 1;
nRes += 1; if(itEMF == eType) nRes += 2;
if(itEMF == eType) if(typeAdditionalFile == 1) nRes += 4;
nRes += 2; if(typeAdditionalFile == 2) nRes += 8;
if(bOle)
nRes += 4;
if(0 != nRes) if(0 != nRes)
m_sName = L"display" + std::to_wstring(nRes) + L"image"; m_sName = L"display" + std::to_wstring(nRes) + L"image";
} }
...@@ -199,7 +197,7 @@ namespace NSShapeImageGen ...@@ -199,7 +197,7 @@ namespace NSShapeImageGen
return GenerateImageID(punkImage, (std::max)(1.0, width), (std::max)(1.0, height)); return GenerateImageID(punkImage, (std::max)(1.0, width), (std::max)(1.0, height));
} }
CImageInfo WriteImage(const std::wstring& strFile, const std::wstring& strOleFile, double& x, double& y, double& width, double& height) CImageInfo WriteImage(const std::wstring& strFile, double& x, double& y, double& width, double& height, const std::wstring& strAdditionalFile, int typeAdditionalFile)
{ {
bool bIsDownload = false; bool bIsDownload = false;
int n1 = (int)strFile.find (L"www"); int n1 = (int)strFile.find (L"www");
...@@ -215,16 +213,16 @@ namespace NSShapeImageGen ...@@ -215,16 +213,16 @@ namespace NSShapeImageGen
if (bIsDownload) if (bIsDownload)
{ {
std::wstring strFile1 = strFile; std::wstring strFileUrl = strFile;
XmlUtils::replace_all(strFile1, L"\\", L"/"); XmlUtils::replace_all(strFileUrl, L"\\", L"/");
XmlUtils::replace_all(strFile1, L"http:/", L"http://"); XmlUtils::replace_all(strFileUrl, L"http:/", L"http://");
XmlUtils::replace_all(strFile1, L"https:/", L"https://"); XmlUtils::replace_all(strFileUrl, L"https:/", L"https://");
XmlUtils::replace_all(strFile1, L"ftp:/", L"ftp://"); XmlUtils::replace_all(strFileUrl, L"ftp:/", L"ftp://");
CImageInfo oInfo; CImageInfo oInfo;
std::map<std::wstring, CImageInfo>::iterator pPair = m_mapImagesFile.find(strFile1); std::map<std::wstring, CImageInfo>::iterator pPair = m_mapImagesFile.find(strFileUrl);
if (pPair != m_mapImagesFile.end()) if (pPair != m_mapImagesFile.end())
return pPair->second; return pPair->second;
...@@ -233,7 +231,7 @@ namespace NSShapeImageGen ...@@ -233,7 +231,7 @@ namespace NSShapeImageGen
#ifndef DISABLE_FILE_DOWNLOADER #ifndef DISABLE_FILE_DOWNLOADER
CFileDownloader oDownloader(strFile1, true); CFileDownloader oDownloader(strFileUrl, true);
if (oDownloader.DownloadSync()) if (oDownloader.DownloadSync())
{ {
strDownload = oDownloader.GetFilePath(); strDownload = oDownloader.GetFilePath();
...@@ -241,21 +239,23 @@ namespace NSShapeImageGen ...@@ -241,21 +239,23 @@ namespace NSShapeImageGen
#endif #endif
return GenerateImageID(strDownload, strFile1, strOleFile, (std::max)(1.0, width), (std::max)(1.0, height)); return GenerateImageID(strDownload, strFileUrl, (std::max)(1.0, width), (std::max)(1.0, height), strAdditionalFile, typeAdditionalFile);
} }
CImageInfo info; if (strAdditionalFile.empty())
CFile oFile; {
if (S_OK != oFile.OpenFile(strFile)) CImageInfo info;
return info; CFile oFile;
if (S_OK != oFile.OpenFile(strFile))
return info;
oFile.CloseFile();
}
oFile.CloseFile();
if (-1 == width && -1 == height) if (width < 0 && height < 0) return GenerateImageID(strFile, L"", -1, -1, strAdditionalFile, typeAdditionalFile);
return GenerateImageID(strFile, L"", strOleFile, width, height); return GenerateImageID(strFile, L"", (std::max)(1.0, width), (std::max)(1.0, height), strAdditionalFile, typeAdditionalFile);
return GenerateImageID(strFile, L"", strOleFile, (std::max)(1.0, width), (std::max)(1.0, height));
} }
void SetFontManager(CFontManager* pFontManager) void SetFontManager(CFontManager* pFontManager)
{ {
...@@ -413,12 +413,12 @@ namespace NSShapeImageGen ...@@ -413,12 +413,12 @@ namespace NSShapeImageGen
return oInfo; return oInfo;
} }
CImageInfo GenerateImageID(const std::wstring& strFileName, const std::wstring & strUrl, const std::wstring& strOleFile, double dWidth, double dHeight) CImageInfo GenerateImageID(const std::wstring& strFileName, const std::wstring & strUrl, double dWidth, double dHeight, const std::wstring& strAdditionalFile, int typeAdditionalFile)
{ {
std::wstring sMapKey = strFileName; std::wstring sMapKey = strFileName;
if(!strUrl.empty()) sMapKey = strUrl; if(!strUrl.empty()) sMapKey = strUrl;
if(!strOleFile.empty()) sMapKey += strOleFile; if(!strAdditionalFile.empty()) sMapKey += strAdditionalFile;
CImageInfo oInfo; CImageInfo oInfo;
std::map<std::wstring, CImageInfo>::iterator pPair = m_mapImagesFile.find(sMapKey); std::map<std::wstring, CImageInfo>::iterator pPair = m_mapImagesFile.find(sMapKey);
...@@ -434,26 +434,30 @@ namespace NSShapeImageGen ...@@ -434,26 +434,30 @@ namespace NSShapeImageGen
LONG lImageType = m_oImageExt.GetImageType(strFileName); LONG lImageType = m_oImageExt.GetImageType(strFileName);
bool bVector = (1 == lImageType || 2 == lImageType); bool bVector = (1 == lImageType || 2 == lImageType);
bool bOle = !strOleFile.empty();
bool bOle = !strAdditionalFile.empty() && (typeAdditionalFile == 1);
bool bMedia = !strAdditionalFile.empty() && (typeAdditionalFile == 2);
if(bVector) if(bVector)
oInfo.m_eType = (1 == lImageType) ? itWMF : itEMF; oInfo.m_eType = (1 == lImageType) ? itWMF : itEMF;
oInfo.SetNameModificator(oInfo.m_eType, bOle); oInfo.SetNameModificator(oInfo.m_eType, typeAdditionalFile);
std::wstring strSaveDir = m_strDstMedia + FILE_SEPARATOR_STR; std::wstring strSaveDir = m_strDstMedia + FILE_SEPARATOR_STR;
std::wstring strSaveItemWE = strSaveDir + std::wstring(oInfo.GetPathWithoutExtension()); std::wstring strSaveItemWE = strSaveDir + std::wstring(oInfo.GetPathWithoutExtension());
//copy ole bin //copy ole bin or media
if(bOle) if(bOle || bMedia)
{ {
std::wstring strExts = _T(".bin"); std::wstring strExts;
int nIndexExt = (int)strOleFile.rfind(wchar_t('.')); int nIndexExt = (int)strAdditionalFile.rfind(wchar_t('.'));
if (-1 != nIndexExt) if (-1 != nIndexExt)
strExts = strOleFile.substr(nIndexExt); strExts = strAdditionalFile.substr(nIndexExt);
if(bOle && strExts.empty()) strExts = L".bin";
std::wstring sCopyOlePath = strSaveItemWE + strExts;//L".bin"; std::wstring sCopyOlePath = strSaveItemWE + strExts;
CDirectory::CopyFile(strOleFile, sCopyOlePath); CDirectory::CopyFile(strAdditionalFile, sCopyOlePath);
} }
if (bVector) if (bVector)
......
...@@ -86,12 +86,12 @@ namespace PPTX ...@@ -86,12 +86,12 @@ namespace PPTX
void FileContainer::read(const OOX::CPath& filename) void FileContainer::read(const OOX::CPath& filename)
{ {
//not implement FileContainer.read //OOX::IFileContainer::read(filename);
} }
void FileContainer::read(const OOX::CRels& rels, const OOX::CPath& path) void FileContainer::read(const OOX::CRels& rels, const OOX::CPath& path)
{ {
//not implement FileContainer.read //OOX::IFileContainer::read(rels, path);
} }
void FileContainer::read(const OOX::CRels& rels, const OOX::CPath& path, FileMap& map, IPPTXEvent* Event) void FileContainer::read(const OOX::CRels& rels, const OOX::CPath& path, FileMap& map, IPPTXEvent* Event)
{ {
...@@ -157,8 +157,6 @@ namespace PPTX ...@@ -157,8 +157,6 @@ namespace PPTX
pContainer->read(normPath, map, Event); pContainer->read(normPath, map, Event);
m_bCancelled = pContainer->m_bCancelled; m_bCancelled = pContainer->m_bCancelled;
} }
//todo детально разобраться и вернуть проверку res.(до перехода на cross platform все было хорошо)
//на презентация с hyperlink выходим при достижении 100%. Проценты считаются от количества обработанных файлов, а hyperlink не файл(Ligninger_og_uligheder.pptx)
if (m_bCancelled) if (m_bCancelled)
{ {
break; break;
......
...@@ -156,5 +156,101 @@ namespace PPTX ...@@ -156,5 +156,101 @@ namespace PPTX
return L""; return L"";
} }
void Blip::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
std::wstring strName = (_T("") == m_namespace) ? _T("blip") : (m_namespace + _T(":blip"));
pWriter->StartNode(strName);
pWriter->StartAttributes();
if (embed.IsInit())
pWriter->WriteAttribute(_T("r:embed"), embed->ToString());
if (link.IsInit())
pWriter->WriteAttribute(_T("r:link"), link->ToString());
pWriter->WriteAttribute(_T("cstate"), cstate);
pWriter->EndAttributes();
// TODO:
size_t nCount = Effects.size();
for (size_t i = 0; i < nCount; ++i)
{
Effects[i].toXmlWriter(pWriter);
}
pWriter->EndNode(strName);
}
void Blip::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteLimit2(0, cstate);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
if (embed.is_init())
pWriter->WriteString1(10, embed->get());
if (link.is_init())
pWriter->WriteString1(11, link->get());
pWriter->StartRecord(2);
ULONG len = (ULONG)Effects.size();
pWriter->WriteULONG(len);
for (ULONG i = 0; i < len; ++i)
{
pWriter->WriteRecord1(3, Effects[i]);
}
pWriter->EndRecord();
double dX = pWriter->GetShapeX(); //mm
double dY = pWriter->GetShapeY();
double dW = pWriter->GetShapeWidth(); //mm
double dH = pWriter->GetShapeHeight();
OOX::IFileContainer* pRels = NULL;
if (pWriter->m_pCurrentContainer->is_init())
pRels = pWriter->m_pCurrentContainer->operator ->();
std::wstring additionalPath;
int additionalType = 0;
if(!oleFilepathBin.empty())
{
additionalPath = oleFilepathBin;
additionalType = 1;
}
else if(!oleRid.empty())
{
additionalPath = this->GetFullOleName(OOX::RId(oleRid), pRels);
additionalType = 1;
}
else if(!mediaFilepath.empty())
{
additionalPath = mediaFilepath;
additionalType = 2;
}
std::wstring imagePath;
if(!oleFilepathImage.empty())
{
imagePath = oleFilepathImage;
}
else
{
imagePath = this->GetFullPicName(pRels);
}
NSShapeImageGen::CImageInfo oId = pWriter->m_pCommon->m_pImageManager->WriteImage(imagePath, dX, dY, dW, dH, additionalPath, additionalType);
std::wstring s = oId.GetPath2();
pWriter->StartRecord(3);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteString1(0, s);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
pWriter->EndRecord();
}
} // namespace Logic } // namespace Logic
} // namespace PPTX } // namespace PPTX
\ No newline at end of file
...@@ -63,16 +63,21 @@ namespace PPTX ...@@ -63,16 +63,21 @@ namespace PPTX
link = oSrc.link; link = oSrc.link;
m_namespace = oSrc.m_namespace; m_namespace = oSrc.m_namespace;
oleRid = oSrc.oleRid; oleRid = oSrc.oleRid;
oleFilepathBin = oSrc.oleFilepathBin; oleFilepathBin = oSrc.oleFilepathBin;
mediaFilepath = oSrc.mediaFilepath;
return *this; return *this;
} }
virtual OOX::EElementType getType() const virtual OOX::EElementType getType() const
{ {
return OOX::et_a_blip; return OOX::et_a_blip;
} }
virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{ {
WritingElement_ReadAttributes_Start( oReader ) WritingElement_ReadAttributes_Start( oReader )
...@@ -81,96 +86,11 @@ namespace PPTX ...@@ -81,96 +86,11 @@ namespace PPTX
WritingElement_ReadAttributes_Read_else_if( oReader, _T("cstate"), cstate ) WritingElement_ReadAttributes_Read_else_if( oReader, _T("cstate"), cstate )
WritingElement_ReadAttributes_End( oReader ) WritingElement_ReadAttributes_End( oReader )
} }
virtual void fromXML(XmlUtils::CXmlNode& node);
virtual std::wstring toXML() const; virtual std::wstring toXML() const;
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
{
std::wstring strName = (_T("") == m_namespace) ? _T("blip") : (m_namespace + _T(":blip"));
pWriter->StartNode(strName);
pWriter->StartAttributes();
if (embed.IsInit())
pWriter->WriteAttribute(_T("r:embed"), embed->ToString());
if (link.IsInit())
pWriter->WriteAttribute(_T("r:link"), link->ToString());
pWriter->WriteAttribute(_T("cstate"), cstate);
pWriter->EndAttributes();
// TODO:
size_t nCount = Effects.size();
for (size_t i = 0; i < nCount; ++i)
{
Effects[i].toXmlWriter(pWriter);
}
pWriter->EndNode(strName);
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteLimit2(0, cstate);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
if (embed.is_init())
pWriter->WriteString1(10, embed->get());
if (link.is_init())
pWriter->WriteString1(11, link->get());
pWriter->StartRecord(2);
ULONG len = (ULONG)Effects.size();
pWriter->WriteULONG(len);
for (ULONG i = 0; i < len; ++i)
{
pWriter->WriteRecord1(3, Effects[i]);
}
pWriter->EndRecord();
double dX = pWriter->GetShapeX(); //mm
double dY = pWriter->GetShapeY();
double dW = pWriter->GetShapeWidth(); //mm
double dH = pWriter->GetShapeHeight();
OOX::IFileContainer* pRels = NULL;
if (pWriter->m_pCurrentContainer->is_init())
pRels = pWriter->m_pCurrentContainer->operator ->();
std::wstring olePath;
if(!oleFilepathBin.empty())
{
olePath = oleFilepathBin;
}
else if(!oleRid.empty())
{
olePath= this->GetFullOleName(OOX::RId(oleRid), pRels);
}
std::wstring imagePath;
if(!oleFilepathImage.empty())
{
imagePath = oleFilepathImage;
}
else
{
imagePath = this->GetFullPicName(pRels);
}
NSShapeImageGen::CImageInfo oId = pWriter->m_pCommon->m_pImageManager->WriteImage(imagePath, olePath, dX, dY, dW, dH);
std::wstring s = oId.GetPath2();
pWriter->StartRecord(3);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteString1(0, s);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
pWriter->EndRecord();
}
virtual std::wstring GetFullPicName(OOX::IFileContainer* pRels = NULL)const; virtual std::wstring GetFullPicName(OOX::IFileContainer* pRels = NULL)const;
virtual std::wstring GetFullOleName(const OOX::RId& pRId, OOX::IFileContainer* pRels = NULL)const; virtual std::wstring GetFullOleName(const OOX::RId& pRId, OOX::IFileContainer* pRels = NULL)const;
...@@ -182,6 +102,8 @@ namespace PPTX ...@@ -182,6 +102,8 @@ namespace PPTX
std::wstring m_namespace; std::wstring m_namespace;
std::wstring oleRid; std::wstring oleRid;
std::wstring mediaFilepath;
//internal //internal
std::wstring oleFilepathBin; std::wstring oleFilepathBin;
std::wstring oleFilepathImage; std::wstring oleFilepathImage;
......
...@@ -69,6 +69,9 @@ namespace PPTX ...@@ -69,6 +69,9 @@ namespace PPTX
dpi = oSrc.dpi; dpi = oSrc.dpi;
rotWithShape = oSrc.rotWithShape; rotWithShape = oSrc.rotWithShape;
additionalFile = oSrc.additionalFile;
oleData = oSrc.oleData;
m_namespace = oSrc.m_namespace; m_namespace = oSrc.m_namespace;
return *this; return *this;
} }
...@@ -432,10 +435,10 @@ namespace PPTX ...@@ -432,10 +435,10 @@ namespace PPTX
strImagePath = pathUrl.GetPath(); strImagePath = pathUrl.GetPath();
} }
NSBinPptxRW::_relsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteImage(strImagePath, oleFile, oleData, strOrigBase64); NSBinPptxRW::_relsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteImage(strImagePath, additionalFile, oleData, strOrigBase64);
// ------------------- // -------------------
if (strTempFile != _T("")) if (!strTempFile.empty())
{ {
CDirectory::DeleteFile(strTempFile); CDirectory::DeleteFile(strTempFile);
} }
...@@ -445,14 +448,18 @@ namespace PPTX ...@@ -445,14 +448,18 @@ namespace PPTX
blip = new PPTX::Logic::Blip(); blip = new PPTX::Logic::Blip();
blip->embed = new OOX::RId((size_t)oRelsGeneratorInfo.nImageRId); blip->embed = new OOX::RId((size_t)oRelsGeneratorInfo.nImageRId);
blip->oleFilepathImage = oRelsGeneratorInfo.sFilepathImage;
if(oRelsGeneratorInfo.nOleRId > 0) if(oRelsGeneratorInfo.nOleRId > 0)
{ {
blip->oleRid = OOX::RId((size_t)oRelsGeneratorInfo.nOleRId).get(); blip->oleRid = OOX::RId((size_t)oRelsGeneratorInfo.nOleRId).get();
blip->oleFilepathBin = oRelsGeneratorInfo.sFilepathOle; blip->oleFilepathBin = oRelsGeneratorInfo.sFilepathOle;
blip->oleFilepathImage = oRelsGeneratorInfo.sFilepathImage;
}
if(oRelsGeneratorInfo.nMediaRId > 0)
{
//blip->nMediaRId = OOX::RId((size_t)oRelsGeneratorInfo.nOleRId).get();
blip->mediaFilepath = oRelsGeneratorInfo.sFilepathMedia;
} }
pReader->Skip(1); // end attribute pReader->Skip(1); // end attribute
break; break;
} }
...@@ -507,8 +514,8 @@ namespace PPTX ...@@ -507,8 +514,8 @@ namespace PPTX
nullable_bool rotWithShape; nullable_bool rotWithShape;
//internal //internal
smart_ptr<OOX::OleObject> oleFile; mutable smart_ptr<OOX::File> additionalFile;
std::wstring oleData; std::wstring oleData;
protected: protected:
virtual void FillParentPointersForChilds() virtual void FillParentPointersForChilds()
{ {
......
This diff is collapsed.
...@@ -237,127 +237,35 @@ namespace PPTX ...@@ -237,127 +237,35 @@ namespace PPTX
virtual void fromXML(XmlUtils::CXmlNode& node); virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
void fromXMLOle(XmlUtils::CXmlNode& node);
virtual std::wstring toXML() const;
virtual void GetRect(Aggplus::RECT& pRect)const; virtual void GetRect(Aggplus::RECT& pRect)const;
virtual std::wstring GetFullPicName()const; virtual std::wstring GetFullPicName()const;
virtual std::wstring GetVideoLink()const; smart_ptr<OOX::File> GetMediaLink()const;
virtual std::wstring GetAudioLink()const;
DWORD GetFill(UniFill& fill)const; DWORD GetFill(UniFill& fill)const;
DWORD GetLine(Ln& line)const; DWORD GetLine(Ln& line)const;
double GetStTrim () const; double GetStTrim () const;
double GetEndTrim () const; double GetEndTrim () const;
long GetRefId() const; long GetRefId() const;
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
if(oleObject.IsInit())
{
pWriter->StartRecord(SPTREE_TYPE_OLE);
}
else
{
pWriter->StartRecord(SPTREE_TYPE_PIC);
}
pWriter->WriteRecord2(4, oleObject);
pWriter->WriteRecord1(0, nvPicPr);
pWriter->WriteRecord1(1, blipFill);
pWriter->WriteRecord1(2, spPr);
pWriter->WriteRecord2(3, style);
pWriter->EndRecord();
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
std::wstring namespace_ = m_namespace;
bool bOle = false;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"pic";
if (pWriter->m_lDocType != XMLWRITER_DOC_TYPE_XLSX &&
pWriter->m_lDocType != XMLWRITER_DOC_TYPE_DOCX)
{
if(oleObject.IsInit() && oleObject->isValid())
{
bOle = true;
pWriter->WriteString(L"<p:graphicFrame><p:nvGraphicFramePr><p:cNvPr id=\"0\" name=\"\"/><p:cNvGraphicFramePr><a:graphicFrameLocks noChangeAspect=\"1\"/></p:cNvGraphicFramePr><p:nvPr><p:extLst><p:ext uri=\"{D42A27DB-BD31-4B8C-83A1-F6EECF244321}\"><p14:modId xmlns:p14=\"http://schemas.microsoft.com/office/powerpoint/2010/main\" val=\"2157879785\"/></p:ext></p:extLst></p:nvPr></p:nvGraphicFramePr>");
if(spPr.xfrm.IsInit())
{
std::wstring oldNamespace = spPr.xfrm->m_ns;
spPr.xfrm->m_ns = _T("p");
spPr.xfrm->toXmlWriter(pWriter);
spPr.xfrm->m_ns = oldNamespace;
}
pWriter->WriteString(L"<a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/presentationml/2006/ole\">");
pWriter->StartNode(_T("p:oleObj"));
pWriter->WriteAttribute(L"name", (std::wstring)L"oleObj");
if(oleObject->m_oId.IsInit())
{
pWriter->WriteAttribute2(L"r:id", oleObject->m_oId->get());
}
if(oleObject->m_oDxaOrig.IsInit())
{
int nDxaOrig = oleObject->m_oDxaOrig.get();
pWriter->WriteAttribute(L"imgW", 635 * nDxaOrig); //twips to emu
}
if(oleObject->m_oDyaOrig.IsInit())
{
int nDyaOrig = oleObject->m_oDyaOrig.get();
pWriter->WriteAttribute(L"imgH", 635 * nDyaOrig); //twips to emu
}
pWriter->WriteAttribute2(L"progId", oleObject->m_sProgId);
pWriter->EndAttributes();
pWriter->WriteString(L"<p:embed/>");
}
}
pWriter->StartNode(namespace_ + L":pic");
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
{
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("xmlns:pic"), (std::wstring)_T("http://schemas.openxmlformats.org/drawingml/2006/picture"));
}
pWriter->EndAttributes();
nvPicPr.toXmlWriter(pWriter);
blipFill.m_namespace = namespace_;
blipFill.toXmlWriter(pWriter);
pWriter->m_lFlag = 1;
spPr.toXmlWriter(pWriter);
pWriter->m_lFlag = 0;
pWriter->Write(style);
pWriter->EndNode(namespace_ + L":pic");
if (pWriter->m_lDocType != XMLWRITER_DOC_TYPE_XLSX &&
pWriter->m_lDocType != XMLWRITER_DOC_TYPE_DOCX)
{
if(bOle)
{
pWriter->WriteString(L"</p:oleObj></a:graphicData></a:graphic></p:graphicFrame>");
}
}
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
virtual std::wstring toXML() const;
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;
void toXmlWriterVML(NSBinPptxRW::CXmlWriter* pWriter, smart_ptr<PPTX::Theme>& oTheme, smart_ptr<PPTX::Logic::ClrMap>& oClrMap, bool in_group = false); void toXmlWriterVML(NSBinPptxRW::CXmlWriter* pWriter, smart_ptr<PPTX::Theme>& oTheme, smart_ptr<PPTX::Logic::ClrMap>& oClrMap, bool in_group = false);
void fromXMLOle(XmlUtils::CXmlNode& node);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
NvPicPr nvPicPr; NvPicPr nvPicPr;
BlipFill blipFill; BlipFill blipFill;
SpPr spPr; SpPr spPr;
nullable<ShapeStyle> style; nullable<ShapeStyle> style;
//internal //internal
nullable<COLEObject> oleObject;
std::wstring m_namespace; std::wstring m_namespace;
nullable<COLEObject> oleObject;
nullable_string m_sClientDataXml; nullable_string m_sClientDataXml;
protected: protected:
virtual void FillParentPointersForChilds(); virtual void FillParentPointersForChilds();
......
...@@ -37,8 +37,11 @@ ...@@ -37,8 +37,11 @@
#include "CxnSp.h" #include "CxnSp.h"
#include "SpTree.h" #include "SpTree.h"
#include "GraphicFrame.h" #include "GraphicFrame.h"
#include "./../SlideMaster.h"
#include "../SlideMaster.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Audio.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Video.h"
namespace PPTX namespace PPTX
{ {
namespace Logic namespace Logic
...@@ -346,8 +349,22 @@ namespace PPTX ...@@ -346,8 +349,22 @@ namespace PPTX
} }
case SPTREE_TYPE_OLE: case SPTREE_TYPE_OLE:
case SPTREE_TYPE_PIC: case SPTREE_TYPE_PIC:
case SPTREE_TYPE_AUDIO:
case SPTREE_TYPE_VIDEO:
{ {
Logic::Pic* p = new Logic::Pic(); Logic::Pic* p = new Logic::Pic();
if (_type == SPTREE_TYPE_AUDIO)
{
OOX::Audio *pAudio = new OOX::Audio(pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
p->blipFill.additionalFile = smart_ptr<OOX::File>(dynamic_cast<OOX::File*>(pAudio));
}
else if (_type == SPTREE_TYPE_VIDEO)
{
OOX::Video* pVideo = new OOX::Video(pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
p->blipFill.additionalFile = smart_ptr<OOX::File>(dynamic_cast<OOX::File*>(pVideo));
}
p->fromPPTY(pReader); p->fromPPTY(pReader);
m_elem.reset(p); m_elem.reset(p);
break; break;
......
...@@ -434,10 +434,10 @@ namespace PPTX ...@@ -434,10 +434,10 @@ namespace PPTX
} }
// ------------------- // -------------------
NSBinPptxRW::_relsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteImage(strUrl, pFill->oleFile, pFill->oleData, strOrigBase64); NSBinPptxRW::_relsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteImage(strUrl, pFill->additionalFile, pFill->oleData, strOrigBase64);
// ------------------- // -------------------
if (strTempFile != _T("")) if (!strTempFile.empty())
{ {
CDirectory::DeleteFile(strTempFile); CDirectory::DeleteFile(strTempFile);
} }
......
...@@ -74,7 +74,7 @@ namespace PPTX ...@@ -74,7 +74,7 @@ namespace PPTX
} }
virtual void read(const OOX::CPath& filename, FileMap& map) virtual void read(const OOX::CPath& filename, FileMap& map)
{ {
//FileContainer::read(filename, map); //FileContainer::read(filename);
XmlUtils::CXmlNode oNode; XmlUtils::CXmlNode oNode;
oNode.FromXmlFile(filename.m_strFilename); oNode.FromXmlFile(filename.m_strFilename);
......
<?xml version="1.0" encoding="windows-1251"?> <?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8.00" Version="8,00"
Name="PPTXFormat" Name="PPTXFormat"
ProjectGUID="{36636678-AE25-4BE6-9A34-2561D1BCF302}" ProjectGUID="{36636678-AE25-4BE6-9A34-2561D1BCF302}"
RootNamespace="PPTXFormat" RootNamespace="PPTXFormat"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment