]> 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 561e530d9fa129985833fbd6a951a3c27faaa899..57bbb468e5fab34ad7f0fc43344aae83e535dec6 100644 (file)
 
 #include "lyx_forms.h"
 
-using lyx::support::rtrim;
+using std::string;
 
+namespace lyx {
+
+using support::rtrim;
+
+namespace frontend {
 
 typedef FormController<ControlInclude, FormView<FD_include> > base_class;
 
@@ -79,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());
 
@@ -114,26 +119,21 @@ void FormInclude::update()
 
 void FormInclude::apply()
 {
-       InsetInclude::Params params = controller().params();
+       InsetCommandParams params = controller().params();
 
-       params.cparams.preview(fl_get_button(dialog_->check_preview));
-
-       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);
@@ -145,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));
@@ -171,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;
        }
@@ -186,3 +186,6 @@ ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
 
        return action;
 }
+
+} // namespace frontend
+} // namespace lyx