allow more than one optional inset

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9272 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2004-11-19 16:17:52 +00:00
parent 020972b7f9
commit 6ae4dc23f4
9 changed files with 77 additions and 14 deletions

View File

@ -1,3 +1,7 @@
2004-11-19 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* Customization.lyx: document OptionalArgs
2004-11-04 Christian Ridderström <chr@home.se>
* LaTeXConfig.lyx.in: remove "supported" and "other" from CTAN

View File

@ -5844,6 +5844,21 @@ LatexName
\layout Description
\family typewriter
\series medium
OptionalArgs
\family default
\series default
[
\family typewriter
int=0
\family default
] The number of optional arguments that can be used with this layout.
This is useful for things like section headings, and only makes sense with
LaTeX.
\layout Description
\family typewriter
\series medium
Margin

View File

@ -1,3 +1,13 @@
2004-11-16 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* text3.C (getStatus): disable LFUN_INSET_OPTARG when the max
number of InsetOptArgs has already been inserted.
* output_latex.C (latexOptArgInsets): new method. This outputs all
the optarg insets, up to the limit defined in the layout file.
(optArgInset): removed
(TeXOnePar): call latexOptArgInsets; correctly update texrow
2004-11-16 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* paragraph.C (isLetter): remove special spellchecker-related

View File

@ -1,3 +1,8 @@
2004-11-16 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* insetoptarg.C (latexOptional): return number of lines instead of
number of characters
2004-11-18 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* insettabular.[Ch] (string2params): Don't pretend to return the

View File

@ -75,10 +75,10 @@ int InsetOptArg::latexOptional(Buffer const & buf, ostream & os,
OutputParams const & runparams) const
{
ostringstream ss;
InsetText::latex(buf, ss, runparams);
int ret = InsetText::latex(buf, ss, runparams);
string str = ss.str();
if (str.find(']') != string::npos)
str = '{' + str + '}';
os << '[' << str << ']';
return str.length() + 2;
return ret;
}

View File

@ -195,18 +195,22 @@ TeXEnvironment(Buffer const & buf,
}
InsetOptArg * optArgInset(Paragraph const & par)
int latexOptArgInsets(Buffer const & buf, Paragraph const & par,
ostream & os, OutputParams const & runparams, int number)
{
// Find the entry.
int lines = 0;
InsetList::const_iterator it = par.insetlist.begin();
InsetList::const_iterator end = par.insetlist.end();
for (; it != end; ++it) {
InsetBase * ins = it->inset;
if (ins->lyxCode() == InsetBase::OPTARG_CODE) {
return static_cast<InsetOptArg *>(ins);
for (; it != end && number > 0 ; ++it) {
if (it->inset->lyxCode() == InsetBase::OPTARG_CODE) {
InsetOptArg * ins =
static_cast<InsetOptArg *>(it->inset);
lines += ins->latexOptional(buf, os, runparams);
--number;
}
}
return 0;
return lines;
}
@ -308,10 +312,13 @@ TeXOnePar(Buffer const & buf,
os << '\\' << style->latexname();
// Separate handling of optional argument inset.
if (style->optionalargs == 1) {
InsetOptArg * it = optArgInset(*pit);
if (it)
it->latexOptional(buf, os, runparams);
if (style->optionalargs > 0) {
int ret = latexOptArgInsets(buf, *pit, os, runparams,
style->optionalargs);
while (ret > 0) {
texrow.newline();
--ret;
}
}
else
os << style->latexparam();

View File

@ -353,3 +353,20 @@ void getParsInRange(ParagraphList & pars, int ystart, int yend,
for (end = beg ; end != endpar && pars[end].y <= yend; ++end)
;
}
/// return the number of InsetOptArg in a paragraph
int numberOfOptArgs(Paragraph const & par)
{
int num = 0;
InsetList::const_iterator it = par.insetlist.begin();
InsetList::const_iterator end = par.insetlist.end();
for (; it != end ; ++it) {
if (it->inset->lyxCode() == InsetBase::OPTARG_CODE)
++num;
}
return num;
}

View File

@ -67,4 +67,8 @@ void getParsInRange(ParagraphList & plist,
lyx::par_type & beg,
lyx::par_type & end);
/// return the number of InsetOptArg in a paragraph
int numberOfOptArgs(Paragraph const & par);
#endif // PARAGRAPH_FUNCS_H

View File

@ -1594,7 +1594,8 @@ bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
break;
case LFUN_INSET_OPTARG:
enable = cur.paragraph().layout()->optionalargs;
enable = numberOfOptArgs(cur.paragraph())
< cur.paragraph().layout()->optionalargs;
break;
case LFUN_APPENDIX: