예제 #1
0
bool Presentation::_loadPresentationBindings(AV_View * pView)
{
  EV_EditMethodContainer * pEMC = m_pApp->getEditMethodContainer();
  g_return_val_if_fail (pEMC != 0, FALSE);
  if(m_pApp->getBindingMap("Presentation") != NULL)
  {
      return true;
  }
  // get the path where our app data is located
  XAP_App * pApp = static_cast<XAP_App*>(XAP_App::getApp());
  UT_String data_path( pApp->getAbiSuiteLibDir() );
  data_path += G_DIR_SEPARATOR;
  data_path += "Presentation.xml";

  EV_EditMethod * pLoadB = pEMC->findEditMethodByName ("com.abisource.abiword.loadbindings.fromURI");
  g_return_val_if_fail (pLoadB != 0, false);
  EV_EditMethodCallData calldata(data_path.c_str(),data_path.size());
  calldata.m_xPos = 0;
  calldata.m_yPos = 0;
  return (pLoadB->Fn(pView,&calldata) ? TRUE : FALSE);
}
예제 #2
0
void GR_MathManager::initialize(void)
{
	XAP_App *pApp = XAP_App::getApp();

	// load the gtkmathview settings and operator dictionaries from the private user directory, ...
	UT_UTF8String userConfDir(pApp->getUserPrivateDirectory());
	UT_UTF8String userDictDir(pApp->getUserPrivateDirectory());
	UT_UTF8String userCombiningDictDir(pApp->getUserPrivateDirectory());
	UT_UTF8String userLocalDictDir(pApp->getUserPrivateDirectory());
#if defined(WIN32)
	userConfDir += "\\math\\gtkmathview.conf.xml";
	userDictDir += "\\math\\dictionary.xml";
	userCombiningDictDir += "\\math\\dictionary-combining.xml";
	userLocalDictDir += "\\math\\dictionary-local.xml";
#else
	userConfDir += "/math/gtkmathview.conf.xml";
	userDictDir += "/math/dictionary.xml";
	userCombiningDictDir += "/math/dictionary-combining.xml";
	userLocalDictDir += "/math/dictionary-local.xml";
#endif

	// ... or from the (common) AbiSuite directory
	UT_UTF8String libConfDir(pApp->getAbiSuiteLibDir());
	UT_UTF8String libDictDir(pApp->getAbiSuiteLibDir());
	UT_UTF8String libCombiningDictDir(pApp->getAbiSuiteLibDir());
	UT_UTF8String libLocalDictDir(pApp->getAbiSuiteLibDir());
#if defined(WIN32)	 
	libConfDir += "\\math\\gtkmathview.conf.xml";
	libDictDir += "\\math\\dictionary.xml";
	libCombiningDictDir += "\\math\\dictionary-combining.xml";
	libLocalDictDir += "\\math\\dictionary-local.xml";
#else
	libConfDir += "/math/gtkmathview.conf.xml";
	libDictDir += "/math/dictionary.xml";
	libCombiningDictDir += "/math/dictionary-combining.xml";
	libLocalDictDir += "/math/dictionary-local.xml";
#endif

	// add the configuration paths
 
#ifdef TOOLKIT_COCOA
	if (const char * resources = getenv("ABIWORD_COCOA_BUNDLED_RESOURCES"))
	{
		UT_UTF8String bundleConfDir(resources);
		bundleConfDir += "/gtkmathview/gtkmathview.conf.xml";
		Configuration::addConfigurationPath(bundleConfDir.utf8_str());
	}
#endif
	Configuration::addConfigurationPath( libConfDir.utf8_str() );
	Configuration::addConfigurationPath( userConfDir.utf8_str() );

	SmartPtr<AbstractLogger> logger = Logger::create();
	m_pLogger = logger;
	SmartPtr<Configuration> configuration = initConfiguration<libxml2_MathView>(logger, getenv("GTKMATHVIEWCONF"));
	logger->setLogLevel(LOG_INFO);
	 
	// add the dictionary paths

#ifdef TOOLKIT_COCOA
	if (const char * resources = getenv("ABIWORD_COCOA_BUNDLED_RESOURCES"))
	{
		UT_UTF8String bundleDictDir(resources);
		UT_UTF8String bundleCombiningDictDir(resources);
		UT_UTF8String bundleLocalDictDir(resources);

		bundleDictDir += "/gtkmathview/dictionary.xml";
		bundleCombiningDictDir += "/gtkmathview/dictionary-combining.xml";
		bundleLocalDictDir += "/gtkmathview/dictionary-local.xml";

		configuration->add("dictionary/path", bundleDictDir.utf8_str());
		configuration->add("dictionary/path", bundleCombiningDictDir.utf8_str());
		configuration->add("dictionary/path", bundleLocalDictDir.utf8_str());
	}
#endif
	configuration->add("dictionary/path", libDictDir.utf8_str());
	configuration->add("dictionary/path", libCombiningDictDir.utf8_str());
	configuration->add("dictionary/path", libLocalDictDir.utf8_str());

	configuration->add("dictionary/path", userDictDir.utf8_str());
	configuration->add("dictionary/path", userCombiningDictDir.utf8_str());
	configuration->add("dictionary/path", userLocalDictDir.utf8_str());

	SmartPtr<GR_Abi_MathGraphicDevice> mathGraphicDevice 
			= GR_Abi_MathGraphicDevice::create(logger, configuration, getGraphics());
	m_pMathGraphicDevice = mathGraphicDevice;
	m_pAbiContext = new GR_Abi_RenderingContext(getGraphics());
	UT_DEBUGMSG(("MAthView New rendering context %p Graphics %p \n",m_pAbiContext,getGraphics()));
	m_pOperatorDictionary = initOperatorDictionary<libxml2_MathView>(logger, configuration);
}
/*!
	Localize and URL for help.
	
	\param pathBeforeLang the path for the help file that prefix
	\param pathAfterLang the path inside the localized directory
	\param remoteURLbase remote URL if help files are not found.
	
	Override in subclasses if platform needs specific work
 */
