]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/PreviewLoader.C
If the graphics loader has a copy c-tor it should have copy assignment that does...
[lyx.git] / src / graphics / PreviewLoader.C
index c5c4d4e9abeaa6bf06e548aec7dc5fde8e5efa03..cf4ae4faaf2f9bfce80d02a749a9af4b61cd4b72 100644 (file)
 
 #include "buffer.h"
 #include "converter.h"
+#include "format.h"
 #include "debug.h"
 #include "lyxrc.h"
 #include "LColor.h"
+#include "Lsstream.h"
 
 #include "insets/inset.h"
 
@@ -26,6 +28,7 @@
 #include "support/filetools.h"
 #include "support/forkedcall.h"
 #include "support/forkedcontr.h"
+#include "support/tostr.h"
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
 
@@ -77,7 +80,7 @@ struct FindFirst {
        FindFirst(string const & comp) : comp_(comp) {}
        bool operator()(StrPair const & sp)
        {
-               return sp.first < comp_;
+               return sp.first == comp_;
        }
 private:
        string const comp_;
@@ -449,7 +452,11 @@ void PreviewLoader::Impl::startLoading()
        lyxerr[Debug::GRAPHICS] << "PreviewLoader::startLoading()" << endl;
 
        // As used by the LaTeX file and by the resulting image files
-       string const filename_base(unique_filename(buffer_.tmppath));
+       string directory = buffer_.tmppath;
+       if (directory.empty())
+               directory = buffer_.filePath();
+       
+       string const filename_base(unique_filename(directory));
 
        // Create an InProgress instance to place in the map of all
        // such processes if it starts correctly.
@@ -543,9 +550,9 @@ void PreviewLoader::Impl::finishedGenerating(pid_t pid, int retval)
        in_progress_.erase(git);
 
        // Tell the outside world
-       std::list<PreviewImagePtr>::const_reverse_iterator 
+       std::list<PreviewImagePtr>::const_reverse_iterator
                nit  = newimages.rbegin();
-       std::list<PreviewImagePtr>::const_reverse_iterator 
+       std::list<PreviewImagePtr>::const_reverse_iterator
                nend = newimages.rend();
        for (; nit != nend; ++nit) {
                imageReady(*nit->get());
@@ -558,14 +565,19 @@ void PreviewLoader::Impl::dumpPreamble(ostream & os) const
        // Why on earth is Buffer::makeLaTeXFile a non-const method?
        Buffer & tmp = const_cast<Buffer &>(buffer_);
        // Dump the preamble only.
-       tmp.makeLaTeXFile(os, buffer_.filePath(), true, false, true);
+       LatexRunParams runparams;
+       runparams.flavor = LatexRunParams::LATEX;
+       runparams.nice = true;
+       runparams.moving_arg = true;
+       runparams.free_spacing = true;
+       tmp.makeLaTeXFile(os, buffer_.filePath(), runparams, false, true);
 
        // FIXME! This is a HACK! The proper fix is to control the 'true'
        // passed to WriteStream below:
        // int InsetFormula::latex(Buffer const *, ostream & os,
-       //                         bool fragile, bool) const
+       //                         LatexRunParams const & runparams) const
        // {
-       //      WriteStream wi(os, fragile, true);
+       //      WriteStream wi(os, runparams.moving_arg, true);
        //      par_->write(wi);
        //      return wi.line();
        // }
@@ -579,7 +591,7 @@ void PreviewLoader::Impl::dumpPreamble(ostream & os) const
 
        for (; it != end; ++it)
                if (it->lyxCode() == Inset::MATHMACRO_CODE)
-                       it->latex(&buffer_, os, true, true);
+                       it->latex(&buffer_, os, runparams);
 
        // All equation lables appear as "(#)" + preview.sty's rendering of
        // the label name