]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/PreviewLoader.C
Add more controls to the view-source dialog.
[lyx.git] / src / graphics / PreviewLoader.C
index aa01f6f13c02644f553b9cfc04eb52715435f9c5..0ed2ef8c0b5693b3af927f3685d0b78d0b9c3255 100644 (file)
@@ -33,7 +33,7 @@
 #include "support/forkedcontr.h"
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
-#include "support/tostr.h"
+#include "support/convert.h"
 
 #include <boost/bind.hpp>
 
@@ -92,7 +92,8 @@ private:
 
 
 /// Store info on a currently executing, forked process.
-struct InProgress {
+class InProgress {
+public:
        ///
        InProgress() : pid(0) {}
        ///
@@ -122,7 +123,8 @@ typedef InProgressProcesses::value_type InProgressProcess;
 namespace lyx {
 namespace graphics {
 
-struct PreviewLoader::Impl : public boost::signals::trackable {
+class PreviewLoader::Impl : public boost::signals::trackable {
+public:
        ///
        Impl(PreviewLoader & p, Buffer const & b);
        /// Stop any InProgress items still executing.
@@ -139,7 +141,7 @@ struct PreviewLoader::Impl : public boost::signals::trackable {
        void startLoading();
 
        /// Emit this signal when an image is ready for display.
-       boost::signal1<void, PreviewImage const &> imageReady;
+       boost::signal<void(PreviewImage const &)> imageReady;
 
        Buffer const & buffer() const { return buffer_; }
 
@@ -253,7 +255,8 @@ Buffer const & PreviewLoader::buffer() const
 
 namespace {
 
-struct IncrementedFileName {
+class IncrementedFileName {
+public:
        IncrementedFileName(string const & to_format,
                            string const & filename_base)
                : to_format_(to_format), base_(filename_base), counter_(1)
@@ -317,7 +320,7 @@ PreviewLoader::Impl::Impl(PreviewLoader & p, Buffer const & b)
        : parent_(p), buffer_(b), font_scaling_factor_(0.0)
 {
        font_scaling_factor_ = 0.01 * lyxrc.dpi * lyxrc.zoom *
-               lyxrc.preview_scale_factor;
+               convert<double>(lyxrc.preview_scale_factor);
 
        lyxerr[Debug::GRAPHICS] << "The font scaling factor is "
                                << font_scaling_factor_ << endl;
@@ -407,7 +410,8 @@ void PreviewLoader::Impl::add(string const & latex_snippet)
 
 namespace {
 
-struct EraseSnippet {
+class EraseSnippet {
+public:
        EraseSnippet(string const & s) : snippet_(s) {}
        void operator()(InProgressProcess & process)
        {
@@ -494,11 +498,12 @@ void PreviewLoader::Impl::startLoading()
        // The conversion command.
        ostringstream cs;
        cs << pconverter_->command << ' ' << pconverter_->to << ' '
-          << latexfile << ' ' << int(font_scaling_factor_) << ' '
+          << support::quoteName(latexfile) << ' '
+          << int(font_scaling_factor_) << ' '
           << lyx_gui::hexname(LColor::preview) << ' '
           << lyx_gui::hexname(LColor::background);
 
-       string const command = support::LibScriptSearch(cs.str());
+       string const command = support::libScriptSearch(cs.str());
 
        // Initiate the conversion from LaTeX to bitmap images files.
        support::Forkedcall::SignalTypePtr
@@ -587,7 +592,7 @@ void PreviewLoader::Impl::dumpPreamble(ostream & os) const
        runparams.nice = true;
        runparams.moving_arg = true;
        runparams.free_spacing = true;
-       tmp.makeLaTeXFile(os, buffer_.filePath(), runparams, true, false);
+       tmp.writeLaTeXSource(os, buffer_.filePath(), runparams, true, false);
 
        // FIXME! This is a HACK! The proper fix is to control the 'true'
        // passed to WriteStream below:
@@ -608,7 +613,7 @@ void PreviewLoader::Impl::dumpPreamble(ostream & os) const
        InsetIterator const end = inset_iterator_end(inset);
 
        for (; it != end; ++it)
-               if (it->lyxCode() == InsetOld::MATHMACRO_CODE)
+               if (it->lyxCode() == InsetBase::MATHMACRO_CODE)
                        it->latex(buffer_, os, runparams);
 
        // All equation lables appear as "(#)" + preview.sty's rendering of
@@ -648,8 +653,8 @@ namespace {
 string const unique_filename(string const bufferpath)
 {
        static int theCounter = 0;
-       string const filename = tostr(theCounter++) + "lyxpreview";
-       return support::AddName(bufferpath, filename);
+       string const filename = convert<string>(theCounter++) + "lyxpreview";
+       return support::addName(bufferpath, filename);
 }