Commit c30161db authored by ElenaSubbotina's avatar ElenaSubbotina

.

parent 1244048c
......@@ -178,7 +178,13 @@ namespace NSBinPptxRW
std::map<std::wstring, _imageManager2Info>::const_iterator pPair = m_mapImages.find ((strBase64Image.empty()) ? strInput : strBase64Image);
if (pPair != m_mapImages.end())
{
smart_ptr<OOX::Media> mediaFile = additionalFile.smart_dynamic_cast<OOX::Media>();
if (mediaFile.IsInit())
mediaFile->set_filename(pPair->second.sFilepathAdditional);
return pPair->second;
}
std::wstring strExts = _T(".jpg");
int nIndexExt = (int)strInput.rfind(wchar_t('.'));
......@@ -1279,7 +1285,29 @@ namespace NSBinPptxRW
}
}
}
if(additionalFile.is<OOX::Media>())
{
smart_ptr<OOX::Media> mediaFile = additionalFile.smart_dynamic_cast<OOX::Media>();
std::wstring strMediaRelsPath;
oRelsGeneratorInfo.nMediaRId = m_lNextRelsID++;
oRelsGeneratorInfo.sFilepathOle = mediaFile->filename().GetPath();
if (m_pManager->m_nDocumentType != XMLWRITER_DOC_TYPE_XLSX)
{
std::wstring strRid = L"rId" + std::to_wstring(oRelsGeneratorInfo.nMediaRId);
if (m_pManager->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX) strMediaRelsPath = L"media/";
else strMediaRelsPath = L"../media/";
strMediaRelsPath += mediaFile->filename().GetFilename();
m_pWriter->WriteString( L"<Relationship Id=\"" + strRid
+ L"\" Type=\"http://schemas.microsoft.com/office/2007/relationships/media\" Target=\"" +
strMediaRelsPath + L"\"/>");
}
}
m_mapImages.insert(std::pair<std::wstring, _relsGeneratorInfo>(strImageRelsPath, oRelsGeneratorInfo));
return oRelsGeneratorInfo;
}
......
......@@ -165,12 +165,26 @@ namespace PPTX
XmlUtils::CAttribute oAttr;
XmlUtils::CNodeValue oValue;
return XmlUtils::CreateNode(_T("p:ext"), oValue);
return XmlUtils::CreateNode(L"p:ext", oValue);
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
// TODO:
if (link.IsInit() && uri.IsInit())
{
pWriter->StartNode(L"p:ext");
pWriter->StartAttributes();
pWriter->WriteAttribute(L"uri", *uri);
pWriter->EndAttributes();
pWriter->StartNode(L"p14:media");
pWriter->StartAttributes();
pWriter->WriteAttribute(L"xmlns:p14", std::wstring(L"http://schemas.microsoft.com/office/powerpoint/2010/main"));
pWriter->WriteAttribute(L"r:embed", link->get());
pWriter->EndAttributes();
pWriter->EndNode(L"p14:media");
pWriter->EndNode(L"p:ext");
}
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
......
......@@ -224,6 +224,11 @@ namespace PPTX
additionalPath = this->GetFullOleName(OOX::RId(oleRid), pRels);
additionalType = 1;
}
else if(!mediaRid.empty())
{
additionalPath = this->GetFullOleName(OOX::RId(mediaRid), pRels);
additionalType = 2;
}
else if(!mediaFilepath.empty())
{
additionalPath = mediaFilepath;
......
......@@ -67,6 +67,7 @@ namespace PPTX
oleRid = oSrc.oleRid;
oleFilepathBin = oSrc.oleFilepathBin;
mediaRid = oSrc.mediaRid;
mediaFilepath = oSrc.mediaFilepath;
return *this;
......@@ -100,11 +101,11 @@ namespace PPTX
nullable<OOX::RId> embed;
nullable<OOX::RId> link;
std::wstring m_namespace;
//internal
std::wstring mediaRid;
std::wstring mediaFilepath;
std::wstring oleRid;
std::wstring mediaFilepath;
//internal
std::wstring oleFilepathBin;
std::wstring oleFilepathImage;
protected:
......
......@@ -457,7 +457,7 @@ namespace PPTX
}
if(oRelsGeneratorInfo.nMediaRId > 0)
{
//blip->nMediaRId = OOX::RId((size_t)oRelsGeneratorInfo.nOleRId).get();
blip->mediaRid = OOX::RId((size_t)oRelsGeneratorInfo.nMediaRId).get();
blip->mediaFilepath = oRelsGeneratorInfo.sFilepathMedia;
}
pReader->Skip(1); // end attribute
......
......@@ -45,8 +45,9 @@ namespace PPTX
public:
WritingElement_AdditionConstructors(MediaFile)
MediaFile()
MediaFile(std::wstring name_)
{
name = name_;
}
MediaFile& operator=(const MediaFile& oSrc)
......@@ -75,19 +76,28 @@ namespace PPTX
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:link"), link)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("contentType"), contentType)
WritingElement_ReadAttributes_Read_if ( oReader, L"r:link", link)
WritingElement_ReadAttributes_Read_else_if ( oReader, L"contentType", contentType)
WritingElement_ReadAttributes_End( oReader )
}
virtual std::wstring toXML() const
{
XmlUtils::CAttribute oAttr;
oAttr.Write(_T("r:link"), link.ToString());
oAttr.Write(_T("contentType"), contentType);
oAttr.Write(L"r:link", link.ToString());
oAttr.Write(L"contentType", contentType);
return XmlUtils::CreateNode(_T("a:") + name, oAttr);
return XmlUtils::CreateNode(L"a:" + name, oAttr);
}
public:
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
pWriter->StartNode(L"a:" + name);
pWriter->StartAttributes();
pWriter->WriteAttribute (L"r:link", link.ToString());
pWriter->WriteAttribute (L"contentType", contentType);
pWriter->EndAttributes();
pWriter->EndNode(L"a:" + name);
}
std::wstring name;
OOX::RId link;
nullable_string contentType;
......
......@@ -832,16 +832,53 @@ namespace PPTX
}
}
}
if(blipFill.blip.IsInit() && !blipFill.blip->oleRid.empty() && oleObject.IsInit())
if(blipFill.blip.IsInit() && blipFill.additionalFile.IsInit())
{
oleObject->m_oId = OOX::RId(blipFill.blip->oleRid);
if (!blipFill.blip->oleRid.empty() && oleObject.IsInit())
{
oleObject->m_oId = OOX::RId(blipFill.blip->oleRid);
if (oleObject->m_OleObjectFile.IsInit() == false)
if (oleObject->m_OleObjectFile.IsInit() == false)
{
oleObject->m_OleObjectFile = new OOX::OleObject(false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
oleObject->m_OleObjectFile->set_filename (blipFill.blip->oleFilepathBin);
oleObject->m_OleObjectFile->set_filename_cache (blipFill.blip->oleFilepathImage);
}
}
if (!blipFill.blip->mediaRid.empty())
{
oleObject->m_OleObjectFile = new OOX::OleObject(false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
oleObject->m_OleObjectFile->set_filename (blipFill.blip->oleFilepathBin);
oleObject->m_OleObjectFile->set_filename_cache (blipFill.blip->oleFilepathImage);
PPTX::Logic::Ext ext;
ext.link = OOX::RId(blipFill.blip->mediaRid);
ext.uri = L"{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}";
nvPicPr.nvPr.extLst.push_back(ext);
int nRId = -1;
if (blipFill.additionalFile.is<OOX::Audio>())
{
nvPicPr.nvPr.media.Media = new PPTX::Logic::MediaFile(L"audioFile");
nRId = pReader->m_pRels->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio",
L"NULL", L"External");
}
if (blipFill.additionalFile.is<OOX::Video>())
{
nvPicPr.nvPr.media.Media = new PPTX::Logic::MediaFile(L"videoFile");
nRId = pReader->m_pRels->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/video",
L"NULL", L"External");
}
if (nvPicPr.nvPr.media.Media.IsInit() && nRId > 0)
{
PPTX::Logic::MediaFile& mediaFile = nvPicPr.nvPr.media.Media.as<PPTX::Logic::MediaFile>();
mediaFile.link = OOX::RId((size_t)nRId);
}
if (nvPicPr.cNvPr.hlinkClick.IsInit() == false)
nvPicPr.cNvPr.hlinkClick.Init();
nvPicPr.cNvPr.hlinkClick->id = L"";
nvPicPr.cNvPr.hlinkClick->action = L"ppaction://media";
}
}
......
......@@ -455,7 +455,11 @@ namespace PPTX
pFill->blip->oleRid = OOX::RId((size_t)oRelsGeneratorInfo.nOleRId).get();
pFill->blip->oleFilepathBin = oRelsGeneratorInfo.sFilepathOle;
}
if(oRelsGeneratorInfo.nMediaRId > 0)
{
pFill->blip->mediaRid = OOX::RId((size_t)oRelsGeneratorInfo.nMediaRId).get();
pFill->blip->mediaFilepath = oRelsGeneratorInfo.sFilepathMedia;
}
pReader->Skip(1); // end attribute
break;
}
......
......@@ -107,16 +107,13 @@ namespace PPTX
return Media->toXML();
return _T("");
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
// TODO:
}
virtual void toPPTY(NSBinPptxRW::CXmlWriter* pWriter) const
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
// TODO:
if (Media.is_init())
Media->toXmlWriter(pWriter);
}
......@@ -126,8 +123,7 @@ namespace PPTX
template<class T> AVSINLINE const bool is() const { return Media.is<T>(); }
template<class T> AVSINLINE T& as() { return Media.as<T>(); }
template<class T> AVSINLINE const T& as() const { return Media.as<T>(); }
//public:
private:
smart_ptr<WrapperWritingElement> Media;
protected:
virtual void FillParentPointersForChilds(){};
......
......@@ -66,7 +66,14 @@ namespace OOX
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("wmf"), _T("image/x-wmf")));
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("svm"), _T("image/svm")));
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("wav"), _T("audio/wav")));
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("xls"), _T("application/vnd.ms-excel")));
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("wma"), _T("audio/x-wma")));
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("m4a"), _T("audio/unknown")));
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("mp3"), _T("audio/mpeg")));
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("mp4"), _T("video/unknown")));
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("mov"), _T("video/unknown")));
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("avi"), _T("video/avi")));
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("wmv"), _T("video/x-wmv")));
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("xls"), _T("application/vnd.ms-excel")));
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("xlsm"), _T("application/vnd.ms-excel.sheet.macroEnabled.12")));
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("xlsb"), _T("application/vnd.ms-excel.sheet.binary.macroEnabled.12")));
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("xlsx"), _T("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")));
......
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