From b9655a2d250df017263edfa5b8c56c14672130ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Wed, 4 Apr 2001 21:58:35 +0000 Subject: [PATCH] adjust for scoped_ptr, constify git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1895 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/xforms/ChangeLog | 8 ++++++++ src/frontends/xforms/FormTabular.C | 27 +++++++++++++-------------- src/frontends/xforms/xforms_helpers.C | 16 +++++++++------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index ea9729d47a..75697cbc37 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,11 @@ +2001-04-05 Lars Gullik Bjønnes + + * xforms_helpers.C (formatted): constify length + + * FormTabular.C (update): small restructure, adjust for scoped_ptr + (input): adjust for scoped_ptr + (input): constify str + 2001-04-03 John Levon * Dialogs.C: s/popup/dialog/ diff --git a/src/frontends/xforms/FormTabular.C b/src/frontends/xforms/FormTabular.C index e83643edde..03ad4a6616 100644 --- a/src/frontends/xforms/FormTabular.C +++ b/src/frontends/xforms/FormTabular.C @@ -128,19 +128,17 @@ void FormTabular::build() void FormTabular::update() { - if (!inset_ || !inset_->tabular) + if (!inset_ || !inset_->tabular.get()) return; - LyXTabular * tabular = inset_->tabular; - int - align, - cell; - char - buf[12]; - string - pwidth, special; + LyXTabular * tabular = inset_->tabular.get(); + int align; + char buf[12]; + string pwidth; + string special; - actCell_ = cell = inset_->GetActCell(); + int cell = inset_->GetActCell(); + actCell_ = cell; int column = tabular->column_of_cell(cell)+1; fl_set_object_label(dialog_->text_warning,""); fl_activate_object(column_options_->input_special_alignment); @@ -346,12 +344,13 @@ void FormTabular::update() tabular->GetRotateTabular()); } + bool FormTabular::input(FL_OBJECT * ob, long) { if (!inset_) return false; - LyXTabular * tabular = inset_->tabular; + LyXTabular * tabular = inset_->tabular.get(); int s; LyXTabular::Feature num = LyXTabular::LAST_ACTION; string special;; @@ -371,7 +370,7 @@ bool FormTabular::input(FL_OBJECT * ob, long) return false; } if (ob == column_options_->input_column_width) { - string str = fl_get_input(ob); + string const str = fl_get_input(ob); if (!str.empty() && !isValidLength(str)) { fl_set_object_label(dialog_->text_warning, _("Warning: Invalid Length (valid example: 10mm)")); @@ -383,7 +382,7 @@ bool FormTabular::input(FL_OBJECT * ob, long) return true; } if (ob == cell_options_->input_mcolumn_width) { - string str = fl_get_input(ob); + string const str = fl_get_input(ob); if (!str.empty() && !isValidLength(str)) { fl_set_object_label(dialog_->text_warning, _("Warning: Invalid Length (valid example: 10mm)")); @@ -394,7 +393,7 @@ bool FormTabular::input(FL_OBJECT * ob, long) update(); // update for alignment return true; } - string str = fl_get_input(column_options_->input_column_width); + string const str = fl_get_input(column_options_->input_column_width); if (!str.empty() && !isValidLength(str)) { fl_set_object_label( dialog_->text_warning, diff --git a/src/frontends/xforms/xforms_helpers.C b/src/frontends/xforms/xforms_helpers.C index 87459b34f7..acbc4ce6d0 100644 --- a/src/frontends/xforms/xforms_helpers.C +++ b/src/frontends/xforms/xforms_helpers.C @@ -38,6 +38,7 @@ void setEnabled(FL_OBJECT * ob, bool enable) // Take a string and add breaks so that it fits into a desired label width, w string formatted(string const & sin, int w, int size, int style) { +#warning Why cant this be done by a one pass algo? (Lgb) string sout; if (sin.empty()) return sout; @@ -59,10 +60,11 @@ string formatted(string const & sin, int w, int size, int style) // Flush remaining contents of word if (!word.empty() ) sentence.push_back(word); - string line, line_plus_word; + string line; + string line_plus_word; for (vector::const_iterator vit = sentence.begin(); vit != sentence.end(); ++vit) { - string word = *vit; + string word(*vit); char c = word[0]; if (c == '\n') { @@ -75,9 +77,9 @@ string formatted(string const & sin, int w, int size, int style) if (!line_plus_word.empty() ) line_plus_word += ' '; line_plus_word += word; - int length = fl_get_string_width(style, size, - line_plus_word.c_str(), - int(line_plus_word.length())); + int const length = fl_get_string_width(style, size, + line_plus_word.c_str(), + int(line_plus_word.length())); if (length >= w) { sout += line + '\n'; line_plus_word = word; @@ -90,8 +92,8 @@ string formatted(string const & sin, int w, int size, int style) sout += line; } - if (sout[sout.length()-1] == '\n') - sout.erase(sout.length()-1); + if (sout[sout.length() - 1] == '\n') + sout.erase(sout.length() - 1); return sout; }