示例#1
0
IIECommand* IECommandMG::CreateIECommand(int id)
{
	int offset_id = id - IE_CMD_ID_OFFSET;

	IECommand_Map::iterator itr;
	size_t size = m_IECommand_Map.size();
	if(0 <= offset_id && offset_id < size/2){
		itr = m_IECommand_Map.begin();
		for(int i=0; i<offset_id; i++)
			itr++;
		
		if((*itr).second->extrn_cmd){
			return (*itr).second->extrn_cmd;
		}
		return CallDLL((*itr).second->dll_path.c_str());
	}
	else if(size/2 <= offset_id && offset_id < size){
		itr = m_IECommand_Map.end();
		for(int i=offset_id; i<size; i++){
			itr--;
		}

		if((*itr).second->extrn_cmd){
			return (*itr).second->extrn_cmd;
		}
		return CallDLL((*itr).second->dll_path.c_str());
	}

	return false;
}
// Look at the results of the file selection dialog and figure out if you need to use an importer.
// Prompt the user if the importer to use isn't obvious.
void gtGetText::launchImporter(int importer, const QString& filename, bool textOnly, 
								const QString& encoding, bool append, PageItem* target)
{
	// Struct for the plugin info, we'll load this up from the array.
	struct ImporterData ida;
	// Do we need to call an importer? Unsure what happens if this ever becomes false.
	bool callImporter = true;
	// Check and see if the file selection dialog returned the index position of the 
	// importer to be used. If it isn't, try to figure out what it is. If we can't,
	// prompt the user.
	if (importer == -1)
	{
		// Attempt to determine the importer based on the file's extension. 
		// Create a Qstring with what could be an extension.
		QString fend = filename.right(filename.length() - filename.lastIndexOf(".") - 1);
		QString fendL(fend.toLower());
		// Look for that extension in the importer QMap. 
		if (importerMap.find(fend) != importerMap.end())
			// If the map is found, assign ida to the corresponding struct in the map.
			ida = *importerMap[fend];
		// Otherwise, test for the lowercase version
		else
		if (importerMap.find(fendL) != importerMap.end())
			// If the map is found, assign ida to the corresponding struct in the map.
			ida = *importerMap[fendL];
		// Otherwise, try and ask the user.
		else
		{
			// Create a new dialog
			dias = new gtDialogs();
			// Pop up the dialog asking the user to select the type from our list (ilist) of 
			// importable file types. If one is not selected, set callImporter to false.
			callImporter = dias->runImporterDialog(ilist);
			// If we're gonna call an importer, we need to copy it's struct to ida.
			if (callImporter)
				ida = importers[dias->getImporter()];
			// Destroy the diag
			delete dias;
		} // else - if (importerMap.find(fend) != importerMap.end())
	}
	else // If we know which importer to use
	{
		// Copy the importer's struct to ida.
		ida = importers[importer];
	}	// else - if (importer == -1)
	
	// Create a target text frame for the imported text and assign it to the parameter "target"
	PageItem* targetFrame=target;
	
	// If the targetframe is 0 ( no frame selected/created? ) then reassign it to the 
	// (questionable interpretation here) first frame in the documentation.
	if (targetFrame==0)
		targetFrame=m_Doc->m_Selection->itemAt(0);

	// If the targetframe is not zero, and we do need to call the importer, 
	// Run the importer via "CallDLL" and pass it what it needs to know.
	if (targetFrame!=0 && callImporter)
		CallDLL(ida, filename, encoding, textOnly, append, targetFrame);
}  //void gtGetText::launchImporter(int importer, const QString& filename, bool textOnly, 
示例#3
0
IIECommand* IECommandMG::CreateIECommand(const char* cmd_name)
{
	std::string cmd_name_s = cmd_name;
	IECommand_Map::iterator itr = m_IECommand_Map.find(cmd_name_s);
	if(itr != m_IECommand_Map.end()){
		if((*itr).second->extrn_cmd){
			return (*itr).second->extrn_cmd;
		}

		//dll呼び出し
		return CallDLL((*itr).second->dll_path.c_str());
	}

	return false;
}