On Mon, Aug 19, 2002 at 06:18:50PM +0100, Angus Leeming wrote: > > > Here is the code. > > Sigh. It would be nice if you'd incorparate my change of > InsetShortTitle * Paragraph::shortTitleInset() const; > to > namespace { > InsetShortTitle * shortTitleInset(Paragraph const &); > }
Ah, sorry. I didn't have it in my local tree. Here's the new short1.diff. Martin
Index: BufferView_pimpl.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.283 diff -u -p -r1.283 BufferView_pimpl.C --- BufferView_pimpl.C 2002/08/18 17:15:23 1.283 +++ BufferView_pimpl.C 2002/08/19 16:58:11 @@ -68,6 +68,7 @@ #include "insets/insetcaption.h" #include "insets/insetfloatlist.h" #include "insets/insetspecialchar.h" +#include "insets/insetshorttitle.h" #include "mathed/formulabase.h" @@ -1498,6 +1497,9 @@ bool BufferView::Pimpl::dispatch(FuncReq LyXTextClass const & tclass = buffer_->params.getLyXTextClass(); + LyXText * lt = bv_->getLyXText(); + LyXLayout_ptr const & style = lt->cursor.par()->layout(); + switch (ev.action) { // --- Misc ------------------------------------------- case LFUN_APPENDIX: @@ -2760,6 +2765,12 @@ bool BufferView::Pimpl::dispatch(FuncReq case LFUN_INSERT_NOTE: insertAndEditInset(new InsetNote(buffer_->params)); + break; + + case LFUN_INSET_SHORTTITLE: + + if (style->hasoption) + insertAndEditInset(new InsetShortTitle(buffer_->params)); break; case LFUN_INSET_FLOAT: Index: LyXAction.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/LyXAction.C,v retrieving revision 1.132 diff -u -p -r1.132 LyXAction.C --- LyXAction.C 2002/08/15 14:33:11 1.132 +++ LyXAction.C 2002/08/19 16:58:12 @@ -247,6 +247,8 @@ void LyXAction::init() ReadOnly }, { LFUN_INSERT_LABEL, "label-insert", N_("Insert Label"), Noop }, + { LFUN_INSET_SHORTTITLE, "shorttitle-insert", N_("Insert Short Title"), + Noop }, { LFUN_LANGUAGE, "language", N_("Change language"), Noop }, { LFUN_LATEX_LOG, "latex-view-log", N_("View LaTeX log"), ReadOnly }, Index: buffer.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/buffer.C,v retrieving revision 1.371 diff -u -p -r1.371 buffer.C --- buffer.C 2002/08/14 22:15:16 1.371 +++ buffer.C 2002/08/19 16:58:14 @@ -71,6 +71,7 @@ #include "insets/insetgraphics.h" #include "insets/insetfoot.h" #include "insets/insetmarginal.h" +#include "insets/insetshorttitle.h" #include "insets/insetminipage.h" #include "insets/insetfloat.h" #include "insets/insettabular.h" @@ -1634,6 +1635,8 @@ void Buffer::readInset(LyXLex & lex, Par inset = new InsetFoot(params); } else if (tmptok == "Marginal") { inset = new InsetMarginal(params); + } else if (tmptok == "ShortTitle") { + inset = new InsetShortTitle(params); } else if (tmptok == "Minipage") { inset = new InsetMinipage(params); } else if (tmptok == "Float") { Index: commandtags.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/commandtags.h,v retrieving revision 1.97 diff -u -p -r1.97 commandtags.h --- commandtags.h 2002/08/15 14:33:11 1.97 +++ commandtags.h 2002/08/19 16:58:15 @@ -288,6 +288,7 @@ enum kb_action { LFUN_FORKS_SHOW, // Angus 16 Feb 2002 LFUN_FORKS_KILL, // Angus 16 Feb 2002 LFUN_TOOLTIPS_TOGGLE, // Angus 8 Mar 2002 + LFUN_INSET_SHORTTITLE, // Martin 12 Aug 2002 LFUN_MOUSE_PRESS, // André 9 Aug 2002 LFUN_MOUSE_MOTION, // André 9 Aug 2002 LFUN_MOUSE_RELEASE, // André 9 Aug 2002 Index: lyxfunc.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxfunc.C,v retrieving revision 1.369 diff -u -p -r1.369 lyxfunc.C --- lyxfunc.C 2002/08/15 14:33:11 1.369 +++ lyxfunc.C 2002/08/19 16:58:17 @@ -535,6 +535,9 @@ FuncStatus LyXFunc::getStatus(FuncReques case LFUN_INSERT_LABEL: code = Inset::LABEL_CODE; break; + case LFUN_INSET_SHORTTITLE: + code = Inset::SHORTTITLE_CODE; + break; case LFUN_REF_INSERT: code = Inset::REF_CODE; break; Index: lyxlayout.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxlayout.C,v retrieving revision 1.7 diff -u -p -r1.7 lyxlayout.C --- lyxlayout.C 2002/07/20 20:47:53 1.7 +++ lyxlayout.C 2002/08/19 16:58:17 @@ -59,6 +59,7 @@ enum LayoutTags { LT_ENDLABELTYPE, LT_LATEXNAME, LT_LATEXPARAM, + LT_HASOPTION, LT_LATEXTYPE, LT_LEFTMARGIN, LT_NEED_PROTECT, @@ -83,6 +84,7 @@ LyXLayout::LyXLayout () margintype = MARGIN_STATIC; latextype = LATEX_PARAGRAPH; intitle = false; + hasoption = false; needprotect = false; keepempty = false; font = LyXFont(LyXFont::ALL_INHERIT); @@ -127,6 +129,7 @@ bool LyXLayout::Read (LyXLex & lexrc, Ly { "fill_top", LT_FILL_TOP }, { "font", LT_FONT }, { "freespacing", LT_FREE_SPACING }, + { "hasoption", LT_HASOPTION }, { "intitle", LT_INTITLE }, { "itemsep", LT_ITEMSEP }, { "keepempty", LT_KEEPEMPTY }, @@ -243,6 +246,10 @@ bool LyXLayout::Read (LyXLex & lexrc, Ly case LT_INTITLE: intitle = lexrc.next() && lexrc.getInteger(); + break; + + case LT_HASOPTION: + hasoption = lexrc.next() && lexrc.getInteger(); break; case LT_NEED_PROTECT: Index: lyxlayout.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxlayout.h,v retrieving revision 1.4 diff -u -p -r1.4 lyxlayout.h --- lyxlayout.h 2002/07/20 20:47:53 1.4 +++ lyxlayout.h 2002/08/19 16:58:17 @@ -188,6 +188,9 @@ public: LYX_LATEX_TYPES latextype; /// Does this object belong in the title part of the document? bool intitle; + /// Does this layout allow for an optional parameter? + bool hasoption; + private: /// Name of the layout/paragraph environment string name_; Index: paragraph.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/paragraph.C,v retrieving revision 1.222 diff -u -p -r1.222 paragraph.C --- paragraph.C 2002/08/15 07:53:46 1.222 +++ paragraph.C 2002/08/19 18:21:49 @@ -32,6 +32,7 @@ #include "insets/insetinclude.h" #include "insets/insetbib.h" #include "insets/insettext.h" +#include "insets/insetshorttitle.h" #include "support/filetools.h" #include "support/lstrings.h" @@ -1092,6 +1088,23 @@ int Paragraph::getPositionOfInset(Inset return -1; } +namespace { + +InsetShortTitle * shortTitleInset(Paragraph const & par) +{ + // Find the entry. + InsetList::iterator it = par.insetlist.begin(); + InsetList::iterator end = par.insetlist.end(); + for (; it != end; ++it) { + Inset * ins = it.getInset(); + if (ins->lyxCode() == Inset::SHORTTITLE_CODE) { + return static_cast<InsetShortTitle *>(ins); + } + } + return 0; +} + +} // end namespace Paragraph * Paragraph::TeXOnePar(Buffer const * buf, BufferParams const & bparams, @@ -1190,8 +1203,17 @@ Paragraph * Paragraph::TeXOnePar(Buffer switch (style->latextype) { case LATEX_COMMAND: os << '\\' - << style->latexname() - << style->latexparam(); + << style->latexname(); + + // Separate handling of shorttitle inset. + // This means you can put it into ANY LaTeX cmd + if (style->hasoption) { + InsetShortTitle * it = shortTitleInset(*this); + if (it != 0) + it->latexOptional(buf, os, false, false); + } + else + os << style->latexparam(); break; case LATEX_ITEM_ENVIRONMENT: if (bibkey) { Index: paragraph.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/paragraph.h,v retrieving revision 1.44 diff -u -p -r1.44 paragraph.h --- paragraph.h 2002/08/15 07:53:46 1.44 +++ paragraph.h 2002/08/19 18:21:49 @@ -27,6 +27,7 @@ class BufferParams; class BufferView; class Counters; class InsetBibKey; +class InsetShortTitle; class Language; class LaTeXFeatures; class ParagraphParameters; Index: paragraph_pimpl.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/paragraph_pimpl.C,v retrieving revision 1.42 diff -u -p -r1.42 paragraph_pimpl.C --- paragraph_pimpl.C 2002/08/11 15:03:51 1.42 +++ paragraph_pimpl.C 2002/08/19 16:58:20 Index: insets/inset.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/inset.h,v retrieving revision 1.55 diff -u -p -r1.55 inset.h --- insets/inset.h 2002/08/13 17:43:38 1.55 +++ insets/inset.h 2002/08/19 16:58:27 @@ -115,7 +115,9 @@ public: /// FLOAT_LIST_CODE, /// - INDEX_PRINT_CODE + INDEX_PRINT_CODE, + /// + SHORTTITLE_CODE }; ///
msg43133/pgp00000.pgp
Description: PGP signature