예제 #1
0
파일: xtgim.cpp 프로젝트: hasenj/scribus
XtgIm::XtgIm(QString fileName, QString enc, PageItem *textItem, bool textOnly)
{
	PrefsContext* prefs = PrefsManager::instance()->prefsFile->getPluginContext("XtgIm");
	bool prefix = prefs->getBool("prefix", true);
	bool ask = prefs->getBool("askAgain", true);
	encoding = enc;
	qDebug()<<"Encoding = "<<encoding;
	in_Buffer = "";
	TextWriter *writer = new TextWriter(textItem->doc());
	writer->open(textItem);
	if (!textOnly)
	{
		if (ask)
		{
			XtgDialog* xtgdia = new XtgDialog(prefix);
			if (xtgdia->exec()) {
				prefix = xtgdia->usePrefix();
				prefs->set("prefix", xtgdia->usePrefix());
				prefs->set("askAgain", xtgdia->askAgain());
				delete xtgdia;
			} 
			else {
				delete xtgdia;
				return;
			}
		}
	}
	filename = fileName;
	/**
	This will load the xtg file into a QByte Array which will be used for 
	furthur parsing
	*/
	loadFiletoArray();
	in_Buffer = toUnicode(buffer);
	QString docname = filename.right(filename.length() - filename.lastIndexOf("/") - 1);
	docname = docname.left(docname.lastIndexOf("."));
	XtgScanner *scanner = new XtgScanner(docname,writer,in_Buffer,textOnly,prefix);
	scanner->xtgParse();
	writer->close();
}
예제 #2
0
		/// <summary>
		/// 書き出し用のファイルを開きます。
		/// </summary>
		/// <param name="path">
		/// ファイルパス
		/// </param>
		/// <returns>
		/// ファイルのオープンに成功した場合 true, それ以外の場合は false
		/// </returns>
		bool open(const FilePath& path)
		{
			return m_writer.open(path);
		}