]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetinclude.C
The speed patch: redraw only rows that have changed
[lyx.git] / src / insets / insetinclude.C
index 698533859cb5a4bb371ec26743aea1407d556c01..5afd3f382273c667b96711b17879f2b54c472540 100644 (file)
@@ -22,6 +22,7 @@
 #include "dispatchresult.h"
 #include "exporter.h"
 #include "funcrequest.h"
+#include "FuncStatus.h"
 #include "gettext.h"
 #include "LaTeXFeatures.h"
 #include "lyx_main.h"
@@ -62,6 +63,7 @@ using lyx::support::FileName;
 using lyx::support::GetFileContents;
 using lyx::support::IsFileReadable;
 using lyx::support::IsLyXFilename;
+using lyx::support::latex_path;
 using lyx::support::MakeAbsPath;
 using lyx::support::MakeDisplayPath;
 using lyx::support::MakeRelPath;
@@ -107,7 +109,7 @@ InsetInclude::InsetInclude(InsetInclude const & other)
          params_(other.params_),
          include_label(other.include_label),
          preview_(new RenderMonitoredPreview(this)),
-         set_label_(other.set_label_)
+         set_label_(false)
 {
        preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
 }
@@ -126,10 +128,10 @@ void InsetInclude::doDispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_INSET_MODIFY: {
                InsetCommandParams p;
                InsetIncludeMailer::string2params(cmd.argument, p);
-               if (!p.getCmdName().empty()) {
+               if (!p.getCmdName().empty())
                        set(p, cur.buffer());
-                       cur.bv().update();
-               }
+               else
+                       cur.noUpdate();
                break;
        }
 
@@ -149,6 +151,23 @@ void InsetInclude::doDispatch(LCursor & cur, FuncRequest & cmd)
 }
 
 
+bool InsetInclude::getStatus(LCursor & cur, FuncRequest const & cmd,
+               FuncStatus & flag) const
+{
+       switch (cmd.action) {
+
+       case LFUN_INSET_MODIFY:
+       case LFUN_INSET_DIALOG_UPDATE:
+       case LFUN_INSET_DIALOG_SHOW:
+               flag.enabled(true);
+               return true;
+
+       default:
+               return InsetBase::getStatus(cur, cmd, flag);
+       }
+}
+
+
 InsetCommandParams const & InsetInclude::params() const
 {
        return params_;
@@ -385,6 +404,7 @@ int InsetInclude::latex(Buffer const & buffer, ostream & os,
        }
 
        if (isVerbatim(params_)) {
+               incfile = latex_path(incfile);
                os << '\\' << params_.getCmdName() << '{' << incfile << '}';
        } else if (type(params_) == INPUT) {
                runparams.exportdata->addExternalFile("latex", writefile,
@@ -392,10 +412,13 @@ int InsetInclude::latex(Buffer const & buffer, ostream & os,
 
                // \input wants file with extension (default is .tex)
                if (!IsLyXFilename(included_file)) {
+                       incfile = latex_path(incfile);
                        os << '\\' << params_.getCmdName() << '{' << incfile << '}';
                } else {
+               incfile = ChangeExtension(incfile, ".tex");
+               incfile = latex_path(incfile);
                        os << '\\' << params_.getCmdName() << '{'
-                          << ChangeExtension(incfile, ".tex")
+                          << incfile
                           <<  '}';
                }
        } else {
@@ -404,8 +427,10 @@ int InsetInclude::latex(Buffer const & buffer, ostream & os,
 
                // \include don't want extension and demands that the
                // file really have .tex
+               incfile = ChangeExtension(incfile, string());
+               incfile = latex_path(incfile);
                os << '\\' << params_.getCmdName() << '{'
-                  << ChangeExtension(incfile, string())
+                  << incfile
                   << '}';
        }
 
@@ -736,7 +761,7 @@ void InsetIncludeMailer::string2params(string const & in,
        string id;
        lex >> id;
        if (!lex || id != "Include")
-               return print_mailer_error("InsetBoxMailer", in, 2, "Include");
+               return print_mailer_error("InsetIncludeMailer", in, 2, "Include");
 
        InsetInclude inset(params);
        inset.read(lex);