On Wed, Sep 27, 2006 at 12:16:33PM +0200, Jean-Marc Lasgouttes wrote:
> >>>>> "Juergen" == Juergen Spitzmueller <[EMAIL PROTECTED]> writes:
> 
> Juergen> "Changing the citation key does not update references to it"
> Juergen> http://bugzilla.lyx.org/show_bug.cgi?id=2744
> 
> Juergen> The attached patch against 1.4svn fixes the bug by extending
> Juergen> changeRefsIfUnique. It works very nicely. OK for trunk and
> Juergen> branch? (I have another fix for bug 1684 in the pipe).
> 
> Some comments:
> 
>   -void Buffer::changeRefsIfUnique(string const & from, string const & to)
>   +void Buffer::changeRefsIfUnique(string const & from, string const & to, 
> InsetBase::Code code)
> 
> I do not like passing an inset code if it is not really generic (the
> codes are hardcoded later). If we follow this route, we should at
> least assert on code's value.
> 
>   +   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);
> 
> I am sure there is a nice way of doing the counting without building
> additional lists, but we would need Lars' help for that :)
> 
>   +   } else
>   +           getLabelList(labels);
>   +
>           if (lyx::count(labels.begin(), labels.end(), from) > 1)
>                   return;

Why not have a virtual function in the insets filling a list and
iterating over all insets in the buffer calling this function?

I know that InsetBase is pretty fat already, nevertheless this feels
better than hard-coding inset codes.

Andre'

Reply via email to