]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/PreviewLoader.cpp
Add context menu for outline operations. Choice of words might not be best.
[lyx.git] / src / graphics / PreviewLoader.cpp
index 4c668120ebcf57fe69e769c3906fa202559b8cc7..67798581f05386db05179cf99af14ad2879be9fb 100644 (file)
 
 #include "support/convert.h"
 #include "support/debug.h"
+#include "support/FileName.h"
 #include "support/filetools.h"
 #include "support/ForkedCalls.h"
 #include "support/lstrings.h"
-#include "support/lyxlib.h"
 
 #include <boost/bind.hpp>
 
@@ -63,7 +63,7 @@ string const unique_filename(string const & bufferpath)
 {
        static int theCounter = 0;
        string const filename = lyx::convert<string>(theCounter++) + "lyxpreview";
-       return lyx::support::addName(bufferpath, filename);
+       return addName(bufferpath, filename);
 }
 
 
@@ -369,7 +369,7 @@ InProgress::InProgress(string const & filename_base,
 void InProgress::stop() const
 {
        if (pid)
-               lyx::support::ForkedCallsController::kill(pid, 0);
+               ForkedCallsController::kill(pid, 0);
 
        if (!metrics_file.empty())
                metrics_file.removeFile();
@@ -469,7 +469,7 @@ void PreviewLoader::Impl::add(string const & latex_snippet)
        if (!pconverter_ || status(latex_snippet) != NotFound)
                return;
 
-       string const snippet = support::trim(latex_snippet);
+       string const snippet = trim(latex_snippet);
        if (snippet.empty())
                return;
 
@@ -554,7 +554,14 @@ void PreviewLoader::Impl::startLoading()
 
        // we use the encoding of the buffer
        Encoding const & enc = buffer_.params().encoding();
-       odocfstream of(enc.iconvName());
+       odocfstream of;
+       try { of.reset(enc.iconvName()); }
+       catch (iconv_codecvt_facet_exception & e) {
+               LYXERR0("Caught iconv exception: " << e.what()
+                       << "\nUnable to create LaTeX file: " << latexfile);
+               return;
+       }
+
        TexRow texrow;
        OutputParams runparams(&enc);
        LaTeXFeatures features(buffer_, buffer_.params(), runparams);
@@ -584,19 +591,19 @@ void PreviewLoader::Impl::startLoading()
        // The conversion command.
        ostringstream cs;
        cs << pconverter_->command << ' ' << pconverter_->to << ' '
-          << support::quoteName(latexfile.toFilesystemEncoding()) << ' '
+          << quoteName(latexfile.toFilesystemEncoding()) << ' '
           << int(font_scaling_factor_) << ' '
           << theApp()->hexName(Color_preview) << ' '
           << theApp()->hexName(Color_background);
 
-       string const command = support::libScriptSearch(cs.str());
+       string const command = libScriptSearch(cs.str());
 
        // Initiate the conversion from LaTeX to bitmap images files.
-       support::ForkedCall::SignalTypePtr
-               convert_ptr(new support::ForkedCall::SignalType);
+       ForkedCall::SignalTypePtr
+               convert_ptr(new ForkedCall::SignalType);
        convert_ptr->connect(bind(&Impl::finishedGenerating, this, _1, _2));
 
-       support::ForkedCall call;
+       ForkedCall call;
        int ret = call.startScript(command, convert_ptr);
 
        if (ret != 0) {
@@ -701,7 +708,7 @@ void PreviewLoader::Impl::dumpPreamble(odocstream & os) const
 
        for (; it != end; ++it)
                if (it->lyxCode() == MATHMACRO_CODE)
-                       it->latex(buffer_, os, runparams);
+                       it->latex(os, runparams);
 
        // All equation labels appear as "(#)" + preview.sty's rendering of
        // the label name