Esempio n. 1
0
/*!
 \fn int FileLoader::TestFile()
 \author Franz Schmid
 \date
 \brief Tests if the file "FileName" exists and determines the type of the file.
 \retval int -1 if the file doesn't exist or any other error has occurred, 0 for the old Format, 1 for the new Format, 2 for EPS and PS files, 3 for SVG files and 4 for PDF files
 */
int FileLoader::TestFile()
{
	QFileInfo fi = QFileInfo(FileName);
	int ret = -1;
	if (!fi.exists())
		ret = -1;
	QString ext = fi.completeSuffix().toLower();

	QList<FileFormat> fileFormats(LoadSavePlugin::supportedFormats());
	QList<FileFormat>::const_iterator it(fileFormats.constBegin());
	QList<FileFormat>::const_iterator itEnd(fileFormats.constEnd());
	for ( ; it != itEnd ; ++it )
	{
		if ((*it).nameMatch.indexIn("."+ext)!=-1)
		{
//  		qDebug() << QString("Match :%1: :.%2: on %3").arg((*it).nameMatch.pattern()).arg(ext).arg((*it).trName);
			if ((*it).plug!=0)
			{
				if ((*it).plug->fileSupported(0, FileName))
				{
// 					qDebug(QString("File Supported With: %1").arg((*it).trName));
					ret=(*it).formatId;
					break;
				}
			}
		}
// 		else
// 			qDebug() << QString("No Match :%1: :.%2: on %3").arg((*it).nameMatch.pattern()).arg(ext).arg((*it).trName);
	}
	
// 	if (ret==-1)
// 	{
// 		if ((ext.endsWith("sla.gz")) || (ext.endsWith("sla")) || (ext.endsWith("scd.gz")) || (ext.endsWith("scd")))
// 			ret = CheckScribus();
// 		else 
// 		if (((ext.endsWith("ps")) || (ext.endsWith("eps"))) && (formatPS))
// 			ret = FORMATID_PSIMPORT;
// 		else if (((ext.endsWith("svg")) || (ext.endsWith("svgz"))) && (formatSVG))
// 			ret = FORMATID_SVGIMPORT;
// 		else if ((ext.endsWith("sxd")) && (formatSXD))
// 			ret = FORMATID_SXDIMPORT;
// 		else if ((ext.endsWith("odg")) && (formatODG))
// 			ret = FORMATID_ODGIMPORT;
// 	}
/*	if (ext == "pdf")
		ret = 4; */
	FileType = ret;
	return ret;
}
Esempio n. 2
0
/*!
 \fn int FileLoader::TestFile()
 \author Franz Schmid
 \date
 \brief Tests if the file "FileName" exists and determines the type of the file.
 \retval int -1 if the file doesn't exist or any other error has occurred, 0 for the old Format, 1 for the new Format, 2 for EPS and PS files, 3 for SVG files and 4 for PDF files
 */
int FileLoader::testFile()
{
	QFileInfo fi = QFileInfo(m_fileName);
	int ret = -1;
	if (!fi.exists())
		ret = -1;
	QString lwrFileName = m_fileName.toLower();

	bool found = false;
	QList<FileFormat> fileFormats(LoadSavePlugin::supportedFormats());
	QList<FileFormat>::const_iterator it(fileFormats.constBegin());
	QList<FileFormat>::const_iterator itEnd(fileFormats.constEnd());
	for ( ; (it != itEnd) && (!found); ++it)
	{
		if (!it->plug)
			continue;
		for (int a = 0; a < it->fileExtensions.count(); a++)
		{
			QString ext = it->fileExtensions[a].toLower();
			if (lwrFileName.endsWith("." + ext)) // Beware of file names containing multiple points
			{
				if (it->plug->fileSupported(0, m_fileName))
				{
					ret = it->formatId;
					found = true;
					break;
				}
			}
		}
	}
	if (!found)
	{
	// now try for the last suffix
		QString ext = fi.suffix().toLower();
		it = fileFormats.constBegin();
		itEnd = fileFormats.constEnd();
		for ( ; (it != itEnd) && (!found); ++it)
		{
			if (!it->plug)
				continue;
			bool found = false;
			for (int a = 0; a < it->fileExtensions.count(); a++)
			{
				QString exts = it->fileExtensions[a].toLower();
				if (ext == exts)
				{
					if (it->plug->fileSupported(0, m_fileName))
					{
						ret = it->formatId;
						found = true;
						break;
					}
				}
			}
			if (found)
				break;
		}
	}
	m_fileType = ret;
	return ret;
}
Esempio n. 3
0
/*!
 \fn int FileLoader::TestFile()
 \author Franz Schmid
 \date
 \brief Tests if the file "FileName" exists and determines the type of the file.
 \retval int -1 if the file doesn't exist or any other error has occurred, 0 for the old Format, 1 for the new Format, 2 for EPS and PS files, 3 for SVG files and 4 for PDF files
 */
int FileLoader::testFile()
{
	QFileInfo fi = QFileInfo(m_fileName);
	int ret = -1;
	if (!fi.exists())
		ret = -1;
	QString ext = fi.completeSuffix().toLower();

	bool found = false;
	QList<FileFormat> fileFormats(LoadSavePlugin::supportedFormats());
	QList<FileFormat>::const_iterator it(fileFormats.constBegin());
	QList<FileFormat>::const_iterator itEnd(fileFormats.constEnd());
	for ( ; it != itEnd ; ++it )
	{
		for (int a = 0; a < it->fileExtensions.count(); a++)
		{
			QString exts = it->fileExtensions[a].toLower();
			if (ext == exts)
			{
				if (it->plug != 0)
				{
					if (it->plug->fileSupported(0, m_fileName))
					{
						ret = it->formatId;
						found = true;
						break;
					}
				}
			}
		}
		if (found)
			break;
	}
	if (!found)
	{
	// now try for the last suffix
		ext = fi.suffix().toLower();
		it = fileFormats.constBegin();
		itEnd = fileFormats.constEnd();
		for ( ; it != itEnd ; ++it )
		{
			bool found = false;
			for (int a = 0; a < it->fileExtensions.count(); a++)
			{
				QString exts = it->fileExtensions[a].toLower();
				if (ext == exts)
				{
					if (it->plug != 0)
					{
						if (it->plug->fileSupported(0, m_fileName))
						{
							ret = it->formatId;
							found = true;
							break;
						}
					}
				}
			}
			if (found)
				break;
		}
	}
	m_fileType = ret;
	return ret;
}