--- latex.service-0.1.orig/LaTeX.m +++ latex.service-0.1/LaTeX.m @@ -21,6 +21,9 @@ #include #include +#include +#include + @interface LaTeXService : NSObject - (void) textToRender: (NSPasteboard*)bp userData: (NSString*)ud @@ -62,23 +65,68 @@ [content appendString: @"\\pagestyle{empty}\n"]; [content appendString: equation]; [content appendString: @"\n\\end{document}"]; - BOOL ret = [content writeToFile: @"temp.tex" atomically: YES]; + + char *tempdir = strdup("/tmp/latexservice.XXXXXX"); + if (mkdtemp(tempdir) == NULL) + { + *err = @"Could not create temporary directory"; + return; + } + BOOL ret = [content writeToFile: [NSString pathWithComponents: [NSArray arrayWithObjects: [NSString stringWithCString: tempdir], @"temp.tex", nil]] atomically: YES]; if (ret) { - NSTask* taskLaTeX = [NSTask launchedTaskWithLaunchPath: @"/usr/bin/tex" - arguments: [NSArray arrayWithObjects: @"-progname=latex",@"temp.tex",nil]]; - [taskLaTeX waitUntilExit]; - NSTask* taskDVI2PNG = [NSTask launchedTaskWithLaunchPath: @"/usr/local/bin/dvipng" - arguments: [NSArray arrayWithObjects: @"-otemp.png",@"-Ttight",@"temp.dvi",nil]]; - [taskDVI2PNG waitUntilExit]; - NSTask* taskPNG2TIFF = [NSTask launchedTaskWithLaunchPath: @"/usr/bin/convert" - arguments: [NSArray arrayWithObjects: @"temp.png",@"temp.tiff",nil]]; - [taskPNG2TIFF waitUntilExit]; - NSImage* equationImage = [[NSImage alloc] initWithContentsOfFile: @"temp.tiff"]; + NSTask* task = [[NSTask alloc] init]; + [task setCurrentDirectoryPath: [NSString stringWithCString: tempdir]]; + [task setLaunchPath: @"latex"]; + [task setArguments: [NSArray arrayWithObjects: @"-progname", @"latex", @"-halt-on-error",@"temp.tex",nil]]; + [task launch]; + [task waitUntilExit]; + if ([task terminationStatus] != 0) + { + *err = @"Error running LaTeX."; + free(tempdir); + RELEASE(task); + return; + } + RELEASE(task); + task = [[NSTask alloc] init]; + [task setCurrentDirectoryPath: [NSString stringWithCString: tempdir]]; + [task setLaunchPath: @"dvipng"]; + [task setArguments: [NSArray arrayWithObjects: @"-otemp.png",@"-Ttight",@"temp.dvi",nil]]; + [task launch]; + [task waitUntilExit]; + if ([task terminationStatus] != 0) + { + *err = @"Error running dvipng."; + free(tempdir); + RELEASE(task); + return; + } + RELEASE(task); + task = [[NSTask alloc] init]; + [task setCurrentDirectoryPath: [NSString stringWithCString: tempdir]]; + [task setLaunchPath: @"convert"]; + [task setArguments: [NSArray arrayWithObjects: @"temp.png",@"temp.tiff",nil]]; + [task launch]; + [task waitUntilExit]; + if ([task terminationStatus] != 0) + { + *err = @"Error running convert."; + free(tempdir); + RELEASE(task); + return; + } + RELEASE(task); + NSImage* equationImage = [[NSImage alloc] initWithContentsOfFile: [NSString pathWithComponents: [NSArray arrayWithObjects: [NSString stringWithCString: tempdir], @"temp.tiff", nil]]]; [pb setData: [equationImage TIFFRepresentation] forType: NSTIFFPboardType]; [equationImage release]; + NSTask* task_rm = [NSTask launchedTaskWithLaunchPath: @"rm" + arguments: [NSArray arrayWithObjects: @"-rf",[NSString stringWithCString: tempdir],nil]]; + [task_rm waitUntilExit]; } + + free(tempdir); } @end --- latex.service-0.1.orig/debian/docs +++ latex.service-0.1/debian/docs @@ -0,0 +1 @@ +README --- latex.service-0.1.orig/debian/changelog +++ latex.service-0.1/debian/changelog @@ -0,0 +1,57 @@ +latex.service (0.1-5build3) natty; urgency=low + + * Rebuild for the GNUstep transition. + + -- Luca Falavigna Fri, 29 Oct 2010 20:57:11 +0200 + +latex.service (0.1-5build2) karmic; urgency=low + + * Rebuild for the GNUstep transition. + + -- Luca Falavigna Mon, 25 May 2009 07:48:59 +0000 + +latex.service (0.1-5build1) intrepid; urgency=low + + * Rebuild for GNUstep transition. + + -- Luca Falavigna Sun, 06 Jul 2008 15:01:51 +0200 + +latex.service (0.1-5) unstable; urgency=low + + * Orphaning package, setting maintainer to the Debian QA Group. + + -- Ana Beatriz Guerrero Lopez Wed, 05 Dec 2007 16:25:09 +0100 + +latex.service (0.1-4) unstable; urgency=low + + * GNUstep transition. + + Updated debian/rules. + + Dropped debian/dirs. + + [Hubert Chathi] + * Run latex binary instead of tex. + * Depend on texlive-latex-base. + * Write to temporary directory, instead of just temp.tex. + + -- Gürkan Sengün Thu, 25 Oct 2007 14:47:21 +0200 + +latex.service (0.1-3) unstable; urgency=low + + * Rebuild against latest libgnustep-gui-dev. + * Bump standards version. + * Fixed debian/copyright. + + -- Gürkan Sengün Sun, 17 Sep 2006 08:10:56 +0200 + +latex.service (0.1-2) unstable; urgency=low + + * Rebuild against latest libgnustep-gui. + * Bump standards version. + + -- Gürkan Sengün Mon, 23 Jan 2006 21:52:31 +0100 + +latex.service (0.1-1) unstable; urgency=low + + * Initial Release. (closes: #252744) + + -- Gürkan Sengün Wed, 2 Jun 2004 10:23:38 +0200 --- latex.service-0.1.orig/debian/control +++ latex.service-0.1/debian/control @@ -0,0 +1,15 @@ +Source: latex.service +Section: x11 +Priority: optional +Maintainer: Debian QA Group +Build-Depends: debhelper (>= 4.0.0), libgnustep-gui-dev (>= 0.12.0), gnustep-make, gnustep-gui-runtime +Standards-Version: 3.7.2 +Homepage: http://www.roard.com/latexservice/ + +Package: latex.service +Architecture: any +Depends: ${shlibs:Depends}, texlive-latex-base | tetex-bin, texlive-generic-extra | tetex-extra, dvipng, imagemagick +Description: LaTeX service for GNUstep + This is a small service which converts a LaTeX text into an image. + Just select the text, click on the service item menu, choose "Return the + LaTeX rendering" and voila! Your text is replaced by its LaTeX rendering. --- latex.service-0.1.orig/debian/compat +++ latex.service-0.1/debian/compat @@ -0,0 +1 @@ +4 --- latex.service-0.1.orig/debian/copyright +++ latex.service-0.1/debian/copyright @@ -0,0 +1,27 @@ +This package was debianized by Gürkan Sengün on +Wed, 2 Jun 2004 10:23:38 +0200. + +It was downloaded from http://www.roard.com/latexservice/ + +Upstream Author: Nicolas Roard + +Copyright: + + Copyright (C) 2003 Nicolas Roard + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. --- latex.service-0.1.orig/debian/rules +++ latex.service-0.1/debian/rules @@ -0,0 +1,44 @@ +#!/usr/bin/make -f +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +build: build-stamp + +build-stamp: + dh_testdir + gs_make + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + gs_make clean distclean + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + gs_make install GNUSTEP_INSTALLATION_DOMAIN=SYSTEM DESTDIR=$(CURDIR)/debian/latex.service + +binary-indep: build install + +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_link + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install