This is my patch for this.
This is basic support, it can be enhanced with, NoFloat, CopyFloat
etc. if wanted.

The fileformat changed slightly after the example I posted ealier.

Comments please.

Attachment: stdfloats.inc
Description: Binary data

Index: FloatList.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/FloatList.C,v
retrieving revision 1.13
diff -u -p -r1.13 FloatList.C
--- FloatList.C	27 Aug 2002 15:51:17 -0000	1.13
+++ FloatList.C	2 Sep 2002 21:06:01 -0000
@@ -26,6 +26,7 @@
 
 FloatList::FloatList()
 {
+#if 0
 	// Insert the latex builtin float-types
 	// (these will later be read from a layout file)
 
@@ -36,7 +37,7 @@ FloatList::FloatList()
 
 	// figure
 	Floating figure("figure", "tbp", "lof",
-			"", "plain", N_("Figure"), 
+			"", "plain", N_("Figure"),
 			N_("List of Figures"), true);
 	newFloat(figure);
 
@@ -47,6 +48,7 @@ FloatList::FloatList()
 			   "", "ruled", N_("Algorithm"),
 			   N_("List of Algorithms"));
 	newFloat(algorithm);
+#endif
 }
 
 
@@ -103,4 +105,3 @@ FloatList::const_iterator FloatList::ope
 {
 	return list.find(t);
 }
-
Index: lyxlayout.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxlayout.h,v
retrieving revision 1.5
diff -u -p -r1.5 lyxlayout.h
--- lyxlayout.h	23 Aug 2002 09:05:31 -0000	1.5
+++ lyxlayout.h	2 Sep 2002 21:06:01 -0000
@@ -190,7 +190,7 @@ public:
 	bool intitle;
 	/// Does this layout allow for an optional parameter?
 	int optionalargs;
-	
+
 private:
 	/// Name of the layout/paragraph environment
 	string name_;
Index: lyxtextclass.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtextclass.C,v
retrieving revision 1.17
diff -u -p -r1.17 lyxtextclass.C
--- lyxtextclass.C	27 Aug 2002 15:51:18 -0000	1.17
+++ lyxtextclass.C	2 Sep 2002 21:06:02 -0000
@@ -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 & f
 		{ "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 & f
 				     << 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 & f
 			if (lexrc.next())
 				rightmargin_ = lexrc.getString();
 			break;
+		case TC_FLOAT:
+			readFloat(lexrc);
+			break;
 		}
 	}
 
@@ -491,6 +496,106 @@ void LyXTextClass::readClassOptions(LyXL
 			break;
 		}
 	}
+	lexrc.popTable();
+}
+
+
+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();
 }
 
Index: lyxtextclass.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtextclass.h,v
retrieving revision 1.7
diff -u -p -r1.7 lyxtextclass.h
--- lyxtextclass.h	27 Aug 2002 15:51:18 -0000	1.7
+++ lyxtextclass.h	2 Sep 2002 21:06:02 -0000
@@ -54,6 +54,8 @@ public:
 	///
 	void readClassOptions(LyXLex &);
 	///
+	void readFloat(LyXLex &);
+	///
 	bool hasLayout(string const & name) const;
 
 	///

-- 
        Lgb

Reply via email to