mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-05 17:09:56 +00:00
Fix bug 2744:
* buffer.[Ch] (changeRefsIfUnique): extend to handle bibitems as well (the function takes a InsetCode argument now) [bug 2744]; clean up by using InsetIterator. * math_hullinset.C (doDispatch): changeRefsIfUnique needs a InsetCode argument now (bug 2744). * insetlabel (doDispatch): changeRefsIfUnique needs a InsetCode argument now. * insetbibitem (doDispatch): use changeRefsIfUnique (actual fix for bug 2744). * insetcommand.[Ch]: * insetcite.[Ch]: implement replaceContents, which is used by changeRefsIfUnique. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@15282 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
294109c66a
commit
11b7b84d1f
@ -1,3 +1,9 @@
|
|||||||
|
2006-10-09 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||||
|
|
||||||
|
* buffer.[Ch] (changeRefsIfUnique): extend to handle bibitems
|
||||||
|
as well (the function takes a InsetCode argument now) [bug 2744];
|
||||||
|
clean up by using InsetIterator.
|
||||||
|
|
||||||
2006-09-21 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
2006-09-21 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||||
|
|
||||||
* lyxfunc.C (getStatus): fix handling of LFUN_RUNCHKTEX (bug 2831)
|
* lyxfunc.C (getStatus): fix handling of LFUN_RUNCHKTEX (bug 2831)
|
||||||
|
37
src/buffer.C
37
src/buffer.C
@ -67,7 +67,7 @@
|
|||||||
#include "support/lyxalgo.h"
|
#include "support/lyxalgo.h"
|
||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
#include "support/fs_extras.h"
|
#include "support/fs_extras.h"
|
||||||
# include "support/gzstream.h"
|
#include "support/gzstream.h"
|
||||||
#include "support/lyxlib.h"
|
#include "support/lyxlib.h"
|
||||||
#include "support/os.h"
|
#include "support/os.h"
|
||||||
#include "support/path.h"
|
#include "support/path.h"
|
||||||
@ -1612,31 +1612,30 @@ void Buffer::saveCursor(StableDocIterator cur, StableDocIterator anc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Buffer::changeRefsIfUnique(string const & from, string const & to)
|
void Buffer::changeRefsIfUnique(string const & from, string const & to, InsetBase::Code code)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(code == InsetBase::CITE_CODE || code == InsetBase::REF_CODE);
|
||||||
// Check if the label 'from' appears more than once
|
// Check if the label 'from' appears more than once
|
||||||
vector<string> labels;
|
vector<string> labels;
|
||||||
getLabelList(labels);
|
|
||||||
|
if (code == InsetBase::CITE_CODE) {
|
||||||
|
vector<pair<string, string> > keys;
|
||||||
|
fillWithBibKeys(keys);
|
||||||
|
vector<pair<string, string> >::const_iterator bit = keys.begin();
|
||||||
|
vector<pair<string, string> >::const_iterator bend = keys.end();
|
||||||
|
|
||||||
|
for (; bit != bend; ++bit)
|
||||||
|
labels.push_back(bit->first);
|
||||||
|
} else
|
||||||
|
getLabelList(labels);
|
||||||
|
|
||||||
if (lyx::count(labels.begin(), labels.end(), from) > 1)
|
if (lyx::count(labels.begin(), labels.end(), from) > 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
InsetBase::Code code = InsetBase::REF_CODE;
|
for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) {
|
||||||
|
if (it->lyxCode() == code) {
|
||||||
ParIterator it = par_iterator_begin();
|
InsetCommand & inset = dynamic_cast<InsetCommand &>(*it);
|
||||||
ParIterator end = par_iterator_end();
|
inset.replaceContents(from, to);
|
||||||
for ( ; it != end; ++it) {
|
|
||||||
bool changed_inset = false;
|
|
||||||
for (InsetList::iterator it2 = it->insetlist.begin();
|
|
||||||
it2 != it->insetlist.end(); ++it2) {
|
|
||||||
if (it2->inset->lyxCode() == code) {
|
|
||||||
InsetCommand * inset = static_cast<InsetCommand *>(it2->inset);
|
|
||||||
if (inset->getContents() == from) {
|
|
||||||
inset->setContents(to);
|
|
||||||
//inset->setButtonLabel();
|
|
||||||
changed_inset = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ public:
|
|||||||
///
|
///
|
||||||
StableDocIterator getAnchor() const { return anchor_; }
|
StableDocIterator getAnchor() const { return anchor_; }
|
||||||
///
|
///
|
||||||
void changeRefsIfUnique(std::string const & from, std::string const & to);
|
void changeRefsIfUnique(std::string const & from, std::string const & to, InsetBase::Code code);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Inserts a file into a document
|
/** Inserts a file into a document
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
2006-10-09 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||||
|
|
||||||
|
* insetlabel (doDispatch): changeRefsIfUnique needs a
|
||||||
|
InsetCode argument now.
|
||||||
|
|
||||||
|
* insetbibitem (doDispatch): use changeRefsIfUnique
|
||||||
|
(actual fix for bug 2744).
|
||||||
|
|
||||||
|
* insetcommand.[Ch]:
|
||||||
|
* insetcite.[Ch]: implement replaceContents, which is
|
||||||
|
used by changeRefsIfUnique.
|
||||||
|
|
||||||
2006-10-03 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
2006-10-03 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||||
|
|
||||||
* insetvspace.C (doDispatch): open dialog on mouse release,
|
* insetvspace.C (doDispatch): open dialog on mouse release,
|
||||||
|
@ -61,10 +61,14 @@ void InsetBibitem::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
case LFUN_INSET_MODIFY: {
|
case LFUN_INSET_MODIFY: {
|
||||||
InsetCommandParams p;
|
InsetCommandParams p;
|
||||||
InsetCommandMailer::string2params("bibitem", cmd.argument, p);
|
InsetCommandMailer::string2params("bibitem", cmd.argument, p);
|
||||||
if (!p.getCmdName().empty())
|
if (p.getCmdName().empty()) {
|
||||||
setParams(p);
|
|
||||||
else
|
|
||||||
cur.noUpdate();
|
cur.noUpdate();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (p.getContents() != params().getContents())
|
||||||
|
cur.bv().buffer()->changeRefsIfUnique(params().getContents(),
|
||||||
|
p.getContents(), InsetBase::CITE_CODE);
|
||||||
|
setParams(p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,14 +28,19 @@
|
|||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
using lyx::support::ascii_lowercase;
|
using lyx::support::ascii_lowercase;
|
||||||
using lyx::support::contains;
|
using lyx::support::contains;
|
||||||
using lyx::support::getVectorFromString;
|
using lyx::support::getVectorFromString;
|
||||||
|
using lyx::support::getStringFromVector;
|
||||||
using lyx::support::ltrim;
|
using lyx::support::ltrim;
|
||||||
using lyx::support::rtrim;
|
using lyx::support::rtrim;
|
||||||
using lyx::support::split;
|
using lyx::support::split;
|
||||||
|
using lyx::support::tokenPos;
|
||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
using std::replace;
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
@ -430,3 +435,14 @@ void InsetCitation::validate(LaTeXFeatures & features) const
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InsetCitation::replaceContents(string const & from, string const & to)
|
||||||
|
{
|
||||||
|
if (tokenPos(getContents(), ',', from) != -1) {
|
||||||
|
vector<string> items = getVectorFromString(getContents());
|
||||||
|
replace(items.begin(), items.end(), from, to);
|
||||||
|
setContents(getStringFromVector(items));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,8 @@ public:
|
|||||||
OutputParams const &) const;
|
OutputParams const &) const;
|
||||||
///
|
///
|
||||||
void validate(LaTeXFeatures &) const;
|
void validate(LaTeXFeatures &) const;
|
||||||
|
///
|
||||||
|
void replaceContents(std::string const & from, std::string const & to);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual std::auto_ptr<InsetBase> doClone() const
|
virtual std::auto_ptr<InsetBase> doClone() const
|
||||||
|
@ -156,6 +156,13 @@ bool InsetCommand::getStatus(LCursor & cur, FuncRequest const & cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InsetCommand::replaceContents(std::string const & from, string const & to)
|
||||||
|
{
|
||||||
|
if (getContents() == from)
|
||||||
|
setContents(to);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetCommandMailer::InsetCommandMailer(string const & name,
|
InsetCommandMailer::InsetCommandMailer(string const & name,
|
||||||
InsetCommand & inset)
|
InsetCommand & inset)
|
||||||
: name_(name), inset_(inset)
|
: name_(name), inset_(inset)
|
||||||
|
@ -72,6 +72,8 @@ public:
|
|||||||
p_.setContents(c);
|
p_.setContents(c);
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
|
virtual void replaceContents(std::string const & from, std::string const & to);
|
||||||
|
///
|
||||||
std::string const & getOptions() const { return p_.getOptions(); }
|
std::string const & getOptions() const { return p_.getOptions(); }
|
||||||
///
|
///
|
||||||
std::string const & getSecOptions() const { return p_.getSecOptions(); }
|
std::string const & getSecOptions() const { return p_.getSecOptions(); }
|
||||||
|
@ -71,7 +71,7 @@ void InsetLabel::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
if (p.getContents() != params().getContents())
|
if (p.getContents() != params().getContents())
|
||||||
cur.bv().buffer()->changeRefsIfUnique(params().getContents(),
|
cur.bv().buffer()->changeRefsIfUnique(params().getContents(),
|
||||||
p.getContents());
|
p.getContents(), InsetBase::REF_CODE);
|
||||||
setParams(p);
|
setParams(p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2006-10-09 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||||
|
|
||||||
|
* math_hullinset.C (doDispatch): changeRefsIfUnique needs a
|
||||||
|
InsetCode argument now (bug 2744).
|
||||||
|
|
||||||
2006-09-25 Enrico Forestieri <forenr@tlc.unipr.it>
|
2006-09-25 Enrico Forestieri <forenr@tlc.unipr.it>
|
||||||
|
|
||||||
* math_symbolinset.C (maxima): newer maxima versions use inf
|
* math_symbolinset.C (maxima): newer maxima versions use inf
|
||||||
|
@ -1078,7 +1078,7 @@ void MathHullInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
numbered(r, true);
|
numbered(r, true);
|
||||||
string old = label(r);
|
string old = label(r);
|
||||||
if (str != old) {
|
if (str != old) {
|
||||||
cur.bv().buffer()->changeRefsIfUnique(old, str);
|
cur.bv().buffer()->changeRefsIfUnique(old, str, InsetBase::REF_CODE);
|
||||||
label(r, str);
|
label(r, str);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -40,6 +40,8 @@ What's new
|
|||||||
|
|
||||||
- Support lgathered and rgathered math environments.
|
- Support lgathered and rgathered math environments.
|
||||||
|
|
||||||
|
- Update bibliography references when the entry has been changed (bug 2744).
|
||||||
|
|
||||||
* User Interface:
|
* User Interface:
|
||||||
|
|
||||||
- Fix a crash that occured on exit if the clipboard was not empty (only on
|
- Fix a crash that occured on exit if the clipboard was not empty (only on
|
||||||
|
Loading…
Reference in New Issue
Block a user