]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBibtex.cpp
Move isMultiCell() to Cursor, and use it.
[lyx.git] / src / insets / InsetBibtex.cpp
index 3ebee05101eb656d91f50591ec79268e69ec2543..9b0e77e7b6936654fddce7609c491bd4e296e007 100644 (file)
@@ -49,9 +49,19 @@ namespace Alert = frontend::Alert;
 namespace os = support::os;
 
 
-InsetBibtex::InsetBibtex(InsetCommandParams const & p)
+InsetBibtex::InsetBibtex(Buffer const & buf, InsetCommandParams const & p)
        : InsetCommand(p, "bibtex")
-{}
+{
+       Inset::setBuffer(const_cast<Buffer &>(buf));
+       buffer_->invalidateBibinfoCache();
+}
+
+
+InsetBibtex::~InsetBibtex()
+{
+       if (isBufferValid())
+               buffer_->invalidateBibinfoCache();
+}
 
 
 ParamInfo const & InsetBibtex::findInfo(string const & /* cmdName */)
@@ -108,7 +118,7 @@ bool InsetBibtex::getStatus(Cursor & cur, FuncRequest const & cmd,
 {
        switch (cmd.action) {
        case LFUN_INSET_EDIT:
-               flag.enabled(true);
+               flag.setEnabled(true);
                return true;
 
        default:
@@ -155,7 +165,7 @@ docstring InsetBibtex::screenLabel() const
 docstring InsetBibtex::toolTip(BufferView const & /*bv*/, int /*x*/, int /*y*/) const
 {
        docstring item = from_ascii("* ");
-       docstring tip = _("Databases:\n");
+       docstring tip = _("Databases:") + "\n";
        vector<docstring> bibfilelist = getVectorFromString(getParam("bibfiles"));
 
        if (bibfilelist.empty()) {
@@ -180,14 +190,14 @@ docstring InsetBibtex::toolTip(BufferView const & /*bv*/, int /*x*/, int /*y*/)
                        style = split(style, bibtotoc, char_type(','));
        }
 
-       tip += _("Style File:\n");
+       tip += _("Style File:") +"\n";
        tip += item;
        if (!style.empty())
                tip += style;
        else
                tip += _("none");
 
-       tip += _("\nLists: ");
+       tip += "\n" + _("Lists:") + " ";
        docstring btprint = getParam("btprint");
                if (btprint == "btPrintAll")
                        tip += _("all references");
@@ -403,10 +413,11 @@ support::FileNameList InsetBibtex::getBibFiles() const
        for (; it != en; ++it) {
                FileName const file = 
                        findtexfile(changeExtension(to_utf8(*it), "bib"), "bib");
-               
-               // If we didn't find a matching file name just fail silently
+
                if (!file.empty())
                        vec.push_back(file);
+               else
+                       LYXERR0("Couldn't find " + to_utf8(*it) + " in InsetBibtex::getBibFiles()!");
        }
        
        return vec;
@@ -694,13 +705,13 @@ void InsetBibtex::fillWithBibKeys(BiblioInfo & keylist,
 
                        docstring entryType;
 
-                       if (!ifs) {
-                               lyxerr << "InsetBibtex::fillWithBibKeys: Unexpected end of file." << std::endl;
+                       if (!readTypeOrKey(entryType, ifs, from_ascii("{("), docstring(), makeLowerCase)) {
+                               lyxerr << "InsetBibtex::fillWithBibKeys: Error reading entry type." << std::endl;
                                continue;
                        }
 
-                       if (!readTypeOrKey(entryType, ifs, from_ascii("{("), docstring(), makeLowerCase)) {
-                               lyxerr << "InsetBibtex::fillWithBibKeys: Error reading entry type." << std::endl;
+                       if (!ifs) {
+                               lyxerr << "InsetBibtex::fillWithBibKeys: Unexpected end of file." << std::endl;
                                continue;
                        }
 
@@ -729,13 +740,13 @@ void InsetBibtex::fillWithBibKeys(BiblioInfo & keylist,
                                docstring name;
                                docstring value;
 
-                               if (!ifs) {
-                                       lyxerr << "InsetBibtex::fillWithBibKeys: Unexpected end of file." << std::endl;
+                               if (!readTypeOrKey(name, ifs, from_ascii("="), from_ascii("#{}(),"), makeLowerCase)) {
+                                       lyxerr << "InsetBibtex::fillWithBibKeys: Error reading string name." << std::endl;
                                        continue;
                                }
 
-                               if (!readTypeOrKey(name, ifs, from_ascii("="), from_ascii("#{}(),"), makeLowerCase)) {
-                                       lyxerr << "InsetBibtex::fillWithBibKeys: Error reading string name." << std::endl;
+                               if (!ifs) {
+                                       lyxerr << "InsetBibtex::fillWithBibKeys: Unexpected end of file." << std::endl;
                                        continue;
                                }
 
@@ -771,17 +782,17 @@ void InsetBibtex::fillWithBibKeys(BiblioInfo & keylist,
                                // Citation entry. Try to read the key.
                                docstring key;
 
-                               if (!ifs) {
-                                       lyxerr << "InsetBibtex::fillWithBibKeys: Unexpected end of file." << std::endl;
-                                       continue;
-                               }
-
                                if (!readTypeOrKey(key, ifs, from_ascii(","), from_ascii("}"), keepCase)) {
                                        lyxerr << "InsetBibtex::fillWithBibKeys: Unable to read key for entry type:" << 
                                                        entryType << "." << std::endl;
                                        continue;
                                }
 
+                               if (!ifs) {
+                                       lyxerr << "InsetBibtex::fillWithBibKeys: Unexpected end of file." << std::endl;
+                                       continue;
+                               }
+
                                /////////////////////////////////////////////
                                // now we have a key, so we will add an entry 
                                // (even if it's empty, as bibtex does)