]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlExternal.C
The reference dialog now disconnects from the inset on Apply. Its behaviour
[lyx.git] / src / frontends / controllers / ControlExternal.C
index d0c4ed75c9101cbf9c69714545a40d8af4313226..73e5433df1b66a6d4c16f7390908d221bfa1b249 100644 (file)
@@ -9,7 +9,7 @@
  *
  * \file ControlExternal.C
  * \author Asger Alstrup
- * \author John Levon
+ * \author John Levon, moz@compsoc.man.ac.uk
  * \author Angus Leeming, a.leeming@ic.ac.uk
  */
 
 #pragma implementation
 #endif
 
+#include "ViewBase.h"
+#include "ButtonControllerBase.h"
 #include "ControlExternal.h"
 #include "buffer.h"
 #include "Dialogs.h"
 #include "Liason.h"
 #include "LyXView.h"
 #include "support/filetools.h"
+#include "support/lstrings.h"
 #include "frontends/FileDialog.h"
 #include "lyx_gui_misc.h" // WriteAlert
+#include "gettext.h"
+#include "BufferView.h"
 
 using std::make_pair;
 using std::vector;
@@ -67,30 +72,33 @@ void ControlExternal::editExternal()
 
        // Create a local copy of the inset and initialise it with this
        // params struct.
-       InsetExternal ie;
-       ie.setFromParams(params());
+       boost::scoped_ptr<InsetExternal> ie;
+       ie.reset(static_cast<InsetExternal *>(inset()->clone(*lv_.buffer())));
+       ie->setFromParams(params());
 
-       ie.editExternal();
+       ie->editExternal();
 }
 
 void ControlExternal::viewExternal()
 {
        view().apply();
 
-       InsetExternal ie;
-       ie.setFromParams(params());
+       boost::scoped_ptr<InsetExternal> ie;
+       ie.reset(static_cast<InsetExternal *>(inset()->clone(*lv_.buffer())));
+       ie->setFromParams(params());
 
-       ie.viewExternal();
+       ie->viewExternal();
 }
 
 void ControlExternal::updateExternal()
 {
        view().apply();
 
-       InsetExternal ie;
-       ie.setFromParams(params());
+       boost::scoped_ptr<InsetExternal> ie;
+       ie.reset(static_cast<InsetExternal *>(inset()->clone(*lv_.buffer())));
+       ie->setFromParams(params());
 
-       ie.updateExternal();
+       ie->updateExternal();
 }
 
 vector<string> const ControlExternal::getTemplates() const
@@ -134,7 +142,7 @@ ExternalTemplate ControlExternal::getTemplate(int i) const
        for (int n = 1; n < i; ++n)
                ++i1;
 
-       return (*i1).second;
+       return i1->second;
 }
 
 
@@ -165,7 +173,7 @@ string const ControlExternal::Browse(string const & input) const
        // FIXME: a temporary hack until the FileDialog interface is updated
        regexp += "|";
 
-       static int once = 0;
+       static int once;
        string current_path;
 
        while (1) {