+2000-10-10 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * src/BufferView_pimpl.C (buffer): cleaned up a little.
+
+ * src/insets/figinset.[Ch]:
+ * src/insets/insetinclude.[Ch]:
+ * src/insets/insetinclude.[Ch]:
+ * src/insets/insetparent.[Ch]:
+ * src/insets/insetref.[Ch]:
+ * src/insets/insettabular.[Ch] (c-tor): Buffer passed as const &.
+
+ * src/insets/*.[Ch]:
+ * src/mathed/formula.[Ch]:
+ * src/mathed/formulamacro.C (Clone): passed Buffer const &.
+
+ * src/buffer.C (parseSingleLyXformat2Token, readInset):
+ * src/lyx_cb.C (FigureApplyCB):
+ * src/lyxfunc.C (getStatus, Dispatch):
+ * src/frontends/xforms/FormTabular.C: use modified c-tors to some
+ insets.
+
+ * src/lyxfunc.C (Dispatch): string "ref" not used. Removed.
+
+ * src/converter.[Ch] (Formats::View):
+ * src/lyx_cb.[Ch] (ShowMessage): constify Buffer * parameter.
+
+ * src/paragraph.C (CopyIntoMinibuffer, Clone): Insets::Clone() passed
+ *current_view->buffer(). This will change later, but this patch is way
+ big enough already!
+
2000-10-09 Juergen Vigna <jug@sad.it>
* src/text.C (GetRow): small fix.
bv_->text->first = screen_->TopCursorVisible(bv_->text);
owner_->updateMenubar();
owner_->updateToolbar();
+ // Similarly, buffer-dependent dialogs should be updated or
+ // hidden. This should go here because some dialogs (eg ToC)
+ // require bv_->text.
+ owner_->getDialogs()->updateBufferDependent();
redraw();
bv_->insetWakeup();
} else {
lyxerr[Debug::INFO] << " No Buffer!" << endl;
owner_->updateMenubar();
owner_->updateToolbar();
+ owner_->getDialogs()->hideBufferDependent();
updateScrollbar();
workarea_->redraw();
owner_->updateLayoutChoice();
owner_->getMiniBuffer()->Init();
owner_->updateWindowTitle();
- // Similarly, buffer-dependent dialogs should be updated or hidden.
- // This should go here because some dialogs (ToC) require bv_->text.
- if (buffer_) owner_->getDialogs()->updateBufferDependent();
-#ifdef WITH_WARNINGS
-#warning Is this the right place for this?
-// What was wrong with where it used to be in the previous if(buffer_) above?
-// There also used to be a hideBufferDependent somewhere here but I haven't
-// time at present to check. This should at least fix the segfault.
-#endif
}
par->InsertChar(pos, LyXParagraph::META_NEWLINE, font);
++pos;
} else if (token == "\\LyXTable") {
- Inset * inset = new InsetTabular(this);
+ Inset * inset = new InsetTabular(*this);
inset->Read(this, lex);
par->InsertInset(pos, inset, font);
++pos;
} else if (inscmd.getCmdName() == "index") {
inset = new InsetIndex(inscmd);
} else if (inscmd.getCmdName() == "include") {
- inset = new InsetInclude(inscmd, this);
+ inset = new InsetInclude(inscmd, *this);
} else if (inscmd.getCmdName() == "label") {
inset = new InsetLabel(inscmd);
} else if (inscmd.getCmdName() == "url"
|| inscmd.getCmdName() == "prettyref") {
if (!inscmd.getOptions().empty()
|| !inscmd.getContents().empty()) {
- inset = new InsetRef(inscmd);
+ inset = new InsetRef(inscmd, *this);
}
} else if (inscmd.getCmdName() == "tableofcontents"
|| inscmd.getCmdName() == "listofalgorithms"
} else if (inscmd.getCmdName() == "printindex") {
inset = new InsetPrintIndex(inscmd);
} else if (inscmd.getCmdName() == "lyxparent") {
- inset = new InsetParent(inscmd, this);
+ inset = new InsetParent(inscmd, *this);
}
} else {
if (tmptok == "Quotes") {
} else if (tmptok == "Formula") {
inset = new InsetFormula;
} else if (tmptok == "Figure") {
- inset = new InsetFig(100, 100, this);
+ inset = new InsetFig(100, 100, *this);
} else if (tmptok == "Info") {
inset = new InsetInfo;
} else if (tmptok == "Include") {
InsetCommandParams p( "Include" );
- inset = new InsetInclude(p, this);
+ inset = new InsetInclude(p, *this);
} else if (tmptok == "ERT") {
inset = new InsetERT;
} else if (tmptok == "Tabular") {
- inset = new InsetTabular(this);
+ inset = new InsetTabular(*this);
} else if (tmptok == "Text") {
inset = new InsetText;
} else if (tmptok == "Foot") {
}
-bool Formats::View(Buffer * buffer, string const & filename)
+bool Formats::View(Buffer const * buffer, string const & filename)
{
if (filename.empty())
return false;
void SetViewer(string const & name, string const & command);
///
static
- bool View(Buffer * buffer, string const & filename);
+ bool View(Buffer const * buffer, string const & filename);
///
static
Format * GetFormat(string const & name);
// comm->setMinibuffer(_("Inserting tabular inset..."));
ysize = int(fl_get_slider_value(create_tabular_->slider_columns) + 0.5);
xsize = int(fl_get_slider_value(create_tabular_->slider_rows) + 0.5);
- InsetTabular * in = new InsetTabular(lv_->buffer(),xsize,ysize);
+ InsetTabular * in = new InsetTabular(*lv_->buffer(),xsize,ysize);
if (!lv_->view()->open_new_inset(in)) {
delete in;
}
}
-InsetFig::InsetFig(int tmpx, int tmpy, Buffer * o)
- : owner(o)
+InsetFig::InsetFig(int tmpx, int tmpy, Buffer const & o)
+ : owner(&o)
{
wid = tmpx;
hgh = tmpy;
}
-Inset * InsetFig::Clone() const
+Inset * InsetFig::Clone(Buffer const & buffer) const
{
- InsetFig * tmp = new InsetFig(100, 100, owner);
+ InsetFig * tmp = new InsetFig(100, 100, buffer);
if (lyxerr.debugging()) {
lyxerr << "Clone Figure: buffer:["
- << current_view->buffer()
+ << &buffer
<< "], cbuffer:[xx]" << endl;
}
class InsetFig: public Inset {
public:
///
- InsetFig(int tmpx, int tmpy, Buffer *);
+ InsetFig(int tmpx, int tmpy, Buffer const &);
///
~InsetFig();
///
///
Inset::Code LyxCode() const;
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
void CallbackFig(long arg);
///
private:
///
- Buffer * owner;
+ Buffer const * owner;
/// restore values on the form
void RestoreForm();
/// recompute screen params
}
-Inset * InsetBibKey::Clone() const
+Inset * InsetBibKey::Clone(Buffer const &) const
{
InsetBibKey * b = new InsetBibKey(params());
b->setCounter(counter);
///
~InsetBibKey();
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
/** Currently \bibitem is used as a LyX2.x command,
so we need this method.
*/
///
~InsetBibtex();
///
- Inset * Clone() const { return new InsetBibtex(params()); }
+ Inset * Clone(Buffer const &) const {
+ return new InsetBibtex(params());
+ }
///
string const getScreenLabel() const;
///
///
InsetCitation(InsetCommandParams const &);
///
- Inset * Clone() const { return new InsetCitation(params()); }
+ Inset * Clone(Buffer const &) const {
+ return new InsetCitation(params());
+ }
///
string const getScreenLabel() const;
///
}
-Inset * InsetCollapsable::Clone() const
+Inset * InsetCollapsable::Clone(Buffer const &) const
{
InsetCollapsable * result = new InsetCollapsable();
result->inset->init(inset);
///
InsetCollapsable();
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
void Read(Buffer const *, LyXLex &);
///
///
EDITABLE Editable() const { return IS_EDITABLE; }
///
- Inset * Clone() const { return new InsetError(contents); }
+ Inset * Clone(Buffer const &) const { return new InsetError(contents); }
///
Inset::Code LyxCode() const { return Inset::NO_CODE; }
/// We don't want "begin" and "end inset" in lyx-file
}
-Inset * InsetERT::Clone() const
+Inset * InsetERT::Clone(Buffer const &) const
{
InsetERT * result = new InsetERT;
result->inset->init(inset);
///
void Write(Buffer const * buf, std::ostream & os) const;
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
string const EditMessage() const;
///
}
-Inset * InsetExternal::Clone() const
+Inset * InsetExternal::Clone(Buffer const &) const
{
InsetExternal * inset = new InsetExternal();
inset->templatename = templatename;
virtual Inset::Code LyxCode() const { return EXTERNAL_CODE; }
///
- virtual Inset * Clone() const;
+ virtual Inset * Clone(Buffer const &) const;
/// returns the text of the button
virtual string const getScreenLabel() const;
}
-Inset * InsetFloat::Clone() const
+Inset * InsetFloat::Clone(Buffer const &) const
{
InsetFloat * result = new InsetFloat(floatType);
result->inset->init(inset);
///
void Validate(LaTeXFeatures & features) const;
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
Inset::Code LyxCode() const { return Inset::FLOAT_CODE; }
///
}
-Inset * InsetFoot::Clone() const
+Inset * InsetFoot::Clone(Buffer const &) const
{
InsetFoot * result = new InsetFoot;
result->inset->init(inset);
///
InsetFoot();
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
Inset::Code LyxCode() const { return Inset::FOOT_CODE; }
///
return params;
}
-Inset * InsetGraphics::Clone() const
+Inset * InsetGraphics::Clone(Buffer const &) const
{
InsetGraphics * newInset = new InsetGraphics;
Inset::Code LyxCode() const { return Inset::GRAPHICS_CODE; }
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
/** Set the inset parameters, used by the GUIndependent dialog.
Return true of new params are different from what was so far.
}
-InsetInclude::InsetInclude(InsetCommandParams const & p, Buffer * bf)
- : InsetCommand(p), master(bf)
+InsetInclude::InsetInclude(InsetCommandParams const & p, Buffer const & bf)
+ : InsetCommand(p), master(&bf)
{
flag = InsetInclude::INCLUDE;
noload = false;
}
-Inset * InsetInclude::Clone() const
+Inset * InsetInclude::Clone(Buffer const & buffer) const
{
- InsetInclude * ii = new InsetInclude (params(), master);
+ InsetInclude * ii = new InsetInclude (params(), buffer);
ii->setNoLoad(isNoLoad());
// By default, the newly created inset is of `include' type,
// so we do not test this case.
class InsetInclude: public InsetCommand {
public:
///
- InsetInclude(InsetCommandParams const &, Buffer *);
+ InsetInclude(InsetCommandParams const &, Buffer const &);
///
~InsetInclude();
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
Inset::Code LyxCode() const { return Inset::INCLUDE_CODE; }
/// This returns the list of labels on the child buffer
///
int flag;
///
- Buffer * master;
+ Buffer const * master;
///
string include_label;
};
///
InsetIndex(InsetCommandParams const &);
///
- Inset * Clone() const { return new InsetIndex(params());}
+ Inset * Clone(Buffer const &) const {
+ return new InsetIndex(params());
+ }
///
string const getScreenLabel() const;
///
///
InsetPrintIndex(InsetCommandParams const &);
///
- Inset * Clone() const { return new InsetPrintIndex(params());}
+ Inset * Clone(Buffer const &) const {
+ return new InsetPrintIndex(params());
+ }
/// Updates needed features for this inset.
void Validate(LaTeXFeatures & features) const;
///
}
-Inset * InsetInfo::Clone() const
+Inset * InsetInfo::Clone(Buffer const &) const
{
return new InsetInfo(contents);
}
///
Inset::Code LyxCode() const;
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
static void CloseInfoCB(FL_OBJECT *, long data);
private:
///
InsetLabel(InsetCommandParams const &);
///
- Inset * Clone() const { return new InsetLabel(params()); }
+ Inset * Clone(Buffer const &) const { return new InsetLabel(params()); }
///
string const getScreenLabel() const { return getContents(); }
///
}
-Inset * InsetLatexAccent::Clone() const
+Inset * InsetLatexAccent::Clone(Buffer const &) const
{
return new InsetLatexAccent(contents);
}
///
bool DirectWrite() const;
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
Inset::Code LyxCode()const;
///
}
-Inset * InsetList::Clone() const
+Inset * InsetList::Clone(Buffer const &) const
{
InsetList * result = new InsetList;
result->inset->init(inset);
///
void Write(Buffer const * buf, std::ostream & os) const;
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
Inset::Code LyxCode() const { return Inset::FOOT_CODE; }
///
}
-Inset * InsetMarginal::Clone() const
+Inset * InsetMarginal::Clone(Buffer const &) const
{
InsetMarginal * result = new InsetMarginal;
result->inset->init(inset);
///
InsetMarginal();
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
Inset::Code LyxCode() const { return Inset::MARGIN_CODE; }
///
}
-Inset * InsetMinipage::Clone() const
+Inset * InsetMinipage::Clone(Buffer const &) const
{
InsetMinipage * result = new InsetMinipage;
result->inset->init(inset);
///
void Write(Buffer const * buf, std::ostream & os) const;
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
Inset::Code LyxCode() const { return Inset::MINIPAGE_CODE; }
///
using std::ostream;
-InsetParent::InsetParent(InsetCommandParams const & p, Buffer * bf)
+InsetParent::InsetParent(InsetCommandParams const & p, Buffer const & bf)
: InsetCommand(p)
{
string fn = p.getContents();
- if (bf)
- setContents(MakeAbsPath(fn, OnlyPath(bf->fileName())));
- else
- setContents(fn);
+ setContents(MakeAbsPath(fn, OnlyPath(bf.fileName())));
}
class InsetParent : public InsetCommand {
public:
///
- InsetParent(InsetCommandParams const &, Buffer * owner = 0);
+ InsetParent(InsetCommandParams const &, Buffer const &);
///
- Inset * Clone() const { return new InsetParent(params()); }
+ Inset * Clone(Buffer const & buffer) const {
+ return new InsetParent(params(), buffer);
+ }
///
string const getScreenLabel() const;
///
}
-Inset * InsetQuotes::Clone() const
+Inset * InsetQuotes::Clone(Buffer const &) const
{
return new InsetQuotes(language, side, times);
}
///
void Validate(LaTeXFeatures &) const;
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
Inset::Code LyxCode() const;
private:
using std::ostream;
-extern BufferView * current_view;
-
-
-InsetRef::InsetRef(InsetCommandParams const & p)
- : InsetCommand(p)
+InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf)
+ : InsetCommand(p), isLatex(buf.isLatex())
{}
void InsetRef::Edit(BufferView * bv, int, int, unsigned int button)
temp += getContents();
- if(!current_view->buffer()->isLatex()
+ if(!isLatex
&& !getOptions().empty()) {
temp += "||";
temp += getOptions();
class InsetRef : public InsetCommand {
public:
///
- InsetRef(InsetCommandParams const &);
+ InsetRef(InsetCommandParams const &, Buffer const &);
///
- Inset * Clone() const { return new InsetRef(params()); }
+ Inset * Clone(Buffer const & buffer) const {
+ return new InsetRef(params(), buffer);
+ }
///
string const getScreenLabel() const;
///
private:
/// This function escapes 8-bit characters
string const escape(string const &) const;
+ ///
+ bool isLatex;
};
#endif
}
-Inset * InsetSpecialChar::Clone() const
+Inset * InsetSpecialChar::Clone(Buffer const &) const
{
return new InsetSpecialChar(kind);
}
///
int DocBook(Buffer const *, std::ostream &) const;
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
Inset::Code LyxCode() const
{
}
-InsetTabular::InsetTabular(Buffer * buf, int rows, int columns)
- : buffer(buf)
+InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
+ : buffer(&buf)
{
if (rows <= 0)
rows = 1;
}
-InsetTabular::InsetTabular(InsetTabular const & tab, Buffer * buf)
- : buffer(buf)
+InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf)
+ : buffer(&buf)
{
tabular = new LyXTabular(this, *(tab.tabular));
the_locking_inset = 0;
}
-Inset * InsetTabular::Clone() const
+Inset * InsetTabular::Clone(Buffer const & buf) const
{
- InsetTabular * t = new InsetTabular(*this, buffer);
+ InsetTabular * t = new InsetTabular(*this, buf);
delete t->tabular;
t->tabular = tabular->Clone(t);
return t;
SELECTION
};
///
- InsetTabular(Buffer *, int rows = 1, int columns = 1);
+ InsetTabular(Buffer const &, int rows = 1, int columns = 1);
///
- InsetTabular(InsetTabular const &, Buffer *);
+ InsetTabular(InsetTabular const &, Buffer const &);
///
~InsetTabular();
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
void Read(Buffer const *, LyXLex &);
///
///
int getMaxWidth(Painter & pain, UpdatableInset const *) const;
///
- Buffer * BufferOwner() const { return buffer; }
+ Buffer * BufferOwner() const { return const_cast<Buffer *>(buffer); }
///
LyXText * getLyXText(BufferView *) const;
///
///
InsetText * the_locking_inset;
///
- Buffer * buffer;
+ Buffer const * buffer;
///
mutable LyXCursor cursor;
///
}
-Inset * InsetText::Clone() const
+Inset * InsetText::Clone(Buffer const &) const
{
InsetText * t = new InsetText(*this);
return t;
///
~InsetText();
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
InsetText & operator=(InsetText const & it);
///
}
-Inset * InsetTheorem::Clone() const
+Inset * InsetTheorem::Clone(Buffer const &) const
{
InsetTheorem * result = new InsetTheorem;
///
void Write(Buffer const * buf, std::ostream & os) const;
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
Inset::Code LyxCode() const { return Inset::THEOREM_CODE; }
///
///
InsetTOC(InsetCommandParams const & p) : InsetCommand(p) {}
///
- Inset * Clone() const { return new InsetTOC(params()); }
+ Inset * Clone(Buffer const &) const { return new InsetTOC(params()); }
///
string const getScreenLabel() const;
///
explicit
InsetUrl(InsetCommandParams const &);
///
- Inset * Clone() const { return new InsetUrl(params()); }
+ Inset * Clone(Buffer const &) const { return new InsetUrl(params()); }
///
Inset::Code LyxCode() const { return Inset::URL_CODE; }
///
}
///
- virtual Inset * Clone() const = 0;
+ virtual Inset * Clone(Buffer const &) const = 0;
/// returns true to override begin and end inset in file
virtual bool DirectWrite() const;
void MenuLayoutSave();
-void ShowMessage(Buffer * buf,
+void ShowMessage(Buffer const * buf,
string const & msg1,
string const & msg2,
string const & msg3, int delay)
current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));
if (fl_get_button(fd_form_figure->radio_inline)) {
- InsetFig * new_inset = new InsetFig(100, 20, buffer);
+ InsetFig * new_inset = new InsetFig(100, 20, *buffer);
current_view->insertInset(new_inset);
current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
new_inset->Edit(current_view, 0, 0, 0);
current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
- Inset * new_inset = new InsetFig(100, 100, buffer);
+ Inset * new_inset = new InsetFig(100, 100, *buffer);
current_view->insertInset(new_inset);
new_inset->Edit(current_view, 0, 0, 0);
current_view->update(BufferView::SELECT|BufferView::FITCUR);
///
extern LyXFont const UserFreeFont(BufferParams const & params);
///
-void ShowMessage(Buffer * buf,
+void ShowMessage(Buffer const * buf,
string const & msg1,
string const & msg2 = string(),
string const & msg3 = string(), int delay = 6);
flag |= ret;
disable = false;
} else {
- static InsetTabular inset(owner->buffer(), 1, 1);
+ static InsetTabular inset(*owner->buffer(), 1, 1);
func_status ret;
disable = true;
meta_fake_bit = Mod1Mask;
string buf;
keyseq.print(buf, true);
- string res = string("M-") + buf;
setMessage(buf); // RVDK_PATCH_5
}
break;
InsetCommandParams p;
p.setFromString(argument);
- InsetRef * inset = new InsetRef(p);
+ InsetRef * inset = new InsetRef(p, *owner->buffer());
if (!owner->view()->insertInset(inset))
delete inset;
else
if (!argument.empty())
::sscanf(argument.c_str(),"%d%d", &r, &c);
InsetTabular * new_inset =
- new InsetTabular(owner->buffer(), r, c);
+ new InsetTabular(*owner->buffer(), r, c);
if (owner->view()->insertInset(new_inset))
new_inset->Edit(owner->view(), 0, 0, 0);
else
{
lyxerr << "arg " << argument << endl;
InsetCommandParams p( "lyxparent", argument );
- Inset * inset = new InsetParent(p, owner->buffer());
+ Inset * inset = new InsetParent(p, *owner->buffer());
if (!owner->view()->insertInset(inset, "Standard", true))
delete inset;
}
case LFUN_CHILDINSERT:
{
InsetCommandParams p( "Include", argument );
- Inset * inset = new InsetInclude(p, owner->buffer());
+ Inset * inset = new InsetInclude(p, *owner->buffer());
if (owner->view()->insertInset(inset, "Standard", true))
inset->Edit(owner->view(), 0, 0, 0);
else
}
-Inset * InsetFormula::Clone() const
+Inset * InsetFormula::Clone(Buffer const &) const
{
InsetFormula * f = new InsetFormula(par);
f->label = label;
///
void Validate(LaTeXFeatures &) const;
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
///
Inset::Code LyxCode() const { return Inset::MATH_CODE; }
///
}
-Inset * InsetFormulaMacro::Clone() const
+Inset * InsetFormulaMacro::Clone(Buffer const &) const
{
return new InsetFormulaMacro(name);
}
///
int DocBook(Buffer const *, std::ostream &) const;
///
- Inset * Clone() const;
+ Inset * Clone(Buffer const &) const;
/// what appears in the minibuffer when opening
string const EditMessage() const;
minibuffer_inset = 0;
if (minibuffer_char == LyXParagraph::META_INSET) {
if (GetInset(pos)) {
- minibuffer_inset = GetInset(pos)->Clone();
+ minibuffer_inset = GetInset(pos)->Clone(*current_view->buffer());
} else {
minibuffer_inset = 0;
minibuffer_char = ' ';
// ale970302
if (bibkey)
- result->bibkey = static_cast<InsetBibKey *>(bibkey->Clone());
+ result->bibkey = static_cast<InsetBibKey *>
+ (bibkey->Clone(*current_view->buffer()));
else
result->bibkey = 0;
result->insetlist = insetlist;
for (InsetList::iterator it = result->insetlist.begin();
it != result->insetlist.end(); ++it)
- (*it).inset = (*it).inset->Clone();
+ (*it).inset = (*it).inset->Clone(*current_view->buffer());
return result;
}