]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlPreamble.C
fix crash due to invalidated iterator
[lyx.git] / src / frontends / controllers / ControlPreamble.C
index 52d863c7541955cf167b0eca7b95c58f9dca90e0..6f779099fc4475b4ee7bb2bf692febf78280daa3 100644 (file)
@@ -1,64 +1,64 @@
 /**
- * \file FormPreamble.C
- * Copyright 2001 The LyX Team.
- * See the file COPYING.
+ * \file ControlPreamble.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author Edwin Leuven, leuven@fee.uva.nl
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include "ControlPreamble.h"
-#include "LyXView.h"
-#include "Dialogs.h"
+
 #include "buffer.h"
-#include "lyxrc.h"
-#include "Liason.h"
-#include "gettext.h"
+#include "bufferparams.h"
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
 
+ControlPreamble::ControlPreamble(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
 
-ControlPreamble::ControlPreamble(LyXView & lv, Dialogs & d)
-       : ControlDialog<ControlConnectBD>(lv, d)
+
+bool ControlPreamble::initialiseParams(std::string const &)
 {
-    d_.showPreamble.connect(SigC::slot(this, &ControlPreamble::show));
+       params_ = kernel().buffer().params().preamble;
+       return true;
 }
 
 
-void ControlPreamble::apply()
+void ControlPreamble::clearParams()
 {
-       if (!lv_.view()->available())
-               return;
-   
-       view().apply();
-
-       lv_.buffer()->params.preamble = params();
-       lv_.buffer()->markDirty();
-       Liason::setMinibuffer(&lv_, _("LaTeX preamble set"));
+       params_.erase();
 }
 
 
-string & ControlPreamble::params() const
+void ControlPreamble::dispatchParams()
 {
-       Assert(params_);
-       return *params_;
+       // This can stay because we're going to throw the class away
+       // as soon as xforms 1.1 is released.
+       // Ie, there's no need to define LFUN_BUFFERPREAMBLE_APPLY.
+       Buffer & buffer = kernel().buffer();
+       buffer.params().preamble = params();
+       buffer.markDirty();
 }
 
 
-void ControlPreamble::setParams()
+string const & ControlPreamble::params() const
 {
-       if (params_) delete params_;
-       params_ = new string(lv_.buffer()->params.preamble);
+       return params_;
 }
 
 
-void ControlPreamble::clearParams()
+void ControlPreamble::params(string const & newparams)
 {
-       if (params_) {
-               delete params_;
-               params_ = 0;
-       }
+       params_ = newparams;
 }
+
+} // namespace frontend
+} // namespace lyx