]> git.lyx.org Git - features.git/commitdiff
Rename .C => .cpp for files in src/frontends/controllers, step 2
authorBo Peng <bpeng@lyx.org>
Wed, 25 Apr 2007 18:06:07 +0000 (18:06 +0000)
committerBo Peng <bpeng@lyx.org>
Wed, 25 Apr 2007 18:06:07 +0000 (18:06 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18000 a592a061-630c-0410-9148-cb99ea01b6c8

84 files changed:
src/frontends/controllers/BCView.C [deleted file]
src/frontends/controllers/BCView.cpp [new file with mode: 0644]
src/frontends/controllers/ButtonController.C [deleted file]
src/frontends/controllers/ButtonController.cpp [new file with mode: 0644]
src/frontends/controllers/ButtonPolicies.C [deleted file]
src/frontends/controllers/ButtonPolicies.cpp [new file with mode: 0644]
src/frontends/controllers/ControlAboutlyx.C [deleted file]
src/frontends/controllers/ControlAboutlyx.cpp [new file with mode: 0644]
src/frontends/controllers/ControlBibtex.C [deleted file]
src/frontends/controllers/ControlBibtex.cpp [new file with mode: 0644]
src/frontends/controllers/ControlBox.C [deleted file]
src/frontends/controllers/ControlBox.cpp [new file with mode: 0644]
src/frontends/controllers/ControlBranch.C [deleted file]
src/frontends/controllers/ControlBranch.cpp [new file with mode: 0644]
src/frontends/controllers/ControlChanges.C [deleted file]
src/frontends/controllers/ControlChanges.cpp [new file with mode: 0644]
src/frontends/controllers/ControlCharacter.C [deleted file]
src/frontends/controllers/ControlCharacter.cpp [new file with mode: 0644]
src/frontends/controllers/ControlCitation.C [deleted file]
src/frontends/controllers/ControlCitation.cpp [new file with mode: 0644]
src/frontends/controllers/ControlCommand.C [deleted file]
src/frontends/controllers/ControlCommand.cpp [new file with mode: 0644]
src/frontends/controllers/ControlCommandBuffer.C [deleted file]
src/frontends/controllers/ControlCommandBuffer.cpp [new file with mode: 0644]
src/frontends/controllers/ControlDocument.C [deleted file]
src/frontends/controllers/ControlDocument.cpp [new file with mode: 0644]
src/frontends/controllers/ControlERT.C [deleted file]
src/frontends/controllers/ControlERT.cpp [new file with mode: 0644]
src/frontends/controllers/ControlErrorList.C [deleted file]
src/frontends/controllers/ControlErrorList.cpp [new file with mode: 0644]
src/frontends/controllers/ControlExternal.C [deleted file]
src/frontends/controllers/ControlExternal.cpp [new file with mode: 0644]
src/frontends/controllers/ControlFloat.C [deleted file]
src/frontends/controllers/ControlFloat.cpp [new file with mode: 0644]
src/frontends/controllers/ControlGraphics.C [deleted file]
src/frontends/controllers/ControlGraphics.cpp [new file with mode: 0644]
src/frontends/controllers/ControlInclude.C [deleted file]
src/frontends/controllers/ControlInclude.cpp [new file with mode: 0644]
src/frontends/controllers/ControlLog.C [deleted file]
src/frontends/controllers/ControlLog.cpp [new file with mode: 0644]
src/frontends/controllers/ControlMath.C [deleted file]
src/frontends/controllers/ControlMath.cpp [new file with mode: 0644]
src/frontends/controllers/ControlNote.C [deleted file]
src/frontends/controllers/ControlNote.cpp [new file with mode: 0644]
src/frontends/controllers/ControlParagraph.C [deleted file]
src/frontends/controllers/ControlParagraph.cpp [new file with mode: 0644]
src/frontends/controllers/ControlPrefs.C [deleted file]
src/frontends/controllers/ControlPrefs.cpp [new file with mode: 0644]
src/frontends/controllers/ControlPrint.C [deleted file]
src/frontends/controllers/ControlPrint.cpp [new file with mode: 0644]
src/frontends/controllers/ControlRef.C [deleted file]
src/frontends/controllers/ControlRef.cpp [new file with mode: 0644]
src/frontends/controllers/ControlSearch.C [deleted file]
src/frontends/controllers/ControlSearch.cpp [new file with mode: 0644]
src/frontends/controllers/ControlSendto.C [deleted file]
src/frontends/controllers/ControlSendto.cpp [new file with mode: 0644]
src/frontends/controllers/ControlShowFile.C [deleted file]
src/frontends/controllers/ControlShowFile.cpp [new file with mode: 0644]
src/frontends/controllers/ControlSpellchecker.C [deleted file]
src/frontends/controllers/ControlSpellchecker.cpp [new file with mode: 0644]
src/frontends/controllers/ControlTabular.C [deleted file]
src/frontends/controllers/ControlTabular.cpp [new file with mode: 0644]
src/frontends/controllers/ControlTabularCreate.C [deleted file]
src/frontends/controllers/ControlTabularCreate.cpp [new file with mode: 0644]
src/frontends/controllers/ControlTexinfo.C [deleted file]
src/frontends/controllers/ControlTexinfo.cpp [new file with mode: 0644]
src/frontends/controllers/ControlThesaurus.C [deleted file]
src/frontends/controllers/ControlThesaurus.cpp [new file with mode: 0644]
src/frontends/controllers/ControlToc.C [deleted file]
src/frontends/controllers/ControlToc.cpp [new file with mode: 0644]
src/frontends/controllers/ControlVSpace.C [deleted file]
src/frontends/controllers/ControlVSpace.cpp [new file with mode: 0644]
src/frontends/controllers/ControlViewSource.C [deleted file]
src/frontends/controllers/ControlViewSource.cpp [new file with mode: 0644]
src/frontends/controllers/ControlWrap.C [deleted file]
src/frontends/controllers/ControlWrap.cpp [new file with mode: 0644]
src/frontends/controllers/Dialog.C [deleted file]
src/frontends/controllers/Dialog.cpp [new file with mode: 0644]
src/frontends/controllers/Kernel.C [deleted file]
src/frontends/controllers/Kernel.cpp [new file with mode: 0644]
src/frontends/controllers/tests/biblio.C [deleted file]
src/frontends/controllers/tests/biblio.cpp [new file with mode: 0644]
src/frontends/controllers/tests/boost.C [deleted file]
src/frontends/controllers/tests/boost.cpp [new file with mode: 0644]

diff --git a/src/frontends/controllers/BCView.C b/src/frontends/controllers/BCView.C
deleted file mode 100644 (file)
index 4979c0d..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * \file BCView.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "BCView.h"
-#include "ButtonController.h"
-
-namespace lyx {
-namespace frontend {
-
-CheckedWidget::~CheckedWidget()
-{}
-
-
-BCView::BCView(ButtonController const & p)
-       : parent(p)
-{}
-
-
-ButtonPolicy & BCView::bp() const
-{
-       return parent.bp();
-}
-
-
-void BCView::addCheckedWidget(CheckedWidget * ptr)
-{
-       if (ptr)
-               checked_widgets.push_back(checked_widget_ptr(ptr));
-}
-
-
-bool BCView::checkWidgets() const
-{
-       bool valid = true;
-
-       checked_widget_list::const_iterator it  = checked_widgets.begin();
-       checked_widget_list::const_iterator end = checked_widgets.end();
-
-       for (; it != end; ++it) {
-               valid &= (*it)->check();
-       }
-
-       // return valid status after checking ALL widgets
-       return valid;
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/BCView.cpp b/src/frontends/controllers/BCView.cpp
new file mode 100644 (file)
index 0000000..4979c0d
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * \file BCView.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "BCView.h"
+#include "ButtonController.h"
+
+namespace lyx {
+namespace frontend {
+
+CheckedWidget::~CheckedWidget()
+{}
+
+
+BCView::BCView(ButtonController const & p)
+       : parent(p)
+{}
+
+
+ButtonPolicy & BCView::bp() const
+{
+       return parent.bp();
+}
+
+
+void BCView::addCheckedWidget(CheckedWidget * ptr)
+{
+       if (ptr)
+               checked_widgets.push_back(checked_widget_ptr(ptr));
+}
+
+
+bool BCView::checkWidgets() const
+{
+       bool valid = true;
+
+       checked_widget_list::const_iterator it  = checked_widgets.begin();
+       checked_widget_list::const_iterator end = checked_widgets.end();
+
+       for (; it != end; ++it) {
+               valid &= (*it)->check();
+       }
+
+       // return valid status after checking ALL widgets
+       return valid;
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ButtonController.C b/src/frontends/controllers/ButtonController.C
deleted file mode 100644 (file)
index 5c7d625..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * \file ButtonController.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Allan Rae
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ButtonController.h"
-#include "BCView.h"
-
-namespace lyx {
-namespace frontend {
-
-BCView & ButtonController::view() const
-{
-       BOOST_ASSERT(view_.get());
-       return *view_.get();
-}
-
-void ButtonController::view(BCView * view)
-{
-       view_.reset(view);
-}
-
-
-ButtonPolicy & ButtonController::bp() const
-{
-       BOOST_ASSERT(bp_.get());
-       return *bp_.get();
-}
-
-void ButtonController::bp(ButtonPolicy * bp)
-{
-       bp_.reset(bp);
-}
-
-
-void ButtonController::refresh() const
-{
-       view().refresh();
-}
-
-
-void ButtonController::refreshReadOnly() const
-{
-       view().refreshReadOnly();
-}
-
-
-void ButtonController::ok() const
-{
-       input(ButtonPolicy::SMI_OKAY);
-}
-
-
-void ButtonController::input(ButtonPolicy::SMInput in) const
-{
-       if (ButtonPolicy::SMI_NOOP == in)
-               return;
-       bp().input(in);
-       view().refresh();
-}
-
-
-void ButtonController::apply() const
-{
-       input(ButtonPolicy::SMI_APPLY);
-}
-
-
-void ButtonController::cancel() const
-{
-       input(ButtonPolicy::SMI_CANCEL);
-}
-
-
-void ButtonController::restore() const
-{
-       input(ButtonPolicy::SMI_RESTORE);
-}
-
-
-void ButtonController::hide() const
-{
-       input(ButtonPolicy::SMI_HIDE);
-}
-
-
-void ButtonController::valid(bool v) const
-{
-       if (v) {
-               input(ButtonPolicy::SMI_VALID);
-       } else {
-               input(ButtonPolicy::SMI_INVALID);
-       }
-}
-
-
-bool ButtonController::readOnly(bool ro) const
-{
-       LYXERR(Debug::GUI) << "Setting controller ro: " << ro << std::endl;
-
-       if (ro) {
-               bp().input(ButtonPolicy::SMI_READ_ONLY);
-       } else {
-               bp().input(ButtonPolicy::SMI_READ_WRITE);
-       }
-       view().refreshReadOnly();
-       view().refresh();
-       return ro;
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ButtonController.cpp b/src/frontends/controllers/ButtonController.cpp
new file mode 100644 (file)
index 0000000..5c7d625
--- /dev/null
@@ -0,0 +1,119 @@
+/**
+ * \file ButtonController.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Allan Rae
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ButtonController.h"
+#include "BCView.h"
+
+namespace lyx {
+namespace frontend {
+
+BCView & ButtonController::view() const
+{
+       BOOST_ASSERT(view_.get());
+       return *view_.get();
+}
+
+void ButtonController::view(BCView * view)
+{
+       view_.reset(view);
+}
+
+
+ButtonPolicy & ButtonController::bp() const
+{
+       BOOST_ASSERT(bp_.get());
+       return *bp_.get();
+}
+
+void ButtonController::bp(ButtonPolicy * bp)
+{
+       bp_.reset(bp);
+}
+
+
+void ButtonController::refresh() const
+{
+       view().refresh();
+}
+
+
+void ButtonController::refreshReadOnly() const
+{
+       view().refreshReadOnly();
+}
+
+
+void ButtonController::ok() const
+{
+       input(ButtonPolicy::SMI_OKAY);
+}
+
+
+void ButtonController::input(ButtonPolicy::SMInput in) const
+{
+       if (ButtonPolicy::SMI_NOOP == in)
+               return;
+       bp().input(in);
+       view().refresh();
+}
+
+
+void ButtonController::apply() const
+{
+       input(ButtonPolicy::SMI_APPLY);
+}
+
+
+void ButtonController::cancel() const
+{
+       input(ButtonPolicy::SMI_CANCEL);
+}
+
+
+void ButtonController::restore() const
+{
+       input(ButtonPolicy::SMI_RESTORE);
+}
+
+
+void ButtonController::hide() const
+{
+       input(ButtonPolicy::SMI_HIDE);
+}
+
+
+void ButtonController::valid(bool v) const
+{
+       if (v) {
+               input(ButtonPolicy::SMI_VALID);
+       } else {
+               input(ButtonPolicy::SMI_INVALID);
+       }
+}
+
+
+bool ButtonController::readOnly(bool ro) const
+{
+       LYXERR(Debug::GUI) << "Setting controller ro: " << ro << std::endl;
+
+       if (ro) {
+               bp().input(ButtonPolicy::SMI_READ_ONLY);
+       } else {
+               bp().input(ButtonPolicy::SMI_READ_WRITE);
+       }
+       view().refreshReadOnly();
+       view().refresh();
+       return ro;
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ButtonPolicies.C b/src/frontends/controllers/ButtonPolicies.C
deleted file mode 100644 (file)
index c14b072..0000000
+++ /dev/null
@@ -1,633 +0,0 @@
-/**
- * \file ButtonPolicies.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Allan Rae
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ButtonPolicies.h"
-#include "debug.h"
-#include <string>
-
-using std::endl;
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-namespace {
-
-string const printState(ButtonPolicy::State const & state)
-{
-       string output;
-
-       switch(state) {
-       case ButtonPolicy::INITIAL:
-               output = "INITIAL";
-               break;
-       case ButtonPolicy::VALID:
-               output = "VALID";
-               break;
-       case ButtonPolicy::INVALID:
-               output = "INVALID";
-               break;
-       case ButtonPolicy::APPLIED:
-               output = "APPLIED";
-               break;
-       case ButtonPolicy::RO_INITIAL:
-               output = "RO_INITIAL";
-               break;
-       case ButtonPolicy::RO_VALID:
-               output = "RO_VALID";
-               break;
-       case ButtonPolicy::RO_INVALID:
-               output = "RO_INVALID";
-               break;
-       case ButtonPolicy::RO_APPLIED:
-               output = "RO_APPLIED";
-               break;
-       case ButtonPolicy::BOGUS:
-               output = "BOGUS";
-               break;
-       }
-
-       return output;
-}
-
-
-string const printInput(ButtonPolicy::SMInput const & input)
-{
-       string output;
-
-       switch (input) {
-       case ButtonPolicy::SMI_VALID:
-               output = "SMI_VALID";
-               break;
-       case ButtonPolicy::SMI_INVALID:
-               output = "SMI_INVALID";
-               break;
-       case ButtonPolicy::SMI_OKAY:
-               output = "SMI_OKAY";
-               break;
-       case ButtonPolicy::SMI_APPLY:
-               output = "SMI_APPLY";
-               break;
-       case ButtonPolicy::SMI_CANCEL:
-               output = "SMI_CANCEL";
-               break;
-       case ButtonPolicy::SMI_RESTORE:
-               output = "SMI_RESTORE";
-               break;
-       case ButtonPolicy::SMI_HIDE:
-               output = "SMI_HIDE";
-               break;
-       case ButtonPolicy::SMI_READ_ONLY:
-               output = "SMI_READ_ONLY";
-               break;
-       case ButtonPolicy::SMI_READ_WRITE:
-               output = "SMI_READ_WRITE";
-               break;
-       case ButtonPolicy::SMI_NOOP:
-               output = "SMI_NOOP";
-               break;
-       case ButtonPolicy::SMI_TOTAL:
-               output = "SMI_TOTAL";
-               break;
-       }
-
-       return output;
-}
-
-
-/// Helper function
-void nextState(ButtonPolicy::State & state,
-              ButtonPolicy::SMInput in,
-              ButtonPolicy::StateMachine const & s_m,
-              char const * function_name = "nextState")
-{
-       if (ButtonPolicy::SMI_NOOP == in) return;
-
-       ButtonPolicy::State tmp = s_m[state][in];
-
-       LYXERR(Debug::GUI) << "Transition from state "
-                          << printState(state) << " to state "
-                          << printState(tmp) << " after input "
-                          << printInput(in) << std::endl;
-
-       if (ButtonPolicy::BOGUS != tmp) {
-               state = tmp;
-       } else {
-               lyxerr << function_name
-                      << ": No transition for input "
-                      << printInput(in)
-                      << " from state "
-                      << printState(state)
-                      << endl;
-       }
-}
-
-} // namespace anon
-
-
-/*-----------------------------PreferencesPolicy-----------------------------*/
-
-
-PreferencesPolicy::PreferencesPolicy()
-       : state_(INITIAL),
-         outputs_(APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
-         state_machine_(APPLIED + 1,
-                        StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
-{
-       // Build the state output map
-       outputs_[INITIAL] = CLOSE;
-       outputs_[VALID] = RESTORE | OKAY | APPLY | CANCEL;
-       outputs_[INVALID] = RESTORE | CANCEL;
-       outputs_[APPLIED] = OKAY | CLOSE;
-
-       // Build the state machine one state at a time
-       // NOTE:  Since CANCEL and HIDE always go to INITIAL they are
-       //        left out of the state machine and handled explicitly
-       //        in input().  This won't necessarily be true for all
-       //        policies though so I'll leave those two as distinct
-       //        inputs rather than merge them.  For example, a dialog
-       //        that doesn't update it's input fields when reshown
-       //        after being hidden needs a policy where CANCEL and
-       //        HIDE are treated differently.
-       //
-       // State::INITIAL
-       state_machine_[INITIAL][SMI_READ_ONLY] = INITIAL;
-       state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
-       state_machine_[INITIAL][SMI_VALID] = VALID;
-       state_machine_[INITIAL][SMI_INVALID] = INVALID;
-       // State::VALID
-       state_machine_[VALID][SMI_VALID] = VALID;
-       state_machine_[VALID][SMI_READ_ONLY] = VALID;
-       state_machine_[VALID][SMI_READ_WRITE] = VALID;
-       state_machine_[VALID][SMI_INVALID] = INVALID;
-       state_machine_[VALID][SMI_APPLY] = APPLIED;
-       state_machine_[VALID][SMI_OKAY] = INITIAL;
-       state_machine_[VALID][SMI_RESTORE] = INITIAL;
-       // State::INVALID
-       state_machine_[INVALID][SMI_VALID] = VALID;
-       state_machine_[INVALID][SMI_INVALID] = INVALID;
-       state_machine_[INVALID][SMI_READ_ONLY] = INVALID;
-       state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
-       state_machine_[INVALID][SMI_RESTORE] = INITIAL;
-       // State::APPLIED
-       state_machine_[APPLIED][SMI_VALID] = VALID;
-       state_machine_[APPLIED][SMI_INVALID] = INVALID;
-       state_machine_[APPLIED][SMI_OKAY] = INITIAL;
-       state_machine_[APPLIED][SMI_READ_ONLY] = APPLIED;
-       state_machine_[APPLIED][SMI_READ_WRITE] = APPLIED;
-}
-
-
-void PreferencesPolicy::input(SMInput input)
-{
-       // The APPLIED state is persistent. Next time the dialog is opened,
-       // the user will be able to press 'Save'.
-       if (SMI_CANCEL == input
-           || SMI_HIDE == input) {
-               if (state_ != APPLIED)
-                       state_ = INITIAL;
-       } else {
-               nextState(state_,
-                         input,
-                         state_machine_,
-                         "PreferencesPolicy");
-       }
-}
-
-
-/*-------------------------------OkCancelPolicy------------------------------*/
-
-
-OkCancelPolicy::OkCancelPolicy()
-       : state_(INITIAL),
-         outputs_(INVALID + 1, ButtonPolicy::ALL_BUTTONS),
-         state_machine_(INVALID + 1,
-                        StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
-{
-       // Build the state output map
-       outputs_[INITIAL] = CLOSE;
-       outputs_[VALID] = RESTORE | OKAY | CANCEL;
-       outputs_[INVALID] = RESTORE | CANCEL;
-
-       // Build the state machine one state at a time
-       // NOTE:  Since CANCEL and HIDE always go to INITIAL they are
-       //        left out of the state machine and handled explicitly
-       //        in input()
-       //
-       // State::INITIAL
-       state_machine_[INITIAL][SMI_READ_ONLY] = INITIAL;
-       state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
-       state_machine_[INITIAL][SMI_VALID] = VALID;
-       state_machine_[INITIAL][SMI_INVALID] = INVALID;
-       // State::VALID
-       state_machine_[VALID][SMI_VALID] = VALID;
-       state_machine_[VALID][SMI_READ_ONLY] = VALID;
-       state_machine_[VALID][SMI_READ_WRITE] = VALID;
-       state_machine_[VALID][SMI_INVALID] = INVALID;
-       state_machine_[VALID][SMI_OKAY] = INITIAL;
-       state_machine_[VALID][SMI_RESTORE] = INITIAL;
-       // State::INVALID
-       state_machine_[INVALID][SMI_VALID] = VALID;
-       state_machine_[INVALID][SMI_INVALID] = INVALID;
-       state_machine_[INVALID][SMI_READ_ONLY] = INVALID;
-       state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
-       state_machine_[INVALID][SMI_RESTORE] = INITIAL;
-}
-
-
-
-void OkCancelPolicy::input(SMInput input)
-{
-       //lyxerr << "OkCancelPolicy::input" << endl;
-
-       // CANCEL and HIDE always take us to INITIAL for all cases
-       if (SMI_CANCEL == input
-           || SMI_HIDE == input) {
-               state_ = INITIAL;
-       } else {
-               nextState(state_, input, state_machine_, "OkCancelPolicy");
-       }
-}
-
-
-/*---------------------------OkCancelReadOnlyPolicy-------------------------*/
-
-
-OkCancelReadOnlyPolicy::OkCancelReadOnlyPolicy()
-       : state_(INITIAL),
-         outputs_(RO_INVALID + 1, ButtonPolicy::ALL_BUTTONS),
-         state_machine_(RO_INVALID + 1,
-                        StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
-{
-       // Build the state output map
-       outputs_[INITIAL] = CLOSE;
-       outputs_[VALID] = RESTORE | OKAY | CANCEL;
-       outputs_[INVALID] = RESTORE | CANCEL;
-       outputs_[RO_INITIAL] = CLOSE;
-       outputs_[RO_VALID] = RESTORE | CANCEL;
-       outputs_[RO_INVALID] = RESTORE | CANCEL;
-
-       // Build the state machine one state at a time
-       // NOTE:  Since CANCEL and HIDE always go to INITIAL they are
-       //        left out of the state machine and handled explicitly
-       //        in input()
-       //
-       // State::INITIAL
-       state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
-       state_machine_[INITIAL][SMI_VALID] = VALID;
-       state_machine_[INITIAL][SMI_INVALID] = INVALID;
-       state_machine_[INITIAL][SMI_READ_ONLY] = RO_INITIAL;
-       // State::VALID
-       state_machine_[VALID][SMI_VALID] = VALID;
-       state_machine_[VALID][SMI_READ_WRITE] = VALID;
-       state_machine_[VALID][SMI_INVALID] = INVALID;
-       state_machine_[VALID][SMI_OKAY] = INITIAL;
-       state_machine_[VALID][SMI_RESTORE] = INITIAL;
-       state_machine_[VALID][SMI_READ_ONLY] = RO_VALID;
-       // State::INVALID
-       state_machine_[INVALID][SMI_INVALID] = INVALID;
-       state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
-       state_machine_[INVALID][SMI_VALID] = VALID;
-       state_machine_[INVALID][SMI_RESTORE] = INITIAL;
-       state_machine_[INVALID][SMI_READ_ONLY] = RO_INVALID;
-       // State::RO_INITIAL
-       state_machine_[RO_INITIAL][SMI_READ_ONLY] = RO_INITIAL;
-       state_machine_[RO_INITIAL][SMI_VALID] = RO_VALID;
-       state_machine_[RO_INITIAL][SMI_INVALID] = RO_INVALID;
-       state_machine_[RO_INITIAL][SMI_READ_WRITE] = INITIAL;
-       // State::RO_VALID
-       state_machine_[RO_VALID][SMI_VALID] = RO_VALID;
-       state_machine_[RO_VALID][SMI_READ_ONLY] = RO_VALID;
-       state_machine_[RO_VALID][SMI_INVALID] = RO_INVALID;
-       state_machine_[RO_VALID][SMI_READ_WRITE] = VALID;
-       state_machine_[RO_VALID][SMI_RESTORE] = RO_INITIAL;
-       // State::RO_INVALID
-       state_machine_[RO_INVALID][SMI_READ_ONLY] = RO_INVALID;
-       state_machine_[RO_INVALID][SMI_INVALID] = RO_INVALID;
-       state_machine_[RO_INVALID][SMI_VALID] = RO_VALID;
-       state_machine_[RO_INVALID][SMI_READ_WRITE] = INVALID;
-       state_machine_[RO_INVALID][SMI_RESTORE] = RO_INITIAL;
-}
-
-
-void OkCancelReadOnlyPolicy::input(SMInput input)
-{
-       //lyxerr << "OkCancelReadOnlyPolicy::input" << endl;
-
-       // CANCEL and HIDE always take us to INITIAL for all cases
-       if (SMI_CANCEL == input
-           || SMI_HIDE == input) {
-               state_ = INITIAL;
-       } else {
-               nextState(state_,
-                         input,
-                         state_machine_,
-                         "OkCancelReadOnlyPolicy");
-       }
-}
-
-
-/*--------------------------NoRepeatedApplyReadOnlyPolicy----------------------*/
-
-
-NoRepeatedApplyReadOnlyPolicy::NoRepeatedApplyReadOnlyPolicy()
-       : state_(INITIAL),
-         outputs_(RO_INVALID + 1, ButtonPolicy::ALL_BUTTONS),
-         state_machine_(RO_INVALID + 1,
-                        StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
-{
-       // Build the state output map
-       outputs_[INITIAL] = CLOSE;
-       outputs_[VALID] = RESTORE | OKAY | APPLY | CANCEL;
-       outputs_[INVALID] = RESTORE | CANCEL;
-       outputs_[RO_INITIAL] = CLOSE;
-       outputs_[RO_VALID] = RESTORE | CANCEL;
-       outputs_[RO_INVALID] = RESTORE | CANCEL;
-
-       // Build the state machine one state at a time
-       // NOTE:  Since CANCEL and HIDE always go to INITIAL they are
-       //        left out of the state machine and handled explicitly
-       //        in input()
-       //
-       // State::INITIAL
-       state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
-       state_machine_[INITIAL][SMI_VALID] = VALID;
-       state_machine_[INITIAL][SMI_INVALID] = INVALID;
-       state_machine_[INITIAL][SMI_READ_ONLY] = RO_INITIAL;
-       // State::VALID
-       state_machine_[VALID][SMI_VALID] = VALID;
-       state_machine_[VALID][SMI_READ_WRITE] = VALID;
-       state_machine_[VALID][SMI_INVALID] = INVALID;
-       state_machine_[VALID][SMI_OKAY] = INITIAL;
-       state_machine_[VALID][SMI_APPLY] = INITIAL;
-       state_machine_[VALID][SMI_RESTORE] = INITIAL;
-       state_machine_[VALID][SMI_READ_ONLY] = RO_VALID;
-       // State::INVALID
-       state_machine_[INVALID][SMI_INVALID] = INVALID;
-       state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
-       state_machine_[INVALID][SMI_VALID] = VALID;
-       state_machine_[INVALID][SMI_RESTORE] = INITIAL;
-       state_machine_[INVALID][SMI_READ_ONLY] = RO_INVALID;
-       // State::RO_INITIAL
-       state_machine_[RO_INITIAL][SMI_READ_ONLY] = RO_INITIAL;
-       state_machine_[RO_INITIAL][SMI_VALID] = RO_VALID;
-       state_machine_[RO_INITIAL][SMI_INVALID] = RO_INVALID;
-       state_machine_[RO_INITIAL][SMI_READ_WRITE] = INITIAL;
-       // State::RO_VALID
-       state_machine_[RO_VALID][SMI_VALID] = RO_VALID;
-       state_machine_[RO_VALID][SMI_READ_ONLY] = RO_VALID;
-       state_machine_[RO_VALID][SMI_INVALID] = RO_INVALID;
-       state_machine_[RO_VALID][SMI_READ_WRITE] = VALID;
-       state_machine_[RO_VALID][SMI_RESTORE] = RO_INITIAL;
-       // State::RO_INVALID
-       state_machine_[RO_INVALID][SMI_INVALID] = RO_INVALID;
-       state_machine_[RO_INVALID][SMI_READ_ONLY] = RO_INVALID;
-       state_machine_[RO_INVALID][SMI_VALID] = RO_VALID;
-       state_machine_[RO_INVALID][SMI_READ_WRITE] = INVALID;
-       state_machine_[RO_INVALID][SMI_RESTORE] = RO_INITIAL;
-}
-
-
-void NoRepeatedApplyReadOnlyPolicy::input(SMInput input)
-{
-       //lyxerr << "NoReapeatedApplyReadOnlyPolicy::input" << endl;
-
-       // CANCEL and HIDE always take us to INITIAL for all cases
-       if (SMI_CANCEL == input
-           || SMI_HIDE == input) {
-               state_ = INITIAL;
-       } else {
-               nextState(state_,
-                         input,
-                         state_machine_,
-                         "NoRepeatedApplyReadOnlyPolicy");
-       }
-}
-
-
-/*--------------------------OkApplyCancelReadOnlyPolicy----------------------*/
-
-
-OkApplyCancelReadOnlyPolicy::OkApplyCancelReadOnlyPolicy()
-       : state_(INITIAL),
-         outputs_(RO_APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
-         state_machine_(RO_APPLIED + 1,
-                        StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
-{
-       // Build the state output map
-       outputs_[INITIAL] = CLOSE;
-       outputs_[VALID] = RESTORE | OKAY | APPLY | CANCEL;
-       outputs_[INVALID] = RESTORE | CANCEL;
-       outputs_[APPLIED] = OKAY | APPLY | CLOSE;
-       outputs_[RO_INITIAL] = CLOSE;
-       outputs_[RO_VALID] = RESTORE | CANCEL;
-       outputs_[RO_INVALID] = RESTORE | CANCEL;
-       outputs_[RO_APPLIED] = CLOSE;
-
-       // Build the state machine one state at a time
-       // NOTE:  Since CANCEL and HIDE always go to INITIAL they are
-       //        left out of the state machine and handled explicitly
-       //        in input()
-       //
-       // State::INITIAL
-       state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
-       state_machine_[INITIAL][SMI_VALID] = VALID;
-       state_machine_[INITIAL][SMI_INVALID] = INVALID;
-       state_machine_[INITIAL][SMI_READ_ONLY] = RO_INITIAL;
-       // State::VALID
-       state_machine_[VALID][SMI_VALID] = VALID;
-       state_machine_[VALID][SMI_READ_WRITE] = VALID;
-       state_machine_[VALID][SMI_INVALID] = INVALID;
-       state_machine_[VALID][SMI_OKAY] = INITIAL;
-       state_machine_[VALID][SMI_RESTORE] = INITIAL;
-       state_machine_[VALID][SMI_APPLY] = APPLIED;
-       state_machine_[VALID][SMI_READ_ONLY] = RO_VALID;
-       // State::INVALID
-       state_machine_[INVALID][SMI_INVALID] = INVALID;
-       state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
-       state_machine_[INVALID][SMI_VALID] = VALID;
-       state_machine_[INVALID][SMI_RESTORE] = INITIAL;
-       state_machine_[INVALID][SMI_READ_ONLY] = RO_INVALID;
-       // State::APPLIED
-       state_machine_[APPLIED][SMI_APPLY] = APPLIED;
-       state_machine_[APPLIED][SMI_READ_WRITE] = APPLIED;
-       state_machine_[APPLIED][SMI_VALID] = VALID;
-       state_machine_[APPLIED][SMI_INVALID] = INVALID;
-       state_machine_[APPLIED][SMI_OKAY] = INITIAL;
-       state_machine_[APPLIED][SMI_READ_ONLY] = RO_APPLIED;
-       // State::RO_INITIAL
-       state_machine_[RO_INITIAL][SMI_READ_ONLY] = RO_INITIAL;
-       state_machine_[RO_INITIAL][SMI_VALID] = RO_VALID;
-       state_machine_[RO_INITIAL][SMI_INVALID] = RO_INVALID;
-       state_machine_[RO_INITIAL][SMI_READ_WRITE] = INITIAL;
-       // State::RO_VALID
-       state_machine_[RO_VALID][SMI_VALID] = RO_VALID;
-       state_machine_[RO_VALID][SMI_READ_ONLY] = RO_VALID;
-       state_machine_[RO_VALID][SMI_INVALID] = RO_INVALID;
-       state_machine_[RO_VALID][SMI_READ_WRITE] = VALID;
-       state_machine_[RO_VALID][SMI_RESTORE] = RO_INITIAL;
-       // State::RO_INVALID
-       state_machine_[RO_INVALID][SMI_INVALID] = RO_INVALID;
-       state_machine_[RO_INVALID][SMI_READ_ONLY] = RO_INVALID;
-       state_machine_[RO_INVALID][SMI_VALID] = RO_VALID;
-       state_machine_[RO_INVALID][SMI_READ_WRITE] = INVALID;
-       state_machine_[RO_INVALID][SMI_RESTORE] = RO_INITIAL;
-       // State::RO_APPLIED
-       state_machine_[RO_APPLIED][SMI_READ_ONLY] = RO_APPLIED;
-       state_machine_[RO_APPLIED][SMI_INVALID] = RO_INVALID;
-       state_machine_[RO_APPLIED][SMI_VALID] = RO_VALID;
-       state_machine_[RO_APPLIED][SMI_READ_WRITE] = APPLIED;
-}
-
-
-void OkApplyCancelReadOnlyPolicy::input(SMInput input)
-{
-       //lyxerr << "OkApplyCancelReadOnlyPolicy::input" << endl;
-
-       // CANCEL and HIDE always take us to INITIAL for all cases
-       if (SMI_CANCEL == input
-           || SMI_HIDE == input) {
-               state_ = INITIAL;
-       } else {
-               nextState(state_,
-                         input,
-                         state_machine_,
-                         "OkApplyCancelReadOnlyPolicy");
-       }
-}
-
-
-/*--------------------------OkApplyCancelPolicy----------------------*/
-
-
-OkApplyCancelPolicy::OkApplyCancelPolicy()
-       : state_(INITIAL),
-         outputs_(APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
-         state_machine_(APPLIED + 1,
-                        StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
-{
-       // Build the state output map
-       outputs_[INITIAL] = CLOSE;
-       outputs_[VALID] = RESTORE | OKAY | APPLY | CANCEL;
-       outputs_[INVALID] = RESTORE | CANCEL;
-       outputs_[APPLIED] = OKAY | APPLY | CLOSE;
-
-       // Build the state machine one state at a time
-       // NOTE:  Since CANCEL and HIDE always go to INITIAL they are
-       //        left out of the state machine and handled explicitly
-       //        in input()
-       //
-       // State::INITIAL
-       state_machine_[INITIAL][SMI_READ_ONLY] = INITIAL;
-       state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
-       state_machine_[INITIAL][SMI_VALID] = VALID;
-       state_machine_[INITIAL][SMI_INVALID] = INVALID;
-       // State::VALID
-       state_machine_[VALID][SMI_VALID] = VALID;
-       state_machine_[VALID][SMI_READ_ONLY] = VALID;
-       state_machine_[VALID][SMI_READ_WRITE] = VALID;
-       state_machine_[VALID][SMI_INVALID] = INVALID;
-       state_machine_[VALID][SMI_OKAY] = INITIAL;
-       state_machine_[VALID][SMI_RESTORE] = INITIAL;
-       state_machine_[VALID][SMI_APPLY] = APPLIED;
-       // State::INVALID
-       state_machine_[INVALID][SMI_INVALID] = INVALID;
-       state_machine_[INVALID][SMI_READ_ONLY] = INVALID;
-       state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
-       state_machine_[INVALID][SMI_VALID] = VALID;
-       state_machine_[INVALID][SMI_RESTORE] = INITIAL;
-       // State::APPLIED
-       state_machine_[APPLIED][SMI_APPLY] = APPLIED;
-       state_machine_[APPLIED][SMI_READ_ONLY] = APPLIED;
-       state_machine_[APPLIED][SMI_READ_WRITE] = APPLIED;
-       state_machine_[APPLIED][SMI_VALID] = VALID;
-       state_machine_[APPLIED][SMI_INVALID] = INVALID;
-       state_machine_[APPLIED][SMI_OKAY] = INITIAL;
-}
-
-
-void OkApplyCancelPolicy::input(SMInput input)
-{
-       //lyxerr << "OkApplyCancelPolicy::input" << endl;
-
-       // CANCEL and HIDE always take us to INITIAL for all cases
-       if (SMI_CANCEL == input
-           || SMI_HIDE == input) {
-               state_ = INITIAL;
-       } else {
-               nextState(state_,
-                         input,
-                         state_machine_,
-                         "OkApplyCancelPolicy");
-       }
-}
-
-
-/*--------------------------NoRepeatedApplyPolicy----------------------*/
-
-
-NoRepeatedApplyPolicy::NoRepeatedApplyPolicy()
-       : state_(INITIAL),
-         outputs_(INVALID + 1, ButtonPolicy::ALL_BUTTONS),
-         state_machine_(INVALID + 1,
-                        StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
-{
-       // Build the state output map
-       outputs_[INITIAL] = CLOSE;
-       outputs_[VALID] = RESTORE | OKAY | APPLY | CANCEL;
-       outputs_[INVALID] = RESTORE | CANCEL;
-
-       // Build the state machine one state at a time
-       // NOTE:  Since CANCEL and HIDE always go to INITIAL they are
-       //        left out of the state machine and handled explicitly
-       //        in input()
-       //
-       // State::INITIAL
-       state_machine_[INITIAL][SMI_READ_ONLY] = INITIAL;
-       state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
-       state_machine_[INITIAL][SMI_VALID] = VALID;
-       state_machine_[INITIAL][SMI_INVALID] = INVALID;
-       // State::VALID
-       state_machine_[VALID][SMI_VALID] = VALID;
-       state_machine_[VALID][SMI_READ_ONLY] = VALID;
-       state_machine_[VALID][SMI_READ_WRITE] = VALID;
-       state_machine_[VALID][SMI_INVALID] = INVALID;
-       state_machine_[VALID][SMI_OKAY] = INITIAL;
-       state_machine_[VALID][SMI_APPLY] = INITIAL;
-       state_machine_[VALID][SMI_RESTORE] = INITIAL;
-       // State::INVALID
-       state_machine_[INVALID][SMI_INVALID] = INVALID;
-       state_machine_[INVALID][SMI_READ_ONLY] = INVALID;
-       state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
-       state_machine_[INVALID][SMI_VALID] = VALID;
-       state_machine_[INVALID][SMI_RESTORE] = INITIAL;
-}
-
-
-void NoRepeatedApplyPolicy::input(SMInput input)
-{
-       //lyxerr << "NoRepeatedApplyPolicy::input" << endl;
-
-       // CANCEL and HIDE always take us to INITIAL for all cases
-       if (SMI_CANCEL == input
-           || SMI_HIDE == input) {
-               state_ = INITIAL;
-       } else {
-               nextState(state_,
-                         input,
-                         state_machine_,
-                         "NoRepeatedApplyPolicy");
-       }
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ButtonPolicies.cpp b/src/frontends/controllers/ButtonPolicies.cpp
new file mode 100644 (file)
index 0000000..c14b072
--- /dev/null
@@ -0,0 +1,633 @@
+/**
+ * \file ButtonPolicies.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Allan Rae
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ButtonPolicies.h"
+#include "debug.h"
+#include <string>
+
+using std::endl;
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+namespace {
+
+string const printState(ButtonPolicy::State const & state)
+{
+       string output;
+
+       switch(state) {
+       case ButtonPolicy::INITIAL:
+               output = "INITIAL";
+               break;
+       case ButtonPolicy::VALID:
+               output = "VALID";
+               break;
+       case ButtonPolicy::INVALID:
+               output = "INVALID";
+               break;
+       case ButtonPolicy::APPLIED:
+               output = "APPLIED";
+               break;
+       case ButtonPolicy::RO_INITIAL:
+               output = "RO_INITIAL";
+               break;
+       case ButtonPolicy::RO_VALID:
+               output = "RO_VALID";
+               break;
+       case ButtonPolicy::RO_INVALID:
+               output = "RO_INVALID";
+               break;
+       case ButtonPolicy::RO_APPLIED:
+               output = "RO_APPLIED";
+               break;
+       case ButtonPolicy::BOGUS:
+               output = "BOGUS";
+               break;
+       }
+
+       return output;
+}
+
+
+string const printInput(ButtonPolicy::SMInput const & input)
+{
+       string output;
+
+       switch (input) {
+       case ButtonPolicy::SMI_VALID:
+               output = "SMI_VALID";
+               break;
+       case ButtonPolicy::SMI_INVALID:
+               output = "SMI_INVALID";
+               break;
+       case ButtonPolicy::SMI_OKAY:
+               output = "SMI_OKAY";
+               break;
+       case ButtonPolicy::SMI_APPLY:
+               output = "SMI_APPLY";
+               break;
+       case ButtonPolicy::SMI_CANCEL:
+               output = "SMI_CANCEL";
+               break;
+       case ButtonPolicy::SMI_RESTORE:
+               output = "SMI_RESTORE";
+               break;
+       case ButtonPolicy::SMI_HIDE:
+               output = "SMI_HIDE";
+               break;
+       case ButtonPolicy::SMI_READ_ONLY:
+               output = "SMI_READ_ONLY";
+               break;
+       case ButtonPolicy::SMI_READ_WRITE:
+               output = "SMI_READ_WRITE";
+               break;
+       case ButtonPolicy::SMI_NOOP:
+               output = "SMI_NOOP";
+               break;
+       case ButtonPolicy::SMI_TOTAL:
+               output = "SMI_TOTAL";
+               break;
+       }
+
+       return output;
+}
+
+
+/// Helper function
+void nextState(ButtonPolicy::State & state,
+              ButtonPolicy::SMInput in,
+              ButtonPolicy::StateMachine const & s_m,
+              char const * function_name = "nextState")
+{
+       if (ButtonPolicy::SMI_NOOP == in) return;
+
+       ButtonPolicy::State tmp = s_m[state][in];
+
+       LYXERR(Debug::GUI) << "Transition from state "
+                          << printState(state) << " to state "
+                          << printState(tmp) << " after input "
+                          << printInput(in) << std::endl;
+
+       if (ButtonPolicy::BOGUS != tmp) {
+               state = tmp;
+       } else {
+               lyxerr << function_name
+                      << ": No transition for input "
+                      << printInput(in)
+                      << " from state "
+                      << printState(state)
+                      << endl;
+       }
+}
+
+} // namespace anon
+
+
+/*-----------------------------PreferencesPolicy-----------------------------*/
+
+
+PreferencesPolicy::PreferencesPolicy()
+       : state_(INITIAL),
+         outputs_(APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
+         state_machine_(APPLIED + 1,
+                        StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
+{
+       // Build the state output map
+       outputs_[INITIAL] = CLOSE;
+       outputs_[VALID] = RESTORE | OKAY | APPLY | CANCEL;
+       outputs_[INVALID] = RESTORE | CANCEL;
+       outputs_[APPLIED] = OKAY | CLOSE;
+
+       // Build the state machine one state at a time
+       // NOTE:  Since CANCEL and HIDE always go to INITIAL they are
+       //        left out of the state machine and handled explicitly
+       //        in input().  This won't necessarily be true for all
+       //        policies though so I'll leave those two as distinct
+       //        inputs rather than merge them.  For example, a dialog
+       //        that doesn't update it's input fields when reshown
+       //        after being hidden needs a policy where CANCEL and
+       //        HIDE are treated differently.
+       //
+       // State::INITIAL
+       state_machine_[INITIAL][SMI_READ_ONLY] = INITIAL;
+       state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
+       state_machine_[INITIAL][SMI_VALID] = VALID;
+       state_machine_[INITIAL][SMI_INVALID] = INVALID;
+       // State::VALID
+       state_machine_[VALID][SMI_VALID] = VALID;
+       state_machine_[VALID][SMI_READ_ONLY] = VALID;
+       state_machine_[VALID][SMI_READ_WRITE] = VALID;
+       state_machine_[VALID][SMI_INVALID] = INVALID;
+       state_machine_[VALID][SMI_APPLY] = APPLIED;
+       state_machine_[VALID][SMI_OKAY] = INITIAL;
+       state_machine_[VALID][SMI_RESTORE] = INITIAL;
+       // State::INVALID
+       state_machine_[INVALID][SMI_VALID] = VALID;
+       state_machine_[INVALID][SMI_INVALID] = INVALID;
+       state_machine_[INVALID][SMI_READ_ONLY] = INVALID;
+       state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
+       state_machine_[INVALID][SMI_RESTORE] = INITIAL;
+       // State::APPLIED
+       state_machine_[APPLIED][SMI_VALID] = VALID;
+       state_machine_[APPLIED][SMI_INVALID] = INVALID;
+       state_machine_[APPLIED][SMI_OKAY] = INITIAL;
+       state_machine_[APPLIED][SMI_READ_ONLY] = APPLIED;
+       state_machine_[APPLIED][SMI_READ_WRITE] = APPLIED;
+}
+
+
+void PreferencesPolicy::input(SMInput input)
+{
+       // The APPLIED state is persistent. Next time the dialog is opened,
+       // the user will be able to press 'Save'.
+       if (SMI_CANCEL == input
+           || SMI_HIDE == input) {
+               if (state_ != APPLIED)
+                       state_ = INITIAL;
+       } else {
+               nextState(state_,
+                         input,
+                         state_machine_,
+                         "PreferencesPolicy");
+       }
+}
+
+
+/*-------------------------------OkCancelPolicy------------------------------*/
+
+
+OkCancelPolicy::OkCancelPolicy()
+       : state_(INITIAL),
+         outputs_(INVALID + 1, ButtonPolicy::ALL_BUTTONS),
+         state_machine_(INVALID + 1,
+                        StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
+{
+       // Build the state output map
+       outputs_[INITIAL] = CLOSE;
+       outputs_[VALID] = RESTORE | OKAY | CANCEL;
+       outputs_[INVALID] = RESTORE | CANCEL;
+
+       // Build the state machine one state at a time
+       // NOTE:  Since CANCEL and HIDE always go to INITIAL they are
+       //        left out of the state machine and handled explicitly
+       //        in input()
+       //
+       // State::INITIAL
+       state_machine_[INITIAL][SMI_READ_ONLY] = INITIAL;
+       state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
+       state_machine_[INITIAL][SMI_VALID] = VALID;
+       state_machine_[INITIAL][SMI_INVALID] = INVALID;
+       // State::VALID
+       state_machine_[VALID][SMI_VALID] = VALID;
+       state_machine_[VALID][SMI_READ_ONLY] = VALID;
+       state_machine_[VALID][SMI_READ_WRITE] = VALID;
+       state_machine_[VALID][SMI_INVALID] = INVALID;
+       state_machine_[VALID][SMI_OKAY] = INITIAL;
+       state_machine_[VALID][SMI_RESTORE] = INITIAL;
+       // State::INVALID
+       state_machine_[INVALID][SMI_VALID] = VALID;
+       state_machine_[INVALID][SMI_INVALID] = INVALID;
+       state_machine_[INVALID][SMI_READ_ONLY] = INVALID;
+       state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
+       state_machine_[INVALID][SMI_RESTORE] = INITIAL;
+}
+
+
+
+void OkCancelPolicy::input(SMInput input)
+{
+       //lyxerr << "OkCancelPolicy::input" << endl;
+
+       // CANCEL and HIDE always take us to INITIAL for all cases
+       if (SMI_CANCEL == input
+           || SMI_HIDE == input) {
+               state_ = INITIAL;
+       } else {
+               nextState(state_, input, state_machine_, "OkCancelPolicy");
+       }
+}
+
+
+/*---------------------------OkCancelReadOnlyPolicy-------------------------*/
+
+
+OkCancelReadOnlyPolicy::OkCancelReadOnlyPolicy()
+       : state_(INITIAL),
+         outputs_(RO_INVALID + 1, ButtonPolicy::ALL_BUTTONS),
+         state_machine_(RO_INVALID + 1,
+                        StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
+{
+       // Build the state output map
+       outputs_[INITIAL] = CLOSE;
+       outputs_[VALID] = RESTORE | OKAY | CANCEL;
+       outputs_[INVALID] = RESTORE | CANCEL;
+       outputs_[RO_INITIAL] = CLOSE;
+       outputs_[RO_VALID] = RESTORE | CANCEL;
+       outputs_[RO_INVALID] = RESTORE | CANCEL;
+
+       // Build the state machine one state at a time
+       // NOTE:  Since CANCEL and HIDE always go to INITIAL they are
+       //        left out of the state machine and handled explicitly
+       //        in input()
+       //
+       // State::INITIAL
+       state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
+       state_machine_[INITIAL][SMI_VALID] = VALID;
+       state_machine_[INITIAL][SMI_INVALID] = INVALID;
+       state_machine_[INITIAL][SMI_READ_ONLY] = RO_INITIAL;
+       // State::VALID
+       state_machine_[VALID][SMI_VALID] = VALID;
+       state_machine_[VALID][SMI_READ_WRITE] = VALID;
+       state_machine_[VALID][SMI_INVALID] = INVALID;
+       state_machine_[VALID][SMI_OKAY] = INITIAL;
+       state_machine_[VALID][SMI_RESTORE] = INITIAL;
+       state_machine_[VALID][SMI_READ_ONLY] = RO_VALID;
+       // State::INVALID
+       state_machine_[INVALID][SMI_INVALID] = INVALID;
+       state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
+       state_machine_[INVALID][SMI_VALID] = VALID;
+       state_machine_[INVALID][SMI_RESTORE] = INITIAL;
+       state_machine_[INVALID][SMI_READ_ONLY] = RO_INVALID;
+       // State::RO_INITIAL
+       state_machine_[RO_INITIAL][SMI_READ_ONLY] = RO_INITIAL;
+       state_machine_[RO_INITIAL][SMI_VALID] = RO_VALID;
+       state_machine_[RO_INITIAL][SMI_INVALID] = RO_INVALID;
+       state_machine_[RO_INITIAL][SMI_READ_WRITE] = INITIAL;
+       // State::RO_VALID
+       state_machine_[RO_VALID][SMI_VALID] = RO_VALID;
+       state_machine_[RO_VALID][SMI_READ_ONLY] = RO_VALID;
+       state_machine_[RO_VALID][SMI_INVALID] = RO_INVALID;
+       state_machine_[RO_VALID][SMI_READ_WRITE] = VALID;
+       state_machine_[RO_VALID][SMI_RESTORE] = RO_INITIAL;
+       // State::RO_INVALID
+       state_machine_[RO_INVALID][SMI_READ_ONLY] = RO_INVALID;
+       state_machine_[RO_INVALID][SMI_INVALID] = RO_INVALID;
+       state_machine_[RO_INVALID][SMI_VALID] = RO_VALID;
+       state_machine_[RO_INVALID][SMI_READ_WRITE] = INVALID;
+       state_machine_[RO_INVALID][SMI_RESTORE] = RO_INITIAL;
+}
+
+
+void OkCancelReadOnlyPolicy::input(SMInput input)
+{
+       //lyxerr << "OkCancelReadOnlyPolicy::input" << endl;
+
+       // CANCEL and HIDE always take us to INITIAL for all cases
+       if (SMI_CANCEL == input
+           || SMI_HIDE == input) {
+               state_ = INITIAL;
+       } else {
+               nextState(state_,
+                         input,
+                         state_machine_,
+                         "OkCancelReadOnlyPolicy");
+       }
+}
+
+
+/*--------------------------NoRepeatedApplyReadOnlyPolicy----------------------*/
+
+
+NoRepeatedApplyReadOnlyPolicy::NoRepeatedApplyReadOnlyPolicy()
+       : state_(INITIAL),
+         outputs_(RO_INVALID + 1, ButtonPolicy::ALL_BUTTONS),
+         state_machine_(RO_INVALID + 1,
+                        StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
+{
+       // Build the state output map
+       outputs_[INITIAL] = CLOSE;
+       outputs_[VALID] = RESTORE | OKAY | APPLY | CANCEL;
+       outputs_[INVALID] = RESTORE | CANCEL;
+       outputs_[RO_INITIAL] = CLOSE;
+       outputs_[RO_VALID] = RESTORE | CANCEL;
+       outputs_[RO_INVALID] = RESTORE | CANCEL;
+
+       // Build the state machine one state at a time
+       // NOTE:  Since CANCEL and HIDE always go to INITIAL they are
+       //        left out of the state machine and handled explicitly
+       //        in input()
+       //
+       // State::INITIAL
+       state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
+       state_machine_[INITIAL][SMI_VALID] = VALID;
+       state_machine_[INITIAL][SMI_INVALID] = INVALID;
+       state_machine_[INITIAL][SMI_READ_ONLY] = RO_INITIAL;
+       // State::VALID
+       state_machine_[VALID][SMI_VALID] = VALID;
+       state_machine_[VALID][SMI_READ_WRITE] = VALID;
+       state_machine_[VALID][SMI_INVALID] = INVALID;
+       state_machine_[VALID][SMI_OKAY] = INITIAL;
+       state_machine_[VALID][SMI_APPLY] = INITIAL;
+       state_machine_[VALID][SMI_RESTORE] = INITIAL;
+       state_machine_[VALID][SMI_READ_ONLY] = RO_VALID;
+       // State::INVALID
+       state_machine_[INVALID][SMI_INVALID] = INVALID;
+       state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
+       state_machine_[INVALID][SMI_VALID] = VALID;
+       state_machine_[INVALID][SMI_RESTORE] = INITIAL;
+       state_machine_[INVALID][SMI_READ_ONLY] = RO_INVALID;
+       // State::RO_INITIAL
+       state_machine_[RO_INITIAL][SMI_READ_ONLY] = RO_INITIAL;
+       state_machine_[RO_INITIAL][SMI_VALID] = RO_VALID;
+       state_machine_[RO_INITIAL][SMI_INVALID] = RO_INVALID;
+       state_machine_[RO_INITIAL][SMI_READ_WRITE] = INITIAL;
+       // State::RO_VALID
+       state_machine_[RO_VALID][SMI_VALID] = RO_VALID;
+       state_machine_[RO_VALID][SMI_READ_ONLY] = RO_VALID;
+       state_machine_[RO_VALID][SMI_INVALID] = RO_INVALID;
+       state_machine_[RO_VALID][SMI_READ_WRITE] = VALID;
+       state_machine_[RO_VALID][SMI_RESTORE] = RO_INITIAL;
+       // State::RO_INVALID
+       state_machine_[RO_INVALID][SMI_INVALID] = RO_INVALID;
+       state_machine_[RO_INVALID][SMI_READ_ONLY] = RO_INVALID;
+       state_machine_[RO_INVALID][SMI_VALID] = RO_VALID;
+       state_machine_[RO_INVALID][SMI_READ_WRITE] = INVALID;
+       state_machine_[RO_INVALID][SMI_RESTORE] = RO_INITIAL;
+}
+
+
+void NoRepeatedApplyReadOnlyPolicy::input(SMInput input)
+{
+       //lyxerr << "NoReapeatedApplyReadOnlyPolicy::input" << endl;
+
+       // CANCEL and HIDE always take us to INITIAL for all cases
+       if (SMI_CANCEL == input
+           || SMI_HIDE == input) {
+               state_ = INITIAL;
+       } else {
+               nextState(state_,
+                         input,
+                         state_machine_,
+                         "NoRepeatedApplyReadOnlyPolicy");
+       }
+}
+
+
+/*--------------------------OkApplyCancelReadOnlyPolicy----------------------*/
+
+
+OkApplyCancelReadOnlyPolicy::OkApplyCancelReadOnlyPolicy()
+       : state_(INITIAL),
+         outputs_(RO_APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
+         state_machine_(RO_APPLIED + 1,
+                        StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
+{
+       // Build the state output map
+       outputs_[INITIAL] = CLOSE;
+       outputs_[VALID] = RESTORE | OKAY | APPLY | CANCEL;
+       outputs_[INVALID] = RESTORE | CANCEL;
+       outputs_[APPLIED] = OKAY | APPLY | CLOSE;
+       outputs_[RO_INITIAL] = CLOSE;
+       outputs_[RO_VALID] = RESTORE | CANCEL;
+       outputs_[RO_INVALID] = RESTORE | CANCEL;
+       outputs_[RO_APPLIED] = CLOSE;
+
+       // Build the state machine one state at a time
+       // NOTE:  Since CANCEL and HIDE always go to INITIAL they are
+       //        left out of the state machine and handled explicitly
+       //        in input()
+       //
+       // State::INITIAL
+       state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
+       state_machine_[INITIAL][SMI_VALID] = VALID;
+       state_machine_[INITIAL][SMI_INVALID] = INVALID;
+       state_machine_[INITIAL][SMI_READ_ONLY] = RO_INITIAL;
+       // State::VALID
+       state_machine_[VALID][SMI_VALID] = VALID;
+       state_machine_[VALID][SMI_READ_WRITE] = VALID;
+       state_machine_[VALID][SMI_INVALID] = INVALID;
+       state_machine_[VALID][SMI_OKAY] = INITIAL;
+       state_machine_[VALID][SMI_RESTORE] = INITIAL;
+       state_machine_[VALID][SMI_APPLY] = APPLIED;
+       state_machine_[VALID][SMI_READ_ONLY] = RO_VALID;
+       // State::INVALID
+       state_machine_[INVALID][SMI_INVALID] = INVALID;
+       state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
+       state_machine_[INVALID][SMI_VALID] = VALID;
+       state_machine_[INVALID][SMI_RESTORE] = INITIAL;
+       state_machine_[INVALID][SMI_READ_ONLY] = RO_INVALID;
+       // State::APPLIED
+       state_machine_[APPLIED][SMI_APPLY] = APPLIED;
+       state_machine_[APPLIED][SMI_READ_WRITE] = APPLIED;
+       state_machine_[APPLIED][SMI_VALID] = VALID;
+       state_machine_[APPLIED][SMI_INVALID] = INVALID;
+       state_machine_[APPLIED][SMI_OKAY] = INITIAL;
+       state_machine_[APPLIED][SMI_READ_ONLY] = RO_APPLIED;
+       // State::RO_INITIAL
+       state_machine_[RO_INITIAL][SMI_READ_ONLY] = RO_INITIAL;
+       state_machine_[RO_INITIAL][SMI_VALID] = RO_VALID;
+       state_machine_[RO_INITIAL][SMI_INVALID] = RO_INVALID;
+       state_machine_[RO_INITIAL][SMI_READ_WRITE] = INITIAL;
+       // State::RO_VALID
+       state_machine_[RO_VALID][SMI_VALID] = RO_VALID;
+       state_machine_[RO_VALID][SMI_READ_ONLY] = RO_VALID;
+       state_machine_[RO_VALID][SMI_INVALID] = RO_INVALID;
+       state_machine_[RO_VALID][SMI_READ_WRITE] = VALID;
+       state_machine_[RO_VALID][SMI_RESTORE] = RO_INITIAL;
+       // State::RO_INVALID
+       state_machine_[RO_INVALID][SMI_INVALID] = RO_INVALID;
+       state_machine_[RO_INVALID][SMI_READ_ONLY] = RO_INVALID;
+       state_machine_[RO_INVALID][SMI_VALID] = RO_VALID;
+       state_machine_[RO_INVALID][SMI_READ_WRITE] = INVALID;
+       state_machine_[RO_INVALID][SMI_RESTORE] = RO_INITIAL;
+       // State::RO_APPLIED
+       state_machine_[RO_APPLIED][SMI_READ_ONLY] = RO_APPLIED;
+       state_machine_[RO_APPLIED][SMI_INVALID] = RO_INVALID;
+       state_machine_[RO_APPLIED][SMI_VALID] = RO_VALID;
+       state_machine_[RO_APPLIED][SMI_READ_WRITE] = APPLIED;
+}
+
+
+void OkApplyCancelReadOnlyPolicy::input(SMInput input)
+{
+       //lyxerr << "OkApplyCancelReadOnlyPolicy::input" << endl;
+
+       // CANCEL and HIDE always take us to INITIAL for all cases
+       if (SMI_CANCEL == input
+           || SMI_HIDE == input) {
+               state_ = INITIAL;
+       } else {
+               nextState(state_,
+                         input,
+                         state_machine_,
+                         "OkApplyCancelReadOnlyPolicy");
+       }
+}
+
+
+/*--------------------------OkApplyCancelPolicy----------------------*/
+
+
+OkApplyCancelPolicy::OkApplyCancelPolicy()
+       : state_(INITIAL),
+         outputs_(APPLIED + 1, ButtonPolicy::ALL_BUTTONS),
+         state_machine_(APPLIED + 1,
+                        StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
+{
+       // Build the state output map
+       outputs_[INITIAL] = CLOSE;
+       outputs_[VALID] = RESTORE | OKAY | APPLY | CANCEL;
+       outputs_[INVALID] = RESTORE | CANCEL;
+       outputs_[APPLIED] = OKAY | APPLY | CLOSE;
+
+       // Build the state machine one state at a time
+       // NOTE:  Since CANCEL and HIDE always go to INITIAL they are
+       //        left out of the state machine and handled explicitly
+       //        in input()
+       //
+       // State::INITIAL
+       state_machine_[INITIAL][SMI_READ_ONLY] = INITIAL;
+       state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
+       state_machine_[INITIAL][SMI_VALID] = VALID;
+       state_machine_[INITIAL][SMI_INVALID] = INVALID;
+       // State::VALID
+       state_machine_[VALID][SMI_VALID] = VALID;
+       state_machine_[VALID][SMI_READ_ONLY] = VALID;
+       state_machine_[VALID][SMI_READ_WRITE] = VALID;
+       state_machine_[VALID][SMI_INVALID] = INVALID;
+       state_machine_[VALID][SMI_OKAY] = INITIAL;
+       state_machine_[VALID][SMI_RESTORE] = INITIAL;
+       state_machine_[VALID][SMI_APPLY] = APPLIED;
+       // State::INVALID
+       state_machine_[INVALID][SMI_INVALID] = INVALID;
+       state_machine_[INVALID][SMI_READ_ONLY] = INVALID;
+       state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
+       state_machine_[INVALID][SMI_VALID] = VALID;
+       state_machine_[INVALID][SMI_RESTORE] = INITIAL;
+       // State::APPLIED
+       state_machine_[APPLIED][SMI_APPLY] = APPLIED;
+       state_machine_[APPLIED][SMI_READ_ONLY] = APPLIED;
+       state_machine_[APPLIED][SMI_READ_WRITE] = APPLIED;
+       state_machine_[APPLIED][SMI_VALID] = VALID;
+       state_machine_[APPLIED][SMI_INVALID] = INVALID;
+       state_machine_[APPLIED][SMI_OKAY] = INITIAL;
+}
+
+
+void OkApplyCancelPolicy::input(SMInput input)
+{
+       //lyxerr << "OkApplyCancelPolicy::input" << endl;
+
+       // CANCEL and HIDE always take us to INITIAL for all cases
+       if (SMI_CANCEL == input
+           || SMI_HIDE == input) {
+               state_ = INITIAL;
+       } else {
+               nextState(state_,
+                         input,
+                         state_machine_,
+                         "OkApplyCancelPolicy");
+       }
+}
+
+
+/*--------------------------NoRepeatedApplyPolicy----------------------*/
+
+
+NoRepeatedApplyPolicy::NoRepeatedApplyPolicy()
+       : state_(INITIAL),
+         outputs_(INVALID + 1, ButtonPolicy::ALL_BUTTONS),
+         state_machine_(INVALID + 1,
+                        StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS))
+{
+       // Build the state output map
+       outputs_[INITIAL] = CLOSE;
+       outputs_[VALID] = RESTORE | OKAY | APPLY | CANCEL;
+       outputs_[INVALID] = RESTORE | CANCEL;
+
+       // Build the state machine one state at a time
+       // NOTE:  Since CANCEL and HIDE always go to INITIAL they are
+       //        left out of the state machine and handled explicitly
+       //        in input()
+       //
+       // State::INITIAL
+       state_machine_[INITIAL][SMI_READ_ONLY] = INITIAL;
+       state_machine_[INITIAL][SMI_READ_WRITE] = INITIAL;
+       state_machine_[INITIAL][SMI_VALID] = VALID;
+       state_machine_[INITIAL][SMI_INVALID] = INVALID;
+       // State::VALID
+       state_machine_[VALID][SMI_VALID] = VALID;
+       state_machine_[VALID][SMI_READ_ONLY] = VALID;
+       state_machine_[VALID][SMI_READ_WRITE] = VALID;
+       state_machine_[VALID][SMI_INVALID] = INVALID;
+       state_machine_[VALID][SMI_OKAY] = INITIAL;
+       state_machine_[VALID][SMI_APPLY] = INITIAL;
+       state_machine_[VALID][SMI_RESTORE] = INITIAL;
+       // State::INVALID
+       state_machine_[INVALID][SMI_INVALID] = INVALID;
+       state_machine_[INVALID][SMI_READ_ONLY] = INVALID;
+       state_machine_[INVALID][SMI_READ_WRITE] = INVALID;
+       state_machine_[INVALID][SMI_VALID] = VALID;
+       state_machine_[INVALID][SMI_RESTORE] = INITIAL;
+}
+
+
+void NoRepeatedApplyPolicy::input(SMInput input)
+{
+       //lyxerr << "NoRepeatedApplyPolicy::input" << endl;
+
+       // CANCEL and HIDE always take us to INITIAL for all cases
+       if (SMI_CANCEL == input
+           || SMI_HIDE == input) {
+               state_ = INITIAL;
+       } else {
+               nextState(state_,
+                         input,
+                         state_machine_,
+                         "NoRepeatedApplyPolicy");
+       }
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlAboutlyx.C b/src/frontends/controllers/ControlAboutlyx.C
deleted file mode 100644 (file)
index 2580fba..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * \file ControlAboutlyx.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlAboutlyx.h"
-#include "gettext.h"
-#include "version.h"
-
-#include "support/filetools.h" // FileSearch
-#include "support/package.h"
-
-#include <fstream>
-#include <sstream>
-
-using std::ostream;
-using std::ostringstream;
-using std::string;
-
-
-namespace lyx {
-
-using support::FileName;
-using support::fileSearch;
-using support::makeDisplayPath;
-using support::package;
-
-namespace frontend {
-
-
-ControlAboutlyx::ControlAboutlyx(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-void ControlAboutlyx::getCredits(ostream & ss) const
-{
-       FileName const name = fileSearch(package().system_support().absFilename(), "CREDITS");
-
-       bool found(!name.empty());
-
-       if (found) {
-               std::ifstream in(name.toFilesystemEncoding().c_str());
-
-               ss << in.rdbuf();
-               found = ss.good();
-       }
-
-       if (!found) {
-               ss << to_utf8(_("ERROR: LyX wasn't able to read CREDITS file\n"))
-                  << to_utf8(_("Please install correctly to estimate the great\n"))
-                  << to_utf8(_("amount of work other people have done for the LyX project."));
-       }
-}
-
-
-string const ControlAboutlyx::getCopyright() const
-{
-       return to_utf8(_("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995-2006 LyX Team"));
-}
-
-
-string const ControlAboutlyx::getLicense() const
-{
-       return to_utf8(_("This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version."));
-}
-
-
-string const ControlAboutlyx::getDisclaimer() const
-{
-       return to_utf8(_("LyX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU General Public License for more details.\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA."));
-}
-
-
-string const ControlAboutlyx::getVersion() const
-{
-       ostringstream ss;
-
-       ss << to_utf8(_("LyX Version "))
-          << lyx_version
-          << " ("
-          << lyx_release_date
-          << ")\n"
-          << to_utf8(_("Library directory: "))
-          << to_utf8(makeDisplayPath(package().system_support().absFilename()))
-          << "\n"
-          << to_utf8(_("User directory: "))
-          << to_utf8(makeDisplayPath(package().user_support().absFilename()));
-
-       return ss.str();
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlAboutlyx.cpp b/src/frontends/controllers/ControlAboutlyx.cpp
new file mode 100644 (file)
index 0000000..2580fba
--- /dev/null
@@ -0,0 +1,102 @@
+/**
+ * \file ControlAboutlyx.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlAboutlyx.h"
+#include "gettext.h"
+#include "version.h"
+
+#include "support/filetools.h" // FileSearch
+#include "support/package.h"
+
+#include <fstream>
+#include <sstream>
+
+using std::ostream;
+using std::ostringstream;
+using std::string;
+
+
+namespace lyx {
+
+using support::FileName;
+using support::fileSearch;
+using support::makeDisplayPath;
+using support::package;
+
+namespace frontend {
+
+
+ControlAboutlyx::ControlAboutlyx(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+void ControlAboutlyx::getCredits(ostream & ss) const
+{
+       FileName const name = fileSearch(package().system_support().absFilename(), "CREDITS");
+
+       bool found(!name.empty());
+
+       if (found) {
+               std::ifstream in(name.toFilesystemEncoding().c_str());
+
+               ss << in.rdbuf();
+               found = ss.good();
+       }
+
+       if (!found) {
+               ss << to_utf8(_("ERROR: LyX wasn't able to read CREDITS file\n"))
+                  << to_utf8(_("Please install correctly to estimate the great\n"))
+                  << to_utf8(_("amount of work other people have done for the LyX project."));
+       }
+}
+
+
+string const ControlAboutlyx::getCopyright() const
+{
+       return to_utf8(_("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995-2006 LyX Team"));
+}
+
+
+string const ControlAboutlyx::getLicense() const
+{
+       return to_utf8(_("This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version."));
+}
+
+
+string const ControlAboutlyx::getDisclaimer() const
+{
+       return to_utf8(_("LyX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU General Public License for more details.\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA."));
+}
+
+
+string const ControlAboutlyx::getVersion() const
+{
+       ostringstream ss;
+
+       ss << to_utf8(_("LyX Version "))
+          << lyx_version
+          << " ("
+          << lyx_release_date
+          << ")\n"
+          << to_utf8(_("Library directory: "))
+          << to_utf8(makeDisplayPath(package().system_support().absFilename()))
+          << "\n"
+          << to_utf8(_("User directory: "))
+          << to_utf8(makeDisplayPath(package().user_support().absFilename()));
+
+       return ss.str();
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlBibtex.C b/src/frontends/controllers/ControlBibtex.C
deleted file mode 100644 (file)
index 1d13cf3..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- * \file ControlBibtex.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Angus Leeming
- * \author Herbert Voß
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlBibtex.h"
-#include "frontend_helpers.h"
-
-#include "buffer.h"
-#include "bufferparams.h"
-
-#include "lyxrc.h"
-#include "gettext.h"
-
-#include "support/filefilterlist.h"
-#include "support/filetools.h"
-#include "support/lstrings.h"
-
-using std::pair;
-using std::string;
-using std::vector;
-
-
-namespace lyx {
-
-using support::contains;
-using support::FileFilterList;
-using support::onlyFilename;
-using support::prefixIs;
-using support::split;
-
-namespace frontend {
-
-
-ControlBibtex::ControlBibtex(Dialog & d)
-       : ControlCommand(d, "bibtex", "bibtex")
-{}
-
-
-docstring const ControlBibtex::browseBib(docstring const & in_name) const
-{
-       // FIXME UNICODE
-       pair<docstring, docstring> dir1(_("Documents|#o#O"),
-                                 lyx::from_utf8(lyxrc.document_path));
-       FileFilterList const filter(_("BibTeX Databases (*.bib)"));
-       return browseRelFile(in_name, lyx::from_utf8(kernel().bufferFilepath()),
-                            _("Select a BibTeX database to add"),
-                            filter, false, dir1);
-}
-
-
-docstring const ControlBibtex::browseBst(docstring const & in_name) const
-{
-       // FIXME UNICODE
-       pair<docstring, docstring> dir1(_("Documents|#o#O"),
-                                 lyx::from_utf8(lyxrc.document_path));
-       FileFilterList const filter(_("BibTeX Styles (*.bst)"));
-       return browseRelFile(in_name, lyx::from_utf8(kernel().bufferFilepath()),
-                            _("Select a BibTeX style"), filter, false, dir1);
-}
-
-
-void ControlBibtex::getBibStyles(vector<string> & data) const
-{
-       data.clear();
-
-       getTexFileList("bstFiles.lst", data);
-       // test, if we have a valid list, otherwise run rescan
-       if (data.empty()) {
-               rescanBibStyles();
-               getTexFileList("bstFiles.lst", data);
-       }
-       vector<string>::iterator it  = data.begin();
-       vector<string>::iterator end = data.end();
-       for (; it != end; ++it) {
-               *it = onlyFilename(*it);
-       }
-       // sort on filename only (no path)
-       std::sort(data.begin(), data.end());
-}
-
-
-void ControlBibtex::getBibFiles(vector<string> & data) const
-{
-       data.clear();
-
-       getTexFileList("bibFiles.lst", data);
-       // test, if we have a valid list, otherwise run rescan
-       if (data.empty()) {
-               rescanBibStyles();
-               getTexFileList("bibFiles.lst", data);
-       }
-       vector<string>::iterator it  = data.begin();
-       vector<string>::iterator end = data.end();
-       for (; it != end; ++it) {
-               *it = onlyFilename(*it);
-       }
-       // sort on filename only (no path)
-       std::sort(data.begin(), data.end());
-}
-
-
-void ControlBibtex::rescanBibStyles() const
-{
-       rescanTexStyles();
-}
-
-
-bool ControlBibtex::usingBibtopic() const
-{
-       return kernel().buffer().params().use_bibtopic;
-}
-
-
-bool ControlBibtex::bibtotoc() const
-{
-       return prefixIs(lyx::to_utf8(params()["options"]), "bibtotoc");
-}
-
-
-string const ControlBibtex::getStylefile() const
-{
-       // the different bibtex packages have (and need) their
-       // own "plain" stylefiles
-       biblio::CiteEngine const engine =
-               kernel().buffer().params().getEngine();
-       docstring defaultstyle;
-       switch (engine) {
-       case biblio::ENGINE_BASIC:
-               defaultstyle = lyx::from_ascii("plain");
-               break;
-       case biblio::ENGINE_NATBIB_AUTHORYEAR:
-               defaultstyle = lyx::from_ascii("plainnat");
-               break;
-       case biblio::ENGINE_NATBIB_NUMERICAL:
-               defaultstyle = lyx::from_ascii("plainnat");
-               break;
-       case biblio::ENGINE_JURABIB:
-               defaultstyle = lyx::from_ascii("jurabib");
-               break;
-       }
-
-       docstring bst = params()["options"];
-       if (bibtotoc()){
-               // bibstyle exists?
-               if (contains(bst, ',')) {
-                       docstring bibtotoc = lyx::from_ascii("bibtotoc");
-                       bst = split(bst, bibtotoc, ',');
-               } else
-                       bst.erase();
-       }
-
-       // propose default style file for new insets
-       // existing insets might have (legally) no bst files
-       // (if the class already provides a style)
-       if (bst.empty() && params()["bibfiles"].empty())
-               bst = defaultstyle;
-
-       // FIXME UNICODE
-       return lyx::to_utf8(bst);
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlBibtex.cpp b/src/frontends/controllers/ControlBibtex.cpp
new file mode 100644 (file)
index 0000000..1d13cf3
--- /dev/null
@@ -0,0 +1,173 @@
+/**
+ * \file ControlBibtex.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Angus Leeming
+ * \author Herbert Voß
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlBibtex.h"
+#include "frontend_helpers.h"
+
+#include "buffer.h"
+#include "bufferparams.h"
+
+#include "lyxrc.h"
+#include "gettext.h"
+
+#include "support/filefilterlist.h"
+#include "support/filetools.h"
+#include "support/lstrings.h"
+
+using std::pair;
+using std::string;
+using std::vector;
+
+
+namespace lyx {
+
+using support::contains;
+using support::FileFilterList;
+using support::onlyFilename;
+using support::prefixIs;
+using support::split;
+
+namespace frontend {
+
+
+ControlBibtex::ControlBibtex(Dialog & d)
+       : ControlCommand(d, "bibtex", "bibtex")
+{}
+
+
+docstring const ControlBibtex::browseBib(docstring const & in_name) const
+{
+       // FIXME UNICODE
+       pair<docstring, docstring> dir1(_("Documents|#o#O"),
+                                 lyx::from_utf8(lyxrc.document_path));
+       FileFilterList const filter(_("BibTeX Databases (*.bib)"));
+       return browseRelFile(in_name, lyx::from_utf8(kernel().bufferFilepath()),
+                            _("Select a BibTeX database to add"),
+                            filter, false, dir1);
+}
+
+
+docstring const ControlBibtex::browseBst(docstring const & in_name) const
+{
+       // FIXME UNICODE
+       pair<docstring, docstring> dir1(_("Documents|#o#O"),
+                                 lyx::from_utf8(lyxrc.document_path));
+       FileFilterList const filter(_("BibTeX Styles (*.bst)"));
+       return browseRelFile(in_name, lyx::from_utf8(kernel().bufferFilepath()),
+                            _("Select a BibTeX style"), filter, false, dir1);
+}
+
+
+void ControlBibtex::getBibStyles(vector<string> & data) const
+{
+       data.clear();
+
+       getTexFileList("bstFiles.lst", data);
+       // test, if we have a valid list, otherwise run rescan
+       if (data.empty()) {
+               rescanBibStyles();
+               getTexFileList("bstFiles.lst", data);
+       }
+       vector<string>::iterator it  = data.begin();
+       vector<string>::iterator end = data.end();
+       for (; it != end; ++it) {
+               *it = onlyFilename(*it);
+       }
+       // sort on filename only (no path)
+       std::sort(data.begin(), data.end());
+}
+
+
+void ControlBibtex::getBibFiles(vector<string> & data) const
+{
+       data.clear();
+
+       getTexFileList("bibFiles.lst", data);
+       // test, if we have a valid list, otherwise run rescan
+       if (data.empty()) {
+               rescanBibStyles();
+               getTexFileList("bibFiles.lst", data);
+       }
+       vector<string>::iterator it  = data.begin();
+       vector<string>::iterator end = data.end();
+       for (; it != end; ++it) {
+               *it = onlyFilename(*it);
+       }
+       // sort on filename only (no path)
+       std::sort(data.begin(), data.end());
+}
+
+
+void ControlBibtex::rescanBibStyles() const
+{
+       rescanTexStyles();
+}
+
+
+bool ControlBibtex::usingBibtopic() const
+{
+       return kernel().buffer().params().use_bibtopic;
+}
+
+
+bool ControlBibtex::bibtotoc() const
+{
+       return prefixIs(lyx::to_utf8(params()["options"]), "bibtotoc");
+}
+
+
+string const ControlBibtex::getStylefile() const
+{
+       // the different bibtex packages have (and need) their
+       // own "plain" stylefiles
+       biblio::CiteEngine const engine =
+               kernel().buffer().params().getEngine();
+       docstring defaultstyle;
+       switch (engine) {
+       case biblio::ENGINE_BASIC:
+               defaultstyle = lyx::from_ascii("plain");
+               break;
+       case biblio::ENGINE_NATBIB_AUTHORYEAR:
+               defaultstyle = lyx::from_ascii("plainnat");
+               break;
+       case biblio::ENGINE_NATBIB_NUMERICAL:
+               defaultstyle = lyx::from_ascii("plainnat");
+               break;
+       case biblio::ENGINE_JURABIB:
+               defaultstyle = lyx::from_ascii("jurabib");
+               break;
+       }
+
+       docstring bst = params()["options"];
+       if (bibtotoc()){
+               // bibstyle exists?
+               if (contains(bst, ',')) {
+                       docstring bibtotoc = lyx::from_ascii("bibtotoc");
+                       bst = split(bst, bibtotoc, ',');
+               } else
+                       bst.erase();
+       }
+
+       // propose default style file for new insets
+       // existing insets might have (legally) no bst files
+       // (if the class already provides a style)
+       if (bst.empty() && params()["bibfiles"].empty())
+               bst = defaultstyle;
+
+       // FIXME UNICODE
+       return lyx::to_utf8(bst);
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlBox.C b/src/frontends/controllers/ControlBox.C
deleted file mode 100644 (file)
index afa06a3..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * \file ControlBox.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Martin Vermeer (with useful hints from Angus Leeming)
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlBox.h"
-#include "funcrequest.h"
-#include "insets/InsetBox.h"
-#include "gettext.h"
-
-
-using std::string;
-using std::vector;
-
-namespace lyx {
-namespace frontend {
-
-ControlBox::ControlBox(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-bool ControlBox::initialiseParams(string const & data)
-{
-       InsetBoxParams params("");
-       InsetBoxMailer::string2params(data, params);
-       params_.reset(new InsetBoxParams(params));
-
-       return true;
-
-}
-
-
-void ControlBox::clearParams()
-{
-       params_.reset();
-}
-
-
-void ControlBox::dispatchParams()
-{
-       string const lfun = InsetBoxMailer::params2string(params());
-       kernel().dispatch(FuncRequest(getLfun(), lfun));
-}
-
-
-void box_gui_tokens(vector<string> & ids, vector<docstring> & gui_names)
-{
-       char const * const ids_[] = {
-               "Frameless", "Boxed", "ovalbox",
-               "Ovalbox", "Shadowbox", "Doublebox"};
-       size_t const ids_size = sizeof(ids_) / sizeof(char *);
-       ids = vector<string>(ids_, ids_ + ids_size);
-       gui_names.clear();
-       gui_names.push_back(_("No frame drawn"));
-       gui_names.push_back(_("Rectangular box"));
-       gui_names.push_back(_("Oval box, thin"));
-       gui_names.push_back(_("Oval box, thick"));
-       gui_names.push_back(_("Shadow box"));
-       gui_names.push_back(_("Double box"));
-}
-
-void box_gui_tokens_special_length(vector<string> & ids,
-       vector<docstring> & gui_names)
-{
-       char const * const ids_[] = {
-               "none", "height", "depth",
-               "totalheight", "width"};
-       size_t const ids_size = sizeof(ids_) / sizeof(char *);
-       ids = vector<string>(ids_, ids_ + ids_size);
-       gui_names.clear();
-       gui_names.push_back(_("None"));
-       gui_names.push_back(_("Height"));
-       gui_names.push_back(_("Depth"));
-       gui_names.push_back(_("Total Height"));
-       gui_names.push_back(_("Width"));
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlBox.cpp b/src/frontends/controllers/ControlBox.cpp
new file mode 100644 (file)
index 0000000..afa06a3
--- /dev/null
@@ -0,0 +1,87 @@
+/**
+ * \file ControlBox.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Martin Vermeer (with useful hints from Angus Leeming)
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlBox.h"
+#include "funcrequest.h"
+#include "insets/InsetBox.h"
+#include "gettext.h"
+
+
+using std::string;
+using std::vector;
+
+namespace lyx {
+namespace frontend {
+
+ControlBox::ControlBox(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+bool ControlBox::initialiseParams(string const & data)
+{
+       InsetBoxParams params("");
+       InsetBoxMailer::string2params(data, params);
+       params_.reset(new InsetBoxParams(params));
+
+       return true;
+
+}
+
+
+void ControlBox::clearParams()
+{
+       params_.reset();
+}
+
+
+void ControlBox::dispatchParams()
+{
+       string const lfun = InsetBoxMailer::params2string(params());
+       kernel().dispatch(FuncRequest(getLfun(), lfun));
+}
+
+
+void box_gui_tokens(vector<string> & ids, vector<docstring> & gui_names)
+{
+       char const * const ids_[] = {
+               "Frameless", "Boxed", "ovalbox",
+               "Ovalbox", "Shadowbox", "Doublebox"};
+       size_t const ids_size = sizeof(ids_) / sizeof(char *);
+       ids = vector<string>(ids_, ids_ + ids_size);
+       gui_names.clear();
+       gui_names.push_back(_("No frame drawn"));
+       gui_names.push_back(_("Rectangular box"));
+       gui_names.push_back(_("Oval box, thin"));
+       gui_names.push_back(_("Oval box, thick"));
+       gui_names.push_back(_("Shadow box"));
+       gui_names.push_back(_("Double box"));
+}
+
+void box_gui_tokens_special_length(vector<string> & ids,
+       vector<docstring> & gui_names)
+{
+       char const * const ids_[] = {
+               "none", "height", "depth",
+               "totalheight", "width"};
+       size_t const ids_size = sizeof(ids_) / sizeof(char *);
+       ids = vector<string>(ids_, ids_ + ids_size);
+       gui_names.clear();
+       gui_names.push_back(_("None"));
+       gui_names.push_back(_("Height"));
+       gui_names.push_back(_("Depth"));
+       gui_names.push_back(_("Total Height"));
+       gui_names.push_back(_("Width"));
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlBranch.C b/src/frontends/controllers/ControlBranch.C
deleted file mode 100644 (file)
index 520ff22..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * \file ControlBranch.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- * \author Martin Vermeer
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlBranch.h"
-
-#include "buffer.h"
-#include "bufferparams.h"
-#include "BranchList.h"
-#include "funcrequest.h"
-#include "insets/InsetBranch.h"
-
-
-using std::string;
-using std::vector;
-
-namespace lyx {
-namespace frontend {
-
-ControlBranch::ControlBranch(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-bool ControlBranch::initialiseParams(string const & data)
-{
-       InsetBranchParams params;
-       InsetBranchMailer::string2params(data, params);
-       params_.reset(new InsetBranchParams(params));
-
-       return true;
-}
-
-
-void ControlBranch::clearParams()
-{
-       params_.reset();
-}
-
-void ControlBranch::dispatchParams()
-{
-       string const lfun = InsetBranchMailer::params2string(params());
-       kernel().dispatch(FuncRequest(getLfun(), lfun));
-}
-
-
-BranchList const & ControlBranch::branchlist() const
-{
-       return kernel().buffer().params().branchlist();
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlBranch.cpp b/src/frontends/controllers/ControlBranch.cpp
new file mode 100644 (file)
index 0000000..520ff22
--- /dev/null
@@ -0,0 +1,62 @@
+/**
+ * \file ControlBranch.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ * \author Martin Vermeer
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlBranch.h"
+
+#include "buffer.h"
+#include "bufferparams.h"
+#include "BranchList.h"
+#include "funcrequest.h"
+#include "insets/InsetBranch.h"
+
+
+using std::string;
+using std::vector;
+
+namespace lyx {
+namespace frontend {
+
+ControlBranch::ControlBranch(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+bool ControlBranch::initialiseParams(string const & data)
+{
+       InsetBranchParams params;
+       InsetBranchMailer::string2params(data, params);
+       params_.reset(new InsetBranchParams(params));
+
+       return true;
+}
+
+
+void ControlBranch::clearParams()
+{
+       params_.reset();
+}
+
+void ControlBranch::dispatchParams()
+{
+       string const lfun = InsetBranchMailer::params2string(params());
+       kernel().dispatch(FuncRequest(getLfun(), lfun));
+}
+
+
+BranchList const & ControlBranch::branchlist() const
+{
+       return kernel().buffer().params().branchlist();
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlChanges.C b/src/frontends/controllers/ControlChanges.C
deleted file mode 100644 (file)
index 59305ad..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * \file ControlChanges.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Michael Gerz
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlChanges.h"
-
-#include "author.h"
-#include "buffer.h"
-#include "bufferparams.h"
-#include "BufferView.h"
-#include "changes.h"
-#include "funcrequest.h"
-#include "lyxfind.h"
-
-#include "support/lyxtime.h"
-
-
-namespace lyx {
-
-namespace frontend {
-
-
-ControlChanges::ControlChanges(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-void ControlChanges::next()
-{
-       kernel().dispatch(FuncRequest(LFUN_CHANGE_NEXT));
-}
-
-
-docstring const ControlChanges::getChangeDate()
-{
-       Change const & c = kernel().bufferview()->getCurrentChange();
-       if (c.type == Change::UNCHANGED)
-               return docstring();
-
-       // FIXME UNICODE
-       return from_utf8(formatted_time(c.changetime));
-}
-
-
-docstring const ControlChanges::getChangeAuthor()
-{
-       Change const & c = kernel().bufferview()->getCurrentChange();
-       if (c.type == Change::UNCHANGED)
-               return docstring();
-
-       Author const & a = kernel().buffer().params().authors().get(c.author);
-
-       docstring author(a.name());
-
-       if (!a.email().empty()) {
-               author += " (" + a.email() + ")";
-       }
-
-       return author;
-}
-
-
-void ControlChanges::accept()
-{
-       kernel().dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
-       next();
-}
-
-
-void ControlChanges::reject()
-{
-       kernel().dispatch(FuncRequest(LFUN_CHANGE_REJECT));
-       next();
-}
-
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlChanges.cpp b/src/frontends/controllers/ControlChanges.cpp
new file mode 100644 (file)
index 0000000..59305ad
--- /dev/null
@@ -0,0 +1,87 @@
+/**
+ * \file ControlChanges.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Michael Gerz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlChanges.h"
+
+#include "author.h"
+#include "buffer.h"
+#include "bufferparams.h"
+#include "BufferView.h"
+#include "changes.h"
+#include "funcrequest.h"
+#include "lyxfind.h"
+
+#include "support/lyxtime.h"
+
+
+namespace lyx {
+
+namespace frontend {
+
+
+ControlChanges::ControlChanges(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+void ControlChanges::next()
+{
+       kernel().dispatch(FuncRequest(LFUN_CHANGE_NEXT));
+}
+
+
+docstring const ControlChanges::getChangeDate()
+{
+       Change const & c = kernel().bufferview()->getCurrentChange();
+       if (c.type == Change::UNCHANGED)
+               return docstring();
+
+       // FIXME UNICODE
+       return from_utf8(formatted_time(c.changetime));
+}
+
+
+docstring const ControlChanges::getChangeAuthor()
+{
+       Change const & c = kernel().bufferview()->getCurrentChange();
+       if (c.type == Change::UNCHANGED)
+               return docstring();
+
+       Author const & a = kernel().buffer().params().authors().get(c.author);
+
+       docstring author(a.name());
+
+       if (!a.email().empty()) {
+               author += " (" + a.email() + ")";
+       }
+
+       return author;
+}
+
+
+void ControlChanges::accept()
+{
+       kernel().dispatch(FuncRequest(LFUN_CHANGE_ACCEPT));
+       next();
+}
+
+
+void ControlChanges::reject()
+{
+       kernel().dispatch(FuncRequest(LFUN_CHANGE_REJECT));
+       next();
+}
+
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlCharacter.C b/src/frontends/controllers/ControlCharacter.C
deleted file mode 100644 (file)
index 5bf1556..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-/**
- * \file ControlCharacter.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlCharacter.h"
-#include "ButtonController.h"
-
-#include "buffer.h"
-#include "bufferparams.h"
-#include "bufferview_funcs.h"
-#include "funcrequest.h"
-#include "language.h"
-#include "LColor.h"
-
-using lyx::bv_funcs::font2string;
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-ControlCharacter::ControlCharacter(Dialog & parent)
-       : Dialog::Controller(parent),
-         font_(0), toggleall_(false), reset_lang_(false)
-{}
-
-
-bool ControlCharacter::initialiseParams(string const &)
-{
-       // Do this the first time only.
-       if (!font_.get())
-               font_.reset(new LyXFont(LyXFont::ALL_IGNORE));
-
-       // so that the user can press Ok
-       if (getFamily()   != LyXFont::IGNORE_FAMILY ||
-           getSeries()   != LyXFont::IGNORE_SERIES ||
-           getShape()    != LyXFont::IGNORE_SHAPE  ||
-           getSize()     != LyXFont::IGNORE_SIZE ||
-           getBar()      != IGNORE ||
-           getColor()    != LColor::ignore ||
-           font_->language() != ignore_language)
-               dialog().bc().valid();
-
-       return true;
-}
-
-
-void ControlCharacter::clearParams()
-{}
-
-
-void ControlCharacter::dispatchParams()
-{
-       // Nothing to dispatch. (Can be called from the Toolbar.)
-       if (!font_.get())
-               return;
-
-       string data;
-       if (font2string(*font_.get(), toggleall_, data)) {
-               kernel().dispatch(FuncRequest(getLfun(), data));
-       }
-}
-
-
-LyXFont::FONT_FAMILY ControlCharacter::getFamily() const
-{
-       if (!font_.get())
-               return LyXFont::IGNORE_FAMILY;
-       return font_->family();
-}
-
-
-void ControlCharacter::setFamily(LyXFont::FONT_FAMILY val)
-{
-       font_->setFamily(val);
-}
-
-
-LyXFont::FONT_SERIES ControlCharacter::getSeries() const
-{
-       if (!font_.get())
-               return LyXFont::IGNORE_SERIES;
-       return font_->series();
-}
-
-
-void ControlCharacter::setSeries(LyXFont::FONT_SERIES val)
-{
-       font_->setSeries(val);
-}
-
-
-LyXFont::FONT_SHAPE ControlCharacter::getShape() const
-{
-       if (!font_.get())
-               return LyXFont::IGNORE_SHAPE;
-       return font_->shape();
-}
-
-
-void ControlCharacter::setShape(LyXFont::FONT_SHAPE val)
-{
-       font_->setShape(val);
-}
-
-
-LyXFont::FONT_SIZE ControlCharacter::getSize() const
-{
-       if (!font_.get())
-               return LyXFont::IGNORE_SIZE;
-       return font_->size();
-}
-
-
-void ControlCharacter::setSize(LyXFont::FONT_SIZE val)
-{
-       font_->setSize(val);
-}
-
-
-FONT_STATE ControlCharacter::getBar() const
-{
-       if (!font_.get())
-               return IGNORE;
-
-       if (font_->emph() == LyXFont::TOGGLE)
-               return EMPH_TOGGLE;
-
-       if (font_->underbar() == LyXFont::TOGGLE)
-               return UNDERBAR_TOGGLE;
-
-       if (font_->noun() == LyXFont::TOGGLE)
-               return NOUN_TOGGLE;
-
-       if (font_->emph() == LyXFont::IGNORE &&
-           font_->underbar() == LyXFont::IGNORE &&
-           font_->noun() == LyXFont::IGNORE)
-               return IGNORE;
-
-       return INHERIT;
-}
-
-
-void ControlCharacter::setBar(FONT_STATE val)
-{
-       switch (val) {
-       case IGNORE:
-               font_->setEmph(LyXFont::IGNORE);
-               font_->setUnderbar(LyXFont::IGNORE);
-               font_->setNoun(LyXFont::IGNORE);
-               break;
-
-       case EMPH_TOGGLE:
-               font_->setEmph(LyXFont::TOGGLE);
-               break;
-
-       case UNDERBAR_TOGGLE:
-               font_->setUnderbar(LyXFont::TOGGLE);
-               break;
-
-       case NOUN_TOGGLE:
-               font_->setNoun(LyXFont::TOGGLE);
-               break;
-
-       case INHERIT:
-               font_->setEmph(LyXFont::INHERIT);
-               font_->setUnderbar(LyXFont::INHERIT);
-               font_->setNoun(LyXFont::INHERIT);
-               break;
-       }
-}
-
-
-LColor_color ControlCharacter::getColor() const
-{
-       if (!font_.get())
-               return LColor::ignore;
-
-       return font_->color();
-}
-
-
-void ControlCharacter::setColor(LColor_color val)
-{
-       switch (val) {
-       case LColor::ignore:
-       case LColor::none:
-       case LColor::black:
-       case LColor::white:
-       case LColor::red:
-       case LColor::green:
-       case LColor::blue:
-       case LColor::cyan:
-       case LColor::magenta:
-       case LColor::yellow:
-       case LColor::inherit:
-               font_->setColor(val);
-               break;
-       default:
-               break;
-       }
-}
-
-
-string ControlCharacter::getLanguage() const
-{
-       if (reset_lang_)
-               return "reset";
-       if (font_.get() && font_->language())
-               return font_->language()->lang();
-       return "ignore";
-}
-
-
-void ControlCharacter::setLanguage(string const & val)
-{
-       if (val == "ignore")
-               font_->setLanguage(ignore_language);
-       else if (val == "reset") {
-               reset_lang_ = true;
-               // Ignored in getLanguage, but needed for dispatchParams
-               font_->setLanguage(kernel().buffer().params().language);
-       } else
-               font_->setLanguage(languages.getLanguage(val));
-}
-
-
-bool ControlCharacter::getToggleAll() const
-{
-       return toggleall_;
-}
-
-
-void ControlCharacter::setToggleAll(bool t)
-{
-       toggleall_ = t;
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlCharacter.cpp b/src/frontends/controllers/ControlCharacter.cpp
new file mode 100644 (file)
index 0000000..5bf1556
--- /dev/null
@@ -0,0 +1,247 @@
+/**
+ * \file ControlCharacter.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlCharacter.h"
+#include "ButtonController.h"
+
+#include "buffer.h"
+#include "bufferparams.h"
+#include "bufferview_funcs.h"
+#include "funcrequest.h"
+#include "language.h"
+#include "LColor.h"
+
+using lyx::bv_funcs::font2string;
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+ControlCharacter::ControlCharacter(Dialog & parent)
+       : Dialog::Controller(parent),
+         font_(0), toggleall_(false), reset_lang_(false)
+{}
+
+
+bool ControlCharacter::initialiseParams(string const &)
+{
+       // Do this the first time only.
+       if (!font_.get())
+               font_.reset(new LyXFont(LyXFont::ALL_IGNORE));
+
+       // so that the user can press Ok
+       if (getFamily()   != LyXFont::IGNORE_FAMILY ||
+           getSeries()   != LyXFont::IGNORE_SERIES ||
+           getShape()    != LyXFont::IGNORE_SHAPE  ||
+           getSize()     != LyXFont::IGNORE_SIZE ||
+           getBar()      != IGNORE ||
+           getColor()    != LColor::ignore ||
+           font_->language() != ignore_language)
+               dialog().bc().valid();
+
+       return true;
+}
+
+
+void ControlCharacter::clearParams()
+{}
+
+
+void ControlCharacter::dispatchParams()
+{
+       // Nothing to dispatch. (Can be called from the Toolbar.)
+       if (!font_.get())
+               return;
+
+       string data;
+       if (font2string(*font_.get(), toggleall_, data)) {
+               kernel().dispatch(FuncRequest(getLfun(), data));
+       }
+}
+
+
+LyXFont::FONT_FAMILY ControlCharacter::getFamily() const
+{
+       if (!font_.get())
+               return LyXFont::IGNORE_FAMILY;
+       return font_->family();
+}
+
+
+void ControlCharacter::setFamily(LyXFont::FONT_FAMILY val)
+{
+       font_->setFamily(val);
+}
+
+
+LyXFont::FONT_SERIES ControlCharacter::getSeries() const
+{
+       if (!font_.get())
+               return LyXFont::IGNORE_SERIES;
+       return font_->series();
+}
+
+
+void ControlCharacter::setSeries(LyXFont::FONT_SERIES val)
+{
+       font_->setSeries(val);
+}
+
+
+LyXFont::FONT_SHAPE ControlCharacter::getShape() const
+{
+       if (!font_.get())
+               return LyXFont::IGNORE_SHAPE;
+       return font_->shape();
+}
+
+
+void ControlCharacter::setShape(LyXFont::FONT_SHAPE val)
+{
+       font_->setShape(val);
+}
+
+
+LyXFont::FONT_SIZE ControlCharacter::getSize() const
+{
+       if (!font_.get())
+               return LyXFont::IGNORE_SIZE;
+       return font_->size();
+}
+
+
+void ControlCharacter::setSize(LyXFont::FONT_SIZE val)
+{
+       font_->setSize(val);
+}
+
+
+FONT_STATE ControlCharacter::getBar() const
+{
+       if (!font_.get())
+               return IGNORE;
+
+       if (font_->emph() == LyXFont::TOGGLE)
+               return EMPH_TOGGLE;
+
+       if (font_->underbar() == LyXFont::TOGGLE)
+               return UNDERBAR_TOGGLE;
+
+       if (font_->noun() == LyXFont::TOGGLE)
+               return NOUN_TOGGLE;
+
+       if (font_->emph() == LyXFont::IGNORE &&
+           font_->underbar() == LyXFont::IGNORE &&
+           font_->noun() == LyXFont::IGNORE)
+               return IGNORE;
+
+       return INHERIT;
+}
+
+
+void ControlCharacter::setBar(FONT_STATE val)
+{
+       switch (val) {
+       case IGNORE:
+               font_->setEmph(LyXFont::IGNORE);
+               font_->setUnderbar(LyXFont::IGNORE);
+               font_->setNoun(LyXFont::IGNORE);
+               break;
+
+       case EMPH_TOGGLE:
+               font_->setEmph(LyXFont::TOGGLE);
+               break;
+
+       case UNDERBAR_TOGGLE:
+               font_->setUnderbar(LyXFont::TOGGLE);
+               break;
+
+       case NOUN_TOGGLE:
+               font_->setNoun(LyXFont::TOGGLE);
+               break;
+
+       case INHERIT:
+               font_->setEmph(LyXFont::INHERIT);
+               font_->setUnderbar(LyXFont::INHERIT);
+               font_->setNoun(LyXFont::INHERIT);
+               break;
+       }
+}
+
+
+LColor_color ControlCharacter::getColor() const
+{
+       if (!font_.get())
+               return LColor::ignore;
+
+       return font_->color();
+}
+
+
+void ControlCharacter::setColor(LColor_color val)
+{
+       switch (val) {
+       case LColor::ignore:
+       case LColor::none:
+       case LColor::black:
+       case LColor::white:
+       case LColor::red:
+       case LColor::green:
+       case LColor::blue:
+       case LColor::cyan:
+       case LColor::magenta:
+       case LColor::yellow:
+       case LColor::inherit:
+               font_->setColor(val);
+               break;
+       default:
+               break;
+       }
+}
+
+
+string ControlCharacter::getLanguage() const
+{
+       if (reset_lang_)
+               return "reset";
+       if (font_.get() && font_->language())
+               return font_->language()->lang();
+       return "ignore";
+}
+
+
+void ControlCharacter::setLanguage(string const & val)
+{
+       if (val == "ignore")
+               font_->setLanguage(ignore_language);
+       else if (val == "reset") {
+               reset_lang_ = true;
+               // Ignored in getLanguage, but needed for dispatchParams
+               font_->setLanguage(kernel().buffer().params().language);
+       } else
+               font_->setLanguage(languages.getLanguage(val));
+}
+
+
+bool ControlCharacter::getToggleAll() const
+{
+       return toggleall_;
+}
+
+
+void ControlCharacter::setToggleAll(bool t)
+{
+       toggleall_ = t;
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlCitation.C b/src/frontends/controllers/ControlCitation.C
deleted file mode 100644 (file)
index be5ebf8..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-/**
- * \file ControlCitation.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlCitation.h"
-
-#include "buffer.h"
-#include "bufferparams.h"
-#include "debug.h" // temporary
-
-#include "support/lstrings.h"
-
-#include <boost/regex.hpp>
-
-#include <algorithm>
-
-using std::string;
-using std::vector;
-using std::pair;
-
-namespace lyx {
-namespace frontend {
-
-vector<biblio::CiteStyle> ControlCitation::citeStyles_;
-
-
-ControlCitation::ControlCitation(Dialog & d)
-       : ControlCommand(d, "cite", "citation")
-{}
-
-
-bool ControlCitation::initialiseParams(string const & data)
-{
-       if (!ControlCommand::initialiseParams(data))
-               return false;
-
-       biblio::CiteEngine const engine =
-               kernel().buffer().params().getEngine();
-
-       bool use_styles = engine != biblio::ENGINE_BASIC;
-
-       vector<pair<string, docstring> > blist;
-       kernel().buffer().fillWithBibKeys(blist);
-       bibkeysInfo_.clear();
-       for (size_t i = 0; i < blist.size(); ++i)
-               bibkeysInfo_[blist[i].first] = blist[i].second;
-
-       if (citeStyles_.empty())
-               citeStyles_ = biblio::getCiteStyles(engine);
-       else {
-               if ((use_styles && citeStyles_.size() == 1) ||
-                   (!use_styles && citeStyles_.size() != 1))
-                       citeStyles_ = biblio::getCiteStyles(engine);
-       }
-
-       return true;
-}
-
-
-
-void ControlCitation::clearParams()
-{
-       ControlCommand::clearParams();
-       bibkeysInfo_.clear();
-}
-
-
-vector<string> const ControlCitation::availableKeys() const
-{
-       return biblio::getKeys(bibkeysInfo_);
-}
-
-
-biblio::CiteEngine const ControlCitation::getEngine() const
-{
-       return kernel().buffer().params().getEngine();
-}
-
-
-docstring const ControlCitation::getInfo(std::string const & key) const
-{
-       if (bibkeysInfo_.empty())
-               return docstring();
-
-       return biblio::getInfo(bibkeysInfo_, key);
-}
-
-namespace {
-
-
-// Escape special chars.
-// All characters are literals except: '.|*?+(){}[]^$\'
-// These characters are literals when preceded by a "\", which is done here
-// @todo: This function should be moved to support, and then the test in tests
-//        should be moved there as well.
-docstring const escape_special_chars(docstring const & expr)
-{
-       // Search for all chars '.|*?+(){}[^$]\'
-       // Note that '[' and '\' must be escaped.
-       // This is a limitation of boost::regex, but all other chars in BREs
-       // are assumed literal.
-       boost::regex reg("[].|*?+(){}^$\\[\\\\]");
-
-       // $& is a perl-like expression that expands to all
-       // of the current match
-       // The '$' must be prefixed with the escape character '\' for
-       // boost to treat it as a literal.
-       // Thus, to prefix a matched expression with '\', we use:
-       // FIXME: UNICODE
-       return from_utf8(boost::regex_replace(to_utf8(expr), reg, "\\\\$&"));
-}
-
-} // namespace anon
-
-vector<string> ControlCitation::searchKeys(
-       vector<string> const & keys_to_search,
-       docstring const & search_expression,
-       bool case_sensitive, bool regex)
-{
-       vector<string> foundKeys;
-
-       docstring expr = support::trim(search_expression);
-       if (expr.empty())
-               return foundKeys;
-
-       if (!regex)
-               // We must escape special chars in the search_expr so that
-               // it is treated as a simple string by boost::regex.
-               expr = escape_special_chars(expr);
-
-       boost::regex reg_exp(to_utf8(expr), case_sensitive?
-               boost::regex_constants::normal : boost::regex_constants::icase);
-
-       vector<string>::const_iterator it = keys_to_search.begin();
-       vector<string>::const_iterator end = keys_to_search.end();
-       for (; it != end; ++it ) {
-               biblio::InfoMap::const_iterator info = bibkeysInfo_.find(*it);
-               if (info == bibkeysInfo_.end())
-                       continue;
-
-               string data = *it;
-               // FIXME UNICODE
-               data += ' ' + to_utf8(info->second);
-
-               try {
-                       // Attempts to find a match for the current RE
-                       // somewhere in data.
-                       if (boost::regex_search(data, reg_exp))
-                               foundKeys.push_back(*it);
-               }
-               catch (boost::regex_error &) {
-                       return vector<string>();
-               }
-       }
-       return foundKeys;
-}
-
-
-vector<docstring> const ControlCitation::getCiteStrings(string const & key) const
-{
-       biblio::CiteEngine const engine = kernel().buffer().params().getEngine();
-       vector<biblio::CiteStyle> const cs = biblio::getCiteStyles(engine);
-
-       if (engine == biblio::ENGINE_NATBIB_NUMERICAL)
-               return biblio::getNumericalStrings(key, bibkeysInfo_, cs);
-       else
-               return biblio::getAuthorYearStrings(key, bibkeysInfo_, cs);
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlCitation.cpp b/src/frontends/controllers/ControlCitation.cpp
new file mode 100644 (file)
index 0000000..be5ebf8
--- /dev/null
@@ -0,0 +1,180 @@
+/**
+ * \file ControlCitation.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlCitation.h"
+
+#include "buffer.h"
+#include "bufferparams.h"
+#include "debug.h" // temporary
+
+#include "support/lstrings.h"
+
+#include <boost/regex.hpp>
+
+#include <algorithm>
+
+using std::string;
+using std::vector;
+using std::pair;
+
+namespace lyx {
+namespace frontend {
+
+vector<biblio::CiteStyle> ControlCitation::citeStyles_;
+
+
+ControlCitation::ControlCitation(Dialog & d)
+       : ControlCommand(d, "cite", "citation")
+{}
+
+
+bool ControlCitation::initialiseParams(string const & data)
+{
+       if (!ControlCommand::initialiseParams(data))
+               return false;
+
+       biblio::CiteEngine const engine =
+               kernel().buffer().params().getEngine();
+
+       bool use_styles = engine != biblio::ENGINE_BASIC;
+
+       vector<pair<string, docstring> > blist;
+       kernel().buffer().fillWithBibKeys(blist);
+       bibkeysInfo_.clear();
+       for (size_t i = 0; i < blist.size(); ++i)
+               bibkeysInfo_[blist[i].first] = blist[i].second;
+
+       if (citeStyles_.empty())
+               citeStyles_ = biblio::getCiteStyles(engine);
+       else {
+               if ((use_styles && citeStyles_.size() == 1) ||
+                   (!use_styles && citeStyles_.size() != 1))
+                       citeStyles_ = biblio::getCiteStyles(engine);
+       }
+
+       return true;
+}
+
+
+
+void ControlCitation::clearParams()
+{
+       ControlCommand::clearParams();
+       bibkeysInfo_.clear();
+}
+
+
+vector<string> const ControlCitation::availableKeys() const
+{
+       return biblio::getKeys(bibkeysInfo_);
+}
+
+
+biblio::CiteEngine const ControlCitation::getEngine() const
+{
+       return kernel().buffer().params().getEngine();
+}
+
+
+docstring const ControlCitation::getInfo(std::string const & key) const
+{
+       if (bibkeysInfo_.empty())
+               return docstring();
+
+       return biblio::getInfo(bibkeysInfo_, key);
+}
+
+namespace {
+
+
+// Escape special chars.
+// All characters are literals except: '.|*?+(){}[]^$\'
+// These characters are literals when preceded by a "\", which is done here
+// @todo: This function should be moved to support, and then the test in tests
+//        should be moved there as well.
+docstring const escape_special_chars(docstring const & expr)
+{
+       // Search for all chars '.|*?+(){}[^$]\'
+       // Note that '[' and '\' must be escaped.
+       // This is a limitation of boost::regex, but all other chars in BREs
+       // are assumed literal.
+       boost::regex reg("[].|*?+(){}^$\\[\\\\]");
+
+       // $& is a perl-like expression that expands to all
+       // of the current match
+       // The '$' must be prefixed with the escape character '\' for
+       // boost to treat it as a literal.
+       // Thus, to prefix a matched expression with '\', we use:
+       // FIXME: UNICODE
+       return from_utf8(boost::regex_replace(to_utf8(expr), reg, "\\\\$&"));
+}
+
+} // namespace anon
+
+vector<string> ControlCitation::searchKeys(
+       vector<string> const & keys_to_search,
+       docstring const & search_expression,
+       bool case_sensitive, bool regex)
+{
+       vector<string> foundKeys;
+
+       docstring expr = support::trim(search_expression);
+       if (expr.empty())
+               return foundKeys;
+
+       if (!regex)
+               // We must escape special chars in the search_expr so that
+               // it is treated as a simple string by boost::regex.
+               expr = escape_special_chars(expr);
+
+       boost::regex reg_exp(to_utf8(expr), case_sensitive?
+               boost::regex_constants::normal : boost::regex_constants::icase);
+
+       vector<string>::const_iterator it = keys_to_search.begin();
+       vector<string>::const_iterator end = keys_to_search.end();
+       for (; it != end; ++it ) {
+               biblio::InfoMap::const_iterator info = bibkeysInfo_.find(*it);
+               if (info == bibkeysInfo_.end())
+                       continue;
+
+               string data = *it;
+               // FIXME UNICODE
+               data += ' ' + to_utf8(info->second);
+
+               try {
+                       // Attempts to find a match for the current RE
+                       // somewhere in data.
+                       if (boost::regex_search(data, reg_exp))
+                               foundKeys.push_back(*it);
+               }
+               catch (boost::regex_error &) {
+                       return vector<string>();
+               }
+       }
+       return foundKeys;
+}
+
+
+vector<docstring> const ControlCitation::getCiteStrings(string const & key) const
+{
+       biblio::CiteEngine const engine = kernel().buffer().params().getEngine();
+       vector<biblio::CiteStyle> const cs = biblio::getCiteStyles(engine);
+
+       if (engine == biblio::ENGINE_NATBIB_NUMERICAL)
+               return biblio::getNumericalStrings(key, bibkeysInfo_, cs);
+       else
+               return biblio::getAuthorYearStrings(key, bibkeysInfo_, cs);
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlCommand.C b/src/frontends/controllers/ControlCommand.C
deleted file mode 100644 (file)
index 13cf85a..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * \file ControlCommand.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlCommand.h"
-
-#include "funcrequest.h"
-#include "insets/InsetCommand.h"
-
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-ControlCommand::ControlCommand(Dialog & dialog, string const & command_name,
-                               string const & lfun_name)
-       : Dialog::Controller(dialog), params_(command_name),
-         lfun_name_(lfun_name)
-{}
-
-
-bool ControlCommand::initialiseParams(string const & data)
-{
-       // The name passed with LFUN_INSET_APPLY is also the name
-       // used to identify the mailer.
-       InsetCommandMailer::string2params(lfun_name_, data, params_);
-       return true;
-}
-
-
-void ControlCommand::clearParams()
-{
-       params_.clear();
-}
-
-
-void ControlCommand::dispatchParams()
-{
-       if (lfun_name_.empty())
-               return;
-
-       string const lfun = InsetCommandMailer::params2string(lfun_name_,
-                                                             params_);
-       kernel().dispatch(FuncRequest(getLfun(), lfun));
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlCommand.cpp b/src/frontends/controllers/ControlCommand.cpp
new file mode 100644 (file)
index 0000000..13cf85a
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * \file ControlCommand.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlCommand.h"
+
+#include "funcrequest.h"
+#include "insets/InsetCommand.h"
+
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+ControlCommand::ControlCommand(Dialog & dialog, string const & command_name,
+                               string const & lfun_name)
+       : Dialog::Controller(dialog), params_(command_name),
+         lfun_name_(lfun_name)
+{}
+
+
+bool ControlCommand::initialiseParams(string const & data)
+{
+       // The name passed with LFUN_INSET_APPLY is also the name
+       // used to identify the mailer.
+       InsetCommandMailer::string2params(lfun_name_, data, params_);
+       return true;
+}
+
+
+void ControlCommand::clearParams()
+{
+       params_.clear();
+}
+
+
+void ControlCommand::dispatchParams()
+{
+       if (lfun_name_.empty())
+               return;
+
+       string const lfun = InsetCommandMailer::params2string(lfun_name_,
+                                                             params_);
+       kernel().dispatch(FuncRequest(getLfun(), lfun));
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlCommandBuffer.C b/src/frontends/controllers/ControlCommandBuffer.C
deleted file mode 100644 (file)
index 9631034..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * \file ControlCommandBuffer.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Lars
- * \author Asger and Jürgen
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlCommandBuffer.h"
-
-#include "BufferView.h"
-#include "cursor.h"
-#include "lyxfunc.h"
-#include "LyXAction.h"
-#include "funcrequest.h"
-
-#include "frontends/LyXView.h"
-
-#include "support/lyxalgo.h"
-#include "support/lstrings.h"
-
-using std::back_inserter;
-using std::transform;
-using std::string;
-using std::vector;
-
-namespace lyx {
-
-using support::prefixIs;
-
-namespace frontend {
-
-namespace {
-
-class prefix_p {
-public:
-       string p;
-       prefix_p(string const & s)
-               : p(s) {}
-       bool operator()(string const & s) const {
-               return prefixIs(s, p);
-       }
-};
-
-} // end of anon namespace
-
-
-ControlCommandBuffer::ControlCommandBuffer(LyXView & lv)
-       : lv_(lv), history_pos_(history_.end())
-{
-       transform(lyxaction.func_begin(), lyxaction.func_end(),
-               back_inserter(commands_), firster());
-}
-
-
-string const ControlCommandBuffer::historyUp()
-{
-       if (history_pos_ == history_.begin())
-               return string();
-
-       return *(--history_pos_);
-}
-
-
-string const ControlCommandBuffer::historyDown()
-{
-       if (history_pos_ == history_.end())
-               return string();
-       if (history_pos_ + 1 == history_.end())
-               return string();
-
-       return *(++history_pos_);
-}
-
-
-docstring const ControlCommandBuffer::getCurrentState() const
-{
-       return lv_.view()->cursor().currentState();
-}
-
-
-vector<string> const
-ControlCommandBuffer::completions(string const & prefix, string & new_prefix)
-{
-       vector<string> comp;
-
-       copy_if(commands_.begin(), commands_.end(),
-               back_inserter(comp), prefix_p(prefix));
-
-       if (comp.empty()) {
-               new_prefix = prefix;
-               return comp;
-       }
-
-       if (comp.size() == 1) {
-               new_prefix = comp[0];
-               return vector<string>();
-       }
-
-       // find maximal available prefix
-       string const tmp = comp[0];
-       string test = prefix;
-       if (tmp.length() > test.length())
-               test += tmp[test.length()];
-       while (test.length() < tmp.length()) {
-               vector<string> vtmp;
-               copy_if(comp.begin(), comp.end(),
-                       back_inserter(vtmp), prefix_p(test));
-               if (vtmp.size() != comp.size()) {
-                       test.erase(test.length() - 1);
-                       break;
-               }
-               test += tmp[test.length()];
-       }
-
-       new_prefix = test;
-       return comp;
-}
-
-
-void ControlCommandBuffer::dispatch(string const & str)
-{
-       if (str.empty())
-               return;
-
-       history_.push_back(str);
-       history_pos_ = history_.end();
-       FuncRequest func = lyxaction.lookupFunc(str);
-       func.origin = FuncRequest::COMMANDBUFFER;
-       lv_.dispatch(func);
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlCommandBuffer.cpp b/src/frontends/controllers/ControlCommandBuffer.cpp
new file mode 100644 (file)
index 0000000..9631034
--- /dev/null
@@ -0,0 +1,140 @@
+/**
+ * \file ControlCommandBuffer.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars
+ * \author Asger and Jürgen
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlCommandBuffer.h"
+
+#include "BufferView.h"
+#include "cursor.h"
+#include "lyxfunc.h"
+#include "LyXAction.h"
+#include "funcrequest.h"
+
+#include "frontends/LyXView.h"
+
+#include "support/lyxalgo.h"
+#include "support/lstrings.h"
+
+using std::back_inserter;
+using std::transform;
+using std::string;
+using std::vector;
+
+namespace lyx {
+
+using support::prefixIs;
+
+namespace frontend {
+
+namespace {
+
+class prefix_p {
+public:
+       string p;
+       prefix_p(string const & s)
+               : p(s) {}
+       bool operator()(string const & s) const {
+               return prefixIs(s, p);
+       }
+};
+
+} // end of anon namespace
+
+
+ControlCommandBuffer::ControlCommandBuffer(LyXView & lv)
+       : lv_(lv), history_pos_(history_.end())
+{
+       transform(lyxaction.func_begin(), lyxaction.func_end(),
+               back_inserter(commands_), firster());
+}
+
+
+string const ControlCommandBuffer::historyUp()
+{
+       if (history_pos_ == history_.begin())
+               return string();
+
+       return *(--history_pos_);
+}
+
+
+string const ControlCommandBuffer::historyDown()
+{
+       if (history_pos_ == history_.end())
+               return string();
+       if (history_pos_ + 1 == history_.end())
+               return string();
+
+       return *(++history_pos_);
+}
+
+
+docstring const ControlCommandBuffer::getCurrentState() const
+{
+       return lv_.view()->cursor().currentState();
+}
+
+
+vector<string> const
+ControlCommandBuffer::completions(string const & prefix, string & new_prefix)
+{
+       vector<string> comp;
+
+       copy_if(commands_.begin(), commands_.end(),
+               back_inserter(comp), prefix_p(prefix));
+
+       if (comp.empty()) {
+               new_prefix = prefix;
+               return comp;
+       }
+
+       if (comp.size() == 1) {
+               new_prefix = comp[0];
+               return vector<string>();
+       }
+
+       // find maximal available prefix
+       string const tmp = comp[0];
+       string test = prefix;
+       if (tmp.length() > test.length())
+               test += tmp[test.length()];
+       while (test.length() < tmp.length()) {
+               vector<string> vtmp;
+               copy_if(comp.begin(), comp.end(),
+                       back_inserter(vtmp), prefix_p(test));
+               if (vtmp.size() != comp.size()) {
+                       test.erase(test.length() - 1);
+                       break;
+               }
+               test += tmp[test.length()];
+       }
+
+       new_prefix = test;
+       return comp;
+}
+
+
+void ControlCommandBuffer::dispatch(string const & str)
+{
+       if (str.empty())
+               return;
+
+       history_.push_back(str);
+       history_pos_ = history_.end();
+       FuncRequest func = lyxaction.lookupFunc(str);
+       func.origin = FuncRequest::COMMANDBUFFER;
+       lv_.dispatch(func);
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlDocument.C b/src/frontends/controllers/ControlDocument.C
deleted file mode 100644 (file)
index 70648a4..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-/**
- * \file ControlDocument.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlDocument.h"
-#include "Kernel.h"
-
-#include "BranchList.h"
-#include "buffer.h"
-#include "bufferparams.h"
-#include "BufferView.h"
-#include "buffer_funcs.h"
-#include "funcrequest.h"
-#include "gettext.h"
-#include "language.h"
-#include "LaTeXFeatures.h"
-#include "LColor.h"
-#include "outputparams.h"
-#include "lyxtextclasslist.h"
-#include "tex-strings.h"
-
-// FIXME: those two headers are needed because of the
-// WorkArea::redraw() call below.
-#include "frontends/LyXView.h"
-#include "frontends/WorkArea.h"
-
-#include <sstream>
-
-using std::ostringstream;
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-char const * const ControlDocument::fontfamilies[5] = {
-       "default", "rmdefault", "sfdefault", "ttdefault", ""
-};
-
-
-char const * ControlDocument::fontfamilies_gui[5] = {
-       N_("Default"), N_("Roman"), N_("Sans Serif"), N_("Typewriter"), ""
-};
-
-
-ControlDocument::ControlDocument(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-ControlDocument::~ControlDocument()
-{}
-
-
-bool ControlDocument::initialiseParams(std::string const &)
-{
-       bp_.reset(new BufferParams);
-       *bp_ = kernel().buffer().params();
-       return true;
-}
-
-
-void ControlDocument::clearParams()
-{
-       bp_.reset();
-}
-
-
-BufferParams & ControlDocument::params() const
-{
-       BOOST_ASSERT(bp_.get());
-       return *bp_;
-}
-
-
-LyXTextClass const & ControlDocument::textClass() const
-{
-       return textclasslist[bp_->textclass];
-}
-
-
-namespace {
-
-void dispatch_bufferparams(Kernel const & kernel, BufferParams const & bp,
-                          kb_action lfun)
-{
-       ostringstream ss;
-       ss << "\\begin_header\n";
-       bp.writeFile(ss);
-       ss << "\\end_header\n";
-       kernel.dispatch(FuncRequest(lfun, ss.str()));
-}
-
-} // namespace anon
-
-
-void ControlDocument::dispatchParams()
-{
-       // This must come first so that a language change is correctly noticed
-       setLanguage();
-
-       // Set the document class.
-       textclass_type const old_class =
-               kernel().buffer().params().textclass;
-       textclass_type const new_class = bp_->textclass;
-       if (new_class != old_class) {
-               string const name = textclasslist[new_class].name();
-               kernel().dispatch(FuncRequest(LFUN_TEXTCLASS_APPLY, name));
-       }
-
-       int const old_secnumdepth = kernel().buffer().params().secnumdepth;
-       int const new_secnumdepth = bp_->secnumdepth;
-
-       // Apply the BufferParams.
-       dispatch_bufferparams(kernel(), params(), LFUN_BUFFER_PARAMS_APPLY);
-       
-       // redo the numbering if necessary
-       if (new_secnumdepth != old_secnumdepth)
-               updateLabels(kernel().buffer());
-
-       // Generate the colours requested by each new branch.
-       BranchList & branchlist = params().branchlist();
-       if (!branchlist.empty()) {
-               BranchList::const_iterator it = branchlist.begin();
-               BranchList::const_iterator const end = branchlist.end();
-               for (; it != end; ++it) {
-                       docstring const & current_branch = it->getBranch();
-                       Branch const * branch = branchlist.find(current_branch);
-                       string const x11hexname =
-                                       lyx::X11hexname(branch->getColor());
-                       // display the new color
-                       docstring const str = current_branch + ' ' + from_ascii(x11hexname);
-                       kernel().dispatch(FuncRequest(LFUN_SET_COLOR, str));
-               }
-
-               // Open insets of selected branches, close deselected ones
-               kernel().dispatch(FuncRequest(LFUN_ALL_INSETS_TOGGLE,
-                       "assign branch"));
-       }
-       // FIXME: If we used an LFUN, we would not need those two lines:
-       kernel().bufferview()->update();
-       kernel().lyxview().currentWorkArea()->redraw();
-}
-
-
-void ControlDocument::setLanguage() const
-{
-       Language const * const newL = bp_->language;
-       if (kernel().buffer().params().language == newL)
-               return;
-
-       string const lang_name = newL->lang();
-       kernel().dispatch(FuncRequest(LFUN_BUFFER_LANGUAGE, lang_name));
-}
-
-
-bool ControlDocument::loadTextclass(textclass_type tc) const
-{
-       string const name = textclasslist[tc].name();
-       kernel().dispatch(FuncRequest(LFUN_TEXTCLASS_LOAD, name));
-
-       // Report back whether we were able to change the class.
-       bool const success = textclasslist[tc].loaded();
-       return success;
-}
-
-
-void ControlDocument::saveAsDefault() const
-{
-       dispatch_bufferparams(kernel(), params(), LFUN_BUFFER_SAVE_AS_DEFAULT);
-}
-
-
-bool const ControlDocument::isFontAvailable(std::string const & font) const
-{
-       if (font == "default" || font == "cmr" 
-           || font == "cmss" || font == "cmtt")
-               // these are standard
-               return true;
-       else if (font == "lmodern" || font == "lmss" || font == "lmtt")
-               return LaTeXFeatures::isAvailable("lmodern");
-       else if (font == "times" || font == "palatino" 
-                || font == "helvet" || font == "courier")
-               return LaTeXFeatures::isAvailable("psnfss");
-       else if (font == "cmbr" || font == "cmtl")
-               return LaTeXFeatures::isAvailable("cmbright");
-       else if (font == "utopia")
-               return LaTeXFeatures::isAvailable("utopia")
-                       || LaTeXFeatures::isAvailable("fourier");
-       else if (font == "beraserif" || font == "berasans" 
-               || font == "beramono")
-               return LaTeXFeatures::isAvailable("bera");
-       else
-               return LaTeXFeatures::isAvailable(font);
-}
-
-
-bool const ControlDocument::providesOSF(std::string const & font) const
-{
-       if (font == "cmr")
-               return isFontAvailable("eco");
-       else if (font == "palatino")
-               return isFontAvailable("mathpazo");
-       else
-               return false;
-}
-
-
-bool const ControlDocument::providesSC(std::string const & font) const
-{
-       if (font == "palatino")
-               return isFontAvailable("mathpazo");
-       else if (font == "utopia")
-               return isFontAvailable("fourier");
-       else
-               return false;
-}
-
-
-bool const ControlDocument::providesScale(std::string const & font) const
-{
-       return (font == "helvet" || font == "luximono"
-               || font == "berasans"  || font == "beramono");
-}
-
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlDocument.cpp b/src/frontends/controllers/ControlDocument.cpp
new file mode 100644 (file)
index 0000000..70648a4
--- /dev/null
@@ -0,0 +1,235 @@
+/**
+ * \file ControlDocument.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlDocument.h"
+#include "Kernel.h"
+
+#include "BranchList.h"
+#include "buffer.h"
+#include "bufferparams.h"
+#include "BufferView.h"
+#include "buffer_funcs.h"
+#include "funcrequest.h"
+#include "gettext.h"
+#include "language.h"
+#include "LaTeXFeatures.h"
+#include "LColor.h"
+#include "outputparams.h"
+#include "lyxtextclasslist.h"
+#include "tex-strings.h"
+
+// FIXME: those two headers are needed because of the
+// WorkArea::redraw() call below.
+#include "frontends/LyXView.h"
+#include "frontends/WorkArea.h"
+
+#include <sstream>
+
+using std::ostringstream;
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+char const * const ControlDocument::fontfamilies[5] = {
+       "default", "rmdefault", "sfdefault", "ttdefault", ""
+};
+
+
+char const * ControlDocument::fontfamilies_gui[5] = {
+       N_("Default"), N_("Roman"), N_("Sans Serif"), N_("Typewriter"), ""
+};
+
+
+ControlDocument::ControlDocument(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+ControlDocument::~ControlDocument()
+{}
+
+
+bool ControlDocument::initialiseParams(std::string const &)
+{
+       bp_.reset(new BufferParams);
+       *bp_ = kernel().buffer().params();
+       return true;
+}
+
+
+void ControlDocument::clearParams()
+{
+       bp_.reset();
+}
+
+
+BufferParams & ControlDocument::params() const
+{
+       BOOST_ASSERT(bp_.get());
+       return *bp_;
+}
+
+
+LyXTextClass const & ControlDocument::textClass() const
+{
+       return textclasslist[bp_->textclass];
+}
+
+
+namespace {
+
+void dispatch_bufferparams(Kernel const & kernel, BufferParams const & bp,
+                          kb_action lfun)
+{
+       ostringstream ss;
+       ss << "\\begin_header\n";
+       bp.writeFile(ss);
+       ss << "\\end_header\n";
+       kernel.dispatch(FuncRequest(lfun, ss.str()));
+}
+
+} // namespace anon
+
+
+void ControlDocument::dispatchParams()
+{
+       // This must come first so that a language change is correctly noticed
+       setLanguage();
+
+       // Set the document class.
+       textclass_type const old_class =
+               kernel().buffer().params().textclass;
+       textclass_type const new_class = bp_->textclass;
+       if (new_class != old_class) {
+               string const name = textclasslist[new_class].name();
+               kernel().dispatch(FuncRequest(LFUN_TEXTCLASS_APPLY, name));
+       }
+
+       int const old_secnumdepth = kernel().buffer().params().secnumdepth;
+       int const new_secnumdepth = bp_->secnumdepth;
+
+       // Apply the BufferParams.
+       dispatch_bufferparams(kernel(), params(), LFUN_BUFFER_PARAMS_APPLY);
+       
+       // redo the numbering if necessary
+       if (new_secnumdepth != old_secnumdepth)
+               updateLabels(kernel().buffer());
+
+       // Generate the colours requested by each new branch.
+       BranchList & branchlist = params().branchlist();
+       if (!branchlist.empty()) {
+               BranchList::const_iterator it = branchlist.begin();
+               BranchList::const_iterator const end = branchlist.end();
+               for (; it != end; ++it) {
+                       docstring const & current_branch = it->getBranch();
+                       Branch const * branch = branchlist.find(current_branch);
+                       string const x11hexname =
+                                       lyx::X11hexname(branch->getColor());
+                       // display the new color
+                       docstring const str = current_branch + ' ' + from_ascii(x11hexname);
+                       kernel().dispatch(FuncRequest(LFUN_SET_COLOR, str));
+               }
+
+               // Open insets of selected branches, close deselected ones
+               kernel().dispatch(FuncRequest(LFUN_ALL_INSETS_TOGGLE,
+                       "assign branch"));
+       }
+       // FIXME: If we used an LFUN, we would not need those two lines:
+       kernel().bufferview()->update();
+       kernel().lyxview().currentWorkArea()->redraw();
+}
+
+
+void ControlDocument::setLanguage() const
+{
+       Language const * const newL = bp_->language;
+       if (kernel().buffer().params().language == newL)
+               return;
+
+       string const lang_name = newL->lang();
+       kernel().dispatch(FuncRequest(LFUN_BUFFER_LANGUAGE, lang_name));
+}
+
+
+bool ControlDocument::loadTextclass(textclass_type tc) const
+{
+       string const name = textclasslist[tc].name();
+       kernel().dispatch(FuncRequest(LFUN_TEXTCLASS_LOAD, name));
+
+       // Report back whether we were able to change the class.
+       bool const success = textclasslist[tc].loaded();
+       return success;
+}
+
+
+void ControlDocument::saveAsDefault() const
+{
+       dispatch_bufferparams(kernel(), params(), LFUN_BUFFER_SAVE_AS_DEFAULT);
+}
+
+
+bool const ControlDocument::isFontAvailable(std::string const & font) const
+{
+       if (font == "default" || font == "cmr" 
+           || font == "cmss" || font == "cmtt")
+               // these are standard
+               return true;
+       else if (font == "lmodern" || font == "lmss" || font == "lmtt")
+               return LaTeXFeatures::isAvailable("lmodern");
+       else if (font == "times" || font == "palatino" 
+                || font == "helvet" || font == "courier")
+               return LaTeXFeatures::isAvailable("psnfss");
+       else if (font == "cmbr" || font == "cmtl")
+               return LaTeXFeatures::isAvailable("cmbright");
+       else if (font == "utopia")
+               return LaTeXFeatures::isAvailable("utopia")
+                       || LaTeXFeatures::isAvailable("fourier");
+       else if (font == "beraserif" || font == "berasans" 
+               || font == "beramono")
+               return LaTeXFeatures::isAvailable("bera");
+       else
+               return LaTeXFeatures::isAvailable(font);
+}
+
+
+bool const ControlDocument::providesOSF(std::string const & font) const
+{
+       if (font == "cmr")
+               return isFontAvailable("eco");
+       else if (font == "palatino")
+               return isFontAvailable("mathpazo");
+       else
+               return false;
+}
+
+
+bool const ControlDocument::providesSC(std::string const & font) const
+{
+       if (font == "palatino")
+               return isFontAvailable("mathpazo");
+       else if (font == "utopia")
+               return isFontAvailable("fourier");
+       else
+               return false;
+}
+
+
+bool const ControlDocument::providesScale(std::string const & font) const
+{
+       return (font == "helvet" || font == "luximono"
+               || font == "berasans"  || font == "beramono");
+}
+
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlERT.C b/src/frontends/controllers/ControlERT.C
deleted file mode 100644 (file)
index 52f1ea1..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * \file ControlERT.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Jürgen Vigna
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlERT.h"
-#include "funcrequest.h"
-
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-ControlERT::ControlERT(Dialog & parent)
-       : Dialog::Controller(parent), status_(InsetERT::Collapsed)
-{}
-
-
-bool ControlERT::initialiseParams(string const & data)
-{
-       InsetERTMailer::string2params(data, status_);
-       return true;
-}
-
-
-void ControlERT::clearParams()
-{
-       status_ = InsetERT::Collapsed;
-}
-
-
-void ControlERT::dispatchParams()
-{
-       string const lfun = InsetERTMailer::params2string(status_);
-       kernel().dispatch(FuncRequest(getLfun(), lfun));
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlERT.cpp b/src/frontends/controllers/ControlERT.cpp
new file mode 100644 (file)
index 0000000..52f1ea1
--- /dev/null
@@ -0,0 +1,48 @@
+/**
+ * \file ControlERT.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jürgen Vigna
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlERT.h"
+#include "funcrequest.h"
+
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+ControlERT::ControlERT(Dialog & parent)
+       : Dialog::Controller(parent), status_(InsetERT::Collapsed)
+{}
+
+
+bool ControlERT::initialiseParams(string const & data)
+{
+       InsetERTMailer::string2params(data, status_);
+       return true;
+}
+
+
+void ControlERT::clearParams()
+{
+       status_ = InsetERT::Collapsed;
+}
+
+
+void ControlERT::dispatchParams()
+{
+       string const lfun = InsetERTMailer::params2string(status_);
+       kernel().dispatch(FuncRequest(getLfun(), lfun));
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlErrorList.C b/src/frontends/controllers/ControlErrorList.C
deleted file mode 100644 (file)
index c456319..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * \file ControlErrorList.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Alfredo Braunstein
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlErrorList.h"
-#include "buffer.h"
-#include "BufferView.h"
-#include "debug.h"
-#include "gettext.h"
-#include "lyxtext.h"
-#include "paragraph.h"
-#include "pariterator.h"
-
-// FIXME: those two headers are needed because of the
-// WorkArea::redraw() call below.
-#include "frontends/LyXView.h"
-#include "frontends/WorkArea.h"
-
-#include "support/lstrings.h"
-
-using lyx::support::bformat;
-
-using std::endl;
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-ControlErrorList::ControlErrorList(Dialog & d)
-       : Dialog::Controller(d)
-{}
-
-
-void ControlErrorList::clearParams()
-{}
-
-
-ErrorList const & ControlErrorList::errorList() const
-{
-       return kernel().bufferview()->buffer()->errorList(error_type_);
-}
-
-
-bool ControlErrorList::initialiseParams(string const & error_type)
-{
-       error_type_ = error_type;
-       Buffer * buf = kernel().bufferview()->buffer();
-       // FIXME UNICODE
-       docstring const title = bformat(_("%1$s Errors (%2$s)"),
-                                    _(error_type),
-                                    lyx::from_utf8(buf->fileName()));
-       name_ = lyx::to_utf8(title);
-       return true;
-}
-
-
-string const & ControlErrorList::name()
-{
-       return name_;
-}
-
-
-void ControlErrorList::goTo(int item)
-{
-       ErrorItem const & err = errorList()[item];
-
-       if (err.par_id == -1)
-               return;
-
-       Buffer & buf = kernel().buffer();
-       ParIterator pit = buf.getParFromID(err.par_id);
-
-       if (pit == buf.par_iterator_end()) {
-               lyxerr << "par id " << err.par_id << " not found" << endl;
-               return;
-       }
-
-       // Now make the selection.
-       // This should be implemented using an LFUN. (Angus)
-       // if pos_end is 0, this means it is end-of-paragraph
-       pos_type const end = err.pos_end ? std::min(err.pos_end, pit->size())
-                                        : pit->size();
-       pos_type const start = std::min(err.pos_start, end);
-       pos_type const range = end - start;
-       DocIterator const dit = makeDocIterator(pit, start);
-       kernel().bufferview()->putSelectionAt(dit, range, false);
-       // FIXME: If we used an LFUN, we would not need those two lines:
-       kernel().bufferview()->update();
-       kernel().lyxview().currentWorkArea()->redraw();
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlErrorList.cpp b/src/frontends/controllers/ControlErrorList.cpp
new file mode 100644 (file)
index 0000000..c456319
--- /dev/null
@@ -0,0 +1,101 @@
+/**
+ * \file ControlErrorList.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlErrorList.h"
+#include "buffer.h"
+#include "BufferView.h"
+#include "debug.h"
+#include "gettext.h"
+#include "lyxtext.h"
+#include "paragraph.h"
+#include "pariterator.h"
+
+// FIXME: those two headers are needed because of the
+// WorkArea::redraw() call below.
+#include "frontends/LyXView.h"
+#include "frontends/WorkArea.h"
+
+#include "support/lstrings.h"
+
+using lyx::support::bformat;
+
+using std::endl;
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+ControlErrorList::ControlErrorList(Dialog & d)
+       : Dialog::Controller(d)
+{}
+
+
+void ControlErrorList::clearParams()
+{}
+
+
+ErrorList const & ControlErrorList::errorList() const
+{
+       return kernel().bufferview()->buffer()->errorList(error_type_);
+}
+
+
+bool ControlErrorList::initialiseParams(string const & error_type)
+{
+       error_type_ = error_type;
+       Buffer * buf = kernel().bufferview()->buffer();
+       // FIXME UNICODE
+       docstring const title = bformat(_("%1$s Errors (%2$s)"),
+                                    _(error_type),
+                                    lyx::from_utf8(buf->fileName()));
+       name_ = lyx::to_utf8(title);
+       return true;
+}
+
+
+string const & ControlErrorList::name()
+{
+       return name_;
+}
+
+
+void ControlErrorList::goTo(int item)
+{
+       ErrorItem const & err = errorList()[item];
+
+       if (err.par_id == -1)
+               return;
+
+       Buffer & buf = kernel().buffer();
+       ParIterator pit = buf.getParFromID(err.par_id);
+
+       if (pit == buf.par_iterator_end()) {
+               lyxerr << "par id " << err.par_id << " not found" << endl;
+               return;
+       }
+
+       // Now make the selection.
+       // This should be implemented using an LFUN. (Angus)
+       // if pos_end is 0, this means it is end-of-paragraph
+       pos_type const end = err.pos_end ? std::min(err.pos_end, pit->size())
+                                        : pit->size();
+       pos_type const start = std::min(err.pos_start, end);
+       pos_type const range = end - start;
+       DocIterator const dit = makeDocIterator(pit, start);
+       kernel().bufferview()->putSelectionAt(dit, range, false);
+       // FIXME: If we used an LFUN, we would not need those two lines:
+       kernel().bufferview()->update();
+       kernel().lyxview().currentWorkArea()->redraw();
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlExternal.C b/src/frontends/controllers/ControlExternal.C
deleted file mode 100644 (file)
index 369a23e..0000000
+++ /dev/null
@@ -1,254 +0,0 @@
-/**
- * \file ControlExternal.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Asger Alstrup
- * \author John Levon
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlExternal.h"
-
-#include "funcrequest.h"
-#include "gettext.h"
-#include "frontend_helpers.h"
-#include "lyxrc.h"
-
-#include "graphics/GraphicsCache.h"
-#include "graphics/GraphicsCacheItem.h"
-#include "graphics/GraphicsImage.h"
-
-#include "insets/InsetExternal.h"
-#include "insets/ExternalSupport.h"
-#include "insets/ExternalTemplate.h"
-
-#include "support/filefilterlist.h"
-#include "support/filetools.h"
-#include "support/convert.h"
-
-using std::advance;
-using std::vector;
-using std::string;
-
-namespace lyx {
-
-using support::FileFilterList;
-using support::FileName;
-using support::makeAbsPath;
-using support::readBB_from_PSFile;
-
-namespace frontend {
-
-
-ControlExternal::ControlExternal(Dialog & parent)
-       : Dialog::Controller(parent),
-         bb_changed_(false)
-{}
-
-
-bool ControlExternal::initialiseParams(string const & data)
-{
-       params_.reset(new InsetExternalParams);
-       InsetExternalMailer::string2params(data, kernel().buffer(), *params_);
-       return true;
-}
-
-
-void ControlExternal::clearParams()
-{
-       params_.reset();
-}
-
-
-void ControlExternal::dispatchParams()
-{
-       string const lfun = InsetExternalMailer::params2string(params(),
-                                                              kernel().buffer());
-
-       kernel().dispatch(FuncRequest(getLfun(), lfun));
-}
-
-
-void ControlExternal::setParams(InsetExternalParams const & p)
-{
-       BOOST_ASSERT(params_.get());
-       *params_ = p;
-}
-
-
-InsetExternalParams const & ControlExternal::params() const
-{
-       BOOST_ASSERT(params_.get());
-       return *params_;
-}
-
-
-void ControlExternal::editExternal()
-{
-       BOOST_ASSERT(params_.get());
-
-       dialog().view().apply();
-       string const lfun =
-               InsetExternalMailer::params2string(params(), kernel().buffer());
-       kernel().dispatch(FuncRequest(LFUN_EXTERNAL_EDIT, lfun));
-}
-
-
-vector<string> const ControlExternal::getTemplates() const
-{
-       vector<string> result;
-
-       external::TemplateManager::Templates::const_iterator i1, i2;
-       i1 = external::TemplateManager::get().getTemplates().begin();
-       i2 = external::TemplateManager::get().getTemplates().end();
-
-       for (; i1 != i2; ++i1) {
-               result.push_back(i1->second.lyxName);
-       }
-       return result;
-}
-
-
-int ControlExternal::getTemplateNumber(string const & name) const
-{
-       external::TemplateManager::Templates::const_iterator i1, i2;
-       i1 = external::TemplateManager::get().getTemplates().begin();
-       i2 = external::TemplateManager::get().getTemplates().end();
-       for (int i = 0; i1 != i2; ++i1, ++i) {
-               if (i1->second.lyxName == name)
-                       return i;
-       }
-
-       // we can get here if a LyX document has a template not installed
-       // on this machine.
-       return -1;
-}
-
-
-external::Template ControlExternal::getTemplate(int i) const
-{
-       external::TemplateManager::Templates::const_iterator i1
-               = external::TemplateManager::get().getTemplates().begin();
-
-       advance(i1, i);
-
-       return i1->second;
-}
-
-
-string const
-ControlExternal::getTemplateFilters(string const & template_name) const
-{
-       /// Determine the template file extension
-       external::TemplateManager const & etm =
-               external::TemplateManager::get();
-       external::Template const * const et_ptr =
-               etm.getTemplateByName(template_name);
-
-       if (et_ptr) 
-               return et_ptr->fileRegExp;
-
-       return string();
-}
-
-
-docstring const ControlExternal::browse(docstring const & input,
-                                    docstring const & template_name) const
-{
-       docstring const title =  _("Select external file");
-
-       docstring const bufpath = lyx::from_utf8(kernel().bufferFilepath());
-       FileFilterList const filter = 
-               FileFilterList(lyx::from_utf8(getTemplateFilters(lyx::to_utf8(template_name))));
-
-       std::pair<docstring, docstring> dir1(_("Documents|#o#O"),
-               lyx::from_utf8(lyxrc.document_path));
-
-       return browseRelFile(input, bufpath, title, filter, false, dir1);
-}
-
-
-string const ControlExternal::readBB(string const & file)
-{
-       FileName const abs_file(makeAbsPath(file, kernel().bufferFilepath()));
-
-       // try to get it from the file, if possible. Zipped files are
-       // unzipped in the readBB_from_PSFile-Function
-       string const bb = readBB_from_PSFile(abs_file);
-       if (!bb.empty())
-               return bb;
-
-       // we don't, so ask the Graphics Cache if it has loaded the file
-       int width = 0;
-       int height = 0;
-
-       graphics::Cache & gc = graphics::Cache::get();
-       if (gc.inCache(abs_file)) {
-               graphics::Image const * image = gc.item(abs_file)->image();
-
-               if (image) {
-                       width  = image->getWidth();
-                       height = image->getHeight();
-               }
-       }
-
-       return ("0 0 " + convert<string>(width) + ' ' + convert<string>(height));
-}
-
-} // namespace frontend
-
-
-namespace external {
-
-namespace {
-
-RotationDataType origins_array[] = {
-       RotationData::DEFAULT,
-       RotationData::TOPLEFT,
-       RotationData::BOTTOMLEFT,
-       RotationData::BASELINELEFT,
-       RotationData::CENTER,
-       RotationData::TOPCENTER,
-       RotationData::BOTTOMCENTER,
-       RotationData::BASELINECENTER,
-       RotationData::TOPRIGHT,
-       RotationData::BOTTOMRIGHT,
-       RotationData::BASELINERIGHT
-};
-
-
-size_type const origins_array_size =
-sizeof(origins_array) / sizeof(origins_array[0]);
-
-vector<RotationDataType> const
-origins(origins_array, origins_array + origins_array_size);
-
-// These are the strings, corresponding to the above, that the GUI should
-// use. Note that they can/should be translated.
-char const * const origin_gui_strs[] = {
-       N_("Default"),
-       N_("Top left"), N_("Bottom left"), N_("Baseline left"),
-       N_("Center"), N_("Top center"), N_("Bottom center"), N_("Baseline center"),
-       N_("Top right"), N_("Bottom right"), N_("Baseline right")
-};
-
-} // namespace anon
-
-
-vector<RotationDataType> const & all_origins()
-{
-       return origins;
-}
-
-docstring const origin_gui_str(size_type i)
-{
-       return _(origin_gui_strs[i]);
-}
-
-} // namespace external
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlExternal.cpp b/src/frontends/controllers/ControlExternal.cpp
new file mode 100644 (file)
index 0000000..369a23e
--- /dev/null
@@ -0,0 +1,254 @@
+/**
+ * \file ControlExternal.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Asger Alstrup
+ * \author John Levon
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlExternal.h"
+
+#include "funcrequest.h"
+#include "gettext.h"
+#include "frontend_helpers.h"
+#include "lyxrc.h"
+
+#include "graphics/GraphicsCache.h"
+#include "graphics/GraphicsCacheItem.h"
+#include "graphics/GraphicsImage.h"
+
+#include "insets/InsetExternal.h"
+#include "insets/ExternalSupport.h"
+#include "insets/ExternalTemplate.h"
+
+#include "support/filefilterlist.h"
+#include "support/filetools.h"
+#include "support/convert.h"
+
+using std::advance;
+using std::vector;
+using std::string;
+
+namespace lyx {
+
+using support::FileFilterList;
+using support::FileName;
+using support::makeAbsPath;
+using support::readBB_from_PSFile;
+
+namespace frontend {
+
+
+ControlExternal::ControlExternal(Dialog & parent)
+       : Dialog::Controller(parent),
+         bb_changed_(false)
+{}
+
+
+bool ControlExternal::initialiseParams(string const & data)
+{
+       params_.reset(new InsetExternalParams);
+       InsetExternalMailer::string2params(data, kernel().buffer(), *params_);
+       return true;
+}
+
+
+void ControlExternal::clearParams()
+{
+       params_.reset();
+}
+
+
+void ControlExternal::dispatchParams()
+{
+       string const lfun = InsetExternalMailer::params2string(params(),
+                                                              kernel().buffer());
+
+       kernel().dispatch(FuncRequest(getLfun(), lfun));
+}
+
+
+void ControlExternal::setParams(InsetExternalParams const & p)
+{
+       BOOST_ASSERT(params_.get());
+       *params_ = p;
+}
+
+
+InsetExternalParams const & ControlExternal::params() const
+{
+       BOOST_ASSERT(params_.get());
+       return *params_;
+}
+
+
+void ControlExternal::editExternal()
+{
+       BOOST_ASSERT(params_.get());
+
+       dialog().view().apply();
+       string const lfun =
+               InsetExternalMailer::params2string(params(), kernel().buffer());
+       kernel().dispatch(FuncRequest(LFUN_EXTERNAL_EDIT, lfun));
+}
+
+
+vector<string> const ControlExternal::getTemplates() const
+{
+       vector<string> result;
+
+       external::TemplateManager::Templates::const_iterator i1, i2;
+       i1 = external::TemplateManager::get().getTemplates().begin();
+       i2 = external::TemplateManager::get().getTemplates().end();
+
+       for (; i1 != i2; ++i1) {
+               result.push_back(i1->second.lyxName);
+       }
+       return result;
+}
+
+
+int ControlExternal::getTemplateNumber(string const & name) const
+{
+       external::TemplateManager::Templates::const_iterator i1, i2;
+       i1 = external::TemplateManager::get().getTemplates().begin();
+       i2 = external::TemplateManager::get().getTemplates().end();
+       for (int i = 0; i1 != i2; ++i1, ++i) {
+               if (i1->second.lyxName == name)
+                       return i;
+       }
+
+       // we can get here if a LyX document has a template not installed
+       // on this machine.
+       return -1;
+}
+
+
+external::Template ControlExternal::getTemplate(int i) const
+{
+       external::TemplateManager::Templates::const_iterator i1
+               = external::TemplateManager::get().getTemplates().begin();
+
+       advance(i1, i);
+
+       return i1->second;
+}
+
+
+string const
+ControlExternal::getTemplateFilters(string const & template_name) const
+{
+       /// Determine the template file extension
+       external::TemplateManager const & etm =
+               external::TemplateManager::get();
+       external::Template const * const et_ptr =
+               etm.getTemplateByName(template_name);
+
+       if (et_ptr) 
+               return et_ptr->fileRegExp;
+
+       return string();
+}
+
+
+docstring const ControlExternal::browse(docstring const & input,
+                                    docstring const & template_name) const
+{
+       docstring const title =  _("Select external file");
+
+       docstring const bufpath = lyx::from_utf8(kernel().bufferFilepath());
+       FileFilterList const filter = 
+               FileFilterList(lyx::from_utf8(getTemplateFilters(lyx::to_utf8(template_name))));
+
+       std::pair<docstring, docstring> dir1(_("Documents|#o#O"),
+               lyx::from_utf8(lyxrc.document_path));
+
+       return browseRelFile(input, bufpath, title, filter, false, dir1);
+}
+
+
+string const ControlExternal::readBB(string const & file)
+{
+       FileName const abs_file(makeAbsPath(file, kernel().bufferFilepath()));
+
+       // try to get it from the file, if possible. Zipped files are
+       // unzipped in the readBB_from_PSFile-Function
+       string const bb = readBB_from_PSFile(abs_file);
+       if (!bb.empty())
+               return bb;
+
+       // we don't, so ask the Graphics Cache if it has loaded the file
+       int width = 0;
+       int height = 0;
+
+       graphics::Cache & gc = graphics::Cache::get();
+       if (gc.inCache(abs_file)) {
+               graphics::Image const * image = gc.item(abs_file)->image();
+
+               if (image) {
+                       width  = image->getWidth();
+                       height = image->getHeight();
+               }
+       }
+
+       return ("0 0 " + convert<string>(width) + ' ' + convert<string>(height));
+}
+
+} // namespace frontend
+
+
+namespace external {
+
+namespace {
+
+RotationDataType origins_array[] = {
+       RotationData::DEFAULT,
+       RotationData::TOPLEFT,
+       RotationData::BOTTOMLEFT,
+       RotationData::BASELINELEFT,
+       RotationData::CENTER,
+       RotationData::TOPCENTER,
+       RotationData::BOTTOMCENTER,
+       RotationData::BASELINECENTER,
+       RotationData::TOPRIGHT,
+       RotationData::BOTTOMRIGHT,
+       RotationData::BASELINERIGHT
+};
+
+
+size_type const origins_array_size =
+sizeof(origins_array) / sizeof(origins_array[0]);
+
+vector<RotationDataType> const
+origins(origins_array, origins_array + origins_array_size);
+
+// These are the strings, corresponding to the above, that the GUI should
+// use. Note that they can/should be translated.
+char const * const origin_gui_strs[] = {
+       N_("Default"),
+       N_("Top left"), N_("Bottom left"), N_("Baseline left"),
+       N_("Center"), N_("Top center"), N_("Bottom center"), N_("Baseline center"),
+       N_("Top right"), N_("Bottom right"), N_("Baseline right")
+};
+
+} // namespace anon
+
+
+vector<RotationDataType> const & all_origins()
+{
+       return origins;
+}
+
+docstring const origin_gui_str(size_type i)
+{
+       return _(origin_gui_strs[i]);
+}
+
+} // namespace external
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlFloat.C b/src/frontends/controllers/ControlFloat.C
deleted file mode 100644 (file)
index cc3cc65..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * \file ControlFloat.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author unknown
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlFloat.h"
-#include "funcrequest.h"
-#include "insets/InsetFloat.h"
-
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-ControlFloat::ControlFloat(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-bool ControlFloat::initialiseParams(string const & data)
-{
-       InsetFloatParams params;
-       InsetFloatMailer::string2params(data, params);
-       params_.reset(new InsetFloatParams(params));
-       return true;
-}
-
-
-void ControlFloat::clearParams()
-{
-       params_.reset();
-}
-
-
-void ControlFloat::dispatchParams()
-{
-       string const lfun = InsetFloatMailer::params2string(params());
-       kernel().dispatch(FuncRequest(getLfun(), lfun));
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlFloat.cpp b/src/frontends/controllers/ControlFloat.cpp
new file mode 100644 (file)
index 0000000..cc3cc65
--- /dev/null
@@ -0,0 +1,50 @@
+/**
+ * \file ControlFloat.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author unknown
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlFloat.h"
+#include "funcrequest.h"
+#include "insets/InsetFloat.h"
+
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+ControlFloat::ControlFloat(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+bool ControlFloat::initialiseParams(string const & data)
+{
+       InsetFloatParams params;
+       InsetFloatMailer::string2params(data, params);
+       params_.reset(new InsetFloatParams(params));
+       return true;
+}
+
+
+void ControlFloat::clearParams()
+{
+       params_.reset();
+}
+
+
+void ControlFloat::dispatchParams()
+{
+       string const lfun = InsetFloatMailer::params2string(params());
+       kernel().dispatch(FuncRequest(getLfun(), lfun));
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlGraphics.C b/src/frontends/controllers/ControlGraphics.C
deleted file mode 100644 (file)
index b07a5e0..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/**
- * \file ControlGraphics.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- * \author Herbert Voß
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlGraphics.h"
-
-#include "frontend_helpers.h"
-
-#include "funcrequest.h"
-#include "gettext.h"
-#include "lyxrc.h"
-
-#include "graphics/GraphicsCache.h"
-#include "graphics/GraphicsCacheItem.h"
-#include "graphics/GraphicsImage.h"
-
-#include "insets/InsetGraphics.h"
-
-#include "support/convert.h"
-#include "support/filefilterlist.h"
-#include "support/filetools.h"
-#include "support/package.h"
-#include "support/types.h"
-
-#include <boost/filesystem/operations.hpp>
-
-using std::make_pair;
-using std::string;
-using std::pair;
-using std::vector;
-
-namespace fs = boost::filesystem;
-
-namespace lyx {
-
-using support::addName;
-using support::FileFilterList;
-using support::FileName;
-using support::isFileReadable;
-using support::makeAbsPath;
-using support::package;
-using support::readBB_from_PSFile;
-
-namespace frontend {
-
-
-ControlGraphics::ControlGraphics(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-bool ControlGraphics::initialiseParams(string const & data)
-{
-       InsetGraphicsParams params;
-       InsetGraphicsMailer::string2params(data, kernel().buffer(), params);
-       params_.reset(new InsetGraphicsParams(params));
-       return true;
-}
-
-
-void ControlGraphics::clearParams()
-{
-       params_.reset();
-}
-
-
-void ControlGraphics::dispatchParams()
-{
-       InsetGraphicsParams tmp_params(params());
-       string const lfun =
-               InsetGraphicsMailer::params2string(tmp_params, kernel().buffer());
-       kernel().dispatch(FuncRequest(getLfun(), lfun));
-}
-
-
-docstring const ControlGraphics::browse(docstring const & in_name) const
-{
-       docstring const title = _("Select graphics file");
-
-       // Does user clipart directory exist?
-       string clipdir = addName(package().user_support().absFilename(), "clipart");
-       string const encoded_clipdir = FileName(clipdir).toFilesystemEncoding();
-       if (!(fs::exists(encoded_clipdir) && fs::is_directory(encoded_clipdir)))
-               // No - bail out to system clipart directory
-               clipdir = addName(package().system_support().absFilename(), "clipart");
-       pair<docstring, docstring> dir1(_("Clipart|#C#c"), from_utf8(clipdir));
-       pair<docstring, docstring> dir2(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
-       // Show the file browser dialog
-       return browseRelFile(in_name, from_utf8(kernel().bufferFilepath()),
-                            title,
-                            FileFilterList(),
-                            false, dir1, dir2);
-}
-
-
-string const ControlGraphics::readBB(string const & file)
-{
-       FileName const abs_file(makeAbsPath(file, kernel().bufferFilepath()));
-
-       // try to get it from the file, if possible. Zipped files are
-       // unzipped in the readBB_from_PSFile-Function
-       string const bb = readBB_from_PSFile(abs_file);
-       if (!bb.empty())
-               return bb;
-
-       // we don't, so ask the Graphics Cache if it has loaded the file
-       int width = 0;
-       int height = 0;
-
-       graphics::Cache & gc = graphics::Cache::get();
-       if (gc.inCache(abs_file)) {
-               graphics::Image const * image = gc.item(abs_file)->image();
-
-               if (image) {
-                       width  = image->getWidth();
-                       height = image->getHeight();
-               }
-       }
-
-       return ("0 0 " + convert<string>(width) + ' ' + convert<string>(height));
-}
-
-
-bool ControlGraphics::isFilenameValid(string const & fname) const
-{
-       // It may be that the filename is relative.
-       FileName const name(makeAbsPath(fname, kernel().bufferFilepath()));
-       return isFileReadable(name);
-}
-
-
-void ControlGraphics::editGraphics()
-{
-       BOOST_ASSERT(params_.get());
-
-       dialog().view().apply();
-       string const lfun =
-               InsetGraphicsMailer::params2string(params(), kernel().buffer());
-       kernel().dispatch(FuncRequest(LFUN_GRAPHICS_EDIT, lfun));
-}
-
-
-namespace {
-
-char const * const bb_units[] = { "bp", "cm", "mm", "in" };
-size_t const bb_size = sizeof(bb_units) / sizeof(char *);
-
-// These are the strings that are stored in the LyX file and which
-// correspond to the LaTeX identifiers shown in the comments at the
-// end of each line.
-char const * const rorigin_lyx_strs[] = {
-       // the LaTeX default is leftBaseline
-       "",
-       "leftTop",  "leftBottom", "leftBaseline", // lt lb lB
-       "center", "centerTop", "centerBottom", "centerBaseline", // c ct cb cB
-       "rightTop", "rightBottom", "rightBaseline" }; // rt rb rB
-
-// These are the strings, corresponding to the above, that the GUI should
-// use. Note that they can/should be translated.
-char const * const rorigin_gui_strs[] = {
-       N_("Default"),
-       N_("Top left"), N_("Bottom left"), N_("Baseline left"),
-       N_("Center"), N_("Top center"), N_("Bottom center"), N_("Baseline center"),
-       N_("Top right"), N_("Bottom right"), N_("Baseline right") };
-
-size_t const rorigin_size = sizeof(rorigin_lyx_strs) / sizeof(char *);
-
-} // namespace anon
-
-
-vector<string> const getBBUnits()
-{
-       return vector<string>(bb_units, bb_units + bb_size);
-}
-
-
-vector<RotationOriginPair> getRotationOriginData()
-{
-       static vector<RotationOriginPair> data;
-       if (!data.empty())
-               return data;
-
-       data.resize(rorigin_size);
-       for (size_type i = 0; i < rorigin_size; ++i) {
-               data[i] = make_pair(_(rorigin_gui_strs[i]),
-                                   rorigin_lyx_strs[i]);
-       }
-
-       return data;
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlGraphics.cpp b/src/frontends/controllers/ControlGraphics.cpp
new file mode 100644 (file)
index 0000000..b07a5e0
--- /dev/null
@@ -0,0 +1,202 @@
+/**
+ * \file ControlGraphics.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ * \author Herbert Voß
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlGraphics.h"
+
+#include "frontend_helpers.h"
+
+#include "funcrequest.h"
+#include "gettext.h"
+#include "lyxrc.h"
+
+#include "graphics/GraphicsCache.h"
+#include "graphics/GraphicsCacheItem.h"
+#include "graphics/GraphicsImage.h"
+
+#include "insets/InsetGraphics.h"
+
+#include "support/convert.h"
+#include "support/filefilterlist.h"
+#include "support/filetools.h"
+#include "support/package.h"
+#include "support/types.h"
+
+#include <boost/filesystem/operations.hpp>
+
+using std::make_pair;
+using std::string;
+using std::pair;
+using std::vector;
+
+namespace fs = boost::filesystem;
+
+namespace lyx {
+
+using support::addName;
+using support::FileFilterList;
+using support::FileName;
+using support::isFileReadable;
+using support::makeAbsPath;
+using support::package;
+using support::readBB_from_PSFile;
+
+namespace frontend {
+
+
+ControlGraphics::ControlGraphics(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+bool ControlGraphics::initialiseParams(string const & data)
+{
+       InsetGraphicsParams params;
+       InsetGraphicsMailer::string2params(data, kernel().buffer(), params);
+       params_.reset(new InsetGraphicsParams(params));
+       return true;
+}
+
+
+void ControlGraphics::clearParams()
+{
+       params_.reset();
+}
+
+
+void ControlGraphics::dispatchParams()
+{
+       InsetGraphicsParams tmp_params(params());
+       string const lfun =
+               InsetGraphicsMailer::params2string(tmp_params, kernel().buffer());
+       kernel().dispatch(FuncRequest(getLfun(), lfun));
+}
+
+
+docstring const ControlGraphics::browse(docstring const & in_name) const
+{
+       docstring const title = _("Select graphics file");
+
+       // Does user clipart directory exist?
+       string clipdir = addName(package().user_support().absFilename(), "clipart");
+       string const encoded_clipdir = FileName(clipdir).toFilesystemEncoding();
+       if (!(fs::exists(encoded_clipdir) && fs::is_directory(encoded_clipdir)))
+               // No - bail out to system clipart directory
+               clipdir = addName(package().system_support().absFilename(), "clipart");
+       pair<docstring, docstring> dir1(_("Clipart|#C#c"), from_utf8(clipdir));
+       pair<docstring, docstring> dir2(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
+       // Show the file browser dialog
+       return browseRelFile(in_name, from_utf8(kernel().bufferFilepath()),
+                            title,
+                            FileFilterList(),
+                            false, dir1, dir2);
+}
+
+
+string const ControlGraphics::readBB(string const & file)
+{
+       FileName const abs_file(makeAbsPath(file, kernel().bufferFilepath()));
+
+       // try to get it from the file, if possible. Zipped files are
+       // unzipped in the readBB_from_PSFile-Function
+       string const bb = readBB_from_PSFile(abs_file);
+       if (!bb.empty())
+               return bb;
+
+       // we don't, so ask the Graphics Cache if it has loaded the file
+       int width = 0;
+       int height = 0;
+
+       graphics::Cache & gc = graphics::Cache::get();
+       if (gc.inCache(abs_file)) {
+               graphics::Image const * image = gc.item(abs_file)->image();
+
+               if (image) {
+                       width  = image->getWidth();
+                       height = image->getHeight();
+               }
+       }
+
+       return ("0 0 " + convert<string>(width) + ' ' + convert<string>(height));
+}
+
+
+bool ControlGraphics::isFilenameValid(string const & fname) const
+{
+       // It may be that the filename is relative.
+       FileName const name(makeAbsPath(fname, kernel().bufferFilepath()));
+       return isFileReadable(name);
+}
+
+
+void ControlGraphics::editGraphics()
+{
+       BOOST_ASSERT(params_.get());
+
+       dialog().view().apply();
+       string const lfun =
+               InsetGraphicsMailer::params2string(params(), kernel().buffer());
+       kernel().dispatch(FuncRequest(LFUN_GRAPHICS_EDIT, lfun));
+}
+
+
+namespace {
+
+char const * const bb_units[] = { "bp", "cm", "mm", "in" };
+size_t const bb_size = sizeof(bb_units) / sizeof(char *);
+
+// These are the strings that are stored in the LyX file and which
+// correspond to the LaTeX identifiers shown in the comments at the
+// end of each line.
+char const * const rorigin_lyx_strs[] = {
+       // the LaTeX default is leftBaseline
+       "",
+       "leftTop",  "leftBottom", "leftBaseline", // lt lb lB
+       "center", "centerTop", "centerBottom", "centerBaseline", // c ct cb cB
+       "rightTop", "rightBottom", "rightBaseline" }; // rt rb rB
+
+// These are the strings, corresponding to the above, that the GUI should
+// use. Note that they can/should be translated.
+char const * const rorigin_gui_strs[] = {
+       N_("Default"),
+       N_("Top left"), N_("Bottom left"), N_("Baseline left"),
+       N_("Center"), N_("Top center"), N_("Bottom center"), N_("Baseline center"),
+       N_("Top right"), N_("Bottom right"), N_("Baseline right") };
+
+size_t const rorigin_size = sizeof(rorigin_lyx_strs) / sizeof(char *);
+
+} // namespace anon
+
+
+vector<string> const getBBUnits()
+{
+       return vector<string>(bb_units, bb_units + bb_size);
+}
+
+
+vector<RotationOriginPair> getRotationOriginData()
+{
+       static vector<RotationOriginPair> data;
+       if (!data.empty())
+               return data;
+
+       data.resize(rorigin_size);
+       for (size_type i = 0; i < rorigin_size; ++i) {
+               data[i] = make_pair(_(rorigin_gui_strs[i]),
+                                   rorigin_lyx_strs[i]);
+       }
+
+       return data;
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlInclude.C b/src/frontends/controllers/ControlInclude.C
deleted file mode 100644 (file)
index 6677db2..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * \file ControlInclude.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Alejandro Aguilar Sierra
- * \author John Levon
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlInclude.h"
-#include "frontend_helpers.h"
-#include "Kernel.h"
-
-#include "buffer.h"
-#include "format.h"
-#include "funcrequest.h"
-#include "gettext.h"
-#include "lyxrc.h"
-
-#include "insets/InsetInclude.h"
-
-#include "support/filefilterlist.h"
-#include "support/filetools.h"
-
-#include <utility>
-
-using std::pair;
-using std::string;
-
-namespace lyx {
-
-using support::FileFilterList;
-using support::FileName;
-using support::isFileReadable;
-using support::makeAbsPath;
-using support::onlyPath;
-
-namespace frontend {
-
-ControlInclude::ControlInclude(Dialog & parent)
-       : Dialog::Controller(parent), params_("include")
-{}
-
-
-bool ControlInclude::initialiseParams(string const & data)
-{
-       InsetIncludeMailer::string2params(data, params_);
-       return true;
-}
-
-
-void ControlInclude::clearParams()
-{
-       params_.clear();
-}
-
-
-void ControlInclude::dispatchParams()
-{
-       string const lfun = InsetIncludeMailer::params2string(params_);
-       kernel().dispatch(FuncRequest(getLfun(), lfun));
-}
-
-
-void ControlInclude::setParams(InsetCommandParams const & params)
-{
-       params_ = params;
-}
-
-
-docstring const ControlInclude::browse(docstring const & in_name, Type in_type) const
-{
-       docstring const title = _("Select document to include");
-
-       // input TeX, verbatim, or LyX file ?
-       FileFilterList filters;
-       switch (in_type) {
-       case INCLUDE:
-       case INPUT:
-               filters = FileFilterList(_("LaTeX/LyX Documents (*.tex *.lyx)"));
-               break;
-       case VERBATIM:
-               break;
-       }
-
-       pair<docstring, docstring> dir1(_("Documents|#o#O"),
-               lyx::from_utf8(lyxrc.document_path));
-
-       docstring const docpath = lyx::from_utf8(onlyPath(kernel().buffer().fileName()));
-
-       return browseRelFile(in_name, docpath, title,
-                            filters, false, dir1);
-}
-
-
-void ControlInclude::load(string const & file)
-{
-       string const ext = support::getExtension(file);
-       if (ext == "lyx")
-               kernel().dispatch(FuncRequest(LFUN_BUFFER_CHILD_OPEN, file));
-       else
-               // tex file or other text file in verbatim mode
-               formats.edit(kernel().buffer(), FileName(file), "text");
-}
-
-
-bool ControlInclude::fileExists(string const & file)
-{
-       FileName const fileWithAbsPath(
-               makeAbsPath(file, onlyPath(kernel().buffer().fileName())));
-
-       if (isFileReadable(fileWithAbsPath))
-               return true;
-
-       return false;
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlInclude.cpp b/src/frontends/controllers/ControlInclude.cpp
new file mode 100644 (file)
index 0000000..6677db2
--- /dev/null
@@ -0,0 +1,124 @@
+/**
+ * \file ControlInclude.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alejandro Aguilar Sierra
+ * \author John Levon
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlInclude.h"
+#include "frontend_helpers.h"
+#include "Kernel.h"
+
+#include "buffer.h"
+#include "format.h"
+#include "funcrequest.h"
+#include "gettext.h"
+#include "lyxrc.h"
+
+#include "insets/InsetInclude.h"
+
+#include "support/filefilterlist.h"
+#include "support/filetools.h"
+
+#include <utility>
+
+using std::pair;
+using std::string;
+
+namespace lyx {
+
+using support::FileFilterList;
+using support::FileName;
+using support::isFileReadable;
+using support::makeAbsPath;
+using support::onlyPath;
+
+namespace frontend {
+
+ControlInclude::ControlInclude(Dialog & parent)
+       : Dialog::Controller(parent), params_("include")
+{}
+
+
+bool ControlInclude::initialiseParams(string const & data)
+{
+       InsetIncludeMailer::string2params(data, params_);
+       return true;
+}
+
+
+void ControlInclude::clearParams()
+{
+       params_.clear();
+}
+
+
+void ControlInclude::dispatchParams()
+{
+       string const lfun = InsetIncludeMailer::params2string(params_);
+       kernel().dispatch(FuncRequest(getLfun(), lfun));
+}
+
+
+void ControlInclude::setParams(InsetCommandParams const & params)
+{
+       params_ = params;
+}
+
+
+docstring const ControlInclude::browse(docstring const & in_name, Type in_type) const
+{
+       docstring const title = _("Select document to include");
+
+       // input TeX, verbatim, or LyX file ?
+       FileFilterList filters;
+       switch (in_type) {
+       case INCLUDE:
+       case INPUT:
+               filters = FileFilterList(_("LaTeX/LyX Documents (*.tex *.lyx)"));
+               break;
+       case VERBATIM:
+               break;
+       }
+
+       pair<docstring, docstring> dir1(_("Documents|#o#O"),
+               lyx::from_utf8(lyxrc.document_path));
+
+       docstring const docpath = lyx::from_utf8(onlyPath(kernel().buffer().fileName()));
+
+       return browseRelFile(in_name, docpath, title,
+                            filters, false, dir1);
+}
+
+
+void ControlInclude::load(string const & file)
+{
+       string const ext = support::getExtension(file);
+       if (ext == "lyx")
+               kernel().dispatch(FuncRequest(LFUN_BUFFER_CHILD_OPEN, file));
+       else
+               // tex file or other text file in verbatim mode
+               formats.edit(kernel().buffer(), FileName(file), "text");
+}
+
+
+bool ControlInclude::fileExists(string const & file)
+{
+       FileName const fileWithAbsPath(
+               makeAbsPath(file, onlyPath(kernel().buffer().fileName())));
+
+       if (isFileReadable(fileWithAbsPath))
+               return true;
+
+       return false;
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlLog.C b/src/frontends/controllers/ControlLog.C
deleted file mode 100644 (file)
index ba1a535..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * \file ControlLog.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlLog.h"
-
-#include "gettext.h"
-#include "lyxlex.h"
-
-#include <sstream>
-#include <fstream>
-
-using std::istringstream;
-using std::ostream;
-using std::string;
-
-namespace lyx {
-
-using support::FileName;
-
-namespace frontend {
-
-ControlLog::ControlLog(Dialog & parent)
-       : Dialog::Controller(parent),
-         type_(LatexLog)
-{}
-
-
-bool ControlLog::initialiseParams(string const & data)
-{
-       istringstream is(data);
-       LyXLex lex(0,0);
-       lex.setStream(is);
-
-       string logtype, logfile;
-       lex >> logtype;
-       if (lex) {
-               lex.next(true);
-               logfile = lex.getString();
-       }
-       if (!lex)
-               // Parsing of the data failed.
-               return false;
-
-       if (logtype == "latex")
-               type_ = LatexLog;
-       else if (logtype == "literate")
-               type_ = LiterateLog;
-       else if (logtype == "lyx2lyx")
-               type_ = Lyx2lyxLog;
-       else if (logtype == "vc")
-               type_ = VCLog;
-       else
-               return false;
-
-       logfile_ = FileName(logfile);
-       return true;
-}
-
-
-void ControlLog::clearParams()
-{
-       logfile_.erase();
-}
-
-
-docstring const ControlLog::title() const
-{
-       docstring t;
-       switch (type_) {
-       case LatexLog:
-               t = _("LaTeX Log");
-               break;
-       case LiterateLog:
-               t = _("Literate Programming Build Log");
-               break;
-       case Lyx2lyxLog:
-               t = _("lyx2lyx Error Log");
-               break;
-       case VCLog:
-               t = _("Version Control Log");
-               break;
-       }
-       return t;
-}
-
-
-void ControlLog::getContents(std::ostream & ss) const
-{
-       std::ifstream in(logfile_.toFilesystemEncoding().c_str());
-
-       bool success = false;
-
-       // FIXME UNICODE
-       // Our caller interprets the file contents as UTF8, but is that
-       // correct?
-       if (in) {
-               ss << in.rdbuf();
-               success = ss.good();
-       }
-
-       if (success)
-               return;
-
-       switch (type_) {
-       case LatexLog:
-               ss << lyx::to_utf8(_("No LaTeX log file found."));
-               break;
-       case LiterateLog:
-               ss << lyx::to_utf8(_("No literate programming build log file found."));
-               break;
-       case Lyx2lyxLog:
-               ss << lyx::to_utf8(_("No lyx2lyx error log file found."));
-               break;
-       case VCLog:
-               ss << lyx::to_utf8(_("No version control log file found."));
-               break;
-       }
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlLog.cpp b/src/frontends/controllers/ControlLog.cpp
new file mode 100644 (file)
index 0000000..ba1a535
--- /dev/null
@@ -0,0 +1,131 @@
+/**
+ * \file ControlLog.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlLog.h"
+
+#include "gettext.h"
+#include "lyxlex.h"
+
+#include <sstream>
+#include <fstream>
+
+using std::istringstream;
+using std::ostream;
+using std::string;
+
+namespace lyx {
+
+using support::FileName;
+
+namespace frontend {
+
+ControlLog::ControlLog(Dialog & parent)
+       : Dialog::Controller(parent),
+         type_(LatexLog)
+{}
+
+
+bool ControlLog::initialiseParams(string const & data)
+{
+       istringstream is(data);
+       LyXLex lex(0,0);
+       lex.setStream(is);
+
+       string logtype, logfile;
+       lex >> logtype;
+       if (lex) {
+               lex.next(true);
+               logfile = lex.getString();
+       }
+       if (!lex)
+               // Parsing of the data failed.
+               return false;
+
+       if (logtype == "latex")
+               type_ = LatexLog;
+       else if (logtype == "literate")
+               type_ = LiterateLog;
+       else if (logtype == "lyx2lyx")
+               type_ = Lyx2lyxLog;
+       else if (logtype == "vc")
+               type_ = VCLog;
+       else
+               return false;
+
+       logfile_ = FileName(logfile);
+       return true;
+}
+
+
+void ControlLog::clearParams()
+{
+       logfile_.erase();
+}
+
+
+docstring const ControlLog::title() const
+{
+       docstring t;
+       switch (type_) {
+       case LatexLog:
+               t = _("LaTeX Log");
+               break;
+       case LiterateLog:
+               t = _("Literate Programming Build Log");
+               break;
+       case Lyx2lyxLog:
+               t = _("lyx2lyx Error Log");
+               break;
+       case VCLog:
+               t = _("Version Control Log");
+               break;
+       }
+       return t;
+}
+
+
+void ControlLog::getContents(std::ostream & ss) const
+{
+       std::ifstream in(logfile_.toFilesystemEncoding().c_str());
+
+       bool success = false;
+
+       // FIXME UNICODE
+       // Our caller interprets the file contents as UTF8, but is that
+       // correct?
+       if (in) {
+               ss << in.rdbuf();
+               success = ss.good();
+       }
+
+       if (success)
+               return;
+
+       switch (type_) {
+       case LatexLog:
+               ss << lyx::to_utf8(_("No LaTeX log file found."));
+               break;
+       case LiterateLog:
+               ss << lyx::to_utf8(_("No literate programming build log file found."));
+               break;
+       case Lyx2lyxLog:
+               ss << lyx::to_utf8(_("No lyx2lyx error log file found."));
+               break;
+       case VCLog:
+               ss << lyx::to_utf8(_("No version control log file found."));
+               break;
+       }
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlMath.C b/src/frontends/controllers/ControlMath.C
deleted file mode 100644 (file)
index d30562c..0000000
+++ /dev/null
@@ -1,517 +0,0 @@
-/**
- * \file ControlMath.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlMath.h"
-#include "debug.h"
-#include "funcrequest.h"
-
-#include "support/lyxalgo.h" // sorted
-#include "support/lstrings.h"
-#include "support/filetools.h"
-
-#include <functional>
-
-using std::string;
-using std::map;
-
-namespace lyx {
-
-using support::compare;
-using support::libFileSearch;
-using support::subst;
-
-namespace frontend {
-
-ControlMath::ControlMath(Dialog & dialog)
-       : Dialog::Controller(dialog)
-{
-       // FIXME: Ideally, those unicode codepoints would be defined
-       // in "lib/symbols". Unfortunately, some of those are already 
-       // defined with non-unicode ids for use within mathed.
-       // FIXME 2: We should fill-in this map with the parsed "symbols"
-       // file done in MathFactory.cpp.
-       math_symbols_["("] = MathSymbol('(');
-       math_symbols_[")"] = MathSymbol(')');
-       math_symbols_["{"] = MathSymbol('{');
-       math_symbols_["}"] = MathSymbol('}');
-       math_symbols_["["] = MathSymbol('[');
-       math_symbols_["]"] = MathSymbol(']');
-       math_symbols_["|"] = MathSymbol('|');
-       math_symbols_["/"] = MathSymbol('/', 54, LyXFont::CMSY_FAMILY);
-       math_symbols_["backslash"] = MathSymbol('\\', 110, LyXFont::CMSY_FAMILY);
-       math_symbols_["lceil"] = MathSymbol(0x2308, 100, LyXFont::CMSY_FAMILY);
-       math_symbols_["rceil"] = MathSymbol(0x2309, 101, LyXFont::CMSY_FAMILY);
-       math_symbols_["lfloor"] = MathSymbol(0x230A, 98, LyXFont::CMSY_FAMILY);
-       math_symbols_["rfloor"] = MathSymbol(0x230B, 99, LyXFont::CMSY_FAMILY);
-       math_symbols_["langle"] = MathSymbol(0x2329, 104, LyXFont::CMSY_FAMILY);
-       math_symbols_["rangle"] = MathSymbol(0x232A, 105, LyXFont::CMSY_FAMILY);
-       math_symbols_["uparrow"] = MathSymbol(0x2191, 34, LyXFont::CMSY_FAMILY);
-       math_symbols_["Uparrow"] = MathSymbol(0x21D1, 42, LyXFont::CMSY_FAMILY);
-       math_symbols_["updownarrow"] = MathSymbol(0x2195, 108, LyXFont::CMSY_FAMILY);
-       math_symbols_["Updownarrow"] = MathSymbol(0x21D5, 109, LyXFont::CMSY_FAMILY);
-       math_symbols_["downarrow"] = MathSymbol(0x2193, 35, LyXFont::CMSY_FAMILY);
-       math_symbols_["Downarrow"] = MathSymbol(0x21D3, 43, LyXFont::CMSY_FAMILY);
-       math_symbols_["downdownarrows"] = MathSymbol(0x21CA, 184, LyXFont::MSA_FAMILY);
-       math_symbols_["downharpoonleft"] = MathSymbol(0x21C3, 188, LyXFont::MSA_FAMILY);
-       math_symbols_["downharpoonright"] = MathSymbol(0x21C2, 186, LyXFont::MSA_FAMILY);
-       math_symbols_["vert"] = MathSymbol(0x007C, 106, LyXFont::CMSY_FAMILY);
-       math_symbols_["Vert"] = MathSymbol(0x2016, 107, LyXFont::CMSY_FAMILY);
-
-       std::map<string, MathSymbol>::const_iterator it = math_symbols_.begin();
-       std::map<string, MathSymbol>::const_iterator end = math_symbols_.end();
-       for (; it != end; ++it)
-               tex_names_[it->second.unicode] = it->first;
-}
-
-
-void ControlMath::dispatchFunc(kb_action action, string const & arg) const
-{
-       kernel().dispatch(FuncRequest(action, arg));
-}
-
-
-void ControlMath::dispatchInsert(string const & name) const
-{
-       dispatchFunc(LFUN_MATH_INSERT, '\\' + name);
-}
-
-
-void ControlMath::dispatchSubscript() const
-{
-       dispatchFunc(LFUN_MATH_INSERT, "_");
-}
-
-
-void ControlMath::dispatchSuperscript() const
-{
-       dispatchFunc(LFUN_MATH_INSERT, "^");
-}
-
-
-void ControlMath::dispatchCubeRoot() const
-{
-       dispatchFunc(LFUN_MATH_INSERT, "\\root");
-       dispatchFunc(LFUN_SELF_INSERT, "3");
-       dispatchFunc(LFUN_CHAR_FORWARD);
-}
-
-
-void ControlMath::dispatchMatrix(string const & str) const
-{
-       dispatchFunc(LFUN_MATH_MATRIX, str);
-}
-
-
-void ControlMath::dispatchDelim(string const & str) const
-{
-       dispatchFunc(LFUN_MATH_DELIM, str);
-}
-
-
-void ControlMath::dispatchBigDelim(string const & str) const
-{
-       dispatchFunc(LFUN_MATH_BIGDELIM, str);
-}
-
-
-void ControlMath::dispatchToggleDisplay() const
-{
-       dispatchFunc(LFUN_MATH_DISPLAY);
-}
-
-
-void ControlMath::showDialog(string const & name) const
-{
-       dispatchFunc(LFUN_DIALOG_SHOW, name);
-}
-
-
-MathSymbol const & ControlMath::mathSymbol(string tex_name) const
-{
-       map<string, MathSymbol>::const_iterator it =
-               math_symbols_.find(tex_name);
-       
-       static MathSymbol unknown_symbol;
-       if (it == math_symbols_.end())
-               return unknown_symbol;
-       
-       return it->second;
-}
-
-
-std::string const & ControlMath::texName(char_type math_symbol) const
-{
-       map<char_type, string>::const_iterator it =
-               tex_names_.find(math_symbol);
-       
-       static string empty_string;
-       if (it == tex_names_.end())
-               return empty_string;
-       
-       return it->second;
-}
-
-
-char const * function_names[] = {
-       "arccos", "arcsin", "arctan", "arg", "bmod",
-       "cos", "cosh", "cot", "coth", "csc", "deg",
-       "det", "dim", "exp", "gcd", "hom", "inf", "ker",
-       "lg", "lim", "liminf", "limsup", "ln", "log",
-       "max", "min", "sec", "sin", "sinh", "sup",
-       "tan", "tanh", "Pr", ""
-};
-
-int const nr_function_names = sizeof(function_names) / sizeof(char const *) - 1;
-
-char const * latex_dots[] = {
-       "ldots", "cdots", "vdots", "ddots", ""
-};
-
-int const nr_latex_dots = sizeof(latex_dots) / sizeof(char const *) - 1;
-
-char const * latex_deco[] = {
-       "widehat", "widetilde", "overbrace", "overleftarrow", "overrightarrow",
-       "overline", "underbrace", "underline", "underleftarrow", "underrightarrow",
-       "underleftrightarrow", "overleftrightarrow",
-       "hat", "acute", "bar", "dot",
-       "check", "grave", "vec", "ddot",
-       "breve", "tilde", "overset", "underset", ""
-};
-
-int const nr_latex_deco = sizeof(latex_deco) / sizeof(char const *) - 1;
-
-char const * latex_arrow[] = {
-       "leftarrow", "rightarrow",
-       "downarrow", "uparrow", "updownarrow", "leftrightarrow",
-       "Leftarrow", "Rightarrow",
-       "Downarrow", "Uparrow", "Updownarrow", "Leftrightarrow",
-       "Longleftrightarrow", "Longleftarrow", "Longrightarrow",
-       "longleftrightarrow", "longleftarrow", "longrightarrow",
-       "leftharpoondown", "rightharpoondown", 
-       "mapsto", "longmapsto",
-       "nwarrow", "nearrow",
-       "leftharpoonup", "rightharpoonup",      
-       "hookleftarrow", "hookrightarrow",
-       "swarrow", "searrow",
-       "rightleftharpoons",
-       "",
-};
-
-int const nr_latex_arrow = sizeof(latex_arrow) / sizeof(char const *);
-
-char const * latex_bop[] = {
-       "pm", "cap", "diamond", "oplus",
-       "mp", "cup", "bigtriangleup", "ominus",
-       "times", "uplus", "bigtriangledown", "otimes",
-       "div", "sqcap", "triangleright", "oslash",
-       "cdot", "sqcup", "triangleleft", "odot",
-       "star", "vee", "amalg", "bigcirc",
-       "setminus", "wedge", "dagger", "circ",
-       "bullet", "wr", "ddagger", ""
-};
-
-int const nr_latex_bop = sizeof(latex_bop) / sizeof(char const *);
-
-char const * latex_brel[] = {
-       "leq", "geq", "equiv", "models",
-       "prec", "succ", "sim", "perp",
-       "preceq", "succeq", "simeq", "mid",
-       "ll", "gg", "asymp", "parallel",
-       "subset", "supset", "approx", "smile",
-       "subseteq", "supseteq", "cong", "frown",
-       "sqsubseteq", "sqsupseteq", "doteq", "neq",
-       "in", "ni", "propto", "notin",
-       "vdash", "dashv", "bowtie", ""
-};
-
-int const nr_latex_brel = sizeof(latex_brel) / sizeof(char const *);
-
-char const * latex_greek[] = {
-       "Gamma", "Delta", "Theta", "Lambda", "Xi", "Pi",
-       "Sigma", "Upsilon", "Phi", "Psi", "Omega",
-       "alpha", "beta", "gamma", "delta", "epsilon", "varepsilon", "zeta",
-       "eta", "theta", "vartheta", "iota", "kappa", "lambda", "mu",
-       "nu", "xi", "pi", "varpi", "rho", "sigma", "varsigma",
-       "tau", "upsilon", "phi", "varphi", "chi", "psi", "omega", ""
-};
-
-int const nr_latex_greek = sizeof(latex_greek) / sizeof(char const *);
-
-char const * latex_misc[] = {
-       "nabla", "partial", "infty", "prime", "ell",
-       "emptyset", "exists", "forall", "imath",  "jmath",
-       "Re", "Im", "aleph", "wp", "hbar",
-       "angle", "top", "bot", "Vert", "neg",
-       "flat", "natural", "sharp", "surd", "triangle",
-       "diamondsuit", "heartsuit", "clubsuit", "spadesuit",
-       "textrm \\AA", "textrm \\O", "mathcircumflex", "_",
-       "mathrm T",
-       "mathbb N", "mathbb Z", "mathbb Q",
-       "mathbb R", "mathbb C", "mathbb H",
-       "mathcal F", "mathcal L",
-       "mathcal H", "mathcal O",
-       "phantom", "vphantom", "hphantom", ""
-};
-
-int const nr_latex_misc = sizeof(latex_misc) / sizeof(char const *);
-
-char const * latex_varsz[] = {
-       "sum", "int", "intop", "iint", "iintop", "iiint", "iiintop",
-       "iiiint", "iiiintop", "dotsint", "dotsintop",
-       "oint", "ointop", "oiint", "oiintop", "ointctrclockwise",
-       "ointctrclockwiseop", "ointclockwise", "ointclockwiseop",
-       "sqint", "sqintop", "sqiint", "sqiintop",
-       "prod", "coprod", "bigsqcup",
-       "bigotimes", "bigodot", "bigoplus",
-       "bigcap", "bigcup", "biguplus",
-       "bigvee", "bigwedge", ""
-};
-
-int const nr_latex_varsz = sizeof(latex_varsz) / sizeof(char const *);
-
-char const * latex_ams_misc[] = {
-       "digamma", "varkappa", "beth", "daleth", "gimel",
-       "ulcorner", "urcorner", "llcorner", "lrcorner",
-       "hbar", "hslash", "vartriangle",
-       "triangledown", "square", "lozenge",
-       "circledS", "angle", "measuredangle",
-       "nexists", "mho", "Finv",
-       "Game", "Bbbk", "backprime",
-       "varnothing", "blacktriangle", "blacktriangledown",
-       "blacksquare", "blacklozenge", "bigstar",
-       "sphericalangle", "complement", "eth",
-       "diagup", "diagdown", ""
-};
-
-int const nr_latex_ams_misc = sizeof(latex_ams_misc) / sizeof(char const *);
-
-char const * latex_ams_arrows[] = {
-       "dashleftarrow", "dashrightarrow", 
-       "leftleftarrows", "leftrightarrows",
-       "rightrightarrows", "rightleftarrows",
-       "Lleftarrow", "Rrightarrow",
-       "twoheadleftarrow", "twoheadrightarrow",
-       "leftarrowtail", "rightarrowtail",
-       "looparrowleft", "looparrowright",
-       "curvearrowleft", "curvearrowright",
-       "circlearrowleft", "circlearrowright",
-       "Lsh", "Rsh",
-       "upuparrows", "downdownarrows",
-       "upharpoonleft", "upharpoonright",
-       "downharpoonleft", "downharpoonright",
-       "leftrightharpoons", "rightleftharpoons",
-       "rightsquigarrow", "leftrightsquigarrow",
-       "nleftarrow", "nrightarrow", "nleftrightarrow",
-       "nLeftarrow", "nRightarrow", "nLeftrightarrow",
-       "multimap",
-       ""
-};
-
-int const nr_latex_ams_arrows = sizeof(latex_ams_arrows) / sizeof(char const *);
-
-char const * latex_ams_rel[] = {
-       "leqq", "geqq",
-       "leqslant", "geqslant",
-       "eqslantless", "eqslantgtr",
-       "lesssim", "gtrsim", 
-       "lessapprox", "gtrapprox",
-       "approxeq", "triangleq",
-       "lessdot", "gtrdot",
-       "lll", "ggg",
-       "lessgtr", "gtrless",
-       "lesseqgtr", "gtreqless",
-       "lesseqqgtr", "gtreqqless",
-       "eqcirc", "circeq",
-       "thicksim", "thickapprox",
-       "backsim", "backsimeq",
-       "subseteqq", "supseteqq",
-       "Subset", "Supset", 
-       "sqsubset", "sqsupset",
-       "preccurlyeq", "succcurlyeq", 
-       "curlyeqprec", "curlyeqsucc", 
-       "precsim", "succsim", 
-       "precapprox", "succapprox", 
-       "vartriangleleft", "vartriangleright", 
-       "trianglelefteq", "trianglerighteq",
-       "bumpeq", "Bumpeq", 
-       "doteqdot", "risingdotseq", "fallingdotseq",
-       "vDash", "Vvdash", "Vdash",
-       "shortmid", "shortparallel",    
-       "smallsmile", "smallfrown",
-       "blacktriangleleft", "blacktriangleright",
-       "because", "therefore", 
-       "backepsilon",
-       "varpropto",
-       "between",
-       "pitchfork",
-       ""
-};
-
-int const nr_latex_ams_rel = sizeof(latex_ams_rel) / sizeof(char const *);
-
-char const * latex_ams_nrel[] = {
-       "nless", "ngtr",
-       "nleq", "ngeq",
-       "nleqslant", "ngeqslant",
-       "nleqq", "ngeqq",
-       "lneq", "gneq",
-       "lneqq", "gneqq",
-       "lvertneqq", "gvertneqq",
-       "lnsim", "gnsim",
-       "lnapprox", "gnapprox",
-       "nprec", "nsucc",
-       "npreceq", "nsucceq",
-       "precnsim", "succnsim",
-       "precnapprox", "succnapprox",
-       "subsetneq", "supsetneq",
-       "subsetneqq", "supsetneqq",
-       "nsubseteq", "nsupseteq", "nsupseteqq",
-       "nvdash", "nvDash", "nVDash",
-       "varsubsetneq", "varsupsetneq",
-       "varsubsetneqq", "varsupsetneqq",
-       "ntriangleleft", "ntriangleright",
-       "ntrianglelefteq", "ntrianglerighteq",
-       "ncong", "nsim",
-       "nmid", "nshortmid",
-       "nparallel", "nshortparallel",
-       "", "", ""
-};
-
-int const nr_latex_ams_nrel = sizeof(latex_ams_nrel) / sizeof(char const *);
-
-
-char const * latex_ams_ops[] = {
-       "dotplus", "smallsetminus", "Cap",
-       "Cup", "barwedge", "veebar",
-       "doublebarwedge", "boxminus", "boxtimes",
-       "boxdot", "boxplus", "divideontimes",
-       "ltimes", "rtimes", "leftthreetimes",
-       "rightthreetimes", "curlywedge", "curlyvee",
-       "circleddash", "circledast", "circledcirc",
-       "centerdot", "intercal", ""
-};
-
-int const nr_latex_ams_ops = sizeof(latex_ams_ops) / sizeof(char const *);
-
-
-char const *  latex_delimiters[] = {
-       "(", ")", "{", "}", "[", "]",
-       "lceil", "rceil", "lfloor", "rfloor", "langle", "rangle",
-       "uparrow", "updownarrow", "Uparrow", "Updownarrow", "downarrow", "Downarrow",
-       "|", "Vert", "/", "backslash", ""
-};
-
-
-int const nr_latex_delimiters = sizeof(latex_delimiters) / sizeof(char const *);
-
-namespace {
-
-struct XPMmap {
-       char const * key;
-       char const * value;
-};
-
-
-bool operator<(XPMmap const & lhs, XPMmap const & rhs)
-{
-               return compare(lhs.key, rhs.key) < 0;
-}
-
-
-class CompareKey : public std::unary_function<XPMmap, bool> {
-public:
-       CompareKey(string const & name) : name_(name) {}
-       bool operator()(XPMmap const & other) const {
-               return other.key == name_;
-       }
-private:
-       string const name_;
-};
-
-
-XPMmap sorted_xpm_map[] = {
-       { "Bumpeq", "bumpeq2" },
-       { "Cap", "cap2" },
-       { "Cup", "cup2" },
-       { "Delta", "delta2" },
-       { "Downarrow", "downarrow2" },
-       { "Gamma", "gamma2" },
-       { "Lambda", "lambda2" },
-       { "Leftarrow", "leftarrow2" },
-       { "Leftrightarrow", "leftrightarrow2" },
-       { "Longleftarrow", "longleftarrow2" },
-       { "Longleftrightarrow", "longleftrightarrow2" },
-       { "Longrightarrow", "longrightarrow2" },
-       { "Omega", "omega2" },
-       { "Phi", "phi2" },
-       { "Pi", "pi2" },
-       { "Psi", "psi2" },
-       { "Rightarrow", "rightarrow2" },
-       { "Sigma", "sigma2" },
-       { "Subset", "subset2" },
-       { "Supset", "supset2" },
-       { "Theta", "theta2" },
-       { "Uparrow", "uparrow2" },
-       { "Updownarrow", "updownarrow2" },
-       { "Upsilon", "upsilon2" },
-       { "Vdash", "vdash3" },
-       { "Xi", "xi2" },
-       { "nLeftarrow", "nleftarrow2" },
-       { "nLeftrightarrow", "nleftrightarrow2" },
-       { "nRightarrow", "nrightarrow2" },
-       { "nVDash", "nvdash3" },
-       { "nvDash", "nvdash2" },
-       { "textrm \\AA", "textrm_AA"},
-       { "textrm \\O", "textrm_Oe"},
-       { "vDash", "vdash2" }
-};
-
-size_t const nr_sorted_xpm_map = sizeof(sorted_xpm_map) / sizeof(XPMmap);
-
-} // namespace anon
-
-
-string const find_xpm(string const & name)
-{
-       XPMmap const * const begin = sorted_xpm_map;
-       XPMmap const * const end = begin + nr_sorted_xpm_map;
-       BOOST_ASSERT(sorted(begin, end));
-
-       XPMmap const * const it =
-               std::find_if(begin, end, CompareKey(name));
-
-       string xpm_name;
-       if (it != end)
-               xpm_name = it->value;
-       else {
-               xpm_name = subst(name, "_", "underscore");
-               xpm_name = subst(xpm_name, ' ', '_');
-
-               // This way we can have "math-delim { }" on the toolbar.
-               xpm_name = subst(xpm_name, "(", "lparen");
-               xpm_name = subst(xpm_name, ")", "rparen");
-               xpm_name = subst(xpm_name, "[", "lbracket");
-               xpm_name = subst(xpm_name, "]", "rbracket");
-               xpm_name = subst(xpm_name, "{", "lbrace");
-               xpm_name = subst(xpm_name, "}", "rbrace");
-               xpm_name = subst(xpm_name, "|", "bars");
-       }
-
-       LYXERR(Debug::GUI) << "find_xpm(" << name << ")\n"
-                          << "Looking for math XPM called \""
-                          << xpm_name << '"' << std::endl;
-
-       return libFileSearch("images/math/", xpm_name, "xpm").absFilename();
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlMath.cpp b/src/frontends/controllers/ControlMath.cpp
new file mode 100644 (file)
index 0000000..d30562c
--- /dev/null
@@ -0,0 +1,517 @@
+/**
+ * \file ControlMath.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlMath.h"
+#include "debug.h"
+#include "funcrequest.h"
+
+#include "support/lyxalgo.h" // sorted
+#include "support/lstrings.h"
+#include "support/filetools.h"
+
+#include <functional>
+
+using std::string;
+using std::map;
+
+namespace lyx {
+
+using support::compare;
+using support::libFileSearch;
+using support::subst;
+
+namespace frontend {
+
+ControlMath::ControlMath(Dialog & dialog)
+       : Dialog::Controller(dialog)
+{
+       // FIXME: Ideally, those unicode codepoints would be defined
+       // in "lib/symbols". Unfortunately, some of those are already 
+       // defined with non-unicode ids for use within mathed.
+       // FIXME 2: We should fill-in this map with the parsed "symbols"
+       // file done in MathFactory.cpp.
+       math_symbols_["("] = MathSymbol('(');
+       math_symbols_[")"] = MathSymbol(')');
+       math_symbols_["{"] = MathSymbol('{');
+       math_symbols_["}"] = MathSymbol('}');
+       math_symbols_["["] = MathSymbol('[');
+       math_symbols_["]"] = MathSymbol(']');
+       math_symbols_["|"] = MathSymbol('|');
+       math_symbols_["/"] = MathSymbol('/', 54, LyXFont::CMSY_FAMILY);
+       math_symbols_["backslash"] = MathSymbol('\\', 110, LyXFont::CMSY_FAMILY);
+       math_symbols_["lceil"] = MathSymbol(0x2308, 100, LyXFont::CMSY_FAMILY);
+       math_symbols_["rceil"] = MathSymbol(0x2309, 101, LyXFont::CMSY_FAMILY);
+       math_symbols_["lfloor"] = MathSymbol(0x230A, 98, LyXFont::CMSY_FAMILY);
+       math_symbols_["rfloor"] = MathSymbol(0x230B, 99, LyXFont::CMSY_FAMILY);
+       math_symbols_["langle"] = MathSymbol(0x2329, 104, LyXFont::CMSY_FAMILY);
+       math_symbols_["rangle"] = MathSymbol(0x232A, 105, LyXFont::CMSY_FAMILY);
+       math_symbols_["uparrow"] = MathSymbol(0x2191, 34, LyXFont::CMSY_FAMILY);
+       math_symbols_["Uparrow"] = MathSymbol(0x21D1, 42, LyXFont::CMSY_FAMILY);
+       math_symbols_["updownarrow"] = MathSymbol(0x2195, 108, LyXFont::CMSY_FAMILY);
+       math_symbols_["Updownarrow"] = MathSymbol(0x21D5, 109, LyXFont::CMSY_FAMILY);
+       math_symbols_["downarrow"] = MathSymbol(0x2193, 35, LyXFont::CMSY_FAMILY);
+       math_symbols_["Downarrow"] = MathSymbol(0x21D3, 43, LyXFont::CMSY_FAMILY);
+       math_symbols_["downdownarrows"] = MathSymbol(0x21CA, 184, LyXFont::MSA_FAMILY);
+       math_symbols_["downharpoonleft"] = MathSymbol(0x21C3, 188, LyXFont::MSA_FAMILY);
+       math_symbols_["downharpoonright"] = MathSymbol(0x21C2, 186, LyXFont::MSA_FAMILY);
+       math_symbols_["vert"] = MathSymbol(0x007C, 106, LyXFont::CMSY_FAMILY);
+       math_symbols_["Vert"] = MathSymbol(0x2016, 107, LyXFont::CMSY_FAMILY);
+
+       std::map<string, MathSymbol>::const_iterator it = math_symbols_.begin();
+       std::map<string, MathSymbol>::const_iterator end = math_symbols_.end();
+       for (; it != end; ++it)
+               tex_names_[it->second.unicode] = it->first;
+}
+
+
+void ControlMath::dispatchFunc(kb_action action, string const & arg) const
+{
+       kernel().dispatch(FuncRequest(action, arg));
+}
+
+
+void ControlMath::dispatchInsert(string const & name) const
+{
+       dispatchFunc(LFUN_MATH_INSERT, '\\' + name);
+}
+
+
+void ControlMath::dispatchSubscript() const
+{
+       dispatchFunc(LFUN_MATH_INSERT, "_");
+}
+
+
+void ControlMath::dispatchSuperscript() const
+{
+       dispatchFunc(LFUN_MATH_INSERT, "^");
+}
+
+
+void ControlMath::dispatchCubeRoot() const
+{
+       dispatchFunc(LFUN_MATH_INSERT, "\\root");
+       dispatchFunc(LFUN_SELF_INSERT, "3");
+       dispatchFunc(LFUN_CHAR_FORWARD);
+}
+
+
+void ControlMath::dispatchMatrix(string const & str) const
+{
+       dispatchFunc(LFUN_MATH_MATRIX, str);
+}
+
+
+void ControlMath::dispatchDelim(string const & str) const
+{
+       dispatchFunc(LFUN_MATH_DELIM, str);
+}
+
+
+void ControlMath::dispatchBigDelim(string const & str) const
+{
+       dispatchFunc(LFUN_MATH_BIGDELIM, str);
+}
+
+
+void ControlMath::dispatchToggleDisplay() const
+{
+       dispatchFunc(LFUN_MATH_DISPLAY);
+}
+
+
+void ControlMath::showDialog(string const & name) const
+{
+       dispatchFunc(LFUN_DIALOG_SHOW, name);
+}
+
+
+MathSymbol const & ControlMath::mathSymbol(string tex_name) const
+{
+       map<string, MathSymbol>::const_iterator it =
+               math_symbols_.find(tex_name);
+       
+       static MathSymbol unknown_symbol;
+       if (it == math_symbols_.end())
+               return unknown_symbol;
+       
+       return it->second;
+}
+
+
+std::string const & ControlMath::texName(char_type math_symbol) const
+{
+       map<char_type, string>::const_iterator it =
+               tex_names_.find(math_symbol);
+       
+       static string empty_string;
+       if (it == tex_names_.end())
+               return empty_string;
+       
+       return it->second;
+}
+
+
+char const * function_names[] = {
+       "arccos", "arcsin", "arctan", "arg", "bmod",
+       "cos", "cosh", "cot", "coth", "csc", "deg",
+       "det", "dim", "exp", "gcd", "hom", "inf", "ker",
+       "lg", "lim", "liminf", "limsup", "ln", "log",
+       "max", "min", "sec", "sin", "sinh", "sup",
+       "tan", "tanh", "Pr", ""
+};
+
+int const nr_function_names = sizeof(function_names) / sizeof(char const *) - 1;
+
+char const * latex_dots[] = {
+       "ldots", "cdots", "vdots", "ddots", ""
+};
+
+int const nr_latex_dots = sizeof(latex_dots) / sizeof(char const *) - 1;
+
+char const * latex_deco[] = {
+       "widehat", "widetilde", "overbrace", "overleftarrow", "overrightarrow",
+       "overline", "underbrace", "underline", "underleftarrow", "underrightarrow",
+       "underleftrightarrow", "overleftrightarrow",
+       "hat", "acute", "bar", "dot",
+       "check", "grave", "vec", "ddot",
+       "breve", "tilde", "overset", "underset", ""
+};
+
+int const nr_latex_deco = sizeof(latex_deco) / sizeof(char const *) - 1;
+
+char const * latex_arrow[] = {
+       "leftarrow", "rightarrow",
+       "downarrow", "uparrow", "updownarrow", "leftrightarrow",
+       "Leftarrow", "Rightarrow",
+       "Downarrow", "Uparrow", "Updownarrow", "Leftrightarrow",
+       "Longleftrightarrow", "Longleftarrow", "Longrightarrow",
+       "longleftrightarrow", "longleftarrow", "longrightarrow",
+       "leftharpoondown", "rightharpoondown", 
+       "mapsto", "longmapsto",
+       "nwarrow", "nearrow",
+       "leftharpoonup", "rightharpoonup",      
+       "hookleftarrow", "hookrightarrow",
+       "swarrow", "searrow",
+       "rightleftharpoons",
+       "",
+};
+
+int const nr_latex_arrow = sizeof(latex_arrow) / sizeof(char const *);
+
+char const * latex_bop[] = {
+       "pm", "cap", "diamond", "oplus",
+       "mp", "cup", "bigtriangleup", "ominus",
+       "times", "uplus", "bigtriangledown", "otimes",
+       "div", "sqcap", "triangleright", "oslash",
+       "cdot", "sqcup", "triangleleft", "odot",
+       "star", "vee", "amalg", "bigcirc",
+       "setminus", "wedge", "dagger", "circ",
+       "bullet", "wr", "ddagger", ""
+};
+
+int const nr_latex_bop = sizeof(latex_bop) / sizeof(char const *);
+
+char const * latex_brel[] = {
+       "leq", "geq", "equiv", "models",
+       "prec", "succ", "sim", "perp",
+       "preceq", "succeq", "simeq", "mid",
+       "ll", "gg", "asymp", "parallel",
+       "subset", "supset", "approx", "smile",
+       "subseteq", "supseteq", "cong", "frown",
+       "sqsubseteq", "sqsupseteq", "doteq", "neq",
+       "in", "ni", "propto", "notin",
+       "vdash", "dashv", "bowtie", ""
+};
+
+int const nr_latex_brel = sizeof(latex_brel) / sizeof(char const *);
+
+char const * latex_greek[] = {
+       "Gamma", "Delta", "Theta", "Lambda", "Xi", "Pi",
+       "Sigma", "Upsilon", "Phi", "Psi", "Omega",
+       "alpha", "beta", "gamma", "delta", "epsilon", "varepsilon", "zeta",
+       "eta", "theta", "vartheta", "iota", "kappa", "lambda", "mu",
+       "nu", "xi", "pi", "varpi", "rho", "sigma", "varsigma",
+       "tau", "upsilon", "phi", "varphi", "chi", "psi", "omega", ""
+};
+
+int const nr_latex_greek = sizeof(latex_greek) / sizeof(char const *);
+
+char const * latex_misc[] = {
+       "nabla", "partial", "infty", "prime", "ell",
+       "emptyset", "exists", "forall", "imath",  "jmath",
+       "Re", "Im", "aleph", "wp", "hbar",
+       "angle", "top", "bot", "Vert", "neg",
+       "flat", "natural", "sharp", "surd", "triangle",
+       "diamondsuit", "heartsuit", "clubsuit", "spadesuit",
+       "textrm \\AA", "textrm \\O", "mathcircumflex", "_",
+       "mathrm T",
+       "mathbb N", "mathbb Z", "mathbb Q",
+       "mathbb R", "mathbb C", "mathbb H",
+       "mathcal F", "mathcal L",
+       "mathcal H", "mathcal O",
+       "phantom", "vphantom", "hphantom", ""
+};
+
+int const nr_latex_misc = sizeof(latex_misc) / sizeof(char const *);
+
+char const * latex_varsz[] = {
+       "sum", "int", "intop", "iint", "iintop", "iiint", "iiintop",
+       "iiiint", "iiiintop", "dotsint", "dotsintop",
+       "oint", "ointop", "oiint", "oiintop", "ointctrclockwise",
+       "ointctrclockwiseop", "ointclockwise", "ointclockwiseop",
+       "sqint", "sqintop", "sqiint", "sqiintop",
+       "prod", "coprod", "bigsqcup",
+       "bigotimes", "bigodot", "bigoplus",
+       "bigcap", "bigcup", "biguplus",
+       "bigvee", "bigwedge", ""
+};
+
+int const nr_latex_varsz = sizeof(latex_varsz) / sizeof(char const *);
+
+char const * latex_ams_misc[] = {
+       "digamma", "varkappa", "beth", "daleth", "gimel",
+       "ulcorner", "urcorner", "llcorner", "lrcorner",
+       "hbar", "hslash", "vartriangle",
+       "triangledown", "square", "lozenge",
+       "circledS", "angle", "measuredangle",
+       "nexists", "mho", "Finv",
+       "Game", "Bbbk", "backprime",
+       "varnothing", "blacktriangle", "blacktriangledown",
+       "blacksquare", "blacklozenge", "bigstar",
+       "sphericalangle", "complement", "eth",
+       "diagup", "diagdown", ""
+};
+
+int const nr_latex_ams_misc = sizeof(latex_ams_misc) / sizeof(char const *);
+
+char const * latex_ams_arrows[] = {
+       "dashleftarrow", "dashrightarrow", 
+       "leftleftarrows", "leftrightarrows",
+       "rightrightarrows", "rightleftarrows",
+       "Lleftarrow", "Rrightarrow",
+       "twoheadleftarrow", "twoheadrightarrow",
+       "leftarrowtail", "rightarrowtail",
+       "looparrowleft", "looparrowright",
+       "curvearrowleft", "curvearrowright",
+       "circlearrowleft", "circlearrowright",
+       "Lsh", "Rsh",
+       "upuparrows", "downdownarrows",
+       "upharpoonleft", "upharpoonright",
+       "downharpoonleft", "downharpoonright",
+       "leftrightharpoons", "rightleftharpoons",
+       "rightsquigarrow", "leftrightsquigarrow",
+       "nleftarrow", "nrightarrow", "nleftrightarrow",
+       "nLeftarrow", "nRightarrow", "nLeftrightarrow",
+       "multimap",
+       ""
+};
+
+int const nr_latex_ams_arrows = sizeof(latex_ams_arrows) / sizeof(char const *);
+
+char const * latex_ams_rel[] = {
+       "leqq", "geqq",
+       "leqslant", "geqslant",
+       "eqslantless", "eqslantgtr",
+       "lesssim", "gtrsim", 
+       "lessapprox", "gtrapprox",
+       "approxeq", "triangleq",
+       "lessdot", "gtrdot",
+       "lll", "ggg",
+       "lessgtr", "gtrless",
+       "lesseqgtr", "gtreqless",
+       "lesseqqgtr", "gtreqqless",
+       "eqcirc", "circeq",
+       "thicksim", "thickapprox",
+       "backsim", "backsimeq",
+       "subseteqq", "supseteqq",
+       "Subset", "Supset", 
+       "sqsubset", "sqsupset",
+       "preccurlyeq", "succcurlyeq", 
+       "curlyeqprec", "curlyeqsucc", 
+       "precsim", "succsim", 
+       "precapprox", "succapprox", 
+       "vartriangleleft", "vartriangleright", 
+       "trianglelefteq", "trianglerighteq",
+       "bumpeq", "Bumpeq", 
+       "doteqdot", "risingdotseq", "fallingdotseq",
+       "vDash", "Vvdash", "Vdash",
+       "shortmid", "shortparallel",    
+       "smallsmile", "smallfrown",
+       "blacktriangleleft", "blacktriangleright",
+       "because", "therefore", 
+       "backepsilon",
+       "varpropto",
+       "between",
+       "pitchfork",
+       ""
+};
+
+int const nr_latex_ams_rel = sizeof(latex_ams_rel) / sizeof(char const *);
+
+char const * latex_ams_nrel[] = {
+       "nless", "ngtr",
+       "nleq", "ngeq",
+       "nleqslant", "ngeqslant",
+       "nleqq", "ngeqq",
+       "lneq", "gneq",
+       "lneqq", "gneqq",
+       "lvertneqq", "gvertneqq",
+       "lnsim", "gnsim",
+       "lnapprox", "gnapprox",
+       "nprec", "nsucc",
+       "npreceq", "nsucceq",
+       "precnsim", "succnsim",
+       "precnapprox", "succnapprox",
+       "subsetneq", "supsetneq",
+       "subsetneqq", "supsetneqq",
+       "nsubseteq", "nsupseteq", "nsupseteqq",
+       "nvdash", "nvDash", "nVDash",
+       "varsubsetneq", "varsupsetneq",
+       "varsubsetneqq", "varsupsetneqq",
+       "ntriangleleft", "ntriangleright",
+       "ntrianglelefteq", "ntrianglerighteq",
+       "ncong", "nsim",
+       "nmid", "nshortmid",
+       "nparallel", "nshortparallel",
+       "", "", ""
+};
+
+int const nr_latex_ams_nrel = sizeof(latex_ams_nrel) / sizeof(char const *);
+
+
+char const * latex_ams_ops[] = {
+       "dotplus", "smallsetminus", "Cap",
+       "Cup", "barwedge", "veebar",
+       "doublebarwedge", "boxminus", "boxtimes",
+       "boxdot", "boxplus", "divideontimes",
+       "ltimes", "rtimes", "leftthreetimes",
+       "rightthreetimes", "curlywedge", "curlyvee",
+       "circleddash", "circledast", "circledcirc",
+       "centerdot", "intercal", ""
+};
+
+int const nr_latex_ams_ops = sizeof(latex_ams_ops) / sizeof(char const *);
+
+
+char const *  latex_delimiters[] = {
+       "(", ")", "{", "}", "[", "]",
+       "lceil", "rceil", "lfloor", "rfloor", "langle", "rangle",
+       "uparrow", "updownarrow", "Uparrow", "Updownarrow", "downarrow", "Downarrow",
+       "|", "Vert", "/", "backslash", ""
+};
+
+
+int const nr_latex_delimiters = sizeof(latex_delimiters) / sizeof(char const *);
+
+namespace {
+
+struct XPMmap {
+       char const * key;
+       char const * value;
+};
+
+
+bool operator<(XPMmap const & lhs, XPMmap const & rhs)
+{
+               return compare(lhs.key, rhs.key) < 0;
+}
+
+
+class CompareKey : public std::unary_function<XPMmap, bool> {
+public:
+       CompareKey(string const & name) : name_(name) {}
+       bool operator()(XPMmap const & other) const {
+               return other.key == name_;
+       }
+private:
+       string const name_;
+};
+
+
+XPMmap sorted_xpm_map[] = {
+       { "Bumpeq", "bumpeq2" },
+       { "Cap", "cap2" },
+       { "Cup", "cup2" },
+       { "Delta", "delta2" },
+       { "Downarrow", "downarrow2" },
+       { "Gamma", "gamma2" },
+       { "Lambda", "lambda2" },
+       { "Leftarrow", "leftarrow2" },
+       { "Leftrightarrow", "leftrightarrow2" },
+       { "Longleftarrow", "longleftarrow2" },
+       { "Longleftrightarrow", "longleftrightarrow2" },
+       { "Longrightarrow", "longrightarrow2" },
+       { "Omega", "omega2" },
+       { "Phi", "phi2" },
+       { "Pi", "pi2" },
+       { "Psi", "psi2" },
+       { "Rightarrow", "rightarrow2" },
+       { "Sigma", "sigma2" },
+       { "Subset", "subset2" },
+       { "Supset", "supset2" },
+       { "Theta", "theta2" },
+       { "Uparrow", "uparrow2" },
+       { "Updownarrow", "updownarrow2" },
+       { "Upsilon", "upsilon2" },
+       { "Vdash", "vdash3" },
+       { "Xi", "xi2" },
+       { "nLeftarrow", "nleftarrow2" },
+       { "nLeftrightarrow", "nleftrightarrow2" },
+       { "nRightarrow", "nrightarrow2" },
+       { "nVDash", "nvdash3" },
+       { "nvDash", "nvdash2" },
+       { "textrm \\AA", "textrm_AA"},
+       { "textrm \\O", "textrm_Oe"},
+       { "vDash", "vdash2" }
+};
+
+size_t const nr_sorted_xpm_map = sizeof(sorted_xpm_map) / sizeof(XPMmap);
+
+} // namespace anon
+
+
+string const find_xpm(string const & name)
+{
+       XPMmap const * const begin = sorted_xpm_map;
+       XPMmap const * const end = begin + nr_sorted_xpm_map;
+       BOOST_ASSERT(sorted(begin, end));
+
+       XPMmap const * const it =
+               std::find_if(begin, end, CompareKey(name));
+
+       string xpm_name;
+       if (it != end)
+               xpm_name = it->value;
+       else {
+               xpm_name = subst(name, "_", "underscore");
+               xpm_name = subst(xpm_name, ' ', '_');
+
+               // This way we can have "math-delim { }" on the toolbar.
+               xpm_name = subst(xpm_name, "(", "lparen");
+               xpm_name = subst(xpm_name, ")", "rparen");
+               xpm_name = subst(xpm_name, "[", "lbracket");
+               xpm_name = subst(xpm_name, "]", "rbracket");
+               xpm_name = subst(xpm_name, "{", "lbrace");
+               xpm_name = subst(xpm_name, "}", "rbrace");
+               xpm_name = subst(xpm_name, "|", "bars");
+       }
+
+       LYXERR(Debug::GUI) << "find_xpm(" << name << ")\n"
+                          << "Looking for math XPM called \""
+                          << xpm_name << '"' << std::endl;
+
+       return libFileSearch("images/math/", xpm_name, "xpm").absFilename();
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlNote.C b/src/frontends/controllers/ControlNote.C
deleted file mode 100644 (file)
index c7969e0..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * \file ControlNote.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlNote.h"
-#include "funcrequest.h"
-#include "insets/InsetNote.h"
-#include "gettext.h"
-
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-ControlNote::ControlNote(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-bool ControlNote::initialiseParams(string const & data)
-{
-       InsetNoteParams params;
-       InsetNoteMailer::string2params(data, params);
-       params_.reset(new InsetNoteParams(params));
-       return true;
-}
-
-
-void ControlNote::clearParams()
-{
-       params_.reset();
-}
-
-
-void ControlNote::dispatchParams()
-{
-       string const lfun = InsetNoteMailer::params2string(params());
-       kernel().dispatch(FuncRequest(getLfun(), lfun));
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlNote.cpp b/src/frontends/controllers/ControlNote.cpp
new file mode 100644 (file)
index 0000000..c7969e0
--- /dev/null
@@ -0,0 +1,51 @@
+/**
+ * \file ControlNote.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlNote.h"
+#include "funcrequest.h"
+#include "insets/InsetNote.h"
+#include "gettext.h"
+
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+ControlNote::ControlNote(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+bool ControlNote::initialiseParams(string const & data)
+{
+       InsetNoteParams params;
+       InsetNoteMailer::string2params(data, params);
+       params_.reset(new InsetNoteParams(params));
+       return true;
+}
+
+
+void ControlNote::clearParams()
+{
+       params_.reset();
+}
+
+
+void ControlNote::dispatchParams()
+{
+       string const lfun = InsetNoteMailer::params2string(params());
+       kernel().dispatch(FuncRequest(getLfun(), lfun));
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlParagraph.C b/src/frontends/controllers/ControlParagraph.C
deleted file mode 100644 (file)
index 79c9bef..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-/**
- * \file ControlParagraph.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlParagraph.h"
-#include "ButtonController.h"
-#include "funcrequest.h"
-#include "lyxlex.h"
-#include "paragraph.h"
-#include "ParagraphParameters.h"
-
-#include <sstream>
-
-using std::istringstream;
-using std::ostringstream;
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-ControlParagraph::ControlParagraph(Dialog & parent)
-       : Dialog::Controller(parent), ininset_(false)
-{}
-
-
-bool ControlParagraph::initialiseParams(string const & data)
-{
-       istringstream is(data);
-       LyXLex lex(0,0);
-       lex.setStream(is);
-
-       // Set tri-state flag:
-       // action == 0: show dialog
-       // action == 1: update dialog, accept changes
-       // action == 2: update dialog, do not accept changes
-       int action = 0;
-
-       if (lex.isOK()) {
-               lex.next();
-               string const token = lex.getString();
-
-               if (token == "show") {
-                       action = 0;
-               } else if (token == "update") {
-                       lex.next();
-                       bool const accept = lex.getBool();
-                       if (lex) {
-                               action = accept ? 1 : 2;
-                       } else {
-                               // Unrecognised update option
-                               return false;
-                       }
-               } else if (!token.empty()) {
-                       // Unrecognised token
-                       return false;
-               }
-       }
-
-       ParagraphParameters * tmp = new ParagraphParameters;
-       tmp->read(lex);
-
-       // For now, only reset the params on "show".
-       // Don't bother checking if the params are different on "update"
-       if (action == 0) {
-               params_.reset(tmp);
-       } else {
-               delete tmp;
-       }
-
-       // Read the rest of the data irrespective of "show" or "update"
-       int nset = 0;
-       while (lex.isOK()) {
-               lex.next();
-               string const token = lex.getString();
-
-               if (token.empty())
-                       continue;
-
-               int Int = 0;
-               if (token == "\\alignpossible" ||
-                   token == "\\aligndefault" ||
-                   token == "\\ininset") {
-                       lex.next();
-                       Int = lex.getInteger();
-               } else {
-                       // Unrecognised token
-                       return false;
-               }
-
-               ++nset;
-
-               if (token == "\\alignpossible") {
-                       alignpossible_ = static_cast<LyXAlignment>(Int);
-               } else if (token == "\\aligndefault") {
-                       aligndefault_ = static_cast<LyXAlignment>(Int);
-               } else {
-                       ininset_ = Int;
-               }
-       }
-       if (nset != 3) {
-               return false;
-       }
-
-       // If "update", then set the activation status of the button controller
-       if (action > 0) {
-               bool const accept = action == 1;
-               dialog().bc().valid(accept);
-       }
-       return true;
-}
-
-
-void ControlParagraph::clearParams()
-{
-       params_.reset();
-}
-
-
-void ControlParagraph::dispatchParams()
-{
-       ostringstream data;
-       params().write(data);
-       FuncRequest const fr(LFUN_PARAGRAPH_PARAMS_APPLY, data.str());
-       kernel().dispatch(fr);
-}
-
-
-ParagraphParameters & ControlParagraph::params()
-{
-       BOOST_ASSERT(params_.get());
-       return *params_;
-}
-
-
-ParagraphParameters const & ControlParagraph::params() const
-{
-       BOOST_ASSERT(params_.get());
-       return *params_;
-}
-
-
-bool ControlParagraph::inInset() const
-{
-       return ininset_;
-}
-
-
-LyXAlignment ControlParagraph::alignPossible() const
-{
-       return alignpossible_;
-}
-
-
-LyXAlignment ControlParagraph::alignDefault() const
-{
-       return aligndefault_;
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlParagraph.cpp b/src/frontends/controllers/ControlParagraph.cpp
new file mode 100644 (file)
index 0000000..79c9bef
--- /dev/null
@@ -0,0 +1,169 @@
+/**
+ * \file ControlParagraph.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlParagraph.h"
+#include "ButtonController.h"
+#include "funcrequest.h"
+#include "lyxlex.h"
+#include "paragraph.h"
+#include "ParagraphParameters.h"
+
+#include <sstream>
+
+using std::istringstream;
+using std::ostringstream;
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+ControlParagraph::ControlParagraph(Dialog & parent)
+       : Dialog::Controller(parent), ininset_(false)
+{}
+
+
+bool ControlParagraph::initialiseParams(string const & data)
+{
+       istringstream is(data);
+       LyXLex lex(0,0);
+       lex.setStream(is);
+
+       // Set tri-state flag:
+       // action == 0: show dialog
+       // action == 1: update dialog, accept changes
+       // action == 2: update dialog, do not accept changes
+       int action = 0;
+
+       if (lex.isOK()) {
+               lex.next();
+               string const token = lex.getString();
+
+               if (token == "show") {
+                       action = 0;
+               } else if (token == "update") {
+                       lex.next();
+                       bool const accept = lex.getBool();
+                       if (lex) {
+                               action = accept ? 1 : 2;
+                       } else {
+                               // Unrecognised update option
+                               return false;
+                       }
+               } else if (!token.empty()) {
+                       // Unrecognised token
+                       return false;
+               }
+       }
+
+       ParagraphParameters * tmp = new ParagraphParameters;
+       tmp->read(lex);
+
+       // For now, only reset the params on "show".
+       // Don't bother checking if the params are different on "update"
+       if (action == 0) {
+               params_.reset(tmp);
+       } else {
+               delete tmp;
+       }
+
+       // Read the rest of the data irrespective of "show" or "update"
+       int nset = 0;
+       while (lex.isOK()) {
+               lex.next();
+               string const token = lex.getString();
+
+               if (token.empty())
+                       continue;
+
+               int Int = 0;
+               if (token == "\\alignpossible" ||
+                   token == "\\aligndefault" ||
+                   token == "\\ininset") {
+                       lex.next();
+                       Int = lex.getInteger();
+               } else {
+                       // Unrecognised token
+                       return false;
+               }
+
+               ++nset;
+
+               if (token == "\\alignpossible") {
+                       alignpossible_ = static_cast<LyXAlignment>(Int);
+               } else if (token == "\\aligndefault") {
+                       aligndefault_ = static_cast<LyXAlignment>(Int);
+               } else {
+                       ininset_ = Int;
+               }
+       }
+       if (nset != 3) {
+               return false;
+       }
+
+       // If "update", then set the activation status of the button controller
+       if (action > 0) {
+               bool const accept = action == 1;
+               dialog().bc().valid(accept);
+       }
+       return true;
+}
+
+
+void ControlParagraph::clearParams()
+{
+       params_.reset();
+}
+
+
+void ControlParagraph::dispatchParams()
+{
+       ostringstream data;
+       params().write(data);
+       FuncRequest const fr(LFUN_PARAGRAPH_PARAMS_APPLY, data.str());
+       kernel().dispatch(fr);
+}
+
+
+ParagraphParameters & ControlParagraph::params()
+{
+       BOOST_ASSERT(params_.get());
+       return *params_;
+}
+
+
+ParagraphParameters const & ControlParagraph::params() const
+{
+       BOOST_ASSERT(params_.get());
+       return *params_;
+}
+
+
+bool ControlParagraph::inInset() const
+{
+       return ininset_;
+}
+
+
+LyXAlignment ControlParagraph::alignPossible() const
+{
+       return alignpossible_;
+}
+
+
+LyXAlignment ControlParagraph::alignDefault() const
+{
+       return aligndefault_;
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlPrefs.C b/src/frontends/controllers/ControlPrefs.C
deleted file mode 100644 (file)
index 73fb192..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-/**
- * \file ControlPrefs.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlPrefs.h"
-
-#include "frontend_helpers.h"
-#include "Kernel.h"
-
-#include "bufferlist.h"
-#include "gettext.h"
-#include "funcrequest.h"
-#include "paper.h"
-#include "LColor.h"
-
-#include "support/filefilterlist.h"
-
-#include <sstream>
-
-using std::ostringstream;
-using std::pair;
-using std::string;
-using std::vector;
-using lyx::support::FileFilterList;
-
-namespace lyx {
-
-namespace frontend {
-
-
-ControlPrefs::ControlPrefs(Dialog & parent)
-       : Dialog::Controller(parent),
-         update_screen_font_(false)
-{}
-
-
-bool ControlPrefs::initialiseParams(std::string const &)
-{
-       rc_ = lyxrc;
-       formats_ = lyx::formats;
-       converters_ = theConverters();
-       converters_.update(formats_);
-       movers_ = theMovers();
-       colors_.clear();
-       update_screen_font_ = false;
-
-       return true;
-}
-
-
-void ControlPrefs::dispatchParams()
-{
-       ostringstream ss;
-       rc_.write(ss, true);
-       kernel().dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
-
-       // FIXME: these need lfuns
-       // FIXME UNICODE
-       theBufferList().setCurrentAuthor(from_utf8(rc_.user_name), from_utf8(rc_.user_email));
-
-       lyx::formats = formats_;
-
-       theConverters() = converters_;
-       theConverters().update(lyx::formats);
-       theConverters().buildGraph();
-
-       theMovers() = movers_;
-
-       vector<string>::const_iterator it = colors_.begin();
-       vector<string>::const_iterator const end = colors_.end();
-       for (; it != end; ++it)
-               kernel().dispatch(FuncRequest(LFUN_SET_COLOR, *it));
-       colors_.clear();
-
-       if (update_screen_font_) {
-               kernel().dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
-               update_screen_font_ = false;
-       }
-
-       // The Save button has been pressed
-       if (dialog().isClosing()) {
-               kernel().dispatch(FuncRequest(LFUN_PREFERENCES_SAVE));
-       }
-}
-
-
-void ControlPrefs::setColor(LColor_color col, string const & hex)
-{
-       colors_.push_back(lcolor.getLyXName(col) + ' ' + hex);
-}
-
-
-void ControlPrefs::updateScreenFonts()
-{
-       update_screen_font_ = true;
-}
-
-
-docstring const ControlPrefs::browsebind(docstring const & file) const
-{
-       return browseLibFile(from_ascii("bind"), file, from_ascii("bind"),
-                            _("Choose bind file"),
-                            FileFilterList(_("LyX bind files (*.bind)")));
-}
-
-
-docstring const ControlPrefs::browseUI(docstring const & file) const
-{
-       return browseLibFile(from_ascii("ui"), file, from_ascii("ui"),
-                            _("Choose UI file"),
-                            FileFilterList(_("LyX UI files (*.ui)")));
-}
-
-
-docstring const ControlPrefs::browsekbmap(docstring const & file) const
-{
-       return browseLibFile(from_ascii("kbd"), file, from_ascii("kmap"),
-                            _("Choose keyboard map"),
-                            FileFilterList(_("LyX keyboard maps (*.kmap)")));
-}
-
-
-docstring const ControlPrefs::browsedict(docstring const & file) const
-{
-       if (lyxrc.use_spell_lib)
-               return browseFile(file,
-                                 _("Choose personal dictionary"),
-                                 FileFilterList(_("*.pws")));
-       else
-               return browseFile(file,
-                                 _("Choose personal dictionary"),
-                                 FileFilterList(_("*.ispell")));
-}
-
-
-docstring const ControlPrefs::browse(docstring const & file,
-                                 docstring const & title) const
-{
-       return browseFile(file, title, FileFilterList(), true);
-}
-
-
-docstring const ControlPrefs::browsedir(docstring const & path,
-                                    docstring const & title) const
-{
-       return browseDir(path, title);
-}
-
-
-// We support less paper sizes than the document dialog
-// Therefore this adjustment is needed.
-PAPER_SIZE const ControlPrefs::toPaperSize(int i) const
-{
-       switch (i) {
-       case 0:
-               return PAPER_DEFAULT;
-       case 1:
-               return PAPER_USLETTER;
-       case 2:
-               return PAPER_USLEGAL;
-       case 3:
-               return PAPER_USEXECUTIVE;
-       case 4:
-               return PAPER_A3;
-       case 5:
-               return PAPER_A4;
-       case 6:
-               return PAPER_A5;
-       case 7:
-               return PAPER_B5;
-       default:
-               // should not happen
-               return PAPER_DEFAULT;
-       }
-}
-
-
-int const ControlPrefs::fromPaperSize(PAPER_SIZE papersize) const
-{
-       switch (papersize) {
-       case PAPER_DEFAULT:
-               return 0;
-       case PAPER_USLETTER:
-               return 1;
-       case PAPER_USLEGAL:
-               return 2;
-       case PAPER_USEXECUTIVE:
-               return 3;
-       case PAPER_A3:
-               return 4;
-       case PAPER_A4:
-               return 5;
-       case PAPER_A5:
-               return 6;
-       case PAPER_B5:
-               return 7;
-       default:
-               // should not happen
-               return 0;
-       }
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlPrefs.cpp b/src/frontends/controllers/ControlPrefs.cpp
new file mode 100644 (file)
index 0000000..73fb192
--- /dev/null
@@ -0,0 +1,212 @@
+/**
+ * \file ControlPrefs.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlPrefs.h"
+
+#include "frontend_helpers.h"
+#include "Kernel.h"
+
+#include "bufferlist.h"
+#include "gettext.h"
+#include "funcrequest.h"
+#include "paper.h"
+#include "LColor.h"
+
+#include "support/filefilterlist.h"
+
+#include <sstream>
+
+using std::ostringstream;
+using std::pair;
+using std::string;
+using std::vector;
+using lyx::support::FileFilterList;
+
+namespace lyx {
+
+namespace frontend {
+
+
+ControlPrefs::ControlPrefs(Dialog & parent)
+       : Dialog::Controller(parent),
+         update_screen_font_(false)
+{}
+
+
+bool ControlPrefs::initialiseParams(std::string const &)
+{
+       rc_ = lyxrc;
+       formats_ = lyx::formats;
+       converters_ = theConverters();
+       converters_.update(formats_);
+       movers_ = theMovers();
+       colors_.clear();
+       update_screen_font_ = false;
+
+       return true;
+}
+
+
+void ControlPrefs::dispatchParams()
+{
+       ostringstream ss;
+       rc_.write(ss, true);
+       kernel().dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
+
+       // FIXME: these need lfuns
+       // FIXME UNICODE
+       theBufferList().setCurrentAuthor(from_utf8(rc_.user_name), from_utf8(rc_.user_email));
+
+       lyx::formats = formats_;
+
+       theConverters() = converters_;
+       theConverters().update(lyx::formats);
+       theConverters().buildGraph();
+
+       theMovers() = movers_;
+
+       vector<string>::const_iterator it = colors_.begin();
+       vector<string>::const_iterator const end = colors_.end();
+       for (; it != end; ++it)
+               kernel().dispatch(FuncRequest(LFUN_SET_COLOR, *it));
+       colors_.clear();
+
+       if (update_screen_font_) {
+               kernel().dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
+               update_screen_font_ = false;
+       }
+
+       // The Save button has been pressed
+       if (dialog().isClosing()) {
+               kernel().dispatch(FuncRequest(LFUN_PREFERENCES_SAVE));
+       }
+}
+
+
+void ControlPrefs::setColor(LColor_color col, string const & hex)
+{
+       colors_.push_back(lcolor.getLyXName(col) + ' ' + hex);
+}
+
+
+void ControlPrefs::updateScreenFonts()
+{
+       update_screen_font_ = true;
+}
+
+
+docstring const ControlPrefs::browsebind(docstring const & file) const
+{
+       return browseLibFile(from_ascii("bind"), file, from_ascii("bind"),
+                            _("Choose bind file"),
+                            FileFilterList(_("LyX bind files (*.bind)")));
+}
+
+
+docstring const ControlPrefs::browseUI(docstring const & file) const
+{
+       return browseLibFile(from_ascii("ui"), file, from_ascii("ui"),
+                            _("Choose UI file"),
+                            FileFilterList(_("LyX UI files (*.ui)")));
+}
+
+
+docstring const ControlPrefs::browsekbmap(docstring const & file) const
+{
+       return browseLibFile(from_ascii("kbd"), file, from_ascii("kmap"),
+                            _("Choose keyboard map"),
+                            FileFilterList(_("LyX keyboard maps (*.kmap)")));
+}
+
+
+docstring const ControlPrefs::browsedict(docstring const & file) const
+{
+       if (lyxrc.use_spell_lib)
+               return browseFile(file,
+                                 _("Choose personal dictionary"),
+                                 FileFilterList(_("*.pws")));
+       else
+               return browseFile(file,
+                                 _("Choose personal dictionary"),
+                                 FileFilterList(_("*.ispell")));
+}
+
+
+docstring const ControlPrefs::browse(docstring const & file,
+                                 docstring const & title) const
+{
+       return browseFile(file, title, FileFilterList(), true);
+}
+
+
+docstring const ControlPrefs::browsedir(docstring const & path,
+                                    docstring const & title) const
+{
+       return browseDir(path, title);
+}
+
+
+// We support less paper sizes than the document dialog
+// Therefore this adjustment is needed.
+PAPER_SIZE const ControlPrefs::toPaperSize(int i) const
+{
+       switch (i) {
+       case 0:
+               return PAPER_DEFAULT;
+       case 1:
+               return PAPER_USLETTER;
+       case 2:
+               return PAPER_USLEGAL;
+       case 3:
+               return PAPER_USEXECUTIVE;
+       case 4:
+               return PAPER_A3;
+       case 5:
+               return PAPER_A4;
+       case 6:
+               return PAPER_A5;
+       case 7:
+               return PAPER_B5;
+       default:
+               // should not happen
+               return PAPER_DEFAULT;
+       }
+}
+
+
+int const ControlPrefs::fromPaperSize(PAPER_SIZE papersize) const
+{
+       switch (papersize) {
+       case PAPER_DEFAULT:
+               return 0;
+       case PAPER_USLETTER:
+               return 1;
+       case PAPER_USLEGAL:
+               return 2;
+       case PAPER_USEXECUTIVE:
+               return 3;
+       case PAPER_A3:
+               return 4;
+       case PAPER_A4:
+               return 5;
+       case PAPER_A5:
+               return 6;
+       case PAPER_B5:
+               return 7;
+       default:
+               // should not happen
+               return 0;
+       }
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlPrint.C b/src/frontends/controllers/ControlPrint.C
deleted file mode 100644 (file)
index a9ea05f..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * \file ControlPrint.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlPrint.h"
-
-#include "ButtonController.h"
-#include "frontend_helpers.h"
-
-#include "buffer.h"
-#include "bufferparams.h"
-#include "funcrequest.h"
-#include "gettext.h"
-#include "PrinterParams.h"
-
-#include "support/convert.h"
-#include "support/filefilterlist.h"
-#include "support/filetools.h"
-
-using std::string;
-
-namespace lyx {
-
-using support::changeExtension;
-using support::FileFilterList;
-
-namespace frontend {
-
-
-ControlPrint::ControlPrint(Dialog & parent)
-       : Dialog::Controller(parent),
-         params_(0)
-{}
-
-
-bool ControlPrint::initialiseParams(std::string const &)
-{
-       /// get global printer parameters
-       string const name =  changeExtension(kernel().buffer().fileName(),
-                                       lyxrc.print_file_extension);
-       params_.reset(new PrinterParams(PrinterParams::PRINTER,
-                                       lyxrc.printer, name));
-
-       dialog().bc().valid(); // so that the user can press Ok
-       return true;
-}
-
-
-void ControlPrint::clearParams()
-{
-       params_.reset();
-}
-
-
-PrinterParams & ControlPrint::params() const
-{
-       BOOST_ASSERT(params_.get());
-       return *params_;
-}
-
-
-docstring const ControlPrint::browse(docstring const & in_name) const
-{
-       return browseRelFile(in_name, lyx::from_utf8(kernel().buffer().filePath()),
-                            _("Print to file"),
-                            FileFilterList(_("PostScript files (*.ps)")),
-                            true);
-}
-
-
-/// print the current buffer
-void ControlPrint::dispatchParams()
-{
-       PrinterParams const pp = params();
-       string command(lyxrc.print_command + ' ');
-
-       if (pp.target == PrinterParams::PRINTER
-           && lyxrc.print_adapt_output  // dvips wants a printer name
-           && !pp.printer_name.empty()) {// printer name given
-               command += lyxrc.print_to_printer
-                       + pp.printer_name
-                       + ' ';
-       }
-
-       if (!pp.all_pages && pp.from_page) {
-               command += lyxrc.print_pagerange_flag + ' ';
-               command += convert<string>(pp.from_page);
-               if (pp.to_page) {
-                       // we have a range "from-to"
-                       command += '-'
-                               + convert<string>(pp.to_page);
-               }
-               command += ' ';
-       }
-
-       // If both are, or both are not selected, then skip the odd/even printing
-       if (pp.odd_pages != pp.even_pages) {
-               if (pp.odd_pages) {
-                       command += lyxrc.print_oddpage_flag + ' ';
-               } else if (pp.even_pages) {
-                       command += lyxrc.print_evenpage_flag + ' ';
-               }
-       }
-
-       if (pp.count_copies > 1) {
-               if (pp.sorted_copies) {
-                       command += lyxrc.print_collcopies_flag;
-               } else {
-                       command += lyxrc.print_copies_flag;
-               }
-               command += ' '
-                       + convert<string>(pp.count_copies)
-                       + ' ';
-       }
-
-       if (pp.reverse_order) {
-               command += lyxrc.print_reverse_flag + ' ';
-       }
-
-       if (!lyxrc.print_extra_options.empty()) {
-               command += lyxrc.print_extra_options + ' ';
-       }
-
-       command += kernel().buffer().params().dvips_options() + ' ';
-
-       string const target = (pp.target == PrinterParams::PRINTER) ?
-               "printer" : "file";
-
-       string const target_name = (pp.target == PrinterParams::PRINTER) ?
-               (pp.printer_name.empty() ? "default" : pp.printer_name) :
-               pp.file_name;
-
-       string const data = target + " " + target_name + " " + command;
-       kernel().dispatch(FuncRequest(getLfun(), data));
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlPrint.cpp b/src/frontends/controllers/ControlPrint.cpp
new file mode 100644 (file)
index 0000000..a9ea05f
--- /dev/null
@@ -0,0 +1,146 @@
+/**
+ * \file ControlPrint.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlPrint.h"
+
+#include "ButtonController.h"
+#include "frontend_helpers.h"
+
+#include "buffer.h"
+#include "bufferparams.h"
+#include "funcrequest.h"
+#include "gettext.h"
+#include "PrinterParams.h"
+
+#include "support/convert.h"
+#include "support/filefilterlist.h"
+#include "support/filetools.h"
+
+using std::string;
+
+namespace lyx {
+
+using support::changeExtension;
+using support::FileFilterList;
+
+namespace frontend {
+
+
+ControlPrint::ControlPrint(Dialog & parent)
+       : Dialog::Controller(parent),
+         params_(0)
+{}
+
+
+bool ControlPrint::initialiseParams(std::string const &)
+{
+       /// get global printer parameters
+       string const name =  changeExtension(kernel().buffer().fileName(),
+                                       lyxrc.print_file_extension);
+       params_.reset(new PrinterParams(PrinterParams::PRINTER,
+                                       lyxrc.printer, name));
+
+       dialog().bc().valid(); // so that the user can press Ok
+       return true;
+}
+
+
+void ControlPrint::clearParams()
+{
+       params_.reset();
+}
+
+
+PrinterParams & ControlPrint::params() const
+{
+       BOOST_ASSERT(params_.get());
+       return *params_;
+}
+
+
+docstring const ControlPrint::browse(docstring const & in_name) const
+{
+       return browseRelFile(in_name, lyx::from_utf8(kernel().buffer().filePath()),
+                            _("Print to file"),
+                            FileFilterList(_("PostScript files (*.ps)")),
+                            true);
+}
+
+
+/// print the current buffer
+void ControlPrint::dispatchParams()
+{
+       PrinterParams const pp = params();
+       string command(lyxrc.print_command + ' ');
+
+       if (pp.target == PrinterParams::PRINTER
+           && lyxrc.print_adapt_output  // dvips wants a printer name
+           && !pp.printer_name.empty()) {// printer name given
+               command += lyxrc.print_to_printer
+                       + pp.printer_name
+                       + ' ';
+       }
+
+       if (!pp.all_pages && pp.from_page) {
+               command += lyxrc.print_pagerange_flag + ' ';
+               command += convert<string>(pp.from_page);
+               if (pp.to_page) {
+                       // we have a range "from-to"
+                       command += '-'
+                               + convert<string>(pp.to_page);
+               }
+               command += ' ';
+       }
+
+       // If both are, or both are not selected, then skip the odd/even printing
+       if (pp.odd_pages != pp.even_pages) {
+               if (pp.odd_pages) {
+                       command += lyxrc.print_oddpage_flag + ' ';
+               } else if (pp.even_pages) {
+                       command += lyxrc.print_evenpage_flag + ' ';
+               }
+       }
+
+       if (pp.count_copies > 1) {
+               if (pp.sorted_copies) {
+                       command += lyxrc.print_collcopies_flag;
+               } else {
+                       command += lyxrc.print_copies_flag;
+               }
+               command += ' '
+                       + convert<string>(pp.count_copies)
+                       + ' ';
+       }
+
+       if (pp.reverse_order) {
+               command += lyxrc.print_reverse_flag + ' ';
+       }
+
+       if (!lyxrc.print_extra_options.empty()) {
+               command += lyxrc.print_extra_options + ' ';
+       }
+
+       command += kernel().buffer().params().dvips_options() + ' ';
+
+       string const target = (pp.target == PrinterParams::PRINTER) ?
+               "printer" : "file";
+
+       string const target_name = (pp.target == PrinterParams::PRINTER) ?
+               (pp.printer_name.empty() ? "default" : pp.printer_name) :
+               pp.file_name;
+
+       string const data = target + " " + target_name + " " + command;
+       kernel().dispatch(FuncRequest(getLfun(), data));
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlRef.C b/src/frontends/controllers/ControlRef.C
deleted file mode 100644 (file)
index e0a886b..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * \file ControlRef.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-
-#include "ControlRef.h"
-
-#include "buffer.h"
-#include "bufferlist.h"
-#include "funcrequest.h"
-
-#include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
-
-using lyx::docstring;
-
-using std::vector;
-using std::string;
-
-namespace lyx {
-
-using support::makeAbsPath;
-using support::makeDisplayPath;
-
-namespace frontend {
-
-ControlRef::ControlRef(Dialog & d)
-       : ControlCommand(d, "ref", "ref")
-{}
-
-
-vector<docstring> const ControlRef::getLabelList(string const & name) const
-{
-       Buffer const & buf = *theBufferList().getBuffer(makeAbsPath(name).absFilename());
-       vector<docstring> list;
-       buf.getLabelList(list);
-       return list;
-}
-
-
-void ControlRef::gotoRef(string const & ref)
-{
-       kernel().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
-       kernel().dispatch(FuncRequest(LFUN_LABEL_GOTO, ref));
-}
-
-
-void ControlRef::gotoBookmark()
-{
-       kernel().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"));
-}
-
-
-vector<string> const ControlRef::getBufferList() const
-{
-       vector<string> buffers = theBufferList().getFileNames();
-       for (vector<string>::iterator it = buffers.begin();
-            it != buffers.end(); ++it) {
-               *it = lyx::to_utf8(makeDisplayPath(*it));
-       }
-
-       return buffers;
-}
-
-
-int ControlRef::getBufferNum() const
-{
-       vector<string> buffers = theBufferList().getFileNames();
-       string const name = kernel().buffer().fileName();
-       vector<string>::const_iterator cit =
-               find(buffers.begin(), buffers.end(), name);
-       if (cit == buffers.end())
-               return 0;
-       return int(cit - buffers.begin());
-}
-
-string const ControlRef::getBufferName(int num) const
-{
-       return theBufferList().getFileNames()[num];
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlRef.cpp b/src/frontends/controllers/ControlRef.cpp
new file mode 100644 (file)
index 0000000..e0a886b
--- /dev/null
@@ -0,0 +1,90 @@
+/**
+ * \file ControlRef.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+
+#include "ControlRef.h"
+
+#include "buffer.h"
+#include "bufferlist.h"
+#include "funcrequest.h"
+
+#include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
+
+using lyx::docstring;
+
+using std::vector;
+using std::string;
+
+namespace lyx {
+
+using support::makeAbsPath;
+using support::makeDisplayPath;
+
+namespace frontend {
+
+ControlRef::ControlRef(Dialog & d)
+       : ControlCommand(d, "ref", "ref")
+{}
+
+
+vector<docstring> const ControlRef::getLabelList(string const & name) const
+{
+       Buffer const & buf = *theBufferList().getBuffer(makeAbsPath(name).absFilename());
+       vector<docstring> list;
+       buf.getLabelList(list);
+       return list;
+}
+
+
+void ControlRef::gotoRef(string const & ref)
+{
+       kernel().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
+       kernel().dispatch(FuncRequest(LFUN_LABEL_GOTO, ref));
+}
+
+
+void ControlRef::gotoBookmark()
+{
+       kernel().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"));
+}
+
+
+vector<string> const ControlRef::getBufferList() const
+{
+       vector<string> buffers = theBufferList().getFileNames();
+       for (vector<string>::iterator it = buffers.begin();
+            it != buffers.end(); ++it) {
+               *it = lyx::to_utf8(makeDisplayPath(*it));
+       }
+
+       return buffers;
+}
+
+
+int ControlRef::getBufferNum() const
+{
+       vector<string> buffers = theBufferList().getFileNames();
+       string const name = kernel().buffer().fileName();
+       vector<string>::const_iterator cit =
+               find(buffers.begin(), buffers.end(), name);
+       if (cit == buffers.end())
+               return 0;
+       return int(cit - buffers.begin());
+}
+
+string const ControlRef::getBufferName(int num) const
+{
+       return theBufferList().getFileNames()[num];
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlSearch.C b/src/frontends/controllers/ControlSearch.C
deleted file mode 100644 (file)
index c706109..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * \file ControlSearch.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlSearch.h"
-
-#include "funcrequest.h"
-#include "lyxfind.h"
-
-namespace lyx {
-namespace frontend {
-
-ControlSearch::ControlSearch(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-void ControlSearch::find(docstring const & search, bool casesensitive,
-                        bool matchword, bool forward)
-{
-       docstring const data = find2string(search, casesensitive,
-                                             matchword, forward);
-       kernel().dispatch(FuncRequest(LFUN_WORD_FIND, data));
-}
-
-
-void ControlSearch::replace(docstring const & search, docstring const & replace,
-                           bool casesensitive, bool matchword,
-                           bool forward, bool all)
-{
-       docstring const data =
-               replace2string(search, replace, casesensitive,
-                                    matchword, all, forward);
-       kernel().dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlSearch.cpp b/src/frontends/controllers/ControlSearch.cpp
new file mode 100644 (file)
index 0000000..c706109
--- /dev/null
@@ -0,0 +1,46 @@
+/**
+ * \file ControlSearch.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlSearch.h"
+
+#include "funcrequest.h"
+#include "lyxfind.h"
+
+namespace lyx {
+namespace frontend {
+
+ControlSearch::ControlSearch(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+void ControlSearch::find(docstring const & search, bool casesensitive,
+                        bool matchword, bool forward)
+{
+       docstring const data = find2string(search, casesensitive,
+                                             matchword, forward);
+       kernel().dispatch(FuncRequest(LFUN_WORD_FIND, data));
+}
+
+
+void ControlSearch::replace(docstring const & search, docstring const & replace,
+                           bool casesensitive, bool matchword,
+                           bool forward, bool all)
+{
+       docstring const data =
+               replace2string(search, replace, casesensitive,
+                                    matchword, all, forward);
+       kernel().dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlSendto.C b/src/frontends/controllers/ControlSendto.C
deleted file mode 100644 (file)
index 371b34a..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * \file ControlSendto.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlSendto.h"
-
-#include "buffer.h"
-#include "converter.h"
-#include "format.h"
-#include "funcrequest.h"
-#include "lyxrc.h"
-
-#include "support/filetools.h"
-#include "support/lstrings.h"
-
-using std::vector;
-using std::string;
-
-namespace lyx {
-
-using support::trim;
-
-namespace frontend {
-
-
-ControlSendto::ControlSendto(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-bool ControlSendto::initialiseParams(std::string const &)
-{
-       format_ = 0;
-       command_ = lyxrc.custom_export_command;
-       return true;
-}
-
-
-void ControlSendto::dispatchParams()
-{
-       if (command_.empty() || !format_ || format_->name().empty())
-               return;
-
-       string const data = format_->name() + " " + command_;
-       kernel().dispatch(FuncRequest(getLfun(), data));
-}
-
-
-vector<Format const *> const ControlSendto::allFormats() const
-{
-       // What formats can we output natively?
-       vector<string> exports;
-       exports.push_back("lyx");
-       exports.push_back("text");
-
-       Buffer const & buffer = kernel().buffer();
-
-       if (buffer.isLatex())
-               exports.push_back("latex");
-       else if (buffer.isDocBook())
-               exports.push_back("docbook");
-       else if (buffer.isLiterate())
-               exports.push_back("literate");
-
-       // Loop over these native formats and ascertain what formats we
-       // can convert to
-       vector<Format const *> to;
-
-       vector<string>::const_iterator ex_it  = exports.begin();
-       vector<string>::const_iterator ex_end = exports.end();
-       for (; ex_it != ex_end; ++ex_it) {
-               // Start off with the native export format.
-               // "formats" is LyX's list of recognised formats
-               to.push_back(formats.getFormat(*ex_it));
-
-               Formats::const_iterator fo_it  = formats.begin();
-               Formats::const_iterator fo_end = formats.end();
-               for (; fo_it != fo_end; ++fo_it) {
-                       // we need to hide the default graphic export formats
-                       // from the external menu, because we need them only
-                       // for the internal lyx-view and external latex run
-                       string const name = fo_it->name();
-                       if (name != "eps" && name != "xpm" && name != "png" &&
-                           theConverters().isReachable(*ex_it, name))
-                               to.push_back(&(*fo_it));
-               }
-       }
-
-       // Remove repeated formats.
-       std::sort(to.begin(), to.end());
-       to.erase(std::unique(to.begin(), to.end()), to.end());
-
-       return to;
-}
-
-
-void ControlSendto::setFormat(Format const * fmt)
-{
-       format_ = fmt;
-}
-
-
-void ControlSendto::setCommand(string const & cmd)
-{
-       command_ = trim(cmd);
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlSendto.cpp b/src/frontends/controllers/ControlSendto.cpp
new file mode 100644 (file)
index 0000000..371b34a
--- /dev/null
@@ -0,0 +1,117 @@
+/**
+ * \file ControlSendto.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlSendto.h"
+
+#include "buffer.h"
+#include "converter.h"
+#include "format.h"
+#include "funcrequest.h"
+#include "lyxrc.h"
+
+#include "support/filetools.h"
+#include "support/lstrings.h"
+
+using std::vector;
+using std::string;
+
+namespace lyx {
+
+using support::trim;
+
+namespace frontend {
+
+
+ControlSendto::ControlSendto(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+bool ControlSendto::initialiseParams(std::string const &)
+{
+       format_ = 0;
+       command_ = lyxrc.custom_export_command;
+       return true;
+}
+
+
+void ControlSendto::dispatchParams()
+{
+       if (command_.empty() || !format_ || format_->name().empty())
+               return;
+
+       string const data = format_->name() + " " + command_;
+       kernel().dispatch(FuncRequest(getLfun(), data));
+}
+
+
+vector<Format const *> const ControlSendto::allFormats() const
+{
+       // What formats can we output natively?
+       vector<string> exports;
+       exports.push_back("lyx");
+       exports.push_back("text");
+
+       Buffer const & buffer = kernel().buffer();
+
+       if (buffer.isLatex())
+               exports.push_back("latex");
+       else if (buffer.isDocBook())
+               exports.push_back("docbook");
+       else if (buffer.isLiterate())
+               exports.push_back("literate");
+
+       // Loop over these native formats and ascertain what formats we
+       // can convert to
+       vector<Format const *> to;
+
+       vector<string>::const_iterator ex_it  = exports.begin();
+       vector<string>::const_iterator ex_end = exports.end();
+       for (; ex_it != ex_end; ++ex_it) {
+               // Start off with the native export format.
+               // "formats" is LyX's list of recognised formats
+               to.push_back(formats.getFormat(*ex_it));
+
+               Formats::const_iterator fo_it  = formats.begin();
+               Formats::const_iterator fo_end = formats.end();
+               for (; fo_it != fo_end; ++fo_it) {
+                       // we need to hide the default graphic export formats
+                       // from the external menu, because we need them only
+                       // for the internal lyx-view and external latex run
+                       string const name = fo_it->name();
+                       if (name != "eps" && name != "xpm" && name != "png" &&
+                           theConverters().isReachable(*ex_it, name))
+                               to.push_back(&(*fo_it));
+               }
+       }
+
+       // Remove repeated formats.
+       std::sort(to.begin(), to.end());
+       to.erase(std::unique(to.begin(), to.end()), to.end());
+
+       return to;
+}
+
+
+void ControlSendto::setFormat(Format const * fmt)
+{
+       format_ = fmt;
+}
+
+
+void ControlSendto::setCommand(string const & cmd)
+{
+       command_ = trim(cmd);
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlShowFile.C b/src/frontends/controllers/ControlShowFile.C
deleted file mode 100644 (file)
index 7cec00a..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * \file ControlShowFile.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Herbert Voß
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlShowFile.h"
-
-#include "support/filetools.h"
-
-using std::string;
-
-namespace lyx {
-
-using support::FileName;
-using support::onlyFilename;
-
-namespace frontend {
-
-
-ControlShowFile::ControlShowFile(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-bool ControlShowFile::initialiseParams(string const & data)
-{
-       filename_ = FileName(data);
-       return true;
-}
-
-
-void ControlShowFile::clearParams()
-{
-       filename_.erase();
-}
-
-
-string ControlShowFile::getFileContents()
-{
-       return support::getFileContents(filename_);
-}
-
-
-string ControlShowFile::getFileName()
-{
-       return onlyFilename(filename_.absFilename());
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlShowFile.cpp b/src/frontends/controllers/ControlShowFile.cpp
new file mode 100644 (file)
index 0000000..7cec00a
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * \file ControlShowFile.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Herbert Voß
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlShowFile.h"
+
+#include "support/filetools.h"
+
+using std::string;
+
+namespace lyx {
+
+using support::FileName;
+using support::onlyFilename;
+
+namespace frontend {
+
+
+ControlShowFile::ControlShowFile(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+bool ControlShowFile::initialiseParams(string const & data)
+{
+       filename_ = FileName(data);
+       return true;
+}
+
+
+void ControlShowFile::clearParams()
+{
+       filename_.erase();
+}
+
+
+string ControlShowFile::getFileContents()
+{
+       return support::getFileContents(filename_);
+}
+
+
+string ControlShowFile::getFileName()
+{
+       return onlyFilename(filename_.absFilename());
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlSpellchecker.C b/src/frontends/controllers/ControlSpellchecker.C
deleted file mode 100644 (file)
index d6814ca..0000000
+++ /dev/null
@@ -1,354 +0,0 @@
-/**
- * \file ControlSpellchecker.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlSpellchecker.h"
-
-#include "buffer.h"
-#include "bufferparams.h"
-#include "BufferView.h"
-#include "cursor.h"
-#include "CutAndPaste.h"
-#include "debug.h"
-#include "gettext.h"
-#include "language.h"
-#include "lyxrc.h"
-#include "paragraph.h"
-
-#if defined(USE_ASPELL)
-# include "aspell_local.h"
-#elif defined(USE_PSPELL)
-# include "pspell.h"
-#endif
-
-#if defined(USE_ISPELL)
-# include "ispell.h"
-#else
-# include "SpellBase.h"
-#endif
-
-#include "support/textutils.h"
-#include "support/convert.h"
-#include "support/docstring.h"
-
-#include "frontends/Alert.h"
-// FIXME: those two headers are needed because of the
-// WorkArea::redraw() call below.
-#include "frontends/LyXView.h"
-#include "frontends/WorkArea.h"
-
-using std::advance;
-using std::distance;
-using std::endl;
-using std::string;
-
-namespace lyx {
-
-using support::bformat;
-using support::contains;
-
-namespace frontend {
-
-
-ControlSpellchecker::ControlSpellchecker(Dialog & parent)
-       : Dialog::Controller(parent), exitEarly_(false),
-         oldval_(0), newvalue_(0), count_(0)
-{
-}
-
-
-ControlSpellchecker::~ControlSpellchecker()
-{}
-
-
-namespace {
-
-SpellBase * getSpeller(BufferParams const & bp)
-{
-       string lang = (lyxrc.isp_use_alt_lang)
-                     ? lyxrc.isp_alt_lang
-                     : bp.language->code();
-
-#if defined(USE_ASPELL)
-       if (lyxrc.use_spell_lib)
-               return new ASpell(bp, lang);
-#elif defined(USE_PSPELL)
-       if (lyxrc.use_spell_lib)
-               return new PSpell(bp, lang);
-#endif
-
-#if defined(USE_ISPELL)
-       lang = (lyxrc.isp_use_alt_lang) ?
-               lyxrc.isp_alt_lang : bp.language->lang();
-
-       return new ISpell(bp, lang);
-#else
-       return new SpellBase;
-#endif
-}
-
-} // namespace anon
-
-
-bool ControlSpellchecker::initialiseParams(std::string const &)
-{
-       LYXERR(Debug::GUI) << "Spellchecker::initialiseParams" << endl;
-
-       speller_.reset(getSpeller(kernel().buffer().params()));
-       if (!speller_.get())
-               return false;
-
-       // reset values to initial
-       oldval_ = 0;
-       newvalue_ = 0;
-       count_ = 0;
-
-       bool const success = speller_->error().empty();
-
-       if (!success) {
-               Alert::error(_("Spellchecker error"),
-                            _("The spellchecker could not be started\n")
-                            + speller_->error());
-               speller_.reset(0);
-       }
-
-       return success;
-}
-
-
-void ControlSpellchecker::clearParams()
-{
-       LYXERR(Debug::GUI) << "Spellchecker::clearParams" << endl;
-       speller_.reset(0);
-}
-
-
-namespace {
-
-bool isLetter(DocIterator const & dit)
-{
-       return dit.inTexted()
-               && dit.inset().allowSpellCheck()
-               && dit.pos() != dit.lastpos()
-               && (dit.paragraph().isLetter(dit.pos())
-                   // We want to pass the ' and escape chars to ispell
-                   || contains(lyx::from_utf8(lyxrc.isp_esc_chars + '\''),
-                               dit.paragraph().getChar(dit.pos())))
-               && !dit.paragraph().isDeleted(dit.pos());
-}
-
-
-WordLangTuple nextWord(LCursor & cur, ptrdiff_t & progress)
-{
-       BufferParams const & bp = cur.bv().buffer()->params();
-       bool inword = false;
-       bool ignoreword = false;
-       cur.resetAnchor();
-       docstring word;
-       string lang_code;
-
-       while (cur.depth()) {
-               if (isLetter(cur)) {
-                       if (!inword) {
-                               inword = true;
-                               ignoreword = false;
-                               cur.resetAnchor();
-                               word.clear();
-                               lang_code = cur.paragraph().getFontSettings(bp, cur.pos()).language()->code();
-                       }
-                       // Insets like optional hyphens and ligature
-                       // break are part of a word.
-                       if (!cur.paragraph().isInset(cur.pos())) {
-                               Paragraph::value_type const c =
-                                       cur.paragraph().getChar(cur.pos());
-                               word += c;
-                               if (isDigit(c))
-                                       ignoreword = true;
-                       }
-               } else { // !isLetter(cur)
-                       if (inword)
-                               if (!word.empty() && !ignoreword) {
-                                       cur.setSelection();
-                                       return WordLangTuple(word, lang_code);
-                               } else
-                                       inword = false;
-               }
-
-               cur.forwardPos();
-               ++progress;
-       }
-
-       return WordLangTuple(docstring(), string());
-}
-
-} // namespace anon
-
-
-
-void ControlSpellchecker::check()
-{
-       LYXERR(Debug::GUI) << "Check the spelling of a word" << endl;
-
-       SpellBase::Result res = SpellBase::OK;
-
-       LCursor cur = kernel().bufferview()->cursor();
-       while (cur && cur.pos() && isLetter(cur)) {
-               cur.backwardPos();
-       }
-
-       ptrdiff_t start = 0, total = 0;
-       DocIterator it = DocIterator(kernel().buffer().inset());
-       for (start = 0; it != cur; it.forwardPos())
-               ++start;
-
-       for (total = start; it; it.forwardPos())
-               ++total;
-
-       exitEarly_ = false;
-
-       while (res == SpellBase::OK || res == SpellBase::IGNORED_WORD) {
-               word_ = nextWord(cur, start);
-
-               // end of document
-               if (getWord().empty()) {
-                       showSummary();
-                       exitEarly_ = true;
-                       return;
-               }
-
-               ++count_;
-
-               // Update slider if and only if value has changed
-               float progress = total ? float(start)/total : 1;
-               newvalue_ = int(100.0 * progress);
-               if (newvalue_!= oldval_) {
-                       LYXERR(Debug::GUI) << "Updating spell progress." << endl;
-                       oldval_ = newvalue_;
-                       // set progress bar
-                       dialog().view().partialUpdate(SPELL_PROGRESSED);
-               }
-
-               // speller might be dead ...
-               if (!checkAlive())
-                       return;
-
-               res = speller_->check(word_);
-
-               // ... or it might just be reporting an error
-               if (!checkAlive())
-                       return;
-       }
-
-       LYXERR(Debug::GUI) << "Found word \"" << to_utf8(getWord()) << "\"" << endl;
-
-       int const size = cur.selEnd().pos() - cur.selBegin().pos();
-       cur.pos() -= size;
-       kernel().bufferview()->putSelectionAt(cur, size, false);
-       // FIXME: if we used a lfun like in find/replace, dispatch would do
-       // that for us
-       kernel().bufferview()->update();
-       // FIXME: this Controller is very badly designed...
-       kernel().lyxview().currentWorkArea()->redraw();
-
-       // set suggestions
-       if (res != SpellBase::OK && res != SpellBase::IGNORED_WORD) {
-               LYXERR(Debug::GUI) << "Found a word needing checking." << endl;
-               dialog().view().partialUpdate(SPELL_FOUND_WORD);
-       }
-}
-
-
-bool ControlSpellchecker::checkAlive()
-{
-       if (speller_->alive() && speller_->error().empty())
-               return true;
-
-       docstring message;
-       if (speller_->error().empty())
-               message = _("The spellchecker has died for some reason.\n"
-                                        "Maybe it has been killed.");
-       else
-               message = _("The spellchecker has failed.\n") + speller_->error();
-
-       dialog().CancelButton();
-
-       Alert::error(_("The spellchecker has failed"), message);
-       return false;
-}
-
-
-void ControlSpellchecker::showSummary()
-{
-       if (!checkAlive() || count_ == 0) {
-               dialog().CancelButton();
-               return;
-       }
-
-       docstring message;
-       if (count_ != 1)
-               message = bformat(_("%1$d words checked."), count_);
-       else
-               message = _("One word checked.");
-
-       dialog().CancelButton();
-       Alert::information(_("Spelling check completed"), message);
-}
-
-
-void ControlSpellchecker::replace(docstring const & replacement)
-{
-       LYXERR(Debug::GUI) << "ControlSpellchecker::replace("
-                          << to_utf8(replacement) << ")" << std::endl;
-       BufferView & bufferview = *kernel().bufferview();
-       cap::replaceSelectionWithString(bufferview.cursor(), replacement, true);
-       kernel().buffer().markDirty();
-       // If we used an LFUN, we would not need that
-       bufferview.update();
-       // fix up the count
-       --count_;
-       check();
-}
-
-
-void ControlSpellchecker::replaceAll(docstring const & replacement)
-{
-       // TODO: add to list
-       replace(replacement);
-}
-
-
-void ControlSpellchecker::insert()
-{
-       speller_->insert(word_);
-       check();
-}
-
-
-docstring const ControlSpellchecker::getSuggestion() const
-{
-       return speller_->nextMiss();
-}
-
-
-docstring const ControlSpellchecker::getWord() const
-{
-       return word_.word();
-}
-
-
-void ControlSpellchecker::ignoreAll()
-{
-       speller_->accept(word_);
-       check();
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlSpellchecker.cpp b/src/frontends/controllers/ControlSpellchecker.cpp
new file mode 100644 (file)
index 0000000..d6814ca
--- /dev/null
@@ -0,0 +1,354 @@
+/**
+ * \file ControlSpellchecker.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlSpellchecker.h"
+
+#include "buffer.h"
+#include "bufferparams.h"
+#include "BufferView.h"
+#include "cursor.h"
+#include "CutAndPaste.h"
+#include "debug.h"
+#include "gettext.h"
+#include "language.h"
+#include "lyxrc.h"
+#include "paragraph.h"
+
+#if defined(USE_ASPELL)
+# include "aspell_local.h"
+#elif defined(USE_PSPELL)
+# include "pspell.h"
+#endif
+
+#if defined(USE_ISPELL)
+# include "ispell.h"
+#else
+# include "SpellBase.h"
+#endif
+
+#include "support/textutils.h"
+#include "support/convert.h"
+#include "support/docstring.h"
+
+#include "frontends/Alert.h"
+// FIXME: those two headers are needed because of the
+// WorkArea::redraw() call below.
+#include "frontends/LyXView.h"
+#include "frontends/WorkArea.h"
+
+using std::advance;
+using std::distance;
+using std::endl;
+using std::string;
+
+namespace lyx {
+
+using support::bformat;
+using support::contains;
+
+namespace frontend {
+
+
+ControlSpellchecker::ControlSpellchecker(Dialog & parent)
+       : Dialog::Controller(parent), exitEarly_(false),
+         oldval_(0), newvalue_(0), count_(0)
+{
+}
+
+
+ControlSpellchecker::~ControlSpellchecker()
+{}
+
+
+namespace {
+
+SpellBase * getSpeller(BufferParams const & bp)
+{
+       string lang = (lyxrc.isp_use_alt_lang)
+                     ? lyxrc.isp_alt_lang
+                     : bp.language->code();
+
+#if defined(USE_ASPELL)
+       if (lyxrc.use_spell_lib)
+               return new ASpell(bp, lang);
+#elif defined(USE_PSPELL)
+       if (lyxrc.use_spell_lib)
+               return new PSpell(bp, lang);
+#endif
+
+#if defined(USE_ISPELL)
+       lang = (lyxrc.isp_use_alt_lang) ?
+               lyxrc.isp_alt_lang : bp.language->lang();
+
+       return new ISpell(bp, lang);
+#else
+       return new SpellBase;
+#endif
+}
+
+} // namespace anon
+
+
+bool ControlSpellchecker::initialiseParams(std::string const &)
+{
+       LYXERR(Debug::GUI) << "Spellchecker::initialiseParams" << endl;
+
+       speller_.reset(getSpeller(kernel().buffer().params()));
+       if (!speller_.get())
+               return false;
+
+       // reset values to initial
+       oldval_ = 0;
+       newvalue_ = 0;
+       count_ = 0;
+
+       bool const success = speller_->error().empty();
+
+       if (!success) {
+               Alert::error(_("Spellchecker error"),
+                            _("The spellchecker could not be started\n")
+                            + speller_->error());
+               speller_.reset(0);
+       }
+
+       return success;
+}
+
+
+void ControlSpellchecker::clearParams()
+{
+       LYXERR(Debug::GUI) << "Spellchecker::clearParams" << endl;
+       speller_.reset(0);
+}
+
+
+namespace {
+
+bool isLetter(DocIterator const & dit)
+{
+       return dit.inTexted()
+               && dit.inset().allowSpellCheck()
+               && dit.pos() != dit.lastpos()
+               && (dit.paragraph().isLetter(dit.pos())
+                   // We want to pass the ' and escape chars to ispell
+                   || contains(lyx::from_utf8(lyxrc.isp_esc_chars + '\''),
+                               dit.paragraph().getChar(dit.pos())))
+               && !dit.paragraph().isDeleted(dit.pos());
+}
+
+
+WordLangTuple nextWord(LCursor & cur, ptrdiff_t & progress)
+{
+       BufferParams const & bp = cur.bv().buffer()->params();
+       bool inword = false;
+       bool ignoreword = false;
+       cur.resetAnchor();
+       docstring word;
+       string lang_code;
+
+       while (cur.depth()) {
+               if (isLetter(cur)) {
+                       if (!inword) {
+                               inword = true;
+                               ignoreword = false;
+                               cur.resetAnchor();
+                               word.clear();
+                               lang_code = cur.paragraph().getFontSettings(bp, cur.pos()).language()->code();
+                       }
+                       // Insets like optional hyphens and ligature
+                       // break are part of a word.
+                       if (!cur.paragraph().isInset(cur.pos())) {
+                               Paragraph::value_type const c =
+                                       cur.paragraph().getChar(cur.pos());
+                               word += c;
+                               if (isDigit(c))
+                                       ignoreword = true;
+                       }
+               } else { // !isLetter(cur)
+                       if (inword)
+                               if (!word.empty() && !ignoreword) {
+                                       cur.setSelection();
+                                       return WordLangTuple(word, lang_code);
+                               } else
+                                       inword = false;
+               }
+
+               cur.forwardPos();
+               ++progress;
+       }
+
+       return WordLangTuple(docstring(), string());
+}
+
+} // namespace anon
+
+
+
+void ControlSpellchecker::check()
+{
+       LYXERR(Debug::GUI) << "Check the spelling of a word" << endl;
+
+       SpellBase::Result res = SpellBase::OK;
+
+       LCursor cur = kernel().bufferview()->cursor();
+       while (cur && cur.pos() && isLetter(cur)) {
+               cur.backwardPos();
+       }
+
+       ptrdiff_t start = 0, total = 0;
+       DocIterator it = DocIterator(kernel().buffer().inset());
+       for (start = 0; it != cur; it.forwardPos())
+               ++start;
+
+       for (total = start; it; it.forwardPos())
+               ++total;
+
+       exitEarly_ = false;
+
+       while (res == SpellBase::OK || res == SpellBase::IGNORED_WORD) {
+               word_ = nextWord(cur, start);
+
+               // end of document
+               if (getWord().empty()) {
+                       showSummary();
+                       exitEarly_ = true;
+                       return;
+               }
+
+               ++count_;
+
+               // Update slider if and only if value has changed
+               float progress = total ? float(start)/total : 1;
+               newvalue_ = int(100.0 * progress);
+               if (newvalue_!= oldval_) {
+                       LYXERR(Debug::GUI) << "Updating spell progress." << endl;
+                       oldval_ = newvalue_;
+                       // set progress bar
+                       dialog().view().partialUpdate(SPELL_PROGRESSED);
+               }
+
+               // speller might be dead ...
+               if (!checkAlive())
+                       return;
+
+               res = speller_->check(word_);
+
+               // ... or it might just be reporting an error
+               if (!checkAlive())
+                       return;
+       }
+
+       LYXERR(Debug::GUI) << "Found word \"" << to_utf8(getWord()) << "\"" << endl;
+
+       int const size = cur.selEnd().pos() - cur.selBegin().pos();
+       cur.pos() -= size;
+       kernel().bufferview()->putSelectionAt(cur, size, false);
+       // FIXME: if we used a lfun like in find/replace, dispatch would do
+       // that for us
+       kernel().bufferview()->update();
+       // FIXME: this Controller is very badly designed...
+       kernel().lyxview().currentWorkArea()->redraw();
+
+       // set suggestions
+       if (res != SpellBase::OK && res != SpellBase::IGNORED_WORD) {
+               LYXERR(Debug::GUI) << "Found a word needing checking." << endl;
+               dialog().view().partialUpdate(SPELL_FOUND_WORD);
+       }
+}
+
+
+bool ControlSpellchecker::checkAlive()
+{
+       if (speller_->alive() && speller_->error().empty())
+               return true;
+
+       docstring message;
+       if (speller_->error().empty())
+               message = _("The spellchecker has died for some reason.\n"
+                                        "Maybe it has been killed.");
+       else
+               message = _("The spellchecker has failed.\n") + speller_->error();
+
+       dialog().CancelButton();
+
+       Alert::error(_("The spellchecker has failed"), message);
+       return false;
+}
+
+
+void ControlSpellchecker::showSummary()
+{
+       if (!checkAlive() || count_ == 0) {
+               dialog().CancelButton();
+               return;
+       }
+
+       docstring message;
+       if (count_ != 1)
+               message = bformat(_("%1$d words checked."), count_);
+       else
+               message = _("One word checked.");
+
+       dialog().CancelButton();
+       Alert::information(_("Spelling check completed"), message);
+}
+
+
+void ControlSpellchecker::replace(docstring const & replacement)
+{
+       LYXERR(Debug::GUI) << "ControlSpellchecker::replace("
+                          << to_utf8(replacement) << ")" << std::endl;
+       BufferView & bufferview = *kernel().bufferview();
+       cap::replaceSelectionWithString(bufferview.cursor(), replacement, true);
+       kernel().buffer().markDirty();
+       // If we used an LFUN, we would not need that
+       bufferview.update();
+       // fix up the count
+       --count_;
+       check();
+}
+
+
+void ControlSpellchecker::replaceAll(docstring const & replacement)
+{
+       // TODO: add to list
+       replace(replacement);
+}
+
+
+void ControlSpellchecker::insert()
+{
+       speller_->insert(word_);
+       check();
+}
+
+
+docstring const ControlSpellchecker::getSuggestion() const
+{
+       return speller_->nextMiss();
+}
+
+
+docstring const ControlSpellchecker::getWord() const
+{
+       return word_.word();
+}
+
+
+void ControlSpellchecker::ignoreAll()
+{
+       speller_->accept(word_);
+       check();
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlTabular.C b/src/frontends/controllers/ControlTabular.C
deleted file mode 100644 (file)
index f4629ec..0000000
+++ /dev/null
@@ -1,243 +0,0 @@
-/**
- * \file ControlTabular.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "BufferView.h"
-#include "ControlTabular.h"
-#include "cursor.h"
-#include "funcrequest.h"
-#include "lyxrc.h"
-#include "paragraph.h"
-#include "insets/InsetTabular.h"
-
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-ControlTabular::ControlTabular(Dialog & parent)
-       : Dialog::Controller(parent), active_cell_(LyXTabular::npos)
-{}
-
-
-bool ControlTabular::initialiseParams(string const & data)
-{
-       // try to get the current cell
-       BufferView const * const bv = kernel().bufferview();
-       if (bv) {
-               LCursor const & cur = bv->cursor();
-               // get the innermost tabular inset;
-               // assume that it is "ours"
-               for (int i = cur.depth() - 1; i >= 0; --i)
-                       if (cur[i].inset().lyxCode() == InsetBase::TABULAR_CODE) {
-                               active_cell_ = cur[i].idx();
-                               break;
-                       }
-       }
-       InsetTabular tmp(kernel().buffer());
-       InsetTabularMailer::string2params(data, tmp);
-       params_.reset(new LyXTabular(tmp.tabular));
-       return true;
-}
-
-
-void ControlTabular::clearParams()
-{
-       params_.reset();
-       active_cell_ = LyXTabular::npos;
-}
-
-
-LyXTabular::idx_type ControlTabular::getActiveCell() const
-{
-       return active_cell_;
-}
-
-
-LyXTabular const & ControlTabular::tabular() const
-{
-       BOOST_ASSERT(params_.get());
-       return *params_.get();
-}
-
-
-void ControlTabular::set(LyXTabular::Feature f, string const & arg)
-{
-       string const data = featureAsString(f) + ' ' + arg;
-       kernel().dispatch(FuncRequest(getLfun(), data));
-}
-
-
-bool ControlTabular::useMetricUnits() const
-{
-       return lyxrc.default_papersize > PAPER_USEXECUTIVE;
-}
-
-
-void ControlTabular::toggleTopLine()
-{
-       if (tabular().isMultiColumn(getActiveCell()))
-               set(LyXTabular::M_TOGGLE_LINE_TOP);
-       else
-               set(LyXTabular::TOGGLE_LINE_TOP);
-}
-
-
-void ControlTabular::toggleBottomLine()
-{
-       if (tabular().isMultiColumn(getActiveCell()))
-               set(LyXTabular::M_TOGGLE_LINE_BOTTOM);
-       else
-               set(LyXTabular::TOGGLE_LINE_BOTTOM);
-}
-
-
-void ControlTabular::toggleLeftLine()
-{
-       if (tabular().isMultiColumn(getActiveCell()))
-               set(LyXTabular::M_TOGGLE_LINE_LEFT);
-       else
-               set(LyXTabular::TOGGLE_LINE_LEFT);
-}
-
-
-void ControlTabular::toggleRightLine()
-{
-       if (tabular().isMultiColumn(getActiveCell()))
-               set(LyXTabular::M_TOGGLE_LINE_RIGHT);
-       else
-               set(LyXTabular::TOGGLE_LINE_RIGHT);
-}
-
-
-void ControlTabular::setSpecial(string const & special)
-{
-       if (tabular().isMultiColumn(getActiveCell()))
-               set(LyXTabular::SET_SPECIAL_MULTI, special);
-       else
-               set(LyXTabular::SET_SPECIAL_COLUMN, special);
-}
-
-
-void ControlTabular::setWidth(string const & width)
-{
-       if (tabular().isMultiColumn(getActiveCell()))
-               set(LyXTabular::SET_MPWIDTH, width);
-       else
-               set(LyXTabular::SET_PWIDTH, width);
-
-       dialog().view().update();
-}
-
-
-void ControlTabular::toggleMultiColumn()
-{
-       set(LyXTabular::MULTICOLUMN);
-       dialog().view().update();
-}
-
-
-void ControlTabular::rotateTabular(bool yes)
-{
-       if (yes)
-               set(LyXTabular::SET_ROTATE_TABULAR);
-       else
-               set(LyXTabular::UNSET_ROTATE_TABULAR);
-}
-
-
-void ControlTabular::rotateCell(bool yes)
-{
-       if (yes)
-               set(LyXTabular::SET_ROTATE_CELL);
-       else
-               set(LyXTabular::UNSET_ROTATE_CELL);
-}
-
-
-void ControlTabular::halign(ControlTabular::HALIGN h)
-{
-       LyXTabular::Feature num = LyXTabular::ALIGN_LEFT;
-       LyXTabular::Feature multi_num = LyXTabular::M_ALIGN_LEFT;
-
-       switch (h) {
-               case LEFT:
-                       num = LyXTabular::ALIGN_LEFT;
-                       multi_num = LyXTabular::M_ALIGN_LEFT;
-                       break;
-               case CENTER:
-                       num = LyXTabular::ALIGN_CENTER;
-                       multi_num = LyXTabular::M_ALIGN_CENTER;
-                       break;
-               case RIGHT:
-                       num = LyXTabular::ALIGN_RIGHT;
-                       multi_num = LyXTabular::M_ALIGN_RIGHT;
-                       break;
-               case BLOCK:
-                       num = LyXTabular::ALIGN_BLOCK;
-                       //multi_num: no equivalent
-                       break;
-       }
-
-       if (tabular().isMultiColumn(getActiveCell()))
-               set(multi_num);
-       else
-               set(num);
-}
-
-
-void ControlTabular::valign(ControlTabular::VALIGN v)
-{
-       LyXTabular::Feature num = LyXTabular::VALIGN_MIDDLE;
-       LyXTabular::Feature multi_num = LyXTabular::M_VALIGN_MIDDLE;
-
-       switch (v) {
-               case TOP:
-                       num = LyXTabular::VALIGN_TOP;
-                       multi_num = LyXTabular::M_VALIGN_TOP;
-                       break;
-               case MIDDLE:
-                       num = LyXTabular::VALIGN_MIDDLE;
-                       multi_num = LyXTabular::M_VALIGN_MIDDLE;
-                       break;
-               case BOTTOM:
-                       num = LyXTabular::VALIGN_BOTTOM;
-                       multi_num = LyXTabular::M_VALIGN_BOTTOM;
-                       break;
-       }
-
-       if (tabular().isMultiColumn(getActiveCell()))
-               set(multi_num);
-       else
-               set(num);
-}
-
-
-void ControlTabular::booktabs(bool yes)
-{
-       if (yes)
-               set(LyXTabular::SET_BOOKTABS);
-       else
-               set(LyXTabular::UNSET_BOOKTABS);
-}
-
-
-void ControlTabular::longTabular(bool yes)
-{
-       if (yes)
-               set(LyXTabular::SET_LONGTABULAR);
-       else
-               set(LyXTabular::UNSET_LONGTABULAR);
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlTabular.cpp b/src/frontends/controllers/ControlTabular.cpp
new file mode 100644 (file)
index 0000000..f4629ec
--- /dev/null
@@ -0,0 +1,243 @@
+/**
+ * \file ControlTabular.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "BufferView.h"
+#include "ControlTabular.h"
+#include "cursor.h"
+#include "funcrequest.h"
+#include "lyxrc.h"
+#include "paragraph.h"
+#include "insets/InsetTabular.h"
+
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+ControlTabular::ControlTabular(Dialog & parent)
+       : Dialog::Controller(parent), active_cell_(LyXTabular::npos)
+{}
+
+
+bool ControlTabular::initialiseParams(string const & data)
+{
+       // try to get the current cell
+       BufferView const * const bv = kernel().bufferview();
+       if (bv) {
+               LCursor const & cur = bv->cursor();
+               // get the innermost tabular inset;
+               // assume that it is "ours"
+               for (int i = cur.depth() - 1; i >= 0; --i)
+                       if (cur[i].inset().lyxCode() == InsetBase::TABULAR_CODE) {
+                               active_cell_ = cur[i].idx();
+                               break;
+                       }
+       }
+       InsetTabular tmp(kernel().buffer());
+       InsetTabularMailer::string2params(data, tmp);
+       params_.reset(new LyXTabular(tmp.tabular));
+       return true;
+}
+
+
+void ControlTabular::clearParams()
+{
+       params_.reset();
+       active_cell_ = LyXTabular::npos;
+}
+
+
+LyXTabular::idx_type ControlTabular::getActiveCell() const
+{
+       return active_cell_;
+}
+
+
+LyXTabular const & ControlTabular::tabular() const
+{
+       BOOST_ASSERT(params_.get());
+       return *params_.get();
+}
+
+
+void ControlTabular::set(LyXTabular::Feature f, string const & arg)
+{
+       string const data = featureAsString(f) + ' ' + arg;
+       kernel().dispatch(FuncRequest(getLfun(), data));
+}
+
+
+bool ControlTabular::useMetricUnits() const
+{
+       return lyxrc.default_papersize > PAPER_USEXECUTIVE;
+}
+
+
+void ControlTabular::toggleTopLine()
+{
+       if (tabular().isMultiColumn(getActiveCell()))
+               set(LyXTabular::M_TOGGLE_LINE_TOP);
+       else
+               set(LyXTabular::TOGGLE_LINE_TOP);
+}
+
+
+void ControlTabular::toggleBottomLine()
+{
+       if (tabular().isMultiColumn(getActiveCell()))
+               set(LyXTabular::M_TOGGLE_LINE_BOTTOM);
+       else
+               set(LyXTabular::TOGGLE_LINE_BOTTOM);
+}
+
+
+void ControlTabular::toggleLeftLine()
+{
+       if (tabular().isMultiColumn(getActiveCell()))
+               set(LyXTabular::M_TOGGLE_LINE_LEFT);
+       else
+               set(LyXTabular::TOGGLE_LINE_LEFT);
+}
+
+
+void ControlTabular::toggleRightLine()
+{
+       if (tabular().isMultiColumn(getActiveCell()))
+               set(LyXTabular::M_TOGGLE_LINE_RIGHT);
+       else
+               set(LyXTabular::TOGGLE_LINE_RIGHT);
+}
+
+
+void ControlTabular::setSpecial(string const & special)
+{
+       if (tabular().isMultiColumn(getActiveCell()))
+               set(LyXTabular::SET_SPECIAL_MULTI, special);
+       else
+               set(LyXTabular::SET_SPECIAL_COLUMN, special);
+}
+
+
+void ControlTabular::setWidth(string const & width)
+{
+       if (tabular().isMultiColumn(getActiveCell()))
+               set(LyXTabular::SET_MPWIDTH, width);
+       else
+               set(LyXTabular::SET_PWIDTH, width);
+
+       dialog().view().update();
+}
+
+
+void ControlTabular::toggleMultiColumn()
+{
+       set(LyXTabular::MULTICOLUMN);
+       dialog().view().update();
+}
+
+
+void ControlTabular::rotateTabular(bool yes)
+{
+       if (yes)
+               set(LyXTabular::SET_ROTATE_TABULAR);
+       else
+               set(LyXTabular::UNSET_ROTATE_TABULAR);
+}
+
+
+void ControlTabular::rotateCell(bool yes)
+{
+       if (yes)
+               set(LyXTabular::SET_ROTATE_CELL);
+       else
+               set(LyXTabular::UNSET_ROTATE_CELL);
+}
+
+
+void ControlTabular::halign(ControlTabular::HALIGN h)
+{
+       LyXTabular::Feature num = LyXTabular::ALIGN_LEFT;
+       LyXTabular::Feature multi_num = LyXTabular::M_ALIGN_LEFT;
+
+       switch (h) {
+               case LEFT:
+                       num = LyXTabular::ALIGN_LEFT;
+                       multi_num = LyXTabular::M_ALIGN_LEFT;
+                       break;
+               case CENTER:
+                       num = LyXTabular::ALIGN_CENTER;
+                       multi_num = LyXTabular::M_ALIGN_CENTER;
+                       break;
+               case RIGHT:
+                       num = LyXTabular::ALIGN_RIGHT;
+                       multi_num = LyXTabular::M_ALIGN_RIGHT;
+                       break;
+               case BLOCK:
+                       num = LyXTabular::ALIGN_BLOCK;
+                       //multi_num: no equivalent
+                       break;
+       }
+
+       if (tabular().isMultiColumn(getActiveCell()))
+               set(multi_num);
+       else
+               set(num);
+}
+
+
+void ControlTabular::valign(ControlTabular::VALIGN v)
+{
+       LyXTabular::Feature num = LyXTabular::VALIGN_MIDDLE;
+       LyXTabular::Feature multi_num = LyXTabular::M_VALIGN_MIDDLE;
+
+       switch (v) {
+               case TOP:
+                       num = LyXTabular::VALIGN_TOP;
+                       multi_num = LyXTabular::M_VALIGN_TOP;
+                       break;
+               case MIDDLE:
+                       num = LyXTabular::VALIGN_MIDDLE;
+                       multi_num = LyXTabular::M_VALIGN_MIDDLE;
+                       break;
+               case BOTTOM:
+                       num = LyXTabular::VALIGN_BOTTOM;
+                       multi_num = LyXTabular::M_VALIGN_BOTTOM;
+                       break;
+       }
+
+       if (tabular().isMultiColumn(getActiveCell()))
+               set(multi_num);
+       else
+               set(num);
+}
+
+
+void ControlTabular::booktabs(bool yes)
+{
+       if (yes)
+               set(LyXTabular::SET_BOOKTABS);
+       else
+               set(LyXTabular::UNSET_BOOKTABS);
+}
+
+
+void ControlTabular::longTabular(bool yes)
+{
+       if (yes)
+               set(LyXTabular::SET_LONGTABULAR);
+       else
+               set(LyXTabular::UNSET_LONGTABULAR);
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlTabularCreate.C b/src/frontends/controllers/ControlTabularCreate.C
deleted file mode 100644 (file)
index 0fb5d24..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * \file ControlTabularCreate.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author unknown
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlTabularCreate.h"
-#include "funcrequest.h"
-
-#include "support/convert.h"
-
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-ControlTabularCreate::ControlTabularCreate(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-bool ControlTabularCreate::initialiseParams(string const &)
-{
-       params_.first  = 5;
-       params_.second = 5;
-       return true;
-}
-
-
-void ControlTabularCreate::clearParams()
-{
-       params_.first  = 0;
-       params_.second = 0;
-}
-
-
-void ControlTabularCreate::dispatchParams()
-{
-       string const data = convert<string>(params().first) + ' ' + convert<string>(params().second);
-       kernel().dispatch(FuncRequest(getLfun(), data));
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlTabularCreate.cpp b/src/frontends/controllers/ControlTabularCreate.cpp
new file mode 100644 (file)
index 0000000..0fb5d24
--- /dev/null
@@ -0,0 +1,51 @@
+/**
+ * \file ControlTabularCreate.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author unknown
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlTabularCreate.h"
+#include "funcrequest.h"
+
+#include "support/convert.h"
+
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+ControlTabularCreate::ControlTabularCreate(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+bool ControlTabularCreate::initialiseParams(string const &)
+{
+       params_.first  = 5;
+       params_.second = 5;
+       return true;
+}
+
+
+void ControlTabularCreate::clearParams()
+{
+       params_.first  = 0;
+       params_.second = 0;
+}
+
+
+void ControlTabularCreate::dispatchParams()
+{
+       string const data = convert<string>(params().first) + ' ' + convert<string>(params().second);
+       kernel().dispatch(FuncRequest(getLfun(), data));
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlTexinfo.C b/src/frontends/controllers/ControlTexinfo.C
deleted file mode 100644 (file)
index 7694773..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * \file ControlTexinfo.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Herbert Voß
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlTexinfo.h"
-#include "funcrequest.h"
-
-#include "support/filetools.h"
-
-#include <algorithm>
-
-using std::string;
-using std::vector;
-
-namespace lyx {
-
-using support::onlyFilename;
-
-namespace frontend {
-
-void getTexFileList(ControlTexinfo::texFileSuffix type,
-                   std::vector<string> & list, bool withPath)
-{
-       string filename;
-       switch (type) {
-       case ControlTexinfo::bst:
-               filename = "bstFiles.lst";
-               break;
-       case ControlTexinfo::cls:
-               filename = "clsFiles.lst";
-               break;
-       case ControlTexinfo::sty:
-               filename = "styFiles.lst";
-               break;
-       }
-       getTexFileList(filename, list);
-       if (list.empty()) {
-               // build filelists of all availabe bst/cls/sty-files.
-               // Done through kpsewhich and an external script,
-               // saved in *Files.lst
-               rescanTexStyles();
-               getTexFileList(filename, list);
-       }
-       if (withPath)
-               return;
-       vector<string>::iterator it  = list.begin();
-       vector<string>::iterator end = list.end();
-       for (; it != end; ++it) {
-               *it = onlyFilename(*it);
-       }
-       // sort on filename only (no path)
-       std::sort(list.begin(), list.end());
-}
-
-
-ControlTexinfo::ControlTexinfo(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-void ControlTexinfo::viewFile(string const & filename) const
-{
-       string const arg = "file " + filename;
-       kernel().dispatch(FuncRequest(LFUN_DIALOG_SHOW, arg));
-}
-
-
-string const ControlTexinfo::getClassOptions(string const & filename) const
-{
-       return getListOfOptions(filename, "cls");
-}
-
-
-string const ControlTexinfo::getFileType(ControlTexinfo::texFileSuffix type) const
-{
-       string ftype;
-       switch (type) {
-       case ControlTexinfo::bst:
-               ftype = "bst";
-               break;
-       case ControlTexinfo::cls:
-               ftype = "cls";
-               break;
-       case ControlTexinfo::sty:
-               ftype = "sty";
-               break;
-       }
-       return ftype;
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlTexinfo.cpp b/src/frontends/controllers/ControlTexinfo.cpp
new file mode 100644 (file)
index 0000000..7694773
--- /dev/null
@@ -0,0 +1,100 @@
+/**
+ * \file ControlTexinfo.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Herbert Voß
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlTexinfo.h"
+#include "funcrequest.h"
+
+#include "support/filetools.h"
+
+#include <algorithm>
+
+using std::string;
+using std::vector;
+
+namespace lyx {
+
+using support::onlyFilename;
+
+namespace frontend {
+
+void getTexFileList(ControlTexinfo::texFileSuffix type,
+                   std::vector<string> & list, bool withPath)
+{
+       string filename;
+       switch (type) {
+       case ControlTexinfo::bst:
+               filename = "bstFiles.lst";
+               break;
+       case ControlTexinfo::cls:
+               filename = "clsFiles.lst";
+               break;
+       case ControlTexinfo::sty:
+               filename = "styFiles.lst";
+               break;
+       }
+       getTexFileList(filename, list);
+       if (list.empty()) {
+               // build filelists of all availabe bst/cls/sty-files.
+               // Done through kpsewhich and an external script,
+               // saved in *Files.lst
+               rescanTexStyles();
+               getTexFileList(filename, list);
+       }
+       if (withPath)
+               return;
+       vector<string>::iterator it  = list.begin();
+       vector<string>::iterator end = list.end();
+       for (; it != end; ++it) {
+               *it = onlyFilename(*it);
+       }
+       // sort on filename only (no path)
+       std::sort(list.begin(), list.end());
+}
+
+
+ControlTexinfo::ControlTexinfo(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+void ControlTexinfo::viewFile(string const & filename) const
+{
+       string const arg = "file " + filename;
+       kernel().dispatch(FuncRequest(LFUN_DIALOG_SHOW, arg));
+}
+
+
+string const ControlTexinfo::getClassOptions(string const & filename) const
+{
+       return getListOfOptions(filename, "cls");
+}
+
+
+string const ControlTexinfo::getFileType(ControlTexinfo::texFileSuffix type) const
+{
+       string ftype;
+       switch (type) {
+       case ControlTexinfo::bst:
+               ftype = "bst";
+               break;
+       case ControlTexinfo::cls:
+               ftype = "cls";
+               break;
+       case ControlTexinfo::sty:
+               ftype = "sty";
+               break;
+       }
+       return ftype;
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlThesaurus.C b/src/frontends/controllers/ControlThesaurus.C
deleted file mode 100644 (file)
index 79a0dca..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * \file ControlThesaurus.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlThesaurus.h"
-
-#include "lyxfind.h"
-#include "funcrequest.h"
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-ControlThesaurus::ControlThesaurus(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-bool ControlThesaurus::initialiseParams(string const & data)
-{
-       oldstr_ = from_utf8(data);
-       return true;
-}
-
-
-void ControlThesaurus::clearParams()
-{
-       oldstr_.erase();
-}
-
-
-void ControlThesaurus::replace(docstring const & newstr)
-{
-       /* FIXME: this is not suitable ! We need to have a "lock"
-        * on a particular charpos in a paragraph that is broken on
-        * deletion/change !
-        */
-       docstring const data =
-               replace2string(oldstr_, newstr,
-                                    true,  // case sensitive
-                                    true,  // match word
-                                    false, // all words
-                                    true); // forward
-       kernel().dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
-}
-
-
-Thesaurus::Meanings const & ControlThesaurus::getMeanings(docstring const & str)
-{
-       if (str != laststr_)
-               meanings_ = thesaurus.lookup(str);
-       return meanings_;
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlThesaurus.cpp b/src/frontends/controllers/ControlThesaurus.cpp
new file mode 100644 (file)
index 0000000..79a0dca
--- /dev/null
@@ -0,0 +1,65 @@
+/**
+ * \file ControlThesaurus.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlThesaurus.h"
+
+#include "lyxfind.h"
+#include "funcrequest.h"
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+ControlThesaurus::ControlThesaurus(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+bool ControlThesaurus::initialiseParams(string const & data)
+{
+       oldstr_ = from_utf8(data);
+       return true;
+}
+
+
+void ControlThesaurus::clearParams()
+{
+       oldstr_.erase();
+}
+
+
+void ControlThesaurus::replace(docstring const & newstr)
+{
+       /* FIXME: this is not suitable ! We need to have a "lock"
+        * on a particular charpos in a paragraph that is broken on
+        * deletion/change !
+        */
+       docstring const data =
+               replace2string(oldstr_, newstr,
+                                    true,  // case sensitive
+                                    true,  // match word
+                                    false, // all words
+                                    true); // forward
+       kernel().dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
+}
+
+
+Thesaurus::Meanings const & ControlThesaurus::getMeanings(docstring const & str)
+{
+       if (str != laststr_)
+               meanings_ = thesaurus.lookup(str);
+       return meanings_;
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlToc.C b/src/frontends/controllers/ControlToc.C
deleted file mode 100644 (file)
index 7e0014f..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * \file ControlToc.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlToc.h"
-
-#include "buffer.h"
-#include "BufferView.h"
-#include "bufferparams.h"
-#include "debug.h"
-#include "FloatList.h"
-#include "funcrequest.h"
-#include "gettext.h"
-
-#include "frontends/LyXView.h"
-
-#include "support/convert.h"
-
-using std::string;
-
-
-class Buffer;
-
-namespace lyx {
-namespace frontend {
-
-
-ControlToc::ControlToc(Dialog & d)
-       : ControlCommand(d, "tableofcontents", "toc")
-{
-}
-
-
-TocList const & ControlToc::tocs() const
-{
-       return kernel().buffer().tocBackend().tocs();
-}
-
-
-bool ControlToc::initialiseParams(string const & data)
-{
-       if (!ControlCommand::initialiseParams(data))
-               return false;
-
-       types_.clear();
-       type_names_.clear();
-       TocList const & tocs = kernel().buffer().tocBackend().tocs();
-       TocList::const_iterator it = tocs.begin();
-       TocList::const_iterator end = tocs.end();
-       for (; it != end; ++it) {
-               types_.push_back(it->first);
-               type_names_.push_back(getGuiName(it->first));
-       }
-
-       string selected_type ;
-       if(params()["type"].empty()) //Then plain toc...
-               selected_type = params().getCmdName();
-       else
-               selected_type = to_ascii(params()["type"]);
-       selected_type_ = -1;
-       for (size_t i = 0;  i != types_.size(); ++i) {
-               if (selected_type == types_[i]) {
-                       selected_type_ = i;
-                       break;
-               }
-       }
-
-       return true;
-}
-
-void ControlToc::goTo(TocItem const & item)
-{
-       string const tmp = convert<string>(item.id());
-       kernel().lyxview().dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, tmp));
-}
-
-
-bool ControlToc::canOutline(size_t type) const
-{
-       return types_[type] == "tableofcontents";
-}
-
-
-void ControlToc::outlineUp()
-{
-       kernel().dispatch(FuncRequest(LFUN_OUTLINE_UP));
-}
-
-
-void ControlToc::outlineDown()
-{
-       kernel().dispatch(FuncRequest(LFUN_OUTLINE_DOWN));
-}
-
-
-void ControlToc::outlineIn()
-{
-       kernel().dispatch(FuncRequest(LFUN_OUTLINE_IN));
-}
-
-
-void ControlToc::outlineOut()
-{
-       kernel().dispatch(FuncRequest(LFUN_OUTLINE_OUT));
-}
-
-
-void ControlToc::updateBackend()
-{
-       kernel().buffer().tocBackend().update();
-}
-
-
-TocIterator const ControlToc::getCurrentTocItem(size_t type) const
-{
-       BOOST_ASSERT(kernel().bufferview());
-       ParConstIterator it(kernel().bufferview()->cursor());
-       return kernel().buffer().tocBackend().item(types_[type], it);
-}
-
-
-docstring const ControlToc::getGuiName(string const & type) const
-{
-       if (type == "tableofcontents")
-               return _("Table of Contents");
-
-       FloatList const & floats =
-               kernel().buffer().params().getLyXTextClass().floats();
-       if (floats.typeExist(type))
-               return from_utf8(floats.getType(type).name());
-       else
-               return _(type);
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlToc.cpp b/src/frontends/controllers/ControlToc.cpp
new file mode 100644 (file)
index 0000000..7e0014f
--- /dev/null
@@ -0,0 +1,145 @@
+/**
+ * \file ControlToc.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlToc.h"
+
+#include "buffer.h"
+#include "BufferView.h"
+#include "bufferparams.h"
+#include "debug.h"
+#include "FloatList.h"
+#include "funcrequest.h"
+#include "gettext.h"
+
+#include "frontends/LyXView.h"
+
+#include "support/convert.h"
+
+using std::string;
+
+
+class Buffer;
+
+namespace lyx {
+namespace frontend {
+
+
+ControlToc::ControlToc(Dialog & d)
+       : ControlCommand(d, "tableofcontents", "toc")
+{
+}
+
+
+TocList const & ControlToc::tocs() const
+{
+       return kernel().buffer().tocBackend().tocs();
+}
+
+
+bool ControlToc::initialiseParams(string const & data)
+{
+       if (!ControlCommand::initialiseParams(data))
+               return false;
+
+       types_.clear();
+       type_names_.clear();
+       TocList const & tocs = kernel().buffer().tocBackend().tocs();
+       TocList::const_iterator it = tocs.begin();
+       TocList::const_iterator end = tocs.end();
+       for (; it != end; ++it) {
+               types_.push_back(it->first);
+               type_names_.push_back(getGuiName(it->first));
+       }
+
+       string selected_type ;
+       if(params()["type"].empty()) //Then plain toc...
+               selected_type = params().getCmdName();
+       else
+               selected_type = to_ascii(params()["type"]);
+       selected_type_ = -1;
+       for (size_t i = 0;  i != types_.size(); ++i) {
+               if (selected_type == types_[i]) {
+                       selected_type_ = i;
+                       break;
+               }
+       }
+
+       return true;
+}
+
+void ControlToc::goTo(TocItem const & item)
+{
+       string const tmp = convert<string>(item.id());
+       kernel().lyxview().dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, tmp));
+}
+
+
+bool ControlToc::canOutline(size_t type) const
+{
+       return types_[type] == "tableofcontents";
+}
+
+
+void ControlToc::outlineUp()
+{
+       kernel().dispatch(FuncRequest(LFUN_OUTLINE_UP));
+}
+
+
+void ControlToc::outlineDown()
+{
+       kernel().dispatch(FuncRequest(LFUN_OUTLINE_DOWN));
+}
+
+
+void ControlToc::outlineIn()
+{
+       kernel().dispatch(FuncRequest(LFUN_OUTLINE_IN));
+}
+
+
+void ControlToc::outlineOut()
+{
+       kernel().dispatch(FuncRequest(LFUN_OUTLINE_OUT));
+}
+
+
+void ControlToc::updateBackend()
+{
+       kernel().buffer().tocBackend().update();
+}
+
+
+TocIterator const ControlToc::getCurrentTocItem(size_t type) const
+{
+       BOOST_ASSERT(kernel().bufferview());
+       ParConstIterator it(kernel().bufferview()->cursor());
+       return kernel().buffer().tocBackend().item(types_[type], it);
+}
+
+
+docstring const ControlToc::getGuiName(string const & type) const
+{
+       if (type == "tableofcontents")
+               return _("Table of Contents");
+
+       FloatList const & floats =
+               kernel().buffer().params().getLyXTextClass().floats();
+       if (floats.typeExist(type))
+               return from_utf8(floats.getType(type).name());
+       else
+               return _(type);
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlVSpace.C b/src/frontends/controllers/ControlVSpace.C
deleted file mode 100644 (file)
index 8bd8db8..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * \file ControlVSpace.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Edwin Leuven
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlVSpace.h"
-#include "ButtonController.h"
-
-#include "funcrequest.h"
-#include "insets/InsetVSpace.h"
-
-
-using std::istringstream;
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-ControlVSpace::ControlVSpace(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-bool ControlVSpace::initialiseParams(string const & data)
-{
-       InsetVSpaceMailer::string2params(data, params_);
-
-       // so that the user can press Ok
-       dialog().bc().valid();
-
-       return true;
-}
-
-
-void ControlVSpace::clearParams()
-{
-       params_ = VSpace();
-}
-
-
-void ControlVSpace::dispatchParams()
-{
-       string const str = InsetVSpaceMailer::params2string(params_);
-       kernel().dispatch(FuncRequest(getLfun(), str));
-}
-
-
-VSpace & ControlVSpace::params()
-{
-       return params_;
-}
-
-
-VSpace const & ControlVSpace::params() const
-{
-       return params_;
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlVSpace.cpp b/src/frontends/controllers/ControlVSpace.cpp
new file mode 100644 (file)
index 0000000..8bd8db8
--- /dev/null
@@ -0,0 +1,68 @@
+/**
+ * \file ControlVSpace.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Edwin Leuven
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlVSpace.h"
+#include "ButtonController.h"
+
+#include "funcrequest.h"
+#include "insets/InsetVSpace.h"
+
+
+using std::istringstream;
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+ControlVSpace::ControlVSpace(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+bool ControlVSpace::initialiseParams(string const & data)
+{
+       InsetVSpaceMailer::string2params(data, params_);
+
+       // so that the user can press Ok
+       dialog().bc().valid();
+
+       return true;
+}
+
+
+void ControlVSpace::clearParams()
+{
+       params_ = VSpace();
+}
+
+
+void ControlVSpace::dispatchParams()
+{
+       string const str = InsetVSpaceMailer::params2string(params_);
+       kernel().dispatch(FuncRequest(getLfun(), str));
+}
+
+
+VSpace & ControlVSpace::params()
+{
+       return params_;
+}
+
+
+VSpace const & ControlVSpace::params() const
+{
+       return params_;
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlViewSource.C b/src/frontends/controllers/ControlViewSource.C
deleted file mode 100644 (file)
index 0471cfa..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * \file ControlViewSource.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Angus Leeming
- * \author Bo Peng
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlViewSource.h"
-#include "gettext.h"
-#include "support/types.h"
-#include "BufferView.h"
-#include "buffer.h"
-#include "cursor.h"
-#include <sstream>
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-ControlViewSource::ControlViewSource(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-bool ControlViewSource::initialiseParams(string const & /*source*/)
-{
-       return true;
-}
-
-docstring const ControlViewSource::updateContent(bool fullSource)
-{
-       // get the *top* level paragraphs that contain the cursor,
-       // or the selected text
-       lyx::pit_type par_begin;
-       lyx::pit_type par_end;
-
-       BufferView * view = kernel().bufferview();
-       if (!view->cursor().selection()) {
-               par_begin = view->cursor().bottom().pit();
-               par_end = par_begin;
-       } else {
-               par_begin = view->cursor().selectionBegin().bottom().pit();
-               par_end = view->cursor().selectionEnd().bottom().pit();
-       }
-       if (par_begin > par_end)
-               std::swap(par_begin, par_end);
-       lyx::odocstringstream ostr;
-       view->buffer()->getSourceCode(ostr, par_begin, par_end + 1, fullSource);
-       return ostr.str();
-}
-
-
-void ControlViewSource::clearParams()
-{
-}
-
-
-docstring const ControlViewSource::title() const
-{
-       string source_type;
-
-       Kernel::DocType doctype = kernel().docType();
-       switch (doctype) {
-       case Kernel::LATEX:
-               source_type = "LaTeX";
-               break;
-       case Kernel::DOCBOOK:
-               source_type = "DocBook";
-               break;
-       case Kernel::LITERATE:
-               source_type = "Literate";
-       default:
-               BOOST_ASSERT(false);
-       }
-       return _(source_type + " Source");
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlViewSource.cpp b/src/frontends/controllers/ControlViewSource.cpp
new file mode 100644 (file)
index 0000000..0471cfa
--- /dev/null
@@ -0,0 +1,87 @@
+/**
+ * \file ControlViewSource.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author Angus Leeming
+ * \author Bo Peng
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlViewSource.h"
+#include "gettext.h"
+#include "support/types.h"
+#include "BufferView.h"
+#include "buffer.h"
+#include "cursor.h"
+#include <sstream>
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+ControlViewSource::ControlViewSource(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+bool ControlViewSource::initialiseParams(string const & /*source*/)
+{
+       return true;
+}
+
+docstring const ControlViewSource::updateContent(bool fullSource)
+{
+       // get the *top* level paragraphs that contain the cursor,
+       // or the selected text
+       lyx::pit_type par_begin;
+       lyx::pit_type par_end;
+
+       BufferView * view = kernel().bufferview();
+       if (!view->cursor().selection()) {
+               par_begin = view->cursor().bottom().pit();
+               par_end = par_begin;
+       } else {
+               par_begin = view->cursor().selectionBegin().bottom().pit();
+               par_end = view->cursor().selectionEnd().bottom().pit();
+       }
+       if (par_begin > par_end)
+               std::swap(par_begin, par_end);
+       lyx::odocstringstream ostr;
+       view->buffer()->getSourceCode(ostr, par_begin, par_end + 1, fullSource);
+       return ostr.str();
+}
+
+
+void ControlViewSource::clearParams()
+{
+}
+
+
+docstring const ControlViewSource::title() const
+{
+       string source_type;
+
+       Kernel::DocType doctype = kernel().docType();
+       switch (doctype) {
+       case Kernel::LATEX:
+               source_type = "LaTeX";
+               break;
+       case Kernel::DOCBOOK:
+               source_type = "DocBook";
+               break;
+       case Kernel::LITERATE:
+               source_type = "Literate";
+       default:
+               BOOST_ASSERT(false);
+       }
+       return _(source_type + " Source");
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/ControlWrap.C b/src/frontends/controllers/ControlWrap.C
deleted file mode 100644 (file)
index a297c08..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * \file ControlWrap.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Dekel Tsur
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlWrap.h"
-#include "funcrequest.h"
-#include "insets/InsetWrap.h"
-
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-ControlWrap::ControlWrap(Dialog & parent)
-       : Dialog::Controller(parent)
-{}
-
-
-bool ControlWrap::initialiseParams(string const & data)
-{
-       InsetWrapParams params;
-       InsetWrapMailer::string2params(data, params);
-       params_.reset(new InsetWrapParams(params));
-       return true;
-}
-
-
-void ControlWrap::clearParams()
-{
-       params_.reset();
-}
-
-
-void ControlWrap::dispatchParams()
-{
-       string const lfun = InsetWrapMailer::params2string(params());
-       kernel().dispatch(FuncRequest(getLfun(), lfun));
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/ControlWrap.cpp b/src/frontends/controllers/ControlWrap.cpp
new file mode 100644 (file)
index 0000000..a297c08
--- /dev/null
@@ -0,0 +1,50 @@
+/**
+ * \file ControlWrap.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Dekel Tsur
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "ControlWrap.h"
+#include "funcrequest.h"
+#include "insets/InsetWrap.h"
+
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+ControlWrap::ControlWrap(Dialog & parent)
+       : Dialog::Controller(parent)
+{}
+
+
+bool ControlWrap::initialiseParams(string const & data)
+{
+       InsetWrapParams params;
+       InsetWrapMailer::string2params(data, params);
+       params_.reset(new InsetWrapParams(params));
+       return true;
+}
+
+
+void ControlWrap::clearParams()
+{
+       params_.reset();
+}
+
+
+void ControlWrap::dispatchParams()
+{
+       string const lfun = InsetWrapMailer::params2string(params());
+       kernel().dispatch(FuncRequest(getLfun(), lfun));
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/Dialog.C b/src/frontends/controllers/Dialog.C
deleted file mode 100644 (file)
index 6c0aee8..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-/**
- * \file Dialog.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "Dialog.h"
-
-#include "ButtonController.h"
-#include "BCView.h"
-
-#include "frontends/LyXView.h"
-
-#include "funcrequest.h"
-#include "FuncStatus.h"
-#include "lyxfunc.h"
-
-using lyx::docstring;
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-Dialog::Dialog(LyXView & lv, string const & name)
-       : is_closing_(false), kernel_(lv), name_(name),
-         bc_ptr_(new ButtonController)
-{}
-
-
-Dialog::~Dialog()
-{}
-
-
-void Dialog::ApplyButton()
-{
-       apply();
-       bc().apply();
-}
-
-
-void Dialog::OKButton()
-{
-       is_closing_ = true;
-       apply();
-       is_closing_ = false;
-       hide();
-       bc().ok();
-}
-
-
-void Dialog::CancelButton()
-{
-       hide();
-       bc().cancel();
-}
-
-
-void Dialog::RestoreButton()
-{
-       // Tell the kernel that a request to refresh the dialog's contents
-       // has been received. It's up to the kernel to supply the necessary
-       // info by calling Dialog::update().
-       kernel().updateDialog(name_);
-       bc().restore();
-}
-
-
-void Dialog::show(string const & data)
-{
-       if (controller().isBufferDependent() && !kernel().isBufferAvailable())
-               return;
-
-       if (!controller().initialiseParams(data)) {
-               lyxerr << "Dialog \"" << name_
-                      << "\" failed to translate the data "
-                       "string passed to show()" << std::endl;
-               return;
-       }
-
-       bc().readOnly(kernel().isBufferReadonly());
-       view().show();
-
-       // The widgets may not be valid, so refresh the button controller
-       bc().refresh();
-}
-
-
-void Dialog::update(string const & data)
-{
-       if (controller().isBufferDependent() && !kernel().isBufferAvailable())
-               return;
-
-       if (!controller().initialiseParams(data)) {
-               lyxerr << "Dialog \"" << name_
-                      << "\" could not be initialized" << std::endl;
-               return;
-       }
-
-       bc().readOnly(kernel().isBufferReadonly());
-       view().update();
-
-       // The widgets may not be valid, so refresh the button controller
-       bc().refresh();
-}
-
-
-void Dialog::hide()
-{
-       if (!view().isVisible())
-               return;
-
-       controller().clearParams();
-       view().hide();
-       kernel().disconnect(name());
-}
-
-
-void Dialog::apply()
-{
-       if (controller().isBufferDependent()) {
-               if (!kernel().isBufferAvailable() ||
-                   kernel().isBufferReadonly())
-                       return;
-       }
-
-       view().apply();
-       controller().dispatchParams();
-
-       if (controller().disconnectOnApply() && !is_closing_) {
-               kernel().disconnect(name());
-               controller().initialiseParams(string());
-               view().update();
-       }
-}
-
-
-bool Dialog::isVisible() const
-{
-       return view().isVisible();
-}
-
-
-void Dialog::redraw()
-{
-       view().redraw();
-}
-
-
-ButtonController & Dialog::bc() const
-{
-       BOOST_ASSERT(bc_ptr_.get());
-       return *bc_ptr_.get();
-}
-
-
-void Dialog::setController(Controller * i)
-{
-       BOOST_ASSERT(i && !controller_ptr_.get());
-       controller_ptr_.reset(i);
-}
-
-
-void Dialog::setView(View * v)
-{
-       BOOST_ASSERT(v && !view_ptr_.get());
-       view_ptr_.reset(v);
-}
-
-
-void Dialog::checkStatus()
-{
-       // buffer independant dialogs are always active.
-       // This check allows us leave canApply unimplemented for some dialogs.
-       if (!controller().isBufferDependent())
-               return;
-
-       // deactivate the dialog if we have no buffer
-       if (!kernel().isBufferAvailable()) {
-               bc().readOnly(true);
-               return;
-       }
-
-       // check whether this dialog may be active
-       if (controller().canApply()) {
-               bool const readonly = kernel().isBufferReadonly();
-               bc().readOnly(readonly);
-               // refreshReadOnly() is too generous in _enabling_ widgets
-               // update dialog to disable disabled widgets again
-               if (!readonly)
-                       view().update();
-       } else
-               bc().readOnly(true);
-}
-
-
-Dialog::Controller::Controller(Dialog & parent)
-       : parent_(parent)
-{}
-
-
-bool Dialog::Controller::canApply() const
-{
-       FuncRequest const fr(getLfun(), dialog().name());
-       FuncStatus const fs(lyx::getStatus(fr));
-       return fs.enabled();
-}
-
-
-Dialog::Controller & Dialog::controller() const
-{
-       BOOST_ASSERT(controller_ptr_.get());
-       return *controller_ptr_.get();
-}
-
-
-Dialog::View::View(Dialog & parent, docstring title) :
-       p_(parent), title_(title)
-{}
-
-
-Dialog::View & Dialog::view() const
-{
-       BOOST_ASSERT(view_ptr_.get());
-       return *view_ptr_.get();
-}
-
-
-void Dialog::View::setTitle(docstring const & newtitle)
-{
-       title_ = newtitle;
-}
-
-
-docstring const & Dialog::View::getTitle() const
-{
-       return title_;
-}
-
-
-void Dialog::View::partialUpdate(int)
-{}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/Dialog.cpp b/src/frontends/controllers/Dialog.cpp
new file mode 100644 (file)
index 0000000..6c0aee8
--- /dev/null
@@ -0,0 +1,251 @@
+/**
+ * \file Dialog.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "Dialog.h"
+
+#include "ButtonController.h"
+#include "BCView.h"
+
+#include "frontends/LyXView.h"
+
+#include "funcrequest.h"
+#include "FuncStatus.h"
+#include "lyxfunc.h"
+
+using lyx::docstring;
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+Dialog::Dialog(LyXView & lv, string const & name)
+       : is_closing_(false), kernel_(lv), name_(name),
+         bc_ptr_(new ButtonController)
+{}
+
+
+Dialog::~Dialog()
+{}
+
+
+void Dialog::ApplyButton()
+{
+       apply();
+       bc().apply();
+}
+
+
+void Dialog::OKButton()
+{
+       is_closing_ = true;
+       apply();
+       is_closing_ = false;
+       hide();
+       bc().ok();
+}
+
+
+void Dialog::CancelButton()
+{
+       hide();
+       bc().cancel();
+}
+
+
+void Dialog::RestoreButton()
+{
+       // Tell the kernel that a request to refresh the dialog's contents
+       // has been received. It's up to the kernel to supply the necessary
+       // info by calling Dialog::update().
+       kernel().updateDialog(name_);
+       bc().restore();
+}
+
+
+void Dialog::show(string const & data)
+{
+       if (controller().isBufferDependent() && !kernel().isBufferAvailable())
+               return;
+
+       if (!controller().initialiseParams(data)) {
+               lyxerr << "Dialog \"" << name_
+                      << "\" failed to translate the data "
+                       "string passed to show()" << std::endl;
+               return;
+       }
+
+       bc().readOnly(kernel().isBufferReadonly());
+       view().show();
+
+       // The widgets may not be valid, so refresh the button controller
+       bc().refresh();
+}
+
+
+void Dialog::update(string const & data)
+{
+       if (controller().isBufferDependent() && !kernel().isBufferAvailable())
+               return;
+
+       if (!controller().initialiseParams(data)) {
+               lyxerr << "Dialog \"" << name_
+                      << "\" could not be initialized" << std::endl;
+               return;
+       }
+
+       bc().readOnly(kernel().isBufferReadonly());
+       view().update();
+
+       // The widgets may not be valid, so refresh the button controller
+       bc().refresh();
+}
+
+
+void Dialog::hide()
+{
+       if (!view().isVisible())
+               return;
+
+       controller().clearParams();
+       view().hide();
+       kernel().disconnect(name());
+}
+
+
+void Dialog::apply()
+{
+       if (controller().isBufferDependent()) {
+               if (!kernel().isBufferAvailable() ||
+                   kernel().isBufferReadonly())
+                       return;
+       }
+
+       view().apply();
+       controller().dispatchParams();
+
+       if (controller().disconnectOnApply() && !is_closing_) {
+               kernel().disconnect(name());
+               controller().initialiseParams(string());
+               view().update();
+       }
+}
+
+
+bool Dialog::isVisible() const
+{
+       return view().isVisible();
+}
+
+
+void Dialog::redraw()
+{
+       view().redraw();
+}
+
+
+ButtonController & Dialog::bc() const
+{
+       BOOST_ASSERT(bc_ptr_.get());
+       return *bc_ptr_.get();
+}
+
+
+void Dialog::setController(Controller * i)
+{
+       BOOST_ASSERT(i && !controller_ptr_.get());
+       controller_ptr_.reset(i);
+}
+
+
+void Dialog::setView(View * v)
+{
+       BOOST_ASSERT(v && !view_ptr_.get());
+       view_ptr_.reset(v);
+}
+
+
+void Dialog::checkStatus()
+{
+       // buffer independant dialogs are always active.
+       // This check allows us leave canApply unimplemented for some dialogs.
+       if (!controller().isBufferDependent())
+               return;
+
+       // deactivate the dialog if we have no buffer
+       if (!kernel().isBufferAvailable()) {
+               bc().readOnly(true);
+               return;
+       }
+
+       // check whether this dialog may be active
+       if (controller().canApply()) {
+               bool const readonly = kernel().isBufferReadonly();
+               bc().readOnly(readonly);
+               // refreshReadOnly() is too generous in _enabling_ widgets
+               // update dialog to disable disabled widgets again
+               if (!readonly)
+                       view().update();
+       } else
+               bc().readOnly(true);
+}
+
+
+Dialog::Controller::Controller(Dialog & parent)
+       : parent_(parent)
+{}
+
+
+bool Dialog::Controller::canApply() const
+{
+       FuncRequest const fr(getLfun(), dialog().name());
+       FuncStatus const fs(lyx::getStatus(fr));
+       return fs.enabled();
+}
+
+
+Dialog::Controller & Dialog::controller() const
+{
+       BOOST_ASSERT(controller_ptr_.get());
+       return *controller_ptr_.get();
+}
+
+
+Dialog::View::View(Dialog & parent, docstring title) :
+       p_(parent), title_(title)
+{}
+
+
+Dialog::View & Dialog::view() const
+{
+       BOOST_ASSERT(view_ptr_.get());
+       return *view_ptr_.get();
+}
+
+
+void Dialog::View::setTitle(docstring const & newtitle)
+{
+       title_ = newtitle;
+}
+
+
+docstring const & Dialog::View::getTitle() const
+{
+       return title_;
+}
+
+
+void Dialog::View::partialUpdate(int)
+{}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/Kernel.C b/src/frontends/controllers/Kernel.C
deleted file mode 100644 (file)
index 235458c..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * \file Kernel.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "Kernel.h"
-
-#include "buffer.h"
-#include "BufferView.h"
-#include "funcrequest.h"
-#include "lyxfunc.h"
-#include "frontends/Dialogs.h"
-#include "frontends/LyXView.h"
-
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-Kernel::Kernel(LyXView & lyxview)
-       : lyxview_(lyxview)
-{}
-
-
-void Kernel::dispatch(FuncRequest const & fr) const
-{
-       lyxview_.dispatch(fr);
-}
-
-
-void Kernel::updateDialog(string const & name) const
-{
-       dispatch(FuncRequest(LFUN_DIALOG_UPDATE, name));
-}
-
-
-void Kernel::disconnect(string const & name) const
-{
-       lyxview_.getDialogs().disconnect(name);
-}
-
-bool Kernel::isBufferAvailable() const
-{
-       if (!lyxview_.view())
-               return false;
-       return lyxview_.view()->buffer() != 0;
-}
-
-
-bool Kernel::isBufferReadonly() const
-{
-       if (!lyxview_.buffer())
-               return true;
-       return lyxview_.buffer()->isReadonly();
-}
-
-
-string const Kernel::bufferFilepath() const
-{
-       return buffer().filePath();
-}
-
-
-Kernel::DocType Kernel::docType() const
-{
-       if (buffer().isLatex())
-               return LATEX;
-       if (buffer().isLiterate())
-               return LITERATE;
-
-       return DOCBOOK;
-}
-
-
-BufferView * Kernel::bufferview()
-{
-       return lyxview_.view();
-}
-
-
-BufferView const * Kernel::bufferview() const
-{
-       return lyxview_.view();
-}
-
-
-Buffer & Kernel::buffer()
-{
-       BOOST_ASSERT(lyxview_.buffer());
-       return *lyxview_.buffer();
-}
-
-
-Buffer const & Kernel::buffer() const
-{
-       BOOST_ASSERT(lyxview_.buffer());
-       return *lyxview_.buffer();
-}
-
-} // namespace frontend
-} // namespace lyx
diff --git a/src/frontends/controllers/Kernel.cpp b/src/frontends/controllers/Kernel.cpp
new file mode 100644 (file)
index 0000000..235458c
--- /dev/null
@@ -0,0 +1,109 @@
+/**
+ * \file Kernel.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "Kernel.h"
+
+#include "buffer.h"
+#include "BufferView.h"
+#include "funcrequest.h"
+#include "lyxfunc.h"
+#include "frontends/Dialogs.h"
+#include "frontends/LyXView.h"
+
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
+
+Kernel::Kernel(LyXView & lyxview)
+       : lyxview_(lyxview)
+{}
+
+
+void Kernel::dispatch(FuncRequest const & fr) const
+{
+       lyxview_.dispatch(fr);
+}
+
+
+void Kernel::updateDialog(string const & name) const
+{
+       dispatch(FuncRequest(LFUN_DIALOG_UPDATE, name));
+}
+
+
+void Kernel::disconnect(string const & name) const
+{
+       lyxview_.getDialogs().disconnect(name);
+}
+
+bool Kernel::isBufferAvailable() const
+{
+       if (!lyxview_.view())
+               return false;
+       return lyxview_.view()->buffer() != 0;
+}
+
+
+bool Kernel::isBufferReadonly() const
+{
+       if (!lyxview_.buffer())
+               return true;
+       return lyxview_.buffer()->isReadonly();
+}
+
+
+string const Kernel::bufferFilepath() const
+{
+       return buffer().filePath();
+}
+
+
+Kernel::DocType Kernel::docType() const
+{
+       if (buffer().isLatex())
+               return LATEX;
+       if (buffer().isLiterate())
+               return LITERATE;
+
+       return DOCBOOK;
+}
+
+
+BufferView * Kernel::bufferview()
+{
+       return lyxview_.view();
+}
+
+
+BufferView const * Kernel::bufferview() const
+{
+       return lyxview_.view();
+}
+
+
+Buffer & Kernel::buffer()
+{
+       BOOST_ASSERT(lyxview_.buffer());
+       return *lyxview_.buffer();
+}
+
+
+Buffer const & Kernel::buffer() const
+{
+       BOOST_ASSERT(lyxview_.buffer());
+       return *lyxview_.buffer();
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/controllers/tests/biblio.C b/src/frontends/controllers/tests/biblio.C
deleted file mode 100644 (file)
index 6fe25a3..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-#include <config.h>
-
-#include <iostream>
-#include <map>
-
-#include <boost/regex.hpp>
-
-
-using std::cout;
-using std::endl;
-using std::string;
-
-// Escape special chars.
-// All characters are literals except: '.|*?+(){}[]^$\'
-// These characters are literals when preceded by a "\", which is done here
-// This function is unfortunately copied from ../frontend_helpers.cpp, so we should
-// try to make sure to keep the two in sync.
-string const escape_special_chars(string const & expr)
-{
-       // Search for all chars '.|*?+(){}[^$]\'
-       // Note that '[' and '\' must be escaped.
-       // This is a limitation of boost::regex, but all other chars in BREs
-       // are assumed literal.
-       boost::regex reg("[].|*?+(){}^$\\[\\\\]");
-
-       // $& is a perl-like expression that expands to all of the current match
-       // The '$' must be prefixed with the escape character '\' for
-       // boost to treat it as a literal.
-       // Thus, to prefix a matched expression with '\', we use:
-       return boost::regex_replace(expr, reg, "\\\\$&");
-}
-
-
-typedef std::map<string, string> InfoMap;
-
-// A functor for use with std::find_if, used to ascertain whether a
-// data entry matches the required regex_
-// This class is unfortunately copied from ../frontend_helpers.cpp, so we should
-// try to make sure to keep the two in sync.
-class RegexMatch : public std::unary_function<string, bool>
-{
-public:
-       // re and icase are used to construct an instance of boost::RegEx.
-       // if icase is true, then matching is insensitive to case
-       RegexMatch(InfoMap const & m, string const & re, bool icase)
-               : map_(m), regex_(re, icase) {}
-
-       bool operator()(string const & key) const {
-               // the data searched is the key + its associated BibTeX/biblio
-               // fields
-               string data = key;
-               InfoMap::const_iterator info = map_.find(key);
-               if (info != map_.end())
-                       data += ' ' + info->second;
-
-               // Attempts to find a match for the current RE
-               // somewhere in data.
-               return boost::regex_search(data, regex_);
-       }
-private:
-       InfoMap const map_;
-       mutable boost::regex regex_;
-};
-
-
-void test_escape_special_chars()
-{
-       cout << escape_special_chars("abcd") << endl;
-       cout << escape_special_chars("ab&cd") << endl;
-       cout << escape_special_chars(".|*?+(){}[]^$\"") << endl;
-       cout << escape_special_chars("..||**??++(()){{}}[[]]^^$$\\\\") << endl;
-}
-
-
-void test_RegexMatch()
-{
-       InfoMap im;
-       im["hello"] = "hei";
-
-       try {
-               RegexMatch rm(im, "h.*o", false);
-               
-               cout << rm("hello") << endl;
-               cout << rm("hei") << endl;
-       }
-       catch (boost::regex_error & regerr) {
-               cout << regerr.what() << endl;
-       }
-}
-
-
-int main()
-{
-       test_escape_special_chars();
-       test_RegexMatch();
-}
diff --git a/src/frontends/controllers/tests/biblio.cpp b/src/frontends/controllers/tests/biblio.cpp
new file mode 100644 (file)
index 0000000..6fe25a3
--- /dev/null
@@ -0,0 +1,96 @@
+#include <config.h>
+
+#include <iostream>
+#include <map>
+
+#include <boost/regex.hpp>
+
+
+using std::cout;
+using std::endl;
+using std::string;
+
+// Escape special chars.
+// All characters are literals except: '.|*?+(){}[]^$\'
+// These characters are literals when preceded by a "\", which is done here
+// This function is unfortunately copied from ../frontend_helpers.cpp, so we should
+// try to make sure to keep the two in sync.
+string const escape_special_chars(string const & expr)
+{
+       // Search for all chars '.|*?+(){}[^$]\'
+       // Note that '[' and '\' must be escaped.
+       // This is a limitation of boost::regex, but all other chars in BREs
+       // are assumed literal.
+       boost::regex reg("[].|*?+(){}^$\\[\\\\]");
+
+       // $& is a perl-like expression that expands to all of the current match
+       // The '$' must be prefixed with the escape character '\' for
+       // boost to treat it as a literal.
+       // Thus, to prefix a matched expression with '\', we use:
+       return boost::regex_replace(expr, reg, "\\\\$&");
+}
+
+
+typedef std::map<string, string> InfoMap;
+
+// A functor for use with std::find_if, used to ascertain whether a
+// data entry matches the required regex_
+// This class is unfortunately copied from ../frontend_helpers.cpp, so we should
+// try to make sure to keep the two in sync.
+class RegexMatch : public std::unary_function<string, bool>
+{
+public:
+       // re and icase are used to construct an instance of boost::RegEx.
+       // if icase is true, then matching is insensitive to case
+       RegexMatch(InfoMap const & m, string const & re, bool icase)
+               : map_(m), regex_(re, icase) {}
+
+       bool operator()(string const & key) const {
+               // the data searched is the key + its associated BibTeX/biblio
+               // fields
+               string data = key;
+               InfoMap::const_iterator info = map_.find(key);
+               if (info != map_.end())
+                       data += ' ' + info->second;
+
+               // Attempts to find a match for the current RE
+               // somewhere in data.
+               return boost::regex_search(data, regex_);
+       }
+private:
+       InfoMap const map_;
+       mutable boost::regex regex_;
+};
+
+
+void test_escape_special_chars()
+{
+       cout << escape_special_chars("abcd") << endl;
+       cout << escape_special_chars("ab&cd") << endl;
+       cout << escape_special_chars(".|*?+(){}[]^$\"") << endl;
+       cout << escape_special_chars("..||**??++(()){{}}[[]]^^$$\\\\") << endl;
+}
+
+
+void test_RegexMatch()
+{
+       InfoMap im;
+       im["hello"] = "hei";
+
+       try {
+               RegexMatch rm(im, "h.*o", false);
+               
+               cout << rm("hello") << endl;
+               cout << rm("hei") << endl;
+       }
+       catch (boost::regex_error & regerr) {
+               cout << regerr.what() << endl;
+       }
+}
+
+
+int main()
+{
+       test_escape_special_chars();
+       test_RegexMatch();
+}
diff --git a/src/frontends/controllers/tests/boost.C b/src/frontends/controllers/tests/boost.C
deleted file mode 100644 (file)
index d8f4a94..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * \file boost.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Lars Gullik Bjønnes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include <boost/assert.hpp>
-
-#include <cstdlib>
-#include <exception>
-
-
-namespace boost {
-
-void throw_exception(std::exception const & /*e*/)
-{
-       BOOST_ASSERT(false);
-}
-
-
-void assertion_failed(char const * /*expr*/, char const * /*function*/,
-                     char const * /*file*/, long /*line*/)
-{
-       ::abort();
-}
-
-
-}
diff --git a/src/frontends/controllers/tests/boost.cpp b/src/frontends/controllers/tests/boost.cpp
new file mode 100644 (file)
index 0000000..d8f4a94
--- /dev/null
@@ -0,0 +1,34 @@
+/**
+ * \file boost.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include <boost/assert.hpp>
+
+#include <cstdlib>
+#include <exception>
+
+
+namespace boost {
+
+void throw_exception(std::exception const & /*e*/)
+{
+       BOOST_ASSERT(false);
+}
+
+
+void assertion_failed(char const * /*expr*/, char const * /*function*/,
+                     char const * /*file*/, long /*line*/)
+{
+       ::abort();
+}
+
+
+}