Exemplo n.º 1
0
bool Hyphenator::loadDict(const QString& name)
{
	if (LanguageManager::instance()->getHyphFilename(name).isEmpty())
		return false;
		
	if (m_language != name)
	{
		m_language = name;

		QFile file(LanguageManager::instance()->getHyphFilename(m_language));
		
		if (m_hdict != nullptr)
			hnj_hyphen_free(m_hdict);

		if (file.open(QIODevice::ReadOnly))
		{
			m_codec = QTextCodec::codecForName(file.readLine());
			m_hdict = hnj_hyphen_load(file.fileName().toLocal8Bit().data());
			file.close();
			return true;
		}
		m_hdict = nullptr;
		return false;
	}

	return (m_codec != nullptr && m_hdict != nullptr);
}
Exemplo n.º 2
0
nsHyphenator::~nsHyphenator()
{
  if (mDict != nullptr) {
    hnj_hyphen_free((HyphenDict*)mDict);
    mDict = nullptr;
  }
}
Exemplo n.º 3
0
static void
Hyphen_dealloc(Hyphenobject *self) {
  if (self->hdict != NULL) {
    hnj_hyphen_free(self->hdict);
    self->hdict = NULL;
  }
  PyObject_DEL(self);
}
Exemplo n.º 4
0
void Hyphenator::NewDict(const QString& name)
{
// 	if (!ScCore->primaryMainWindow()->Sprachen.contains(name))
// 		return;
	if( LanguageManager::instance()->getHyphFilename(name).isEmpty() )
		return;
		
	if (Language != name) 
	{
		Language = name;

		char *filename = NULL;
		QString pfad = LanguageManager::instance()->getHyphFilename(Language);
		
		if (m_hdict != NULL)
			hnj_hyphen_free(m_hdict);

		QFile f(pfad);
		if (f.open(QIODevice::ReadOnly))
		{
			QTextStream st(&f);
			QString line;
			line = st.readLine();
			m_codec = QTextCodec::codecForName(line.toUtf8());
			f.close();
		}
		else
		{
			m_usable = false;
			m_hdict = NULL;
			return;
		}
		QByteArray fn = pfad.toLocal8Bit();
		filename = fn.data();
		m_hdict = hnj_hyphen_load(filename);
		m_usable = m_hdict == NULL ? false : true;
	}
}
Exemplo n.º 5
0
Hyphenator::~Hyphenator()
{
	if (m_hdict)
		hnj_hyphen_free(m_hdict);
}