]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetbibitem.C
The speed patch: redraw only rows that have changed
[lyx.git] / src / insets / insetbibitem.C
index 7338afbbbfa47559c3b66fc33851b8651faf414f..c26cb17a6e530884b2cbf37228256a377c0f4e71 100644 (file)
 
 #include "support/lstrings.h"
 #include "support/std_ostream.h"
-#include "support/tostr.h"
+#include "support/convert.h"
 
 using lyx::support::prefixIs;
-using lyx::support::strToInt;
 
 using std::max;
 using std::string;
@@ -43,7 +42,7 @@ InsetBibitem::InsetBibitem(InsetCommandParams const & p)
        : InsetCommand(p, "bibitem"), counter(1)
 {
        if (getContents().empty())
-               setContents(key_prefix + tostr(++key_counter));
+               setContents(key_prefix + convert<string>(++key_counter));
 }
 
 
@@ -62,11 +61,10 @@ void InsetBibitem::doDispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_INSET_MODIFY: {
                InsetCommandParams p;
                InsetCommandMailer::string2params("bibitem", cmd.argument, p);
-               if (p.getCmdName().empty())
-                       break;
-               setParams(p);
-               cur.bv().update();
-               cur.bv().fitCursor();
+               if (!p.getCmdName().empty())
+                       setParams(p);
+               else
+                       cur.noUpdate();
                break;
        }
 
@@ -100,14 +98,13 @@ void InsetBibitem::write(Buffer const &, std::ostream & os) const
 // This should be changed!!! (Jug)
 void InsetBibitem::read(Buffer const &, LyXLex & lex)
 {
-       if (lex.eatLine()) {
+       if (lex.eatLine())
                scanCommand(lex.getString());
-       } else {
+       else
                lex.printError("InsetCommand: Parse error: `$$Token'");
-       }
 
        if (prefixIs(getContents(), key_prefix)) {
-               int key = strToInt(getContents().substr(key_prefix.length()));
+               int const key = convert<int>(getContents().substr(key_prefix.length()));
                key_counter = max(key_counter, key);
        }
 }
@@ -115,7 +112,7 @@ void InsetBibitem::read(Buffer const &, LyXLex & lex)
 
 string const InsetBibitem::getBibLabel() const
 {
-       return getOptions().empty() ? tostr(counter) : getOptions();
+       return getOptions().empty() ? convert<string>(counter) : getOptions();
 }
 
 
@@ -131,27 +128,6 @@ int InsetBibitem::plaintext(Buffer const &, ostream & os,
        return 0;
 }
 
-// ale070405 This function maybe shouldn't be here. We'll fix this at 0.13.
-int bibitemMaxWidth(BufferView * bv, LyXFont const &)
-{
-       int w = 0;
-       // Ha, now we are mainly at 1.2.0 and it is still here (Jug)
-       // Does look like a hack? It is! (but will change at 0.13)
-       ParagraphList::iterator it = bv->buffer()->paragraphs().begin();
-       ParagraphList::iterator end = bv->buffer()->paragraphs().end();
-       for (; it != end; ++it) {
-               if (it->bibitem()) {
-#ifdef WITH_WARNINGS
-#warning metrics broken!
-#endif
-                       int const wx = it->bibitem()->width();
-                       if (wx > w)
-                               w = wx;
-               }
-       }
-       return w;
-}
-
 
 // ale070405
 string const bibitemWidest(Buffer const & buffer)