2002-09-25 14:26:13 +00:00
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
* \file InsetCommandParams.cpp
|
2002-09-25 14:26:13 +00:00
|
|
|
* 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
|
2007-10-25 04:13:56 +00:00
|
|
|
* \author Richard Heck
|
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>
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "InsetCommandParams.h"
|
2002-07-04 13:54:28 +00:00
|
|
|
|
2007-10-25 04:13:56 +00:00
|
|
|
#include "InsetBibitem.h"
|
|
|
|
#include "InsetBibtex.h"
|
|
|
|
#include "InsetCitation.h"
|
|
|
|
#include "InsetFloatList.h"
|
|
|
|
#include "InsetHFill.h"
|
|
|
|
#include "InsetHyperlink.h"
|
|
|
|
#include "InsetInclude.h"
|
|
|
|
#include "InsetIndex.h"
|
|
|
|
#include "InsetLabel.h"
|
|
|
|
#include "InsetNomencl.h"
|
|
|
|
#include "InsetRef.h"
|
|
|
|
#include "InsetTOC.h"
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
#include "Lexer.h"
|
2002-07-04 17:45:35 +00:00
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/debug.h"
|
2007-04-18 12:59:07 +00:00
|
|
|
#include "support/ExceptionMessage.h"
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/gettext.h"
|
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"
|
2007-11-28 22:12:03 +00:00
|
|
|
#include "support/docstream.h"
|
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 <boost/assert.hpp>
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2007-12-12 18:57:56 +00:00
|
|
|
using namespace lyx::support;
|
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
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2002-07-04 13:54:28 +00:00
|
|
|
|
2007-10-19 17:22:55 +00:00
|
|
|
InsetCommandParams::InsetCommandParams(InsetCode code)
|
|
|
|
: insetCode_(code), preview_(false)
|
2007-09-27 18:24:18 +00:00
|
|
|
{
|
2007-10-19 17:22:55 +00:00
|
|
|
cmdName_ = getDefaultCmd(code);
|
|
|
|
info_ = findInfo(code, cmdName_);
|
2007-09-27 18:24:18 +00:00
|
|
|
BOOST_ASSERT(info_);
|
|
|
|
params_.resize(info_->n);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-19 17:22:55 +00:00
|
|
|
InsetCommandParams::InsetCommandParams(InsetCode code,
|
2007-09-27 18:24:18 +00:00
|
|
|
string const & cmdName)
|
2007-10-19 17:22:55 +00:00
|
|
|
: insetCode_(code), cmdName_(cmdName), preview_(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
|
|
|
{
|
2007-10-19 17:22:55 +00:00
|
|
|
info_ = findInfo(code, cmdName);
|
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(info_);
|
|
|
|
params_.resize(info_->n);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-25 04:13:56 +00:00
|
|
|
CommandInfo const * InsetCommandParams::findInfo(
|
2007-12-12 19:28:07 +00:00
|
|
|
InsetCode code, string const & cmdName)
|
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
|
|
|
{
|
2007-10-19 17:22:55 +00:00
|
|
|
switch (code) {
|
2007-10-25 04:13:56 +00:00
|
|
|
case BIBITEM_CODE:
|
|
|
|
return InsetBibitem::findInfo(cmdName);
|
|
|
|
case BIBTEX_CODE:
|
|
|
|
return InsetBibtex::findInfo(cmdName);
|
|
|
|
case CITE_CODE:
|
|
|
|
return InsetCitation::findInfo(cmdName);
|
|
|
|
case FLOAT_LIST_CODE:
|
|
|
|
return InsetFloatList::findInfo(cmdName);
|
|
|
|
case HFILL_CODE:
|
|
|
|
return InsetHFill::findInfo(cmdName);
|
|
|
|
case HYPERLINK_CODE:
|
|
|
|
return InsetHyperlink::findInfo(cmdName);
|
|
|
|
case INCLUDE_CODE:
|
|
|
|
return InsetInclude::findInfo(cmdName);
|
2007-10-19 17:22:55 +00:00
|
|
|
case INDEX_PRINT_CODE:
|
2007-10-25 04:13:56 +00:00
|
|
|
return InsetPrintIndex::findInfo(cmdName);
|
|
|
|
case LABEL_CODE:
|
|
|
|
return InsetLabel::findInfo(cmdName);
|
|
|
|
case NOMENCL_CODE:
|
|
|
|
return InsetNomencl::findInfo(cmdName);
|
|
|
|
case NOMENCL_PRINT_CODE:
|
|
|
|
return InsetPrintNomencl::findInfo(cmdName);
|
|
|
|
case REF_CODE:
|
|
|
|
return InsetRef::findInfo(cmdName);
|
|
|
|
case TOC_CODE:
|
|
|
|
return InsetTOC::findInfo(cmdName);
|
2007-10-19 17:22:55 +00:00
|
|
|
default:
|
|
|
|
BOOST_ASSERT(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
|
|
|
return 0;
|
|
|
|
}
|
2002-07-04 13:54:28 +00:00
|
|
|
|
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
string InsetCommandParams::getDefaultCmd(InsetCode code) {
|
2007-10-25 04:13:56 +00:00
|
|
|
switch (code) {
|
|
|
|
case BIBITEM_CODE:
|
|
|
|
return InsetBibitem::defaultCommand();
|
|
|
|
case BIBTEX_CODE:
|
|
|
|
return InsetBibtex::defaultCommand();
|
|
|
|
case CITE_CODE:
|
|
|
|
return InsetCitation::defaultCommand();
|
|
|
|
case FLOAT_LIST_CODE:
|
|
|
|
return InsetFloatList::defaultCommand();
|
|
|
|
case HFILL_CODE:
|
|
|
|
return InsetHFill::defaultCommand();
|
|
|
|
case HYPERLINK_CODE:
|
|
|
|
return InsetHyperlink::defaultCommand();
|
|
|
|
case INCLUDE_CODE:
|
|
|
|
return InsetInclude::defaultCommand();
|
|
|
|
case INDEX_PRINT_CODE:
|
|
|
|
return InsetPrintIndex::defaultCommand();
|
|
|
|
case LABEL_CODE:
|
|
|
|
return InsetLabel::defaultCommand();
|
|
|
|
case NOMENCL_CODE:
|
|
|
|
return InsetNomencl::defaultCommand();
|
|
|
|
case NOMENCL_PRINT_CODE:
|
|
|
|
return InsetPrintNomencl::defaultCommand();
|
|
|
|
case REF_CODE:
|
|
|
|
return InsetRef::defaultCommand();
|
|
|
|
case TOC_CODE:
|
|
|
|
return InsetTOC::defaultCommand();
|
|
|
|
default:
|
|
|
|
BOOST_ASSERT(false);
|
|
|
|
}
|
|
|
|
return string(); //silence the warning
|
2007-09-27 18:24:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-25 04:13:56 +00:00
|
|
|
bool InsetCommandParams::isCompatibleCommand(
|
2007-12-12 19:28:07 +00:00
|
|
|
InsetCode code, string const & s)
|
2007-10-25 04:13:56 +00:00
|
|
|
{
|
2007-10-19 17:22:55 +00:00
|
|
|
switch (code) {
|
|
|
|
case BIBITEM_CODE:
|
2007-10-25 04:13:56 +00:00
|
|
|
return InsetBibitem::isCompatibleCommand(s);
|
2007-10-19 17:22:55 +00:00
|
|
|
case BIBTEX_CODE:
|
2007-10-25 04:13:56 +00:00
|
|
|
return InsetBibtex::isCompatibleCommand(s);
|
2007-10-19 17:22:55 +00:00
|
|
|
case CITE_CODE:
|
2007-10-25 04:13:56 +00:00
|
|
|
return InsetCitation::isCompatibleCommand(s);
|
2007-10-19 17:22:55 +00:00
|
|
|
case FLOAT_LIST_CODE:
|
2007-10-25 04:13:56 +00:00
|
|
|
return InsetFloatList::isCompatibleCommand(s);
|
2007-10-19 17:22:55 +00:00
|
|
|
case HFILL_CODE:
|
2007-10-25 04:13:56 +00:00
|
|
|
return InsetHFill::isCompatibleCommand(s);
|
2007-10-19 17:22:55 +00:00
|
|
|
case HYPERLINK_CODE:
|
2007-10-25 04:13:56 +00:00
|
|
|
return InsetHyperlink::isCompatibleCommand(s);
|
2007-10-19 17:22:55 +00:00
|
|
|
case INCLUDE_CODE:
|
2007-10-25 04:13:56 +00:00
|
|
|
return InsetInclude::isCompatibleCommand(s);
|
2007-10-19 17:22:55 +00:00
|
|
|
case INDEX_PRINT_CODE:
|
2007-10-25 04:13:56 +00:00
|
|
|
return InsetPrintIndex::isCompatibleCommand(s);
|
2007-10-19 17:22:55 +00:00
|
|
|
case LABEL_CODE:
|
2007-10-25 04:13:56 +00:00
|
|
|
return InsetLabel::isCompatibleCommand(s);
|
2007-10-19 17:22:55 +00:00
|
|
|
case NOMENCL_CODE:
|
2007-10-25 04:13:56 +00:00
|
|
|
return InsetNomencl::isCompatibleCommand(s);
|
2007-10-19 17:22:55 +00:00
|
|
|
case NOMENCL_PRINT_CODE:
|
2007-10-25 04:13:56 +00:00
|
|
|
return InsetPrintNomencl::isCompatibleCommand(s);
|
2007-10-19 17:22:55 +00:00
|
|
|
case REF_CODE:
|
2007-10-25 04:13:56 +00:00
|
|
|
return InsetRef::isCompatibleCommand(s);
|
2007-10-19 17:22:55 +00:00
|
|
|
case TOC_CODE:
|
2007-10-25 04:13:56 +00:00
|
|
|
return InsetTOC::isCompatibleCommand(s);
|
2007-10-19 17:22:55 +00:00
|
|
|
default:
|
|
|
|
BOOST_ASSERT(false);
|
|
|
|
}
|
2007-10-25 04:13:56 +00:00
|
|
|
return false; //silence the warning
|
2007-09-27 18:24:18 +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)
|
|
|
|
{
|
2007-10-25 04:13:56 +00:00
|
|
|
if (!isCompatibleCommand(insetCode_, cmdName_)){
|
2007-11-28 22:12:03 +00:00
|
|
|
LYXERR0("InsetCommand: Incompatible command name " <<
|
|
|
|
name << ".");
|
2007-10-25 04:13:56 +00:00
|
|
|
throw ExceptionMessage(WarningException, _("InsetCommand Error: "),
|
2008-02-12 16:41:49 +00:00
|
|
|
_("Incompatible command name."));
|
2007-10-25 04:13:56 +00:00
|
|
|
}
|
|
|
|
|
2007-09-27 18:24:18 +00:00
|
|
|
cmdName_ = name;
|
2007-10-19 17:22:55 +00:00
|
|
|
CommandInfo const * const info = findInfo(insetCode_, cmdName_);
|
|
|
|
if (!info) {
|
2007-11-28 22:12:03 +00:00
|
|
|
LYXERR0("Command '" << name << "' is not compatible with a '" <<
|
|
|
|
insetType() << "' inset.");
|
2007-10-19 17:22:55 +00:00
|
|
|
return;
|
|
|
|
}
|
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
|
|
|
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;
|
2007-12-12 19:28:07 +00:00
|
|
|
swap(params, params_);
|
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
|
|
|
}
|
2002-07-04 13:54:28 +00:00
|
|
|
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
void InsetCommandParams::read(Lexer & lex)
|
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
|
|
|
if (lex.isOK()) {
|
|
|
|
lex.next();
|
2007-10-19 17:22:55 +00:00
|
|
|
string const insetType = lex.getString();
|
|
|
|
InsetCode const code = insetCode(insetType);
|
|
|
|
if (code != insetCode_) {
|
2008-02-11 19:42:36 +00:00
|
|
|
lex.printError("InsetCommandParams: Attempt to change type of inset.");
|
|
|
|
throw ExceptionMessage(WarningException, _("InsetCommandParams Error: "),
|
2008-02-12 16:41:49 +00:00
|
|
|
_("Attempt to change type of parameters."));
|
2007-04-18 12:59:07 +00:00
|
|
|
}
|
2002-07-04 13:54:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-27 18:24:18 +00:00
|
|
|
if (lex.isOK()) {
|
|
|
|
lex.next();
|
2007-10-19 17:22:55 +00:00
|
|
|
string const test = lex.getString();
|
2007-09-27 18:24:18 +00:00
|
|
|
if (test != "LatexCommand") {
|
2008-02-11 19:42:36 +00:00
|
|
|
lex.printError("InsetCommandParams: No LatexCommand line found.");
|
|
|
|
throw ExceptionMessage(WarningException, _("InsetCommandParams error:"),
|
2008-02-12 16:41:49 +00:00
|
|
|
_("Can't find LatexCommand line."));
|
2007-09-27 18:24:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
lex.next();
|
|
|
|
cmdName_ = lex.getString();
|
2007-10-25 04:13:56 +00:00
|
|
|
if (!isCompatibleCommand(insetCode_, cmdName_)){
|
2008-02-11 19:42:36 +00:00
|
|
|
lex.printError("InsetCommandParams: Incompatible command name " + cmdName_ + ".");
|
|
|
|
throw ExceptionMessage(WarningException, _("InsetCommandParams Error: "),
|
2008-02-12 16:41:49 +00:00
|
|
|
_("Incompatible command name."));
|
2007-10-25 04:13:56 +00:00
|
|
|
}
|
|
|
|
|
2007-10-19 17:22:55 +00:00
|
|
|
info_ = findInfo(insetCode_, cmdName_);
|
2007-09-27 18:24:18 +00:00
|
|
|
if (!info_) {
|
2008-02-11 19:42:36 +00:00
|
|
|
lex.printError("InsetCommandParams: Unknown inset name `$$Token'");
|
2007-09-27 18:24:18 +00:00
|
|
|
throw ExceptionMessage(WarningException,
|
2008-02-12 16:41:49 +00:00
|
|
|
_("Unknown inset name: "), from_utf8(insetType()));
|
2007-09-27 18:24:18 +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;
|
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();
|
2007-04-18 12:59:07 +00:00
|
|
|
} else {
|
2007-09-27 18:24:18 +00:00
|
|
|
lex.printError("Unknown parameter name `$$Token' for command " + cmdName_);
|
2007-04-18 12:59:07 +00:00
|
|
|
throw ExceptionMessage(WarningException,
|
2008-02-11 19:42:36 +00:00
|
|
|
_("InsetCommandParams: ") + from_ascii(cmdName_),
|
2007-04-18 12:59:07 +00:00
|
|
|
_("Unknown parameter name: ") + from_utf8(token));
|
|
|
|
}
|
2002-07-04 13:54:28 +00:00
|
|
|
}
|
|
|
|
if (token != "\\end_inset") {
|
|
|
|
lex.printError("Missing \\end_inset at this point. "
|
|
|
|
"Read: `$$Token'");
|
2007-04-18 12:59:07 +00:00
|
|
|
throw ExceptionMessage(WarningException,
|
|
|
|
_("Missing \\end_inset at this point."),
|
|
|
|
from_utf8(token));
|
2002-07-04 13:54:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
void InsetCommandParams::write(ostream & os) const
|
2002-07-04 13:54:28 +00:00
|
|
|
{
|
2007-10-19 17:22:55 +00:00
|
|
|
os << "CommandInset " << insetType() << '\n';
|
2007-09-27 18:24:18 +00:00
|
|
|
os << "LatexCommand " << cmdName_ << '\n';
|
2007-10-23 18:51:04 +00:00
|
|
|
if (preview_)
|
|
|
|
os << "preview true\n";
|
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 (!params_[i].empty())
|
|
|
|
// FIXME UNICODE
|
|
|
|
os << info_->paramnames[i] << ' '
|
2007-04-26 11:30:54 +00:00
|
|
|
<< Lexer::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
|
|
|
{
|
2007-09-27 18:24:18 +00:00
|
|
|
docstring s = '\\' + from_ascii(cmdName_);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-23 18:51:04 +00:00
|
|
|
docstring const InsetCommandParams::getFirstNonOptParam() 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
|
|
|
{
|
|
|
|
for (size_t i = 0; i < info_->n; ++i)
|
|
|
|
if (!info_->optional[i])
|
2007-10-23 18:51:04 +00:00
|
|
|
return 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);
|
2007-10-23 18:51:04 +00:00
|
|
|
return docstring();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2007-10-19 17:22:55 +00:00
|
|
|
return o1.insetCode_ == o2.insetCode_ &&
|
2007-09-27 18:24:18 +00:00
|
|
|
o1.cmdName_ == o2.cmdName_ &&
|
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
|
|
|
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
|