mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 14:15:32 +00:00
more from the diff-5.diff merged
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4983 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
cf0b2ab5ae
commit
51e4d793ed
@ -525,26 +525,24 @@ bool BufferView::lockInset(UpdatableInset * inset)
|
||||
}
|
||||
}
|
||||
// Then do a deep look of the inset and lock the right one
|
||||
Paragraph * par = &*(buffer()->paragraphs.begin());
|
||||
int const id = inset->id();
|
||||
while (par) {
|
||||
InsetList::iterator it =
|
||||
par->insetlist.begin();
|
||||
InsetList::iterator const end =
|
||||
par->insetlist.end();
|
||||
ParagraphList::iterator pit = buffer()->paragraphs.begin();
|
||||
ParagraphList::iterator pend = buffer()->paragraphs.end();
|
||||
for (; pit != pend; ++pit) {
|
||||
InsetList::iterator it = pit->insetlist.begin();
|
||||
InsetList::iterator end = pit->insetlist.end();
|
||||
for (; it != end; ++it) {
|
||||
if (it.getInset() == inset) {
|
||||
text->setCursorIntern(this, par, it.getPos());
|
||||
text->setCursorIntern(this, &*pit, it.getPos());
|
||||
theLockingInset(inset);
|
||||
return true;
|
||||
}
|
||||
if (it.getInset()->getInsetFromID(id)) {
|
||||
text->setCursorIntern(this, par, it.getPos());
|
||||
text->setCursorIntern(this, &*pit, it.getPos());
|
||||
it.getInset()->edit(this);
|
||||
return theLockingInset()->lockInsetInInset(this, inset);
|
||||
}
|
||||
}
|
||||
par = par->next();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1,7 +1,24 @@
|
||||
2002-08-15 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* paragraph.C (Paragraph): reformat a bit
|
||||
(cutIntoMinibuffer): use builtin InsetList function instad of
|
||||
doing it manually.
|
||||
(getInset): ditto
|
||||
|
||||
* buffer.C: include boost/bind.hpp, add using std::for_each
|
||||
(writeFileAscii): use ParagraphList iterators
|
||||
(validate): use for_each for validate traversal of paragraphs
|
||||
(getBibkeyList): use ParagraphList iterators
|
||||
(resizeInsets): use for_each to resizeInsetsLyXText for all
|
||||
paragraphs.
|
||||
(getParFromID): use ParagraphList iterators
|
||||
|
||||
* BufferView2.C (lockInset): use paragraph list and iterators
|
||||
|
||||
2002-08-14 John Levon <levon@movementarian.org>
|
||||
|
||||
* lyxserver.C: remove spurious xforms include
|
||||
|
||||
|
||||
2002-08-14 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
||||
|
||||
* lyxfunc.C (getStatus): disable math-extern outside of math mode
|
||||
@ -17,7 +34,7 @@
|
||||
|
||||
* funcrequest.C: move stuff here from .h
|
||||
|
||||
* Makefile.am:
|
||||
* Makefile.am:
|
||||
* BufferView_pimpl.C:
|
||||
* LyXAction.C:
|
||||
* toc.C:
|
||||
@ -109,7 +126,7 @@
|
||||
* paragraph_pimpl.h: remove inclusion of boost/array.hpp, remove
|
||||
unused class variable counter_,
|
||||
|
||||
* paragraph.[Ch] (getFirstCounter): delete unused function
|
||||
* paragraph.[Ch] (getFirstCounter): delete unused function
|
||||
|
||||
* counters.C: include LAssert.h
|
||||
(reset): add a new function with no arg, change other version to
|
||||
|
66
src/buffer.C
66
src/buffer.C
@ -95,6 +95,9 @@
|
||||
#include "support/lyxmanip.h"
|
||||
#include "support/lyxalgo.h" // for lyx::count
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
@ -108,8 +111,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <utime.h>
|
||||
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
#ifdef HAVE_LOCALE
|
||||
#include <locale>
|
||||
#endif
|
||||
@ -133,6 +134,7 @@ using std::max;
|
||||
using std::set;
|
||||
using std::stack;
|
||||
using std::list;
|
||||
using std::for_each;
|
||||
|
||||
using lyx::pos_type;
|
||||
using lyx::textclass_type;
|
||||
@ -2116,10 +2118,11 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
|
||||
|
||||
void Buffer::writeFileAscii(ostream & ofs, int linelen)
|
||||
{
|
||||
Paragraph * par = &*(paragraphs.begin());
|
||||
while (par) {
|
||||
ofs << asciiParagraph(par, linelen, par->previous() == 0);
|
||||
par = par->next();
|
||||
ParagraphList::iterator beg = paragraphs.begin();
|
||||
ParagraphList::iterator end = paragraphs.end();
|
||||
ParagraphList::iterator it = beg;
|
||||
for (; it != end; ++it) {
|
||||
ofs << asciiParagraph(&*it, linelen, it == beg);
|
||||
}
|
||||
ofs << "\n";
|
||||
}
|
||||
@ -3621,25 +3624,14 @@ int Buffer::runChktex()
|
||||
|
||||
void Buffer::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
Paragraph * par = &*(paragraphs.begin());
|
||||
LyXTextClass const & tclass = params.getLyXTextClass();
|
||||
|
||||
// AMS Style is at document level
|
||||
if (params.use_amsmath || tclass.provides(LyXTextClass::amsmath))
|
||||
features.require("amsmath");
|
||||
|
||||
while (par) {
|
||||
// We don't use "lyxerr.debug" because of speed. (Asger)
|
||||
if (lyxerr.debugging(Debug::LATEX))
|
||||
lyxerr << "Paragraph: " << par << endl;
|
||||
|
||||
// Now just follow the list of paragraphs and run
|
||||
// validate on each of them.
|
||||
par->validate(features);
|
||||
|
||||
// and then the next paragraph
|
||||
par = par->next();
|
||||
}
|
||||
for_each(paragraphs.begin(), paragraphs.end(),
|
||||
boost::bind(&Paragraph::validate, _1, boost::ref(features)));
|
||||
|
||||
// the bullet shapes are buffer level not paragraph level
|
||||
// so they are tested here
|
||||
@ -3726,17 +3718,17 @@ vector<pair<string, string> > const Buffer::getBibkeyList() const
|
||||
}
|
||||
|
||||
vector<StringPair> keys;
|
||||
Paragraph * par = &*(paragraphs.begin());
|
||||
while (par) {
|
||||
if (par->bibkey) {
|
||||
string const key = par->bibkey->getContents();
|
||||
string const opt = par->bibkey->getOptions();
|
||||
string const ref = par->asString(this, false);
|
||||
ParagraphList::iterator pit = paragraphs.begin();
|
||||
ParagraphList::iterator pend = paragraphs.end();
|
||||
for (; pit != pend; ++pit) {
|
||||
if (pit->bibkey) {
|
||||
string const key = pit->bibkey->getContents();
|
||||
string const opt = pit->bibkey->getOptions();
|
||||
string const ref = pit->asString(this, false);
|
||||
string const info = opt + "TheBibliographyRef" + ref;
|
||||
|
||||
keys.push_back(StringPair(key, info));
|
||||
}
|
||||
par = par->next();
|
||||
}
|
||||
|
||||
// Might be either using bibtex or a child has bibliography
|
||||
@ -3826,10 +3818,8 @@ bool Buffer::dispatch(int action, string const & argument, bool * result)
|
||||
void Buffer::resizeInsets(BufferView * bv)
|
||||
{
|
||||
/// then remove all LyXText in text-insets
|
||||
Paragraph * par = &*(paragraphs.begin());
|
||||
for (; par; par = par->next()) {
|
||||
par->resizeInsetsLyXText(bv);
|
||||
}
|
||||
for_each(paragraphs.begin(), paragraphs.end(),
|
||||
boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv));
|
||||
}
|
||||
|
||||
|
||||
@ -3908,17 +3898,19 @@ Inset * Buffer::getInsetFromID(int id_arg) const
|
||||
|
||||
Paragraph * Buffer::getParFromID(int id) const
|
||||
{
|
||||
if (id < 0) return 0;
|
||||
Paragraph * par = &*(paragraphs.begin());
|
||||
while (par) {
|
||||
if (par->id() == id) {
|
||||
return par;
|
||||
if (id < 0)
|
||||
return 0;
|
||||
|
||||
ParagraphList::iterator it = paragraphs.begin();
|
||||
ParagraphList::iterator end = paragraphs.end();
|
||||
for (; it != end; ++it) {
|
||||
if (it->id() == id) {
|
||||
return &*it;
|
||||
}
|
||||
Paragraph * tmp = par->getParFromID(id);
|
||||
Paragraph * tmp = it->getParFromID(id);
|
||||
if (tmp) {
|
||||
return tmp;
|
||||
}
|
||||
par = par->next();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,3 +1,10 @@
|
||||
2002-08-15 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* insettext.C (edit): use ParagraphList iterators
|
||||
|
||||
* insetbib.C (bibitemMaxWidth): use ParagraphList iterators
|
||||
(bibitemWidest): ditto
|
||||
|
||||
2002-08-14 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* insettext.C: include <boost/bind.hpp>
|
||||
|
@ -327,14 +327,14 @@ int bibitemMaxWidth(BufferView * bv, LyXFont const & font)
|
||||
int w = 0;
|
||||
// Ha, now we are mainly at 1.2.0 and it is still here (Jug)
|
||||
// Does look like a hack? It is! (but will change at 0.13)
|
||||
Paragraph * par = &*(bv->buffer()->paragraphs.begin());
|
||||
|
||||
while (par) {
|
||||
if (par->bibkey) {
|
||||
int const wx = par->bibkey->width(bv, font);
|
||||
if (wx > w) w = wx;
|
||||
ParagraphList::iterator it = bv->buffer()->paragraphs.begin();
|
||||
ParagraphList::iterator end = bv->buffer()->paragraphs.end();
|
||||
for (; it != end; ++it) {
|
||||
if (it->bibkey) {
|
||||
int const wx = it->bibkey->width(bv, font);
|
||||
if (wx > w)
|
||||
w = wx;
|
||||
}
|
||||
par = par->next();
|
||||
}
|
||||
return w;
|
||||
}
|
||||
@ -345,21 +345,22 @@ string const bibitemWidest(Buffer const * buffer)
|
||||
{
|
||||
int w = 0;
|
||||
// Does look like a hack? It is! (but will change at 0.13)
|
||||
Paragraph * par = &*(buffer->paragraphs.begin());
|
||||
|
||||
InsetBibKey * bkey = 0;
|
||||
LyXFont font;
|
||||
|
||||
while (par) {
|
||||
if (par->bibkey) {
|
||||
ParagraphList::iterator it = buffer->paragraphs.begin();
|
||||
ParagraphList::iterator end = buffer->paragraphs.end();
|
||||
for (; it != end; ++it) {
|
||||
if (it->bibkey) {
|
||||
int const wx =
|
||||
font_metrics::width(par->bibkey->getBibLabel(),
|
||||
font);
|
||||
font_metrics::width(it->bibkey->getBibLabel(),
|
||||
font);
|
||||
if (wx > w) {
|
||||
w = wx;
|
||||
bkey = par->bibkey;
|
||||
bkey = it->bibkey;
|
||||
}
|
||||
}
|
||||
par = par->next();
|
||||
}
|
||||
|
||||
if (bkey && !bkey->getBibLabel().empty())
|
||||
|
@ -739,11 +739,12 @@ void InsetText::edit(BufferView * bv, bool front)
|
||||
if (front)
|
||||
lt->setCursor(bv, &*(paragraphs.begin()), 0);
|
||||
else {
|
||||
Paragraph * p = &*(paragraphs.begin());
|
||||
while (p->next())
|
||||
p = p->next();
|
||||
ParagraphList::iterator it = paragraphs.begin();
|
||||
ParagraphList::iterator end = paragraphs.end();
|
||||
while (boost::next(it) != end)
|
||||
++it;
|
||||
// int const pos = (p->size() ? p->size()-1 : p->size());
|
||||
lt->setCursor(bv, p, p->size());
|
||||
lt->setCursor(bv, &*it, it->size());
|
||||
}
|
||||
lt->clearSelection();
|
||||
finishUndo();
|
||||
|
@ -127,10 +127,11 @@ Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
|
||||
|
||||
// copy everything behind the break-position to the new paragraph
|
||||
insetlist = lp.insetlist;
|
||||
for (InsetList::iterator it = insetlist.begin();
|
||||
it != insetlist.end(); ++it)
|
||||
{
|
||||
it.setInset(it.getInset()->clone(*current_view->buffer(), same_ids));
|
||||
InsetList::iterator it = insetlist.begin();
|
||||
InsetList::iterator end = insetlist.end();
|
||||
for (; it != end; ++it) {
|
||||
it.setInset(it.getInset()->clone(*current_view->buffer(),
|
||||
same_ids));
|
||||
// tell the new inset who is the boss now
|
||||
it.getInset()->parOwner(this);
|
||||
}
|
||||
@ -349,21 +350,8 @@ void Paragraph::cutIntoMinibuffer(BufferParams const & bparams, pos_type pos)
|
||||
minibuffer_inset = 0;
|
||||
if (minibuffer_char == Paragraph::META_INSET) {
|
||||
if (getInset(pos)) {
|
||||
minibuffer_inset = getInset(pos);
|
||||
// This is a little hack since I want exactly
|
||||
// the inset, not just a clone. Otherwise
|
||||
// the inset would be deleted when calling Erase(pos)
|
||||
// find the entry
|
||||
InsetList::iterator it = insetlist.begin();
|
||||
InsetList::iterator end = insetlist.end();
|
||||
for (; it != end; ++it) {
|
||||
if (it.getPos() == pos)
|
||||
break;
|
||||
}
|
||||
|
||||
if (it != end && it.getPos() == pos)
|
||||
it.setInset(0);
|
||||
// the inset is not in a paragraph anymore
|
||||
minibuffer_inset = insetlist.release(pos);
|
||||
minibuffer_inset->parOwner(0);
|
||||
} else {
|
||||
minibuffer_inset = 0;
|
||||
@ -452,27 +440,7 @@ Inset * Paragraph::getInset(pos_type pos)
|
||||
{
|
||||
lyx::Assert(pos < size());
|
||||
|
||||
// Find the inset.
|
||||
InsetList::iterator it = insetlist.begin();
|
||||
InsetList::iterator end = insetlist.end();
|
||||
for (; it != end; ++it) {
|
||||
if (it.getPos() == pos)
|
||||
break;
|
||||
}
|
||||
|
||||
if (it != end && it.getPos() == pos)
|
||||
return it.getInset();
|
||||
|
||||
lyxerr << "ERROR (Paragraph::getInset): "
|
||||
<< "Inset does not exist: " << pos << endl;
|
||||
//::raise(SIGSTOP);
|
||||
|
||||
// text[pos] = ' '; // WHY!!! does this set the pos to ' '????
|
||||
// Did this commenting out introduce a bug? So far I have not
|
||||
// see any, please enlighten me. (Lgb)
|
||||
// My guess is that since the inset does not exist, we might
|
||||
// as well replace it with a space to prevent craches. (Asger)
|
||||
return 0;
|
||||
return insetlist.get(pos);
|
||||
}
|
||||
|
||||
|
||||
@ -2055,5 +2023,3 @@ bool Paragraph::isFreeSpacing() const
|
||||
return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user