Attached is <ugly>patch</ugly> for docbook glossaries export. Missing
features are:

- glossary entries in insets does not appear in glossary. I couldn't
find a "chic" way to include those.. (the current one is not so chic
anyway.. ) Any ideas??
- prefix is not working, therefore, you cannot change the sorting.
(any idea how to do it?)
- possible performance problems. (not tested)

Ugras
Index: src/paragraph.h
===================================================================
--- src/paragraph.h	(revision 15801)
+++ src/paragraph.h	(working copy)
@@ -158,6 +158,10 @@
 				 LyXFont const & outerfont,
 				 pos_type initial = 0) const;
 
+	void simpleDocBookGlossary(Buffer const & buf,
+				   OutputParams const & runparams,
+				   odocstream &,
+				   pos_type initial = 0) const;
 	///
 	bool hasSameLayout(Paragraph const & par) const;
 
Index: src/paragraph.C
===================================================================
--- src/paragraph.C	(revision 15801)
+++ src/paragraph.C	(working copy)
@@ -1201,6 +1201,23 @@
 }
 
 
+void Paragraph::simpleDocBookGlossary(Buffer const & buf,
+				    OutputParams const & runparams,
+				    odocstream & os,
+				    pos_type initial) const
+{
+// 	pos_type initial = 0;
+
+	for (pos_type i = initial; i < size(); ++i) {
+		if (isInset(i)) {
+			InsetBase const * inset = getInset(i);
+			if(inset->lyxCode() == InsetBase::NOMENCL_CODE )
+				inset->docbook(buf, os, runparams);
+		}
+	}
+}
+
+
 void Paragraph::simpleDocBookOnePar(Buffer const & buf,
 				    odocstream & os,
 				    OutputParams const & runparams,
@@ -1233,6 +1250,7 @@
 
 		if (isInset(i)) {
 			InsetBase const * inset = getInset(i);
+			if(inset->lyxCode() != InsetBase::NOMENCL_CODE )
 			inset->docbook(buf, os, runparams);
 		} else {
 			value_type c = getChar(i);
@@ -1245,7 +1263,6 @@
 		}
 		font_old = font;
 	}
-
 	if (emph_flag) {
 		os << "</emphasis>";
 	}
Index: src/insets/insetnomencl.C
===================================================================
--- src/insets/insetnomencl.C	(revision 15801)
+++ src/insets/insetnomencl.C	(working copy)
@@ -18,6 +18,10 @@
 #include "LaTeXFeatures.h"
 #include "metricsinfo.h"
 #include "sgml.h"
+#include "paragraph.h"
+#include "paragraph_funcs.h"
+#include "ParagraphList.h"
+#include "buffer.h"
 
 
 namespace lyx {
@@ -39,15 +43,15 @@
 int InsetNomencl::docbook(Buffer const &, odocstream & os,
 			OutputParams const &) const
 {
-	// FIXME: This does not work, because the entry needs to be put
-	// in the glossary.
-#if 0
-	os << "<glossentry><glossterm>"
+	// FIXME: This does not work when nomencl entry put inside the insets,
+	os << "<glossentry>" << '\n' 
+	   << "<glossterm>"
 	   << sgml::escapeString(getParam("symbol"))
-	   << "</glossterm><glossdef><para>"
-	   << sgml::escapeString(getParam("description"))
-	   << "</para></glossdef></glossentry>";
-#endif
+	   << "</glossterm> " << '\n'
+	   << "<glossdef><para>"
+	   << sgml::escapeString(getParam("description")) << '\n'
+	   << "</para></glossdef>" << '\n'
+	   <<"</glossentry>" << '\n';
 	return 0;
 }
 
@@ -75,11 +79,17 @@
 }
 
 
-int InsetPrintNomencl::docbook(Buffer const &, odocstream & os,
-		OutputParams const &) const
+int InsetPrintNomencl::docbook(Buffer const & buf, odocstream & os,
+		OutputParams const & params) const
 {
-	// FIXME This does not work, we need to define the entries here.
-	//os << "<glossary><glossary/>";
+	ParagraphList::const_iterator beg = buf.paragraphs().begin();
+	ParagraphList::const_iterator par = buf.paragraphs().begin();
+	ParagraphList::const_iterator end = buf.paragraphs().end();
+	os << "<glossary>" << '\n';
+	for (; par != end; ++par) {
+		par->simpleDocBookGlossary(buf,params,os);
+	}
+	os << "</glossary>" << '\n';
 	return 0;
 }
 
Index: lib/doc/Extended.lyx
===================================================================
--- lib/doc/Extended.lyx	(revision 15801)
+++ lib/doc/Extended.lyx	(working copy)
@@ -2677,7 +2677,7 @@
 \noun on
 Özgür U\i \~{g}
 ra\i \c{s}
- Baram
+ Baran
 \end_layout
 
 \begin_layout Standard
@@ -2960,6 +2960,12 @@
 
 \end_layout
 
+\begin_layout Standard
+ Docbook glossaries works in a similar way with a limitation. With the curent
+ version of lyx, glossary entries entered inside the insets (tables, notes,
+ etc.) are not processed.
+\end_layout
+
 \begin_layout Section
 Multipart Documents
 \end_layout

Reply via email to