Il 23/05/2011 14:50, Abdel Younes ha scritto:
I don't think it would work. That buffer has no access to the bibliography or
reference info from the working buffer. Probably what you would need to do is
copy the reference cache and the bibinfo cache, though you'd also have to make
sure they were updated as well whenever they changed in the main buffer, or the
main buffer switched, etc. Seems very delicate.
In a way, what we want really is for the search buffer to treat the main buffer
as its parent, but only for certain purposes. Maybe there is some way to
accomplish that....
Maybe the solution is to create a special EmbeddedBuffer class that will
constantly refer to the document Buffer (const access to the params, ref cache,
etc). EmbeddedBuffer would inherit Buffer and would offer only const access to
the params/etc.
The problem might be then when the user inserts a citation (bibliography
environment) into the Find/Replace WAs (because you would try to modify
those const-access items/caches).
Ok, here I've got something completely different (see attached patch):
simply use the main document's buffer(), when scanning for citations
from within the dialog.
I checked that also the ReferenceGui (for labels) makes something like
that, even though indirectly because in that case there's a combo box on
the top allowing the user to choose which buffer should be scanned for
labels.
This seems to work fine for me, should I commit ?
T.
Index: src/frontends/qt4/GuiCitation.h
===================================================================
--- src/frontends/qt4/GuiCitation.h (revisione 38819)
+++ src/frontends/qt4/GuiCitation.h (copia locale)
@@ -42,6 +42,9 @@
GuiCitation(GuiView & lv);
///
~GuiCitation();
+ /// We use the main document's buffer() so to catch the citations
+ /// defined there, also while using the dialog from the Adv F&R.
+ Buffer const & buffer() const;
private Q_SLOTS:
void on_okPB_clicked();
Index: src/frontends/qt4/GuiCitation.cpp
===================================================================
--- src/frontends/qt4/GuiCitation.cpp (revisione 38819)
+++ src/frontends/qt4/GuiCitation.cpp (copia locale)
@@ -20,6 +20,7 @@
#include "qt_helpers.h"
#include "Buffer.h"
+#include "BufferView.h"
#include "BiblioInfo.h"
#include "BufferParams.h"
#include "FuncRequest.h"
@@ -625,7 +626,7 @@
bool GuiCitation::initialiseParams(string const & data)
{
InsetCommand::string2params(data, params_);
- CiteEngine const engine = buffer().params().citeEngine();
+ CiteEngine const engine = citeEngine();
citeStyles_ = citeStyles(engine);
init();
return true;
@@ -763,6 +764,15 @@
}
+Buffer const & GuiCitation::buffer() const
+{
+ if (lyxview().documentBufferView())
+ return lyxview().documentBufferView()->buffer();
+ else
+ return lyxview().currentBufferView()->buffer();
+}
+
+
void GuiCitation::saveSession() const
{
Dialog::saveSession();