]> git.lyx.org Git - lyx.git/commitdiff
Compute and output numbers for numerical citations.
authorJulien Rioux <jrioux@lyx.org>
Tue, 14 May 2013 19:50:13 +0000 (21:50 +0200)
committerJulien Rioux <jrioux@lyx.org>
Thu, 16 May 2013 14:10:05 +0000 (16:10 +0200)
lib/layouts/basic.module
lib/layouts/natbib.module
src/BiblioInfo.cpp
src/Buffer.cpp
src/insets/InsetBibitem.cpp

index 5cd393babd0e8c682473d92178e10a5fd0877e55..5c2867a16fab85a0d8a20469364b8a61bceefff5 100644 (file)
@@ -30,7 +30,7 @@ CiteFormat default
        !startlink {!<a href='#LyXCite-%clean:key%'>!}
        !endlink {!</a>!}
 
-       !cite %!startlink%{%label%[[%label%]][[#%key%]]}%!endlink%%!nextcite%
+       !cite %!startlink%{%label%[[%label%]][[{%numericallabel%[[%numericallabel%]][[#%key%]]}]]}%!endlink%%!nextcite%
 
        !nextcite {%next%[[%!sep% %!cite%]]}
        !nexthashkey {%next%[[%!sep% #%key%%!nexthashkey%]]}
index 56c6d002439d21e227dcb6652a6e63330d27d943..2848fb9bb0fb564206d35fb0dd6c21833eb814c9 100644 (file)
@@ -89,15 +89,15 @@ CiteFormat numerical
        !sep ,
        !close ]
 
-       !citet %!abbrvauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%#%key%%!endlink%]]}%!nextcitet%
-       !citealt %!abbrvauthor% %!textbefore%{%dialog%[[#ID]][[%!startlink%#%key%%!endlink%]]}%!nextcitealt%
+       !citet %!abbrvauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%
+       !citealt %!abbrvauthor% %!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitealt%
 
-       !hashkey {%dialog%[[#ID]][[%!startlink%#%key%%!endlink%%!nexthashkey%]]}
+       !hashkey {%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nexthashkey%]]}
 
        !nextcitet {%next%[[%!close%%!sep% %!citet%]]}
        !nextcitealt {%next%[[%!sep% %!citealt%]]}
        !nexthashid {%next%[[%!sep% #ID%!nexthashid%]]}
-       !nexthashkey {%next%[[%!sep% %!startlink%#%key%%!endlink%%!nexthashkey%]]}
+       !nexthashkey {%next%[[%!sep% %!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nexthashkey%]]}
 
        cite %!open%%!textbefore%%!hashkey%%!textafter%%!close%
        citep %!open%%!textbefore%%!hashkey%%!textafter%%!close%
index dfc29bb3309e9e4dd04d067f479860842c6587f8..ed6680226985c39fc3a50ecf18175c3cbb7dec45 100644 (file)
@@ -682,6 +682,8 @@ docstring BibTeXInfo::getValueForKey(string const & oldkey, Buffer const & buf,
                        ret = label_;
                else if (key == "modifier" && modifier_ != 0)
                        ret = modifier_;
+               else if (key == "numericallabel")
+                       ret = cite_number_;
                else if (key == "abbrvauthor")
                        // Special key to provide abbreviated author names.
                        ret = getAbbreviatedAuthor(buf, false);
index 3cb28da1267bf4b7394e3bffeebc9f07068f9d71..014dcd6929cb8df769eee32b63d8aedb727635a4 100644 (file)
@@ -4313,8 +4313,10 @@ void Buffer::updateBuffer(UpdateScope scope, UpdateType utype) const
        DocumentClass const & textclass = master->params().documentClass();
 
        // do this only if we are the top-level Buffer
-       if (master == this)
+       if (master == this) {
+               textclass.counters().reset(from_ascii("bibitem"));
                reloadBibInfoCache();
+       }
 
        // keep the buffers to be children in this set. If the call from the
        // master comes back we can see which of them were actually seen (i.e.
index 5241859ac23ac19c811a75e2348c52959c1bb899..bb879259304dccba9e82f95f69406b49ce45220e 100644 (file)
@@ -204,6 +204,9 @@ void InsetBibitem::read(Lexer & lex)
 
 docstring InsetBibitem::bibLabel() const
 {
+       BufferParams const & bp = buffer().masterBuffer()->params();
+       if (bp.citeEngineType() == ENGINE_TYPE_NUMERICAL)
+               return autolabel_;
        docstring const & label = getParam("label");
        return label.empty() ? autolabel_ : label;
 }
@@ -307,6 +310,17 @@ void InsetBibitem::collectBibKeys(InsetIterator const & it) const
        BibTeXInfo keyvalmap(false);
        keyvalmap.key(key);
        keyvalmap.label(label);
+
+       BufferParams const & bp = buffer().masterBuffer()->params();
+       Counters & counters = bp.documentClass().counters();
+       docstring const bibitem = from_ascii("bibitem");
+       if (bp.citeEngineType() == ENGINE_TYPE_NUMERICAL || getParam("label").empty()) {
+               if (counters.hasCounter(bibitem))
+                       counters.step(bibitem, InternalUpdate);
+               string const & lang = it.paragraph().getParLanguage(bp)->code();
+               keyvalmap.setCiteNumber(counters.theCounter(bibitem, lang));
+       }
+
        DocIterator doc_it(it);
        doc_it.forwardPos();
        keyvalmap[from_ascii("ref")] = doc_it.paragraph().asString(
@@ -321,7 +335,7 @@ void InsetBibitem::updateBuffer(ParIterator const & it, UpdateType utype)
        BufferParams const & bp = buffer().masterBuffer()->params();
        Counters & counters = bp.documentClass().counters();
        docstring const bibitem = from_ascii("bibitem");
-       if (getParam("label").empty()) {
+       if (bp.citeEngineType() == ENGINE_TYPE_NUMERICAL || getParam("label").empty()) {
                if (counters.hasCounter(bibitem))
                        counters.step(bibitem, utype);
                string const & lang = it.paragraph().getParLanguage(bp)->code();