]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetcite.C
Don't remove cell selections after fontchange.
[lyx.git] / src / insets / insetcite.C
index 591e450bba40914e359746f104c9272c836b18b6..6eedb6df8ccf46d8bf539f5fe5370078359b374f 100644 (file)
 #include "BufferView.h"
 #include "LaTeXFeatures.h"
 #include "LyXView.h"
+
 #include "frontends/Dialogs.h"
+
 #include "support/lstrings.h"
 
+
+using std::ostream;
+
+
 InsetCitation::InsetCitation(InsetCommandParams const & p, bool)
        : InsetCommand(p)
 {}
 
-string const InsetCitation::getScreenLabel() const
+string const InsetCitation::getScreenLabel(Buffer const *) const
 {
        string keys(getContents());
 
@@ -36,7 +42,7 @@ string const InsetCitation::getScreenLabel() const
                keys = frontStrip(split(keys, label, ',')) + ",";
 
                string::size_type const maxSize = 40;
-               while (contains( keys, "," )) {
+               while (contains(keys, ",")) {
                        string key;
                        keys = frontStrip(split(keys, key, ','));
 
@@ -63,7 +69,12 @@ void InsetCitation::edit(BufferView * bv, int, int, unsigned int)
        bv->owner()->getDialogs()->showCitation(this);
 }
 
-int InsetCitation::ascii(Buffer const *, std::ostream & os, int) const
+void InsetCitation::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+int InsetCitation::ascii(Buffer const *, ostream & os, int) const
 {
         os << "[" << getContents() << "]";
         return 0;
@@ -73,7 +84,7 @@ int InsetCitation::ascii(Buffer const *, std::ostream & os, int) const
 // the \cite command is valid. Eg, the user has natbib enabled, inputs some
 // citations and then changes his mind, turning natbib support off. The output
 // should revert to \cite[]{}
-int InsetCitation::latex(Buffer const * buffer, std::ostream & os,
+int InsetCitation::latex(Buffer const * buffer, ostream & os,
                        bool /*fragile*/, bool/*fs*/) const
 {
        os << "\\";
@@ -85,7 +96,14 @@ int InsetCitation::latex(Buffer const * buffer, std::ostream & os,
        if (!getOptions().empty())
                os << "[" << getOptions() << "]";
 
-       os << "{" << getContents() << "}";
+       // Paranoia check: make sure that there is no whitespace in here
+       string content;
+       for (string::const_iterator it = getContents().begin();
+            it != getContents().end(); ++it) {
+               if (*it != ' ') content += *it;
+       }
+       
+       os << "{" << content << "}";
 
        return 0;
 }
@@ -93,7 +111,6 @@ int InsetCitation::latex(Buffer const * buffer, std::ostream & os,
 
 void InsetCitation::validate(LaTeXFeatures & features) const
 {
-       if (getCmdName() != "cite" && features.bufferParams().use_natbib)
-               features.natbib = true;
+       if (features.bufferParams().use_natbib)
+               features.require("natbib");
 }
-