diff --git a/src/ChangeLog b/src/ChangeLog index 3216f9355f..24255bf70a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2001-01-26 Dekel Tsur + + * vspace.C (isValidLength): Fix for empty input string. + 2001-01-26 Jean-Marc Lasgouttes * LyXAction.C (init): change description of LFUN_FIGURE to diff --git a/src/frontends/kde/ChangeLog b/src/frontends/kde/ChangeLog index 1b5e5ea0ee..6634b776d5 100644 --- a/src/frontends/kde/ChangeLog +++ b/src/frontends/kde/ChangeLog @@ -1,3 +1,15 @@ +2001-01-26 Dekel Tsur + + * dlg/lengthentry.C: Move the '#include ' to the top + (fix compilation with lyxstring). + + * FormPrint.h: Fix for namespace-less compilers. + + * refdlg.C (RefDialog): Use InsetRef::types. + + * FormRef.C (update, apply): Use InsetRef::getName and + InsetRef::getType. + 2000-01-24 John Levon * FormParagraph.C: update readonly in correct diff --git a/src/frontends/kde/FormPrint.h b/src/frontends/kde/FormPrint.h index 467626a2a0..e87ea18880 100644 --- a/src/frontends/kde/FormPrint.h +++ b/src/frontends/kde/FormPrint.h @@ -22,6 +22,10 @@ class Dialogs; class LyXView; class PrintDialog; +#ifdef SIGC_CXX_NAMESPACES +using SigC::Connection; +#endif + class FormPrint : public DialogBase, public noncopyable { public: /**@name Constructors and Destructors */ @@ -57,9 +61,9 @@ private: Dialogs * d_; /// Hide connection. - SigC::Connection h_; + Connection h_; /// Update connection. - SigC::Connection u_; + Connection u_; }; #endif diff --git a/src/frontends/kde/FormRef.C b/src/frontends/kde/FormRef.C index a9c66440dc..cd53a7303b 100644 --- a/src/frontends/kde/FormRef.C +++ b/src/frontends/kde/FormRef.C @@ -23,6 +23,7 @@ #include "lyxfunc.h" #include "refdlg.h" #include "debug.h" +#include "insets/insetref.h" #include @@ -30,7 +31,7 @@ using std::endl; FormRef::FormRef(LyXView *v, Dialogs *d) : dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0), - sort(0), gotowhere(GOTOREF), type(REF), refs(0) + sort(0), gotowhere(GOTOREF), refs(0) { // let the dialog be shown // This is a permanent connection so we won't bother @@ -172,22 +173,8 @@ void FormRef::update(bool switched) dialog_->reference->setText(params.getContents().c_str()); dialog_->refname->setText(params.getOptions().c_str()); - if (params.getCmdName()=="pageref") { - type = PAGEREF; - dialog_->type->setCurrentItem(1); - } else if (params.getCmdName()=="vref") { - type = VREF; - dialog_->type->setCurrentItem(2); - } else if (params.getCmdName()=="vpageref") { - type = VPAGEREF; - dialog_->type->setCurrentItem(3); - } else if (params.getCmdName()=="prettyref") { - type = PRETTYREF; - dialog_->type->setCurrentItem(4); - } else { - type = REF; - dialog_->type->setCurrentItem(0); - } + if (inset_) + dialog_->type->setCurrentItem(InsetRef::getType(params.getCmdName())); dialog_->buttonGoto->setText(_("&Goto reference")); QToolTip::remove(dialog_->buttonGoto); @@ -221,26 +208,7 @@ void FormRef::apply() if (!lv_->view()->available()) return; - switch (dialog_->type->currentItem()) { - case 0: - params.setCmdName("ref"); - break; - case 1: - params.setCmdName("pageref"); - break; - case 2: - params.setCmdName("vref"); - break; - case 3: - params.setCmdName("vpageref"); - break; - case 4: - params.setCmdName("prettyref"); - break; - default: - lyxerr[Debug::GUI] << "Unknown Ref Type" << endl; - } - + params.setCmdName(InsetRef::getName(dialog_->type->currentItem())); params.setContents(dialog_->reference->text()); params.setOptions(dialog_->refname->text()); diff --git a/src/frontends/kde/FormRef.h b/src/frontends/kde/FormRef.h index 9d1750ec36..12fa636b56 100644 --- a/src/frontends/kde/FormRef.h +++ b/src/frontends/kde/FormRef.h @@ -52,10 +52,6 @@ public: void close(); private: - enum Type { - REF, PAGEREF, VREF, VPAGEREF, PRETTYREF - }; - enum GotoType { GOTOREF, GOTOBACK }; @@ -103,9 +99,6 @@ private: /// where to go GotoType gotowhere; - /// current type - Type type; - /// available references std::vector< string > refs; }; diff --git a/src/frontends/kde/dlg/lengthentry.C b/src/frontends/kde/dlg/lengthentry.C index 3135178efd..c1be409f4f 100644 --- a/src/frontends/kde/dlg/lengthentry.C +++ b/src/frontends/kde/dlg/lengthentry.C @@ -4,6 +4,8 @@ * John Levon, moz@compsoc.man.ac.uk */ +#include + #include "lengthentry.h" #include @@ -11,8 +13,6 @@ #include #include "support/lstrings.h" - -#include #include #include "debug.h" @@ -125,7 +125,7 @@ bool LengthEntry::setFromLengthStr(const string & str) string val; lyxerr[Debug::GUI] << "setFromLengthStr: " << str << endl; - + string::size_type i = str.find_first_not_of("0123456789.,"); setValue(strToDbl(str.substr(0, i))); diff --git a/src/frontends/kde/refdlg.C b/src/frontends/kde/refdlg.C index 017d1d88a0..032442f3a3 100644 --- a/src/frontends/kde/refdlg.C +++ b/src/frontends/kde/refdlg.C @@ -15,8 +15,9 @@ #include #include "refdlg.h" - #include "dlg/helpers.h" +#include "insets/insetref.h" + #ifdef CXX_WORKING_NAMESPACES using kde_helpers::setSizeHint; @@ -65,11 +66,8 @@ RefDialog::RefDialog(FormRef *form, QWidget *parent, const char *name, bool, WFl sort->setMaximumSize(sort->sizeHint()); type = new QComboBox(this); - type->insertItem(_("Reference")); - type->insertItem(_("Page number")); - type->insertItem(_("Ref on page xxx")); - type->insertItem(_("on page xxx")); - type->insertItem(_("Pretty reference")); + for (int i = 0; !InsetRef::types[i].latex_name.empty(); ++i) + type->insertItem(_(InsetRef::types[i].gui_name.c_str())); setSizeHint(type); labeltype = new QLabel(this); diff --git a/src/support/ChangeLog b/src/support/ChangeLog index ce40df4569..6d918d0858 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,7 @@ +2001-01-26 Dekel Tsur + + * lyxstring.C: Fix some assertions. + 2001-01-23 Dekel Tsur * lstrings.C (strip): Add a fix for compilers with broken diff --git a/src/support/lyxstring.C b/src/support/lyxstring.C index ff25d6fba9..bc17eef026 100644 --- a/src/support/lyxstring.C +++ b/src/support/lyxstring.C @@ -1046,7 +1046,7 @@ lyxstring::size_type lyxstring::rfind(value_type c, size_type i) const lyxstring::size_type lyxstring::find_first_of(lyxstring const & a, size_type i) const { - Assert(i < rep->sz); // OURS! + Assert(i <= rep->sz); // OURS! TestlyxstringInvariant(this); for (size_type t = i; t < rep->sz; ++t) { @@ -1060,7 +1060,7 @@ lyxstring::size_type lyxstring::find_first_of(value_type const * ptr, size_type i, size_type n) const { - Assert(ptr && i < rep->sz); // OURS! + Assert(ptr && i <= rep->sz); // OURS! TestlyxstringInvariant(this); if (!n) return npos; @@ -1074,7 +1074,7 @@ lyxstring::size_type lyxstring::find_first_of(value_type const * ptr, lyxstring::size_type lyxstring::find_first_of(value_type const * ptr, size_type i) const { - Assert(ptr && i < rep->sz); // OURS! + Assert(ptr && i <= rep->sz); // OURS! TestlyxstringInvariant(this); for (size_type t = i; t < rep->sz; ++t) { @@ -1086,7 +1086,7 @@ lyxstring::size_type lyxstring::find_first_of(value_type const * ptr, lyxstring::size_type lyxstring::find_first_of(value_type c, size_type i) const { - Assert(i < rep->sz); // OURS! + Assert(i <= rep->sz); // OURS! TestlyxstringInvariant(this); for (size_type t = i; t < rep->sz; ++t) { @@ -1158,7 +1158,7 @@ lyxstring::size_type lyxstring::find_first_not_of(lyxstring const & a, TestlyxstringInvariant(this); if (!rep->sz) return npos; - Assert(i < rep->sz); + Assert(i <= rep->sz); for (size_type t = i; t < rep->sz; ++t) { if (a.find(rep->s[t]) == npos) return t; } @@ -1170,7 +1170,7 @@ lyxstring::size_type lyxstring::find_first_not_of(value_type const * ptr, size_type i, size_type n) const { - Assert(ptr && i < rep->sz); // OURS! + Assert(ptr && i <= rep->sz); // OURS! TestlyxstringInvariant(this); if (!n) return (i < rep->sz) ? i : npos; @@ -1184,7 +1184,7 @@ lyxstring::size_type lyxstring::find_first_not_of(value_type const * ptr, lyxstring::size_type lyxstring::find_first_not_of(value_type const * ptr, size_type i) const { - Assert(ptr && i < rep->sz); // OURS! + Assert(ptr && i <= rep->sz); // OURS! TestlyxstringInvariant(this); for (size_type t = i; t < rep->sz; ++t) { @@ -1198,7 +1198,7 @@ lyxstring::size_type lyxstring::find_first_not_of(value_type c, size_type i) const { if (!rep->sz) return npos; - Assert(i < rep->sz); // OURS! + Assert(i <= rep->sz); // OURS! TestlyxstringInvariant(this); for (size_type t = i; t < rep->sz; ++t) { @@ -1293,7 +1293,7 @@ lyxstring & lyxstring::replace(size_type i, size_type n, lyxstring const & x, lyxstring & lyxstring::replace(size_type i, size_type n, value_type const * p, size_type n2) { - Assert(p && i < rep->sz); // OURS! + Assert(p && i <= rep->sz); // OURS! TestlyxstringInvariant(this); rep = rep->get_own_copy(); @@ -1304,7 +1304,7 @@ lyxstring & lyxstring::replace(size_type i, size_type n, lyxstring & lyxstring::replace(size_type i, size_type n, value_type const * p) { - Assert(p && i < rep->sz); // OURS! + Assert(p && i <= rep->sz); // OURS! TestlyxstringInvariant(this); return replace(i, min(n, rep->sz), p, (!p) ? 0 : strlen(p)); diff --git a/src/vspace.C b/src/vspace.C index d12ecb820a..3c46446067 100644 --- a/src/vspace.C +++ b/src/vspace.C @@ -249,6 +249,8 @@ bool isValidLength(string const & data, LyXLength * result) /// The parser may seem overkill for lengths without /// glue, but since we already have it, using it is /// easier than writing something from scratch. + if (data.empty()) + return true; string buffer(data); int pattern_index = 0;