remove InsetOld::par_owner & handling

(const correct after Angus' comment)


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7610 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-08-26 16:36:53 +00:00
parent 814e5398c5
commit 407c8f08bc
13 changed files with 79 additions and 49 deletions

View File

@ -3,6 +3,12 @@
* paragraph_func.[Ch] (outerPar): new function
* paragraph.C:
* paragraph_funcs.C:
* paragraph_funcs.h:
* paragraph_pimpl.C:
* text2.C: remove Inset::par_owner
2003-08-25 Martin Vermeer <martin.vermeer@hut.fi>
* lyxrow_funcs.C:

View File

@ -1,25 +1,35 @@
2003-08-26 André Pönitz <poenitz@gmx.net>
* insetfoot.C:
* insetnewline.C:
* insetquotes.C:
* insettabular.C:
* inset.[Ch]: remove InsetOld::par_owner_ & handling
2003-08-26 Martin Vermeer <martin.vermeer@hut.fi>
* insetbranch.C: Small fix to prevent a crash on loading.
2003-08-25 Martin Vermeer <martin.vermeer@hut.fi>
* insets/inset.h:
* insets/insetbibtex.[Ch]:
* insets/insetbranch.[Ch]:
* insets/insetcollapsable.h:
* insets/insetert.[Ch]:
* insets/insetfloatlist.[Ch]:
* insets/insetfootlike.[Ch]:
* insets/insetinclude.[Ch]:
* insets/insetindex.[Ch]:
* insets/insetindex.h:
* insets/insetminipage.h:
* insets/insetnote.[Ch]:
* insets/insettext.C:
* insets/insettheorem.[Ch]:
* insets/insettoc.[Ch]: eliminates the needFullRow/display() stuff
altogether, putting the logic in metrics/draw in the insets.
* inset.h:
* insetbibtex.[Ch]:
* insetbranch.[Ch]:
* insetcollapsable.h:
* insetert.[Ch]:
* insetfloatlist.[Ch]:
* insetfootlike.[Ch]:
* insetinclude.[Ch]:
* insetindex.[Ch]:
* insetindex.h:
* insetminipage.h:
* insetnote.[Ch]:
* insettext.C:
* insettheorem.[Ch]:
* insettoc.[Ch]: eliminates the needFullRow/display() stuff
altogether, putting the logic in metrics/draw in the insets.=20
Draws short single row insets with more or less realistic metrics.
2003-08-19 André Pönitz <poenitz@gmx.net>

View File

@ -38,17 +38,17 @@ unsigned int InsetOld::inset_id = 0;
InsetOld::InsetOld()
: InsetBase(),
top_x(0), top_baseline(0), scx(0),
id_(inset_id++), owner_(0), par_owner_(0),
id_(inset_id++), owner_(0),
background_color_(LColor::inherit)
{}
InsetOld::InsetOld(InsetOld const & in)
: InsetBase(),
top_x(0), top_baseline(0), scx(0), id_(in.id_), owner_(0),
top_x(0), top_baseline(0), scx(0),
id_(in.id_), owner_(0),
name_(in.name_), background_color_(in.background_color_)
{
}
{}
bool InsetOld::directWrite() const

View File

@ -207,10 +207,6 @@ public:
///
UpdatableInset * owner() const { return owner_; }
///
void parOwner(Paragraph * par) { par_owner_ = par; }
///
Paragraph * parOwner() const { return par_owner_; }
///
void setBackgroundColor(LColor::color);
///
LColor::color backgroundColor() const;
@ -330,8 +326,6 @@ protected:
private:
///
UpdatableInset * owner_;
/// the paragraph in which this inset has been inserted
Paragraph * par_owner_;
///
string name_;
///

View File

@ -23,8 +23,7 @@
// the following are needed just to get the layout of the enclosing
// paragraph. This seems a bit too much to me (JMarc)
#include "lyxlayout.h"
#include "buffer.h"
#include "paragraph.h"
#include "paragraph_funcs.h"
using std::ostream;
@ -63,9 +62,8 @@ int InsetFoot::latex(Buffer const * buf, ostream & os,
LatexRunParams const & runparams_in) const
{
LatexRunParams runparams = runparams_in;
if (buf && parOwner()) {
LyXLayout_ptr const & layout = parOwner()->layout();
runparams.moving_arg |= layout->intitle;
if (buf) {
runparams.moving_arg |= ownerPar(*buf, this).layout()->intitle;
}
os << "%\n\\footnote{";

View File

@ -18,7 +18,10 @@
#include "paragraph.h"
#include "lyxtext.h"
#include "metricsinfo.h"
#include "paragraph_funcs.h"
#include "support/LOstream.h"
#include "frontends/Painter.h"
#include "frontends/font_metrics.h"
@ -83,7 +86,8 @@ void InsetNewline::draw(PainterInfo & pi, int x, int y) const
int const asc = font_metrics::maxAscent(pi.base.font);
// hack, and highly dubious
lyx::pos_type pos = parOwner()->getPositionOfInset(this);
lyx::pos_type pos = ownerPar(*pi.base.bv->buffer(), this)
.getPositionOfInset(this);
bool const ltr_pos = (pi.base.bv->text->bidi_level(pos) % 2 == 0);
int xp[3];

View File

@ -24,8 +24,11 @@
#include "lyxrc.h"
#include "paragraph.h"
#include "metricsinfo.h"
#include "paragraph_funcs.h"
#include "frontends/font_metrics.h"
#include "frontends/Painter.h"
#include "support/LAssert.h"
#include "support/lstrings.h"
@ -254,7 +257,7 @@ int InsetQuotes::latex(Buffer const * buf, ostream & os,
LatexRunParams const & runparams) const
{
// How do we get the local language here??
lyx::pos_type curr_pos = parOwner()->getPositionOfInset(this);
lyx::pos_type curr_pos = ownerPar(*buf, this).getPositionOfInset(this);
Assert(curr_pos != -1);
#warning FIXME. We _must_ find another way to get the language. (Lgb)

View File

@ -32,6 +32,7 @@
#include "undo_funcs.h"
#include "WordLangTuple.h"
#include "metricsinfo.h"
#include "paragraph_funcs.h"
#include "frontends/Alert.h"
#include "frontends/Dialogs.h"
@ -1094,7 +1095,7 @@ int InsetTabular::latex(Buffer const * buf, ostream & os,
int InsetTabular::ascii(Buffer const * buf, ostream & os, int ll) const
{
if (ll > 0)
return tabular.ascii(buf, os, (int)parOwner()->params().depth(),
return tabular.ascii(buf, os, ownerPar(*buf, this).params().depth(),
false, 0);
return tabular.ascii(buf, os, 0, false, 0);
}
@ -2245,7 +2246,7 @@ bool InsetTabular::copySelection(BufferView * bv)
ostringstream os;
paste_tabular->ascii(bv->buffer(), os,
(int)parOwner()->params().depth(), true, '\t');
ownerPar(*bv->buffer(), this).params().depth(), true, '\t');
bv->stuffClipboard(STRCONV(os.str()));
return true;
}

View File

@ -66,7 +66,7 @@ using lyx::pos_type;
Paragraph::Paragraph()
: pimpl_(new Paragraph::Pimpl(this)), y(0)
: y(0), pimpl_(new Paragraph::Pimpl(this))
{
enumdepth = 0;
itemdepth = 0;
@ -75,7 +75,7 @@ Paragraph::Paragraph()
Paragraph::Paragraph(Paragraph const & lp)
: pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this)), y(0)
: y(0), pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this))
{
enumdepth = 0;
itemdepth = 0;
@ -90,8 +90,6 @@ Paragraph::Paragraph(Paragraph const & lp)
for (; it != end; ++it) {
// currently we hold Inset*, not InsetBase*
it->inset = static_cast<InsetOld*>(it->inset->clone().release());
// tell the new inset who is the boss now
it->inset->parOwner(this);
}
}
@ -119,8 +117,6 @@ void Paragraph::operator=(Paragraph const & lp)
InsetList::iterator end = insetlist.end();
for (; it != end; ++it) {
it->inset = static_cast<InsetOld*>(it->inset->clone().release());
// tell the new inset who is the boss now
it->inset->parOwner(this);
}
}