UT_String XAP_AppImpl::localizeHelpUrl (const char * pathBeforeLang, 
										   const char * pathAfterLang,
										   const char * remoteURLbase)
{
	XAP_App* pApp = XAP_App::getApp();

	UT_return_val_if_fail(pApp, "");
	XAP_Prefs* pPrefs = pApp->getPrefs();
	UT_return_val_if_fail(pPrefs, "");

	const char* abiSuiteLibDir = pApp->getAbiSuiteLibDir();
	const gchar* abiSuiteLocString = NULL;
	UT_String url;

	// evil...
	pPrefs->getPrefsValue((gchar*)"StringSet", &abiSuiteLocString);

	// 1st try file on user's computer (local file), if not exist try remote help
	UT_String path(abiSuiteLibDir);
	_catPath(path, pathBeforeLang);

	UT_String localized_path(path);
	_catPath(localized_path, abiSuiteLocString);

	if (UT_directoryExists(localized_path.c_str()))
	{
		// the localised help exists, so use it
		path = localized_path;
	}
	else
	{
		// the localised help directory does not exist, so fall back to the
		// en-US help location, which is the default lang, so usually available
		localized_path = path;
		_catPath(localized_path, "en-US");
	}

	_catPath(localized_path, pathAfterLang);
	localized_path += ".html";

	if (remoteURLbase && !UT_isRegularFile(localized_path.c_str()))
	{
		// not found, so build localized path for remote URL (but we can't verify remote URL)
		url = remoteURLbase;
		
		// HACK: Not all help files are localized. 
		// HACK: Hard code the available translations here instead of 404-ing.
		if (!(
			!strcmp(abiSuiteLocString, "en-US") ||
			!strcmp(abiSuiteLocString, "fr-FR") ||
			!strcmp(abiSuiteLocString, "pl-PL")
			))
			_catPath(url, "en-US");
		else
			_catPath(url, abiSuiteLocString);
		_catPath(url, pathAfterLang);
		url += ".html";
	}
	else
	{
		url = "file://";
		url += localized_path;
	}

	return url;
}