From 2b99c9b18976f63d4a83e21e96d32b5acb07160b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Tue, 18 Feb 2003 12:36:02 +0000 Subject: [PATCH] re-enable insertion of bibrefs (and remove 19 lines...) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6195 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/buffer.C | 25 +++++++------------------ src/frontends/xforms/FormCitation.C | 11 +++++------ src/frontends/xforms/FormCitation.h | 4 ++-- src/insets/inset.h | 4 +++- src/insets/insetbib.C | 22 ++++++++-------------- src/insets/insetbib.h | 6 ++---- 6 files changed, 27 insertions(+), 45 deletions(-) diff --git a/src/buffer.C b/src/buffer.C index 53113abb48..26a813cd82 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -2884,24 +2884,6 @@ vector > const Buffer::getBibkeyList() const } vector keys; - ParagraphList::iterator pit = paragraphs.begin(); - ParagraphList::iterator pend = paragraphs.end(); - for (; pit != pend; ++pit) { - InsetBibKey * bib = pit->bibkey(); - if (bib) { - string const key = bib->getContents(); - string const opt = bib->getOptions(); - string const ref = pit->asString(this, false); - string const info = opt + "TheBibliographyRef" + ref; - - keys.push_back(StringPair(key, info)); - } - } - - if (!keys.empty()) - return keys; - - // Might be either using bibtex or a child has bibliography for (inset_iterator it = inset_const_iterator_begin(); it != inset_const_iterator_end(); ++it) { // Search for Bibtex or Include inset @@ -2913,6 +2895,13 @@ vector > const Buffer::getBibkeyList() const vector const tmp = static_cast(*it).getKeys(); keys.insert(keys.end(), tmp.begin(), tmp.end()); + } else if (it->lyxCode() == Inset::BIBKEY_CODE) { + InsetBibKey & bib = static_cast(*it); + string const key = bib.getContents(); + string const opt = bib.getOptions(); + string const ref; // = pit->asString(this, false); + string const info = opt + "TheBibliographyRef" + ref; + keys.push_back(StringPair(key, info)); } } diff --git a/src/frontends/xforms/FormCitation.C b/src/frontends/xforms/FormCitation.C index 87194a26da..a1b9014b58 100644 --- a/src/frontends/xforms/FormCitation.C +++ b/src/frontends/xforms/FormCitation.C @@ -48,8 +48,7 @@ void fillChoice(FD_citation * dialog, vector vec) { // Check whether the current contents of the browser will be // changed by loading the contents of the vec... - vector const choice_style = - getVector(dialog->choice_style); + vector const choice_style = getVector(dialog->choice_style); if (vec == choice_style) return; @@ -320,8 +319,7 @@ ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long) // with the selected browser_cite key fl_clear_browser(dialog_->browser_info); string const tmp = - formatted(biblio::getInfo(theMap, - citekeys[sel - 1]), + formatted(biblio::getInfo(theMap, citekeys[sel - 1]), dialog_->browser_info->w - 10); fl_add_browser_line(dialog_->browser_info, tmp.c_str()); } @@ -433,7 +431,8 @@ void FormCitation::update() // Use the first citekey to fill choice_style string key; - if (!citekeys.empty()) key = citekeys[0]; + if (!citekeys.empty()) + key = citekeys[0]; fillChoice(dialog_.get(), controller().getCiteStrings(key)); @@ -477,7 +476,7 @@ void FormCitation::updateBrowser(FL_OBJECT * browser, fl_clear_browser(browser); for (vector::const_iterator it = keys.begin(); - it < keys.end(); ++it) { + it != keys.end(); ++it) { string key = trim(*it); if (!key.empty()) fl_add_browser_line(browser, key.c_str()); diff --git a/src/frontends/xforms/FormCitation.h b/src/frontends/xforms/FormCitation.h index cd32c12e44..8c03035160 100644 --- a/src/frontends/xforms/FormCitation.h +++ b/src/frontends/xforms/FormCitation.h @@ -55,9 +55,9 @@ private: /// void setCiteButtons(State) const; - /// + /// used keys (left panel) std::vector citekeys; - /// + /// available keys (right panel) std::vector bibkeys; }; diff --git a/src/insets/inset.h b/src/insets/inset.h index 0f66e29c6c..dc1f49782f 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -122,7 +122,9 @@ public: /// INDEX_PRINT_CODE, /// - OPTARG_CODE + OPTARG_CODE, + /// + BIBKEY_CODE }; /// diff --git a/src/insets/insetbib.C b/src/insets/insetbib.C index e77956c59b..2fdee1a160 100644 --- a/src/insets/insetbib.C +++ b/src/insets/insetbib.C @@ -51,11 +51,6 @@ InsetBibKey::InsetBibKey(InsetCommandParams const & p) } -InsetBibKey::~InsetBibKey() -{ -} - - Inset * InsetBibKey::clone(Buffer const &, bool) const { InsetBibKey * b = new InsetBibKey(params()); @@ -101,13 +96,13 @@ void InsetBibKey::read(Buffer const *, LyXLex & lex) } } + string const InsetBibKey::getBibLabel() const { - if (! getOptions().empty()) - return getOptions(); - return tostr(counter); + return getOptions().empty() ? tostr(counter) : getOptions(); } + string const InsetBibKey::getScreenLabel(Buffer const *) const { return getContents() + " [" + getBibLabel() + ']'; @@ -126,16 +121,13 @@ void InsetBibKey::edit(BufferView * bv, bool) } + + InsetBibtex::InsetBibtex(InsetCommandParams const & p, bool) : InsetCommand(p) {} -InsetBibtex::~InsetBibtex() -{ -} - - string const InsetBibtex::getScreenLabel(Buffer const *) const { return _("BibTeX Generated References"); @@ -241,8 +233,10 @@ vector const InsetBibtex::getFiles(Buffer const & buffer) const return vec; } + // This method returns a comma separated list of Bibtex entries -vector > const InsetBibtex::getKeys(Buffer const * buffer) const +vector > const + InsetBibtex::getKeys(Buffer const * buffer) const { vector > keys; diff --git a/src/insets/insetbib.h b/src/insets/insetbib.h index 14068e366f..c407c8c79c 100644 --- a/src/insets/insetbib.h +++ b/src/insets/insetbib.h @@ -28,8 +28,6 @@ public: /// InsetBibKey(InsetCommandParams const &); /// - ~InsetBibKey(); - /// Inset * clone(Buffer const &, bool same_id = false) const; /** Currently \bibitem is used as a LyX2.x command, so we need this method. @@ -45,6 +43,8 @@ public: void edit(BufferView * bv, bool front = true); /// EDITABLE editable() const { return IS_EDITABLE; } + /// + Inset::Code lyxCode() const { return Inset::BIBKEY_CODE; } /// keep .lyx format compatible bool directWrite() const { return true; } /// @@ -76,8 +76,6 @@ public: /// InsetBibtex(InsetCommandParams const &, bool same_id = false); /// - ~InsetBibtex(); - /// Inset * clone(Buffer const &, bool same_id = false) const { return new InsetBibtex(params(), same_id); } -- 2.39.2