floats in layout files

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5202 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2002-09-04 06:52:26 +00:00
parent b1736dc48a
commit 6b9e0044d3
7 changed files with 223 additions and 58 deletions

View File

@ -1,3 +1,9 @@
2002-09-04 Lars Gullik Bjønnes <larsbj@gullik.net>
* layouts/stdclass.inc: include stdfloats.h
* layouts/stdfloats.inc: new file
2002-09-03 Angus Leeming <leeming@lyx.org>
* scripts/lyxpreview2ppm.sh: test expects integer arguments.

View File

@ -42,4 +42,5 @@ Input stdtitle.inc
Input stdstruct.inc
Input lyxmacros.inc
Input stdlayouts.inc
Input stdfloats.inc
Input obsolete.inc

38
lib/layouts/stdfloats.inc Normal file
View File

@ -0,0 +1,38 @@
# Author : Lars Gullik Bjønnes <larsbj@lyx.org>
# This include file contains all the floats that are defined as standard
# in most LyX layouts.
Float
Type table
GuiName Table
Placement tbp
Extension lot
NumberWithin none
Style plain
ListName "List of Tables"
LaTeXBuiltin true
End
Float
Type figure
GuiName Figure
Placement tbp
Extension lof
NumberWithin none
Style plain
ListName "List of Figures"
LaTeXBuiltin true
End
Float
Type algorithm
GuiName Algorithm
Placement tbp
Extension loa
NumberWithin none
Style ruled
ListName "List of Algorithms"
LaTeXBuiltin false
End

View File

@ -1,3 +1,15 @@
2002-09-04 Lars Gullik Bjønnes <larsbj@gullik.net>
* lyxtextclass.C (TextClassTags): add TC_FLOAT
(Read): add float->TC_FLOAT to textclassTags
(Read): and handle it in the switch
(readFloat): new function
* FloatList.C (FloatList): comment out the hardcoded float
definitions.
* lyxlayout.h: ws change.
2002-08-29 Dekel Tsur <dekelts@tau.ac.il>
* buffer.C (readFile): Look for lyx2lyx in LYXDIR/lyx2lyx/

View File

@ -26,6 +26,7 @@
FloatList::FloatList()
{
#if 0
// Insert the latex builtin float-types
// (these will later be read from a layout file)
@ -47,6 +48,7 @@ FloatList::FloatList()
"", "ruled", N_("Algorithm"),
N_("List of Algorithms"));
newFloat(algorithm);
#endif
}
@ -103,4 +105,3 @@ FloatList::const_iterator FloatList::operator[](string const & t) const
{
return list.find(t);
}

View File

@ -107,7 +107,8 @@ enum TextClassTags {
TC_PROVIDESMAKEIDX,
TC_PROVIDESURL,
TC_LEFTMARGIN,
TC_RIGHTMARGIN
TC_RIGHTMARGIN,
TC_FLOAT
};
@ -119,6 +120,7 @@ bool LyXTextClass::Read(string const & filename, bool merge)
{ "columns", TC_COLUMNS },
{ "defaultfont", TC_DEFAULTFONT },
{ "defaultstyle", TC_DEFAULTSTYLE },
{ "float", TC_FLOAT },
{ "input", TC_INPUT },
{ "leftmargin", TC_LEFTMARGIN },
{ "maxcounter", TC_MAXCOUNTER },
@ -146,7 +148,7 @@ bool LyXTextClass::Read(string const & filename, bool merge)
<< MakeDisplayPath(filename)
<< endl;
LyXLex lexrc(textClassTags, TC_RIGHTMARGIN);
LyXLex lexrc(textClassTags, TC_FLOAT);
bool error = false;
lexrc.setFile(filename);
@ -322,6 +324,9 @@ bool LyXTextClass::Read(string const & filename, bool merge)
if (lexrc.next())
rightmargin_ = lexrc.getString();
break;
case TC_FLOAT:
readFloat(lexrc);
break;
}
}
@ -495,6 +500,106 @@ void LyXTextClass::readClassOptions(LyXLex & lexrc)
}
enum FloatTags {
FT_TYPE = 1,
FT_NAME,
FT_PLACEMENT,
FT_EXT,
FT_WITHIN,
FT_STYLE,
FT_LISTNAME,
FT_BUILTIN,
FT_END
};
void LyXTextClass::readFloat(LyXLex & lexrc)
{
keyword_item floatTags[] = {
{ "end", FT_END },
{ "extension", FT_EXT },
{ "guiname", FT_NAME },
{ "latexbuiltin", FT_BUILTIN },
{ "listname", FT_LISTNAME },
{ "numberwithin", FT_WITHIN },
{ "placement", FT_PLACEMENT },
{ "style", FT_STYLE },
{ "type", FT_TYPE }
};
lexrc.pushTable(floatTags, FT_END);
string type;
string placement;
string ext;
string within;
string style;
string name;
string listname;
bool builtin = false;
bool getout = false;
while (!getout && lexrc.isOK()) {
int le = lexrc.lex();
switch (le) {
case LyXLex::LEX_UNDEF:
lexrc.printError("Unknown ClassOption tag `$$Token'");
continue;
default: break;
}
switch (static_cast<FloatTags>(le)) {
case FT_TYPE:
lexrc.next();
type = lexrc.getString();
// Here we could check if this type is already defined
// and modify it with the rest of the vars instead.
break;
case FT_NAME:
lexrc.next();
name = lexrc.getString();
break;
case FT_PLACEMENT:
lexrc.next();
placement = lexrc.getString();
break;
case FT_EXT:
lexrc.next();
ext = lexrc.getString();
break;
case FT_WITHIN:
lexrc.next();
within = lexrc.getString();
if (within == "none")
within.erase();
break;
case FT_STYLE:
lexrc.next();
style = lexrc.getString();
break;
case FT_LISTNAME:
lexrc.next();
listname = lexrc.getString();
break;
case FT_BUILTIN:
lexrc.next();
builtin = lexrc.getBool();
break;
case FT_END:
getout = true;
break;
}
}
// Here if have a full float if getout == true
if (getout) {
Floating newfloat(type, placement, ext, within,
style, name, listname, builtin);
floatlist_.newFloat(newfloat);
}
lexrc.popTable();
}
LyXFont const & LyXTextClass::defaultfont() const
{
return defaultfont_;

View File

@ -54,6 +54,8 @@ public:
///
void readClassOptions(LyXLex &);
///
void readFloat(LyXLex &);
///
bool hasLayout(string const & name) const;
///