]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormInclude.C
get rid of broken_header.h and some unneeded tests
[lyx.git] / src / frontends / xforms / FormInclude.C
index e51ca031d3731e5de8a7b5b0fee01037e139704b..57bbb468e5fab34ad7f0fc43344aae83e535dec6 100644 (file)
@@ -7,25 +7,31 @@
  * \author John Levon
  * \author Angus Leeming
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
-#include <algorithm>
 
-
-#include "debug.h"
-
-#include "xformsBC.h"
-#include "ControlInclude.h"
 #include "FormInclude.h"
+#include "ControlInclude.h"
 #include "forms/form_include.h"
-#include "insets/insetinclude.h"
+
 #include "Tooltips.h"
 #include "xforms_helpers.h" // setEnabled
+#include "xformsBC.h"
+
 #include "support/lstrings.h" // strip
+
 #include "lyx_forms.h"
 
+using std::string;
+
+namespace lyx {
+
+using support::rtrim;
+
+namespace frontend {
+
 typedef FormController<ControlInclude, FormView<FD_include> > base_class;
 
 FormInclude::FormInclude(Dialog & parent)
@@ -78,9 +84,9 @@ void FormInclude::build()
 
 void FormInclude::update()
 {
-       string const filename = controller().params().cparams.getContents();
-       string const cmdname = controller().params().cparams.getCmdName();
-       bool const preview = static_cast<bool>((controller().params().cparams.preview()));
+       string const filename = controller().params().getContents();
+       string const cmdname = controller().params().getCmdName();
+       bool const preview = static_cast<bool>((controller().params().preview()));
 
        fl_set_input(dialog_->input_filename, filename.c_str());
 
@@ -113,26 +119,21 @@ void FormInclude::update()
 
 void FormInclude::apply()
 {
-       InsetInclude::Params params = controller().params();
-
-       params.cparams.preview(fl_get_button(dialog_->check_preview));
+       InsetCommandParams params = controller().params();
 
-       string const file = fl_get_input(dialog_->input_filename);
-       if (controller().fileExists(file))
-               params.cparams.setContents(file);
-       else
-               params.cparams.setContents("");
+       params.preview(fl_get_button(dialog_->check_preview));
+       params.setContents(getString(dialog_->input_filename));
 
        ControlInclude::Type const type = ControlInclude::Type(type_.get());
        if (type == ControlInclude::INPUT)
-               params.flag = InsetInclude::INPUT;
+               params.setCmdName("input");
        else if (type == ControlInclude::INCLUDE)
-               params.flag = InsetInclude::INCLUDE;
+               params.setCmdName("include");
        else if (type == ControlInclude::VERBATIM) {
                if (fl_get_button(dialog_->check_visiblespace))
-                       params.flag = InsetInclude::VERBAST;
+                       params.setCmdName("verbatiminput*");
                else
-                       params.flag = InsetInclude::VERB;
+                       params.setCmdName("verbatiminput");
        }
 
        controller().setParams(params);
@@ -144,15 +145,15 @@ ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
        ButtonPolicy::SMInput action = ButtonPolicy::SMI_VALID;
 
        if (ob == dialog_->button_browse) {
-               string const in_name = fl_get_input(dialog_->input_filename);
+               string const in_name = getString(dialog_->input_filename);
                fl_freeze_form(form());
                ControlInclude::Type const type = ControlInclude::Type(type_.get());
-               string const out_name = controller().Browse(in_name, type);
+               string const out_name = controller().browse(in_name, type);
                fl_set_input(dialog_->input_filename, out_name.c_str());
                fl_unfreeze_form(form());
 
        } else if (ob == dialog_->button_load) {
-               string const in_name = fl_get_input(dialog_->input_filename);
+               string const in_name = getString(dialog_->input_filename);
                if (!rtrim(in_name).empty() && controller().fileExists(in_name)) {
                        dialog().OKButton();
                        controller().load(rtrim(in_name));
@@ -170,7 +171,7 @@ ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
                setEnabled(dialog_->button_load, true);
 
        } else if (ob == dialog_->input_filename) {
-               string const in_name = fl_get_input(dialog_->input_filename);
+               string const in_name = getString(dialog_->input_filename);
                if (rtrim(in_name).empty())
                        action = ButtonPolicy::SMI_INVALID;
        }
@@ -185,3 +186,6 @@ ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
 
        return action;
 }
+
+} // namespace frontend
+} // namespace lyx