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
#define SPTREE_TYPE_SPTREE 4
#define SPTREE_TYPE_GRFRAME 5
#define SPTREE_TYPE_OLE 6
#define SPTREE_TYPE_VIDEO 7
#define SPTREE_TYPE_AUDIO 8
static BYTE SchemeClr_GetBYTECode(const std::wstring& sValue)
{
......
......@@ -36,6 +36,8 @@
#include "../../Common/DocxFormat/Source/DocxFormat/WritingElement.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/OleObject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Audio.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Video.h"
#include "../../Common/Base64.h"
......@@ -106,7 +108,7 @@ namespace NSBinPptxRW
CreateFontPicker(NULL);
}
CImageManager2::CImageManager2() : m_mapImages(), m_lIndexNextImage(0), m_lIndexNextOle(0)
CImageManager2::CImageManager2() : m_mapImages(), m_lIndexNextImage(0), m_lIndexCounter(0)
{
m_nDocumentType = XMLWRITER_DOC_TYPE_PPTX;
m_pContentTypes = new OOX::CContentTypes();
......@@ -118,8 +120,8 @@ namespace NSBinPptxRW
void CImageManager2::Clear()
{
m_mapImages.clear();
m_lIndexNextImage = 1;
m_lIndexNextOle = 1;
m_lIndexNextImage = 0;
m_lIndexCounter = 0;
}
void CImageManager2::SetDstMedia(const std::wstring& strDst)
{
......@@ -147,24 +149,33 @@ namespace NSBinPptxRW
{
if(nIndex1 + sFind1.length() < strInput.length())
{
wchar_t cRes = strInput[nIndex1 + sFind1.length()];
if('1' <= cRes && cRes <= '6')
wchar_t cRes1 = strInput[nIndex1 + sFind1.length()];
if('1' <= cRes1 && cRes1 <= '9')
{
wchar_t cRes2 = strInput[nIndex1 + sFind1.length() + 1];
int nImageIndex = nIndex1 + (int)sFind1.length() + 1;
if(nImageIndex == (int)strInput.find(_T("image"), nImageIndex))
nRes = cRes - '0';
if (std::wstring::npos != strInput.find(_T("image"), nImageIndex))
{
nRes = cRes1 - '0';
if('0' <= cRes2 && cRes2 <= '9')
{
nRes = nRes * 10 + (cRes2 - '0');
}
}
}
}
}
return nRes;
}
_imageManager2Info CImageManager2::GenerateImage(const std::wstring& strInput, NSCommon::smart_ptr<OOX::OleObject> & oleFile, const std::wstring& oleData, std::wstring strBase64Image)
_imageManager2Info CImageManager2::GenerateImage(const std::wstring& strInput, NSCommon::smart_ptr<OOX::File> & additionalFile, const std::wstring& oleData, std::wstring strBase64Image)
{
if (IsNeedDownload(strInput))
return DownloadImage(strInput);
std::map<std::wstring, _imageManager2Info>::const_iterator pPair = m_mapImages.find ((_T("") == strBase64Image) ? strInput : strBase64Image);
std::map<std::wstring, _imageManager2Info>::const_iterator pPair = m_mapImages.find ((strBase64Image.empty()) ? strInput : strBase64Image);
if (pPair != m_mapImages.end())
return pPair->second;
......@@ -174,7 +185,8 @@ namespace NSBinPptxRW
if (-1 != nIndexExt)
strExts = strInput.substr(nIndexExt);
std::wstring strOleBin;
int typeAdditional = 0;
std::wstring strAdditional;
std::wstring strImage = strInput;
int nDisplayType = IsDisplayedImage(strInput);
......@@ -208,21 +220,52 @@ namespace NSBinPptxRW
}
if(0 != (nDisplayType & 4))
{
smart_ptr<OOX::OleObject> oleFile = additionalFile.smart_dynamic_cast<OOX::OleObject>();
if (oleFile.IsInit())
{
if (OOX::CSystemUtility::IsFileExist(oleFile->filename()) == false)
{
typeAdditional = 1;
std::wstring strOle = strFolder + strFileName + oleFile->filename().GetExtention();
if (OOX::CSystemUtility::IsFileExist(strOle))
{
m_pContentTypes->AddDefault(oleFile->filename().GetExtention(false));
strOleBin = strOle;
strAdditional = strOle;
}
else
{
strOle = strFolder + strFileName + L".bin";
if (OOX::CSystemUtility::IsFileExist(strOle))
strOleBin = strOle;
strAdditional = strOle;
}
}
}
}
if(0 != (nDisplayType & 8))
{
smart_ptr<OOX::Media> mediaFile = additionalFile.smart_dynamic_cast<OOX::Media>();
if (mediaFile.IsInit())
{
if (OOX::CSystemUtility::IsFileExist(mediaFile->filename()) == false)
{
typeAdditional = 2;
std::wstring strMedia = strFolder + strFileName + mediaFile->filename().GetExtention();
if (OOX::CSystemUtility::IsFileExist(strMedia))
{
m_pContentTypes->AddDefault(mediaFile->filename().GetExtention(false));
strAdditional = strMedia;
}
else
{
strMedia = strFolder + strFileName;
if (mediaFile.is<OOX::Audio>()) strMedia += L".wav";
if (mediaFile.is<OOX::Video>()) strMedia += L".avi";
if (OOX::CSystemUtility::IsFileExist(strMedia))
strAdditional = strMedia;
}
}
}
......@@ -233,10 +276,14 @@ namespace NSBinPptxRW
m_pContentTypes->AddDefault(strExts.substr(1));
}
_imageManager2Info oImageManagerInfo = GenerateImageExec(strImage, strExts, strOleBin, oleData);
_imageManager2Info oImageManagerInfo = GenerateImageExec(strImage, strExts, strAdditional, typeAdditional, oleData);
if (!oImageManagerInfo.sFilepathOle.empty())
oleFile->set_filename(oImageManagerInfo.sFilepathOle);
if (!oImageManagerInfo.sFilepathAdditional.empty())
{
smart_ptr<OOX::Media> mediaFile = additionalFile.smart_dynamic_cast<OOX::Media>();
if (mediaFile.IsInit())
mediaFile->set_filename(oImageManagerInfo.sFilepathAdditional);
}
if (strBase64Image.empty())
m_mapImages[strInput] = oImageManagerInfo;
......@@ -281,7 +328,7 @@ namespace NSBinPptxRW
}
return bRes;
}
_imageManager2Info CImageManager2::GenerateImageExec(const std::wstring& strInput, const std::wstring& sExts, const std::wstring& strOleImage, const std::wstring& oleData)
_imageManager2Info CImageManager2::GenerateImageExec(const std::wstring& strInput, const std::wstring& sExts, const std::wstring& strAdditionalImage, int nAdditionalType, const std::wstring& oleData)
{
OOX::CPath oPathOutput;
_imageManager2Info oImageManagerInfo;
......@@ -305,29 +352,45 @@ namespace NSBinPptxRW
}
oImageManagerInfo.sFilepathImage = oPathOutput.GetPath();
if (!strOleImage.empty() || !oleData.empty() )
if ((!strAdditionalImage.empty() || !oleData.empty() ) && (nAdditionalType == 1))
{
std::wstring strExtsOle = L".bin";
std::wstring strAdditionalExt = L".bin";
int pos = (int)strOleImage.rfind(L".");
if (pos >= 0) strExtsOle = strOleImage.substr(pos);
int pos = (int)strAdditionalImage.rfind(L".");
if (pos >= 0) strAdditionalExt = strAdditionalImage.substr(pos);
std::wstring strImageOle = L"oleObject" + std::to_wstring(++m_lIndexNextOle) + strExtsOle;
std::wstring strImageAdditional = L"oleObject" + std::to_wstring(++m_lIndexCounter) + strAdditionalExt;
OOX::CPath pathOutputOle = m_strDstEmbed + FILE_SEPARATOR_STR + strImageOle;
OOX::CPath pathOutput = m_strDstEmbed + FILE_SEPARATOR_STR + strImageAdditional;
std::wstring strOleImageOut = pathOutputOle.GetPath();
std::wstring strAdditionalImageOut = pathOutput.GetPath();
if(!oleData.empty())
{
WriteOleData(strOleImageOut, oleData);
WriteOleData(strAdditionalImageOut, oleData);
}
else
{
CDirectory::CopyFile(strOleImage, strOleImageOut);
CDirectory::CopyFile(strAdditionalImage, strAdditionalImageOut);
}
oImageManagerInfo.sFilepathOle = strOleImageOut;
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
}
else if (!strAdditionalImage.empty() && nAdditionalType == 2)
{
std::wstring strAdditionalExt;
int pos = (int)strAdditionalImage.rfind(L".");
if (pos >= 0) strAdditionalExt = strAdditionalImage.substr(pos);
std::wstring strImageAdditional = L"media" + std::to_wstring(++m_lIndexCounter) + strAdditionalExt;
OOX::CPath pathOutput = m_strDstMedia + FILE_SEPARATOR_STR + strImageAdditional;
std::wstring strAdditionalImageOut = pathOutput.GetPath();
CDirectory::CopyFile(strAdditionalImage, strAdditionalImageOut);
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
}
return oImageManagerInfo;
......@@ -372,7 +435,6 @@ namespace NSBinPptxRW
strExts = strUrl.substr(nIndexExt);
std::wstring strImage;
std::wstring strOleImage;
int nDisplayType = IsDisplayedImage(strUrl);
......@@ -380,11 +442,6 @@ namespace NSBinPptxRW
{
std::wstring strInputMetafile = strUrl.substr(0, strUrl.length() - strExts.length());
std::wstring sDownloadRes;
//todo
if(0 != (nDisplayType & 4))
{
strOleImage = DownloadImageExec(strInputMetafile + _T(".bin"));
}
if(0 != (nDisplayType & 1))
{
......@@ -414,11 +471,9 @@ namespace NSBinPptxRW
_imageManager2Info oImageManagerInfo;
if (!strImage.empty())
{
oImageManagerInfo = GenerateImageExec(strImage, strExts, strOleImage, L"");
oImageManagerInfo = GenerateImageExec(strImage, strExts, L"", 0, L"");
CDirectory::DeleteFile(strImage);
}
if (!strOleImage.empty())
CDirectory::DeleteFile(strOleImage);
m_mapImages[strUrl] = oImageManagerInfo;
return oImageManagerInfo;
......@@ -1166,9 +1221,9 @@ namespace NSBinPptxRW
oFile.CloseFile();
}
_relsGeneratorInfo CRelsGenerator::WriteImage(const std::wstring& strImage, smart_ptr<OOX::OleObject> & oleFile, const std::wstring& oleData, std::wstring strBase64Image = _T(""))
_relsGeneratorInfo CRelsGenerator::WriteImage(const std::wstring& strImage, smart_ptr<OOX::File> & additionalFile, const std::wstring& oleData, std::wstring strBase64Image = _T(""))
{
_imageManager2Info oImageManagerInfo = m_pManager->GenerateImage(strImage, oleFile, oleData, strBase64Image);
_imageManager2Info oImageManagerInfo = m_pManager->GenerateImage(strImage, additionalFile, oleData, strBase64Image);
std::wstring strImageRelsPath;
......@@ -1194,8 +1249,10 @@ namespace NSBinPptxRW
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\" Target=\"" + strImageRelsPath +
L"\"/>");
if( oleFile.IsInit() )
if(additionalFile.is<OOX::OleObject>())
{
smart_ptr<OOX::OleObject> oleFile = additionalFile.smart_dynamic_cast<OOX::OleObject>();
std::wstring strOleRelsPath;
oRelsGeneratorInfo.nOleRId = m_lNextRelsID++;
......
......@@ -48,7 +48,7 @@ class COfficeFontPicker;
namespace OOX
{
class OleObject;
class File;
class CContentTypes;
class WritingElement;
class IFileContainer;
......@@ -91,7 +91,7 @@ namespace NSBinPptxRW
struct _imageManager2Info
{
std::wstring sFilepathOle;
std::wstring sFilepathAdditional;
std::wstring sFilepathImage;
};
......@@ -99,7 +99,9 @@ namespace NSBinPptxRW
{
int nImageRId;
int nOleRId;
int nMediaRId;
std::wstring sFilepathMedia;
std::wstring sFilepathOle;
std::wstring sFilepathImage;
......@@ -107,6 +109,7 @@ namespace NSBinPptxRW
{
nImageRId = -1;
nOleRId = -1;
nMediaRId = -1;
}
};
......@@ -158,17 +161,13 @@ namespace NSBinPptxRW
NSShapeImageGen::CImageManager* m_pImageManager;
//NSFontCutter::CFontDstManager m_oFontPicker;
NSFontCutter::CFontDstManager* m_pNativePicker;
COfficeFontPicker* m_pFontPicker;
bool m_bDeleteFontPicker;
public:
CCommonWriter();
~CCommonWriter();
public:
void CreateFontPicker(COfficeFontPicker* pPicker);
void CheckFontPicker();
};
......@@ -178,7 +177,7 @@ namespace NSBinPptxRW
private:
std::map<std::wstring, _imageManager2Info> m_mapImages;
_INT32 m_lIndexNextImage;
_INT32 m_lIndexNextOle;
_INT32 m_lIndexCounter;
std::wstring m_strDstMedia;
std::wstring m_strDstEmbed;
public:
......@@ -197,8 +196,8 @@ namespace NSBinPptxRW
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 GenerateImageExec(const std::wstring& strInput, const std::wstring& strExts, const std::wstring& strOleImage, const std::wstring& oleData);
_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& strAdditionalImage, int nAdditionalType, const std::wstring& oleData);
void SaveImageAsPng(const std::wstring& strFileSrc, const std::wstring& strFileDst);
void SaveImageAsJPG(const std::wstring& strFileSrc, const std::wstring& strFileDst);
......@@ -426,7 +425,7 @@ namespace NSBinPptxRW
void AddRels (const std::wstring& strRels);
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
......
......@@ -104,16 +104,14 @@ namespace NSShapeImageGen
return *this;
}
void SetNameModificator(NSShapeImageGen::ImageType eType, bool bOle)
void SetNameModificator(NSShapeImageGen::ImageType eType, int typeAdditionalFile )
{
std::wstring sPrefix;
int nRes = 0;
if(itWMF == eType)
nRes += 1;
if(itEMF == eType)
nRes += 2;
if(bOle)
nRes += 4;
if(itWMF == eType) nRes += 1;
if(itEMF == eType) nRes += 2;
if(typeAdditionalFile == 1) nRes += 4;
if(typeAdditionalFile == 2) nRes += 8;
if(0 != nRes)
m_sName = L"display" + std::to_wstring(nRes) + L"image";
}
......@@ -199,7 +197,7 @@ namespace NSShapeImageGen
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;
int n1 = (int)strFile.find (L"www");
......@@ -215,16 +213,16 @@ namespace NSShapeImageGen
if (bIsDownload)
{
std::wstring strFile1 = strFile;
std::wstring strFileUrl = strFile;
XmlUtils::replace_all(strFile1, L"\\", L"/");
XmlUtils::replace_all(strFile1, L"http:/", L"http://");
XmlUtils::replace_all(strFile1, L"https:/", L"https://");
XmlUtils::replace_all(strFile1, L"ftp:/", L"ftp://");
XmlUtils::replace_all(strFileUrl, L"\\", L"/");
XmlUtils::replace_all(strFileUrl, L"http:/", L"http://");
XmlUtils::replace_all(strFileUrl, L"https:/", L"https://");
XmlUtils::replace_all(strFileUrl, L"ftp:/", L"ftp://");
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())
return pPair->second;
......@@ -233,7 +231,7 @@ namespace NSShapeImageGen
#ifndef DISABLE_FILE_DOWNLOADER
CFileDownloader oDownloader(strFile1, true);
CFileDownloader oDownloader(strFileUrl, true);
if (oDownloader.DownloadSync())
{
strDownload = oDownloader.GetFilePath();
......@@ -241,21 +239,23 @@ namespace NSShapeImageGen
#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;
CFile oFile;
if (S_OK != oFile.OpenFile(strFile))
return info;
if (strAdditionalFile.empty())
{
CImageInfo info;
CFile oFile;
if (S_OK != oFile.OpenFile(strFile))
return info;
oFile.CloseFile();
}
oFile.CloseFile();
if (-1 == width && -1 == height)
return GenerateImageID(strFile, L"", strOleFile, width, height);
return GenerateImageID(strFile, L"", strOleFile, (std::max)(1.0, width), (std::max)(1.0, height));
if (width < 0 && height < 0) return GenerateImageID(strFile, L"", -1, -1, strAdditionalFile, typeAdditionalFile);
return GenerateImageID(strFile, L"", (std::max)(1.0, width), (std::max)(1.0, height), strAdditionalFile, typeAdditionalFile);
}
void SetFontManager(CFontManager* pFontManager)
{
......@@ -413,12 +413,12 @@ namespace NSShapeImageGen
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;
if(!strUrl.empty()) sMapKey = strUrl;
if(!strOleFile.empty()) sMapKey += strOleFile;
if(!strAdditionalFile.empty()) sMapKey += strAdditionalFile;
CImageInfo oInfo;
std::map<std::wstring, CImageInfo>::iterator pPair = m_mapImagesFile.find(sMapKey);
......@@ -434,26 +434,30 @@ namespace NSShapeImageGen
LONG lImageType = m_oImageExt.GetImageType(strFileName);
bool bVector = (1 == lImageType || 2 == lImageType);
bool bOle = !strOleFile.empty();
bool bOle = !strAdditionalFile.empty() && (typeAdditionalFile == 1);
bool bMedia = !strAdditionalFile.empty() && (typeAdditionalFile == 2);
if(bVector)
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 strSaveItemWE = strSaveDir + std::wstring(oInfo.GetPathWithoutExtension());
//copy ole bin
if(bOle)
//copy ole bin or media
if(bOle || bMedia)
{
std::wstring strExts = _T(".bin");
int nIndexExt = (int)strOleFile.rfind(wchar_t('.'));
std::wstring strExts;
int nIndexExt = (int)strAdditionalFile.rfind(wchar_t('.'));
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";
CDirectory::CopyFile(strOleFile, sCopyOlePath);
std::wstring sCopyOlePath = strSaveItemWE + strExts;
CDirectory::CopyFile(strAdditionalFile, sCopyOlePath);
}
if (bVector)
......
......@@ -86,12 +86,12 @@ namespace PPTX
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)
{
//not implement FileContainer.read
//OOX::IFileContainer::read(rels, path);
}
void FileContainer::read(const OOX::CRels& rels, const OOX::CPath& path, FileMap& map, IPPTXEvent* Event)
{
......@@ -157,8 +157,6 @@ namespace PPTX
pContainer->read(normPath, map, Event);
m_bCancelled = pContainer->m_bCancelled;
}
//todo детально разобраться и вернуть проверку res.(до перехода на cross platform все было хорошо)
//на презентация с hyperlink выходим при достижении 100%. Проценты считаются от количества обработанных файлов, а hyperlink не файл(Ligninger_og_uligheder.pptx)
if (m_bCancelled)
{
break;
......
......@@ -156,5 +156,101 @@ namespace PPTX
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 PPTX
\ No newline at end of file
......@@ -63,16 +63,21 @@ namespace PPTX
link = oSrc.link;
m_namespace = oSrc.m_namespace;
oleRid = oSrc.oleRid;
oleFilepathBin = oSrc.oleFilepathBin;
mediaFilepath = oSrc.mediaFilepath;
return *this;
}
virtual OOX::EElementType getType() const
{
return OOX::et_a_blip;
}
virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
......@@ -81,96 +86,11 @@ namespace PPTX
WritingElement_ReadAttributes_Read_else_if( oReader, _T("cstate"), cstate )
WritingElement_ReadAttributes_End( oReader )
}
virtual void fromXML(XmlUtils::CXmlNode& node);
virtual std::wstring toXML() const;
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;
virtual void 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);
}
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 void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
virtual std::wstring GetFullPicName(OOX::IFileContainer* pRels = NULL)const;
virtual std::wstring GetFullOleName(const OOX::RId& pRId, OOX::IFileContainer* pRels = NULL)const;
......@@ -182,6 +102,8 @@ namespace PPTX
std::wstring m_namespace;
std::wstring oleRid;
std::wstring mediaFilepath;
//internal
std::wstring oleFilepathBin;
std::wstring oleFilepathImage;
......
......@@ -69,6 +69,9 @@ namespace PPTX
dpi = oSrc.dpi;
rotWithShape = oSrc.rotWithShape;
additionalFile = oSrc.additionalFile;
oleData = oSrc.oleData;
m_namespace = oSrc.m_namespace;
return *this;
}
......@@ -432,10 +435,10 @@ namespace PPTX
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);
}
......@@ -445,14 +448,18 @@ namespace PPTX
blip = new PPTX::Logic::Blip();
blip->embed = new OOX::RId((size_t)oRelsGeneratorInfo.nImageRId);
blip->oleFilepathImage = oRelsGeneratorInfo.sFilepathImage;
if(oRelsGeneratorInfo.nOleRId > 0)
{
blip->oleRid = OOX::RId((size_t)oRelsGeneratorInfo.nOleRId).get();
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
break;
}
......@@ -507,8 +514,8 @@ namespace PPTX
nullable_bool rotWithShape;
//internal
smart_ptr<OOX::OleObject> oleFile;
std::wstring oleData;
mutable smart_ptr<OOX::File> additionalFile;
std::wstring oleData;
protected:
virtual void FillParentPointersForChilds()
{
......
......@@ -41,7 +41,10 @@
#include "Media/MediaFile.h"
#include "Media/WavAudioFile.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Media/Audio.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Media/Video.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Media/OleObject.h"
#include "../../../Common/DocxFormat/Source/MathEquation/MathEquation.h"
#include "../../../ASCOfficeDocxFile2/BinWriter/BinEquationWriter.h"
......@@ -136,7 +139,9 @@ namespace PPTX
pWriter->WriteLimit2(6, m_oUpdateMode);
if (ole_file.IsInit() == false || ole_file->isMsPackage() == false)
{
pWriter->WriteString1(7, ole_file->filename().GetFilename()); //OleObject Binary FileName (bin, xls, doc, ... other stream file)
std::wstring sExt = ole_file->filename().GetExtention(false);
if (!sExt.empty())
pWriter->WriteString1(7, L"maskFile." + sExt); //OleObject Binary FileName Extension (bin, xls, doc, ... other stream file)
}
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
......@@ -608,6 +613,137 @@ namespace PPTX
return XmlUtils::CreateNode(m_namespace + L":pic", oValue);
}
void Pic::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
if(oleObject.IsInit())
{
pWriter->StartRecord(SPTREE_TYPE_OLE);
}
else if (nvPicPr.nvPr.media.is_init())
{
blipFill.additionalFile = GetMediaLink();
smart_ptr<OOX::Media> mediaFile = blipFill.additionalFile.smart_dynamic_cast<OOX::Media>();
if (mediaFile.IsInit() && blipFill.blip.IsInit())
{
blipFill.blip->mediaFilepath = mediaFile->filename().GetPath();
}
if (nvPicPr.nvPr.media.as<MediaFile>().name == L"audioFile")
pWriter->StartRecord(SPTREE_TYPE_AUDIO);
else if (nvPicPr.nvPr.media.as<MediaFile>().name == L"videoFile")
pWriter->StartRecord(SPTREE_TYPE_VIDEO);
else
pWriter->StartRecord(SPTREE_TYPE_PIC);
}
else
{
pWriter->StartRecord(SPTREE_TYPE_PIC);
}
if (blipFill.additionalFile.is<OOX::Media>())
{
smart_ptr<OOX::Media> mediaFile = blipFill.additionalFile.smart_dynamic_cast<OOX::Media>();
pWriter->StartRecord(5);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
std::wstring sExt = mediaFile->filename().GetExtention(false);
if (!sExt.empty())
pWriter->WriteString1(0, L"maskFile." + sExt);
//todoo start, end positions ..
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
pWriter->EndRecord();
}
pWriter->WriteRecord2(4, oleObject);
pWriter->WriteRecord1(0, nvPicPr);
pWriter->WriteRecord1(1, blipFill);
pWriter->WriteRecord1(2, spPr);
pWriter->WriteRecord2(3, style);
pWriter->EndRecord();
}
void Pic::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>");
}
}
}
void Pic::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
......@@ -621,9 +757,8 @@ namespace PPTX
{
case 0:
{
nvPicPr.fromPPTY(pReader);
break;
}
nvPicPr.fromPPTY(pReader);
}break;
case 1:
{
blipFill.fromPPTY(pReader);
......@@ -637,19 +772,23 @@ namespace PPTX
if (NSFile::CFileBinary::Exists(oleObject->m_OleObjectFile->filename().GetPath()) == false)
oleObject->m_OleObjectFile->set_filename (blipFill.blip->oleFilepathBin);
}
break;
}
smart_ptr<OOX::Media> mediaFile = blipFill.additionalFile.smart_dynamic_cast<OOX::Media>();
if (mediaFile.IsInit() && blipFill.blip.IsInit())
{
if (NSFile::CFileBinary::Exists(mediaFile->filename().GetPath()) == false)
mediaFile->set_filename (blipFill.blip->mediaFilepath);
}
}break;
case 2:
{
spPr.fromPPTY(pReader);
break;
}
spPr.fromPPTY(pReader);
}break;
case 3:
{
style = new ShapeStyle(L"p");
style->fromPPTY(pReader);
break;
}
style->fromPPTY(pReader);
}break;
case 4:
{
oleObject = new COLEObject();
......@@ -658,15 +797,34 @@ namespace PPTX
if(oleObject->m_sData.IsInit())
blipFill.oleData = oleObject->m_sData.get();
blipFill.oleFile = oleObject->m_OleObjectFile;
blipFill.additionalFile = oleObject->m_OleObjectFile.smart_dynamic_cast<OOX::File>();
}break;
case 5:
{
LONG _end_rec1 = pReader->GetPos() + pReader->GetLong() + 4;
//if (oleObject->m_OleObjectFile.IsInit())
//{
// blipFill.olePath = oleObject->m_OleObjectFile->filename().GetPath();
// if (NSFile::CFileBinary::Exists(blipFill.olePath))
// blipFill.olePath.clear();
//}
break;
pReader->Skip(1); // start attributes
while (true)
{
BYTE _at = pReader->GetUChar_TypeNode();
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
break;
if (0 == _at)
{
std::wstring strMediaFileMask = pReader->GetString2();
smart_ptr<OOX::Media> mediaFile = blipFill.additionalFile.smart_dynamic_cast<OOX::Media>();
if (mediaFile.IsInit())
{
mediaFile->set_filename(strMediaFileMask);
}
}
else
break;
}
pReader->Seek(_end_rec1);
}
default:
{
......@@ -726,57 +884,28 @@ namespace PPTX
return blipFill.blip->GetFullPicName();
return _T("");
}
std::wstring Pic::GetVideoLink()const
smart_ptr<OOX::File> Pic::GetMediaLink()const
{
std::wstring file = _T("");
if (parentFileIs<Slide>())
smart_ptr<OOX::File> file;
if (!parentFileIs<Slide>()) return file;
if (nvPicPr.nvPr.media.is<WavAudioFile>())
{
if (nvPicPr.nvPr.media.is<MediaFile>())
{
if ((nvPicPr.nvPr.media.as<MediaFile>().name == _T("videoFile")) || (nvPicPr.nvPr.media.as<MediaFile>().name == _T("quickTimeFile")))
{
file = parentFileAs<Slide>().GetLinkFromRId(nvPicPr.nvPr.media.as<MediaFile>().link.get());
if (std::wstring (_T("NULL")) == file) // HAVE TRIM
{
if(nvPicPr.nvPr.extLst.size())
{
file = parentFileAs<Slide>().GetLinkFromRId(nvPicPr.nvPr.extLst[0].link.get());
}
}
}
}
return parentFileAs<Slide>().Find(nvPicPr.nvPr.media.as<WavAudioFile>().embed.get());
}
return file;
}
std::wstring Pic::GetAudioLink()const
{
std::wstring file = _T("");
if (parentFileIs<Slide>())
if (nvPicPr.nvPr.media.is<MediaFile>())
{
if (nvPicPr.nvPr.media.is<WavAudioFile>())
{
return parentFileAs<Slide>().GetLinkFromRId(nvPicPr.nvPr.media.as<WavAudioFile>().embed.get());
}
if (nvPicPr.nvPr.media.is<MediaFile>())
file = parentFileAs<Slide>().Find(nvPicPr.nvPr.media.as<MediaFile>().link.get());
smart_ptr<OOX::Media> mediaFile = file.smart_dynamic_cast<OOX::Media>();
if ( mediaFile.IsInit() == false && !nvPicPr.nvPr.extLst.empty())
{
if (nvPicPr.nvPr.media.as<MediaFile>().name == _T("audioFile"))
{
file = parentFileAs<Slide>().GetLinkFromRId(nvPicPr.nvPr.media.as<MediaFile>().link.get());
if (std::wstring (_T("NULL")) == file) // HAVE TRIM
{
if(nvPicPr.nvPr.extLst.size())
{
file = parentFileAs<Slide>().GetLinkFromRId(nvPicPr.nvPr.extLst[0].link.get());
}
}
}
}
}
//todooo - почему везде нулевой то? - сделать по всем поиск по uri
file = parentFileAs<Slide>().Find(nvPicPr.nvPr.extLst[0].link.get());
}
}//удалять ли c UnknownType ???? (если не найден щас генерится)
return file;
}
......
......@@ -237,127 +237,35 @@ namespace PPTX
virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
virtual std::wstring toXML() const;
void fromXMLOle(XmlUtils::CXmlNode& node);
virtual void GetRect(Aggplus::RECT& pRect)const;
virtual std::wstring GetFullPicName()const;
virtual std::wstring GetVideoLink()const;
virtual std::wstring GetAudioLink()const;
smart_ptr<OOX::File> GetMediaLink()const;
DWORD GetFill(UniFill& fill)const;
DWORD GetLine(Ln& line)const;
double GetStTrim () const;
double GetEndTrim () 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 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 fromXMLOle(XmlUtils::CXmlNode& node);
//----------------------------------------------------------------------
NvPicPr nvPicPr;
BlipFill blipFill;
SpPr spPr;
nullable<ShapeStyle> style;
//internal
nullable<COLEObject> oleObject;
std::wstring m_namespace;
nullable<COLEObject> oleObject;
nullable_string m_sClientDataXml;
protected:
virtual void FillParentPointersForChilds();
......
......@@ -37,8 +37,11 @@
#include "CxnSp.h"
#include "SpTree.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 Logic
......@@ -346,8 +349,22 @@ namespace PPTX
}
case SPTREE_TYPE_OLE:
case SPTREE_TYPE_PIC:
case SPTREE_TYPE_AUDIO:
case SPTREE_TYPE_VIDEO:
{
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);
m_elem.reset(p);
break;
......
......@@ -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);
}
......
......@@ -74,7 +74,7 @@ namespace PPTX
}
virtual void read(const OOX::CPath& filename, FileMap& map)
{
//FileContainer::read(filename, map);
//FileContainer::read(filename);
XmlUtils::CXmlNode oNode;
oNode.FromXmlFile(filename.m_strFilename);
......
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Version="8,00"
Name="PPTXFormat"
ProjectGUID="{36636678-AE25-4BE6-9A34-2561D1BCF302}"
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