rest of patch

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8544 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2004-03-27 12:46:30 +00:00
parent 206a1c6a02
commit 52ed731842
10 changed files with 41 additions and 189 deletions

View File

@ -25,6 +25,7 @@
#include "format.h"
#include "funcrequest.h"
#include "gettext.h"
#include "insetiterator.h"
#include "iterators.h"
#include "language.h"
#include "LaTeX.h"
@ -65,11 +66,10 @@
#include "support/path.h"
#include "support/textutils.h"
#include "support/tostr.h"
#include "support/std_sstream.h"
#include <boost/bind.hpp>
#include "support/std_sstream.h"
#include <iomanip>
#include <stack>
@ -458,7 +458,7 @@ void Buffer::insertStringAsLines(ParagraphList & pars,
bool space_inserted = true;
bool autobreakrows = !pars[par].inInset() ||
static_cast<InsetText *>(pars[par].inInset())->getAutoBreakRows();
for(string::const_iterator cit = str.begin();
for (string::const_iterator cit = str.begin();
cit != str.end(); ++cit) {
if (*cit == '\n') {
if (autobreakrows && (!pars[par].empty() || pars[par].allowEmpty())) {
@ -1183,15 +1183,17 @@ void Buffer::getLabelList(std::vector<string> & list) const
/// if this is a child document and the parent is already loaded
/// Use the parent's list instead [ale990407]
Buffer const * tmp = getMasterBuffer();
if (!tmp) {
lyxerr << "getMasterBuffer() failed!" << endl;
BOOST_ASSERT(tmp);
}
if (tmp != this) {
tmp->getLabelList(list);
return;
}
for (inset_iterator it = inset_const_iterator_begin();
it != inset_const_iterator_end(); ++it) {
it->getLabelList(*this, list);
}
for (InsetIterator it(inset()); it; ++it)
it.nextInset()->getLabelList(*this, list);
}
@ -1202,13 +1204,13 @@ void Buffer::fillWithBibKeys(std::vector<std::pair<string, string> > & keys)
/// if this is a child document and the parent is already loaded
/// use the parent's list instead [ale990412]
Buffer const * tmp = getMasterBuffer();
BOOST_ASSERT(tmp);
if (tmp != this) {
tmp->fillWithBibKeys(keys);
return;
}
for (inset_iterator it = inset_const_iterator_begin();
it != inset_const_iterator_end(); ++it) {
for (InsetIterator it(inset()); it; ++it) {
if (it->lyxCode() == InsetOld::BIBTEX_CODE) {
InsetBibtex const & inset =
dynamic_cast<InsetBibtex const &>(*it);
@ -1300,17 +1302,6 @@ bool Buffer::isMultiLingual() const
}
void Buffer::inset_iterator::setParagraph()
{
while (pit != par_type(pars_->size())) {
it = (*pars_)[pit].insetlist.begin();
if (it != (*pars_)[pit].insetlist.end())
return;
++pit;
}
}
ParIterator Buffer::getParFromID(int id) const
{
#warning FIXME: const correctness! (Andre)
@ -1485,95 +1476,3 @@ Buffer const * Buffer::getMasterBuffer() const
return this;
}
Buffer::inset_iterator::inset_iterator(ParagraphList & pars, base_type p)
: pit(p), pars_(&pars)
{
setParagraph();
}
Buffer::inset_iterator Buffer::inset_iterator_begin()
{
return inset_iterator(paragraphs(), 0);
}
Buffer::inset_iterator Buffer::inset_iterator_end()
{
return inset_iterator(paragraphs(), paragraphs().size());
}
Buffer::inset_iterator Buffer::inset_const_iterator_begin() const
{
ParagraphList & pars = const_cast<ParagraphList&>(paragraphs());
return inset_iterator(pars, 0);
}
Buffer::inset_iterator Buffer::inset_const_iterator_end() const
{
ParagraphList & pars = const_cast<ParagraphList&>(paragraphs());
return inset_iterator(pars, pars.size());
}
Buffer::inset_iterator & Buffer::inset_iterator::operator++()
{
if (pit != par_type(pars_->size())) {
++it;
if (it == (*pars_)[pit].insetlist.end()) {
++pit;
setParagraph();
}
}
return *this;
}
Buffer::inset_iterator Buffer::inset_iterator::operator++(int)
{
inset_iterator tmp = *this;
++*this;
return tmp;
}
Buffer::inset_iterator::reference Buffer::inset_iterator::operator*()
{
return *it->inset;
}
Buffer::inset_iterator::pointer Buffer::inset_iterator::operator->()
{
return it->inset;
}
lyx::par_type Buffer::inset_iterator::getPar() const
{
return pit;
}
lyx::pos_type Buffer::inset_iterator::getPos() const
{
return it->pos;
}
bool operator==(Buffer::inset_iterator const & iter1,
Buffer::inset_iterator const & iter2)
{
return iter1.pit == iter2.pit && iter1.it == iter2.it;
}
bool operator!=(Buffer::inset_iterator const & iter1,
Buffer::inset_iterator const & iter2)
{
return !(iter1 == iter2);
}

View File

@ -286,58 +286,6 @@ public:
TexRow & texrow();
TexRow const & texrow() const;
class inset_iterator {
public:
typedef std::input_iterator_tag iterator_category;
typedef InsetBase value_type;
typedef ptrdiff_t difference_type;
typedef InsetBase * pointer;
typedef InsetBase & reference;
typedef lyx::par_type base_type;
///
inset_iterator(ParagraphList & pars, base_type p);
/// prefix ++
inset_iterator & operator++();
/// postfix ++
inset_iterator operator++(int);
///
reference operator*();
///
pointer operator->();
///
lyx::par_type getPar() const;
///
lyx::pos_type getPos() const;
///
friend
bool operator==(inset_iterator const & iter1,
inset_iterator const & iter2);
private:
///
void setParagraph();
///
lyx::par_type pit;
///
InsetList::iterator it;
public:
ParagraphList * pars_;
};
/// return an iterator to all *top-level* insets in the buffer
inset_iterator inset_iterator_begin();
/// return the end of all *top-level* insets in the buffer
inset_iterator inset_iterator_end();
/// return a const iterator to all *top-level* insets in the buffer
inset_iterator inset_const_iterator_begin() const;
/// return the const end of all *top-level* insets in the buffer
inset_iterator inset_const_iterator_end() const;
///
ParIterator par_iterator_begin();
///
@ -376,10 +324,4 @@ private:
boost::scoped_ptr<Impl> const pimpl_;
};
bool operator==(Buffer::inset_iterator const & iter1,
Buffer::inset_iterator const & iter2);
bool operator!=(Buffer::inset_iterator const & iter1,
Buffer::inset_iterator const & iter2);
#endif

View File

@ -1335,6 +1335,12 @@ void LCursor::undispatched()
}
void LCursor::dispatched()
{
disp_.dispatched(true);
}
void LCursor::noUpdate()
{
disp_.update(false);

View File

@ -168,6 +168,8 @@ public:
void update();
/// the event was not (yet) dispatched
void undispatched();
/// the event was already dispatched
void dispatched();
/// don't call update() when done
void noUpdate();

View File

@ -17,6 +17,7 @@
#include "converter.h"
#include "debug.h"
#include "format.h"
#include "insetiterator.h"
#include "LColor.h"
#include "lyxrc.h"
#include "outputparams.h"
@ -599,10 +600,7 @@ void PreviewLoader::Impl::dumpPreamble(ostream & os) const
<< "\n";
// Loop over the insets in the buffer and dump all the math-macros.
Buffer::inset_iterator it = buffer_.inset_const_iterator_begin();
Buffer::inset_iterator end = buffer_.inset_const_iterator_end();
for (; it != end; ++it)
for (InsetIterator it(buffer_.inset()); it; ++it)
if (it->lyxCode() == InsetOld::MATHMACRO_CODE)
it->latex(buffer_, os, runparams);

View File

@ -14,6 +14,7 @@
#include "PreviewLoader.h"
#include "buffer.h"
#include "insetiterator.h"
#include "lyxrc.h"
#include "paragraph.h"
@ -82,10 +83,7 @@ void Previews::generateBufferPreviews(Buffer const & buffer) const
{
PreviewLoader & ploader = loader(buffer);
Buffer::inset_iterator it = buffer.inset_const_iterator_begin();
Buffer::inset_iterator end = buffer.inset_const_iterator_end();
for (; it != end; ++it)
for (InsetIterator it(buffer.inset()); it; ++it)
it->addPreview(ploader);
ploader.startLoading();

View File

@ -14,6 +14,8 @@
#include "math_macrotemplate.h"
#include "debug.h"
#include <boost/assert.hpp>
using std::string;
using std::endl;
@ -42,6 +44,7 @@ MathAtom & MathMacroTable::provide(string const & name)
if (pos == macro_table.end()) {
lyxerr << "MathMacroTable::provideTemplate: no template with name '"
<< name << "' available." << endl;
BOOST_ASSERT(false);
}
return pos->second;
}
@ -49,6 +52,8 @@ MathAtom & MathMacroTable::provide(string const & name)
void MathMacroTable::create(MathAtom const & at)
{
lyxerr << "MathMacroTable::create: '"
<< at->asMacroTemplate()->name() << "'" << endl;
macro_table[at->asMacroTemplate()->name()] = at;
}

View File

@ -83,10 +83,10 @@ void MathMacroTemplate::metrics(MetricsInfo & mi, Dimension & dim) const
{
cell(0).metrics(mi);
cell(1).metrics(mi);
dim_.wid = cell(0).width() + cell(1).width() + 10;
dim_.asc = std::max(cell(0).ascent(), cell(1).ascent()) + 2;
dim_.des = std::max(cell(0).descent(), cell(1).descent()) + 2;
dim = dim_;
dim.wid = cell(0).width() + cell(1).width() + 10;
dim.asc = std::max(cell(0).ascent(), cell(1).ascent()) + 2;
dim.des = std::max(cell(0).descent(), cell(1).descent()) + 2;
dim_ = dim;
}

View File

@ -335,7 +335,7 @@ void MathNestInset::handleFont2(LCursor & cur, string const & arg)
void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
{
lyxerr << "MathNestInset: request: " << cmd << std::endl;
//lyxerr << "MathNestInset: request: " << cmd << std::endl;
//CursorSlice sl = cur.current();
switch (cmd.action) {
@ -739,11 +739,6 @@ void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
cur.insert(MathAtom(new MathSpaceInset(",")));
break;
case LFUN_UNDO:
#warning look here
//cur.bv().owner()->message(_("Invalid action in math mode!"));
break;
case LFUN_INSET_ERT:
// interpret this as if a backslash was typed
recordUndo(cur, Undo::ATOMIC);
@ -890,12 +885,14 @@ bool MathNestInset::getStatus(LCursor & /*cur*/, FuncRequest const & cmd,
return ret;
}
void MathNestInset::edit(LCursor & cur, bool left)
{
cur.push(*this);
cur.idx() = left ? 0 : cur.lastidx();
cur.pos() = left ? 0 : cur.lastpos();
cur.resetAnchor();
lyxerr << "MathNestInset::edit, cur:\n" << cur << endl;
}

View File

@ -31,6 +31,8 @@ using std::advance;
using lyx::par_type;
using std::endl;
namespace {
@ -156,8 +158,11 @@ bool textUndoOrRedo(BufferView & bv,
DocumentIterator dit =
undo.cursor.asDocumentIterator(&bv.buffer()->inset());
if (dit.inMathed()) {
// not much to be done
// Easy way out: store a full cell.
otherstack.top().array = asString(dit.cell());
} else {
// As cells might be too large in texted, store just a part
// of the paragraph list.
otherstack.top().pars.clear();
LyXText * text = dit.text();
BOOST_ASSERT(text);