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>
|
2008-03-17 21:11:17 +00:00
|
|
|
#include <algorithm>
|
2015-12-10 00:15:16 +00:00
|
|
|
#include <functional>
|
|
|
|
|
2002-11-04 00:15:56 +00:00
|
|
|
|
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 "InsetHyperlink.h"
|
|
|
|
#include "InsetInclude.h"
|
|
|
|
#include "InsetIndex.h"
|
|
|
|
#include "InsetLabel.h"
|
2010-09-07 00:41:00 +00:00
|
|
|
#include "InsetLine.h"
|
2007-10-25 04:13:56 +00:00
|
|
|
#include "InsetNomencl.h"
|
|
|
|
#include "InsetRef.h"
|
|
|
|
#include "InsetTOC.h"
|
|
|
|
|
2015-05-03 21:55:19 +00:00
|
|
|
#include "Buffer.h"
|
2010-02-13 13:08:32 +00:00
|
|
|
#include "Encoding.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
#include "Lexer.h"
|
2010-02-13 13:08:32 +00:00
|
|
|
#include "OutputParams.h"
|
|
|
|
|
|
|
|
#include "frontends/alert.h"
|
2002-07-04 17:45:35 +00:00
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/debug.h"
|
Per Abdel's suggestion that we focus on bug-fixing at this point, this will be the last patch in this series for a bit. But I wanted to get this done before I forget what it is I was doing, so here it is.
The idea behind this patch is to make real key-value support for InsetCommand parameters possible. This should be particularly useful for the listings version of InsetInclude, though we would need some kind of UI for it before it would really be helpful. (See below for some thoughts.) This doesn't substantially change anything else, though some things do get re-arranged a bit.
Basically, the idea is this. First, we introduce a whole range of parameter types: Normal LaTeX optional and required parameters; ones for LyX's internal use (like embed); and finally, in connection with keyval, ones that represent keys and ones that represent optional and required arguments where the keyval stuff will appear. (I'm assuming here that there will always be exactly one of those, and that it will accept only keyval-type material.) The parameters themselves are stored in a map, so it's really only the output routines that need to care about the different types of parameters.
Regarding the frontend, it seems to me that something like the following would work:
(i) scan the parameter list for LATEX_KEY type parameters
(ii) the dialog will have a series of lines, each of which has a combo box listing the acceptable keys and a QLineEdit for entering its value, as well as a "delete" button of some sort for removing this key and its value
(iii) there should be an "add line" button to add a new line, activated only when all other lines are filled with values
Probably not even too hard.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23235 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-25 22:13:45 +00:00
|
|
|
#include "support/docstream.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"
|
|
|
|
|
2008-04-30 08:26:40 +00:00
|
|
|
#include "support/lassert.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
|
|
|
|
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
|
|
|
|
2008-03-15 00:02:41 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2008-04-02 19:12:47 +00:00
|
|
|
/// Get information for \p code and command \p cmdName.
|
|
|
|
/// Don't call this without first making sure the command name is
|
|
|
|
/// acceptable to the inset.
|
|
|
|
static ParamInfo const & findInfo(InsetCode code, string const & cmdName)
|
|
|
|
{
|
|
|
|
switch (code) {
|
|
|
|
case BIBITEM_CODE:
|
|
|
|
return InsetBibitem::findInfo(cmdName);
|
|
|
|
case BIBTEX_CODE:
|
|
|
|
return InsetBibtex::findInfo(cmdName);
|
|
|
|
case CITE_CODE:
|
2009-04-17 14:29:32 +00:00
|
|
|
return InsetCitation::findInfo(cmdName);
|
2008-04-02 19:12:47 +00:00
|
|
|
case FLOAT_LIST_CODE:
|
|
|
|
return InsetFloatList::findInfo(cmdName);
|
|
|
|
case HYPERLINK_CODE:
|
|
|
|
return InsetHyperlink::findInfo(cmdName);
|
|
|
|
case INCLUDE_CODE:
|
|
|
|
return InsetInclude::findInfo(cmdName);
|
|
|
|
case INDEX_PRINT_CODE:
|
|
|
|
return InsetPrintIndex::findInfo(cmdName);
|
|
|
|
case LABEL_CODE:
|
2009-04-17 14:29:32 +00:00
|
|
|
return InsetLabel::findInfo(cmdName);
|
2010-09-07 00:41:00 +00:00
|
|
|
case LINE_CODE:
|
|
|
|
return InsetLine::findInfo(cmdName);
|
2008-04-02 19:12:47 +00:00
|
|
|
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);
|
|
|
|
default:
|
2013-04-25 21:27:10 +00:00
|
|
|
LATTEST(false);
|
|
|
|
// fall through in release mode
|
2008-04-02 19:12:47 +00:00
|
|
|
}
|
2013-04-25 21:27:10 +00:00
|
|
|
static const ParamInfo pi;
|
|
|
|
return pi;
|
2008-04-02 19:12:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-15 00:02:41 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// ParamInfo::ParamData
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-02-13 13:08:32 +00:00
|
|
|
ParamInfo::ParamData::ParamData(std::string const & s, ParamType t,
|
|
|
|
ParamHandling h)
|
|
|
|
: name_(s), type_(t), handling_(h)
|
2008-02-23 22:01:02 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
Per Abdel's suggestion that we focus on bug-fixing at this point, this will be the last patch in this series for a bit. But I wanted to get this done before I forget what it is I was doing, so here it is.
The idea behind this patch is to make real key-value support for InsetCommand parameters possible. This should be particularly useful for the listings version of InsetInclude, though we would need some kind of UI for it before it would really be helpful. (See below for some thoughts.) This doesn't substantially change anything else, though some things do get re-arranged a bit.
Basically, the idea is this. First, we introduce a whole range of parameter types: Normal LaTeX optional and required parameters; ones for LyX's internal use (like embed); and finally, in connection with keyval, ones that represent keys and ones that represent optional and required arguments where the keyval stuff will appear. (I'm assuming here that there will always be exactly one of those, and that it will accept only keyval-type material.) The parameters themselves are stored in a map, so it's really only the output routines that need to care about the different types of parameters.
Regarding the frontend, it seems to me that something like the following would work:
(i) scan the parameter list for LATEX_KEY type parameters
(ii) the dialog will have a series of lines, each of which has a combo box listing the acceptable keys and a QLineEdit for entering its value, as well as a "delete" button of some sort for removing this key and its value
(iii) there should be an "add line" button to add a new line, activated only when all other lines are filled with values
Probably not even too hard.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23235 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-25 22:13:45 +00:00
|
|
|
bool ParamInfo::ParamData::isOptional() const
|
|
|
|
{
|
2008-04-02 19:12:47 +00:00
|
|
|
return type_ == ParamInfo::LATEX_OPTIONAL;
|
Per Abdel's suggestion that we focus on bug-fixing at this point, this will be the last patch in this series for a bit. But I wanted to get this done before I forget what it is I was doing, so here it is.
The idea behind this patch is to make real key-value support for InsetCommand parameters possible. This should be particularly useful for the listings version of InsetInclude, though we would need some kind of UI for it before it would really be helpful. (See below for some thoughts.) This doesn't substantially change anything else, though some things do get re-arranged a bit.
Basically, the idea is this. First, we introduce a whole range of parameter types: Normal LaTeX optional and required parameters; ones for LyX's internal use (like embed); and finally, in connection with keyval, ones that represent keys and ones that represent optional and required arguments where the keyval stuff will appear. (I'm assuming here that there will always be exactly one of those, and that it will accept only keyval-type material.) The parameters themselves are stored in a map, so it's really only the output routines that need to care about the different types of parameters.
Regarding the frontend, it seems to me that something like the following would work:
(i) scan the parameter list for LATEX_KEY type parameters
(ii) the dialog will have a series of lines, each of which has a combo box listing the acceptable keys and a QLineEdit for entering its value, as well as a "delete" button of some sort for removing this key and its value
(iii) there should be an "add line" button to add a new line, activated only when all other lines are filled with values
Probably not even too hard.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23235 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-25 22:13:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-23 22:01:02 +00:00
|
|
|
bool ParamInfo::ParamData::operator==(ParamInfo::ParamData const & rhs) const
|
|
|
|
{
|
2010-02-13 13:08:32 +00:00
|
|
|
return name() == rhs.name() && type() == rhs.type()
|
|
|
|
&& handling() == rhs.handling();
|
2008-02-23 22:01:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ParamInfo::hasParam(std::string const & name) const
|
|
|
|
{
|
|
|
|
const_iterator it = begin();
|
Per Abdel's suggestion that we focus on bug-fixing at this point, this will be the last patch in this series for a bit. But I wanted to get this done before I forget what it is I was doing, so here it is.
The idea behind this patch is to make real key-value support for InsetCommand parameters possible. This should be particularly useful for the listings version of InsetInclude, though we would need some kind of UI for it before it would really be helpful. (See below for some thoughts.) This doesn't substantially change anything else, though some things do get re-arranged a bit.
Basically, the idea is this. First, we introduce a whole range of parameter types: Normal LaTeX optional and required parameters; ones for LyX's internal use (like embed); and finally, in connection with keyval, ones that represent keys and ones that represent optional and required arguments where the keyval stuff will appear. (I'm assuming here that there will always be exactly one of those, and that it will accept only keyval-type material.) The parameters themselves are stored in a map, so it's really only the output routines that need to care about the different types of parameters.
Regarding the frontend, it seems to me that something like the following would work:
(i) scan the parameter list for LATEX_KEY type parameters
(ii) the dialog will have a series of lines, each of which has a combo box listing the acceptable keys and a QLineEdit for entering its value, as well as a "delete" button of some sort for removing this key and its value
(iii) there should be an "add line" button to add a new line, activated only when all other lines are filled with values
Probably not even too hard.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23235 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-25 22:13:45 +00:00
|
|
|
const_iterator last = end();
|
|
|
|
for (; it != last; ++it) {
|
2008-02-23 22:01:02 +00:00
|
|
|
if (it->name() == name)
|
2008-04-02 19:12:47 +00:00
|
|
|
return true;
|
2008-02-23 22:01:02 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-13 13:08:32 +00:00
|
|
|
void ParamInfo::add(std::string const & name, ParamType type,
|
|
|
|
ParamHandling handling)
|
2008-02-23 22:01:02 +00:00
|
|
|
{
|
2010-02-13 13:08:32 +00:00
|
|
|
info_.push_back(ParamData(name, type, handling));
|
2008-02-23 22:01:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ParamInfo::operator==(ParamInfo const & rhs) const
|
|
|
|
{
|
Per Abdel's suggestion that we focus on bug-fixing at this point, this will be the last patch in this series for a bit. But I wanted to get this done before I forget what it is I was doing, so here it is.
The idea behind this patch is to make real key-value support for InsetCommand parameters possible. This should be particularly useful for the listings version of InsetInclude, though we would need some kind of UI for it before it would really be helpful. (See below for some thoughts.) This doesn't substantially change anything else, though some things do get re-arranged a bit.
Basically, the idea is this. First, we introduce a whole range of parameter types: Normal LaTeX optional and required parameters; ones for LyX's internal use (like embed); and finally, in connection with keyval, ones that represent keys and ones that represent optional and required arguments where the keyval stuff will appear. (I'm assuming here that there will always be exactly one of those, and that it will accept only keyval-type material.) The parameters themselves are stored in a map, so it's really only the output routines that need to care about the different types of parameters.
Regarding the frontend, it seems to me that something like the following would work:
(i) scan the parameter list for LATEX_KEY type parameters
(ii) the dialog will have a series of lines, each of which has a combo box listing the acceptable keys and a QLineEdit for entering its value, as well as a "delete" button of some sort for removing this key and its value
(iii) there should be an "add line" button to add a new line, activated only when all other lines are filled with values
Probably not even too hard.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23235 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-25 22:13:45 +00:00
|
|
|
if (size() != rhs.size())
|
|
|
|
return false;
|
|
|
|
return equal(begin(), end(), rhs.begin());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ParamInfo::ParamData const &
|
|
|
|
ParamInfo::operator[](std::string const & name) const
|
|
|
|
{
|
|
|
|
const_iterator it = begin();
|
|
|
|
const_iterator last = end();
|
|
|
|
for (; it != last; ++it) {
|
|
|
|
if (it->name() == name)
|
|
|
|
return *it;
|
2008-02-23 22:01:02 +00:00
|
|
|
}
|
2013-04-25 21:27:10 +00:00
|
|
|
LATTEST(false);
|
|
|
|
// we will try to continue in release mode
|
|
|
|
static const ParamData pd("asdfghjkl", LYX_INTERNAL);
|
|
|
|
return pd;
|
2008-02-23 22:01:02 +00:00
|
|
|
}
|
|
|
|
|
2002-07-04 13:54:28 +00:00
|
|
|
|
2008-03-15 00:02:41 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// InsetCommandParams
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-15 00:02:41 +00:00
|
|
|
std::string InsetCommandParams::insetType() const
|
|
|
|
{
|
|
|
|
return insetName(insetCode_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-02 19:12:47 +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 HYPERLINK_CODE:
|
|
|
|
return InsetHyperlink::defaultCommand();
|
|
|
|
case INCLUDE_CODE:
|
|
|
|
return InsetInclude::defaultCommand();
|
|
|
|
case INDEX_PRINT_CODE:
|
|
|
|
return InsetPrintIndex::defaultCommand();
|
|
|
|
case LABEL_CODE:
|
|
|
|
return InsetLabel::defaultCommand();
|
2010-09-07 00:41:00 +00:00
|
|
|
case LINE_CODE:
|
|
|
|
return InsetLine::defaultCommand();
|
2007-10-25 04:13:56 +00:00
|
|
|
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:
|
2013-04-25 21:27:10 +00:00
|
|
|
LATTEST(false);
|
|
|
|
// fall through in release mode
|
2007-10-25 04:13:56 +00:00
|
|
|
}
|
2013-04-25 21:27:10 +00:00
|
|
|
return string();
|
2007-09-27 18:24:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-02 19:12:47 +00:00
|
|
|
bool InsetCommandParams::isCompatibleCommand(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 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);
|
2010-09-07 00:41:00 +00:00
|
|
|
case LINE_CODE:
|
|
|
|
return InsetLine::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);
|
2013-04-25 21:27:10 +00:00
|
|
|
default:
|
|
|
|
LATTEST(false);
|
|
|
|
// fall through in release mode
|
2007-10-19 17:22:55 +00:00
|
|
|
}
|
2013-04-25 21:27:10 +00:00
|
|
|
return false;
|
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)
|
|
|
|
{
|
2010-05-03 17:55:44 +00:00
|
|
|
if (!isCompatibleCommand(insetCode_, name)) {
|
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;
|
2008-02-23 22:01:02 +00:00
|
|
|
info_ = findInfo(insetCode_, 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
|
|
|
}
|
2002-07-04 13:54:28 +00:00
|
|
|
|
|
|
|
|
2015-05-20 13:49:15 +00:00
|
|
|
void InsetCommandParams::read(Lexer & lex)
|
|
|
|
{
|
|
|
|
Read(lex, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetCommandParams::Read(Lexer & lex, Buffer const * buffer)
|
2002-07-04 13:54:28 +00:00
|
|
|
{
|
2008-04-05 10:34:29 +00:00
|
|
|
lex.setContext("InsetCommandParams::read");
|
|
|
|
lex >> insetName(insetCode_).c_str();
|
|
|
|
lex >> "LatexCommand";
|
|
|
|
lex >> cmdName_;
|
|
|
|
if (!isCompatibleCommand(insetCode_, cmdName_)) {
|
|
|
|
lex.printError("Incompatible command name " + cmdName_ + ".");
|
2008-02-11 19:42:36 +00:00
|
|
|
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
|
|
|
|
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
|
|
|
}
|
2008-02-23 22:01:02 +00:00
|
|
|
if (info_.hasParam(token)) {
|
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
|
|
|
lex.next(true);
|
Correctly load documents moved elsewhere after save.
It is now possible opening documents that where manually moved to a
different location after they were saved and still produce an output.
Indeed, (hopefully) all needed included files are now still found.
When the moved document is saved again, all paths are accordingly updated.
Of course, for this to work, a document has to be saved in Format 490,
at least.
As an example, after converting the user guide to the last format, it can
be copied anywhere and opened without the need of adapting the paths of
included files or moving them to a proper place.
There is one glitch I am aware of. When moving a child document (but not
the master) the path to the master is correctly updated but it won't be
recognized as such. This is because LyX checks that the parent actually
includes this document but, of course, being the parent document not
touched, it appears not including this child. Anyway, it will also occur
when saving the child to a different location and the user is warned
on the terminal about this fact when the moved child is loaded.
However, there is no problem when it is the master that has been moved.
2015-05-16 17:51:53 +00:00
|
|
|
docstring data = lex.getDocString();
|
|
|
|
if (buffer && token == "filename") {
|
|
|
|
data = from_utf8(buffer->includedFilePath(to_utf8(data)));
|
|
|
|
} else if (buffer && token == "bibfiles") {
|
|
|
|
int i = 0;
|
|
|
|
docstring newdata;
|
|
|
|
docstring bib = support::token(data, ',', i);
|
|
|
|
while (!bib.empty()) {
|
|
|
|
bib = from_utf8(buffer->includedFilePath(to_utf8(bib), "bib"));
|
|
|
|
if (!newdata.empty())
|
|
|
|
newdata.append(1, ',');
|
|
|
|
newdata.append(bib);
|
|
|
|
bib = support::token(data, ',', ++i);
|
|
|
|
}
|
|
|
|
data = newdata;
|
|
|
|
} else if (buffer && token == "options") {
|
|
|
|
data = from_utf8(buffer->includedFilePath(to_utf8(data), "bst"));
|
|
|
|
}
|
|
|
|
params_[token] = data;
|
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,
|
2009-01-01 16:35:14 +00:00
|
|
|
_("InsetCommandParams Error: "),
|
|
|
|
_("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
|
2015-05-03 21:55:19 +00:00
|
|
|
{
|
|
|
|
Write(os, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetCommandParams::Write(ostream & os, Buffer const * buffer) 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";
|
2008-02-23 22:01:02 +00:00
|
|
|
ParamInfo::const_iterator it = info_.begin();
|
|
|
|
ParamInfo::const_iterator end = info_.end();
|
|
|
|
for (; it != end; ++it) {
|
2015-05-03 21:55:19 +00:00
|
|
|
string const & name = it->name();
|
|
|
|
string data = to_utf8((*this)[name]);
|
2008-02-23 22:01:02 +00:00
|
|
|
if (!data.empty()) {
|
2015-05-03 21:55:19 +00:00
|
|
|
// Adjust path of files if document was moved
|
|
|
|
if (buffer && name == "filename") {
|
|
|
|
data = buffer->includedFilePath(data);
|
|
|
|
} else if (buffer && name == "bibfiles") {
|
|
|
|
int i = 0;
|
|
|
|
string newdata;
|
|
|
|
string bib = token(data, ',', i);
|
|
|
|
while (!bib.empty()) {
|
2015-05-05 20:29:22 +00:00
|
|
|
bib = buffer->includedFilePath(bib, "bib");
|
2015-05-03 21:55:19 +00:00
|
|
|
if (!newdata.empty())
|
|
|
|
newdata.append(1, ',');
|
|
|
|
newdata.append(bib);
|
|
|
|
bib = token(data, ',', ++i);
|
|
|
|
}
|
|
|
|
data = newdata;
|
Correctly load documents moved elsewhere after save.
It is now possible opening documents that where manually moved to a
different location after they were saved and still produce an output.
Indeed, (hopefully) all needed included files are now still found.
When the moved document is saved again, all paths are accordingly updated.
Of course, for this to work, a document has to be saved in Format 490,
at least.
As an example, after converting the user guide to the last format, it can
be copied anywhere and opened without the need of adapting the paths of
included files or moving them to a proper place.
There is one glitch I am aware of. When moving a child document (but not
the master) the path to the master is correctly updated but it won't be
recognized as such. This is because LyX checks that the parent actually
includes this document but, of course, being the parent document not
touched, it appears not including this child. Anyway, it will also occur
when saving the child to a different location and the user is warned
on the terminal about this fact when the moved child is loaded.
However, there is no problem when it is the master that has been moved.
2015-05-16 17:51:53 +00:00
|
|
|
} else if (buffer && name == "options") {
|
|
|
|
data = buffer->includedFilePath(data, "bst");
|
2015-05-03 21:55:19 +00:00
|
|
|
}
|
2008-02-23 22:01:02 +00:00
|
|
|
os << name << ' '
|
2015-05-03 21:55:19 +00:00
|
|
|
<< Lexer::quoteString(data)
|
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';
|
2008-02-23 22:01:02 +00:00
|
|
|
}
|
|
|
|
}
|
2002-07-04 13:54:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Per Abdel's suggestion that we focus on bug-fixing at this point, this will be the last patch in this series for a bit. But I wanted to get this done before I forget what it is I was doing, so here it is.
The idea behind this patch is to make real key-value support for InsetCommand parameters possible. This should be particularly useful for the listings version of InsetInclude, though we would need some kind of UI for it before it would really be helpful. (See below for some thoughts.) This doesn't substantially change anything else, though some things do get re-arranged a bit.
Basically, the idea is this. First, we introduce a whole range of parameter types: Normal LaTeX optional and required parameters; ones for LyX's internal use (like embed); and finally, in connection with keyval, ones that represent keys and ones that represent optional and required arguments where the keyval stuff will appear. (I'm assuming here that there will always be exactly one of those, and that it will accept only keyval-type material.) The parameters themselves are stored in a map, so it's really only the output routines that need to care about the different types of parameters.
Regarding the frontend, it seems to me that something like the following would work:
(i) scan the parameter list for LATEX_KEY type parameters
(ii) the dialog will have a series of lines, each of which has a combo box listing the acceptable keys and a QLineEdit for entering its value, as well as a "delete" button of some sort for removing this key and its value
(iii) there should be an "add line" button to add a new line, activated only when all other lines are filled with values
Probably not even too hard.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23235 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-25 22:13:45 +00:00
|
|
|
bool InsetCommandParams::writeEmptyOptional(ParamInfo::const_iterator ci) const
|
|
|
|
{
|
2013-04-25 21:27:10 +00:00
|
|
|
LASSERT(ci->isOptional(), return false);
|
|
|
|
|
Per Abdel's suggestion that we focus on bug-fixing at this point, this will be the last patch in this series for a bit. But I wanted to get this done before I forget what it is I was doing, so here it is.
The idea behind this patch is to make real key-value support for InsetCommand parameters possible. This should be particularly useful for the listings version of InsetInclude, though we would need some kind of UI for it before it would really be helpful. (See below for some thoughts.) This doesn't substantially change anything else, though some things do get re-arranged a bit.
Basically, the idea is this. First, we introduce a whole range of parameter types: Normal LaTeX optional and required parameters; ones for LyX's internal use (like embed); and finally, in connection with keyval, ones that represent keys and ones that represent optional and required arguments where the keyval stuff will appear. (I'm assuming here that there will always be exactly one of those, and that it will accept only keyval-type material.) The parameters themselves are stored in a map, so it's really only the output routines that need to care about the different types of parameters.
Regarding the frontend, it seems to me that something like the following would work:
(i) scan the parameter list for LATEX_KEY type parameters
(ii) the dialog will have a series of lines, each of which has a combo box listing the acceptable keys and a QLineEdit for entering its value, as well as a "delete" button of some sort for removing this key and its value
(iii) there should be an "add line" button to add a new line, activated only when all other lines are filled with values
Probably not even too hard.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23235 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-25 22:13:45 +00:00
|
|
|
++ci; // we want to start with the next one
|
|
|
|
ParamInfo::const_iterator end = info_.end();
|
|
|
|
for (; ci != end; ++ci) {
|
|
|
|
switch (ci->type()) {
|
|
|
|
case ParamInfo::LYX_INTERNAL:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ParamInfo::LATEX_REQUIRED:
|
|
|
|
return false;
|
|
|
|
|
|
|
|
case ParamInfo::LATEX_OPTIONAL: {
|
|
|
|
std::string const & name = ci->name();
|
|
|
|
docstring const & data = (*this)[name];
|
|
|
|
if (!data.empty())
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
} //end switch
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-13 13:08:32 +00:00
|
|
|
docstring InsetCommandParams::prepareCommand(OutputParams const & runparams,
|
|
|
|
docstring const & command,
|
|
|
|
ParamInfo::ParamHandling handling) const
|
|
|
|
{
|
|
|
|
docstring result;
|
2010-10-21 18:01:06 +00:00
|
|
|
switch (handling) {
|
|
|
|
case ParamInfo::HANDLING_LATEXIFY: {
|
2012-06-30 11:30:48 +00:00
|
|
|
pair<docstring, docstring> command_latexed =
|
|
|
|
runparams.encoding->latexString(command, runparams.dryrun);
|
|
|
|
result = command_latexed.first;
|
|
|
|
if (!command_latexed.second.empty()) {
|
2010-02-13 13:08:32 +00:00
|
|
|
// issue a warning about omitted characters
|
|
|
|
// FIXME: should be passed to the error dialog
|
|
|
|
frontend::Alert::warning(_("Uncodable characters"),
|
2010-02-28 14:50:02 +00:00
|
|
|
bformat(_("The following characters that are used in the inset %1$s are not\n"
|
|
|
|
"representable in the current encoding and therefore have been omitted:\n%2$s."),
|
2012-06-30 11:30:48 +00:00
|
|
|
from_utf8(insetType()), command_latexed.second));
|
2010-02-13 13:08:32 +00:00
|
|
|
}
|
2010-10-21 18:01:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ParamInfo::HANDLING_ESCAPE:
|
2010-02-13 13:08:32 +00:00
|
|
|
result = escape(command);
|
2010-10-21 18:01:06 +00:00
|
|
|
break;
|
|
|
|
case ParamInfo::HANDLING_NONE:
|
2010-02-13 13:08:32 +00:00
|
|
|
result = command;
|
2010-10-21 18:01:06 +00:00
|
|
|
break;
|
|
|
|
} // switch
|
2010-02-13 13:08:32 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
docstring InsetCommandParams::getCommand(OutputParams const & runparams) 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;
|
2008-02-23 22:01:02 +00:00
|
|
|
ParamInfo::const_iterator it = info_.begin();
|
|
|
|
ParamInfo::const_iterator end = info_.end();
|
|
|
|
for (; it != end; ++it) {
|
|
|
|
std::string const & name = it->name();
|
Per Abdel's suggestion that we focus on bug-fixing at this point, this will be the last patch in this series for a bit. But I wanted to get this done before I forget what it is I was doing, so here it is.
The idea behind this patch is to make real key-value support for InsetCommand parameters possible. This should be particularly useful for the listings version of InsetInclude, though we would need some kind of UI for it before it would really be helpful. (See below for some thoughts.) This doesn't substantially change anything else, though some things do get re-arranged a bit.
Basically, the idea is this. First, we introduce a whole range of parameter types: Normal LaTeX optional and required parameters; ones for LyX's internal use (like embed); and finally, in connection with keyval, ones that represent keys and ones that represent optional and required arguments where the keyval stuff will appear. (I'm assuming here that there will always be exactly one of those, and that it will accept only keyval-type material.) The parameters themselves are stored in a map, so it's really only the output routines that need to care about the different types of parameters.
Regarding the frontend, it seems to me that something like the following would work:
(i) scan the parameter list for LATEX_KEY type parameters
(ii) the dialog will have a series of lines, each of which has a combo box listing the acceptable keys and a QLineEdit for entering its value, as well as a "delete" button of some sort for removing this key and its value
(iii) there should be an "add line" button to add a new line, activated only when all other lines are filled with values
Probably not even too hard.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23235 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-25 22:13:45 +00:00
|
|
|
switch (it->type()) {
|
|
|
|
case ParamInfo::LYX_INTERNAL:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ParamInfo::LATEX_REQUIRED: {
|
2010-10-21 17:56:00 +00:00
|
|
|
docstring const data =
|
2010-02-13 13:08:32 +00:00
|
|
|
prepareCommand(runparams, (*this)[name], it->handling());
|
2008-02-23 22:01:02 +00:00
|
|
|
s += '{' + data + '}';
|
|
|
|
noparam = false;
|
Per Abdel's suggestion that we focus on bug-fixing at this point, this will be the last patch in this series for a bit. But I wanted to get this done before I forget what it is I was doing, so here it is.
The idea behind this patch is to make real key-value support for InsetCommand parameters possible. This should be particularly useful for the listings version of InsetInclude, though we would need some kind of UI for it before it would really be helpful. (See below for some thoughts.) This doesn't substantially change anything else, though some things do get re-arranged a bit.
Basically, the idea is this. First, we introduce a whole range of parameter types: Normal LaTeX optional and required parameters; ones for LyX's internal use (like embed); and finally, in connection with keyval, ones that represent keys and ones that represent optional and required arguments where the keyval stuff will appear. (I'm assuming here that there will always be exactly one of those, and that it will accept only keyval-type material.) The parameters themselves are stored in a map, so it's really only the output routines that need to care about the different types of parameters.
Regarding the frontend, it seems to me that something like the following would work:
(i) scan the parameter list for LATEX_KEY type parameters
(ii) the dialog will have a series of lines, each of which has a combo box listing the acceptable keys and a QLineEdit for entering its value, as well as a "delete" button of some sort for removing this key and its value
(iii) there should be an "add line" button to add a new line, activated only when all other lines are filled with values
Probably not even too hard.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23235 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-25 22:13:45 +00:00
|
|
|
break;
|
2008-02-23 22:01:02 +00:00
|
|
|
}
|
Per Abdel's suggestion that we focus on bug-fixing at this point, this will be the last patch in this series for a bit. But I wanted to get this done before I forget what it is I was doing, so here it is.
The idea behind this patch is to make real key-value support for InsetCommand parameters possible. This should be particularly useful for the listings version of InsetInclude, though we would need some kind of UI for it before it would really be helpful. (See below for some thoughts.) This doesn't substantially change anything else, though some things do get re-arranged a bit.
Basically, the idea is this. First, we introduce a whole range of parameter types: Normal LaTeX optional and required parameters; ones for LyX's internal use (like embed); and finally, in connection with keyval, ones that represent keys and ones that represent optional and required arguments where the keyval stuff will appear. (I'm assuming here that there will always be exactly one of those, and that it will accept only keyval-type material.) The parameters themselves are stored in a map, so it's really only the output routines that need to care about the different types of parameters.
Regarding the frontend, it seems to me that something like the following would work:
(i) scan the parameter list for LATEX_KEY type parameters
(ii) the dialog will have a series of lines, each of which has a combo box listing the acceptable keys and a QLineEdit for entering its value, as well as a "delete" button of some sort for removing this key and its value
(iii) there should be an "add line" button to add a new line, activated only when all other lines are filled with values
Probably not even too hard.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23235 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-25 22:13:45 +00:00
|
|
|
case ParamInfo::LATEX_OPTIONAL: {
|
2010-10-21 17:56:00 +00:00
|
|
|
docstring const data =
|
2010-02-13 13:08:32 +00:00
|
|
|
prepareCommand(runparams, (*this)[name], it->handling());
|
Per Abdel's suggestion that we focus on bug-fixing at this point, this will be the last patch in this series for a bit. But I wanted to get this done before I forget what it is I was doing, so here it is.
The idea behind this patch is to make real key-value support for InsetCommand parameters possible. This should be particularly useful for the listings version of InsetInclude, though we would need some kind of UI for it before it would really be helpful. (See below for some thoughts.) This doesn't substantially change anything else, though some things do get re-arranged a bit.
Basically, the idea is this. First, we introduce a whole range of parameter types: Normal LaTeX optional and required parameters; ones for LyX's internal use (like embed); and finally, in connection with keyval, ones that represent keys and ones that represent optional and required arguments where the keyval stuff will appear. (I'm assuming here that there will always be exactly one of those, and that it will accept only keyval-type material.) The parameters themselves are stored in a map, so it's really only the output routines that need to care about the different types of parameters.
Regarding the frontend, it seems to me that something like the following would work:
(i) scan the parameter list for LATEX_KEY type parameters
(ii) the dialog will have a series of lines, each of which has a combo box listing the acceptable keys and a QLineEdit for entering its value, as well as a "delete" button of some sort for removing this key and its value
(iii) there should be an "add line" button to add a new line, activated only when all other lines are filled with values
Probably not even too hard.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23235 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-25 22:13:45 +00:00
|
|
|
if (!data.empty()) {
|
|
|
|
s += '[' + data + ']';
|
2006-11-04 17:55:36 +00:00
|
|
|
noparam = false;
|
Per Abdel's suggestion that we focus on bug-fixing at this point, this will be the last patch in this series for a bit. But I wanted to get this done before I forget what it is I was doing, so here it is.
The idea behind this patch is to make real key-value support for InsetCommand parameters possible. This should be particularly useful for the listings version of InsetInclude, though we would need some kind of UI for it before it would really be helpful. (See below for some thoughts.) This doesn't substantially change anything else, though some things do get re-arranged a bit.
Basically, the idea is this. First, we introduce a whole range of parameter types: Normal LaTeX optional and required parameters; ones for LyX's internal use (like embed); and finally, in connection with keyval, ones that represent keys and ones that represent optional and required arguments where the keyval stuff will appear. (I'm assuming here that there will always be exactly one of those, and that it will accept only keyval-type material.) The parameters themselves are stored in a map, so it's really only the output routines that need to care about the different types of parameters.
Regarding the frontend, it seems to me that something like the following would work:
(i) scan the parameter list for LATEX_KEY type parameters
(ii) the dialog will have a series of lines, each of which has a combo box listing the acceptable keys and a QLineEdit for entering its value, as well as a "delete" button of some sort for removing this key and its value
(iii) there should be an "add line" button to add a new line, activated only when all other lines are filled with values
Probably not even too hard.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23235 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-25 22:13:45 +00:00
|
|
|
} else if (writeEmptyOptional(it)) {
|
|
|
|
s += "[]";
|
|
|
|
noparam = false;
|
2006-11-04 17:55:36 +00:00
|
|
|
}
|
Per Abdel's suggestion that we focus on bug-fixing at this point, this will be the last patch in this series for a bit. But I wanted to get this done before I forget what it is I was doing, so here it is.
The idea behind this patch is to make real key-value support for InsetCommand parameters possible. This should be particularly useful for the listings version of InsetInclude, though we would need some kind of UI for it before it would really be helpful. (See below for some thoughts.) This doesn't substantially change anything else, though some things do get re-arranged a bit.
Basically, the idea is this. First, we introduce a whole range of parameter types: Normal LaTeX optional and required parameters; ones for LyX's internal use (like embed); and finally, in connection with keyval, ones that represent keys and ones that represent optional and required arguments where the keyval stuff will appear. (I'm assuming here that there will always be exactly one of those, and that it will accept only keyval-type material.) The parameters themselves are stored in a map, so it's really only the output routines that need to care about the different types of parameters.
Regarding the frontend, it seems to me that something like the following would work:
(i) scan the parameter list for LATEX_KEY type parameters
(ii) the dialog will have a series of lines, each of which has a combo box listing the acceptable keys and a QLineEdit for entering its value, as well as a "delete" button of some sort for removing this key and its value
(iii) there should be an "add line" button to add a new line, activated only when all other lines are filled with values
Probably not even too hard.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23235 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-25 22:13:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} //end switch
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-02 19:12:47 +00:00
|
|
|
docstring 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
|
|
|
{
|
2008-02-23 22:01:02 +00:00
|
|
|
ParamInfo::const_iterator it =
|
Per Abdel's suggestion that we focus on bug-fixing at this point, this will be the last patch in this series for a bit. But I wanted to get this done before I forget what it is I was doing, so here it is.
The idea behind this patch is to make real key-value support for InsetCommand parameters possible. This should be particularly useful for the listings version of InsetInclude, though we would need some kind of UI for it before it would really be helpful. (See below for some thoughts.) This doesn't substantially change anything else, though some things do get re-arranged a bit.
Basically, the idea is this. First, we introduce a whole range of parameter types: Normal LaTeX optional and required parameters; ones for LyX's internal use (like embed); and finally, in connection with keyval, ones that represent keys and ones that represent optional and required arguments where the keyval stuff will appear. (I'm assuming here that there will always be exactly one of those, and that it will accept only keyval-type material.) The parameters themselves are stored in a map, so it's really only the output routines that need to care about the different types of parameters.
Regarding the frontend, it seems to me that something like the following would work:
(i) scan the parameter list for LATEX_KEY type parameters
(ii) the dialog will have a series of lines, each of which has a combo box listing the acceptable keys and a QLineEdit for entering its value, as well as a "delete" button of some sort for removing this key and its value
(iii) there should be an "add line" button to add a new line, activated only when all other lines are filled with values
Probably not even too hard.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23235 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-25 22:13:45 +00:00
|
|
|
find_if(info_.begin(), info_.end(),
|
|
|
|
not1(mem_fun_ref(&ParamInfo::ParamData::isOptional)));
|
2013-04-25 21:27:10 +00:00
|
|
|
LASSERT(it != info_.end(), return docstring());
|
2008-02-23 22:01:02 +00:00
|
|
|
return (*this)[it->name()];
|
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
|
|
|
|
{
|
2013-04-25 21:27:10 +00:00
|
|
|
static const docstring dummy;
|
2008-04-20 08:19:26 +00:00
|
|
|
LASSERT(info_.hasParam(name), return dummy);
|
2008-02-23 22:01:02 +00:00
|
|
|
ParamMap::const_iterator data = params_.find(name);
|
|
|
|
if (data == params_.end() || data->second.empty())
|
|
|
|
return dummy;
|
|
|
|
return data->second;
|
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 & InsetCommandParams::operator[](string const & name)
|
|
|
|
{
|
2013-04-25 21:27:10 +00:00
|
|
|
LATTEST(info_.hasParam(name));
|
|
|
|
// this will add the name in release mode
|
2008-02-23 22:01:02 +00:00
|
|
|
return params_[name];
|
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::clear()
|
|
|
|
{
|
2008-02-23 22:01:02 +00:00
|
|
|
params_.clear();
|
2002-07-04 13:54:28 +00:00
|
|
|
}
|
|
|
|
|
2002-07-04 17:45:35 +00:00
|
|
|
|
2008-04-02 19:12:47 +00:00
|
|
|
bool operator==(InsetCommandParams const & o1, InsetCommandParams const & o2)
|
2002-07-04 17:45:35 +00:00
|
|
|
{
|
2008-04-02 19:12:47 +00:00
|
|
|
return o1.insetCode_ == o2.insetCode_
|
|
|
|
&& o1.cmdName_ == o2.cmdName_
|
|
|
|
&& o1.info_ == o2.info_
|
|
|
|
&& o1.params_ == o2.params_
|
|
|
|
&& o1.preview_ == o2.preview_;
|
2002-07-04 17:45:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-02 19:12:47 +00:00
|
|
|
bool operator!=(InsetCommandParams const & o1, InsetCommandParams const & o2)
|
2002-07-04 17:45:35 +00:00
|
|
|
{
|
|
|
|
return !(o1 == o2);
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|