Commit 9774d1de authored by ElenaSubbotina's avatar ElenaSubbotina

PptFormatReader - add presentation video & audio

parent f5b141ee
......@@ -196,6 +196,15 @@ void NSPresentationEditor::CPPTXWriter::WriteContentTypes()
<Default Extension=\"xml\" ContentType=\"application/xml\" />\
<Default Extension=\"gif\" ContentType=\"image/gif\"/>\
<Default Extension=\"emf\" ContentType=\"image/x-emf\"/>\
<Default Extension=\"wav\" ContentType=\"audio/wav\"/>\
<Default Extension=\"wma\" ContentType=\"audio/x-ms-wma\"/>\
<Default Extension=\"mp3\" ContentType=\"audio/unknown\"/>\
<Default Extension=\"m4a\" ContentType=\"audio/unknown\"/>\
<Default Extension=\"wmv\" ContentType=\"video/x-ms-wmv\"/>\
<Default Extension=\"avi\" ContentType=\"video/avi\"/>\
<Default Extension=\"m4v\" ContentType=\"video/unknown\"/>\
<Default Extension=\"mp4\" ContentType=\"video/unknown\"/>\
<Default Extension=\"mov\" ContentType=\"video/unknown\"/>\
<Default Extension=\"xls\" ContentType=\"application/vnd.ms-excel\"/>\
<Default Extension=\"xlsx\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"/>\
<Default Extension=\"bin\" ContentType=\"application/vnd.openxmlformats-officedocument.oleObject\" />\
......@@ -770,25 +779,14 @@ void NSPresentationEditor::CPPTXWriter::WriteBackground(CStringWriter& oWriter,
void NSPresentationEditor::CPPTXWriter::WriteElement(CStringWriter& oWriter, CRelsGenerator& oRels, IElement* pElement, CLayout* pLayout)
{
CImageElement* pImageElem = dynamic_cast<CImageElement*>(pElement);
if (pImageElem)
{
pImageElem->m_oMetric = m_pDocument->m_oInfo;
pImageElem->NormalizeCoordsByMetric();
if (!pElement) return;
m_pShapeWriter->SetShape(pImageElem);
}
pElement->m_oMetric = m_pDocument->m_oInfo;
pElement->NormalizeCoordsByMetric();
CShapeElement* pShapeElem = dynamic_cast<CShapeElement*>(pElement);
if (pShapeElem)
{
pShapeElem->m_oMetric = m_pDocument->m_oInfo;
pShapeElem->NormalizeCoordsByMetric();
m_pShapeWriter->SetShape(pShapeElem);
}
bool bObject = m_pShapeWriter->SetElement(pElement);
if (pImageElem || pShapeElem)
if (bObject)
{
m_pShapeWriter->SetRelsGenerator(&oRels);
......
......@@ -50,7 +50,7 @@ namespace NSPresentationEditor
CDocument * m_pDocument;
CPPTUserInfo* m_pUserInfo;
CImageManager m_oManager;
CMediaManager m_oManager;
CShapeWriter* m_pShapeWriter;
......
......@@ -37,56 +37,89 @@
namespace NSPresentationEditor
{
class CImageManager
class CMediaManager
{
private:
std::map<std::wstring, std::wstring> m_mapImages;
std::map<std::wstring, std::wstring> m_mapMedia;
long m_lIndexNextAudio;
long m_lIndexNextVideo;
long m_lIndexNextImage;
long m_lIndexNextImage;
std::wstring m_strDstMedia;
public:
CImageManager() : m_lIndexNextImage(0)
CMediaManager() : m_lIndexNextImage(0), m_lIndexNextAudio(0), m_lIndexNextVideo(0)
{
}
~CImageManager()
~CMediaManager()
{
}
inline void Clear()
{
m_mapImages.clear();
m_mapMedia.clear();
m_lIndexNextImage = 0;
m_lIndexNextAudio = 0;
m_lIndexNextVideo = 0;
}
inline std::wstring FindMedia(const std::wstring& strInput)
{
std::map<std::wstring, std::wstring>::iterator pPair = m_mapMedia.find(strInput);
if (m_mapMedia.end() != pPair)
{
return pPair->second;
}
return L"";
}
inline void SetDstMedia(const std::wstring& strDst)
{
m_strDstMedia = strDst;
}
public:
inline std::wstring GenerateImage(const std::wstring& strInput)
inline std::wstring GenerateVideo(const std::wstring& strInput)
{
return GenerateMedia(strInput, L"video", m_lIndexNextVideo, L".avi");
}
inline std::wstring GenerateAudio(const std::wstring& strInput)
{
return GenerateMedia(strInput, L"audio", m_lIndexNextAudio, L".wav");
}
inline std::wstring GenerateImage(const std::wstring& strInput)
{
std::map<std::wstring, std::wstring>::iterator pPair = m_mapImages.find(strInput);
if (m_mapImages.end() != pPair)
return GenerateMedia(strInput, L"image", m_lIndexNextImage, L".png");
}
inline std::wstring GenerateMedia(const std::wstring& strInput, const std::wstring& Template, long & Indexer, const std::wstring& strDefaultExt)
{
std::map<std::wstring, std::wstring>::iterator pPair = m_mapMedia.find(strInput);
if (m_mapMedia.end() != pPair)
{
return pPair->second;
}
if (IsNeedDownload(strInput))
return DownloadImage(strInput);
{
#ifndef DISABLE_FILE_DOWNLOADER
CFileDownloader oDownloader(strInput, TRUE);
if ( oDownloader.DownloadSync() )
{
return GenerateMedia( oDownloader.GetFilePath(), Template, Indexer, strDefaultExt);
}
#endif
}
std::wstring strExts = _T(".jpg");
int nIndexExt = strInput.rfind(wchar_t('.'));
std::wstring strExts = strDefaultExt;
int nIndexExt = strInput.rfind(wchar_t('.'));
if (-1 != nIndexExt)
strExts = strInput.substr(nIndexExt);
if (strExts == _T(".tmp")) strExts = _T(".png");
if (strExts == _T(".tmp")) strExts = strDefaultExt;
std::wstring strImage = L"image" + std::to_wstring(m_lIndexNextImage++);
std::wstring strMediaName = Template + std::to_wstring(++Indexer);
std::wstring strOutput = m_strDstMedia + strImage + strExts;
strImage = _T("../media/") + strImage + strExts;
std::wstring strOutput = m_strDstMedia + strMediaName + strExts;
strMediaName = _T("../media/") + strMediaName + strExts;
// теперь нужно скопировать картинку
// теперь нужно скопировать
if (strOutput != strInput)
{
if (CDirectory::CopyFile(strInput, strOutput) == false)
......@@ -94,8 +127,8 @@ namespace NSPresentationEditor
return L"";
}
}
m_mapImages[strInput] = strImage;
return strImage;
m_mapMedia[strInput] = strMediaName;
return strMediaName;
}
inline bool IsNeedDownload(const std::wstring& strFile)
......@@ -108,18 +141,8 @@ namespace NSPresentationEditor
return true;
return false;
}
inline std::wstring DownloadImage(const std::wstring& strFile)
{
#ifndef DISABLE_FILE_DOWNLOADER
CFileDownloader oDownloader(strFile, TRUE);
if ( oDownloader.DownloadSync() )
{
return GenerateImage( oDownloader.GetFilePath() );
}
#endif
return _T("");
}
};
static std::wstring CorrectXmlString3(const std::wstring & str)
{
std::wstring buffer;
......@@ -128,12 +151,12 @@ namespace NSPresentationEditor
{
switch(str[pos])
{
case '&': buffer.append(_T("&amp;")); break;
case '\"': buffer.append(_T("&quot;")); break;
case '\'': buffer.append(_T("&apos;")); break;
case '<': buffer.append(_T("&lt;")); break;
case '>': buffer.append(_T("&gt;")); break;
default: buffer.append(&str[pos], 1); break;
case '&': buffer.append(_T("&amp;")); break;
case '\"': buffer.append(_T("&quot;")); break;
case '\'': buffer.append(_T("&apos;")); break;
case '<': buffer.append(_T("&lt;")); break;
case '>': buffer.append(_T("&gt;")); break;
default: buffer.append(&str[pos], 1); break;
}
}
return buffer;
......@@ -143,12 +166,12 @@ namespace NSPresentationEditor
private:
NSPresentationEditor::CStringWriter m_oWriter;
int m_lNextRelsID;
std::map<std::wstring, int> m_mapImages;
CImageManager* m_pManager;
std::map<std::wstring, int> m_mapMediaRelsID;
CMediaManager* m_pManager;
std::map<std::wstring, std::wstring> m_mapHyperlinks;
public:
CRelsGenerator(CImageManager* pManager) : m_oWriter(), m_lNextRelsID(1)
CRelsGenerator(CMediaManager* pManager) : m_oWriter(), m_lNextRelsID(1)
{
m_pManager = pManager;
}
......@@ -159,7 +182,7 @@ namespace NSPresentationEditor
{
m_oWriter.ClearNoAttack();
m_lNextRelsID = 1;
m_mapImages.clear();
m_mapMediaRelsID.clear();
m_mapHyperlinks.clear();
}
......@@ -262,23 +285,25 @@ namespace NSPresentationEditor
return strRid;
}
inline std::wstring WriteHyperlinkImage(const std::wstring& strImage, bool bExternal = true)
inline std::wstring WriteHyperlinkMedia(const std::wstring& strMedia, bool bExternal = true, bool newRIdAlways = false, std::wstring strRelsType = L"http://schemas.microsoft.com/office/2007/relationships/media")
{
std::map<std::wstring, int>::iterator pPair = m_mapImages.find(strImage);
if (m_mapImages.end() != pPair)
if (!newRIdAlways)
{
std::wstring strRid = L"rId" + std::to_wstring(pPair->second);
return strRid;
}
std::map<std::wstring, int>::iterator pPair = m_mapMediaRelsID.find(strMedia);
m_mapImages[strImage] = m_lNextRelsID;
if (m_mapMediaRelsID.end() != pPair)
{
std::wstring strRid = L"rId" + std::to_wstring(pPair->second);
return strRid;
}
std::wstring strRid = L"rId" + std::to_wstring(m_lNextRelsID++);
m_mapMediaRelsID[strMedia] = m_lNextRelsID;
}
std::wstring strRid = L"rId" + std::to_wstring(m_lNextRelsID++);
std::wstring strRels = L"<Relationship Id=\"" + strRid + L"\"";
strRels += L" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\"";
strRels += L" Target=\"" + strImage + L"\"";
std::wstring strRels = L"<Relationship Id=\"" + strRid + L"\"" + L" Type=\"" + strRelsType + L"\""
+ L" Target=\"" + strMedia + L"\"";
if (bExternal)
strRels += L" TargetMode=\"External\"";
......@@ -288,13 +313,45 @@ namespace NSPresentationEditor
return strRid;
}
inline std::wstring WriteImage(const std::wstring& strImagePath)
inline std::wstring WriteHyperlinkImage(const std::wstring& strImage, bool bExternal = true)
{
return WriteHyperlinkMedia(strImage, bExternal, false, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image");
}
inline std::wstring WriteHyperlinkAudio(const std::wstring& strImage, bool bExternal = true)
{
return WriteHyperlinkMedia(strImage, bExternal, false, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio");
}
inline std::wstring WriteHyperlinkVideo(const std::wstring& strImage, bool bExternal = true)
{
return WriteHyperlinkMedia(strImage, bExternal, false, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/video");
}
inline std::wstring WriteMedia(const std::wstring& strMediaPath)
{
std::wstring strMedia = m_pManager->FindMedia(strMediaPath);
if (strMedia.empty()) return WriteHyperlinkMedia(CorrectXmlString3(strMediaPath), true, true);
return WriteHyperlinkMedia(strMedia, false, true);
}
inline std::wstring WriteImage(const std::wstring& strImagePath)
{
std::wstring strImage = m_pManager->GenerateImage(strImagePath);
if (strImage.empty()) return WriteHyperlinkImage(CorrectXmlString3(strImagePath), true);
return WriteHyperlinkImage(strImage, false);
if (strImage.empty()) return WriteHyperlinkImage(CorrectXmlString3(strImagePath), true);
return WriteHyperlinkImage(strImage, false);
}
inline std::wstring WriteAudio(const std::wstring& strAudioPath)
{
std::wstring strAudio = m_pManager->GenerateAudio(strAudioPath);
if (strAudio.empty()) return WriteHyperlinkAudio(CorrectXmlString3(strAudioPath), true);
return WriteHyperlinkAudio(strAudio, false);
}
inline std::wstring WriteVideo(const std::wstring& strVideoPath)
{
std::wstring strVideo = m_pManager->GenerateVideo(strVideoPath);
if (strVideo.empty()) return WriteHyperlinkVideo(CorrectXmlString3(strVideoPath), true);
return WriteHyperlinkVideo(strVideo, false);
}
};
}
......@@ -293,6 +293,31 @@ NSPresentationEditor::CShapeWriter::CShapeWriter()
m_pImageElement = NULL;
m_pShapeElement = NULL;
}
bool NSPresentationEditor::CShapeWriter::SetElement(IElement* pElem)
{
m_pShapeElement = dynamic_cast<CShapeElement*>(pElem);
m_pImageElement = dynamic_cast<CImageElement*>(pElem);
m_pSimpleGraphicsConverter->PathCommandEnd();
m_oMetricInfo = pElem->m_oMetric;
m_oBounds = pElem->m_rcBounds;
m_oTextRect = m_oBounds;
m_bWordArt = false;
m_bTextBox = false;
if (m_pShapeElement)
{
m_pShapeElement->m_oShape.GetTextRect(m_oTextRect);
}
m_oWriter.ClearNoAttack();
m_oWriterPath.ClearNoAttack();
m_oWriterVML.ClearNoAttack();
return (m_pShapeElement || m_pImageElement);
}
std::wstring NSPresentationEditor::CShapeWriter::ConvertLine(CPen & pen)
{
NSPresentationEditor::CStringWriter line_writer;
......@@ -366,7 +391,7 @@ std::wstring NSPresentationEditor::CShapeWriter::ConvertLineEnd(unsigned char ca
}
return sResult;
}
std::wstring NSPresentationEditor::CShapeWriter::ConvertBrush(CBrush & brush)
std::wstring NSPresentationEditor::CShapeWriter::ConvertBrush(CBrush & brush)
{
NSPresentationEditor::CStringWriter brush_writer;
......@@ -458,7 +483,7 @@ std::wstring NSPresentationEditor::CShapeWriter::ConvertBrush(CBrush & brush)
return brush_writer.GetData();
}
std::wstring NSPresentationEditor::CShapeWriter::ConvertShadow(CShadow & shadow)
std::wstring NSPresentationEditor::CShapeWriter::ConvertShadow(CShadow & shadow)
{
std::wstring Preset;
bool Inner = false;
......@@ -575,7 +600,7 @@ std::wstring NSPresentationEditor::CShapeWriter::ConvertShadow(CShadow & shadow)
return shadow_writer.GetData();
}
std::wstring NSPresentationEditor::CShapeWriter::ConvertColor(CColor & color, long alpha)
std::wstring NSPresentationEditor::CShapeWriter::ConvertColor(CColor & color, long alpha)
{
NSPresentationEditor::CStringWriter color_writer;
if (color.m_lSchemeIndex == -1)
......@@ -606,6 +631,9 @@ std::wstring NSPresentationEditor::CShapeWriter::ConvertColor(CColor & color, l
}
void NSPresentationEditor::CShapeWriter::WriteImageInfo()
{
CAudioElement* pAudioElement = dynamic_cast<CAudioElement*>(m_pImageElement);
CVideoElement* pVideoElement = dynamic_cast<CVideoElement*>(m_pImageElement);
m_oWriter.WriteString(std::wstring(L"<p:nvPicPr>"));
std::wstring strShapeID = std::to_wstring(m_lNextShapeID);
......@@ -613,7 +641,11 @@ void NSPresentationEditor::CShapeWriter::WriteImageInfo()
m_oWriter.WriteString(std::wstring(L"<p:cNvPr id=\"") + strShapeID + L"\"" );
if (m_pImageElement->m_sName.empty())
m_pImageElement->m_sName = std::wstring(L"Image ") + strShapeID;
{
if (pAudioElement) m_pImageElement->m_sName = std::wstring(L"Audio ") + strShapeID;
else if (pVideoElement) m_pImageElement->m_sName = std::wstring(L"Video ") + strShapeID;
else m_pImageElement->m_sName = std::wstring(L"Image ") + strShapeID;
}
if (m_pImageElement->m_bHidden) m_oWriter.WriteString(std::wstring(L" hidden=\"1\""));
......@@ -627,14 +659,22 @@ void NSPresentationEditor::CShapeWriter::WriteImageInfo()
// m_oWriter.WriteStringXML(m_pImageElement->m_sDescription);
// m_oWriter.WriteString(std::wstring(L"\""));
//}
m_oWriter.WriteString(std::wstring(L">"));
m_oWriter.WriteString(std::wstring(L"></p:cNvPr><p:cNvPicPr><a:spLocks noGrp=\"1\" noChangeAspect=\"1\"/></p:cNvPicPr>"));
if (pVideoElement || pAudioElement)
{
m_oWriter.WriteString(std::wstring(L"<a:hlinkClick r:id=\"\" action=\"ppaction://media\"/>"));
}
m_oWriter.WriteString(std::wstring(L"</p:cNvPr><p:cNvPicPr><a:picLocks noGrp=\"1\" noChangeAspect=\"1\"/></p:cNvPicPr>"));
++m_lNextShapeID;
m_oWriter.WriteString(std::wstring(L"<p:nvPr>"));
if (-1 != m_pImageElement->m_lPlaceholderType)
{
m_oWriter.WriteString(std::wstring(L"<p:nvPr><p:ph"));
m_oWriter.WriteString(std::wstring(L"<p:ph"));
if (m_pImageElement->m_lPlaceholderType > 0)
m_oWriter.WriteString(std::wstring(L" type=\"") + GetPhType(m_pImageElement->m_lPlaceholderType) + L"\"");
......@@ -644,12 +684,39 @@ void NSPresentationEditor::CShapeWriter::WriteImageInfo()
m_oWriter.WriteString(std::wstring(L" idx=\"") + strIdx + L"\"");
}
m_oWriter.WriteString(std::wstring(L"/></p:nvPr>"));
m_oWriter.WriteString(std::wstring(L"/>"));
}
else
std::wstring sMediaFile;
if ((pVideoElement) && (!pVideoElement->m_strVideoFileName.empty()))
{
m_oWriter.WriteString(std::wstring(L"<p:nvPr/>"));
std::wstring strRid = m_pRels->WriteVideo(pVideoElement->m_strVideoFileName);
m_oWriter.WriteString(L"<a:videoFile r:link=\"" + strRid + L"\"/>");
sMediaFile = pVideoElement->m_strVideoFileName;
}
if ((pAudioElement) && (!pAudioElement->m_strAudioFileName.empty()))
{
std::wstring strRid = m_pRels->WriteAudio(pAudioElement->m_strAudioFileName);
m_oWriter.WriteString(L"<a:audioFile r:link=\"" + strRid + L"\"/>");
sMediaFile = pAudioElement->m_strAudioFileName;
}
if (sMediaFile.empty() == false)
{
std::wstring strRid = m_pRels->WriteMedia(sMediaFile);
if (!strRid.empty())
{
m_oWriter.WriteString(L"<p:extLst><p:ext uri=\"{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}\">\
<p14:media xmlns:p14=\"http://schemas.microsoft.com/office/powerpoint/2010/main\" r:embed=\"" + strRid + L"\"/></p:ext></p:extLst>");
}
}
m_oWriter.WriteString(std::wstring(L"</p:nvPr>"));
std::wstring str2 = _T("</p:nvPicPr>");
m_oWriter.WriteString(str2);
......@@ -1306,7 +1373,7 @@ std::wstring NSPresentationEditor::CShapeWriter::ConvertImage()
strRid = m_pRels->WriteHyperlinkImage(CorrectXmlString3(m_pImageElement->m_sImageName));
}
if (strRid.empty()) return _T("");
if (strRid.empty()) return _T("");
m_oWriter.WriteString(std::wstring(L"<p:pic>"));
......
......@@ -167,53 +167,16 @@ namespace NSPresentationEditor
{
m_lNextShapeID = 1000;
}
AVSINLINE void SetShape(CImageElement* pShapeElem)
{
m_pSimpleGraphicsConverter->PathCommandEnd();
m_pImageElement = pShapeElem;
m_pShapeElement = NULL;
m_oMetricInfo = m_pImageElement->m_oMetric;
m_oBounds = m_pImageElement->m_rcBounds;
m_oTextRect = m_oBounds;
m_bWordArt = false;
m_bTextBox = false;
m_oWriter.ClearNoAttack();
m_oWriterPath.ClearNoAttack();
m_oWriterVML.ClearNoAttack();
}
AVSINLINE void SetShape(CShapeElement* pShapeElem)
{
m_pSimpleGraphicsConverter->PathCommandEnd();
m_pShapeElement = pShapeElem;
m_pImageElement = NULL;
m_oMetricInfo = m_pShapeElement->m_oMetric;
m_oBounds = m_pShapeElement->m_rcBounds;
m_oTextRect = m_oBounds;
m_bWordArt = false;
m_bTextBox = false;
if (m_pShapeElement)
{
m_pShapeElement->m_oShape.GetTextRect(m_oTextRect);
}
m_oWriter.ClearNoAttack();
m_oWriterPath.ClearNoAttack();
m_oWriterVML.ClearNoAttack();
}
bool SetElement(IElement* pElem);
//--------------------------------------------------------------------
std::wstring ConvertShape ();
std::wstring ConvertImage ();
std::wstring ConvertLine (CPen & pen);
std::wstring ConvertShape ();
std::wstring ConvertImage ();
std::wstring ConvertLine (CPen & pen);
std::wstring ConvertShadow (CShadow & shadow);
std::wstring ConvertBrush (CBrush & brush);
std::wstring ConvertLineEnd (unsigned char cap, unsigned char length, unsigned char width);
static std::wstring ConvertColor (CColor & color, long alpha);
std::wstring ConvertLineEnd(unsigned char cap, unsigned char length, unsigned char width);
// тип рендерера-----------------------------------------------------------------------------
virtual HRESULT get_Type(LONG* lType) ;
//-------- Функции для работы со страницей --------------------------------------------------
......
......@@ -236,7 +236,6 @@ public:
{
case NSPresentationEditor::etVideo:
{
//default -> line = false
pElement->m_bLine = false;
for (long i = 0; i < lCount; ++i)
{
......@@ -246,7 +245,6 @@ public:
}
case NSPresentationEditor::etPicture:
{
//default -> line = false
pElement->m_oBrush.Type = c_BrushTypeTexture;
pElement->m_bLine = false;
for (long i = 0; i < lCount; ++i)
......@@ -257,7 +255,6 @@ public:
}
case NSPresentationEditor::etAudio:
{
//default -> line = false
pElement->m_bLine = false;
for (long i = 0; i < lCount; ++i)
{
......@@ -806,7 +803,7 @@ public:
}
inline void SetUpPropertyAudio(CAudioElement* pElement, CTheme* pTheme, CSlideInfo* pInfo, CSlide* pSlide, CProperty* pProperty)
{
SetUpProperty((IElement*)pElement, pTheme, pInfo, pSlide, pProperty);
SetUpPropertyImage((CImageElement*)pElement, pTheme, pInfo, pSlide, pProperty);
}
inline void SetUpPropertyImage(CImageElement* pElement, CTheme* pTheme, CSlideInfo* pInfo, CSlide* pSlide, CProperty* pProperty)
{
......@@ -1362,8 +1359,8 @@ public:
{
CVideoElement* pVideoElem = new CVideoElement();
pVideoElem->m_strVideoFileName = oInfo.m_strFilePath + FILE_SEPARATOR_STR;
pVideoElem->m_strImageFileName = oInfoDefault.m_strFilePath + FILE_SEPARATOR_STR;
pVideoElem->m_strVideoFileName = oInfo.m_strFilePath ;
pVideoElem->m_strImageFileName = oInfoDefault.m_strFilePath + FILE_SEPARATOR_STR;
pElem = (IElement*)pVideoElem;
}
......@@ -1371,7 +1368,8 @@ public:
{
CAudioElement* pAudioElem = new CAudioElement();
pAudioElem->m_strAudioFileName = oInfo.m_strFilePath + FILE_SEPARATOR_STR;
pAudioElem->m_strAudioFileName = oInfo.m_strFilePath;
pAudioElem->m_strImageFileName = oInfoDefault.m_strFilePath + FILE_SEPARATOR_STR;
pAudioElem->m_dClipStartTime = oInfo.m_dStartTime;
pAudioElem->m_dClipEndTime = oInfo.m_dEndTime;
......
......@@ -1058,10 +1058,6 @@
RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\CommentsWriter.h"
>
</File>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\ContentTypesWriter.h"
>
</File>
<File
RelativePath="..\PPTXWriter\Converter.cpp"
>
......
......@@ -200,8 +200,6 @@ namespace NSPresentationEditor
return m_lCountRef;
}
public:
IElement()
{
m_bIsBackground = false;
......@@ -338,12 +336,5 @@ namespace NSPresentationEditor
virtual void SetupProperty(CSlide* pSlide, CTheme* pTheme, CLayout* pLayout, CElementProperty* pProperty) = 0;
virtual IElement* CreateDublicate() = 0;
virtual std::wstring SerializeToXml()
{
std::wstring strElement;
// strElement.Format(_T("<Element type='%d' id='%d' lid='%d' pid='%d' ptp='%d' />"),
// (int)m_etType, m_lID, m_lLayoutID, m_lPlaceholderID, m_lPlaceholderType);
return strElement;
}
};
}
......@@ -330,73 +330,9 @@ namespace NSPresentationEditor
m_bImagePresent = false;
}
virtual ~CImageElement()
{
}
virtual void WriteToXml(XmlUtils::CXmlWriter& oWriter)
{
std::wstring strXml = SaveToXML();
oWriter.WriteString(strXml);
}
virtual void ReadFromXml(XmlUtils::CXmlNode& oNode)
{
}
virtual std::wstring SaveToXML()
{
std::wstring strEffect;
// if (!m_oAnimations.m_arAnimations.empty())
// return ToAnimationXml();
// LONG lFlags = 0;
// if (m_bFlipH)
// lFlags |= 0x0001;
// if (m_bFlipV)
// lFlags |= 0x0002;
// strEffect.Format(_T("<ImagePaint-DrawImageFromFile left='%d' top='%d' right='%d' bottom='%d' angle='%lf' flags='%d' filepath='%ls' metric='0' backcolor='-1' scaletype='-1' scalecolor='255' widthmetric='%d' heightmetric='%d'>\
// <timeline type='1' begin='%lf' end='%lf' fadein='0' fadeout='0' completeness='1.0' /></ImagePaint-DrawImageFromFile>"),
// (LONG)m_rcBounds.left, (LONG)m_rcBounds.top, (LONG)m_rcBounds.right, (LONG)m_rcBounds.bottom,
// m_dRotate, lFlags, m_strImageFileName,
// m_oMetric.m_lMillimetresHor, m_oMetric.m_lMillimetresVer,
// m_dStartTime, m_dEndTime);
return strEffect;
}
// std::wstring ToAnimationXml()
// {
// LONG lFlags = 0;
// if (m_bFlipH)
// lFlags |= 0x0001;
// if (m_bFlipV)
// lFlags |= 0x0002;
// std::wstring strEffect = _T("");
// strEffect.Format(_T("<ImagePaint-DrawImageFromFile left='%d' top='%d' right='%d' bottom='%d' angle='%lf' flags='%d' filepath='%ls' metric='0' backcolor='-1' scaletype='-1' scalecolor='255' widthmetric='%d' heightmetric='%d'>\
// <timeline type='1' begin='%lf' end='%lf' fadein='0' fadeout='0' completeness='1.0' /></ImagePaint-DrawImageFromFile>"),
// (LONG)m_rcBounds.left, (LONG)m_rcBounds.top, (LONG)m_rcBounds.right, (LONG)m_rcBounds.bottom,
// m_dRotate, lFlags, m_strImageFileName,
// m_oMetric.m_lMillimetresHor, m_oMetric.m_lMillimetresVer,
// m_dStartTime, m_dEndTime);
// std::wstring TimeLine;
// TimeLine.Format ( _T("<timeline type = \"1\" begin=\"%f\" end=\"%f\" fadein=\"0\" fadeout=\"0\" completeness=\"1.0\"/> "),
// m_dStartTime, m_dEndTime );
// std::wstring Source = m_oAnimations.ToXml(m_dStartTime, m_dEndTime);
// Source += TimeLine;
// Source += _T("</ImagePaint-DrawImageFromFileAnimate>");
// strEffect.Replace ( _T("</ImagePaint-DrawImageFromFile>"), Source );
// strEffect.Replace ( _T("<ImagePaint-DrawImageFromFile"), _T("<ImagePaint-DrawImageFromFileAnimate") );
// return strEffect;
// }
virtual IElement* CreateDublicate()
{
CImageElement* pImageElement = new CImageElement();
......@@ -925,7 +861,7 @@ namespace NSPresentationEditor
};
class CAudioElement : public IElement
class CAudioElement : public CImageElement
{
public:
std::wstring m_strAudioFileName;
......@@ -938,8 +874,7 @@ namespace NSPresentationEditor
double m_dClipEndTime;
bool m_bLoop;
public:
CAudioElement() : IElement()
CAudioElement() : CImageElement()
{
m_etType = etAudio;
......@@ -957,60 +892,11 @@ namespace NSPresentationEditor
{
}
virtual std::wstring SaveToXML()
{
std::wstring element;
// element.Format(_T("<AudioSource StartTime='%lf' Duration='%lf' Amplify='%lf'>"), m_dStartTime, m_dEndTime-m_dStartTime, (double)m_nAmplify);
// int lIndex = m_strAudioFileName.find(L"file:///");
// if (0 == lIndex)
// {
// m_strAudioFileName = m_strAudioFileName.substr(8);
// //m_strFileName.Replace('/', '\\');
// //m_strFileName.Replace(L"%20", L" ");
// }
// std::wstring strFileName = m_strAudioFileName;
// CorrectXmlString(strFileName);
// std::wstring source;
// source.Format(_T("<Source StartTime='%lf' EndTime='%lf' FilePath='%ls' loop='%d' />"), m_dClipStartTime, m_dClipEndTime, strFileName, m_bLoop);
// element += source;
// std::wstring animations;
// if(!m_oAnimations.m_arAnimations.empty()) // для audio только "media call's" - play - pause - stop
// {
// m_oAnimations.m_dSlideWidth = m_oMetric.m_lMillimetresHor;
// m_oAnimations.m_dSlideHeight = m_oMetric.m_lMillimetresVer;
// animations = m_oAnimations.ToXml(m_dStartTime, m_dEndTime);
// element += animations;
// }
// std::wstring timeLine;
// timeLine.Format ( _T("<timeline type = \"1\" begin=\"%f\" end=\"%f\" fadein=\"0\" fadeout=\"0\" completeness=\"1.0\"/> "), m_dStartTime, m_dEndTime );
// element += timeLine;
// element += _T("</AudioSource>");
return element;
}
virtual void WriteToXml(XmlUtils::CXmlWriter& oWriter)
{
std::wstring strXml = SaveToXML();
oWriter.WriteString(strXml);
}
virtual void ReadFromXml(XmlUtils::CXmlNode& oNode)
{
}
virtual IElement* CreateDublicate()
{
CAudioElement* pAudioElement = new CAudioElement();
SetProperiesToDublicate((IElement*)pAudioElement);
SetProperiesToDublicate((CImageElement*)pAudioElement);
pAudioElement->m_strAudioFileName = m_strAudioFileName;
pAudioElement->m_nAmplify = m_nAmplify;
......@@ -1041,7 +927,6 @@ namespace NSPresentationEditor
bool m_bLoop;
public:
CVideoElement() : CImageElement()
{
m_etType = etVideo;
......@@ -1057,31 +942,12 @@ namespace NSPresentationEditor
virtual ~CVideoElement()
{
}
virtual void WriteToXml(XmlUtils::CXmlWriter& oWriter)
{
std::wstring strXml = SaveToXML();
oWriter.WriteString(strXml);
}
virtual void ReadFromXml(XmlUtils::CXmlNode& oNode)
{
}
virtual std::wstring SaveToXML()
{
return L""; //GetVideoStream () + GetAudioStream ();
}
std::wstring ToAnimationXml()
{
return L"";
}
virtual IElement* CreateDublicate()
{
CVideoElement* pVideoElement = new CVideoElement();
SetProperiesToDublicate((IElement*)pVideoElement);
SetProperiesToDublicate((CImageElement*)pVideoElement);
pVideoElement->m_strVideoFileName = m_strVideoFileName;
pVideoElement->m_nAlpha = m_nAlpha;
......@@ -1098,83 +964,6 @@ namespace NSPresentationEditor
virtual void SetupProperty(CSlide* pSlide, CTheme* pTheme, CLayout* pLayout, CElementProperty* pProperty)
{
}
// inline std::wstring GetVideoStream ()
// {
// int lIndex = m_strVideoFileName.find(L"file:///");
// if (0 == lIndex)
// {
// m_strVideoFileName = m_strVideoFileName.substr(8);
// /*m_strFileName.Replace('/', '\\');*/
// }
// std::wstring strFileName = m_strVideoFileName;
// CorrectXmlString(strFileName);
// std::wstring element;
// element.Format ( L"<VideoStream left='%d' top='%d' right='%d' bottom='%d' angle='%f' loop='%d' \
//widthmetric='%d' heightmetric='%d' file='%ls' begin='%f' end='%f' >",
// (LONG)m_rcBounds.left, (LONG)m_rcBounds.top, (LONG)m_rcBounds.right, (LONG)m_rcBounds.bottom, m_dRotate, m_bLoop,
// m_oMetric.m_lMillimetresHor, m_oMetric.m_lMillimetresVer,
// strFileName, m_dClipStartTime, m_dClipEndTime );
// std::wstring animations;
// if(!m_oAnimations.m_arAnimations.empty())
// {
// m_oAnimations.m_dSlideWidth = m_oMetric.m_lMillimetresHor;
// m_oAnimations.m_dSlideHeight = m_oMetric.m_lMillimetresVer;
// animations = m_oAnimations.ToXml(m_dStartTime, m_dEndTime);
// element += animations;
// }
// std::wstring timeLine;
// timeLine.Format ( L"<timeline type = \"1\" begin=\"%f\" end=\"%f\" fadein=\"0\" fadeout=\"0\" completeness=\"1.0\"/> ", m_dStartTime, m_dEndTime );
// element += timeLine;
// element += L"</VideoStream>";
// return element;
// }
// inline std::wstring GetAudioStream ()
// {
// std::wstring element;
// element.Format(L"<AudioSource StartTime='%lf' Duration='%lf' Amplify='%lf' loop='%d' >", m_dStartTime, m_dEndTime - m_dStartTime, 100.0, m_bLoop);
// int lIndex = m_strVideoFileName.find(L"file:///");
// if (0 == lIndex)
// {
// m_strVideoFileName = m_strVideoFileName.substr(8);
// //m_strFileName.Replace('/', '\\');
// //m_strFileName.Replace(L"%20", L" ");
// }
// std::wstring strFileName = m_strVideoFileName;
// CorrectXmlString(strFileName);
// std::wstring source;
// source.Format(L"<Source StartTime='%lf' EndTime='%lf' FilePath='%ls'/>", m_dClipStartTime, m_dClipEndTime, strFileName);
// element += source;
// std::wstring animations;
// if(!m_oAnimations.m_arAnimations.empty()) // для audio только "media call's" - play - pause - stop
// {
// m_oAnimations.m_dSlideWidth = m_oMetric.m_lMillimetresHor;
// m_oAnimations.m_dSlideHeight = m_oMetric.m_lMillimetresVer;
// animations = m_oAnimations.ToXml(m_dStartTime, m_dEndTime);
// element += animations;
// }
// std::wstring timeLine;
// timeLine.Format ( L"<timeline type = \"1\" begin=\"%f\" end=\"%f\" fadein=\"0\" fadeout=\"0\" completeness=\"1.0\"/> ", m_dStartTime, m_dEndTime );
// element += timeLine;
// element += L"</AudioSource>";
// return element;
// }
};
}
......
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