]> git.lyx.org Git - features.git/blob - src/insets/InsetBibtex.cpp
2b12c9f03beaec8bad6669734067aa1c0478400d
[features.git] / src / insets / InsetBibtex.cpp
1 /**
2  * \file InsetBibtex.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alejandro Aguilar Sierra
7  * \author Richard Heck (BibTeX parser improvements)
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "InsetBibtex.h"
15
16 #include "Buffer.h"
17 #include "BufferParams.h"
18 #include "DispatchResult.h"
19 #include "EmbeddedFiles.h"
20 #include "Encoding.h"
21 #include "FuncRequest.h"
22 #include "LaTeXFeatures.h"
23 #include "MetricsInfo.h"
24 #include "OutputParams.h"
25 #include "TextClass.h"
26
27 #include "frontends/alert.h"
28
29 #include "support/debug.h"
30 #include "support/docstream.h"
31 #include "support/ExceptionMessage.h"
32 #include "support/filetools.h"
33 #include "support/gettext.h"
34 #include "support/lstrings.h"
35 #include "support/os.h"
36 #include "support/Path.h"
37 #include "support/textutils.h"
38
39 #include <limits>
40
41 using namespace std;
42 using namespace lyx::support;
43
44 namespace lyx {
45
46 namespace Alert = frontend::Alert;
47 namespace os = support::os;
48
49
50 InsetBibtex::InsetBibtex(InsetCommandParams const & p)
51         : InsetCommand(p, "bibtex"), bibfiles_()
52 {}
53
54
55 ParamInfo const & InsetBibtex::findInfo(string const & /* cmdName */)
56 {
57         static ParamInfo param_info_;
58         if (param_info_.empty()) {
59                 param_info_.add("btprint", ParamInfo::LATEX_OPTIONAL);
60                 param_info_.add("bibfiles", ParamInfo::LATEX_REQUIRED);
61                 param_info_.add("embed", ParamInfo::LYX_INTERNAL);
62                 param_info_.add("options", ParamInfo::LYX_INTERNAL);
63         }
64         return param_info_;
65 }
66
67
68 void InsetBibtex::doDispatch(Cursor & cur, FuncRequest & cmd)
69 {
70         switch (cmd.action) {
71
72         case LFUN_INSET_MODIFY: {
73                 InsetCommandParams p(BIBTEX_CODE);
74                 try {
75                         if (!InsetCommandMailer::string2params("bibtex", 
76                                         to_utf8(cmd.argument()), p)) {
77                                 cur.noUpdate();
78                                 break;
79                         }
80                 } catch (ExceptionMessage const & message) {
81                         if (message.type_ == WarningException) {
82                                 Alert::warning(message.title_, message.details_);
83                                 cur.noUpdate();
84                         } else 
85                                 throw message;
86                         break;
87                 }
88                 //
89                 createBibFiles(p["bibfiles"], p["embed"]);
90                 updateParam();
91                 buffer().updateBibfilesCache();
92                 break;
93         }
94
95         default:
96                 InsetCommand::doDispatch(cur, cmd);
97                 break;
98         }
99 }
100
101
102 docstring InsetBibtex::screenLabel() const
103 {
104         return _("BibTeX Generated Bibliography");
105 }
106
107
108 static string normalizeName(Buffer const & buffer,
109         OutputParams const & runparams, string const & name, string const & ext)
110 {
111         string const fname = makeAbsPath(name, buffer.filePath()).absFilename();
112         if (FileName(name).isAbsolute() || !FileName(fname + ext).isReadableFile())
113                 return name;
114         if (!runparams.nice)
115                 return fname;
116
117         // FIXME UNICODE
118         return to_utf8(makeRelPath(from_utf8(fname),
119                                          from_utf8(buffer.masterBuffer()->filePath())));
120 }
121
122
123 int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
124 {
125         // the sequence of the commands:
126         // 1. \bibliographystyle{style}
127         // 2. \addcontentsline{...} - if option bibtotoc set
128         // 3. \bibliography{database}
129         // and with bibtopic:
130         // 1. \bibliographystyle{style}
131         // 2. \begin{btSect}{database}
132         // 3. \btPrint{Cited|NotCited|All}
133         // 4. \end{btSect}
134
135         // Database(s)
136         // If we are processing the LaTeX file in a temp directory then
137         // copy the .bib databases to this temp directory, mangling their
138         // names in the process. Store this mangled name in the list of
139         // all databases.
140         // (We need to do all this because BibTeX *really*, *really*
141         // can't handle "files with spaces" and Windows users tend to
142         // use such filenames.)
143         // Otherwise, store the (maybe absolute) path to the original,
144         // unmangled database name.
145         EmbeddedFileList::const_iterator it = bibfiles_.begin();
146         EmbeddedFileList::const_iterator it_end = bibfiles_.end();
147         odocstringstream dbs;
148         for (; it != it_end; ++it) {
149                 string utf8input = removeExtension(it->availableFile().absFilename());
150                 string database =
151                         normalizeName(buffer(), runparams, utf8input, ".bib");
152                 FileName const try_in_file =
153                         makeAbsPath(database + ".bib", buffer().filePath());
154                 bool const not_from_texmf = try_in_file.isReadableFile();
155
156                 if (!runparams.inComment && !runparams.dryrun && !runparams.nice &&
157                     not_from_texmf) {
158
159                         // mangledFilename() needs the extension
160                         DocFileName const in_file = DocFileName(try_in_file);
161                         database = removeExtension(in_file.mangledFilename());
162                         FileName const out_file = makeAbsPath(database + ".bib",
163                                         buffer().masterBuffer()->temppath());
164
165                         bool const success = in_file.copyTo(out_file);
166                         if (!success) {
167                                 lyxerr << "Failed to copy '" << in_file
168                                        << "' to '" << out_file << "'"
169                                        << endl;
170                         }
171                 } else if (!runparams.inComment && runparams.nice && not_from_texmf &&
172                            !isValidLaTeXFilename(database)) {
173                                 frontend::Alert::warning(_("Invalid filename"),
174                                                          _("The following filename is likely to cause trouble "
175                                                            "when running the exported file through LaTeX: ") +
176                                                             from_utf8(database));
177                 }
178
179                 if (it != bibfiles_.begin())
180                         dbs << ',';
181                 // FIXME UNICODE
182                 dbs << from_utf8(latex_path(database));
183         }
184         docstring const db_out = dbs.str();
185
186         // Post this warning only once.
187         static bool warned_about_spaces = false;
188         if (!warned_about_spaces &&
189             runparams.nice && db_out.find(' ') != docstring::npos) {
190                 warned_about_spaces = true;
191
192                 Alert::warning(_("Export Warning!"),
193                                _("There are spaces in the paths to your BibTeX databases.\n"
194                                               "BibTeX will be unable to find them."));
195         }
196
197         // Style-Options
198         string style = to_utf8(getParam("options")); // maybe empty! and with bibtotoc
199         string bibtotoc;
200         if (prefixIs(style, "bibtotoc")) {
201                 bibtotoc = "bibtotoc";
202                 if (contains(style, ','))
203                         style = split(style, bibtotoc, ',');
204         }
205
206         // line count
207         int nlines = 0;
208
209         if (!style.empty()) {
210                 string base = normalizeName(buffer(), runparams, style, ".bst");
211                 FileName const try_in_file = 
212                         makeAbsPath(base + ".bst", buffer().filePath());
213                 bool const not_from_texmf = try_in_file.isReadableFile();
214                 // If this style does not come from texmf and we are not
215                 // exporting to .tex copy it to the tmp directory.
216                 // This prevents problems with spaces and 8bit charcaters
217                 // in the file name.
218                 if (!runparams.inComment && !runparams.dryrun && !runparams.nice &&
219                     not_from_texmf) {
220                         // use new style name
221                         DocFileName const in_file = DocFileName(try_in_file);
222                         base = removeExtension(in_file.mangledFilename());
223                         FileName const out_file = makeAbsPath(base + ".bst",
224                                         buffer().masterBuffer()->temppath());
225                         bool const success = in_file.copyTo(out_file);
226                         if (!success) {
227                                 lyxerr << "Failed to copy '" << in_file
228                                        << "' to '" << out_file << "'"
229                                        << endl;
230                         }
231                 }
232                 // FIXME UNICODE
233                 os << "\\bibliographystyle{"
234                    << from_utf8(latex_path(normalizeName(buffer(), runparams, base, ".bst")))
235                    << "}\n";
236                 nlines += 1;
237         }
238
239         // Post this warning only once.
240         static bool warned_about_bst_spaces = false;
241         if (!warned_about_bst_spaces && runparams.nice && contains(style, ' ')) {
242                 warned_about_bst_spaces = true;
243                 Alert::warning(_("Export Warning!"),
244                                _("There are spaces in the path to your BibTeX style file.\n"
245                                               "BibTeX will be unable to find it."));
246         }
247
248         if (!db_out.empty() && buffer().params().use_bibtopic) {
249                 os << "\\begin{btSect}{" << db_out << "}\n";
250                 docstring btprint = getParam("btprint");
251                 if (btprint.empty())
252                         // default
253                         btprint = from_ascii("btPrintCited");
254                 os << "\\" << btprint << "\n"
255                    << "\\end{btSect}\n";
256                 nlines += 3;
257         }
258
259         // bibtotoc-Option
260         if (!bibtotoc.empty() && !buffer().params().use_bibtopic) {
261                 if (buffer().params().documentClass().hasLaTeXLayout("chapter")) {
262                         if (buffer().params().sides == OneSide) {
263                                 // oneside
264                                 os << "\\clearpage";
265                         } else {
266                                 // twoside
267                                 os << "\\cleardoublepage";
268                         }
269                         os << "\\addcontentsline{toc}{chapter}{\\bibname}";
270                 } else if (buffer().params().documentClass().hasLaTeXLayout("section"))
271                         os << "\\addcontentsline{toc}{section}{\\refname}";
272         }
273
274         if (!db_out.empty() && !buffer().params().use_bibtopic) {
275                 docstring btprint = getParam("btprint");
276                 if (btprint == "btPrintAll") {
277                         os << "\\nocite{*}\n";
278                         nlines += 1;
279                 }
280                 os << "\\bibliography{" << db_out << "}\n";
281                 nlines += 1;
282         }
283
284         return nlines;
285 }
286
287
288 EmbeddedFileList InsetBibtex::embeddedFiles() const
289 {
290         return bibfiles_;
291 }
292
293 namespace {
294
295         // methods for parsing bibtex files
296
297         typedef map<docstring, docstring> VarMap;
298
299         /// remove whitespace characters, optionally a single comma,
300         /// and further whitespace characters from the stream.
301         /// @return true if a comma was found, false otherwise
302         ///
303         bool removeWSAndComma(idocfstream & ifs) {
304                 char_type ch;
305
306                 if (!ifs)
307                         return false;
308
309                 // skip whitespace
310                 do {
311                         ifs.get(ch);
312                 } while (ifs && isSpace(ch));
313
314                 if (!ifs)
315                         return false;
316
317                 if (ch != ',') {
318                         ifs.putback(ch);
319                         return false;
320                 }
321
322                 // skip whitespace
323                 do {
324                         ifs.get(ch);
325                 } while (ifs && isSpace(ch));
326
327                 if (ifs) {
328                         ifs.putback(ch);
329                 }
330
331                 return true;
332         }
333
334
335         enum charCase {
336                 makeLowerCase,
337                 keepCase
338         };
339
340         /// remove whitespace characters, read characer sequence
341         /// not containing whitespace characters or characters in
342         /// delimChars, and remove further whitespace characters.
343         ///
344         /// @return true if a string of length > 0 could be read.
345         ///
346         bool readTypeOrKey(docstring & val, idocfstream & ifs,
347                 docstring const & delimChars, docstring const &illegalChars, 
348                 charCase chCase) {
349
350                 char_type ch;
351
352                 val.clear();
353
354                 if (!ifs)
355                         return false;
356
357                 // skip whitespace
358                 do {
359                         ifs.get(ch);
360                 } while (ifs && isSpace(ch));
361
362                 if (!ifs)
363                         return false;
364
365                 // read value
366                 bool legalChar = true;
367                 while (ifs && !isSpace(ch) && 
368                                                  delimChars.find(ch) == docstring::npos &&
369                                                  (legalChar = (illegalChars.find(ch) == docstring::npos))
370                                         ) 
371                 {
372                         if (chCase == makeLowerCase)
373                                 val += lowercase(ch);
374                         else
375                                 val += ch;
376                         ifs.get(ch);
377                 }
378                 
379                 if (!legalChar) {
380                         ifs.putback(ch);
381                         return false;
382                 }
383
384                 // skip whitespace
385                 while (ifs && isSpace(ch)) {
386                         ifs.get(ch);
387                 }
388
389                 if (ifs) {
390                         ifs.putback(ch);
391                 }
392
393                 return val.length() > 0;
394         }
395
396         /// read subsequent bibtex values that are delimited with a #-character.
397         /// Concatenate all parts and replace names with the associated string in
398         /// the variable strings.
399         /// @return true if reading was successfull (all single parts were delimited
400         /// correctly)
401         bool readValue(docstring & val, idocfstream & ifs, const VarMap & strings) {
402
403                 char_type ch;
404
405                 val.clear();
406
407                 if (!ifs)
408                         return false;
409
410                 do {
411                         // skip whitespace
412                         do {
413                                 ifs.get(ch);
414                         } while (ifs && isSpace(ch));
415
416                         if (!ifs)
417                                 return false;
418
419                         // check for field type
420                         if (isDigit(ch)) {
421
422                                 // read integer value
423                                 do {
424                                         val += ch;
425                                         ifs.get(ch);
426                                 } while (ifs && isDigit(ch));
427
428                                 if (!ifs)
429                                         return false;
430
431                         } else if (ch == '"' || ch == '{') {
432                                 // set end delimiter
433                                 char_type delim = ch == '"' ? '"': '}';
434
435                                 //Skip whitespace
436                                 do {
437                                         ifs.get(ch);
438                                 } while (ifs && isSpace(ch));
439                                 
440                                 if (!ifs)
441                                         return false;
442                                 
443                                 //We now have the first non-whitespace character
444                                 //We'll collapse adjacent whitespace.
445                                 bool lastWasWhiteSpace = false;
446                                 
447                                 // inside this delimited text braces must match.
448                                 // Thus we can have a closing delimiter only
449                                 // when nestLevel == 0
450                                 int nestLevel = 0;
451  
452                                 while (ifs && (nestLevel > 0 || ch != delim)) {
453                                         if (isSpace(ch)) {
454                                                 lastWasWhiteSpace = true;
455                                                 ifs.get(ch);
456                                                 continue;
457                                         }
458                                         //We output the space only after we stop getting 
459                                         //whitespace so as not to output any whitespace
460                                         //at the end of the value.
461                                         if (lastWasWhiteSpace) {
462                                                 lastWasWhiteSpace = false;
463                                                 val += ' ';
464                                         }
465                                         
466                                         val += ch;
467
468                                         // update nesting level
469                                         switch (ch) {
470                                                 case '{':
471                                                         ++nestLevel;
472                                                         break;
473                                                 case '}':
474                                                         --nestLevel;
475                                                         if (nestLevel < 0) return false;
476                                                         break;
477                                         }
478
479                                         ifs.get(ch);
480                                 }
481
482                                 if (!ifs)
483                                         return false;
484
485                                 ifs.get(ch);
486
487                                 if (!ifs)
488                                         return false;
489
490                         } else {
491
492                                 // reading a string name
493                                 docstring strName;
494
495                                 while (ifs && !isSpace(ch) && ch != '#' && ch != ',' && ch != '}' && ch != ')') {
496                                         strName += lowercase(ch);
497                                         ifs.get(ch);
498                                 }
499
500                                 if (!ifs)
501                                         return false;
502
503                                 // replace the string with its assigned value or
504                                 // discard it if it's not assigned
505                                 if (strName.length()) {
506                                         VarMap::const_iterator pos = strings.find(strName);
507                                         if (pos != strings.end()) {
508                                                 val += pos->second;
509                                         }
510                                 }
511                         }
512
513                         // skip WS
514                         while (ifs && isSpace(ch)) {
515                                 ifs.get(ch);
516                         }
517
518                         if (!ifs)
519                                 return false;
520
521                         // continue reading next value on concatenate with '#'
522                 } while (ch == '#');
523
524                 ifs.putback(ch);
525
526                 return true;
527         }
528 }
529
530
531 // This method returns a comma separated list of Bibtex entries
532 void InsetBibtex::fillWithBibKeys(BiblioInfo & keylist,
533         InsetIterator const & /*di*/) const
534 {
535         EmbeddedFileList const files = embeddedFiles();
536         for (vector<EmbeddedFile>::const_iterator it = files.begin();
537              it != files.end(); ++ it) {
538                 // This bibtex parser is a first step to parse bibtex files
539                 // more precisely.
540                 //
541                 // - it reads the whole bibtex entry and does a syntax check
542                 //   (matching delimiters, missing commas,...
543                 // - it recovers from errors starting with the next @-character
544                 // - it reads @string definitions and replaces them in the
545                 //   field values.
546                 // - it accepts more characters in keys or value names than
547                 //   bibtex does.
548                 //
549                 // Officially bibtex does only support ASCII, but in practice
550                 // you can use the encoding of the main document as long as
551                 // some elements like keys and names are pure ASCII. Therefore
552                 // we convert the file from the buffer encoding.
553                 // We don't restrict keys to ASCII in LyX, since our own
554                 // InsetBibitem can generate non-ASCII keys, and nonstandard
555                 // 8bit clean bibtex forks exist.
556                 
557                 idocfstream ifs(it->availableFile().toFilesystemEncoding().c_str(),
558                         ios_base::in, buffer().params().encoding().iconvName());
559
560                 char_type ch;
561                 VarMap strings;
562
563                 while (ifs) {
564
565                         ifs.get(ch);
566                         if (!ifs)
567                                 break;
568
569                         if (ch != '@')
570                                 continue;
571
572                         docstring entryType;
573
574                         if (!readTypeOrKey(entryType, ifs, from_ascii("{("), 
575                                            docstring(), makeLowerCase) || !ifs)
576                                 continue;
577
578                         if (entryType == from_ascii("comment")) {
579
580                                 ifs.ignore(numeric_limits<int>::max(), '\n');
581                                 continue;
582                         }
583
584                         ifs.get(ch);
585                         if (!ifs)
586                                 break;
587
588                         if ((ch != '(') && (ch != '{')) {
589                                 // invalid entry delimiter
590                                 ifs.putback(ch);
591                                 continue;
592                         }
593
594                         // process the entry
595                         if (entryType == from_ascii("string")) {
596
597                                 // read string and add it to the strings map
598                                 // (or replace it's old value)
599                                 docstring name;
600                                 docstring value;
601
602                                 if (!readTypeOrKey(name, ifs, from_ascii("="), 
603                                                    from_ascii("#{}(),"), makeLowerCase) || !ifs)
604                                         continue;
605
606                                 // next char must be an equal sign
607                                 ifs.get(ch);
608                                 if (!ifs || ch != '=')
609                                         continue;
610
611                                 if (!readValue(value, ifs, strings))
612                                         continue;
613
614                                 strings[name] = value;
615
616                         } else if (entryType == from_ascii("preamble")) {
617
618                                 // preamble definitions are discarded.
619                                 // can they be of any use in lyx?
620                                 docstring value;
621
622                                 if (!readValue(value, ifs, strings))
623                                         continue;
624
625                         } else {
626
627                                 // Citation entry. Try to read the key.
628                                 docstring key;
629
630                                 if (!readTypeOrKey(key, ifs, from_ascii(","), 
631                                                    from_ascii("}"), keepCase) || !ifs)
632                                         continue;
633
634                                 /////////////////////////////////////////////
635                                 // now we have a key, so we will add an entry 
636                                 // (even if it's empty, as bibtex does)
637                                 //
638                                 // we now read the field = value pairs.
639                                 // all items must be separated by a comma. If
640                                 // it is missing the scanning of this entry is
641                                 // stopped and the next is searched.
642                                 docstring fields;
643                                 docstring name;
644                                 docstring value;
645                                 docstring commaNewline;
646                                 docstring data;
647                                 BibTeXInfo keyvalmap(key, entryType);
648                                 
649                                 bool readNext = removeWSAndComma(ifs);
650  
651                                 while (ifs && readNext) {
652
653                                         // read field name
654                                         if (!readTypeOrKey(name, ifs, from_ascii("="), 
655                                                            from_ascii("{}(),"), makeLowerCase) || !ifs)
656                                                 break;
657
658                                         // next char must be an equal sign
659                                         ifs.get(ch);
660                                         if (!ifs)
661                                                 break;
662                                         if (ch != '=') {
663                                                 ifs.putback(ch);
664                                                 break;
665                                         }
666
667                                         // read field value
668                                         if (!readValue(value, ifs, strings))
669                                                 break;
670
671                                         keyvalmap[name] = value;
672                                         data += "\n\n" + value;
673                                         keylist.addFieldName(name);
674                                         readNext = removeWSAndComma(ifs);
675                                 }
676
677                                 // add the new entry
678                                 keylist.addEntryType(entryType);
679                                 keyvalmap.setAllData(data);
680                                 keylist[key] = keyvalmap;
681                         }
682                 } //< searching '@'
683         } //< for loop over files
684 }
685
686
687
688 bool InsetBibtex::addDatabase(string const & db)
689 {
690         EmbeddedFile file(changeExtension(db, "bib"), buffer().filePath());
691         
692         // only compare filename
693         EmbeddedFileList::iterator it = bibfiles_.begin();
694         EmbeddedFileList::iterator it_end = bibfiles_.end();
695         for (; it != it_end; ++it)
696                 if (it->absFilename() == file.absFilename())
697                         return false;
698         
699         bibfiles_.push_back(file);
700         updateParam();
701         return true;
702 }
703
704
705 bool InsetBibtex::delDatabase(string const & db)
706 {
707         EmbeddedFile file(changeExtension(db, "bib"), buffer().filePath());
708         
709         // only compare filename
710         EmbeddedFileList::iterator it = bibfiles_.begin();
711         EmbeddedFileList::iterator it_end = bibfiles_.end();
712         for (; it != it_end; ++it)
713                 if (it->absFilename() == file.absFilename()) {
714                         bibfiles_.erase(it);
715                         updateParam();
716                         return true;
717                 }
718         return false;
719 }
720
721
722 void InsetBibtex::validate(LaTeXFeatures & features) const
723 {
724         if (features.bufferParams().use_bibtopic)
725                 features.require("bibtopic");
726 }
727
728
729 void InsetBibtex::createBibFiles(docstring const & bibParam,
730         docstring const & embedParam) const
731 {
732         bibfiles_.clear();
733         
734         string tmp;
735         string emb;
736         
737         string bibfiles = to_utf8(bibParam);
738         string embedStatus = to_utf8(embedParam);
739         
740         LYXERR(Debug::FILES, "Create bib files from parameters "
741                 << bibfiles << " and " << embedStatus);
742
743         bibfiles = split(bibfiles, tmp, ',');
744         embedStatus = split(embedStatus, emb, ',');
745         
746         while (!tmp.empty()) {
747                 EmbeddedFile file(changeExtension(tmp, "bib"), buffer().filePath());
748                 
749                 file.setInzipName(emb);
750                 file.setEmbed(!emb.empty());
751                 file.enable(buffer().embedded(), &buffer(), false);
752                 bibfiles_.push_back(file);
753                 // Get next file name
754                 bibfiles = split(bibfiles, tmp, ',');
755                 embedStatus = split(embedStatus, emb, ',');
756         }
757 }
758
759
760 void InsetBibtex::updateParam()
761 {
762         docstring bibfiles;
763         docstring embed;
764
765         bool first = true;
766         for (EmbeddedFileList::iterator it = bibfiles_.begin();
767                 it != bibfiles_.end(); ++it) {
768                 if (!first) {
769                         bibfiles += ',';
770                         embed += ',';
771                 } else
772                         first = false;
773                 bibfiles += from_utf8(it->outputFilename(buffer().filePath()));
774                 if (it->embedded())
775                         embed += from_utf8(it->inzipName());
776         }
777         setParam("bibfiles", bibfiles);
778         setParam("embed", embed);
779 }
780
781
782 void InsetBibtex::registerEmbeddedFiles(EmbeddedFileList & files) const
783 {
784         if (bibfiles_.empty())
785                 createBibFiles(params()["bibfiles"], params()["embed"]);
786
787         EmbeddedFileList::const_iterator it = bibfiles_.begin();
788         EmbeddedFileList::const_iterator it_end = bibfiles_.end();
789         for (; it != it_end; ++it)
790                 files.registerFile(*it, this, buffer());
791 }
792
793
794 void InsetBibtex::updateEmbeddedFile(EmbeddedFile const & file)
795 {
796         // look for the item and update status
797         for (EmbeddedFileList::iterator it = bibfiles_.begin();
798                 it != bibfiles_.end(); ++it)
799                 if (it->absFilename() == file.absFilename())
800                         *it = file;
801         
802         updateParam();
803 }
804
805
806 } // namespace lyx