2002-09-12 14:58:06 +00:00
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
* \file factory.cpp
|
2002-09-12 14:58:06 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2002-09-12 14:58:06 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-12 14:58:06 +00:00
|
|
|
*/
|
2002-08-27 10:14:56 +00:00
|
|
|
|
2002-11-04 00:15:56 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2003-09-05 16:31:30 +00:00
|
|
|
#include "factory.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Buffer.h"
|
|
|
|
#include "BufferParams.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
#include "FloatList.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "FuncRequest.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
#include "Lexer.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "LyX.h"
|
2007-11-07 23:34:45 +00:00
|
|
|
#include "TextClass.h"
|
2002-08-28 17:33:42 +00:00
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "insets/InsetBibitem.h"
|
|
|
|
#include "insets/InsetBibtex.h"
|
|
|
|
#include "insets/InsetCaption.h"
|
2007-04-25 16:11:45 +00:00
|
|
|
#include "insets/InsetCitation.h"
|
2007-09-05 15:29:04 +00:00
|
|
|
#include "insets/InsetFlex.h"
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "insets/InsetERT.h"
|
Add support for listings package. Two listings command \lstinline, \lstinputlisting and an environment \lstlisting are supported, along with preamble \lstset. \lstinputlisting is implemented through Include dialog, and the other two are implemented with a new inset listings, along with its dialog.
* src/LyXAction.cpp: listing-insert action
* src/insets/Inset.h,cpp: LISTINGS_CODE
* src/insets/InsetInclude.cpp: handle \lstinputlisting
* src/insets/InsetListings.h,cpp: new listings inset
* src/insets/InsetListingsParams.h,cpp: parameters from listings package
* src/insets/InsetCommandParams.h,cpp: handle lstinputlisting option
* src/Bidi.cpp: handle LISTINGS_CODE
* src/frontends/qt4/ui/TextLayoutUi.ui: update UI
* src/frontends/qt4/ui/ListingsUi.ui: new dialog
* src/frontends/qt4/ui/IncludeUi.ui: update UI
* src/frontends/qt4/QInclude.h,cpp: add lstinputlisting
* src/frontends/qt4/QDocument.h,cpp: add textedit for preamble listings_params
* src/frontends/qt4/QListings.h,cpp: new listings inset
* src/frontends/qt4/Dialogs.cpp: new listings dialog
* src/frontends/controllers/ControlInclude.h,cpp: add lstinputlisting
* src/frontends/controllers/ControlListings.h,cpp: new listings inset
* src/LyXFunc.cpp: handle LISTING_CODE
* src/Paragraph.cpp: handle LISTING_CODE
* src/factory.cpp: new listings inset
* src/CutAndPaste.cpp: handle LISTINGS_CODE
* src/LaTeXFeatures.cpp: require listings
* src/Text3.cpp: Handle LISTINGS_CODE
* src/lfuns.h: add LFUN_LISTING_INSERT
* src/Buffer.cpp: change lyx file format to 269
* src/BufferParams.h,cpp: add listings_params to preamble
* lib/lyx2lyx/LyX.py: lyx2lyx
* lib/lyx2lyx/lyx_1_5.py: lyx2lyx
* lib/ui/stdmenus.inc: new menu item (no shortcut!)
* src/insets/Makefile.am: update autotools
* src/frontends/controllers/Makefile.am
* src/frontends/qt4/Makefile.dialogs
* src/frontends/qt4/Makefile.am
* po/POTFILES.in: a few more translatable files.
* development/scons/scons_manifest.py: scons build system
* development/FORMAT: document format changes
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18243 a592a061-630c-0410-9148-cb99ea01b6c8
2007-05-09 19:11:42 +00:00
|
|
|
#include "insets/InsetListings.h"
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "insets/InsetExternal.h"
|
|
|
|
#include "insets/InsetFloat.h"
|
|
|
|
#include "insets/InsetFloatList.h"
|
|
|
|
#include "insets/InsetFoot.h"
|
|
|
|
#include "insets/InsetGraphics.h"
|
|
|
|
#include "insets/InsetInclude.h"
|
|
|
|
#include "insets/InsetIndex.h"
|
2007-10-11 14:52:00 +00:00
|
|
|
#include "insets/InsetInfo.h"
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "insets/InsetNomencl.h"
|
|
|
|
#include "insets/InsetLabel.h"
|
|
|
|
#include "insets/InsetLine.h"
|
|
|
|
#include "insets/InsetMarginal.h"
|
2008-03-26 08:10:01 +00:00
|
|
|
#include "insets/InsetNewline.h"
|
2008-03-25 09:26:03 +00:00
|
|
|
#include "insets/InsetNewpage.h"
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "insets/InsetNote.h"
|
|
|
|
#include "insets/InsetBox.h"
|
|
|
|
#include "insets/InsetBranch.h"
|
|
|
|
#include "insets/InsetOptArg.h"
|
2007-11-23 02:10:00 +00:00
|
|
|
#include "insets/InsetNewpage.h"
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "insets/InsetRef.h"
|
|
|
|
#include "insets/InsetSpace.h"
|
|
|
|
#include "insets/InsetTabular.h"
|
|
|
|
#include "insets/InsetTOC.h"
|
2007-10-13 19:06:09 +00:00
|
|
|
#include "insets/InsetHyperlink.h"
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "insets/InsetVSpace.h"
|
|
|
|
#include "insets/InsetWrap.h"
|
2004-01-26 10:13:15 +00:00
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "mathed/MathMacroTemplate.h"
|
|
|
|
#include "mathed/InsetMathHull.h"
|
2003-02-27 13:26:07 +00:00
|
|
|
|
2007-04-28 20:44:46 +00:00
|
|
|
#include "frontends/alert.h"
|
2007-04-18 12:59:07 +00:00
|
|
|
|
2007-11-29 07:04:28 +00:00
|
|
|
#include "support/debug.h"
|
2003-03-12 11:52:23 +00:00
|
|
|
#include "support/lstrings.h"
|
2007-04-18 12:59:07 +00:00
|
|
|
#include "support/ExceptionMessage.h"
|
2002-08-27 10:14:56 +00:00
|
|
|
|
2008-04-30 08:26:40 +00:00
|
|
|
#include "support/lassert.h"
|
2003-10-01 16:27:36 +00:00
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
#include <sstream>
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2007-12-12 19:57:42 +00:00
|
|
|
using namespace lyx::support;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
namespace Alert = frontend::Alert;
|
|
|
|
|
2003-09-05 22:17:02 +00:00
|
|
|
|
2008-02-23 22:32:33 +00:00
|
|
|
Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
|
2002-08-27 10:14:56 +00:00
|
|
|
{
|
2007-11-03 17:37:37 +00:00
|
|
|
BufferParams const & params = buf.params();
|
2002-08-27 10:14:56 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
try {
|
2003-03-11 11:52:05 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
switch (cmd.action) {
|
2003-10-27 12:41:26 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_LINE_INSERT:
|
|
|
|
return new InsetLine;
|
2003-10-27 12:41:26 +00:00
|
|
|
|
2008-03-25 09:26:03 +00:00
|
|
|
case LFUN_NEWPAGE_INSERT: {
|
|
|
|
string const name = cmd.getArg(0);
|
|
|
|
InsetNewpageParams inp;
|
|
|
|
if (name.empty() || name == "newpage")
|
|
|
|
inp.kind = InsetNewpageParams::NEWPAGE;
|
|
|
|
else if (name == "pagebreak")
|
|
|
|
inp.kind = InsetNewpageParams::PAGEBREAK;
|
|
|
|
else if (name == "clearpage")
|
|
|
|
inp.kind = InsetNewpageParams::CLEARPAGE;
|
|
|
|
else if (name == "cleardoublepage")
|
|
|
|
inp.kind = InsetNewpageParams::CLEARDOUBLEPAGE;
|
|
|
|
return new InsetNewpage(inp);
|
|
|
|
}
|
2003-11-12 14:38:26 +00:00
|
|
|
|
2007-09-05 18:40:56 +00:00
|
|
|
case LFUN_FLEX_INSERT: {
|
2007-04-18 12:59:07 +00:00
|
|
|
string s = cmd.getArg(0);
|
2008-04-05 20:24:05 +00:00
|
|
|
return new InsetFlex(buf, s);
|
2007-04-18 12:59:07 +00:00
|
|
|
}
|
2003-10-27 12:41:26 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_NOTE_INSERT: {
|
|
|
|
string arg = cmd.getArg(0);
|
|
|
|
if (arg.empty())
|
|
|
|
arg = "Note";
|
2008-03-04 22:28:18 +00:00
|
|
|
return new InsetNote(buf, arg);
|
2007-04-18 12:59:07 +00:00
|
|
|
}
|
2003-10-27 12:41:26 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_BOX_INSERT: {
|
|
|
|
string arg = cmd.getArg(0);
|
|
|
|
if (arg.empty())
|
|
|
|
arg = "Boxed";
|
2008-03-04 22:28:18 +00:00
|
|
|
return new InsetBox(buf, arg);
|
2007-04-18 12:59:07 +00:00
|
|
|
}
|
2003-08-17 11:28:23 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_BRANCH_INSERT: {
|
|
|
|
docstring arg = cmd.argument();
|
|
|
|
if (arg.empty())
|
|
|
|
arg = from_ascii("none");
|
2008-03-04 22:28:18 +00:00
|
|
|
return new InsetBranch(buf, InsetBranchParams(arg));
|
2007-04-18 12:59:07 +00:00
|
|
|
}
|
2003-02-26 19:28:38 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_ERT_INSERT:
|
2008-03-04 22:28:18 +00:00
|
|
|
return new InsetERT(buf);
|
2003-02-26 19:28:38 +00:00
|
|
|
|
Add support for listings package. Two listings command \lstinline, \lstinputlisting and an environment \lstlisting are supported, along with preamble \lstset. \lstinputlisting is implemented through Include dialog, and the other two are implemented with a new inset listings, along with its dialog.
* src/LyXAction.cpp: listing-insert action
* src/insets/Inset.h,cpp: LISTINGS_CODE
* src/insets/InsetInclude.cpp: handle \lstinputlisting
* src/insets/InsetListings.h,cpp: new listings inset
* src/insets/InsetListingsParams.h,cpp: parameters from listings package
* src/insets/InsetCommandParams.h,cpp: handle lstinputlisting option
* src/Bidi.cpp: handle LISTINGS_CODE
* src/frontends/qt4/ui/TextLayoutUi.ui: update UI
* src/frontends/qt4/ui/ListingsUi.ui: new dialog
* src/frontends/qt4/ui/IncludeUi.ui: update UI
* src/frontends/qt4/QInclude.h,cpp: add lstinputlisting
* src/frontends/qt4/QDocument.h,cpp: add textedit for preamble listings_params
* src/frontends/qt4/QListings.h,cpp: new listings inset
* src/frontends/qt4/Dialogs.cpp: new listings dialog
* src/frontends/controllers/ControlInclude.h,cpp: add lstinputlisting
* src/frontends/controllers/ControlListings.h,cpp: new listings inset
* src/LyXFunc.cpp: handle LISTING_CODE
* src/Paragraph.cpp: handle LISTING_CODE
* src/factory.cpp: new listings inset
* src/CutAndPaste.cpp: handle LISTINGS_CODE
* src/LaTeXFeatures.cpp: require listings
* src/Text3.cpp: Handle LISTINGS_CODE
* src/lfuns.h: add LFUN_LISTING_INSERT
* src/Buffer.cpp: change lyx file format to 269
* src/BufferParams.h,cpp: add listings_params to preamble
* lib/lyx2lyx/LyX.py: lyx2lyx
* lib/lyx2lyx/lyx_1_5.py: lyx2lyx
* lib/ui/stdmenus.inc: new menu item (no shortcut!)
* src/insets/Makefile.am: update autotools
* src/frontends/controllers/Makefile.am
* src/frontends/qt4/Makefile.dialogs
* src/frontends/qt4/Makefile.am
* po/POTFILES.in: a few more translatable files.
* development/scons/scons_manifest.py: scons build system
* development/FORMAT: document format changes
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18243 a592a061-630c-0410-9148-cb99ea01b6c8
2007-05-09 19:11:42 +00:00
|
|
|
case LFUN_LISTING_INSERT:
|
2008-03-04 22:28:18 +00:00
|
|
|
return new InsetListings(buf);
|
Add support for listings package. Two listings command \lstinline, \lstinputlisting and an environment \lstlisting are supported, along with preamble \lstset. \lstinputlisting is implemented through Include dialog, and the other two are implemented with a new inset listings, along with its dialog.
* src/LyXAction.cpp: listing-insert action
* src/insets/Inset.h,cpp: LISTINGS_CODE
* src/insets/InsetInclude.cpp: handle \lstinputlisting
* src/insets/InsetListings.h,cpp: new listings inset
* src/insets/InsetListingsParams.h,cpp: parameters from listings package
* src/insets/InsetCommandParams.h,cpp: handle lstinputlisting option
* src/Bidi.cpp: handle LISTINGS_CODE
* src/frontends/qt4/ui/TextLayoutUi.ui: update UI
* src/frontends/qt4/ui/ListingsUi.ui: new dialog
* src/frontends/qt4/ui/IncludeUi.ui: update UI
* src/frontends/qt4/QInclude.h,cpp: add lstinputlisting
* src/frontends/qt4/QDocument.h,cpp: add textedit for preamble listings_params
* src/frontends/qt4/QListings.h,cpp: new listings inset
* src/frontends/qt4/Dialogs.cpp: new listings dialog
* src/frontends/controllers/ControlInclude.h,cpp: add lstinputlisting
* src/frontends/controllers/ControlListings.h,cpp: new listings inset
* src/LyXFunc.cpp: handle LISTING_CODE
* src/Paragraph.cpp: handle LISTING_CODE
* src/factory.cpp: new listings inset
* src/CutAndPaste.cpp: handle LISTINGS_CODE
* src/LaTeXFeatures.cpp: require listings
* src/Text3.cpp: Handle LISTINGS_CODE
* src/lfuns.h: add LFUN_LISTING_INSERT
* src/Buffer.cpp: change lyx file format to 269
* src/BufferParams.h,cpp: add listings_params to preamble
* lib/lyx2lyx/LyX.py: lyx2lyx
* lib/lyx2lyx/lyx_1_5.py: lyx2lyx
* lib/ui/stdmenus.inc: new menu item (no shortcut!)
* src/insets/Makefile.am: update autotools
* src/frontends/controllers/Makefile.am
* src/frontends/qt4/Makefile.dialogs
* src/frontends/qt4/Makefile.am
* po/POTFILES.in: a few more translatable files.
* development/scons/scons_manifest.py: scons build system
* development/FORMAT: document format changes
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18243 a592a061-630c-0410-9148-cb99ea01b6c8
2007-05-09 19:11:42 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_FOOTNOTE_INSERT:
|
2008-03-04 22:28:18 +00:00
|
|
|
return new InsetFoot(buf);
|
2003-02-26 19:28:38 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_MARGINALNOTE_INSERT:
|
2008-03-04 22:28:18 +00:00
|
|
|
return new InsetMarginal(buf);
|
2003-02-26 19:28:38 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_OPTIONAL_INSERT:
|
2008-03-04 22:28:18 +00:00
|
|
|
return new InsetOptArg(buf);
|
2003-02-26 19:28:38 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_FLOAT_INSERT: {
|
|
|
|
// check if the float type exists
|
|
|
|
string const argument = to_utf8(cmd.argument());
|
2008-03-04 22:28:18 +00:00
|
|
|
if (buf.params().documentClass().floats().typeExist(argument))
|
|
|
|
return new InsetFloat(buf, argument);
|
2007-04-18 12:59:07 +00:00
|
|
|
lyxerr << "Non-existent float type: " << argument << endl;
|
2003-02-26 19:28:38 +00:00
|
|
|
}
|
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_FLOAT_WIDE_INSERT: {
|
|
|
|
// check if the float type exists
|
|
|
|
string const argument = to_utf8(cmd.argument());
|
2008-02-28 01:42:02 +00:00
|
|
|
if (params.documentClass().floats().typeExist(argument)) {
|
2008-03-04 22:28:18 +00:00
|
|
|
auto_ptr<InsetFloat> p(new InsetFloat(buf, argument));
|
2008-03-27 22:26:24 +00:00
|
|
|
p->setWide(true, params);
|
2007-04-18 12:59:07 +00:00
|
|
|
return p.release();
|
|
|
|
}
|
|
|
|
lyxerr << "Non-existent float type: " << argument << endl;
|
|
|
|
return 0;
|
|
|
|
}
|
2006-11-04 17:55:36 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_WRAP_INSERT: {
|
|
|
|
string const argument = to_utf8(cmd.argument());
|
2007-10-03 21:07:01 +00:00
|
|
|
if (argument == "figure" || argument == "table")
|
2008-03-04 22:28:18 +00:00
|
|
|
return new InsetWrap(buf, argument);
|
2007-09-09 23:47:22 +00:00
|
|
|
lyxerr << "Non-existent wrapfig type: " << argument << endl;
|
2005-07-15 22:10:25 +00:00
|
|
|
return 0;
|
2007-04-18 12:59:07 +00:00
|
|
|
}
|
2003-02-26 19:28:38 +00:00
|
|
|
|
2007-10-03 13:38:19 +00:00
|
|
|
case LFUN_INDEX_INSERT:
|
2008-03-04 22:28:18 +00:00
|
|
|
return new InsetIndex(buf);
|
2003-02-26 19:28:38 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_NOMENCL_INSERT: {
|
2007-10-19 17:22:55 +00:00
|
|
|
InsetCommandParams icp(NOMENCL_CODE);
|
2007-11-03 17:37:37 +00:00
|
|
|
icp["symbol"] = cmd.argument();
|
2007-04-18 12:59:07 +00:00
|
|
|
return new InsetNomencl(icp);
|
|
|
|
}
|
2003-02-26 19:28:38 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_TABULAR_INSERT: {
|
|
|
|
if (cmd.argument().empty())
|
|
|
|
return 0;
|
2007-12-12 19:28:07 +00:00
|
|
|
istringstream ss(to_utf8(cmd.argument()));
|
2007-04-18 12:59:07 +00:00
|
|
|
int r = 0, c = 0;
|
|
|
|
ss >> r >> c;
|
|
|
|
if (r <= 0)
|
|
|
|
r = 2;
|
|
|
|
if (c <= 0)
|
|
|
|
c = 2;
|
2007-11-03 17:37:37 +00:00
|
|
|
return new InsetTabular(buf, r, c);
|
2007-04-18 12:59:07 +00:00
|
|
|
}
|
2006-11-04 17:55:36 +00:00
|
|
|
|
2008-03-04 22:48:40 +00:00
|
|
|
case LFUN_CAPTION_INSERT:
|
|
|
|
return new InsetCaption(buf);
|
2002-08-29 13:05:55 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_INDEX_PRINT:
|
2007-10-19 17:22:55 +00:00
|
|
|
return new InsetPrintIndex(InsetCommandParams(INDEX_PRINT_CODE));
|
2003-03-13 11:00:31 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_NOMENCL_PRINT:
|
2007-10-19 17:22:55 +00:00
|
|
|
return new InsetPrintNomencl(InsetCommandParams(NOMENCL_PRINT_CODE));
|
2002-08-27 10:14:56 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_TOC_INSERT:
|
2007-10-19 17:22:55 +00:00
|
|
|
return new InsetTOC(InsetCommandParams(TOC_CODE));
|
2003-02-26 19:28:38 +00:00
|
|
|
|
2008-04-18 15:54:05 +00:00
|
|
|
case LFUN_INFO_INSERT: {
|
|
|
|
InsetInfo * inset = new InsetInfo(buf, to_utf8(cmd.argument()));
|
|
|
|
inset->updateInfo();
|
|
|
|
return inset;
|
|
|
|
}
|
2003-03-05 14:59:37 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_INSET_INSERT: {
|
|
|
|
string const name = cmd.getArg(0);
|
2007-10-17 12:50:25 +00:00
|
|
|
InsetCode code = insetCode(name);
|
|
|
|
switch (code) {
|
|
|
|
case NO_CODE:
|
|
|
|
lyxerr << "No such inset '" << name << "'.";
|
|
|
|
return 0;
|
|
|
|
|
2007-10-19 17:22:55 +00:00
|
|
|
case BIBITEM_CODE: {
|
|
|
|
InsetCommandParams icp(code);
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetCommand::string2params(name, to_utf8(cmd.argument()), icp);
|
More cache fixing. Similar fix as for InsetBibtex, and I've renamed the key routine.
Unfortunately, we can't do a one-short fix for InsetCommand, requiring that it take
a Buffer & in the constructor, due to problems in mathed, specifically, here:
void InsetMathHull::label(row_type row, docstring const & label)
{
...
label_[row] = new InsetLabel(p);
if (buffer_)
label_[row]->setBuffer(buffer());
}
If InsetLabel has to have a Buffer, then buffer_ has to be set, which means InsetMathHull needs a Buffer. But then truckloads of these are created in Parser, where we don't really seem to have access to a Buffer.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25137 a592a061-630c-0410-9148-cb99ea01b6c8
2008-06-05 06:55:34 +00:00
|
|
|
return new InsetBibitem(buf, icp);
|
2007-10-19 17:22:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case BIBTEX_CODE: {
|
|
|
|
InsetCommandParams icp(code);
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetCommand::string2params(name, to_utf8(cmd.argument()), icp);
|
2008-06-05 06:42:53 +00:00
|
|
|
return new InsetBibtex(buf, icp);
|
2007-10-19 17:22:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case CITE_CODE: {
|
|
|
|
InsetCommandParams icp(code);
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetCommand::string2params(name, to_utf8(cmd.argument()), icp);
|
2007-10-19 17:22:55 +00:00
|
|
|
return new InsetCitation(icp);
|
|
|
|
}
|
|
|
|
|
|
|
|
case ERT_CODE: {
|
2008-03-27 23:37:59 +00:00
|
|
|
return new InsetERT(buf,
|
|
|
|
InsetERT::string2params(to_utf8(cmd.argument())));
|
2007-10-19 17:22:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case LISTINGS_CODE: {
|
|
|
|
InsetListingsParams par;
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetListings::string2params(to_utf8(cmd.argument()), par);
|
2008-03-04 22:28:18 +00:00
|
|
|
return new InsetListings(buf, par);
|
2007-10-19 17:22:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case EXTERNAL_CODE: {
|
|
|
|
InsetExternalParams iep;
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetExternal::string2params(to_utf8(cmd.argument()), buf, iep);
|
2008-03-25 16:08:39 +00:00
|
|
|
auto_ptr<InsetExternal> inset(new InsetExternal(buf));
|
2008-03-24 20:32:52 +00:00
|
|
|
inset->setBuffer(buf);
|
2008-02-27 20:43:16 +00:00
|
|
|
inset->setParams(iep);
|
2007-10-19 17:22:55 +00:00
|
|
|
return inset.release();
|
|
|
|
}
|
|
|
|
|
|
|
|
case GRAPHICS_CODE: {
|
|
|
|
InsetGraphicsParams igp;
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetGraphics::string2params(to_utf8(cmd.argument()), buf, igp);
|
2008-03-25 16:08:39 +00:00
|
|
|
auto_ptr<InsetGraphics> inset(new InsetGraphics(buf));
|
2007-10-19 17:22:55 +00:00
|
|
|
inset->setParams(igp);
|
|
|
|
return inset.release();
|
|
|
|
}
|
|
|
|
|
|
|
|
case HYPERLINK_CODE: {
|
|
|
|
InsetCommandParams icp(code);
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetCommand::string2params(name, to_utf8(cmd.argument()), icp);
|
2007-10-19 17:22:55 +00:00
|
|
|
return new InsetHyperlink(icp);
|
|
|
|
}
|
|
|
|
|
|
|
|
case INCLUDE_CODE: {
|
2007-10-23 15:02:15 +00:00
|
|
|
InsetCommandParams icp(code);
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetCommand::string2params(name, to_utf8(cmd.argument()), icp);
|
2007-10-23 15:02:15 +00:00
|
|
|
return new InsetInclude(icp);
|
2007-10-19 17:22:55 +00:00
|
|
|
}
|
|
|
|
|
2007-10-17 12:50:25 +00:00
|
|
|
case INDEX_CODE:
|
2008-03-04 22:28:18 +00:00
|
|
|
return new InsetIndex(buf);
|
2007-10-19 17:22:55 +00:00
|
|
|
|
|
|
|
case NOMENCL_CODE: {
|
|
|
|
InsetCommandParams icp(code);
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetCommand::string2params(name, lyx::to_utf8(cmd.argument()), icp);
|
2007-10-19 17:22:55 +00:00
|
|
|
return new InsetNomencl(icp);
|
|
|
|
}
|
|
|
|
|
|
|
|
case LABEL_CODE: {
|
|
|
|
InsetCommandParams icp(code);
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetCommand::string2params(name, to_utf8(cmd.argument()), icp);
|
2007-10-19 17:22:55 +00:00
|
|
|
return new InsetLabel(icp);
|
|
|
|
}
|
|
|
|
|
|
|
|
case REF_CODE: {
|
|
|
|
InsetCommandParams icp(code);
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetCommand::string2params(name, to_utf8(cmd.argument()), icp);
|
2008-03-04 22:28:18 +00:00
|
|
|
return new InsetRef(buf, icp);
|
2007-10-19 17:22:55 +00:00
|
|
|
}
|
*** File Format Change: UI and enhancement for InsetSpace ***
* src/insets/InsetSpace.{cpp,h}:
- merge in HFill inset, add support for dotfill, hrulefill,
hspace and hspace*
* src/insets/InsetHFill.{cpp,h}:
- remove
* src/frontends/qt4/GuiHSpace.{cpp,h}:
* src/frontends/qt4/ui/HSpaceUi.ui:
* src/frontends/qt4/GuiView:
- new GUI for Space insets.
* src/insets/Inset.{cpp,h}:
* src/insets/InsetCode.h:
* src/insets/InsetCollapsable.cpp:
* src/insets/InsetCommandParams.cpp:
- remove HFILL_CODE and LFUN_HFILL_INSERT, add SPACE_CODE where necessary,
new Inset member isStretchableSpace() to indicate HFill and friends.
* Buffer.cpp:
- increase format to 319
* lib/lyx2lyx/LyX.py:
* lib/lyx2lyx/lyx_1_6.py:
- conversion/reversion routines
* development/FORMAT:
- document file format change
* src/Makefile.am:
* src/frontends/qt4/Makefile.am:
* development/scons/scons_manifest.py:
- deal with UI changes.
* src/LyXAction.cpp:
- remove LFUN_HFILL_INSERT
* src/LyXFunc.cpp:
- handle space dialog.
* src/factory.cpp:
* src/Paragraph.cpp (isHFill):
* src/Text.cpp:
* src/Text3.cpp:
* src/TextMetrics.cpp:
- adapt to changes
* lib/ui/classic.ui:
* lib/ui/stdmenus.ui:
- add HSpace dialog, remove HFill.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23787 a592a061-630c-0410-9148-cb99ea01b6c8
2008-03-17 09:23:43 +00:00
|
|
|
|
|
|
|
case SPACE_CODE: {
|
|
|
|
InsetSpaceParams isp;
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetSpace::string2params(to_utf8(cmd.argument()), isp);
|
*** File Format Change: UI and enhancement for InsetSpace ***
* src/insets/InsetSpace.{cpp,h}:
- merge in HFill inset, add support for dotfill, hrulefill,
hspace and hspace*
* src/insets/InsetHFill.{cpp,h}:
- remove
* src/frontends/qt4/GuiHSpace.{cpp,h}:
* src/frontends/qt4/ui/HSpaceUi.ui:
* src/frontends/qt4/GuiView:
- new GUI for Space insets.
* src/insets/Inset.{cpp,h}:
* src/insets/InsetCode.h:
* src/insets/InsetCollapsable.cpp:
* src/insets/InsetCommandParams.cpp:
- remove HFILL_CODE and LFUN_HFILL_INSERT, add SPACE_CODE where necessary,
new Inset member isStretchableSpace() to indicate HFill and friends.
* Buffer.cpp:
- increase format to 319
* lib/lyx2lyx/LyX.py:
* lib/lyx2lyx/lyx_1_6.py:
- conversion/reversion routines
* development/FORMAT:
- document file format change
* src/Makefile.am:
* src/frontends/qt4/Makefile.am:
* development/scons/scons_manifest.py:
- deal with UI changes.
* src/LyXAction.cpp:
- remove LFUN_HFILL_INSERT
* src/LyXFunc.cpp:
- handle space dialog.
* src/factory.cpp:
* src/Paragraph.cpp (isHFill):
* src/Text.cpp:
* src/Text3.cpp:
* src/TextMetrics.cpp:
- adapt to changes
* lib/ui/classic.ui:
* lib/ui/stdmenus.ui:
- add HSpace dialog, remove HFill.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23787 a592a061-630c-0410-9148-cb99ea01b6c8
2008-03-17 09:23:43 +00:00
|
|
|
return new InsetSpace(isp);
|
|
|
|
}
|
2007-10-19 17:22:55 +00:00
|
|
|
|
|
|
|
case TOC_CODE: {
|
|
|
|
InsetCommandParams icp(code);
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetCommand::string2params(name, to_utf8(cmd.argument()), icp);
|
2007-10-19 17:22:55 +00:00
|
|
|
return new InsetTOC(icp);
|
|
|
|
}
|
|
|
|
|
|
|
|
case VSPACE_CODE: {
|
|
|
|
VSpace vspace;
|
2008-03-27 00:21:35 +00:00
|
|
|
InsetVSpace::string2params(to_utf8(cmd.argument()), vspace);
|
2007-10-19 17:22:55 +00:00
|
|
|
return new InsetVSpace(vspace);
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
lyxerr << "Inset '" << name << "' not permitted with LFUN_INSET_INSERT."
|
2007-12-12 19:28:07 +00:00
|
|
|
<< endl;
|
2007-10-19 17:22:55 +00:00
|
|
|
return 0;
|
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
}
|
2007-10-17 12:50:25 +00:00
|
|
|
} //end LFUN_INSET_INSERT
|
2003-02-27 13:26:07 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
case LFUN_SPACE_INSERT: {
|
*** File Format Change: UI and enhancement for InsetSpace ***
* src/insets/InsetSpace.{cpp,h}:
- merge in HFill inset, add support for dotfill, hrulefill,
hspace and hspace*
* src/insets/InsetHFill.{cpp,h}:
- remove
* src/frontends/qt4/GuiHSpace.{cpp,h}:
* src/frontends/qt4/ui/HSpaceUi.ui:
* src/frontends/qt4/GuiView:
- new GUI for Space insets.
* src/insets/Inset.{cpp,h}:
* src/insets/InsetCode.h:
* src/insets/InsetCollapsable.cpp:
* src/insets/InsetCommandParams.cpp:
- remove HFILL_CODE and LFUN_HFILL_INSERT, add SPACE_CODE where necessary,
new Inset member isStretchableSpace() to indicate HFill and friends.
* Buffer.cpp:
- increase format to 319
* lib/lyx2lyx/LyX.py:
* lib/lyx2lyx/lyx_1_6.py:
- conversion/reversion routines
* development/FORMAT:
- document file format change
* src/Makefile.am:
* src/frontends/qt4/Makefile.am:
* development/scons/scons_manifest.py:
- deal with UI changes.
* src/LyXAction.cpp:
- remove LFUN_HFILL_INSERT
* src/LyXFunc.cpp:
- handle space dialog.
* src/factory.cpp:
* src/Paragraph.cpp (isHFill):
* src/Text.cpp:
* src/Text3.cpp:
* src/TextMetrics.cpp:
- adapt to changes
* lib/ui/classic.ui:
* lib/ui/stdmenus.ui:
- add HSpace dialog, remove HFill.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23787 a592a061-630c-0410-9148-cb99ea01b6c8
2008-03-17 09:23:43 +00:00
|
|
|
string const name = cmd.getArg(0);
|
|
|
|
string const len = cmd.getArg(1);
|
|
|
|
if (name.empty()) {
|
|
|
|
lyxerr << "LyX function 'space-insert' needs an argument." << endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
InsetSpaceParams isp;
|
2007-04-18 12:59:07 +00:00
|
|
|
if (name == "normal")
|
*** File Format Change: UI and enhancement for InsetSpace ***
* src/insets/InsetSpace.{cpp,h}:
- merge in HFill inset, add support for dotfill, hrulefill,
hspace and hspace*
* src/insets/InsetHFill.{cpp,h}:
- remove
* src/frontends/qt4/GuiHSpace.{cpp,h}:
* src/frontends/qt4/ui/HSpaceUi.ui:
* src/frontends/qt4/GuiView:
- new GUI for Space insets.
* src/insets/Inset.{cpp,h}:
* src/insets/InsetCode.h:
* src/insets/InsetCollapsable.cpp:
* src/insets/InsetCommandParams.cpp:
- remove HFILL_CODE and LFUN_HFILL_INSERT, add SPACE_CODE where necessary,
new Inset member isStretchableSpace() to indicate HFill and friends.
* Buffer.cpp:
- increase format to 319
* lib/lyx2lyx/LyX.py:
* lib/lyx2lyx/lyx_1_6.py:
- conversion/reversion routines
* development/FORMAT:
- document file format change
* src/Makefile.am:
* src/frontends/qt4/Makefile.am:
* development/scons/scons_manifest.py:
- deal with UI changes.
* src/LyXAction.cpp:
- remove LFUN_HFILL_INSERT
* src/LyXFunc.cpp:
- handle space dialog.
* src/factory.cpp:
* src/Paragraph.cpp (isHFill):
* src/Text.cpp:
* src/Text3.cpp:
* src/TextMetrics.cpp:
- adapt to changes
* lib/ui/classic.ui:
* lib/ui/stdmenus.ui:
- add HSpace dialog, remove HFill.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23787 a592a061-630c-0410-9148-cb99ea01b6c8
2008-03-17 09:23:43 +00:00
|
|
|
isp.kind = InsetSpaceParams::NORMAL;
|
|
|
|
else if (name == "protected")
|
|
|
|
isp.kind = InsetSpaceParams::PROTECTED;
|
|
|
|
else if (name == "thin")
|
|
|
|
isp.kind = InsetSpaceParams::THIN;
|
|
|
|
else if (name == "quad")
|
|
|
|
isp.kind = InsetSpaceParams::QUAD;
|
|
|
|
else if (name == "qquad")
|
|
|
|
isp.kind = InsetSpaceParams::QQUAD;
|
|
|
|
else if (name == "enspace")
|
|
|
|
isp.kind = InsetSpaceParams::ENSPACE;
|
|
|
|
else if (name == "enskip")
|
|
|
|
isp.kind = InsetSpaceParams::ENSKIP;
|
|
|
|
else if (name == "negthinspace")
|
|
|
|
isp.kind = InsetSpaceParams::NEGTHIN;
|
|
|
|
else if (name == "hfill")
|
|
|
|
isp.kind = InsetSpaceParams::HFILL;
|
2008-03-18 12:11:28 +00:00
|
|
|
else if (name == "hfill*")
|
|
|
|
isp.kind = InsetSpaceParams::HFILL_PROTECTED;
|
*** File Format Change: UI and enhancement for InsetSpace ***
* src/insets/InsetSpace.{cpp,h}:
- merge in HFill inset, add support for dotfill, hrulefill,
hspace and hspace*
* src/insets/InsetHFill.{cpp,h}:
- remove
* src/frontends/qt4/GuiHSpace.{cpp,h}:
* src/frontends/qt4/ui/HSpaceUi.ui:
* src/frontends/qt4/GuiView:
- new GUI for Space insets.
* src/insets/Inset.{cpp,h}:
* src/insets/InsetCode.h:
* src/insets/InsetCollapsable.cpp:
* src/insets/InsetCommandParams.cpp:
- remove HFILL_CODE and LFUN_HFILL_INSERT, add SPACE_CODE where necessary,
new Inset member isStretchableSpace() to indicate HFill and friends.
* Buffer.cpp:
- increase format to 319
* lib/lyx2lyx/LyX.py:
* lib/lyx2lyx/lyx_1_6.py:
- conversion/reversion routines
* development/FORMAT:
- document file format change
* src/Makefile.am:
* src/frontends/qt4/Makefile.am:
* development/scons/scons_manifest.py:
- deal with UI changes.
* src/LyXAction.cpp:
- remove LFUN_HFILL_INSERT
* src/LyXFunc.cpp:
- handle space dialog.
* src/factory.cpp:
* src/Paragraph.cpp (isHFill):
* src/Text.cpp:
* src/Text3.cpp:
* src/TextMetrics.cpp:
- adapt to changes
* lib/ui/classic.ui:
* lib/ui/stdmenus.ui:
- add HSpace dialog, remove HFill.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23787 a592a061-630c-0410-9148-cb99ea01b6c8
2008-03-17 09:23:43 +00:00
|
|
|
else if (name == "dotfill")
|
|
|
|
isp.kind = InsetSpaceParams::DOTFILL;
|
|
|
|
else if (name == "hrulefill")
|
|
|
|
isp.kind = InsetSpaceParams::HRULEFILL;
|
|
|
|
else if (name == "hspace") {
|
|
|
|
if (len.empty() || !isValidLength(len)) {
|
|
|
|
lyxerr << "LyX function 'space-insert hspace' "
|
|
|
|
<< "needs a valid length argument." << endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
isp.kind = InsetSpaceParams::CUSTOM;
|
|
|
|
isp.length = Length(len);
|
|
|
|
}
|
|
|
|
else if (name == "hspace*") {
|
|
|
|
if (len.empty() || !isValidLength(len)) {
|
|
|
|
lyxerr << "LyX function 'space-insert hspace*' "
|
|
|
|
<< "needs a valid length argument." << endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
isp.kind = InsetSpaceParams::CUSTOM_PROTECTED;
|
|
|
|
isp.length = Length(len);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lyxerr << "Wrong argument for LyX function 'space-insert'." << endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return new InsetSpace(isp);
|
2007-04-18 12:59:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-11-04 17:55:36 +00:00
|
|
|
|
2007-04-18 12:59:07 +00:00
|
|
|
default:
|
|
|
|
break;
|
2003-02-27 13:26:07 +00:00
|
|
|
}
|
2003-05-22 10:40:57 +00:00
|
|
|
|
2007-12-12 19:57:42 +00:00
|
|
|
} catch (ExceptionMessage const & message) {
|
|
|
|
if (message.type_ == ErrorException) {
|
2007-12-16 11:34:29 +00:00
|
|
|
// This should never happen!
|
2007-04-18 12:59:07 +00:00
|
|
|
Alert::error(message.title_, message.details_);
|
2008-07-14 08:35:00 +00:00
|
|
|
lyx_exit(1);
|
2007-12-12 19:57:42 +00:00
|
|
|
} else if (message.type_ == WarningException) {
|
2007-04-18 12:59:07 +00:00
|
|
|
Alert::warning(message.title_, message.details_);
|
|
|
|
return 0;
|
|
|
|
}
|
2003-05-22 10:40:57 +00:00
|
|
|
}
|
|
|
|
|
2002-08-27 10:14:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2003-03-12 11:52:23 +00:00
|
|
|
|
2008-03-27 07:26:37 +00:00
|
|
|
|
2008-02-23 22:32:33 +00:00
|
|
|
Inset * createInset(Buffer & buf, FuncRequest const & cmd)
|
|
|
|
{
|
|
|
|
Inset * inset = createInsetHelper(buf, cmd);
|
|
|
|
if (inset)
|
2008-02-27 20:43:16 +00:00
|
|
|
inset->setBuffer(buf);
|
2008-02-23 22:32:33 +00:00
|
|
|
return inset;
|
|
|
|
}
|
2003-03-12 11:52:23 +00:00
|
|
|
|
2008-03-27 07:26:37 +00:00
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
Inset * readInset(Lexer & lex, Buffer const & buf)
|
2003-03-12 11:52:23 +00:00
|
|
|
{
|
|
|
|
// consistency check
|
2008-03-27 07:26:37 +00:00
|
|
|
if (lex.getString() != "\\begin_inset")
|
|
|
|
LYXERR0("Buffer::readInset: Consistency check failed.");
|
2003-03-12 11:52:23 +00:00
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
auto_ptr<Inset> inset;
|
2003-03-12 11:52:23 +00:00
|
|
|
|
2008-04-05 19:27:02 +00:00
|
|
|
string tmptok;
|
|
|
|
lex >> tmptok;
|
2003-03-12 11:52:23 +00:00
|
|
|
|
|
|
|
// test the different insets
|
2007-10-17 12:50:25 +00:00
|
|
|
|
2008-03-27 07:26:37 +00:00
|
|
|
// FIXME It would be better if we did not have this branch and could
|
|
|
|
// just do one massive switch for all insets. But at present, it's
|
|
|
|
// easier to do it this way, and we can't do the massive switch until
|
|
|
|
// the conversion mentioned below. Note that if we do want to do a
|
|
|
|
// single switch, we need to remove this "CommandInset" line---or
|
|
|
|
// replace it with a single "InsetType" line that would be used in all
|
|
|
|
// insets.
|
2007-09-27 18:24:18 +00:00
|
|
|
if (tmptok == "CommandInset") {
|
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();
|
2007-09-27 18:24:18 +00:00
|
|
|
string const insetType = lex.getString();
|
|
|
|
lex.pushToken(insetType);
|
2007-10-17 12:50:25 +00:00
|
|
|
|
|
|
|
InsetCode const code = insetCode(insetType);
|
|
|
|
|
|
|
|
//FIXME If we do the one massive switch, we cannot do this here, since
|
|
|
|
//we do not know in advance that we're dealing with a command inset.
|
|
|
|
//Worst case, we could put it in each case below. Better, we could
|
|
|
|
//pass the lexer to the constructor and let the params be built there.
|
2007-10-19 17:22:55 +00:00
|
|
|
InsetCommandParams inscmd(code);
|
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
|
|
|
inscmd.read(lex);
|
2003-03-12 11:52:23 +00:00
|
|
|
|
2007-10-17 12:50:25 +00:00
|
|
|
switch (code) {
|
|
|
|
case BIBITEM_CODE:
|
More cache fixing. Similar fix as for InsetBibtex, and I've renamed the key routine.
Unfortunately, we can't do a one-short fix for InsetCommand, requiring that it take
a Buffer & in the constructor, due to problems in mathed, specifically, here:
void InsetMathHull::label(row_type row, docstring const & label)
{
...
label_[row] = new InsetLabel(p);
if (buffer_)
label_[row]->setBuffer(buffer());
}
If InsetLabel has to have a Buffer, then buffer_ has to be set, which means InsetMathHull needs a Buffer. But then truckloads of these are created in Parser, where we don't really seem to have access to a Buffer.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25137 a592a061-630c-0410-9148-cb99ea01b6c8
2008-06-05 06:55:34 +00:00
|
|
|
inset.reset(new InsetBibitem(buf, inscmd));
|
2007-10-17 12:50:25 +00:00
|
|
|
break;
|
|
|
|
case BIBTEX_CODE:
|
2008-06-05 06:42:53 +00:00
|
|
|
inset.reset(new InsetBibtex(buf, inscmd));
|
2007-10-17 12:50:25 +00:00
|
|
|
break;
|
|
|
|
case CITE_CODE:
|
|
|
|
inset.reset(new InsetCitation(inscmd));
|
|
|
|
break;
|
|
|
|
case HYPERLINK_CODE:
|
|
|
|
inset.reset(new InsetHyperlink(inscmd));
|
|
|
|
break;
|
|
|
|
case INCLUDE_CODE:
|
|
|
|
inset.reset(new InsetInclude(inscmd));
|
|
|
|
break;
|
|
|
|
case INDEX_PRINT_CODE:
|
|
|
|
inset.reset(new InsetPrintIndex(inscmd));
|
|
|
|
break;
|
|
|
|
case LABEL_CODE:
|
|
|
|
inset.reset(new InsetLabel(inscmd));
|
|
|
|
break;
|
|
|
|
case NOMENCL_CODE:
|
|
|
|
inset.reset(new InsetNomencl(inscmd));
|
|
|
|
break;
|
|
|
|
case NOMENCL_PRINT_CODE:
|
|
|
|
inset.reset(new InsetPrintNomencl(inscmd));
|
|
|
|
break;
|
|
|
|
case REF_CODE:
|
2008-04-03 18:40:46 +00:00
|
|
|
if (inscmd["name"].empty() && inscmd["reference"].empty())
|
|
|
|
return 0;
|
|
|
|
inset.reset(new InsetRef(buf, inscmd));
|
2007-10-17 12:50:25 +00:00
|
|
|
break;
|
|
|
|
case TOC_CODE:
|
|
|
|
inset.reset(new InsetTOC(inscmd));
|
|
|
|
break;
|
|
|
|
case NO_CODE:
|
|
|
|
default:
|
|
|
|
lyxerr << "unknown CommandInset '" << insetType
|
2007-12-12 19:28:07 +00:00
|
|
|
<< "'" << endl;
|
2007-10-17 12:50:25 +00:00
|
|
|
while (lex.isOK() && lex.getString() != "\\end_inset")
|
|
|
|
lex.next();
|
|
|
|
return 0;
|
2003-03-12 11:52:23 +00:00
|
|
|
}
|
2008-02-27 20:43:16 +00:00
|
|
|
inset->setBuffer(const_cast<Buffer &>(buf));
|
2007-10-17 12:50:25 +00:00
|
|
|
} else {
|
|
|
|
// FIXME This branch should be made to use inset codes as the preceding
|
|
|
|
// branch does. Unfortunately, that will take some doing. It requires
|
|
|
|
// converting the representation of the insets in LyX files so that they
|
|
|
|
// use the inset names listed in Inset.cpp. Then, as above, the inset names
|
|
|
|
// can be translated to inset codes using insetCode(). And the insets'
|
|
|
|
// write() routines should use insetName() rather than hardcoding it.
|
2003-03-12 11:52:23 +00:00
|
|
|
if (tmptok == "Quotes") {
|
2008-09-06 14:04:01 +00:00
|
|
|
inset.reset(new InsetQuotes(buf));
|
2003-03-12 11:52:23 +00:00
|
|
|
} else if (tmptok == "External") {
|
2008-03-25 16:08:39 +00:00
|
|
|
inset.reset(new InsetExternal(const_cast<Buffer &>(buf)));
|
2003-03-12 11:52:23 +00:00
|
|
|
} else if (tmptok == "FormulaMacro") {
|
2004-04-13 06:27:29 +00:00
|
|
|
inset.reset(new MathMacroTemplate);
|
2003-03-12 11:52:23 +00:00
|
|
|
} else if (tmptok == "Formula") {
|
2006-09-16 18:11:38 +00:00
|
|
|
inset.reset(new InsetMathHull);
|
2003-03-12 11:52:23 +00:00
|
|
|
} else if (tmptok == "Graphics") {
|
2008-03-25 16:08:39 +00:00
|
|
|
inset.reset(new InsetGraphics(const_cast<Buffer &>(buf)));
|
2003-12-10 17:28:14 +00:00
|
|
|
} else if (tmptok == "Note") {
|
2008-03-04 22:28:18 +00:00
|
|
|
inset.reset(new InsetNote(buf, tmptok));
|
2003-12-10 21:48:40 +00:00
|
|
|
} else if (tmptok == "Box") {
|
2008-03-04 22:28:18 +00:00
|
|
|
inset.reset(new InsetBox(buf, tmptok));
|
2007-09-08 13:09:58 +00:00
|
|
|
} else if (tmptok == "Flex") {
|
2003-11-28 10:12:04 +00:00
|
|
|
lex.next();
|
|
|
|
string s = lex.getString();
|
2008-04-05 20:24:05 +00:00
|
|
|
inset.reset(new InsetFlex(buf, s));
|
2003-08-17 11:28:23 +00:00
|
|
|
} else if (tmptok == "Branch") {
|
2008-04-05 20:24:05 +00:00
|
|
|
inset.reset(new InsetBranch(buf, InsetBranchParams()));
|
2003-03-12 11:52:23 +00:00
|
|
|
} else if (tmptok == "ERT") {
|
2008-03-04 22:28:18 +00:00
|
|
|
inset.reset(new InsetERT(buf));
|
Add support for listings package. Two listings command \lstinline, \lstinputlisting and an environment \lstlisting are supported, along with preamble \lstset. \lstinputlisting is implemented through Include dialog, and the other two are implemented with a new inset listings, along with its dialog.
* src/LyXAction.cpp: listing-insert action
* src/insets/Inset.h,cpp: LISTINGS_CODE
* src/insets/InsetInclude.cpp: handle \lstinputlisting
* src/insets/InsetListings.h,cpp: new listings inset
* src/insets/InsetListingsParams.h,cpp: parameters from listings package
* src/insets/InsetCommandParams.h,cpp: handle lstinputlisting option
* src/Bidi.cpp: handle LISTINGS_CODE
* src/frontends/qt4/ui/TextLayoutUi.ui: update UI
* src/frontends/qt4/ui/ListingsUi.ui: new dialog
* src/frontends/qt4/ui/IncludeUi.ui: update UI
* src/frontends/qt4/QInclude.h,cpp: add lstinputlisting
* src/frontends/qt4/QDocument.h,cpp: add textedit for preamble listings_params
* src/frontends/qt4/QListings.h,cpp: new listings inset
* src/frontends/qt4/Dialogs.cpp: new listings dialog
* src/frontends/controllers/ControlInclude.h,cpp: add lstinputlisting
* src/frontends/controllers/ControlListings.h,cpp: new listings inset
* src/LyXFunc.cpp: handle LISTING_CODE
* src/Paragraph.cpp: handle LISTING_CODE
* src/factory.cpp: new listings inset
* src/CutAndPaste.cpp: handle LISTINGS_CODE
* src/LaTeXFeatures.cpp: require listings
* src/Text3.cpp: Handle LISTINGS_CODE
* src/lfuns.h: add LFUN_LISTING_INSERT
* src/Buffer.cpp: change lyx file format to 269
* src/BufferParams.h,cpp: add listings_params to preamble
* lib/lyx2lyx/LyX.py: lyx2lyx
* lib/lyx2lyx/lyx_1_5.py: lyx2lyx
* lib/ui/stdmenus.inc: new menu item (no shortcut!)
* src/insets/Makefile.am: update autotools
* src/frontends/controllers/Makefile.am
* src/frontends/qt4/Makefile.dialogs
* src/frontends/qt4/Makefile.am
* po/POTFILES.in: a few more translatable files.
* development/scons/scons_manifest.py: scons build system
* development/FORMAT: document format changes
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18243 a592a061-630c-0410-9148-cb99ea01b6c8
2007-05-09 19:11:42 +00:00
|
|
|
} else if (tmptok == "listings") {
|
2008-03-04 22:28:18 +00:00
|
|
|
inset.reset(new InsetListings(buf));
|
2008-05-30 15:38:43 +00:00
|
|
|
} else if (tmptok == "space") {
|
2003-11-03 17:47:28 +00:00
|
|
|
inset.reset(new InsetSpace);
|
2003-03-12 11:52:23 +00:00
|
|
|
} else if (tmptok == "Tabular") {
|
2008-07-23 12:13:41 +00:00
|
|
|
inset.reset(new InsetTabular(const_cast<Buffer &>(buf)));
|
2003-03-12 11:52:23 +00:00
|
|
|
} else if (tmptok == "Text") {
|
2008-03-04 22:28:18 +00:00
|
|
|
inset.reset(new InsetText(buf));
|
2003-11-28 15:53:34 +00:00
|
|
|
} else if (tmptok == "VSpace") {
|
|
|
|
inset.reset(new InsetVSpace);
|
2003-03-12 11:52:23 +00:00
|
|
|
} else if (tmptok == "Foot") {
|
2008-03-04 22:28:18 +00:00
|
|
|
inset.reset(new InsetFoot(buf));
|
2003-03-12 11:52:23 +00:00
|
|
|
} else if (tmptok == "Marginal") {
|
2008-03-04 22:28:18 +00:00
|
|
|
inset.reset(new InsetMarginal(buf));
|
2008-03-25 09:26:03 +00:00
|
|
|
} else if (tmptok == "Newpage") {
|
|
|
|
inset.reset(new InsetNewpage);
|
2008-03-26 08:10:01 +00:00
|
|
|
} else if (tmptok == "Newline") {
|
|
|
|
inset.reset(new InsetNewline);
|
2003-03-12 11:52:23 +00:00
|
|
|
} else if (tmptok == "OptArg") {
|
2008-03-04 22:28:18 +00:00
|
|
|
inset.reset(new InsetOptArg(buf));
|
2003-03-12 11:52:23 +00:00
|
|
|
} else if (tmptok == "Float") {
|
|
|
|
lex.next();
|
|
|
|
string tmptok = lex.getString();
|
2008-03-04 22:28:18 +00:00
|
|
|
inset.reset(new InsetFloat(buf, tmptok));
|
2003-03-12 11:52:23 +00:00
|
|
|
} else if (tmptok == "Wrap") {
|
|
|
|
lex.next();
|
|
|
|
string tmptok = lex.getString();
|
2008-03-04 22:28:18 +00:00
|
|
|
inset.reset(new InsetWrap(buf, tmptok));
|
2003-03-12 11:52:23 +00:00
|
|
|
} else if (tmptok == "Caption") {
|
2008-03-04 22:28:18 +00:00
|
|
|
inset.reset(new InsetCaption(buf));
|
2007-10-03 13:38:19 +00:00
|
|
|
} else if (tmptok == "Index") {
|
2008-03-04 22:28:18 +00:00
|
|
|
inset.reset(new InsetIndex(buf));
|
2003-03-12 11:52:23 +00:00
|
|
|
} else if (tmptok == "FloatList") {
|
2003-11-03 17:47:28 +00:00
|
|
|
inset.reset(new InsetFloatList);
|
2007-10-11 14:52:00 +00:00
|
|
|
} else if (tmptok == "Info") {
|
2008-03-04 22:28:18 +00:00
|
|
|
inset.reset(new InsetInfo(buf));
|
2003-10-01 16:27:36 +00:00
|
|
|
} else {
|
2003-10-14 12:49:15 +00:00
|
|
|
lyxerr << "unknown Inset type '" << tmptok
|
2007-12-12 19:28:07 +00:00
|
|
|
<< "'" << endl;
|
2003-10-14 12:49:15 +00:00
|
|
|
while (lex.isOK() && lex.getString() != "\\end_inset")
|
|
|
|
lex.next();
|
|
|
|
return 0;
|
2003-03-12 11:52:23 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:38:30 +00:00
|
|
|
// Set the buffer reference for proper parsing of some insets
|
|
|
|
// (InsetCollapsable for example)
|
2008-02-27 20:43:16 +00:00
|
|
|
inset->setBuffer(const_cast<Buffer &>(buf));
|
|
|
|
inset->read(lex);
|
2008-03-04 14:38:30 +00:00
|
|
|
// Set again the buffer for insets that are created inside this inset
|
|
|
|
// (InsetMathHull for example).
|
|
|
|
inset->setBuffer(const_cast<Buffer &>(buf));
|
2003-03-12 11:52:23 +00:00
|
|
|
}
|
2003-11-03 17:47:28 +00:00
|
|
|
return inset.release();
|
2003-03-12 11:52:23 +00:00
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|