Commit 9774d1de authored by ElenaSubbotina's avatar ElenaSubbotina

PptFormatReader - add presentation video & audio

parent f5b141ee
...@@ -196,6 +196,15 @@ void NSPresentationEditor::CPPTXWriter::WriteContentTypes() ...@@ -196,6 +196,15 @@ void NSPresentationEditor::CPPTXWriter::WriteContentTypes()
<Default Extension=\"xml\" ContentType=\"application/xml\" />\ <Default Extension=\"xml\" ContentType=\"application/xml\" />\
<Default Extension=\"gif\" ContentType=\"image/gif\"/>\ <Default Extension=\"gif\" ContentType=\"image/gif\"/>\
<Default Extension=\"emf\" ContentType=\"image/x-emf\"/>\ <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=\"xls\" ContentType=\"application/vnd.ms-excel\"/>\
<Default Extension=\"xlsx\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"/>\ <Default Extension=\"xlsx\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"/>\
<Default Extension=\"bin\" ContentType=\"application/vnd.openxmlformats-officedocument.oleObject\" />\ <Default Extension=\"bin\" ContentType=\"application/vnd.openxmlformats-officedocument.oleObject\" />\
...@@ -770,25 +779,14 @@ void NSPresentationEditor::CPPTXWriter::WriteBackground(CStringWriter& oWriter, ...@@ -770,25 +779,14 @@ void NSPresentationEditor::CPPTXWriter::WriteBackground(CStringWriter& oWriter,
void NSPresentationEditor::CPPTXWriter::WriteElement(CStringWriter& oWriter, CRelsGenerator& oRels, IElement* pElement, CLayout* pLayout) void NSPresentationEditor::CPPTXWriter::WriteElement(CStringWriter& oWriter, CRelsGenerator& oRels, IElement* pElement, CLayout* pLayout)
{ {
CImageElement* pImageElem = dynamic_cast<CImageElement*>(pElement); if (!pElement) return;
if (pImageElem)
{
pImageElem->m_oMetric = m_pDocument->m_oInfo;
pImageElem->NormalizeCoordsByMetric();
m_pShapeWriter->SetShape(pImageElem); pElement->m_oMetric = m_pDocument->m_oInfo;
} pElement->NormalizeCoordsByMetric();
CShapeElement* pShapeElem = dynamic_cast<CShapeElement*>(pElement); bool bObject = m_pShapeWriter->SetElement(pElement);
if (pShapeElem)
{
pShapeElem->m_oMetric = m_pDocument->m_oInfo;
pShapeElem->NormalizeCoordsByMetric();
m_pShapeWriter->SetShape(pShapeElem);
}
if (pImageElem || pShapeElem) if (bObject)
{ {
m_pShapeWriter->SetRelsGenerator(&oRels); m_pShapeWriter->SetRelsGenerator(&oRels);
......
...@@ -50,7 +50,7 @@ namespace NSPresentationEditor ...@@ -50,7 +50,7 @@ namespace NSPresentationEditor
CDocument * m_pDocument; CDocument * m_pDocument;
CPPTUserInfo* m_pUserInfo; CPPTUserInfo* m_pUserInfo;
CImageManager m_oManager; CMediaManager m_oManager;
CShapeWriter* m_pShapeWriter; CShapeWriter* m_pShapeWriter;
......
...@@ -37,56 +37,89 @@ ...@@ -37,56 +37,89 @@
namespace NSPresentationEditor namespace NSPresentationEditor
{ {
class CImageManager class CMediaManager
{ {
private: 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; std::wstring m_strDstMedia;
public: public:
CImageManager() : m_lIndexNextImage(0) CMediaManager() : m_lIndexNextImage(0), m_lIndexNextAudio(0), m_lIndexNextVideo(0)
{ {
} }
~CImageManager() ~CMediaManager()
{ {
} }
inline void Clear() inline void Clear()
{ {
m_mapImages.clear(); m_mapMedia.clear();
m_lIndexNextImage = 0; 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) inline void SetDstMedia(const std::wstring& strDst)
{ {
m_strDstMedia = strDst; m_strDstMedia = strDst;
} }
inline std::wstring GenerateVideo(const std::wstring& strInput)
public: {
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) inline std::wstring GenerateImage(const std::wstring& strInput)
{ {
std::map<std::wstring, std::wstring>::iterator pPair = m_mapImages.find(strInput); return GenerateMedia(strInput, L"image", m_lIndexNextImage, L".png");
if (m_mapImages.end() != pPair) }
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; return pPair->second;
} }
if (IsNeedDownload(strInput)) 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"); std::wstring strExts = strDefaultExt;
int nIndexExt = strInput.rfind(wchar_t('.')); int nIndexExt = strInput.rfind(wchar_t('.'));
if (-1 != nIndexExt) if (-1 != nIndexExt)
strExts = strInput.substr(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; std::wstring strOutput = m_strDstMedia + strMediaName + strExts;
strImage = _T("../media/") + strImage + strExts; strMediaName = _T("../media/") + strMediaName + strExts;
// теперь нужно скопировать картинку // теперь нужно скопировать
if (strOutput != strInput) if (strOutput != strInput)
{ {
if (CDirectory::CopyFile(strInput, strOutput) == false) if (CDirectory::CopyFile(strInput, strOutput) == false)
...@@ -94,8 +127,8 @@ namespace NSPresentationEditor ...@@ -94,8 +127,8 @@ namespace NSPresentationEditor
return L""; return L"";
} }
} }
m_mapImages[strInput] = strImage; m_mapMedia[strInput] = strMediaName;
return strImage; return strMediaName;
} }
inline bool IsNeedDownload(const std::wstring& strFile) inline bool IsNeedDownload(const std::wstring& strFile)
...@@ -108,18 +141,8 @@ namespace NSPresentationEditor ...@@ -108,18 +141,8 @@ namespace NSPresentationEditor
return true; return true;
return false; 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) static std::wstring CorrectXmlString3(const std::wstring & str)
{ {
std::wstring buffer; std::wstring buffer;
...@@ -143,12 +166,12 @@ namespace NSPresentationEditor ...@@ -143,12 +166,12 @@ namespace NSPresentationEditor
private: private:
NSPresentationEditor::CStringWriter m_oWriter; NSPresentationEditor::CStringWriter m_oWriter;
int m_lNextRelsID; int m_lNextRelsID;
std::map<std::wstring, int> m_mapImages; std::map<std::wstring, int> m_mapMediaRelsID;
CImageManager* m_pManager; CMediaManager* m_pManager;
std::map<std::wstring, std::wstring> m_mapHyperlinks; std::map<std::wstring, std::wstring> m_mapHyperlinks;
public: public:
CRelsGenerator(CImageManager* pManager) : m_oWriter(), m_lNextRelsID(1) CRelsGenerator(CMediaManager* pManager) : m_oWriter(), m_lNextRelsID(1)
{ {
m_pManager = pManager; m_pManager = pManager;
} }
...@@ -159,7 +182,7 @@ namespace NSPresentationEditor ...@@ -159,7 +182,7 @@ namespace NSPresentationEditor
{ {
m_oWriter.ClearNoAttack(); m_oWriter.ClearNoAttack();
m_lNextRelsID = 1; m_lNextRelsID = 1;
m_mapImages.clear(); m_mapMediaRelsID.clear();
m_mapHyperlinks.clear(); m_mapHyperlinks.clear();
} }
...@@ -262,23 +285,25 @@ namespace NSPresentationEditor ...@@ -262,23 +285,25 @@ namespace NSPresentationEditor
return strRid; 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")
{
if (!newRIdAlways)
{ {
std::map<std::wstring, int>::iterator pPair = m_mapImages.find(strImage); std::map<std::wstring, int>::iterator pPair = m_mapMediaRelsID.find(strMedia);
if (m_mapImages.end() != pPair) if (m_mapMediaRelsID.end() != pPair)
{ {
std::wstring strRid = L"rId" + std::to_wstring(pPair->second); std::wstring strRid = L"rId" + std::to_wstring(pPair->second);
return strRid; return strRid;
} }
m_mapImages[strImage] = m_lNextRelsID; m_mapMediaRelsID[strMedia] = m_lNextRelsID;
}
std::wstring strRid = L"rId" + std::to_wstring(m_lNextRelsID++); std::wstring strRid = L"rId" + std::to_wstring(m_lNextRelsID++);
std::wstring strRels = L"<Relationship Id=\"" + strRid + L"\""; std::wstring strRels = L"<Relationship Id=\"" + strRid + L"\"" + L" Type=\"" + strRelsType + L"\""
strRels += L" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\""; + L" Target=\"" + strMedia + L"\"";
strRels += L" Target=\"" + strImage + L"\"";
if (bExternal) if (bExternal)
strRels += L" TargetMode=\"External\""; strRels += L" TargetMode=\"External\"";
...@@ -288,6 +313,25 @@ namespace NSPresentationEditor ...@@ -288,6 +313,25 @@ namespace NSPresentationEditor
return strRid; return strRid;
} }
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) inline std::wstring WriteImage(const std::wstring& strImagePath)
{ {
std::wstring strImage = m_pManager->GenerateImage(strImagePath); std::wstring strImage = m_pManager->GenerateImage(strImagePath);
...@@ -295,6 +339,19 @@ namespace NSPresentationEditor ...@@ -295,6 +339,19 @@ namespace NSPresentationEditor
if (strImage.empty()) return WriteHyperlinkImage(CorrectXmlString3(strImagePath), true); if (strImage.empty()) return WriteHyperlinkImage(CorrectXmlString3(strImagePath), true);
return WriteHyperlinkImage(strImage, false); 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() ...@@ -293,6 +293,31 @@ NSPresentationEditor::CShapeWriter::CShapeWriter()
m_pImageElement = NULL; m_pImageElement = NULL;
m_pShapeElement = 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) std::wstring NSPresentationEditor::CShapeWriter::ConvertLine(CPen & pen)
{ {
NSPresentationEditor::CStringWriter line_writer; NSPresentationEditor::CStringWriter line_writer;
...@@ -606,6 +631,9 @@ std::wstring NSPresentationEditor::CShapeWriter::ConvertColor(CColor & color, l ...@@ -606,6 +631,9 @@ std::wstring NSPresentationEditor::CShapeWriter::ConvertColor(CColor & color, l
} }
void NSPresentationEditor::CShapeWriter::WriteImageInfo() 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>")); m_oWriter.WriteString(std::wstring(L"<p:nvPicPr>"));
std::wstring strShapeID = std::to_wstring(m_lNextShapeID); std::wstring strShapeID = std::to_wstring(m_lNextShapeID);
...@@ -613,7 +641,11 @@ void NSPresentationEditor::CShapeWriter::WriteImageInfo() ...@@ -613,7 +641,11 @@ void NSPresentationEditor::CShapeWriter::WriteImageInfo()
m_oWriter.WriteString(std::wstring(L"<p:cNvPr id=\"") + strShapeID + L"\"" ); m_oWriter.WriteString(std::wstring(L"<p:cNvPr id=\"") + strShapeID + L"\"" );
if (m_pImageElement->m_sName.empty()) 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\"")); if (m_pImageElement->m_bHidden) m_oWriter.WriteString(std::wstring(L" hidden=\"1\""));
...@@ -627,14 +659,22 @@ void NSPresentationEditor::CShapeWriter::WriteImageInfo() ...@@ -627,14 +659,22 @@ void NSPresentationEditor::CShapeWriter::WriteImageInfo()
// m_oWriter.WriteStringXML(m_pImageElement->m_sDescription); // 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">"));
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:spLocks noGrp=\"1\" noChangeAspect=\"1\"/></p:cNvPicPr>")); m_oWriter.WriteString(std::wstring(L"</p:cNvPr><p:cNvPicPr><a:picLocks noGrp=\"1\" noChangeAspect=\"1\"/></p:cNvPicPr>"));
++m_lNextShapeID; ++m_lNextShapeID;
m_oWriter.WriteString(std::wstring(L"<p:nvPr>"));
if (-1 != m_pImageElement->m_lPlaceholderType) 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) if (m_pImageElement->m_lPlaceholderType > 0)
m_oWriter.WriteString(std::wstring(L" type=\"") + GetPhType(m_pImageElement->m_lPlaceholderType) + L"\""); m_oWriter.WriteString(std::wstring(L" type=\"") + GetPhType(m_pImageElement->m_lPlaceholderType) + L"\"");
...@@ -644,13 +684,40 @@ void NSPresentationEditor::CShapeWriter::WriteImageInfo() ...@@ -644,13 +684,40 @@ void NSPresentationEditor::CShapeWriter::WriteImageInfo()
m_oWriter.WriteString(std::wstring(L" idx=\"") + strIdx + L"\""); 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>"); std::wstring str2 = _T("</p:nvPicPr>");
m_oWriter.WriteString(str2); m_oWriter.WriteString(str2);
} }
......
...@@ -167,53 +167,16 @@ namespace NSPresentationEditor ...@@ -167,53 +167,16 @@ namespace NSPresentationEditor
{ {
m_lNextShapeID = 1000; 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; bool SetElement(IElement* pElem);
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();
}
//-------------------------------------------------------------------- //--------------------------------------------------------------------
std::wstring ConvertShape (); std::wstring ConvertShape ();
std::wstring ConvertImage (); std::wstring ConvertImage ();
std::wstring ConvertLine (CPen & pen); std::wstring ConvertLine (CPen & pen);
std::wstring ConvertShadow (CShadow & shadow); std::wstring ConvertShadow (CShadow & shadow);
std::wstring ConvertBrush (CBrush & brush); 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); 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) ; virtual HRESULT get_Type(LONG* lType) ;
//-------- Функции для работы со страницей -------------------------------------------------- //-------- Функции для работы со страницей --------------------------------------------------
......
...@@ -236,7 +236,6 @@ public: ...@@ -236,7 +236,6 @@ public:
{ {
case NSPresentationEditor::etVideo: case NSPresentationEditor::etVideo:
{ {
//default -> line = false
pElement->m_bLine = false; pElement->m_bLine = false;
for (long i = 0; i < lCount; ++i) for (long i = 0; i < lCount; ++i)
{ {
...@@ -246,7 +245,6 @@ public: ...@@ -246,7 +245,6 @@ public:
} }
case NSPresentationEditor::etPicture: case NSPresentationEditor::etPicture:
{ {
//default -> line = false
pElement->m_oBrush.Type = c_BrushTypeTexture; pElement->m_oBrush.Type = c_BrushTypeTexture;
pElement->m_bLine = false; pElement->m_bLine = false;
for (long i = 0; i < lCount; ++i) for (long i = 0; i < lCount; ++i)
...@@ -257,7 +255,6 @@ public: ...@@ -257,7 +255,6 @@ public:
} }
case NSPresentationEditor::etAudio: case NSPresentationEditor::etAudio:
{ {
//default -> line = false
pElement->m_bLine = false; pElement->m_bLine = false;
for (long i = 0; i < lCount; ++i) for (long i = 0; i < lCount; ++i)
{ {
...@@ -806,7 +803,7 @@ public: ...@@ -806,7 +803,7 @@ public:
} }
inline void SetUpPropertyAudio(CAudioElement* pElement, CTheme* pTheme, CSlideInfo* pInfo, CSlide* pSlide, CProperty* pProperty) 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) inline void SetUpPropertyImage(CImageElement* pElement, CTheme* pTheme, CSlideInfo* pInfo, CSlide* pSlide, CProperty* pProperty)
{ {
...@@ -1362,7 +1359,7 @@ public: ...@@ -1362,7 +1359,7 @@ public:
{ {
CVideoElement* pVideoElem = new CVideoElement(); CVideoElement* pVideoElem = new CVideoElement();
pVideoElem->m_strVideoFileName = oInfo.m_strFilePath + FILE_SEPARATOR_STR; pVideoElem->m_strVideoFileName = oInfo.m_strFilePath ;
pVideoElem->m_strImageFileName = oInfoDefault.m_strFilePath + FILE_SEPARATOR_STR; pVideoElem->m_strImageFileName = oInfoDefault.m_strFilePath + FILE_SEPARATOR_STR;
pElem = (IElement*)pVideoElem; pElem = (IElement*)pVideoElem;
...@@ -1371,7 +1368,8 @@ public: ...@@ -1371,7 +1368,8 @@ public:
{ {
CAudioElement* pAudioElem = new CAudioElement(); 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_dClipStartTime = oInfo.m_dStartTime;
pAudioElem->m_dClipEndTime = oInfo.m_dEndTime; pAudioElem->m_dClipEndTime = oInfo.m_dEndTime;
......
...@@ -1058,10 +1058,6 @@ ...@@ -1058,10 +1058,6 @@
RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\CommentsWriter.h" RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\CommentsWriter.h"
> >
</File> </File>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\ContentTypesWriter.h"
>
</File>
<File <File
RelativePath="..\PPTXWriter\Converter.cpp" RelativePath="..\PPTXWriter\Converter.cpp"
> >
......
...@@ -200,8 +200,6 @@ namespace NSPresentationEditor ...@@ -200,8 +200,6 @@ namespace NSPresentationEditor
return m_lCountRef; return m_lCountRef;
} }
public:
IElement() IElement()
{ {
m_bIsBackground = false; m_bIsBackground = false;
...@@ -338,12 +336,5 @@ namespace NSPresentationEditor ...@@ -338,12 +336,5 @@ namespace NSPresentationEditor
virtual void SetupProperty(CSlide* pSlide, CTheme* pTheme, CLayout* pLayout, CElementProperty* pProperty) = 0; virtual void SetupProperty(CSlide* pSlide, CTheme* pTheme, CLayout* pLayout, CElementProperty* pProperty) = 0;
virtual IElement* CreateDublicate() = 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 ...@@ -330,73 +330,9 @@ namespace NSPresentationEditor
m_bImagePresent = false; m_bImagePresent = false;
} }
virtual ~CImageElement() 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() virtual IElement* CreateDublicate()
{ {
CImageElement* pImageElement = new CImageElement(); CImageElement* pImageElement = new CImageElement();
...@@ -925,7 +861,7 @@ namespace NSPresentationEditor ...@@ -925,7 +861,7 @@ namespace NSPresentationEditor
}; };
class CAudioElement : public IElement class CAudioElement : public CImageElement
{ {
public: public:
std::wstring m_strAudioFileName; std::wstring m_strAudioFileName;
...@@ -938,8 +874,7 @@ namespace NSPresentationEditor ...@@ -938,8 +874,7 @@ namespace NSPresentationEditor
double m_dClipEndTime; double m_dClipEndTime;
bool m_bLoop; bool m_bLoop;
public: CAudioElement() : CImageElement()
CAudioElement() : IElement()
{ {
m_etType = etAudio; m_etType = etAudio;
...@@ -957,60 +892,11 @@ namespace NSPresentationEditor ...@@ -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() virtual IElement* CreateDublicate()
{ {
CAudioElement* pAudioElement = new CAudioElement(); CAudioElement* pAudioElement = new CAudioElement();
SetProperiesToDublicate((IElement*)pAudioElement); SetProperiesToDublicate((CImageElement*)pAudioElement);
pAudioElement->m_strAudioFileName = m_strAudioFileName; pAudioElement->m_strAudioFileName = m_strAudioFileName;
pAudioElement->m_nAmplify = m_nAmplify; pAudioElement->m_nAmplify = m_nAmplify;
...@@ -1041,7 +927,6 @@ namespace NSPresentationEditor ...@@ -1041,7 +927,6 @@ namespace NSPresentationEditor
bool m_bLoop; bool m_bLoop;
public:
CVideoElement() : CImageElement() CVideoElement() : CImageElement()
{ {
m_etType = etVideo; m_etType = etVideo;
...@@ -1058,30 +943,11 @@ namespace NSPresentationEditor ...@@ -1058,30 +943,11 @@ namespace NSPresentationEditor
{ {
} }
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() virtual IElement* CreateDublicate()
{ {
CVideoElement* pVideoElement = new CVideoElement(); CVideoElement* pVideoElement = new CVideoElement();
SetProperiesToDublicate((IElement*)pVideoElement); SetProperiesToDublicate((CImageElement*)pVideoElement);
pVideoElement->m_strVideoFileName = m_strVideoFileName; pVideoElement->m_strVideoFileName = m_strVideoFileName;
pVideoElement->m_nAlpha = m_nAlpha; pVideoElement->m_nAlpha = m_nAlpha;
...@@ -1098,83 +964,6 @@ namespace NSPresentationEditor ...@@ -1098,83 +964,6 @@ namespace NSPresentationEditor
virtual void SetupProperty(CSlide* pSlide, CTheme* pTheme, CLayout* pLayout, CElementProperty* pProperty) 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