mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
probably fixed bug 1561
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10298 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b72724a9b6
commit
3e1919e067
33
src/buffer.C
33
src/buffer.C
@ -64,6 +64,7 @@
|
||||
|
||||
#include "graphics/Previews.h"
|
||||
|
||||
#include "support/lyxalgo.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/fs_extras.h"
|
||||
#ifdef USE_COMPRESSION
|
||||
@ -1543,8 +1544,40 @@ void Buffer::buildMacros()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Buffer::saveCursor(StableDocIterator cur, StableDocIterator anc)
|
||||
{
|
||||
cursor_ = cur;
|
||||
anchor_ = anc;
|
||||
}
|
||||
|
||||
|
||||
void Buffer::changeRefsIfUnique(string const & from, string const & to)
|
||||
{
|
||||
// Check if the label 'from' appears more than once
|
||||
vector<string> labels;
|
||||
getLabelList(labels);
|
||||
|
||||
if (lyx::count(labels.begin(), labels.end(), from) > 1)
|
||||
return;
|
||||
|
||||
InsetBase::Code code = InsetBase::REF_CODE;
|
||||
|
||||
ParIterator it = par_iterator_begin();
|
||||
ParIterator end = par_iterator_end();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -333,6 +333,8 @@ public:
|
||||
StableDocIterator getCursor() const { return cursor_; }
|
||||
///
|
||||
StableDocIterator getAnchor() const { return anchor_; }
|
||||
///
|
||||
void changeRefsIfUnique(std::string const & from, std::string const & to);
|
||||
|
||||
private:
|
||||
/** Inserts a file into a document
|
||||
|
@ -251,7 +251,7 @@ void FontLoader::update()
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
|
||||
FontInfo::FontInfo(LyXFont const & f)
|
||||
QLFontInfo::QLFontInfo(LyXFont const & f)
|
||||
: metrics(font)
|
||||
{
|
||||
|
||||
@ -322,12 +322,12 @@ FontInfo::FontInfo(LyXFont const & f)
|
||||
}
|
||||
|
||||
|
||||
int FontInfo::width(Uchar val) const
|
||||
int QLFontInfo::width(Uchar val) const
|
||||
{
|
||||
// Starting with version 3.1.0, Qt/X11 does its own caching of
|
||||
// character width, so it is not necessary to provide ours.
|
||||
#if defined (USE_LYX_FONTCACHE)
|
||||
FontInfo::WidthCache::const_iterator cit = widthcache.find(val);
|
||||
QLFontInfo::WidthCache::const_iterator cit = widthcache.find(val);
|
||||
if (cit != widthcache.end())
|
||||
return cit->second;
|
||||
|
||||
|
@ -30,9 +30,9 @@
|
||||
* Qt font loader for LyX. Matches LyXFonts against
|
||||
* actual QFont instances, and also caches metrics.
|
||||
*/
|
||||
class FontInfo {
|
||||
class QLFontInfo {
|
||||
public:
|
||||
FontInfo(LyXFont const & f);
|
||||
QLFontInfo(LyXFont const & f);
|
||||
|
||||
/// Return pixel width for the given unicode char
|
||||
int width(Uchar val) const;
|
||||
@ -79,17 +79,17 @@ public:
|
||||
static void addToFontPath();
|
||||
|
||||
/// Get font info (font + metrics) for the given LyX font.
|
||||
FontInfo & fontinfo(LyXFont const & f) {
|
||||
FontInfo * & fi =
|
||||
QLFontInfo & fontinfo(LyXFont const & f) {
|
||||
QLFontInfo * & fi =
|
||||
fontinfo_[f.family()][f.series()][f.realShape()][f.size()];
|
||||
if (!fi)
|
||||
fi = new FontInfo(f);
|
||||
fi = new QLFontInfo(f);
|
||||
return *fi;
|
||||
}
|
||||
|
||||
private:
|
||||
/// BUTT ugly !
|
||||
FontInfo * fontinfo_[LyXFont::NUM_FAMILIES][2][4][10];
|
||||
QLFontInfo * fontinfo_[LyXFont::NUM_FAMILIES][2][4][10];
|
||||
};
|
||||
|
||||
extern FontLoader fontloader;
|
||||
|
@ -139,7 +139,7 @@ int width(char const * s, size_t ls, LyXFont const & f)
|
||||
return smallcapswidth(s, ls, f);
|
||||
|
||||
Encoding const * encoding = fontencoding(f);
|
||||
FontInfo & fi = fontloader.fontinfo(f);
|
||||
QLFontInfo & fi = fontloader.fontinfo(f);
|
||||
|
||||
if (ls == 1)
|
||||
return fi.width(encoding->ucs(s[0]));
|
||||
|
@ -58,37 +58,6 @@ string const InsetLabel::getScreenLabel(Buffer const &) const
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
void changeRefsIfUnique(BufferView & bv, string const & from, string const & to)
|
||||
{
|
||||
// Check if the label 'from' appears more than once
|
||||
vector<string> labels;
|
||||
bv.buffer()->getLabelList(labels);
|
||||
|
||||
if (lyx::count(labels.begin(), labels.end(), from) > 1)
|
||||
return;
|
||||
|
||||
InsetBase::Code code = InsetBase::REF_CODE;
|
||||
|
||||
ParIterator it = bv.buffer()->par_iterator_begin();
|
||||
ParIterator end = bv.buffer()->par_iterator_end();
|
||||
for ( ; it != end; ++it) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
void InsetLabel::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
@ -101,7 +70,7 @@ void InsetLabel::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
}
|
||||
if (p.getContents() != params().getContents())
|
||||
changeRefsIfUnique(cur.bv(), params().getContents(),
|
||||
cur.bv().buffer()->changeRefsIfUnique(params().getContents(),
|
||||
p.getContents());
|
||||
setParams(p);
|
||||
break;
|
||||
|
@ -1064,15 +1064,19 @@ void MathHullInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
//lyxerr << "arg: " << cmd.argument << endl;
|
||||
string const name = cmd.getArg(0);
|
||||
if (name == "label") {
|
||||
InsetCommandParams icp;
|
||||
InsetCommandMailer::string2params(name, cmd.argument, icp);
|
||||
string str = icp.getContents();
|
||||
InsetCommandParams p;
|
||||
InsetCommandMailer::string2params(name, cmd.argument, p);
|
||||
string str = p.getContents();
|
||||
recordUndoInset(cur);
|
||||
row_type const r = (type_ == "multline") ? nrows() - 1 : cur.row();
|
||||
str = lyx::support::trim(str);
|
||||
if (!str.empty())
|
||||
numbered(r, true);
|
||||
label(r, str);
|
||||
string old = label(r);
|
||||
if (str != old) {
|
||||
cur.bv().buffer()->changeRefsIfUnique(old, str);
|
||||
label(r, str);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -160,9 +160,8 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
|
||||
|
||||
if (token[0] != '\\') {
|
||||
string::const_iterator cit = token.begin();
|
||||
for (; cit != token.end(); ++cit) {
|
||||
for (; cit != token.end(); ++cit)
|
||||
par.insertChar(par.size(), (*cit), font, change);
|
||||
}
|
||||
} else if (token == "\\begin_layout") {
|
||||
lex.eatLine();
|
||||
string layoutname = lex.getString();
|
||||
|
Loading…
Reference in New Issue
Block a user