2002-09-25 14:26:13 +00:00
|
|
|
/**
|
|
|
|
* \file insetcommandparams.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-07-04 13:54:28 +00:00
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
* \author Angus Leeming
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
* \author Georg Baum
|
2002-07-04 13:54:28 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-25 14:26:13 +00:00
|
|
|
*/
|
2002-07-04 13:54:28 +00:00
|
|
|
|
2002-11-04 00:15:56 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2002-07-04 13:54:28 +00:00
|
|
|
#include "insetcommandparams.h"
|
|
|
|
|
2003-09-05 09:01:27 +00:00
|
|
|
#include "debug.h"
|
|
|
|
#include "lyxlex.h"
|
2002-07-04 17:45:35 +00:00
|
|
|
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
|
|
|
#include <boost/assert.hpp>
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
using support::findToken;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
|
|
using std::string;
|
2002-07-04 17:45:35 +00:00
|
|
|
using std::endl;
|
2003-09-05 09:01:27 +00:00
|
|
|
using std::ostream;
|
2002-07-04 17:45:35 +00:00
|
|
|
|
2002-07-04 13:54:28 +00:00
|
|
|
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
InsetCommandParams::InsetCommandParams(string const & name)
|
|
|
|
: name_(name), preview_(false)
|
|
|
|
{
|
|
|
|
info_ = findInfo(name);
|
|
|
|
BOOST_ASSERT(info_);
|
|
|
|
params_.resize(info_->n);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InsetCommandParams::CommandInfo const *
|
|
|
|
InsetCommandParams::findInfo(std::string const & name)
|
|
|
|
{
|
|
|
|
// No parameter may be named "preview", because that is a required
|
|
|
|
// flag for all commands.
|
|
|
|
|
|
|
|
// InsetBibitem
|
|
|
|
if (name == "bibitem") {
|
|
|
|
static const char * const paramnames[] = {"label", "key", ""};
|
|
|
|
static const bool isoptional[] = {true, false};
|
|
|
|
static const CommandInfo info = {2, paramnames, isoptional};
|
|
|
|
return &info;
|
|
|
|
}
|
|
|
|
|
|
|
|
// InsetBibtex
|
|
|
|
if (name == "bibtex") {
|
|
|
|
static const char * const paramnames[] =
|
|
|
|
{"options", "btprint", "bibfiles", ""};
|
|
|
|
static const bool isoptional[] = {true, true, false};
|
|
|
|
static const CommandInfo info = {3, paramnames, isoptional};
|
|
|
|
return &info;
|
|
|
|
}
|
|
|
|
|
|
|
|
// InsetCitation
|
|
|
|
// FIXME: Use is_possible_cite_command() in
|
|
|
|
// src/frontends/controllers/biblio.C, see comment in src/factory.C.
|
|
|
|
if (name == "cite" || name == "citet" || name == "citep" || name == "citealt" ||
|
|
|
|
name == "citealp" || name == "citeauthor" || name == "citeyear" ||
|
|
|
|
name == "citeyearpar" || name == "citet*" || name == "citep*" ||
|
|
|
|
name == "citealt*" || name == "citealp*" ||
|
|
|
|
name == "citeauthor*" || name == "Citet" || name == "Citep" ||
|
|
|
|
name == "Citealt" || name == "Citealp" || name == "Citeauthor" ||
|
|
|
|
name == "Citet*" || name == "Citep*" || name == "Citealt*" ||
|
|
|
|
name == "Citealp*" || name == "Citeauthor*" ||
|
|
|
|
name == "citefield" || name == "citetitle" || name == "cite*") {
|
|
|
|
// standard cite does only take one argument if jurabib is
|
|
|
|
// not used, but jurabib extends this to two arguments, so
|
|
|
|
// we have to allow both here. InsetCitation takes care that
|
|
|
|
// LaTeX output is nevertheless correct.
|
|
|
|
static const char * const paramnames[] =
|
|
|
|
{"after", "before", "key", ""};
|
|
|
|
static const bool isoptional[] = {true, true, false};
|
|
|
|
static const CommandInfo info = {3, paramnames, isoptional};
|
|
|
|
return &info;
|
|
|
|
}
|
|
|
|
|
|
|
|
// InsetFloatlist
|
|
|
|
if (name == "floatlist") {
|
|
|
|
static const char * const paramnames[] = {"type", ""};
|
|
|
|
static const bool isoptional[] = {false};
|
|
|
|
static const CommandInfo info = {1, paramnames, isoptional};
|
|
|
|
return &info;
|
|
|
|
}
|
|
|
|
|
|
|
|
// InsetHfill
|
|
|
|
if (name == "hfill") {
|
|
|
|
static const char * const paramnames[] = {""};
|
|
|
|
static const CommandInfo info = {0, paramnames, 0};
|
|
|
|
return &info;
|
|
|
|
}
|
|
|
|
|
|
|
|
// InsetInclude
|
|
|
|
if (name == "include" || name == "input" || name == "verbatiminput" ||
|
|
|
|
name == "verbatiminput*") {
|
|
|
|
static const char * const paramnames[] = {"filename", ""};
|
|
|
|
static const bool isoptional[] = {false};
|
|
|
|
static const CommandInfo info = {1, paramnames, isoptional};
|
|
|
|
return &info;
|
|
|
|
}
|
|
|
|
|
|
|
|
// InsetIndex, InsetPrintIndex, InsetLabel
|
|
|
|
if (name == "index" || name == "printindex" || name == "label") {
|
|
|
|
static const char * const paramnames[] = {"name", ""};
|
|
|
|
static const bool isoptional[] = {false};
|
|
|
|
static const CommandInfo info = {1, paramnames, isoptional};
|
|
|
|
return &info;
|
|
|
|
}
|
|
|
|
|
2006-11-04 17:55:36 +00:00
|
|
|
// InsetNomencl
|
|
|
|
if (name == "nomenclature") {
|
|
|
|
static const char * const paramnames[] = {"prefix", "symbol", "description", ""};
|
|
|
|
static const bool isoptional[] = {true, false, false};
|
|
|
|
static const CommandInfo info = {3, paramnames, isoptional};
|
|
|
|
return &info;
|
|
|
|
}
|
|
|
|
|
|
|
|
// InsetPrintNomencl
|
|
|
|
if (name == "printnomenclature") {
|
|
|
|
static const char * const paramnames[] = {"labelwidth", ""};
|
|
|
|
static const bool isoptional[] = {true};
|
|
|
|
static const CommandInfo info = {1, paramnames, isoptional};
|
|
|
|
return &info;
|
|
|
|
}
|
|
|
|
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
// InsetRef
|
|
|
|
if (name == "eqref" || name == "pageref" || name == "vpageref" ||
|
|
|
|
name == "vref" || name == "prettyref" || name == "ref") {
|
|
|
|
static const char * const paramnames[] =
|
|
|
|
{"name", "reference", ""};
|
|
|
|
static const bool isoptional[] = {true, false};
|
|
|
|
static const CommandInfo info = {2, paramnames, isoptional};
|
|
|
|
return &info;
|
|
|
|
}
|
|
|
|
|
|
|
|
// InsetTOC
|
|
|
|
if (name == "tableofcontents") {
|
|
|
|
static const char * const paramnames[] = {"type", ""};
|
|
|
|
static const bool isoptional[] = {false};
|
|
|
|
static const CommandInfo info = {1, paramnames, isoptional};
|
|
|
|
return &info;
|
|
|
|
}
|
|
|
|
|
|
|
|
// InsetUrl
|
|
|
|
if (name == "htmlurl" || name == "url") {
|
|
|
|
static const char * const paramnames[] =
|
|
|
|
{"name", "target", ""};
|
|
|
|
static const bool isoptional[] = {true, false};
|
|
|
|
static const CommandInfo info = {2, paramnames, isoptional};
|
|
|
|
return &info;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2002-07-04 13:54:28 +00:00
|
|
|
|
|
|
|
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
void InsetCommandParams::setCmdName(string const & name)
|
|
|
|
{
|
|
|
|
name_ = name;
|
|
|
|
CommandInfo const * const info = findInfo(name);
|
|
|
|
BOOST_ASSERT(info);
|
|
|
|
ParamVector params(info->n);
|
|
|
|
// Overtake parameters with the same name
|
|
|
|
for (size_t i = 0; i < info_->n; ++i) {
|
|
|
|
int j = findToken(info->paramnames, info_->paramnames[i]);
|
|
|
|
if (j >= 0)
|
|
|
|
params[j] = params_[i];
|
|
|
|
}
|
|
|
|
info_ = info;
|
|
|
|
std::swap(params, params_);
|
|
|
|
}
|
2002-07-04 13:54:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
void InsetCommandParams::scanCommand(string const & cmd)
|
|
|
|
{
|
2004-03-05 14:49:10 +00:00
|
|
|
string tcmdname, toptions, tsecoptions, tcontents;
|
2002-07-04 13:54:28 +00:00
|
|
|
|
|
|
|
if (cmd.empty()) return;
|
2004-04-03 08:37:12 +00:00
|
|
|
|
2004-03-05 14:49:10 +00:00
|
|
|
enum { WS, CMDNAME, OPTION, SECOPTION, CONTENT } state = WS;
|
2002-07-04 13:54:28 +00:00
|
|
|
|
|
|
|
// Used to handle things like \command[foo[bar]]{foo{bar}}
|
|
|
|
int nestdepth = 0;
|
|
|
|
|
|
|
|
for (string::size_type i = 0; i < cmd.length(); ++i) {
|
2005-05-06 14:15:31 +00:00
|
|
|
char const c = cmd[i];
|
2002-07-04 13:54:28 +00:00
|
|
|
if ((state == CMDNAME && c == ' ') ||
|
|
|
|
(state == CMDNAME && c == '[') ||
|
|
|
|
(state == CMDNAME && c == '{')) {
|
|
|
|
state = WS;
|
|
|
|
}
|
|
|
|
if ((state == OPTION && c == ']') ||
|
2004-03-05 14:49:10 +00:00
|
|
|
(state == SECOPTION && c == ']') ||
|
2002-07-04 13:54:28 +00:00
|
|
|
(state == CONTENT && c == '}')) {
|
|
|
|
if (nestdepth == 0) {
|
|
|
|
state = WS;
|
|
|
|
} else {
|
|
|
|
--nestdepth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((state == OPTION && c == '[') ||
|
2004-03-05 14:49:10 +00:00
|
|
|
(state == SECOPTION && c == '[') ||
|
2002-07-04 13:54:28 +00:00
|
|
|
(state == CONTENT && c == '{')) {
|
|
|
|
++nestdepth;
|
|
|
|
}
|
|
|
|
switch (state) {
|
|
|
|
case CMDNAME: tcmdname += c; break;
|
|
|
|
case OPTION: toptions += c; break;
|
2004-03-05 14:49:10 +00:00
|
|
|
case SECOPTION: tsecoptions += c; break;
|
2002-07-04 13:54:28 +00:00
|
|
|
case CONTENT: tcontents += c; break;
|
2005-05-06 14:15:31 +00:00
|
|
|
case WS: {
|
|
|
|
char const b = i? cmd[i-1]: 0;
|
2002-07-04 13:54:28 +00:00
|
|
|
if (c == '\\') {
|
|
|
|
state = CMDNAME;
|
2004-03-05 14:49:10 +00:00
|
|
|
} else if (c == '[' && b != ']') {
|
2002-07-04 13:54:28 +00:00
|
|
|
state = OPTION;
|
|
|
|
nestdepth = 0; // Just to be sure
|
2004-03-05 14:49:10 +00:00
|
|
|
} else if (c == '[' && b == ']') {
|
|
|
|
state = SECOPTION;
|
|
|
|
nestdepth = 0; // Just to be sure
|
2002-07-04 13:54:28 +00:00
|
|
|
} else if (c == '{') {
|
|
|
|
state = CONTENT;
|
|
|
|
nestdepth = 0; // Just to be sure
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2005-05-06 14:15:31 +00:00
|
|
|
}
|
2002-07-04 13:54:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Don't mess with this.
|
|
|
|
if (!tcmdname.empty()) setCmdName(tcmdname);
|
|
|
|
if (!toptions.empty()) setOptions(toptions);
|
2004-03-05 14:49:10 +00:00
|
|
|
if (!tsecoptions.empty()) setSecOptions(tsecoptions);
|
2002-07-04 13:54:28 +00:00
|
|
|
if (!tcontents.empty()) setContents(tcontents);
|
|
|
|
|
|
|
|
if (lyxerr.debugging(Debug::PARSER))
|
|
|
|
lyxerr << "Command <" << cmd
|
2006-10-21 00:16:43 +00:00
|
|
|
<< "> == <" << to_utf8(getCommand())
|
2002-07-04 13:54:28 +00:00
|
|
|
<< "> == <" << getCmdName()
|
|
|
|
<< '|' << getContents()
|
2004-04-03 08:37:12 +00:00
|
|
|
<< '|' << getOptions()
|
2004-03-05 14:49:10 +00:00
|
|
|
<< '|' << getSecOptions() << '>' << endl;
|
2002-07-04 13:54:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetCommandParams::read(LyXLex & lex)
|
|
|
|
{
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
if (lex.isOK()) {
|
|
|
|
lex.next();
|
|
|
|
name_ = lex.getString();
|
|
|
|
info_ = findInfo(name_);
|
|
|
|
if (!info_)
|
|
|
|
lex.printError("InsetCommand: Unknown inset name `$$Token'");
|
2002-07-04 13:54:28 +00:00
|
|
|
}
|
|
|
|
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
string token;
|
2002-07-04 13:54:28 +00:00
|
|
|
while (lex.isOK()) {
|
2002-08-02 18:25:25 +00:00
|
|
|
lex.next();
|
2002-07-04 13:54:28 +00:00
|
|
|
token = lex.getString();
|
|
|
|
if (token == "\\end_inset")
|
|
|
|
break;
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
// FIXME Why is preview_ read but not written?
|
2002-08-02 18:25:25 +00:00
|
|
|
if (token == "preview") {
|
|
|
|
lex.next();
|
|
|
|
preview_ = lex.getBool();
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
continue;
|
2002-08-02 18:25:25 +00:00
|
|
|
}
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
int const i = findToken(info_->paramnames, token);
|
|
|
|
if (i >= 0) {
|
|
|
|
lex.next(true);
|
|
|
|
params_[i] = lex.getDocString();
|
|
|
|
} else
|
|
|
|
lex.printError("Unknown parameter name `$$Token' for command " + name_);
|
2002-07-04 13:54:28 +00:00
|
|
|
}
|
|
|
|
if (token != "\\end_inset") {
|
|
|
|
lex.printError("Missing \\end_inset at this point. "
|
|
|
|
"Read: `$$Token'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetCommandParams::write(ostream & os) const
|
|
|
|
{
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
os << "LatexCommand " << name_ << '\n';
|
|
|
|
for (size_t i = 0; i < info_->n; ++i)
|
|
|
|
if (!params_[i].empty())
|
|
|
|
// FIXME UNICODE
|
|
|
|
os << info_->paramnames[i] << ' '
|
2006-10-21 00:16:43 +00:00
|
|
|
<< LyXLex::quoteString(to_utf8(params_[i]))
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
<< '\n';
|
2002-07-04 13:54:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
docstring const InsetCommandParams::getCommand() const
|
2002-07-04 13:54:28 +00:00
|
|
|
{
|
2006-10-21 00:16:43 +00:00
|
|
|
docstring s = '\\' + from_ascii(name_);
|
2006-11-04 17:55:36 +00:00
|
|
|
bool noparam = true;
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
for (size_t i = 0; i < info_->n; ++i) {
|
|
|
|
if (info_->optional[i]) {
|
|
|
|
if (params_[i].empty()) {
|
|
|
|
// We need to write this parameter even if
|
|
|
|
// it is empty if nonempty optional parameters
|
|
|
|
// follow before the next required parameter.
|
|
|
|
for (size_t j = i + 1; j < info_->n; ++j) {
|
|
|
|
if (!info_->optional[j])
|
|
|
|
break;
|
|
|
|
if (!params_[j].empty()) {
|
|
|
|
s += "[]";
|
2006-11-04 17:55:36 +00:00
|
|
|
noparam = false;
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-11-04 17:55:36 +00:00
|
|
|
} else {
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
s += '[' + params_[i] + ']';
|
2006-11-04 17:55:36 +00:00
|
|
|
noparam = false;
|
|
|
|
}
|
|
|
|
} else {
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
s += '{' + params_[i] + '}';
|
2006-11-04 17:55:36 +00:00
|
|
|
noparam = false;
|
|
|
|
}
|
2004-03-05 14:49:10 +00:00
|
|
|
}
|
2006-11-04 17:55:36 +00:00
|
|
|
if (noparam)
|
2006-11-04 14:55:15 +00:00
|
|
|
// Make sure that following stuff does not change the
|
|
|
|
// command name.
|
|
|
|
s += "{}";
|
2006-10-19 16:51:30 +00:00
|
|
|
return s;
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string const InsetCommandParams::getOptions() const
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < info_->n; ++i)
|
|
|
|
if (info_->optional[i])
|
2006-10-21 00:16:43 +00:00
|
|
|
return to_utf8(params_[i]);
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
lyxerr << "Programming error: get nonexisting option in "
|
|
|
|
<< name_ << " inset." << endl;;
|
|
|
|
return string();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string const InsetCommandParams::getSecOptions() const
|
|
|
|
{
|
|
|
|
bool first = true;
|
|
|
|
for (size_t i = 0; i < info_->n; ++i)
|
|
|
|
if (info_->optional[i]) {
|
|
|
|
if (first)
|
|
|
|
first = false;
|
|
|
|
else
|
2006-10-21 00:16:43 +00:00
|
|
|
return to_utf8(params_[i]);
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
}
|
|
|
|
// Happens in InsetCitation
|
|
|
|
lyxerr << "Programming error: get nonexisting second option in "
|
|
|
|
<< name_ << " inset." << endl;;
|
|
|
|
return string();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string const InsetCommandParams::getContents() const
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < info_->n; ++i)
|
|
|
|
if (!info_->optional[i])
|
2006-10-21 00:16:43 +00:00
|
|
|
return to_utf8(params_[i]);
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
BOOST_ASSERT(false);
|
|
|
|
return string();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetCommandParams::setOptions(std::string const & o)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < info_->n; ++i)
|
|
|
|
if (info_->optional[i]) {
|
2006-10-21 00:16:43 +00:00
|
|
|
params_[i] = from_utf8(o);
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
lyxerr << "Programming error: set nonexisting option in "
|
|
|
|
<< name_ << " inset." << endl;;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetCommandParams::setSecOptions(std::string const & s)
|
|
|
|
{
|
|
|
|
bool first = true;
|
|
|
|
for (size_t i = 0; i < info_->n; ++i)
|
|
|
|
if (info_->optional[i]) {
|
|
|
|
if (first)
|
|
|
|
first = false;
|
|
|
|
else {
|
2006-10-21 00:16:43 +00:00
|
|
|
params_[i] = from_utf8(s);
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Happens in InsetCitation
|
|
|
|
lyxerr << "Programming error: set nonexisting second option in "
|
|
|
|
<< name_ << " inset." << endl;;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetCommandParams::setContents(std::string const & c)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < info_->n; ++i)
|
|
|
|
if (!info_->optional[i]) {
|
2006-10-21 00:16:43 +00:00
|
|
|
params_[i] = from_utf8(c);
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
BOOST_ASSERT(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
docstring const & InsetCommandParams::operator[](string const & name) const
|
|
|
|
{
|
|
|
|
int const i = findToken(info_->paramnames, name);
|
|
|
|
BOOST_ASSERT(i >= 0);
|
|
|
|
return params_[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
docstring & InsetCommandParams::operator[](string const & name)
|
|
|
|
{
|
|
|
|
int const i = findToken(info_->paramnames, name);
|
|
|
|
BOOST_ASSERT(i >= 0);
|
|
|
|
return params_[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetCommandParams::clear()
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < info_->n; ++i)
|
|
|
|
params_[i].clear();
|
2002-07-04 13:54:28 +00:00
|
|
|
}
|
|
|
|
|
2002-07-04 17:45:35 +00:00
|
|
|
|
|
|
|
bool operator==(InsetCommandParams const & o1,
|
|
|
|
InsetCommandParams const & o2)
|
|
|
|
{
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
return o1.name_ == o2.name_ &&
|
|
|
|
o1.info_ == o2.info_ &&
|
|
|
|
o1.params_ == o2.params_ &&
|
|
|
|
o1.preview_ == o2.preview_;
|
2002-07-04 17:45:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool operator!=(InsetCommandParams const & o1,
|
|
|
|
InsetCommandParams const & o2)
|
|
|
|
{
|
|
|
|
return !(o1 == o2);
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|