Files
core/ASCOfficePPTXFile/PPTXFormat/FileFactory.cpp
Sergey.Konovalov a0d3261927 Bug 30175 - Ошибка в консоли при переоткрытии презентации с определенной темой.
оишбка в mailmerge

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@64387 954022d7-b5bf-4e40-9824-e11837661b57
2016-05-21 00:28:27 +03:00

146 lines
6.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//#include "./stdafx.h"
#include "FileFactory.h"
#include "DocxFormat/File.h"
#include "DocxFormat/FileTypes.h"
#include "DocxFormat/Rels/RelationShip.h"
#include "App.h"
#include "Core.h"
#include "Theme.h"
#include "HandoutMaster.h"
#include "Presentation.h"
#include "PresProps.h"
#include "SlideLayout.h"
#include "SlideMaster.h"
#include "Slide.h"
#include "CommentAuthors.h"
#include "Comments.h"
#include "TableStyles.h"
#include "ViewProps.h"
#include "NotesSlide.h"
#include "NotesMaster.h"
#include "DocxFormat/Media/Image.h"
#include "DocxFormat/Media/Audio.h"
#include "DocxFormat/Media/Video.h"
#include "DocxFormat/Media/OleObject.h"
#include "DocxFormat/External/HyperLink.h"
#include "DocxFormat/External/ExternalImage.h"
#include "DocxFormat/External/ExternalAudio.h"
#include "DocxFormat/External/ExternalVideo.h"
#include "DocxFormat/Drawing/VmlDrawing.h"
#include "DocxFormat/Drawing/LegacyDiagramText.h"
#include "DocxFormat/UnknowTypeFile.h"
#include "FileMap.h"
namespace PPTX
{
const smart_ptr<PPTX::File> FileFactory::CreateFilePPTX(const OOX::CPath& path, const PPTX::Rels::RelationShip& relation, FileMap& map)
{
OOX::CPath filename = path / relation.filename();
if (relation.type() == PPTX::FileTypes::App)
return smart_ptr<PPTX::File>(new PPTX::App(filename, map));
else if (relation.type() == PPTX::FileTypes::Core)
return smart_ptr<PPTX::File>(new PPTX::Core(filename, map));
else if (relation.type() == PPTX::FileTypes::Presentation)
return smart_ptr<PPTX::File>(new PPTX::Presentation(filename, map));
else if (relation.type() == PPTX::FileTypes::Theme)
return smart_ptr<PPTX::File>(new PPTX::Theme(filename, map));
else if (relation.type() == PPTX::FileTypes::SlideMaster)
return smart_ptr<PPTX::File>(new PPTX::SlideMaster(filename, map));
else if (relation.type() == PPTX::FileTypes::SlideLayout)
return smart_ptr<PPTX::File>(new PPTX::SlideLayout(filename, map));
else if (relation.type() == PPTX::FileTypes::Slide)
return smart_ptr<PPTX::File>(new PPTX::Slide(filename, map));
else if (relation.type() == PPTX::FileTypes::HandoutMaster)
return smart_ptr<PPTX::File>(new PPTX::HandoutMaster(filename, map));
else if (relation.type() == PPTX::FileTypes::NotesMaster)
return smart_ptr<PPTX::File>(new PPTX::NotesMaster(filename, map));
else if (relation.type() == PPTX::FileTypes::NotesSlide)
return smart_ptr<PPTX::File>(new PPTX::NotesSlide(filename, map));
else if (relation.type() == PPTX::FileTypes::PresProps)
return smart_ptr<PPTX::File>(new PPTX::PresProps(filename, map));
else if (relation.type() == PPTX::FileTypes::ViewProps)
return smart_ptr<PPTX::File>(new PPTX::ViewProps(filename, map));
else if (relation.type() == PPTX::FileTypes::TableStyles)
return smart_ptr<PPTX::File>(new PPTX::TableStyles(filename, map));
else if (relation.type() == PPTX::FileTypes::LegacyDiagramText)
return smart_ptr<PPTX::File>(new PPTX::LegacyDiagramText(filename));
else if (relation.type() == PPTX::FileTypes::VmlDrawing)
return smart_ptr<PPTX::File>(new PPTX::VmlDrawing(filename, map));
else if (relation.type() == PPTX::FileTypes::HyperLink)
return smart_ptr<PPTX::File>(new PPTX::HyperLink(relation.target()));
else if ((relation.type() == PPTX::FileTypes::ExternalImage) && (relation.isExternal()))
return smart_ptr<PPTX::File>(new PPTX::ExternalImage(relation.target()));
else if ((relation.type() == PPTX::FileTypes::ExternalAudio) && (relation.isExternal()))
return smart_ptr<PPTX::File>(new PPTX::ExternalAudio(relation.target()));
else if ((relation.type() == PPTX::FileTypes::ExternalVideo) && (relation.isExternal()))
return smart_ptr<PPTX::File>(new PPTX::ExternalVideo(relation.target()));
else if (relation.type() == PPTX::FileTypes::Image)
return smart_ptr<PPTX::File>(new PPTX::Image(filename));
else if (relation.type() == PPTX::FileTypes::Audio)
return smart_ptr<PPTX::File>(new PPTX::Audio(filename));
else if (relation.type() == PPTX::FileTypes::Video)
return smart_ptr<PPTX::File>(new PPTX::Video(filename));
else if (relation.type() == PPTX::FileTypes::Media) // FOR NONE OPTIMIZED PPTX FILES
return smart_ptr<PPTX::File>(new PPTX::HyperLink(filename));
else if (relation.type() == PPTX::FileTypes::Data) // нужен только filepath
return smart_ptr<PPTX::File>(new PPTX::Image(filename));
else if (relation.type() == PPTX::FileTypes::DrawingDiag)
return smart_ptr<PPTX::File>(new PPTX::Image(filename)); // нужен только filepath
else if (relation.type() == PPTX::FileTypes::Chart)
return smart_ptr<PPTX::File>(new PPTX::Image(filename)); // нужен только filepath
else if (relation.type() == PPTX::FileTypes::CommentAuthors)
return smart_ptr<PPTX::File>(new PPTX::Authors(filename, map));
else if (relation.type() == PPTX::FileTypes::SlideComments)
return smart_ptr<PPTX::File>(new PPTX::Comments(filename, map));
else if (relation.type() == PPTX::FileTypes::OleObject)
return smart_ptr<PPTX::File>(new PPTX::OleObject(filename));
return smart_ptr<PPTX::File>(new PPTX::UnknowTypeFile());
}
const smart_ptr<PPTX::File> FileFactory::CreateFilePPTX_OnlyMedia(const OOX::CPath& path, const PPTX::Rels::RelationShip& relation)
{
bool bIsDownload = false;
CString strFile = relation.filename().GetPath();
int n1 = strFile.Find(_T("www"));
int n2 = strFile.Find(_T("http"));
int n3 = strFile.Find(_T("ftp"));
int n4 = strFile.Find(_T("https://"));
//если nI сранивать не с 0, то будут проблемы
//потому что в инсталяции мы кладем файлы в /var/www...
if (0 == n1 || 0 == n2 || 0 == n3 || 0 == n4)
bIsDownload = true;
OOX::CPath filename = path / relation.filename();
if (bIsDownload)
filename = relation.filename();
CString strT = relation.type();
if (strT == PPTX::FileTypes::Image ||
strT == PPTX::FileTypes::Data ||
strT == PPTX::FileTypes::DrawingDiag ||
strT == PPTX::FileTypes::Chart)
{
return smart_ptr<PPTX::File>(new PPTX::Image(filename));
}
else if(strT == PPTX::FileTypes::HyperLink)
return smart_ptr<PPTX::File>(new PPTX::HyperLink(relation.target()));
else if(strT == PPTX::FileTypes::LegacyDiagramText)
return smart_ptr<PPTX::File>(new PPTX::LegacyDiagramText(filename));
else if(strT == PPTX::FileTypes::OleObject)
return smart_ptr<PPTX::File>(new PPTX::OleObject(filename));
return smart_ptr<PPTX::File>(new PPTX::UnknowTypeFile());
}
} // namespace PPTX