2008-02-22 03:27:42 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file InsetLayout.cpp
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Martin Vermeer
|
|
|
|
* \author Richard Heck
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "InsetLayout.h"
|
|
|
|
|
2009-02-09 23:30:24 +00:00
|
|
|
#include "ColorSet.h"
|
2012-11-19 13:21:02 +00:00
|
|
|
#include "Layout.h"
|
2008-02-22 03:39:10 +00:00
|
|
|
#include "Lexer.h"
|
2008-07-28 15:14:37 +00:00
|
|
|
#include "TextClass.h"
|
2008-06-18 18:54:31 +00:00
|
|
|
|
2008-07-28 15:14:37 +00:00
|
|
|
#include "support/debug.h"
|
2008-02-22 03:27:42 +00:00
|
|
|
#include "support/lstrings.h"
|
2012-04-26 14:31:42 +00:00
|
|
|
#include "support/textutils.h"
|
2008-02-22 03:27:42 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::set;
|
|
|
|
using std::vector;
|
|
|
|
|
2015-04-26 14:49:16 +00:00
|
|
|
using namespace lyx::support;
|
|
|
|
|
2008-02-22 03:27:42 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2010-01-14 23:45:53 +00:00
|
|
|
InsetLayout::InsetLayout() :
|
|
|
|
name_(from_ascii("undefined")), lyxtype_(STANDARD),
|
2009-12-18 00:29:22 +00:00
|
|
|
labelstring_(from_ascii("UNDEFINED")), contentaslabel_(false),
|
2015-01-11 19:00:45 +00:00
|
|
|
decoration_(DEFAULT), latextype_(NOLATEXTYPE), font_(inherit_font),
|
|
|
|
labelfont_(sane_font), bgcolor_(Color_error),
|
|
|
|
fixedwidthpreambleencoding_(false), htmlforcecss_ (false),
|
|
|
|
htmlisblock_(true), multipar_(true), custompars_(true),
|
|
|
|
forceplain_(false), passthru_(false), parbreakisnewline_(false),
|
|
|
|
freespacing_(false), keepempty_(false), forceltr_(false),
|
|
|
|
forceownlines_(false), needprotect_(false), intoc_(false),
|
|
|
|
spellcheck_(true), resetsfont_(false), display_(true),
|
2015-11-03 16:47:25 +00:00
|
|
|
forcelocalfontswitch_(false), add_to_toc_(false), is_toc_caption_(false)
|
2014-12-20 20:03:40 +00:00
|
|
|
{
|
2008-10-05 19:38:22 +00:00
|
|
|
labelfont_.setColor(Color_error);
|
2008-02-22 03:27:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-11 19:00:45 +00:00
|
|
|
InsetLayout::InsetDecoration translateDecoration(std::string const & str)
|
2008-04-03 20:55:09 +00:00
|
|
|
{
|
2015-04-26 14:49:16 +00:00
|
|
|
if (compare_ascii_no_case(str, "classic") == 0)
|
2008-10-25 13:41:02 +00:00
|
|
|
return InsetLayout::CLASSIC;
|
2015-04-26 14:49:16 +00:00
|
|
|
if (compare_ascii_no_case(str, "minimalistic") == 0)
|
2008-10-25 13:41:02 +00:00
|
|
|
return InsetLayout::MINIMALISTIC;
|
2015-04-26 14:49:16 +00:00
|
|
|
if (compare_ascii_no_case(str, "conglomerate") == 0)
|
2008-10-25 13:41:02 +00:00
|
|
|
return InsetLayout::CONGLOMERATE;
|
|
|
|
return InsetLayout::DEFAULT;
|
2008-04-03 20:55:09 +00:00
|
|
|
}
|
2008-02-22 03:27:42 +00:00
|
|
|
|
2012-12-02 14:47:23 +00:00
|
|
|
namespace {
|
|
|
|
|
2008-10-25 14:02:25 +00:00
|
|
|
InsetLayout::InsetLaTeXType translateLaTeXType(std::string const & str)
|
|
|
|
{
|
2015-04-26 14:49:16 +00:00
|
|
|
if (compare_ascii_no_case(str, "command") == 0)
|
2008-10-25 14:02:25 +00:00
|
|
|
return InsetLayout::COMMAND;
|
2015-04-26 14:49:16 +00:00
|
|
|
if (compare_ascii_no_case(str, "environment") == 0)
|
2008-10-25 14:02:25 +00:00
|
|
|
return InsetLayout::ENVIRONMENT;
|
2015-04-26 14:49:16 +00:00
|
|
|
if (compare_ascii_no_case(str, "none") == 0)
|
2008-10-25 14:02:25 +00:00
|
|
|
return InsetLayout::NOLATEXTYPE;
|
|
|
|
return InsetLayout::ILT_ERROR;
|
|
|
|
}
|
|
|
|
|
2009-02-09 23:30:24 +00:00
|
|
|
} // namespace anon
|
2008-02-22 16:15:21 +00:00
|
|
|
|
|
|
|
|
2008-12-16 14:13:02 +00:00
|
|
|
bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
2008-02-22 03:27:42 +00:00
|
|
|
{
|
2008-04-03 20:55:09 +00:00
|
|
|
enum {
|
2015-11-03 16:47:25 +00:00
|
|
|
IL_ADDTOTOC,
|
2012-11-19 13:21:02 +00:00
|
|
|
IL_ARGUMENT,
|
2012-04-10 18:21:01 +00:00
|
|
|
IL_BABELPREAMBLE,
|
2008-04-03 20:55:09 +00:00
|
|
|
IL_BGCOLOR,
|
2009-12-18 00:29:22 +00:00
|
|
|
IL_CONTENTASLABEL,
|
2008-07-28 15:14:37 +00:00
|
|
|
IL_COPYSTYLE,
|
2009-06-06 03:02:43 +00:00
|
|
|
IL_COUNTER,
|
2008-10-05 19:38:22 +00:00
|
|
|
IL_CUSTOMPARS,
|
2008-04-03 20:55:09 +00:00
|
|
|
IL_DECORATION,
|
Introduce a wrapper class for odocstream to help ensuring that no
blank lines may be inadvertently output. This is achieved by using two
special iomanip-like variables (breakln and safebreakln) in the lyx::
namespace. When they are inserted in the stream, a newline is output
only if not already at the beginning of a line. The difference between
breakln and safebreakln is that, if needed, the former outputs '\n'
and the latter "%\n".
In future, the new class will also be used for counting the number of
newlines issued. Even if the infractrure for doing that is already in
place, the counting is essentially still done the old way.
There are still places in the code where the functionality of the
class could be used, most probably. ATM, it is used for InsetTabular,
InsetListings, InsetFloat, and InsetText.
The Comment and GreyedOut insets required a special treatment and a
new InsetLayout parameter (Display) has been introduced. The default
for Display is "true", meaning that the corresponding latex
environment is of "display" type, i.e., it stands on its own, whereas
"false" means that the contents appear inline with the text. The
latter is the case for both Comment and GreyedOut insets.
Mostly, the only visible effects on latex exports should be the
disappearing of some redundant % chars and the appearing/disappearing
of null {} latex groups after a comment or lyxgreyedout environments
(they are related to the presence or absence of a space immediately
after those environments), as well as the fact that math environments
are now started on their own lines.
As a last thing, only the latex code between \begin{document} and
\end{document} goes through the new class, the preamble being directly
output through odocstream, as usual.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37360 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-29 02:41:13 +00:00
|
|
|
IL_DISPLAY,
|
2015-01-11 19:00:45 +00:00
|
|
|
IL_FIXEDWIDTH_PREAMBLE_ENCODING,
|
2008-07-28 15:14:37 +00:00
|
|
|
IL_FONT,
|
2012-11-28 19:55:21 +00:00
|
|
|
IL_FORCE_LOCAL_FONT_SWITCH,
|
2008-04-03 20:55:09 +00:00
|
|
|
IL_FORCELTR,
|
2014-12-01 13:56:47 +00:00
|
|
|
IL_FORCEOWNLINES,
|
2008-10-05 19:38:22 +00:00
|
|
|
IL_FORCEPLAIN,
|
2008-07-28 15:14:37 +00:00
|
|
|
IL_FREESPACING,
|
2009-06-05 17:36:51 +00:00
|
|
|
IL_HTMLTAG,
|
|
|
|
IL_HTMLATTR,
|
2009-10-27 14:33:01 +00:00
|
|
|
IL_HTMLFORCECSS,
|
2009-06-06 03:02:43 +00:00
|
|
|
IL_HTMLINNERTAG,
|
|
|
|
IL_HTMLINNERATTR,
|
2009-10-26 20:53:46 +00:00
|
|
|
IL_HTMLISBLOCK,
|
2009-06-06 03:02:43 +00:00
|
|
|
IL_HTMLLABEL,
|
2009-06-05 17:36:51 +00:00
|
|
|
IL_HTMLSTYLE,
|
2009-06-05 19:42:56 +00:00
|
|
|
IL_HTMLPREAMBLE,
|
2009-02-06 17:54:33 +00:00
|
|
|
IL_INTOC,
|
2015-11-03 16:47:25 +00:00
|
|
|
IL_ISTOCCAPTION,
|
2008-04-03 20:55:09 +00:00
|
|
|
IL_LABELFONT,
|
|
|
|
IL_LABELSTRING,
|
2012-04-10 18:21:01 +00:00
|
|
|
IL_LANGPREAMBLE,
|
2008-04-03 20:55:09 +00:00
|
|
|
IL_LATEXNAME,
|
|
|
|
IL_LATEXPARAM,
|
|
|
|
IL_LATEXTYPE,
|
2012-11-25 18:10:16 +00:00
|
|
|
IL_LEFTDELIM,
|
2008-04-03 20:55:09 +00:00
|
|
|
IL_LYXTYPE,
|
2014-12-08 08:06:41 +00:00
|
|
|
IL_OBSOLETEDBY,
|
2008-04-03 20:55:09 +00:00
|
|
|
IL_KEEPEMPTY,
|
|
|
|
IL_MULTIPAR,
|
|
|
|
IL_NEEDPROTECT,
|
|
|
|
IL_PASSTHRU,
|
2015-04-20 16:13:49 +00:00
|
|
|
IL_PASSTHRU_CHARS,
|
2010-08-09 21:20:29 +00:00
|
|
|
IL_PARBREAKISNEWLINE,
|
2008-04-03 20:55:09 +00:00
|
|
|
IL_PREAMBLE,
|
|
|
|
IL_REQUIRES,
|
2012-11-25 18:10:16 +00:00
|
|
|
IL_RIGHTDELIM,
|
2010-03-17 12:23:24 +00:00
|
|
|
IL_REFPREFIX,
|
2012-12-02 09:16:26 +00:00
|
|
|
IL_RESETARGS,
|
2010-10-13 15:54:39 +00:00
|
|
|
IL_RESETSFONT,
|
2012-12-02 09:16:26 +00:00
|
|
|
IL_SPELLCHECK,
|
2008-04-03 20:55:09 +00:00
|
|
|
IL_END
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-04-02 23:06:22 +00:00
|
|
|
LexerKeyword elementTags[] = {
|
2015-11-03 16:47:25 +00:00
|
|
|
{ "addtotoc", IL_ADDTOTOC },
|
2012-11-19 13:21:02 +00:00
|
|
|
{ "argument", IL_ARGUMENT },
|
2012-04-10 18:21:01 +00:00
|
|
|
{ "babelpreamble", IL_BABELPREAMBLE },
|
2008-02-22 03:27:42 +00:00
|
|
|
{ "bgcolor", IL_BGCOLOR },
|
2009-12-18 00:29:22 +00:00
|
|
|
{ "contentaslabel", IL_CONTENTASLABEL },
|
2015-01-11 19:00:45 +00:00
|
|
|
{ "copystyle", IL_COPYSTYLE },
|
2009-06-06 03:02:43 +00:00
|
|
|
{ "counter", IL_COUNTER},
|
2008-10-05 19:38:22 +00:00
|
|
|
{ "custompars", IL_CUSTOMPARS },
|
2008-02-22 03:27:42 +00:00
|
|
|
{ "decoration", IL_DECORATION },
|
Introduce a wrapper class for odocstream to help ensuring that no
blank lines may be inadvertently output. This is achieved by using two
special iomanip-like variables (breakln and safebreakln) in the lyx::
namespace. When they are inserted in the stream, a newline is output
only if not already at the beginning of a line. The difference between
breakln and safebreakln is that, if needed, the former outputs '\n'
and the latter "%\n".
In future, the new class will also be used for counting the number of
newlines issued. Even if the infractrure for doing that is already in
place, the counting is essentially still done the old way.
There are still places in the code where the functionality of the
class could be used, most probably. ATM, it is used for InsetTabular,
InsetListings, InsetFloat, and InsetText.
The Comment and GreyedOut insets required a special treatment and a
new InsetLayout parameter (Display) has been introduced. The default
for Display is "true", meaning that the corresponding latex
environment is of "display" type, i.e., it stands on its own, whereas
"false" means that the contents appear inline with the text. The
latter is the case for both Comment and GreyedOut insets.
Mostly, the only visible effects on latex exports should be the
disappearing of some redundant % chars and the appearing/disappearing
of null {} latex groups after a comment or lyxgreyedout environments
(they are related to the presence or absence of a space immediately
after those environments), as well as the fact that math environments
are now started on their own lines.
As a last thing, only the latex code between \begin{document} and
\end{document} goes through the new class, the preamble being directly
output through odocstream, as usual.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37360 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-29 02:41:13 +00:00
|
|
|
{ "display", IL_DISPLAY },
|
2008-02-22 03:27:42 +00:00
|
|
|
{ "end", IL_END },
|
2015-01-11 19:00:45 +00:00
|
|
|
{ "fixedwidthpreambleencoding", IL_FIXEDWIDTH_PREAMBLE_ENCODING },
|
2008-02-22 03:27:42 +00:00
|
|
|
{ "font", IL_FONT },
|
2012-11-28 19:55:21 +00:00
|
|
|
{ "forcelocalfontswitch", IL_FORCE_LOCAL_FONT_SWITCH },
|
2008-02-22 03:27:42 +00:00
|
|
|
{ "forceltr", IL_FORCELTR },
|
2014-12-01 13:56:47 +00:00
|
|
|
{ "forceownlines", IL_FORCEOWNLINES },
|
2008-10-05 19:38:22 +00:00
|
|
|
{ "forceplain", IL_FORCEPLAIN },
|
2008-02-22 03:27:42 +00:00
|
|
|
{ "freespacing", IL_FREESPACING },
|
2009-06-05 17:36:51 +00:00
|
|
|
{ "htmlattr", IL_HTMLATTR },
|
2009-10-27 14:33:01 +00:00
|
|
|
{ "htmlforcecss", IL_HTMLFORCECSS },
|
2009-06-06 03:02:43 +00:00
|
|
|
{ "htmlinnerattr", IL_HTMLINNERATTR},
|
|
|
|
{ "htmlinnertag", IL_HTMLINNERTAG},
|
2009-10-26 20:53:46 +00:00
|
|
|
{ "htmlisblock", IL_HTMLISBLOCK},
|
2009-06-06 03:02:43 +00:00
|
|
|
{ "htmllabel", IL_HTMLLABEL },
|
2009-06-05 19:42:56 +00:00
|
|
|
{ "htmlpreamble", IL_HTMLPREAMBLE },
|
2009-06-05 17:36:51 +00:00
|
|
|
{ "htmlstyle", IL_HTMLSTYLE },
|
|
|
|
{ "htmltag", IL_HTMLTAG },
|
2009-02-06 17:54:33 +00:00
|
|
|
{ "intoc", IL_INTOC },
|
2015-11-03 16:47:25 +00:00
|
|
|
{ "istoccaption", IL_ISTOCCAPTION },
|
2008-02-22 03:27:42 +00:00
|
|
|
{ "keepempty", IL_KEEPEMPTY },
|
|
|
|
{ "labelfont", IL_LABELFONT },
|
|
|
|
{ "labelstring", IL_LABELSTRING },
|
2012-04-10 18:21:01 +00:00
|
|
|
{ "langpreamble", IL_LANGPREAMBLE },
|
2008-02-22 03:27:42 +00:00
|
|
|
{ "latexname", IL_LATEXNAME },
|
|
|
|
{ "latexparam", IL_LATEXPARAM },
|
|
|
|
{ "latextype", IL_LATEXTYPE },
|
2012-11-25 18:10:16 +00:00
|
|
|
{ "leftdelim", IL_LEFTDELIM },
|
2008-02-22 03:27:42 +00:00
|
|
|
{ "lyxtype", IL_LYXTYPE },
|
|
|
|
{ "multipar", IL_MULTIPAR },
|
|
|
|
{ "needprotect", IL_NEEDPROTECT },
|
2014-12-08 08:06:41 +00:00
|
|
|
{ "obsoletedby", IL_OBSOLETEDBY },
|
2010-08-09 21:20:29 +00:00
|
|
|
{ "parbreakisnewline", IL_PARBREAKISNEWLINE },
|
2008-02-22 03:27:42 +00:00
|
|
|
{ "passthru", IL_PASSTHRU },
|
2015-04-20 16:13:49 +00:00
|
|
|
{ "passthruchars", IL_PASSTHRU_CHARS },
|
2008-02-22 03:27:42 +00:00
|
|
|
{ "preamble", IL_PREAMBLE },
|
2010-03-17 12:23:24 +00:00
|
|
|
{ "refprefix", IL_REFPREFIX },
|
2010-02-13 15:44:17 +00:00
|
|
|
{ "requires", IL_REQUIRES },
|
2012-12-02 09:16:26 +00:00
|
|
|
{ "resetargs", IL_RESETARGS },
|
2010-10-13 15:54:39 +00:00
|
|
|
{ "resetsfont", IL_RESETSFONT },
|
2012-11-25 18:10:16 +00:00
|
|
|
{ "rightdelim", IL_RIGHTDELIM },
|
2010-02-13 15:44:17 +00:00
|
|
|
{ "spellcheck", IL_SPELLCHECK }
|
2008-02-22 03:27:42 +00:00
|
|
|
};
|
|
|
|
|
2008-04-05 10:34:29 +00:00
|
|
|
lex.pushTable(elementTags);
|
2008-02-22 03:27:42 +00:00
|
|
|
|
|
|
|
labelfont_ = inherit_font;
|
2008-10-25 10:47:38 +00:00
|
|
|
bgcolor_ = Color_none;
|
2008-02-22 03:27:42 +00:00
|
|
|
bool getout = false;
|
2008-10-05 19:38:22 +00:00
|
|
|
// whether we've read the CustomPars or ForcePlain tag
|
|
|
|
// for issuing a warning in case MultiPars comes later
|
|
|
|
bool readCustomOrPlain = false;
|
2008-04-05 10:34:29 +00:00
|
|
|
|
2015-01-11 19:00:45 +00:00
|
|
|
string tmp;
|
2008-04-05 10:34:29 +00:00
|
|
|
while (!getout && lex.isOK()) {
|
|
|
|
int le = lex.lex();
|
2008-02-22 03:27:42 +00:00
|
|
|
switch (le) {
|
|
|
|
case Lexer::LEX_UNDEF:
|
2008-04-05 21:24:57 +00:00
|
|
|
lex.printError("Unknown InsetLayout tag");
|
2008-02-22 03:27:42 +00:00
|
|
|
continue;
|
2008-04-05 21:24:57 +00:00
|
|
|
default:
|
|
|
|
break;
|
2008-02-22 03:27:42 +00:00
|
|
|
}
|
2008-04-03 20:55:09 +00:00
|
|
|
switch (le) {
|
2008-10-25 15:25:46 +00:00
|
|
|
// FIXME
|
2008-12-16 14:13:02 +00:00
|
|
|
// Perhaps a more elegant way to deal with the next two would be the
|
2008-10-25 15:25:46 +00:00
|
|
|
// way this sort of thing is handled in Layout::read(), namely, by
|
|
|
|
// using the Lexer.
|
2008-10-25 13:32:54 +00:00
|
|
|
case IL_LYXTYPE: {
|
2011-03-29 00:57:07 +00:00
|
|
|
// make sure that we have the right sort of name.
|
2011-03-29 01:01:24 +00:00
|
|
|
if (name_ != from_ascii("undefined")
|
|
|
|
&& name_.substr(0,5) != from_ascii("Flex:")) {
|
2011-03-29 00:57:07 +00:00
|
|
|
LYXERR0("Flex insets must have names of the form `Flex:<name>'.\n"
|
|
|
|
"This one has the name `" << to_utf8(name_) << "'\n"
|
|
|
|
"Ignoring LyXType declaration.");
|
2011-03-29 01:01:24 +00:00
|
|
|
break;
|
2011-03-29 00:57:07 +00:00
|
|
|
}
|
2008-10-25 13:32:54 +00:00
|
|
|
string lt;
|
|
|
|
lex >> lt;
|
|
|
|
lyxtype_ = translateLyXType(lt);
|
|
|
|
if (lyxtype_ == NOLYXTYPE)
|
|
|
|
LYXERR0("Unknown LyXType `" << lt << "'.");
|
2010-01-14 21:43:44 +00:00
|
|
|
if (lyxtype_ == CHARSTYLE)
|
|
|
|
multipar_ = false;
|
2008-02-22 03:27:42 +00:00
|
|
|
break;
|
2008-10-25 13:32:54 +00:00
|
|
|
}
|
2008-10-25 14:02:25 +00:00
|
|
|
case IL_LATEXTYPE: {
|
|
|
|
string lt;
|
|
|
|
lex >> lt;
|
|
|
|
latextype_ = translateLaTeXType(lt);
|
|
|
|
if (latextype_ == ILT_ERROR)
|
|
|
|
LYXERR0("Unknown LaTeXType `" << lt << "'.");
|
2008-02-22 03:27:42 +00:00
|
|
|
break;
|
2008-10-25 14:02:25 +00:00
|
|
|
}
|
2008-02-22 03:27:42 +00:00
|
|
|
case IL_LABELSTRING:
|
2008-04-05 10:34:29 +00:00
|
|
|
lex >> labelstring_;
|
2008-02-22 03:27:42 +00:00
|
|
|
break;
|
|
|
|
case IL_DECORATION:
|
2008-04-05 10:34:29 +00:00
|
|
|
lex >> tmp;
|
|
|
|
decoration_ = translateDecoration(tmp);
|
2008-02-22 03:27:42 +00:00
|
|
|
break;
|
|
|
|
case IL_LATEXNAME:
|
2008-04-05 10:34:29 +00:00
|
|
|
lex >> latexname_;
|
2008-02-22 03:27:42 +00:00
|
|
|
break;
|
|
|
|
case IL_LATEXPARAM:
|
2008-04-05 10:34:29 +00:00
|
|
|
lex >> tmp;
|
2015-04-26 14:49:16 +00:00
|
|
|
latexparam_ = subst(tmp, """, "\"");
|
2008-02-22 03:27:42 +00:00
|
|
|
break;
|
2012-11-25 18:10:16 +00:00
|
|
|
case IL_LEFTDELIM:
|
|
|
|
lex >> leftdelim_;
|
2015-04-26 14:49:16 +00:00
|
|
|
leftdelim_ = subst(leftdelim_, from_ascii("<br/>"),
|
2012-11-30 08:13:38 +00:00
|
|
|
from_ascii("\n"));
|
2012-11-25 18:10:16 +00:00
|
|
|
break;
|
2015-01-11 19:00:45 +00:00
|
|
|
case IL_FIXEDWIDTH_PREAMBLE_ENCODING:
|
|
|
|
lex >> fixedwidthpreambleencoding_;
|
|
|
|
break;
|
2012-11-28 19:55:21 +00:00
|
|
|
case IL_FORCE_LOCAL_FONT_SWITCH:
|
|
|
|
lex >> forcelocalfontswitch_;
|
|
|
|
break;
|
2012-11-25 18:10:16 +00:00
|
|
|
case IL_RIGHTDELIM:
|
|
|
|
lex >> rightdelim_;
|
2015-04-26 14:49:16 +00:00
|
|
|
rightdelim_ = subst(rightdelim_, from_ascii("<br/>"),
|
2012-11-30 08:13:38 +00:00
|
|
|
from_ascii("\n"));
|
2012-11-25 18:10:16 +00:00
|
|
|
break;
|
2008-02-22 03:27:42 +00:00
|
|
|
case IL_LABELFONT:
|
2008-04-05 10:34:29 +00:00
|
|
|
labelfont_ = lyxRead(lex, inherit_font);
|
2008-02-22 03:27:42 +00:00
|
|
|
break;
|
|
|
|
case IL_FORCELTR:
|
2008-04-05 10:34:29 +00:00
|
|
|
lex >> forceltr_;
|
2008-02-22 03:27:42 +00:00
|
|
|
break;
|
2014-12-01 13:56:47 +00:00
|
|
|
case IL_FORCEOWNLINES:
|
|
|
|
lex >> forceownlines_;
|
|
|
|
break;
|
2009-02-06 17:54:33 +00:00
|
|
|
case IL_INTOC:
|
|
|
|
lex >> intoc_;
|
|
|
|
break;
|
2008-02-22 03:27:42 +00:00
|
|
|
case IL_MULTIPAR:
|
2008-04-05 10:34:29 +00:00
|
|
|
lex >> multipar_;
|
2008-10-05 19:38:22 +00:00
|
|
|
// the defaults for these depend upon multipar_
|
|
|
|
if (readCustomOrPlain)
|
|
|
|
LYXERR0("Warning: Read MultiPar after CustomPars or ForcePlain. "
|
|
|
|
"Previous value may be overwritten!");
|
|
|
|
readCustomOrPlain = false;
|
|
|
|
custompars_ = multipar_;
|
|
|
|
forceplain_ = !multipar_;
|
|
|
|
break;
|
2009-06-06 03:02:43 +00:00
|
|
|
case IL_COUNTER:
|
|
|
|
lex >> counter_;
|
|
|
|
break;
|
2008-10-05 19:38:22 +00:00
|
|
|
case IL_CUSTOMPARS:
|
|
|
|
lex >> custompars_;
|
|
|
|
readCustomOrPlain = true;
|
|
|
|
break;
|
|
|
|
case IL_FORCEPLAIN:
|
|
|
|
lex >> forceplain_;
|
2010-08-08 14:34:59 +00:00
|
|
|
readCustomOrPlain = true;
|
2008-02-22 03:27:42 +00:00
|
|
|
break;
|
|
|
|
case IL_PASSTHRU:
|
2008-04-05 10:34:29 +00:00
|
|
|
lex >> passthru_;
|
2008-02-22 03:27:42 +00:00
|
|
|
break;
|
2015-04-20 16:13:49 +00:00
|
|
|
case IL_PASSTHRU_CHARS:
|
|
|
|
lex >> passthru_chars_;
|
|
|
|
break;
|
2010-08-09 21:20:29 +00:00
|
|
|
case IL_PARBREAKISNEWLINE:
|
|
|
|
lex >> parbreakisnewline_;
|
|
|
|
break;
|
2008-02-22 03:27:42 +00:00
|
|
|
case IL_KEEPEMPTY:
|
2008-04-05 10:34:29 +00:00
|
|
|
lex >> keepempty_;
|
2008-02-22 03:27:42 +00:00
|
|
|
break;
|
|
|
|
case IL_FREESPACING:
|
2008-04-05 10:34:29 +00:00
|
|
|
lex >> freespacing_;
|
2008-02-22 03:27:42 +00:00
|
|
|
break;
|
|
|
|
case IL_NEEDPROTECT:
|
2008-04-05 10:34:29 +00:00
|
|
|
lex >> needprotect_;
|
2008-02-22 03:27:42 +00:00
|
|
|
break;
|
2009-12-18 00:29:22 +00:00
|
|
|
case IL_CONTENTASLABEL:
|
|
|
|
lex >> contentaslabel_;
|
|
|
|
break;
|
2010-10-12 15:07:27 +00:00
|
|
|
case IL_COPYSTYLE: {
|
|
|
|
// initialize with a known style
|
2008-07-28 15:14:37 +00:00
|
|
|
docstring style;
|
|
|
|
lex >> style;
|
2015-04-26 14:49:16 +00:00
|
|
|
style = subst(style, '_', ' ');
|
2008-07-28 15:14:37 +00:00
|
|
|
|
|
|
|
// We don't want to apply the algorithm in DocumentClass::insetLayout()
|
|
|
|
// here. So we do it the long way.
|
2015-01-11 19:00:45 +00:00
|
|
|
TextClass::InsetLayouts::const_iterator it =
|
2008-07-28 15:14:37 +00:00
|
|
|
tclass.insetLayouts().find(style);
|
|
|
|
if (it != tclass.insetLayouts().end()) {
|
|
|
|
docstring const tmpname = name_;
|
|
|
|
this->operator=(it->second);
|
|
|
|
name_ = tmpname;
|
|
|
|
} else {
|
|
|
|
LYXERR0("Cannot copy unknown InsetLayout `"
|
2014-12-09 20:19:49 +00:00
|
|
|
<< style << "' to InsetLayout `"
|
|
|
|
<< name() << "'\n"
|
2008-07-28 15:14:37 +00:00
|
|
|
<< "All InsetLayouts so far:");
|
2015-01-11 19:00:45 +00:00
|
|
|
TextClass::InsetLayouts::const_iterator lit =
|
2008-07-28 15:14:37 +00:00
|
|
|
tclass.insetLayouts().begin();
|
2015-01-11 19:00:45 +00:00
|
|
|
TextClass::InsetLayouts::const_iterator len =
|
2008-07-28 15:14:37 +00:00
|
|
|
tclass.insetLayouts().end();
|
|
|
|
for (; lit != len; ++lit)
|
|
|
|
lyxerr << lit->second.name() << "\n";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-12-08 08:06:41 +00:00
|
|
|
case IL_OBSOLETEDBY: {
|
|
|
|
docstring style;
|
|
|
|
lex >> style;
|
2015-04-26 14:49:16 +00:00
|
|
|
style = subst(style, '_', ' ');
|
2014-12-08 08:06:41 +00:00
|
|
|
|
|
|
|
// We don't want to apply the algorithm in DocumentClass::insetLayout()
|
|
|
|
// here. So we do it the long way.
|
|
|
|
TextClass::InsetLayouts::const_iterator it =
|
|
|
|
tclass.insetLayouts().find(style);
|
|
|
|
if (it != tclass.insetLayouts().end()) {
|
|
|
|
docstring const tmpname = name_;
|
|
|
|
this->operator=(it->second);
|
|
|
|
name_ = tmpname;
|
|
|
|
if (obsoleted_by().empty())
|
|
|
|
obsoleted_by_ = style;
|
|
|
|
} else {
|
2014-12-09 20:19:49 +00:00
|
|
|
LYXERR0("Cannot replace InsetLayout `"
|
|
|
|
<< name()
|
|
|
|
<< "' with unknown InsetLayout `"
|
|
|
|
<< style << "'\n"
|
|
|
|
<< "All InsetLayouts so far:");
|
2015-01-11 19:00:45 +00:00
|
|
|
TextClass::InsetLayouts::const_iterator lit =
|
2014-12-09 20:19:49 +00:00
|
|
|
tclass.insetLayouts().begin();
|
2015-01-11 19:00:45 +00:00
|
|
|
TextClass::InsetLayouts::const_iterator len =
|
2014-12-09 20:19:49 +00:00
|
|
|
tclass.insetLayouts().end();
|
|
|
|
for (; lit != len; ++lit)
|
|
|
|
lyxerr << lit->second.name() << "\n";
|
2014-12-08 08:06:41 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-07-28 15:14:37 +00:00
|
|
|
|
2008-02-22 03:27:42 +00:00
|
|
|
case IL_FONT: {
|
2008-04-05 10:34:29 +00:00
|
|
|
font_ = lyxRead(lex, inherit_font);
|
2008-03-03 04:19:50 +00:00
|
|
|
// If you want to define labelfont, you need to do so after
|
|
|
|
// font is defined.
|
|
|
|
labelfont_ = font_;
|
2008-02-22 03:27:42 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-12-02 09:16:26 +00:00
|
|
|
case IL_RESETARGS:
|
|
|
|
bool reset;
|
|
|
|
lex >> reset;
|
2013-01-13 08:16:39 +00:00
|
|
|
if (reset) {
|
2012-12-02 09:16:26 +00:00
|
|
|
latexargs_.clear();
|
2013-01-13 08:16:39 +00:00
|
|
|
postcommandargs_.clear();
|
|
|
|
}
|
2012-12-02 09:16:26 +00:00
|
|
|
break;
|
2012-11-19 13:21:02 +00:00
|
|
|
case IL_ARGUMENT:
|
|
|
|
readArgument(lex);
|
|
|
|
break;
|
2008-04-05 10:34:29 +00:00
|
|
|
case IL_BGCOLOR:
|
|
|
|
lex >> tmp;
|
|
|
|
bgcolor_ = lcolor.getFromLyXName(tmp);
|
2008-02-22 03:27:42 +00:00
|
|
|
break;
|
|
|
|
case IL_PREAMBLE:
|
2009-06-03 23:44:31 +00:00
|
|
|
preamble_ = from_utf8(lex.getLongString("EndPreamble"));
|
2008-02-22 03:27:42 +00:00
|
|
|
break;
|
2012-04-10 18:21:01 +00:00
|
|
|
case IL_BABELPREAMBLE:
|
|
|
|
babelpreamble_ = from_utf8(lex.getLongString("EndBabelPreamble"));
|
|
|
|
break;
|
|
|
|
case IL_LANGPREAMBLE:
|
|
|
|
langpreamble_ = from_utf8(lex.getLongString("EndLangPreamble"));
|
|
|
|
break;
|
2010-03-17 12:23:24 +00:00
|
|
|
case IL_REFPREFIX:
|
|
|
|
lex >> refprefix_;
|
|
|
|
break;
|
2009-06-05 17:36:51 +00:00
|
|
|
case IL_HTMLTAG:
|
|
|
|
lex >> htmltag_;
|
|
|
|
break;
|
|
|
|
case IL_HTMLATTR:
|
|
|
|
lex >> htmlattr_;
|
|
|
|
break;
|
2009-10-27 14:33:01 +00:00
|
|
|
case IL_HTMLFORCECSS:
|
|
|
|
lex >> htmlforcecss_;
|
|
|
|
break;
|
2009-06-06 03:02:43 +00:00
|
|
|
case IL_HTMLINNERTAG:
|
|
|
|
lex >> htmlinnertag_;
|
|
|
|
break;
|
|
|
|
case IL_HTMLINNERATTR:
|
|
|
|
lex >> htmlinnerattr_;
|
|
|
|
break;
|
|
|
|
case IL_HTMLLABEL:
|
|
|
|
lex >> htmllabel_;
|
|
|
|
break;
|
2009-10-26 20:53:46 +00:00
|
|
|
case IL_HTMLISBLOCK:
|
|
|
|
lex >> htmlisblock_;
|
|
|
|
break;
|
2009-06-05 17:36:51 +00:00
|
|
|
case IL_HTMLSTYLE:
|
|
|
|
htmlstyle_ = from_utf8(lex.getLongString("EndHTMLStyle"));
|
|
|
|
break;
|
2009-06-05 19:42:56 +00:00
|
|
|
case IL_HTMLPREAMBLE:
|
|
|
|
htmlpreamble_ = from_utf8(lex.getLongString("EndPreamble"));
|
|
|
|
break;
|
2008-02-22 03:27:42 +00:00
|
|
|
case IL_REQUIRES: {
|
2008-04-05 10:34:29 +00:00
|
|
|
lex.eatLine();
|
2015-01-11 19:00:45 +00:00
|
|
|
vector<string> const req
|
2015-05-19 08:17:34 +00:00
|
|
|
= getVectorFromString(lex.getString(true));
|
2008-02-22 03:27:42 +00:00
|
|
|
requires_.insert(req.begin(), req.end());
|
|
|
|
break;
|
|
|
|
}
|
2010-02-13 15:44:17 +00:00
|
|
|
case IL_SPELLCHECK:
|
|
|
|
lex >> spellcheck_;
|
|
|
|
break;
|
2010-10-13 15:54:39 +00:00
|
|
|
case IL_RESETSFONT:
|
|
|
|
lex >> resetsfont_;
|
|
|
|
break;
|
Introduce a wrapper class for odocstream to help ensuring that no
blank lines may be inadvertently output. This is achieved by using two
special iomanip-like variables (breakln and safebreakln) in the lyx::
namespace. When they are inserted in the stream, a newline is output
only if not already at the beginning of a line. The difference between
breakln and safebreakln is that, if needed, the former outputs '\n'
and the latter "%\n".
In future, the new class will also be used for counting the number of
newlines issued. Even if the infractrure for doing that is already in
place, the counting is essentially still done the old way.
There are still places in the code where the functionality of the
class could be used, most probably. ATM, it is used for InsetTabular,
InsetListings, InsetFloat, and InsetText.
The Comment and GreyedOut insets required a special treatment and a
new InsetLayout parameter (Display) has been introduced. The default
for Display is "true", meaning that the corresponding latex
environment is of "display" type, i.e., it stands on its own, whereas
"false" means that the contents appear inline with the text. The
latter is the case for both Comment and GreyedOut insets.
Mostly, the only visible effects on latex exports should be the
disappearing of some redundant % chars and the appearing/disappearing
of null {} latex groups after a comment or lyxgreyedout environments
(they are related to the presence or absence of a space immediately
after those environments), as well as the fact that math environments
are now started on their own lines.
As a last thing, only the latex code between \begin{document} and
\end{document} goes through the new class, the preamble being directly
output through odocstream, as usual.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37360 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-29 02:41:13 +00:00
|
|
|
case IL_DISPLAY:
|
|
|
|
lex >> display_;
|
|
|
|
break;
|
2015-11-03 16:47:25 +00:00
|
|
|
case IL_ADDTOTOC:
|
|
|
|
lex >> toc_type_;
|
|
|
|
add_to_toc_ = !toc_type_.empty();
|
|
|
|
break;
|
|
|
|
case IL_ISTOCCAPTION:
|
|
|
|
lex >> is_toc_caption_;
|
|
|
|
break;
|
2008-02-22 03:27:42 +00:00
|
|
|
case IL_END:
|
|
|
|
getout = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Here add element to list if getout == true
|
|
|
|
if (!getout)
|
|
|
|
return false;
|
2015-01-11 19:00:45 +00:00
|
|
|
|
2008-02-22 03:27:42 +00:00
|
|
|
// The label font is generally used as-is without
|
|
|
|
// any realization against a given context.
|
|
|
|
labelfont_.realize(sane_font);
|
|
|
|
|
2008-04-05 10:34:29 +00:00
|
|
|
lex.popTable();
|
2008-02-22 03:27:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-10-25 13:32:54 +00:00
|
|
|
|
2015-01-11 19:00:45 +00:00
|
|
|
InsetLayout::InsetLyXType translateLyXType(std::string const & str)
|
2008-10-25 13:32:54 +00:00
|
|
|
{
|
2015-04-26 14:49:16 +00:00
|
|
|
if (compare_ascii_no_case(str, "charstyle") == 0)
|
2008-10-25 13:32:54 +00:00
|
|
|
return InsetLayout::CHARSTYLE;
|
2015-04-26 14:49:16 +00:00
|
|
|
if (compare_ascii_no_case(str, "custom") == 0)
|
2008-10-25 13:32:54 +00:00
|
|
|
return InsetLayout::CUSTOM;
|
2015-04-26 14:49:16 +00:00
|
|
|
if (compare_ascii_no_case(str, "element") == 0)
|
2008-10-25 13:32:54 +00:00
|
|
|
return InsetLayout::ELEMENT;
|
2015-04-26 14:49:16 +00:00
|
|
|
if (compare_ascii_no_case(str, "end") == 0)
|
2008-10-25 13:32:54 +00:00
|
|
|
return InsetLayout::END;
|
2015-04-26 14:49:16 +00:00
|
|
|
if (compare_ascii_no_case(str, "standard") == 0)
|
2008-10-25 13:32:54 +00:00
|
|
|
return InsetLayout::STANDARD;
|
|
|
|
return InsetLayout::NOLYXTYPE;
|
|
|
|
}
|
|
|
|
|
2009-10-27 14:33:01 +00:00
|
|
|
|
2009-10-27 19:46:47 +00:00
|
|
|
string const & InsetLayout::htmltag() const
|
|
|
|
{
|
|
|
|
if (htmltag_.empty())
|
2009-11-19 22:49:30 +00:00
|
|
|
htmltag_ = multipar_ ? "div" : "span";
|
2015-01-11 19:00:45 +00:00
|
|
|
return htmltag_;
|
2009-10-27 19:46:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-27 19:17:52 +00:00
|
|
|
string const & InsetLayout::htmlattr() const
|
|
|
|
{
|
|
|
|
if (htmlattr_.empty())
|
|
|
|
htmlattr_ = "class=\"" + defaultCSSClass() + "\"";
|
2015-01-11 19:00:45 +00:00
|
|
|
return htmlattr_;
|
2009-10-27 19:17:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const & InsetLayout::htmlinnerattr() const
|
|
|
|
{
|
|
|
|
if (htmlinnerattr_.empty())
|
|
|
|
htmlinnerattr_ = "class=\"" + defaultCSSClass() + "_inner\"";
|
2015-01-11 19:00:45 +00:00
|
|
|
return htmlinnerattr_;
|
2009-10-27 19:17:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-27 14:33:01 +00:00
|
|
|
string InsetLayout::defaultCSSClass() const
|
2015-01-11 19:00:45 +00:00
|
|
|
{
|
2009-10-27 14:33:01 +00:00
|
|
|
if (!defaultcssclass_.empty())
|
|
|
|
return defaultcssclass_;
|
2009-10-27 19:17:52 +00:00
|
|
|
string d;
|
|
|
|
string n = to_utf8(name());
|
|
|
|
string::const_iterator it = n.begin();
|
|
|
|
string::const_iterator en = n.end();
|
2009-10-27 14:33:01 +00:00
|
|
|
for (; it != en; ++it) {
|
2012-04-26 14:31:42 +00:00
|
|
|
if (!isAlphaASCII(*it))
|
2009-10-27 19:17:52 +00:00
|
|
|
d += "_";
|
2012-04-26 14:31:42 +00:00
|
|
|
else if (isLower(*it))
|
2009-10-27 14:33:01 +00:00
|
|
|
d += *it;
|
2009-10-27 19:17:52 +00:00
|
|
|
else
|
2015-04-26 14:49:16 +00:00
|
|
|
d += lowercase(*it);
|
2009-10-27 14:33:01 +00:00
|
|
|
}
|
|
|
|
// are there other characters we need to remove?
|
2009-10-27 19:17:52 +00:00
|
|
|
defaultcssclass_ = d;
|
2009-10-27 14:33:01 +00:00
|
|
|
return defaultcssclass_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetLayout::makeDefaultCSS() const
|
|
|
|
{
|
2015-01-11 19:00:45 +00:00
|
|
|
if (!htmldefaultstyle_.empty())
|
2009-10-27 14:33:01 +00:00
|
|
|
return;
|
2009-10-27 19:46:47 +00:00
|
|
|
docstring const mainfontCSS = font_.asCSS();
|
|
|
|
if (!mainfontCSS.empty())
|
2015-01-11 19:00:45 +00:00
|
|
|
htmldefaultstyle_ =
|
2009-10-27 19:46:47 +00:00
|
|
|
from_ascii(htmltag() + "." + defaultCSSClass() + " {\n") +
|
|
|
|
mainfontCSS + from_ascii("\n}\n");
|
2009-10-27 14:33:01 +00:00
|
|
|
}
|
|
|
|
|
2009-10-27 19:46:47 +00:00
|
|
|
|
2015-01-11 19:00:45 +00:00
|
|
|
docstring InsetLayout::htmlstyle() const
|
|
|
|
{
|
2009-10-27 14:33:01 +00:00
|
|
|
if (!htmlstyle_.empty() && !htmlforcecss_)
|
|
|
|
return htmlstyle_;
|
2009-10-27 19:46:47 +00:00
|
|
|
if (htmldefaultstyle_.empty())
|
2009-10-27 14:33:01 +00:00
|
|
|
makeDefaultCSS();
|
|
|
|
docstring retval = htmldefaultstyle_;
|
|
|
|
if (!htmlstyle_.empty())
|
2009-10-27 19:46:47 +00:00
|
|
|
retval += '\n' + htmlstyle_ + '\n';
|
2009-10-27 14:33:01 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2012-11-19 13:21:02 +00:00
|
|
|
void InsetLayout::readArgument(Lexer & lex)
|
|
|
|
{
|
|
|
|
Layout::latexarg arg;
|
|
|
|
arg.mandatory = false;
|
2012-12-17 12:32:40 +00:00
|
|
|
arg.autoinsert = false;
|
2015-05-09 10:17:24 +00:00
|
|
|
arg.insertcotext = false;
|
2012-11-19 13:21:02 +00:00
|
|
|
bool error = false;
|
|
|
|
bool finished = false;
|
2012-11-26 08:10:14 +00:00
|
|
|
arg.font = inherit_font;
|
|
|
|
arg.labelfont = inherit_font;
|
2015-11-03 16:47:25 +00:00
|
|
|
arg.is_toc_caption = false;
|
2012-11-29 14:34:20 +00:00
|
|
|
string nr;
|
2012-11-19 13:21:02 +00:00
|
|
|
lex >> nr;
|
2015-04-26 14:49:16 +00:00
|
|
|
bool const postcmd = prefixIs(nr, "post:");
|
2012-11-19 13:21:02 +00:00
|
|
|
while (!finished && lex.isOK() && !error) {
|
|
|
|
lex.next();
|
2015-04-26 14:49:16 +00:00
|
|
|
string const tok = ascii_lowercase(lex.getString());
|
2012-11-19 13:21:02 +00:00
|
|
|
|
|
|
|
if (tok.empty()) {
|
|
|
|
continue;
|
|
|
|
} else if (tok == "endargument") {
|
|
|
|
finished = true;
|
|
|
|
} else if (tok == "labelstring") {
|
|
|
|
lex.next();
|
|
|
|
arg.labelstring = lex.getDocString();
|
2012-12-09 18:15:41 +00:00
|
|
|
} else if (tok == "menustring") {
|
|
|
|
lex.next();
|
|
|
|
arg.menustring = lex.getDocString();
|
2012-11-19 13:21:02 +00:00
|
|
|
} else if (tok == "mandatory") {
|
|
|
|
lex.next();
|
|
|
|
arg.mandatory = lex.getBool();
|
2012-12-17 12:32:40 +00:00
|
|
|
} else if (tok == "autoinsert") {
|
|
|
|
lex.next();
|
|
|
|
arg.autoinsert = lex.getBool();
|
2015-05-09 10:17:24 +00:00
|
|
|
} else if (tok == "insertcotext") {
|
|
|
|
lex.next();
|
|
|
|
arg.insertcotext = lex.getBool();
|
2015-05-21 06:53:56 +00:00
|
|
|
} else if (tok == "insertcotext") {
|
|
|
|
lex.next();
|
|
|
|
arg.insertcotext = lex.getBool();
|
2012-11-19 13:21:02 +00:00
|
|
|
} else if (tok == "leftdelim") {
|
|
|
|
lex.next();
|
|
|
|
arg.ldelim = lex.getDocString();
|
2015-04-26 14:49:16 +00:00
|
|
|
arg.ldelim = subst(arg.ldelim,
|
2012-11-30 08:13:38 +00:00
|
|
|
from_ascii("<br/>"), from_ascii("\n"));
|
2012-11-19 13:21:02 +00:00
|
|
|
} else if (tok == "rightdelim") {
|
|
|
|
lex.next();
|
|
|
|
arg.rdelim = lex.getDocString();
|
2015-04-26 14:49:16 +00:00
|
|
|
arg.rdelim = subst(arg.rdelim,
|
2012-11-30 08:13:38 +00:00
|
|
|
from_ascii("<br/>"), from_ascii("\n"));
|
2013-02-24 10:29:21 +00:00
|
|
|
} else if (tok == "defaultarg") {
|
|
|
|
lex.next();
|
|
|
|
arg.defaultarg = lex.getDocString();
|
2012-12-10 13:09:51 +00:00
|
|
|
} else if (tok == "presetarg") {
|
|
|
|
lex.next();
|
|
|
|
arg.presetarg = lex.getDocString();
|
2012-11-19 13:21:02 +00:00
|
|
|
} else if (tok == "tooltip") {
|
|
|
|
lex.next();
|
|
|
|
arg.tooltip = lex.getDocString();
|
|
|
|
} else if (tok == "requires") {
|
|
|
|
lex.next();
|
|
|
|
arg.requires = lex.getString();
|
2012-11-26 08:10:14 +00:00
|
|
|
} else if (tok == "decoration") {
|
|
|
|
lex.next();
|
|
|
|
arg.decoration = lex.getString();
|
|
|
|
} else if (tok == "font") {
|
|
|
|
arg.font = lyxRead(lex, arg.font);
|
|
|
|
} else if (tok == "labelfont") {
|
|
|
|
arg.labelfont = lyxRead(lex, arg.labelfont);
|
2015-05-08 07:32:31 +00:00
|
|
|
} else if (tok == "passthruchars") {
|
|
|
|
lex.next();
|
|
|
|
arg.pass_thru_chars = lex.getDocString();
|
2015-11-03 16:47:25 +00:00
|
|
|
} else if (tok == "istoccaption") {
|
|
|
|
lex.next();
|
|
|
|
arg.is_toc_caption = lex.getBool();
|
2012-11-19 13:21:02 +00:00
|
|
|
} else {
|
|
|
|
lex.printError("Unknown tag");
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (arg.labelstring.empty())
|
|
|
|
LYXERR0("Incomplete Argument definition!");
|
2012-12-28 10:21:24 +00:00
|
|
|
else if (postcmd)
|
|
|
|
postcommandargs_[nr] = arg;
|
2012-11-19 13:21:02 +00:00
|
|
|
else
|
|
|
|
latexargs_[nr] = arg;
|
|
|
|
}
|
|
|
|
|
2012-12-28 10:21:24 +00:00
|
|
|
|
|
|
|
Layout::LaTeXArgMap InsetLayout::args() const
|
|
|
|
{
|
|
|
|
Layout::LaTeXArgMap args = latexargs_;
|
|
|
|
if (!postcommandargs_.empty())
|
|
|
|
args.insert(postcommandargs_.begin(), postcommandargs_.end());
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-28 18:02:07 +00:00
|
|
|
unsigned int InsetLayout::optArgs() const
|
2012-11-19 13:21:02 +00:00
|
|
|
{
|
2012-11-24 01:40:38 +00:00
|
|
|
unsigned int nr = 0;
|
2014-04-06 17:21:47 +00:00
|
|
|
Layout::LaTeXArgMap const args = InsetLayout::args();
|
|
|
|
Layout::LaTeXArgMap::const_iterator it = args.begin();
|
|
|
|
for (; it != args.end(); ++it) {
|
2012-11-19 13:21:02 +00:00
|
|
|
if (!(*it).second.mandatory)
|
|
|
|
++nr;
|
|
|
|
}
|
|
|
|
return nr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-28 18:02:07 +00:00
|
|
|
unsigned int InsetLayout::requiredArgs() const
|
2012-11-19 13:21:02 +00:00
|
|
|
{
|
2012-11-24 01:40:38 +00:00
|
|
|
unsigned int nr = 0;
|
2014-04-06 17:21:47 +00:00
|
|
|
Layout::LaTeXArgMap const args = InsetLayout::args();
|
|
|
|
Layout::LaTeXArgMap::const_iterator it = args.begin();
|
|
|
|
for (; it != args.end(); ++it) {
|
2012-11-19 13:21:02 +00:00
|
|
|
if ((*it).second.mandatory)
|
|
|
|
++nr;
|
|
|
|
}
|
|
|
|
return nr;
|
|
|
|
}
|
|
|
|
|
2009-10-27 14:33:01 +00:00
|
|
|
|
2008-02-22 03:27:42 +00:00
|
|
|
} //namespace lyx
|