/**
- * \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 "ViewBase.h"
-#include "ButtonControllerBase.h"
#include "ControlPreamble.h"
-#include "frontends/LyXView.h"
-#include "Dialogs.h"
+
#include "buffer.h"
-#include "lyxrc.h"
-#include "Liason.h"
-#include "gettext.h"
-#include "BufferView.h"
-#include "support/LAssert.h"
-
-ControlPreamble::ControlPreamble(LyXView & lv, Dialogs & d)
- : ControlDialogBD(lv, d),
- params_(0)
-{
- d_.showPreamble.connect(SigC::slot(this, &ControlPreamble::show));
-}
+#include "bufferparams.h"
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+ControlPreamble::ControlPreamble(Dialog & parent)
+ : Dialog::Controller(parent)
+{}
-void ControlPreamble::apply()
+
+bool ControlPreamble::initialiseParams(std::string const &)
{
- if (!lv_.view()->available())
- return;
+ params_ = kernel().buffer().params().preamble;
+ return true;
+}
- view().apply();
- lv_.buffer()->params.preamble = params();
- lv_.buffer()->markDirty();
- Liason::setMinibuffer(&lv_, _("LaTeX preamble set"));
+void ControlPreamble::clearParams()
+{
+ params_.erase();
}
-string & ControlPreamble::params() const
+void ControlPreamble::dispatchParams()
{
- lyx::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