View File

@ -60,7 +60,6 @@ bool moveItem(Paragraph & from, Paragraph & to,
if (from.getInset(i)) {
// the inset is not in a paragraph anymore
tmpinset = from.insetlist.release(i);
tmpinset->parOwner(0);
}
if (!to.insetAllowed(tmpinset->lyxCode()))
@ -1048,10 +1047,10 @@ LyXFont const outerFont(ParagraphList::iterator pit,
}
ParagraphList::iterator outerPar(Buffer & buf, InsetOld * inset)
ParagraphList::iterator outerPar(Buffer const & buf, InsetOld const * inset)
{
ParIterator pit = buf.par_iterator_begin();
ParIterator end = buf.par_iterator_end();
ParIterator pit = const_cast<Buffer &>(buf).par_iterator_begin();
ParIterator end = const_cast<Buffer &>(buf).par_iterator_end();
for ( ; pit != end; ++pit) {
InsetList::iterator ii = pit->insetlist.begin();
InsetList::iterator iend = pit->insetlist.end();
@ -1061,6 +1060,22 @@ ParagraphList::iterator outerPar(Buffer & buf, InsetOld * inset)
}
lyxerr << "outerPar: should not happen\n";
Assert(false);
return end.pit(); // shut up compiler
return const_cast<Buffer &>(buf).paragraphs.end(); // shut up compiler
}
Paragraph const & ownerPar(Buffer const & buf, InsetOld const * inset)
{
ParConstIterator pit = buf.par_iterator_begin();
ParConstIterator end = buf.par_iterator_end();
for ( ; pit != end; ++pit) {
InsetList::const_iterator ii = pit->insetlist.begin();
InsetList::const_iterator iend = pit->insetlist.end();
for ( ; ii != iend; ++ii)
if (ii->inset == inset)
return *pit.pit();
}
lyxerr << "ownerPar: should not happen\n";
Assert(false);
return buf.paragraphs.front(); // shut up compiler
}

View File

@ -76,7 +76,10 @@ LyXFont const outerFont(ParagraphList::iterator pit,
ParagraphList const & plist);
/// find outermost paragraph containing an inset
ParagraphList::iterator outerPar(Buffer & buf, InsetOld * inset);
ParagraphList::iterator outerPar(Buffer const & buf, InsetOld const * inset);
/// find owning paragraph containing an inset
Paragraph const & ownerPar(Buffer const & buf, InsetOld const * inset);
#endif // PARAGRAPH_FUNCS_H

View File

@ -331,7 +331,6 @@ void Paragraph::Pimpl::insertInset(pos_type pos,
// Add a new entry in the insetlist.
owner_->insetlist.insert(inset, pos);
inset->parOwner(owner_);
if (inset_owner)
inset->setOwner(inset_owner);

View File

@ -1003,9 +1003,10 @@ void LyXText::setCounter(Buffer const * buf, ParagraphList::iterator pit)
isOK = true;
break;
} else {
Paragraph const * owner = &ownerPar(*buf, in);
tmppit = ownerParagraphs().begin();
for ( ; tmppit != end; ++tmppit)
if (&*tmppit == in->parOwner())
if (&*tmppit == owner)
break;
}
}