- if (!inset_)
- return false;
-
- int s;
- LyXTabular::Feature num = LyXTabular::LAST_ACTION;
- string special;;
-
- int cell = inset_->getActCell();
-
- if (actCell_ != cell) {
- update();
- fl_set_object_label(dialog_->text_warning,
- _("Warning: Wrong Cursor position, updated window"));
- fl_show_object(dialog_->text_warning);
- return false;
- }
- // No point in processing directives that you can't do anything with
- // anyhow, so exit now if the buffer is read-only.
- if (lv_->buffer()->isReadonly()) {
- update();
- return false;
- }
- if ((ob == column_options_->input_column_width) ||
- (ob == column_options_->choice_value_column_width))
- {
- string const str =
- getLengthFromWidgets(column_options_->input_column_width,
- column_options_->choice_value_column_width);
- inset_->tabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH, str);
- update(); // update for alignment
- return true;
- }
- if ((ob == cell_options_->input_mcolumn_width) ||
- (ob == cell_options_->choice_value_mcolumn_width))
- {
- string const str =
- getLengthFromWidgets(cell_options_->input_mcolumn_width,
- cell_options_->choice_value_mcolumn_width);
- inset_->tabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH, str);
- update(); // update for alignment
- return true;
- }
-
- if (ob == tabular_options_->button_append_row)
- num = LyXTabular::APPEND_ROW;
- else if (ob == tabular_options_->button_append_column)
- num = LyXTabular::APPEND_COLUMN;
- else if (ob == tabular_options_->button_delete_row)
- num = LyXTabular::DELETE_ROW;
- else if (ob == tabular_options_->button_delete_column)
- num = LyXTabular::DELETE_COLUMN;
- else if (ob == tabular_options_->button_set_borders)
- num = LyXTabular::SET_ALL_LINES;
- else if (ob == tabular_options_->button_unset_borders)
- num = LyXTabular::UNSET_ALL_LINES;
- else if (ob == column_options_->radio_border_top)
- num = LyXTabular::TOGGLE_LINE_TOP;
- else if (ob == column_options_->radio_border_bottom)
- num = LyXTabular::TOGGLE_LINE_BOTTOM;
- else if (ob == column_options_->radio_border_left)
- num = LyXTabular::TOGGLE_LINE_LEFT;
- else if (ob == column_options_->radio_border_right)
- num = LyXTabular::TOGGLE_LINE_RIGHT;
- else if (ob == column_options_->radio_align_left)
- num = LyXTabular::ALIGN_LEFT;
- else if (ob == column_options_->radio_align_right)
- num = LyXTabular::ALIGN_RIGHT;
- else if (ob == column_options_->radio_align_center)
- num = LyXTabular::ALIGN_CENTER;
- else if (ob == column_options_->radio_valign_top)
- num = LyXTabular::VALIGN_TOP;
- else if (ob == column_options_->radio_valign_bottom)
- num = LyXTabular::VALIGN_BOTTOM;
- else if (ob == column_options_->radio_valign_center)
- num = LyXTabular::VALIGN_CENTER;
- else if (ob == cell_options_->radio_multicolumn)
- num = LyXTabular::MULTICOLUMN;
- else if (ob == tabular_options_->radio_longtable) {
- if (fl_get_button(tabular_options_->radio_longtable))
- num = LyXTabular::SET_LONGTABULAR;
+ int s;
+ LyXTabular::Feature num = LyXTabular::LAST_ACTION;
+ string special;
+
+ LyXTabular const & tabular = controller().tabular();
+
+ LyXTabular::idx_type const cell = controller().getActiveCell();
+
+ // ugly hack to auto-apply the stuff that hasn't been
+ // yet. don't let this continue to exist ...
+ if (ob == dialog_->button_close) {
+ closing_ = true;
+ string w1 =
+ getLengthFromWidgets(column_options_->input_column_width,
+ column_options_->choice_value_column_width);
+ string w2;
+ LyXLength llen = tabular.getColumnPWidth(cell);
+ if (!llen.zero())
+ w2 = llen.asString();
+
+ string mw1 = getLengthFromWidgets(cell_options_->input_mcolumn_width,
+ cell_options_->choice_value_mcolumn_width);
+ llen = tabular.getMColumnPWidth(cell);
+ string mw2;
+ if (llen.zero())
+ mw2 = "";
+ else
+ mw2 = llen.asString();
+
+ string al1 = getString(column_options_->input_special_alignment);
+ string al2 = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
+ string mal1 = getString(cell_options_->input_special_multialign);
+ string mal2 = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
+
+ // we must do these all at the end
+ if (w1 != w2)
+ input(column_options_->input_column_width, 0);
+ if (mw1 != mw2)
+ input(cell_options_->input_mcolumn_width, 0);
+ if (al1 != al2)
+ input(column_options_->input_special_alignment, 0);
+ if (mal1 != mal2)
+ input(cell_options_->input_special_multialign, 0);
+ closing_ = false;
+ dialog().OKButton();
+ return ButtonPolicy::SMI_VALID;
+ }
+
+ if (actCell_ != cell) {
+ update();
+ postWarning(_("Wrong Cursor position, updated window"));
+ return ButtonPolicy::SMI_VALID;
+ }
+
+ // No point in processing directives that you can't do anything with
+ // anyhow, so exit now if the buffer is read-only.
+ if (bc().bp().isReadOnly()) {
+ update();
+ return ButtonPolicy::SMI_VALID;
+ }
+
+ if ((ob == column_options_->input_column_width) ||
+ (ob == column_options_->choice_value_column_width)) {
+ string const str =
+ getLengthFromWidgets(column_options_->input_column_width,
+ column_options_->choice_value_column_width);
+ controller().set(LyXTabular::SET_PWIDTH, str);
+
+ //check if the input is valid
+ string const input = getString(column_options_->input_column_width);
+ if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
+ postWarning(_("Invalid Length (valid example: 10mm)"));
+ return ButtonPolicy::SMI_INVALID;
+ }
+
+ update(); // update for alignment
+ return ButtonPolicy::SMI_VALID;
+ }
+
+ if ((ob == cell_options_->input_mcolumn_width) ||
+ (ob == cell_options_->choice_value_mcolumn_width)) {
+ string const str =
+ getLengthFromWidgets(cell_options_->input_mcolumn_width,
+ cell_options_->choice_value_mcolumn_width);
+ controller().set(LyXTabular::SET_MPWIDTH, str);
+
+ //check if the input is valid
+ string const input = getString(cell_options_->input_mcolumn_width);
+ if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
+ postWarning(_("Invalid Length (valid example: 10mm)"));
+ return ButtonPolicy::SMI_INVALID;
+ }
+ update(); // update for alignment
+ return ButtonPolicy::SMI_VALID;
+ }
+
+ if (ob == tabular_options_->button_append_row)
+ num = LyXTabular::APPEND_ROW;
+ else if (ob == tabular_options_->button_append_column)
+ num = LyXTabular::APPEND_COLUMN;
+ else if (ob == tabular_options_->button_delete_row)
+ num = LyXTabular::DELETE_ROW;
+ else if (ob == tabular_options_->button_delete_column)
+ num = LyXTabular::DELETE_COLUMN;
+ else if (ob == tabular_options_->button_set_borders)
+ num = LyXTabular::SET_ALL_LINES;
+ else if (ob == tabular_options_->button_unset_borders)
+ num = LyXTabular::UNSET_ALL_LINES;
+ else if (ob == column_options_->check_border_top)
+ num = LyXTabular::TOGGLE_LINE_TOP;
+ else if (ob == column_options_->check_border_bottom)
+ num = LyXTabular::TOGGLE_LINE_BOTTOM;
+ else if (ob == column_options_->check_border_left)
+ num = LyXTabular::TOGGLE_LINE_LEFT;
+ else if (ob == column_options_->check_border_right)
+ num = LyXTabular::TOGGLE_LINE_RIGHT;
+ else if (ob == column_options_->radio_align_left)
+ num = LyXTabular::ALIGN_LEFT;
+ else if (ob == column_options_->radio_align_right)
+ num = LyXTabular::ALIGN_RIGHT;
+ else if (ob == column_options_->radio_align_center)
+ num = LyXTabular::ALIGN_CENTER;
+ else if (ob == column_options_->radio_align_block)
+ num = LyXTabular::ALIGN_BLOCK;
+ else if (ob == column_options_->radio_valign_top)
+ num = LyXTabular::VALIGN_TOP;
+ else if (ob == column_options_->radio_valign_bottom)
+ num = LyXTabular::VALIGN_BOTTOM;
+ else if (ob == column_options_->radio_valign_middle)
+ num = LyXTabular::VALIGN_MIDDLE;
+ else if (ob == cell_options_->check_multicolumn)
+ num = LyXTabular::MULTICOLUMN;
+ else if (ob == tabular_options_->check_longtable) {
+ if (fl_get_button(tabular_options_->check_longtable))
+ num = LyXTabular::SET_LONGTABULAR;