mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-23 00:38:01 +00:00
Remove embedding stuff from InsetBibtex.
There might be some header cleanup that can be done here, or some uses of forward declarations and such. This was pretty quick and dirty, just to get it done. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24357 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
31808dd993
commit
5cadecf3f6
@ -207,7 +207,7 @@ public:
|
|||||||
|
|
||||||
/// A cache for the bibfiles (including bibfiles of loaded child
|
/// A cache for the bibfiles (including bibfiles of loaded child
|
||||||
/// documents), needed for appropriate update of natbib labels.
|
/// documents), needed for appropriate update of natbib labels.
|
||||||
mutable EmbeddedFileList bibfilesCache_;
|
mutable support::FileNameList bibfilesCache_;
|
||||||
|
|
||||||
mutable RefCache ref_cache_;
|
mutable RefCache ref_cache_;
|
||||||
|
|
||||||
@ -1388,7 +1388,7 @@ void Buffer::updateBibfilesCache() const
|
|||||||
if (it->lyxCode() == BIBTEX_CODE) {
|
if (it->lyxCode() == BIBTEX_CODE) {
|
||||||
InsetBibtex const & inset =
|
InsetBibtex const & inset =
|
||||||
static_cast<InsetBibtex const &>(*it);
|
static_cast<InsetBibtex const &>(*it);
|
||||||
EmbeddedFileList const bibfiles = inset.getBibFiles();
|
support::FileNameList const bibfiles = inset.getBibFiles();
|
||||||
d->bibfilesCache_.insert(d->bibfilesCache_.end(),
|
d->bibfilesCache_.insert(d->bibfilesCache_.end(),
|
||||||
bibfiles.begin(),
|
bibfiles.begin(),
|
||||||
bibfiles.end());
|
bibfiles.end());
|
||||||
@ -1396,7 +1396,7 @@ void Buffer::updateBibfilesCache() const
|
|||||||
InsetInclude & inset =
|
InsetInclude & inset =
|
||||||
static_cast<InsetInclude &>(*it);
|
static_cast<InsetInclude &>(*it);
|
||||||
inset.updateBibfilesCache();
|
inset.updateBibfilesCache();
|
||||||
EmbeddedFileList const & bibfiles =
|
support::FileNameList const & bibfiles =
|
||||||
inset.getBibfilesCache(*this);
|
inset.getBibfilesCache(*this);
|
||||||
d->bibfilesCache_.insert(d->bibfilesCache_.end(),
|
d->bibfilesCache_.insert(d->bibfilesCache_.end(),
|
||||||
bibfiles.begin(),
|
bibfiles.begin(),
|
||||||
@ -1406,7 +1406,7 @@ void Buffer::updateBibfilesCache() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EmbeddedFileList const & Buffer::getBibfilesCache() const
|
support::FileNameList const & Buffer::getBibfilesCache() const
|
||||||
{
|
{
|
||||||
// If this is a child document, use the parent's cache instead.
|
// If this is a child document, use the parent's cache instead.
|
||||||
if (d->parent_buffer)
|
if (d->parent_buffer)
|
||||||
|
@ -61,6 +61,7 @@ class WorkAreaManager;
|
|||||||
|
|
||||||
namespace support {
|
namespace support {
|
||||||
class FileName;
|
class FileName;
|
||||||
|
class FileNameList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The buffer object.
|
/** The buffer object.
|
||||||
@ -307,7 +308,7 @@ public:
|
|||||||
void updateBibfilesCache() const;
|
void updateBibfilesCache() const;
|
||||||
/// Return the cache with all bibfiles in use (including bibfiles
|
/// Return the cache with all bibfiles in use (including bibfiles
|
||||||
/// of loaded child documents).
|
/// of loaded child documents).
|
||||||
EmbeddedFileList const & getBibfilesCache() const;
|
support::FileNameList const & getBibfilesCache() const;
|
||||||
///
|
///
|
||||||
void getLabelList(std::vector<docstring> &) const;
|
void getLabelList(std::vector<docstring> &) const;
|
||||||
|
|
||||||
|
@ -208,9 +208,7 @@ void GuiBibtex::addDatabase()
|
|||||||
if (matches.empty()) {
|
if (matches.empty()) {
|
||||||
QString label = item->text();
|
QString label = item->text();
|
||||||
QListWidgetItem * db = new QListWidgetItem(label);
|
QListWidgetItem * db = new QListWidgetItem(label);
|
||||||
db->setFlags(db->flags() | Qt::ItemIsSelectable
|
db->setFlags(db->flags() | Qt::ItemIsSelectable);
|
||||||
| Qt::ItemIsUserCheckable);
|
|
||||||
db->setCheckState(Qt::Checked);
|
|
||||||
databaseLW->addItem(db);
|
databaseLW->addItem(db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,9 +221,7 @@ void GuiBibtex::addDatabase()
|
|||||||
databaseLW->findItems(f, Qt::MatchExactly);
|
databaseLW->findItems(f, Qt::MatchExactly);
|
||||||
if (matches.empty()) {
|
if (matches.empty()) {
|
||||||
QListWidgetItem * db = new QListWidgetItem(f);
|
QListWidgetItem * db = new QListWidgetItem(f);
|
||||||
db->setFlags(db->flags() | Qt::ItemIsSelectable
|
db->setFlags(db->flags() | Qt::ItemIsSelectable);
|
||||||
| Qt::ItemIsUserCheckable);
|
|
||||||
db->setCheckState(Qt::Checked);
|
|
||||||
databaseLW->addItem(db);
|
databaseLW->addItem(db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,19 +286,14 @@ void GuiBibtex::updateContents()
|
|||||||
databaseLW->clear();
|
databaseLW->clear();
|
||||||
|
|
||||||
docstring bibs = params_["bibfiles"];
|
docstring bibs = params_["bibfiles"];
|
||||||
docstring embs = params_["embed"];
|
|
||||||
docstring bib;
|
docstring bib;
|
||||||
docstring emb;
|
|
||||||
|
|
||||||
while (!bibs.empty()) {
|
while (!bibs.empty()) {
|
||||||
bibs = split(bibs, bib, ',');
|
bibs = split(bibs, bib, ',');
|
||||||
embs = split(embs, emb, ',');
|
|
||||||
bib = trim(bib);
|
bib = trim(bib);
|
||||||
if (!bib.empty()) {
|
if (!bib.empty()) {
|
||||||
QListWidgetItem * db = new QListWidgetItem(toqstr(bib));
|
QListWidgetItem * db = new QListWidgetItem(toqstr(bib));
|
||||||
db->setFlags(db->flags() | Qt::ItemIsSelectable
|
db->setFlags(db->flags() | Qt::ItemIsSelectable);
|
||||||
| Qt::ItemIsUserCheckable);
|
|
||||||
db->setCheckState(emb.empty() ? Qt::Unchecked : Qt::Checked);
|
|
||||||
databaseLW->addItem(db);
|
databaseLW->addItem(db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,28 +351,17 @@ void GuiBibtex::updateContents()
|
|||||||
void GuiBibtex::applyView()
|
void GuiBibtex::applyView()
|
||||||
{
|
{
|
||||||
docstring dbs;
|
docstring dbs;
|
||||||
docstring emb;
|
|
||||||
|
|
||||||
unsigned int maxCount = databaseLW->count();
|
unsigned int maxCount = databaseLW->count();
|
||||||
Buffer & buf = buffer();
|
|
||||||
for (unsigned int i = 0; i < maxCount; i++) {
|
for (unsigned int i = 0; i < maxCount; i++) {
|
||||||
if (i != 0) {
|
if (i != 0)
|
||||||
dbs += ',';
|
dbs += ',';
|
||||||
emb += ',';
|
|
||||||
}
|
|
||||||
QString item = databaseLW->item(i)->text();
|
QString item = databaseLW->item(i)->text();
|
||||||
docstring bibfile = qstring_to_ucs4(item);
|
docstring bibfile = qstring_to_ucs4(item);
|
||||||
dbs += bibfile;
|
dbs += bibfile;
|
||||||
if (databaseLW->item(i)->checkState() == Qt::Checked) {
|
|
||||||
FileName bibfilepath = InsetBibtex::getBibTeXPath(bibfile, buf);
|
|
||||||
string inzipName = EmbeddedFile(bibfilepath.absFilename(),
|
|
||||||
buf.filePath()).inzipName();
|
|
||||||
emb += from_utf8(inzipName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
params_["bibfiles"] = dbs;
|
params_["bibfiles"] = dbs;
|
||||||
params_["embed"] = emb;
|
|
||||||
|
|
||||||
docstring const bibstyle = qstring_to_ucs4(styleCB->currentText());
|
docstring const bibstyle = qstring_to_ucs4(styleCB->currentText());
|
||||||
bool const bibtotoc = bibtocCB->isChecked();
|
bool const bibtotoc = bibtocCB->isChecked();
|
||||||
|
@ -176,7 +176,7 @@
|
|||||||
<string>BibTeX database to use</string>
|
<string>BibTeX database to use</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Databa&ses (select to embed when saved in bundled format)</string>
|
<string>Databa&ses</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment" >
|
<property name="alignment" >
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "BufferParams.h"
|
#include "BufferParams.h"
|
||||||
#include "DispatchResult.h"
|
#include "DispatchResult.h"
|
||||||
#include "EmbeddedFiles.h"
|
|
||||||
#include "Encoding.h"
|
#include "Encoding.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
#include "LaTeXFeatures.h"
|
#include "LaTeXFeatures.h"
|
||||||
@ -48,30 +47,10 @@ namespace os = support::os;
|
|||||||
|
|
||||||
|
|
||||||
InsetBibtex::InsetBibtex(InsetCommandParams const & p)
|
InsetBibtex::InsetBibtex(InsetCommandParams const & p)
|
||||||
: InsetCommand(p, "bibtex"), bibfiles_()
|
: InsetCommand(p, "bibtex")
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
void InsetBibtex::setBuffer(Buffer & buffer)
|
|
||||||
{
|
|
||||||
// FIXME We ought to have a buffer.
|
|
||||||
if (buffer_) {
|
|
||||||
EmbeddedFileList::iterator it = bibfiles_.begin();
|
|
||||||
EmbeddedFileList::iterator en = bibfiles_.end();
|
|
||||||
for (; it != en; ++it) {
|
|
||||||
try {
|
|
||||||
*it = it->copyTo(buffer);
|
|
||||||
} catch (ExceptionMessage const & message) {
|
|
||||||
Alert::error(message.title_, message.details_);
|
|
||||||
// failed to embed
|
|
||||||
it->setEmbed(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
InsetCommand::setBuffer(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ParamInfo const & InsetBibtex::findInfo(string const & /* cmdName */)
|
ParamInfo const & InsetBibtex::findInfo(string const & /* cmdName */)
|
||||||
{
|
{
|
||||||
static ParamInfo param_info_;
|
static ParamInfo param_info_;
|
||||||
@ -106,8 +85,6 @@ void InsetBibtex::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
setParams(p);
|
setParams(p);
|
||||||
updateBibFiles();
|
|
||||||
updateParam();
|
|
||||||
buffer().updateBibfilesCache();
|
buffer().updateBibfilesCache();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -162,11 +139,14 @@ int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
|
|||||||
// use such filenames.)
|
// use such filenames.)
|
||||||
// Otherwise, store the (maybe absolute) path to the original,
|
// Otherwise, store the (maybe absolute) path to the original,
|
||||||
// unmangled database name.
|
// unmangled database name.
|
||||||
EmbeddedFileList::const_iterator it = bibfiles_.begin();
|
vector<docstring> bibfilelist = getVectorFromString(getParam("bibfiles"));
|
||||||
EmbeddedFileList::const_iterator it_end = bibfiles_.end();
|
vector<docstring>::const_iterator it = bibfilelist.begin();
|
||||||
|
vector<docstring>::const_iterator en = bibfilelist.end();
|
||||||
odocstringstream dbs;
|
odocstringstream dbs;
|
||||||
for (; it != it_end; ++it) {
|
bool didone = false;
|
||||||
string utf8input = removeExtension(it->availableFile().absFilename());
|
|
||||||
|
for (; it != en; ++it) {
|
||||||
|
string utf8input = to_utf8(*it);
|
||||||
string database =
|
string database =
|
||||||
normalizeName(buffer(), runparams, utf8input, ".bib");
|
normalizeName(buffer(), runparams, utf8input, ".bib");
|
||||||
FileName const try_in_file =
|
FileName const try_in_file =
|
||||||
@ -196,8 +176,10 @@ int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
|
|||||||
from_utf8(database));
|
from_utf8(database));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it != bibfiles_.begin())
|
if (didone)
|
||||||
dbs << ',';
|
dbs << ',';
|
||||||
|
else
|
||||||
|
didone =- true;
|
||||||
// FIXME UNICODE
|
// FIXME UNICODE
|
||||||
dbs << from_utf8(latex_path(database));
|
dbs << from_utf8(latex_path(database));
|
||||||
}
|
}
|
||||||
@ -305,9 +287,27 @@ int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EmbeddedFileList const & InsetBibtex::getBibFiles() const
|
support::FileNameList InsetBibtex::getBibFiles() const
|
||||||
{
|
{
|
||||||
return bibfiles_;
|
FileName path(buffer().filePath());
|
||||||
|
support::PathChanger p(path);
|
||||||
|
|
||||||
|
FileNameList vec;
|
||||||
|
|
||||||
|
vector<docstring> bibfilelist = getVectorFromString(getParam("bibfiles"));
|
||||||
|
vector<docstring>::const_iterator it = bibfilelist.begin();
|
||||||
|
vector<docstring>::const_iterator en = bibfilelist.end();
|
||||||
|
for (; it != en; ++it) {
|
||||||
|
FileName const file =
|
||||||
|
findtexfile(changeExtension(to_utf8(*it), "bib"), "bib");
|
||||||
|
|
||||||
|
// If we didn't find a matching file name just fail silently
|
||||||
|
if (!file.empty())
|
||||||
|
vec.push_back(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
return vec;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -570,11 +570,11 @@ void InsetBibtex::fillWithBibKeys(BiblioInfo & keylist,
|
|||||||
// We don't restrict keys to ASCII in LyX, since our own
|
// We don't restrict keys to ASCII in LyX, since our own
|
||||||
// InsetBibitem can generate non-ASCII keys, and nonstandard
|
// InsetBibitem can generate non-ASCII keys, and nonstandard
|
||||||
// 8bit clean bibtex forks exist.
|
// 8bit clean bibtex forks exist.
|
||||||
EmbeddedFileList const & files = getBibFiles();
|
support::FileNameList const & files = getBibFiles();
|
||||||
EmbeddedFileList::const_iterator it = files.begin();
|
support::FileNameList::const_iterator it = files.begin();
|
||||||
EmbeddedFileList::const_iterator en = files.end();
|
support::FileNameList::const_iterator en = files.end();
|
||||||
for (; it != en; ++ it) {
|
for (; it != en; ++ it) {
|
||||||
idocfstream ifs(it->availableFile().toFilesystemEncoding().c_str(),
|
idocfstream ifs(it->toFilesystemEncoding().c_str(),
|
||||||
ios_base::in, buffer().params().encoding().iconvName());
|
ios_base::in, buffer().params().encoding().iconvName());
|
||||||
|
|
||||||
char_type ch;
|
char_type ch;
|
||||||
@ -718,31 +718,33 @@ FileName InsetBibtex::getBibTeXPath(docstring const & filename, Buffer const & b
|
|||||||
|
|
||||||
bool InsetBibtex::addDatabase(docstring const & db)
|
bool InsetBibtex::addDatabase(docstring const & db)
|
||||||
{
|
{
|
||||||
FileName const texPath = getBibTeXPath(db, buffer());
|
docstring bibfiles = getParam("bibfiles");
|
||||||
EmbeddedFileList::const_iterator efp =
|
if (tokenPos(bibfiles, ',', db) == -1) {
|
||||||
bibfiles_.findFile(texPath.absFilename());
|
if (!bibfiles.empty())
|
||||||
if (efp != bibfiles_.end())
|
bibfiles += ',';
|
||||||
//already have it
|
setParam("bibfiles", bibfiles + db);
|
||||||
return false;
|
return true;
|
||||||
|
}
|
||||||
EmbeddedFile file(texPath.absFilename(), buffer().filePath());
|
return false;
|
||||||
bibfiles_.push_back(file);
|
|
||||||
updateParam();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool InsetBibtex::delDatabase(docstring const & db)
|
bool InsetBibtex::delDatabase(docstring const & db)
|
||||||
{
|
{
|
||||||
FileName const texPath = getBibTeXPath(db, buffer());
|
docstring bibfiles = getParam("bibfiles");
|
||||||
EmbeddedFileList::iterator efp =
|
if (contains(bibfiles, db)) {
|
||||||
bibfiles_.findFile(texPath.absFilename());
|
int const n = tokenPos(bibfiles, ',', db);
|
||||||
if (efp == bibfiles_.end())
|
docstring bd = db;
|
||||||
// don't have it
|
if (n > 0) {
|
||||||
return false;
|
// this is not the first database
|
||||||
|
docstring tmp = ',' + bd;
|
||||||
bibfiles_.erase(efp);
|
setParam("bibfiles", subst(bibfiles, tmp, docstring()));
|
||||||
updateParam();
|
} else if (n == 0)
|
||||||
|
// this is the first (or only) database
|
||||||
|
setParam("bibfiles", split(bibfiles, bd, ','));
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -754,103 +756,4 @@ void InsetBibtex::validate(LaTeXFeatures & features) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetBibtex::updateBibFiles() const
|
|
||||||
{
|
|
||||||
// need to do this to keep old info while also not
|
|
||||||
// copying over any files that have been deleted.
|
|
||||||
EmbeddedFileList oldlist = bibfiles_;
|
|
||||||
bibfiles_.clear();
|
|
||||||
|
|
||||||
docstring bibfile;
|
|
||||||
docstring embfile;
|
|
||||||
|
|
||||||
docstring bibfiles = getParam("bibfiles");
|
|
||||||
docstring embfiles = getParam("embed");
|
|
||||||
|
|
||||||
bibfiles = split(bibfiles, bibfile, ',');
|
|
||||||
embfiles = split(embfiles, embfile, ',');
|
|
||||||
|
|
||||||
while (!bibfile.empty()) {
|
|
||||||
FileName bib = getBibTeXPath(bibfile, buffer());
|
|
||||||
EmbeddedFileList::iterator efp = oldlist.findFile(bib.absFilename());
|
|
||||||
if (efp != oldlist.end()) {
|
|
||||||
// already have this one, but embedding status may have been changed
|
|
||||||
bool old_status = efp->embedded();
|
|
||||||
bool new_status = !embfile.empty();
|
|
||||||
efp->setEmbed(new_status);
|
|
||||||
try {
|
|
||||||
// copy file if embedding status changed.
|
|
||||||
efp->enable(buffer().embedded(), buffer(), old_status != new_status);
|
|
||||||
} catch (ExceptionMessage const & message) {
|
|
||||||
Alert::error(message.title_, message.details_);
|
|
||||||
// failed to change embeddeing status
|
|
||||||
efp->setEmbed(old_status);
|
|
||||||
}
|
|
||||||
bibfiles_.push_back(*efp);
|
|
||||||
} else {
|
|
||||||
EmbeddedFile file(bib.absFilename(), buffer().filePath());
|
|
||||||
file.setEmbed(!embfile.empty());
|
|
||||||
try {
|
|
||||||
file.enable(buffer().embedded(), buffer(), true);
|
|
||||||
} catch (ExceptionMessage const & message) {
|
|
||||||
Alert::error(message.title_, message.details_);
|
|
||||||
// failed to embed
|
|
||||||
file.setEmbed(false);
|
|
||||||
}
|
|
||||||
bibfiles_.push_back(file);
|
|
||||||
}
|
|
||||||
// Get next file name
|
|
||||||
bibfiles = split(bibfiles, bibfile, ',');
|
|
||||||
embfiles = split(embfiles, embfile, ',');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetBibtex::updateParam()
|
|
||||||
{
|
|
||||||
docstring bibfiles;
|
|
||||||
docstring embed;
|
|
||||||
|
|
||||||
bool first = true;
|
|
||||||
|
|
||||||
EmbeddedFileList::iterator it = bibfiles_.begin();
|
|
||||||
EmbeddedFileList::iterator en = bibfiles_.end();
|
|
||||||
for (; it != en; ++it) {
|
|
||||||
if (!first) {
|
|
||||||
bibfiles += ',';
|
|
||||||
embed += ',';
|
|
||||||
} else
|
|
||||||
first = false;
|
|
||||||
bibfiles += from_utf8(it->outputFilename(buffer().filePath()));
|
|
||||||
if (it->embedded())
|
|
||||||
embed += from_utf8(it->inzipName());
|
|
||||||
}
|
|
||||||
setParam("bibfiles", bibfiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetBibtex::registerEmbeddedFiles(EmbeddedFileList & files) const
|
|
||||||
{
|
|
||||||
if (bibfiles_.empty())
|
|
||||||
updateBibFiles();
|
|
||||||
|
|
||||||
EmbeddedFileList::const_iterator it = bibfiles_.begin();
|
|
||||||
EmbeddedFileList::const_iterator en = bibfiles_.end();
|
|
||||||
for (; it != en; ++it)
|
|
||||||
files.registerFile(*it, this, buffer());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetBibtex::updateEmbeddedFile(EmbeddedFile const & file)
|
|
||||||
{
|
|
||||||
// look for the item and update status
|
|
||||||
string const filename = file.absFilename();
|
|
||||||
EmbeddedFileList::iterator it = bibfiles_.findFile(filename);
|
|
||||||
if (it == bibfiles_.end())
|
|
||||||
return;
|
|
||||||
*it = file;
|
|
||||||
updateParam();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
#include "EmbeddedFiles.h"
|
#include "EmbeddedFiles.h"
|
||||||
#include "InsetCommand.h"
|
#include "InsetCommand.h"
|
||||||
|
|
||||||
|
#include "support/FileNameList.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
@ -28,8 +30,6 @@ public:
|
|||||||
///
|
///
|
||||||
InsetBibtex(InsetCommandParams const &);
|
InsetBibtex(InsetCommandParams const &);
|
||||||
///
|
///
|
||||||
virtual void setBuffer(Buffer & buffer);
|
|
||||||
///
|
|
||||||
docstring screenLabel() const;
|
docstring screenLabel() const;
|
||||||
///
|
///
|
||||||
EDITABLE editable() const { return IS_EDITABLE; }
|
EDITABLE editable() const { return IS_EDITABLE; }
|
||||||
@ -42,7 +42,7 @@ public:
|
|||||||
///
|
///
|
||||||
void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const;
|
void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const;
|
||||||
///
|
///
|
||||||
EmbeddedFileList const & getBibFiles() const;
|
support::FileNameList getBibFiles() const;
|
||||||
///
|
///
|
||||||
bool addDatabase(docstring const &);
|
bool addDatabase(docstring const &);
|
||||||
///
|
///
|
||||||
@ -56,24 +56,14 @@ public:
|
|||||||
///
|
///
|
||||||
static bool isCompatibleCommand(std::string const & s)
|
static bool isCompatibleCommand(std::string const & s)
|
||||||
{ return s == "bibtex"; }
|
{ return s == "bibtex"; }
|
||||||
/// update bibfiles and embed from bibfiles_
|
|
||||||
void updateParam();
|
|
||||||
/// look up the path to the file using TeX
|
/// look up the path to the file using TeX
|
||||||
static support::FileName
|
static support::FileName
|
||||||
getBibTeXPath(docstring const & filename, Buffer const & buf);
|
getBibTeXPath(docstring const & filename, Buffer const & buf);
|
||||||
private:
|
private:
|
||||||
///
|
|
||||||
void updateBibFiles() const;
|
|
||||||
///
|
|
||||||
void registerEmbeddedFiles(EmbeddedFileList &) const;
|
|
||||||
///
|
|
||||||
void updateEmbeddedFile(EmbeddedFile const & file);
|
|
||||||
///
|
///
|
||||||
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||||
///
|
///
|
||||||
Inset * clone() const { return new InsetBibtex(*this); }
|
Inset * clone() const { return new InsetBibtex(*this); }
|
||||||
/// embedded bib files
|
|
||||||
mutable EmbeddedFileList bibfiles_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include "buffer_funcs.h"
|
#include "buffer_funcs.h"
|
||||||
#include "BufferParams.h"
|
#include "BufferParams.h"
|
||||||
#include "DispatchResult.h"
|
#include "DispatchResult.h"
|
||||||
#include "EmbeddedFiles.h"
|
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
#include "LaTeXFeatures.h"
|
#include "LaTeXFeatures.h"
|
||||||
#include "ParIterator.h"
|
#include "ParIterator.h"
|
||||||
@ -25,6 +24,7 @@
|
|||||||
|
|
||||||
#include "support/debug.h"
|
#include "support/debug.h"
|
||||||
#include "support/docstream.h"
|
#include "support/docstream.h"
|
||||||
|
#include "support/FileNameList.h"
|
||||||
#include "support/gettext.h"
|
#include "support/gettext.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
|
|
||||||
@ -142,15 +142,15 @@ docstring complexLabel(Buffer const & buffer,
|
|||||||
static CachedMap cached_keys;
|
static CachedMap cached_keys;
|
||||||
|
|
||||||
// and cache the timestamp of the bibliography files.
|
// and cache the timestamp of the bibliography files.
|
||||||
static map<EmbeddedFile, time_t> bibfileStatus;
|
static map<FileName, time_t> bibfileStatus;
|
||||||
|
|
||||||
BiblioInfo biblist;
|
BiblioInfo biblist;
|
||||||
|
|
||||||
EmbeddedFileList const & bibfilesCache = buffer.getBibfilesCache();
|
support::FileNameList const & bibfilesCache = buffer.getBibfilesCache();
|
||||||
// compare the cached timestamps with the actual ones.
|
// compare the cached timestamps with the actual ones.
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
EmbeddedFileList::const_iterator ei = bibfilesCache.begin();
|
support::FileNameList::const_iterator ei = bibfilesCache.begin();
|
||||||
EmbeddedFileList::const_iterator en = bibfilesCache.end();
|
support::FileNameList::const_iterator en = bibfilesCache.end();
|
||||||
for (; ei != en; ++ ei) {
|
for (; ei != en; ++ ei) {
|
||||||
time_t lastw = ei->lastModified();
|
time_t lastw = ei->lastModified();
|
||||||
if (lastw != bibfileStatus[*ei]) {
|
if (lastw != bibfileStatus[*ei]) {
|
||||||
|
@ -704,17 +704,17 @@ void InsetInclude::updateBibfilesCache()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EmbeddedFileList const &
|
support::FileNameList const &
|
||||||
InsetInclude::getBibfilesCache(Buffer const & buffer) const
|
InsetInclude::getBibfilesCache(Buffer const & buffer) const
|
||||||
{
|
{
|
||||||
Buffer * const tmp = getChildBuffer(buffer, params());
|
Buffer * const tmp = getChildBuffer(buffer, params());
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
tmp->setParent(0);
|
tmp->setParent(0);
|
||||||
EmbeddedFileList const & cache = tmp->getBibfilesCache();
|
support::FileNameList const & cache = tmp->getBibfilesCache();
|
||||||
tmp->setParent(&buffer);
|
tmp->setParent(&buffer);
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
static EmbeddedFileList const empty;
|
static support::FileNameList const empty;
|
||||||
return empty;
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
#include "Counters.h"
|
#include "Counters.h"
|
||||||
#include "InsetCommandParams.h"
|
#include "InsetCommandParams.h"
|
||||||
#include "RenderButton.h"
|
#include "RenderButton.h"
|
||||||
#include "EmbeddedFiles.h"
|
|
||||||
|
#include "support/FileNameList.h"
|
||||||
|
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
@ -31,10 +32,6 @@ class InsetLabel;
|
|||||||
class LaTeXFeatures;
|
class LaTeXFeatures;
|
||||||
class RenderMonitoredPreview;
|
class RenderMonitoredPreview;
|
||||||
|
|
||||||
namespace support {
|
|
||||||
class FileNameList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// for including tex/lyx files
|
/// for including tex/lyx files
|
||||||
class InsetInclude : public InsetCommand {
|
class InsetInclude : public InsetCommand {
|
||||||
public:
|
public:
|
||||||
@ -72,7 +69,7 @@ public:
|
|||||||
* Return an empty vector if the child doc is not loaded.
|
* Return an empty vector if the child doc is not loaded.
|
||||||
* \param buffer the Buffer containing this inset.
|
* \param buffer the Buffer containing this inset.
|
||||||
*/
|
*/
|
||||||
EmbeddedFileList const &
|
support::FileNameList const &
|
||||||
getBibfilesCache(Buffer const & buffer) const;
|
getBibfilesCache(Buffer const & buffer) const;
|
||||||
///
|
///
|
||||||
EDITABLE editable() const { return IS_EDITABLE; }
|
EDITABLE editable() const { return IS_EDITABLE; }
|
||||||
|
@ -592,6 +592,24 @@ int tokenPos(string const & a, char delim, string const & tok)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// this could probably be faster and/or cleaner, but it seems to work (JMarc)
|
||||||
|
// rewritten to use new string (Lgb)
|
||||||
|
int tokenPos(docstring const & a, char_type delim, docstring const & tok)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
docstring str = a;
|
||||||
|
docstring tmptok;
|
||||||
|
|
||||||
|
while (!str.empty()) {
|
||||||
|
str = split(str, tmptok, delim);
|
||||||
|
if (tok == tmptok)
|
||||||
|
return i;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/// Substitute all \a oldchar with \a newchar
|
/// Substitute all \a oldchar with \a newchar
|
||||||
|
@ -152,6 +152,7 @@ docstring const token(docstring const & a, char_type delim, int n);
|
|||||||
\endcode
|
\endcode
|
||||||
*/
|
*/
|
||||||
int tokenPos(std::string const & a, char delim, std::string const & tok);
|
int tokenPos(std::string const & a, char delim, std::string const & tok);
|
||||||
|
int tokenPos(docstring const & a, char_type delim, docstring const & tok);
|
||||||
|
|
||||||
|
|
||||||
/// Substitute all \a oldchar with \a newchar
|
/// Substitute all \a oldchar with \a newchar
|
||||||
|
Loading…
x
Reference in New Issue
Block a user