]> git.lyx.org Git - features.git/commitdiff
bibfile parsing and insetgraphics fixes from Herbert; FormToc fix from John; compile...
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 11 Mar 2002 11:17:49 +0000 (11:17 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 11 Mar 2002 11:17:49 +0000 (11:17 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3704 a592a061-630c-0410-9148-cb99ea01b6c8

po/POTFILES.in
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlGraphics.C
src/frontends/controllers/ControlGraphics.h
src/frontends/controllers/biblio.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormGraphics.C
src/frontends/xforms/FormToc.C
src/support/ChangeLog
src/support/lyxsum.C

index b4eca29180183ee9bf9113acf0d3ad6ead9bd179..2e6bb2cc2a923879fcc5e1e0d921f4a76fedbb63 100644 (file)
@@ -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
index 57cbbef39632bb316f478154b0f55eee4df2e947..9a9f771e94a0a4c6f2b31f121b6a650a3ada800f 100644 (file)
@@ -1,3 +1,13 @@
+2002-03-10  Herbert Voss  <voss@lyx.org>
+
+       * biblio.C (parseBibTeX): fix bug
+       (familyName): improve parsing
+
+2002-03-09  Herbert Voss  <voss@lyx.org>
+
+       * ControlGraphics.[Ch]: adding checkFilename() for testing 
+       of non-existing files
+
 2002-03-07  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * ControlSendto.C (allFormats): fix a iterators are not pointers
@@ -9,7 +19,8 @@
 
 2002-03-05  Herbert Voss  <voss@lyx.org>
 
-       biblio.C: (getInfo) simplify if using paragraph layout "bibliography".
+       * biblio.C (getInfo): simplify if using paragraph layout
+       "bibliography". 
 
 2002-03-05  Angus Leeming  <a.leeming@ic.ac.uk>
 
index 8231bdb0fc2d5bb5514ca3458a0352974438b716..de90d133b5c2b779e71450a32d6c6809b23845fb 100644 (file)
@@ -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!"));
+
+}
index 022e3e9564b97f7c927d9deca1c331c14a99ad40..8b760701d0f04049785c7903bb3e0a460b025c92 100644 (file)
@@ -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();
index 5f64ba6e10aa142b0ec9da95ccf80a0d38921222..64cf3f487aa8c61ccea169bf30cc2df4038238b0 100644 (file)
@@ -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<string, string, bool> 
 {
@@ -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;
index 99d4fc80076c8f4910ed48021b2882463bfde1f0..431577a7bd61e2a6a510b4995864c1d653b40730 100644 (file)
@@ -1,3 +1,11 @@
+2002-03-09  Herbert Voss  <voss@lyx.org>
+
+       * FormGraphics.C: test if file exists, simplify an if command
+
+2002-03-10  John Levon  <moz@compsoc.man.ac.uk>
+
+       * FormToc.C: make goto not reset the dialog
 2002-03-08  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * FeedbackController.[Ch]: new files, providing a standard interface to
index f353a3faebabf630637c7af9610651825e10a9d3..b5ce351bcc589943ad7d84cf79efb0269e5032f2 100644 (file)
@@ -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));
index 11a5c322b2028f003101cefa4b20024475732fc8..9a6f50797b3901b635ded5da0bb45837b00b56ca 100644 (file)
@@ -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;
 }
 
index 01139595e609fe6183697e000a879def1fa2a4e9..74f2afaa2466124c4ff0348380d1069216aceec8 100644 (file)
@@ -1,3 +1,7 @@
+2002-03-11  Kayvan A. Sylvan  <kayvan@sylvan.com>
+
+       * lyxsum.C: compilation fix
+
 2002-03-02  Herbert Voss  <voss@perce.de>
 
        * filetools.C: fix bug for xbm format and added some more debug
index a4a1eacb88aeca86d9a9bd3da830302661ec1b80..f74039591ebe0d1825a4577dfb8ad339ba0a0b6c 100644 (file)
@@ -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 <sys/mman.h>
 
 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)"