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_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> 2003-08-25 Martin Vermeer <martin.vermeer@hut.fi>
* lyxrow_funcs.C: * 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> 2003-08-26 Martin Vermeer <martin.vermeer@hut.fi>
* insetbranch.C: Small fix to prevent a crash on loading. * insetbranch.C: Small fix to prevent a crash on loading.
2003-08-25 Martin Vermeer <martin.vermeer@hut.fi> 2003-08-25 Martin Vermeer <martin.vermeer@hut.fi>
* insets/inset.h: * inset.h:
* insets/insetbibtex.[Ch]: * insetbibtex.[Ch]:
* insets/insetbranch.[Ch]: * insetbranch.[Ch]:
* insets/insetcollapsable.h: * insetcollapsable.h:
* insets/insetert.[Ch]: * insetert.[Ch]:
* insets/insetfloatlist.[Ch]: * insetfloatlist.[Ch]:
* insets/insetfootlike.[Ch]: * insetfootlike.[Ch]:
* insets/insetinclude.[Ch]: * insetinclude.[Ch]:
* insets/insetindex.[Ch]: * insetindex.[Ch]:
* insets/insetindex.h: * insetindex.h:
* insets/insetminipage.h: * insetminipage.h:
* insets/insetnote.[Ch]: * insetnote.[Ch]:
* insets/insettext.C: * insettext.C:
* insets/insettheorem.[Ch]: * insettheorem.[Ch]:
* insets/insettoc.[Ch]: eliminates the needFullRow/display() stuff * insettoc.[Ch]: eliminates the needFullRow/display() stuff
altogether, putting the logic in metrics/draw in the insets. 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> 2003-08-19 André Pönitz <poenitz@gmx.net>

View File

@ -38,17 +38,17 @@ unsigned int InsetOld::inset_id = 0;
InsetOld::InsetOld() InsetOld::InsetOld()
: InsetBase(), : InsetBase(),
top_x(0), top_baseline(0), scx(0), 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) background_color_(LColor::inherit)
{} {}
InsetOld::InsetOld(InsetOld const & in) InsetOld::InsetOld(InsetOld const & in)
: InsetBase(), : 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_) name_(in.name_), background_color_(in.background_color_)
{ {}
}
bool InsetOld::directWrite() const bool InsetOld::directWrite() const

View File

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

View File

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

View File

@ -18,7 +18,10 @@
#include "paragraph.h" #include "paragraph.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "metricsinfo.h" #include "metricsinfo.h"
#include "paragraph_funcs.h"
#include "support/LOstream.h" #include "support/LOstream.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "frontends/font_metrics.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); int const asc = font_metrics::maxAscent(pi.base.font);
// hack, and highly dubious // 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); bool const ltr_pos = (pi.base.bv->text->bidi_level(pos) % 2 == 0);
int xp[3]; int xp[3];

View File

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

View File

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

View File

@ -66,7 +66,7 @@ using lyx::pos_type;
Paragraph::Paragraph() Paragraph::Paragraph()
: pimpl_(new Paragraph::Pimpl(this)), y(0) : y(0), pimpl_(new Paragraph::Pimpl(this))
{ {
enumdepth = 0; enumdepth = 0;
itemdepth = 0; itemdepth = 0;
@ -75,7 +75,7 @@ Paragraph::Paragraph()
Paragraph::Paragraph(Paragraph const & lp) 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; enumdepth = 0;
itemdepth = 0; itemdepth = 0;
@ -90,8 +90,6 @@ Paragraph::Paragraph(Paragraph const & lp)
for (; it != end; ++it) { for (; it != end; ++it) {
// currently we hold Inset*, not InsetBase* // currently we hold Inset*, not InsetBase*
it->inset = static_cast<InsetOld*>(it->inset->clone().release()); 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(); InsetList::iterator end = insetlist.end();
for (; it != end; ++it) { for (; it != end; ++it) {
it->inset = static_cast<InsetOld*>(it->inset->clone().release()); 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)) { if (from.getInset(i)) {
// the inset is not in a paragraph anymore // the inset is not in a paragraph anymore
tmpinset = from.insetlist.release(i); tmpinset = from.insetlist.release(i);
tmpinset->parOwner(0);
} }
if (!to.insetAllowed(tmpinset->lyxCode())) 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 pit = const_cast<Buffer &>(buf).par_iterator_begin();
ParIterator end = buf.par_iterator_end(); ParIterator end = const_cast<Buffer &>(buf).par_iterator_end();
for ( ; pit != end; ++pit) { for ( ; pit != end; ++pit) {
InsetList::iterator ii = pit->insetlist.begin(); InsetList::iterator ii = pit->insetlist.begin();
InsetList::iterator iend = pit->insetlist.end(); InsetList::iterator iend = pit->insetlist.end();
@ -1061,6 +1060,22 @@ ParagraphList::iterator outerPar(Buffer & buf, InsetOld * inset)
} }
lyxerr << "outerPar: should not happen\n"; lyxerr << "outerPar: should not happen\n";
Assert(false); 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); ParagraphList const & plist);
/// find outermost paragraph containing an inset /// 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 #endif // PARAGRAPH_FUNCS_H

View File

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

View File

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