From: Jean-Marc Lasgouttes Date: Mon, 11 Mar 2002 11:17:49 +0000 (+0000) Subject: bibfile parsing and insetgraphics fixes from Herbert; FormToc fix from John; compile... X-Git-Tag: 1.6.10~19694 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=6bfec9b307b79ace8bd25ab26f775252ed5cf4fe;p=features.git bibfile parsing and insetgraphics fixes from Herbert; FormToc fix from John; compile fix from Kayvan git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3704 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/po/POTFILES.in b/po/POTFILES.in index b4eca29180..2e6bb2cc2a 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -71,10 +71,10 @@ src/frontends/qt2/QURL.C src/frontends/qt2/QVCLog.C src/frontends/xforms/Alert_pimpl.C src/frontends/xforms/combox.C +src/frontends/xforms/FeedbackController.C src/frontends/xforms/FileDialog.C src/frontends/xforms/form_aboutlyx.C src/frontends/xforms/FormAboutlyx.C -src/frontends/xforms/FormBase.C src/frontends/xforms/form_bibitem.C src/frontends/xforms/FormBibitem.C src/frontends/xforms/form_bibtex.C @@ -191,7 +191,6 @@ src/lyxfont.C src/lyxfunc.C src/lyx_main.C src/lyxrc.C -src/LyXSendto.C src/lyxtextclasslist.C src/lyxvc.C src/LyXView.C diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 57cbbef396..9a9f771e94 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,13 @@ +2002-03-10 Herbert Voss + + * biblio.C (parseBibTeX): fix bug + (familyName): improve parsing + +2002-03-09 Herbert Voss + + * ControlGraphics.[Ch]: adding checkFilename() for testing + of non-existing files + 2002-03-07 Lars Gullik Bjønnes * ControlSendto.C (allFormats): fix a iterators are not pointers @@ -9,7 +19,8 @@ 2002-03-05 Herbert Voss - biblio.C: (getInfo) simplify if using paragraph layout "bibliography". + * biblio.C (getInfo): simplify if using paragraph layout + "bibliography". 2002-03-05 Angus Leeming diff --git a/src/frontends/controllers/ControlGraphics.C b/src/frontends/controllers/ControlGraphics.C index 8231bdb0fc..de90d133b5 100644 --- a/src/frontends/controllers/ControlGraphics.C +++ b/src/frontends/controllers/ControlGraphics.C @@ -36,6 +36,7 @@ #include "helper_funcs.h" // for browseFile #include "support/lstrings.h" #include "support/filetools.h" // for AddName, zippedFile +#include "frontends/Alert.h" #include "BufferView.h" using std::pair; @@ -132,3 +133,10 @@ string const ControlGraphics::readBB(string const & file) } +void ControlGraphics::checkFilename(string const & fname) { + if (!IsFileReadable(fname)) + Alert::alert(_("Warning!"), + _("Filename") + ' ' + + fname + _(" does not exist!")); + +} diff --git a/src/frontends/controllers/ControlGraphics.h b/src/frontends/controllers/ControlGraphics.h index 022e3e9564..8b760701d0 100644 --- a/src/frontends/controllers/ControlGraphics.h +++ b/src/frontends/controllers/ControlGraphics.h @@ -40,7 +40,8 @@ public: string const readBB(string const & file); /// Control the bb bool bbChanged; - + /// test if file exist + void checkFilename(string const & fname); private: /// Dispatch the changed parameters to the kernel. virtual void applyParamsToInset(); diff --git a/src/frontends/controllers/biblio.C b/src/frontends/controllers/biblio.C index 5f64ba6e10..64cf3f487a 100644 --- a/src/frontends/controllers/biblio.C +++ b/src/frontends/controllers/biblio.C @@ -146,10 +146,18 @@ string const familyName(string const & name) // Very simple parser string fname = name; - string::size_type idx = fname.rfind("."); + // possible authorname combinations are: + // "Surname, FirstName" + // "Surname, F." + // "FirstName Surname" + // "F. Surname" + string::size_type idx = fname.find(","); + if (idx != string::npos) + return frontStrip(fname.substr(0,idx)); + idx = fname.rfind("."); if (idx != string::npos) fname = frontStrip(fname.substr(idx+1)); - + return fname; } @@ -212,10 +220,6 @@ string const getYear(InfoMap const & map, string const & key) - - - - // A functor for use with std::sort, leading to case insensitive sorting struct compareNoCase: public std::binary_function { @@ -339,8 +343,8 @@ string const parseBibTeX(string data, string const & findkey) string::size_type const idx = dummy.empty() ? string::npos : dummy.find('%'); if (idx != string::npos) { + // ignore lines with a beginning '%' if (idx > 0) { - // This is safe. data MUST contain a '%' data_ += dummy.substr(0,data.find('%')); } } else { @@ -379,12 +383,12 @@ string const parseBibTeX(string data, string const & findkey) data = strip(data, '}');// maybe there is a main closing '}' // happens, when last keyword string::size_type const idx = - data.empty() ? data.find('=') : string::npos; + !data.empty() ? data.find('=') : string::npos; if (idx == string::npos) return string(); - data = data.substr(idx, data.length() - 1); + data = data.substr(idx); data = frontStrip(strip(data)); if (data.length() < 2 || data[0] != '=') { // a valid entry? @@ -403,16 +407,16 @@ string const parseBibTeX(string data, string const & findkey) } else { return data; // no {} and no "", pure data } - string tmp = data.substr(keypos, data.length()-1); + string tmp = data.substr(keypos); while (tmp.find('{') != string::npos && tmp.find('}') != string::npos && tmp.find('{') < tmp.find('}') && tmp.find('{') < tmp.find(enclosing)) { keypos += tmp.find('{') + 1; - tmp = data.substr(keypos, data.length() - 1); + tmp = data.substr(keypos); keypos += tmp.find('}') + 1; - tmp = data.substr(keypos, data.length() - 1); + tmp = data.substr(keypos); } if (tmp.find(enclosing) == string::npos) return data; diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 99d4fc8007..431577a7bd 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,11 @@ +2002-03-09 Herbert Voss + + * FormGraphics.C: test if file exists, simplify an if command + +2002-03-10 John Levon + + * FormToc.C: make goto not reset the dialog + 2002-03-08 Angus Leeming * FeedbackController.[Ch]: new files, providing a standard interface to diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index f353a3faeb..b5ce351bcc 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -28,7 +28,6 @@ #include "input_validators.h" #include "debug.h" // for lyxerr #include "support/lstrings.h" // for strToDbl & tostr -#include "support/FileInfo.h" #include "support/filetools.h" // for MakeAbsPath etc #include "insets/insetgraphicsParams.h" #include "lyxrc.h" // for lyxrc.display_graphics @@ -43,7 +42,7 @@ int const WIDTH_MAXDIGITS = 10; int const HEIGHT_MAXDIGITS = 10; int const ROTATE_MAXCHARS = 4; int const FILENAME_MAXCHARS = 1024; -string defaultUnit = "cm"; +string defaultUnit("cm"); } // namespace anon @@ -164,6 +163,9 @@ void FormGraphics::build() fl_addto_tabfolder(dialog_->tabFolder, _("LaTeX Size"), size_->form); fl_addto_tabfolder(dialog_->tabFolder, _("Bounding Box"), bbox_->form); fl_addto_tabfolder(dialog_->tabFolder, _("Extras"), special_->form); + // set the right default unit + if (lyxrc.default_papersize < 3) + defaultUnit = "in"; } @@ -174,6 +176,7 @@ void FormGraphics::apply() // the file section igp.filename = getStringFromInput(file_->input_filename); + controller().checkFilename(igp.filename); igp.subcaption = fl_get_button(file_->check_subcaption); igp.subcaptionText = getStringFromInput(file_->input_subcaption); igp.rotate = fl_get_button(file_->check_rotate); @@ -266,8 +269,6 @@ void FormGraphics::apply() void FormGraphics::update() { - if (lyxrc.default_papersize < 3) - defaultUnit = string("in"); // Update dialog with details from inset InsetGraphicsParams & igp = controller().params(); @@ -281,7 +282,7 @@ void FormGraphics::update() { fl_set_input(file_->input_rotate_angle, tostr(igp.rotateAngle).c_str()); if (igp.rotateOrigin.empty()) - fl_set_choice(file_->choice_origin,0); + fl_set_choice(file_->choice_origin,1); else fl_set_choice_text(file_->choice_origin,igp.rotateOrigin.c_str()); setEnabled(file_->input_rotate_angle, @@ -310,9 +311,9 @@ void FormGraphics::update() { break; } updateWidgetsFromLength(lyxview_->input_lyxwidth, - lyxview_->choice_width_lyxwidth, igp.lyxwidth,defaultUnit); + lyxview_->choice_width_lyxwidth, igp.lyxwidth, defaultUnit); updateWidgetsFromLength(lyxview_->input_lyxheight, - lyxview_->choice_width_lyxheight, igp.lyxheight,defaultUnit); + lyxview_->choice_width_lyxheight, igp.lyxheight, defaultUnit); fl_set_input(lyxview_->input_lyxscale, tostr(igp.lyxscale).c_str()); switch (igp.lyxsize_type) { case InsetGraphicsParams::DEFAULT_SIZE: { @@ -347,9 +348,9 @@ void FormGraphics::update() { // the size section // Update the draft and clip mode updateWidgetsFromLength(size_->input_width, - size_->choice_width_units,igp.width,defaultUnit); + size_->choice_width_units, igp.width, defaultUnit); updateWidgetsFromLength(size_->input_height, - size_->choice_height_units,igp.height,defaultUnit); + size_->choice_height_units, igp.height, defaultUnit); fl_set_input(size_->input_scale, tostr(igp.scale).c_str()); switch (igp.size_type) { case InsetGraphicsParams::DEFAULT_SIZE: { @@ -483,13 +484,10 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long) setEnabled(lyxview_->choice_width_lyxheight, 0); setEnabled(lyxview_->input_lyxscale, 1); } else if (ob == lyxview_->button_latex_values) { - if (fl_get_choice(size_->choice_width_units) > 3 - && fl_get_choice(size_->choice_width_units) < 8 - || fl_get_choice(size_->choice_height_units) > 3 - && fl_get_choice(size_->choice_height_units) < 8) - Alert::alert(_("Warning!"), - _("The units t%, p%, c% and l% are not allowed here."), - _("Cannot use the values from LaTeX size!")); + if (contains(fl_get_choice_text(size_->choice_width_units),'%')) + Alert::alert(_("Warning!"), + _("The units t%, p%, c% and l% are not allowed here."), + _("Cannot use the values from LaTeX size!")); else { LyXLength dummy = LyXLength(getLengthFromWidgets(size_->input_width, size_->choice_width_units)); diff --git a/src/frontends/xforms/FormToc.C b/src/frontends/xforms/FormToc.C index 11a5c322b2..9a6f50797b 100644 --- a/src/frontends/xforms/FormToc.C +++ b/src/frontends/xforms/FormToc.C @@ -60,18 +60,21 @@ void FormToc::update() ButtonPolicy::SMInput FormToc::input(FL_OBJECT * ob, long) { + if (ob == dialog_->browser_toc) { + unsigned int const choice = fl_get_browser(dialog_->browser_toc); + + if (choice - 1 < toclist_.size() && choice >= 1) { + controller().Goto(toclist_[choice - 1].par->id()); + } + return ButtonPolicy::SMI_VALID; + } + if (ob != dialog_->choice_toc_type) { updateType(); } updateContents(); - unsigned int const choice = fl_get_browser(dialog_->browser_toc); - - if (choice - 1 < toclist_.size() && choice >= 1) { - controller().Goto(toclist_[choice - 1].par->id()); - } - return ButtonPolicy::SMI_VALID; } diff --git a/src/support/ChangeLog b/src/support/ChangeLog index 01139595e6..74f2afaa24 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,7 @@ +2002-03-11 Kayvan A. Sylvan + + * lyxsum.C: compilation fix + 2002-03-02 Herbert Voss * filetools.C: fix bug for xbm format and added some more debug diff --git a/src/support/lyxsum.C b/src/support/lyxsum.C index a4a1eacb88..f74039591e 100644 --- a/src/support/lyxsum.C +++ b/src/support/lyxsum.C @@ -16,6 +16,8 @@ #include "support/lyxlib.h" #include "debug.h" +using std::endl; + // Various implementations of lyx::sum(), depending on what methods // are available. Order is faster to slowest. #if defined(HAVE_MMAP) && defined(HAVE_MUNMAP) @@ -31,7 +33,6 @@ #include using std::ifstream; -using std::endl; using std::for_each; using std::istreambuf_iterator; using std::istream_iterator; @@ -89,6 +90,9 @@ unsigned long do_crc(InputIterator first, InputIterator last) } // namespace #if HAVE_DECL_ISTREAMBUF_ITERATOR +using std::ifstream; +using std::istreambuf_iterator; + unsigned long lyx::sum(string const & file) { lyxerr[Debug::FILES] << "lyx::sum() using istreambuf_iterator (fast)"