- LSLaunchFSRefSpec inLaunchSpec;
- inLaunchSpec.appRef = &outAppRef;
- inLaunchSpec.numDocs = 1;
- inLaunchSpec.itemRefs = &fileref;
- inLaunchSpec.passThruParams = NULL;
- inLaunchSpec.launchFlags = kLSLaunchDefaults;
- inLaunchSpec.asyncRefCon = NULL;
- status = LSOpenFromRefSpec(&inLaunchSpec, NULL);
-
- return status != kLSApplicationNotFoundErr;
+ CFURLRef docURLs[] = { docURL };
+ CFArrayRef launchItems = CFArrayCreate(
+ NULL,
+ (const void**)docURLs, sizeof(docURLs) / sizeof(CFURLRef),
+ NULL);
+ LSLaunchURLSpec launchUrlSpec = {
+ appURL, launchItems, NULL, kLSLaunchDefaults, NULL
+ };
+
+ string const texinputs = os::latex_path_list(
+ replaceCurdirPath(path, lyxrc.texinputs_prefix));
+ string const otherinputs = os::latex_path_list(path);
+ string const oldtexinputs = getEnv("TEXINPUTS");
+ string const newtexinputs = ".:" + texinputs + ":" + oldtexinputs;
+ string const oldbibinputs = getEnv("BIBINPUTS");
+ string const newbibinputs = ".:" + otherinputs + ":" + oldbibinputs;
+ string const oldbstinputs = getEnv("BSTINPUTS");
+ string const newbstinputs = ".:" + otherinputs + ":" + oldbstinputs;
+ string const oldtexfonts = getEnv("TEXFONTS");
+ string const newtexfonts = ".:" + otherinputs + ":" + oldtexfonts;
+ if (!path.empty() && !lyxrc.texinputs_prefix.empty()) {
+ setEnv("TEXINPUTS", newtexinputs);
+ setEnv("BIBINPUTS", newbibinputs);
+ setEnv("BSTINPUTS", newbstinputs);
+ setEnv("TEXFONTS", newtexfonts);
+ }
+ status = LSOpenFromURLSpec (&launchUrlSpec, NULL);
+ CFRelease(launchItems);
+ if (!path.empty() && !lyxrc.texinputs_prefix.empty()) {
+ setEnv("TEXINPUTS", oldtexinputs);
+ setEnv("BIBINPUTS", oldbibinputs);
+ setEnv("BSTINPUTS", oldbstinputs);
+ setEnv("TEXFONTS", oldtexfonts);
+ }
+ return status == 0;