]> git.lyx.org Git - features.git/commitdiff
This is one of a series of patches that will merge the layout modules development...
authorRichard Heck <rgheck@comcast.net>
Wed, 29 Aug 2007 17:59:49 +0000 (17:59 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 29 Aug 2007 17:59:49 +0000 (17:59 +0000)
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.

This patch adds the backend. The ModuleList class holds a list of the available modules, which are retrieved from lyxmodules.lst, itself generated by configure.py. There are two LFUNs available: modules-clear and module-add, which do the obvious thing; you can test by typing these into the minibuffer, along with the name of one of the available modules: URL (a CharStyle), Endnote (a Custom Inset), and---with the spaces---End To Foot (View>LaTeX and look at the user preamble), which are themselves in lib/layouts. There are some others, too, that allow theorems to be added to classes like article and book.

The GUI will come next.

Issues: (i) The configure.py script could be improved. It'd be nice, for example, if it tested for the presence of the LaTeX packages a particular module needs. But this would mean re-working the LaTeX script, and I don't know how to do that. Note that at present, the packages are ignored. This will change shortly. (ii) I've used std::string in LyXModule, following what seemed to be a precedent in TextClass. If some of these should be docstrings, please let me know, and I'll change them. (iii) There is at present no distinction between LaTeX and DocBook modules. Should there be? That is: Should there be modules that are available when the document class is a LaTeX class and others that are available only when it is DocBook? Or should there just be one set of modules? Each module can of course indicate for what it is suitable in its description.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19893 a592a061-630c-0410-9148-cb99ea01b6c8

25 files changed:
lib/Makefile.am
lib/configure.py
lib/layouts/endnotes.module [new file with mode: 0644]
lib/layouts/foottoend.module [new file with mode: 0644]
lib/layouts/theorems-ams-withinsec.module [new file with mode: 0644]
lib/layouts/theorems-ams.module [new file with mode: 0644]
lib/layouts/theorems-std.module [new file with mode: 0644]
lib/layouts/theorems-withinchap.module [new file with mode: 0644]
lib/layouts/theorems-withinsec.module [new file with mode: 0644]
lib/layouts/url.module [new file with mode: 0644]
lib/lyx2lyx/LyX.py
lib/lyx2lyx/lyx_1_6.py
src/Buffer.cpp
src/BufferParams.cpp
src/BufferParams.h
src/LyX.cpp
src/LyXAction.cpp
src/LyXFunc.cpp
src/Makefile.am
src/ModuleList.cpp [new file with mode: 0644]
src/ModuleList.h [new file with mode: 0644]
src/TextClass.cpp
src/TextClass.h
src/insets/InsetInclude.cpp
src/lfuns.h

index dd6194e73c6dae78a565ca96fc7f32124c0463c6..e149b094fc6429fac59a99bf81c56c3bb632a11f 100644 (file)
@@ -1012,7 +1012,15 @@ dist_layouts_DATA =\
        layouts/agu_stdsections.inc \
        layouts/agu_stdtitle.inc \
        layouts/g-brief2.layout \
-       layouts/svglobal.layout
+       layouts/svglobal.layout \
+       layouts/endnotes.module \
+       layouts/foottoend.module \
+       layouts/theorems-ams.module \
+       layouts/theorems-ams-withinsec.module \
+       layouts/theorems-std.module \
+       layouts/theorems-withinchap.module \
+       layouts/theorems-withinsec.module \
+       layouts/url.module
 
 scriptsdir = $(pkgdatadir)/scripts
 # Note that we "chmod 755" manually these files in install-data-hook.
index 16994d2924bc500179af1c1ad7ee82ec1c37da4b..8a00c05d8a925374ed49f3f407d4903daf389f12 100644 (file)
@@ -737,6 +737,60 @@ s!@chk_docbook@!%s!g
         ''.join(lyxin))
 
 
+def checkModulesConfig():
+  removeFiles(['lyxmodules.lst'])
+
+  print '+checking list of modules... '
+  tx = open('lyxmodules.lst', 'w')
+  tx.write('''## This file declares modules and their associated definition files.
+## It has been automatically generated by configure
+## Use "Options/Reconfigure" if you need to update it after a
+## configuration change. 
+''')
+  # build the list of available modules
+  foundClasses = []
+  for file in glob.glob( os.path.join('layouts', '*.module') ) + \
+      glob.glob( os.path.join(srcdir, 'layouts', '*.module' ) ) :
+      # valid file?
+      print file
+      if not os.path.isfile(file): 
+          continue
+      tx.write(processModuleFile(file, bool_docbook, bool_linuxdoc))
+  tx.close()
+  print '\tdone'
+
+def processModuleFile(file, bool_docbook, bool_linuxdoc):
+    ''' process module file and get a line of result
+
+        Declare lines look like this:
+          \DeclareLyXModule[LaTeX Packages]{Description}{ModuleName}...
+        We expect output:
+          "ModuleName" "filename" "Description"
+        "
+    '''
+    p = re.compile(r'\DeclareLyXModule\s*(?:\[([^]]*)\])?{(.*)}{(.*)}')
+    for line in open(file).readlines():
+        res = p.search(line)
+        if res != None:
+            (packages, desc, modname) = res.groups()
+            #check availability...need to add that
+            if modname == None:
+              modname = desc
+              desc = packages
+              packages = ""
+            elif packages != None:
+              pkgs = [s.strip() for s in packages.split(",")]
+              packages = ",".join(pkgs)
+
+            filename = file.split(os.sep)[-1]
+            #return '"%s" "%s" "%s" "%s"\n' % (modname, filename, desc, '.'.join(pkgs))
+            return '"%s" "%s" "%s"\n' % (modname, filename, desc)
+    print "Module file without \DeclareLyXModule line. "
+    sys.exit(2)
+
+
+
+
 def checkTeXAllowSpaces():
     ''' Let's check whether spaces are allowed in TeX file names '''
     tex_allows_spaces = 'false'
@@ -830,4 +884,5 @@ Options:
     # --without-latex-config can disable lyx_check_config
     checkLatexConfig( lyx_check_config and LATEX != '', bool_docbook, bool_linuxdoc)
     createLaTeXConfig()
+    checkModulesConfig() #lyx_check_config and LATEX != '')
     removeTempFiles()
diff --git a/lib/layouts/endnotes.module b/lib/layouts/endnotes.module
new file mode 100644 (file)
index 0000000..93ee98e
--- /dev/null
@@ -0,0 +1,16 @@
+#\DeclareLyXModule[endnotes.sty]{Adds an endnote command, in addition to footnotes. You will need to add \theendnotes in ERT where you want the endnotes to appear.}{Endnote}
+
+Format 5
+
+InsetLayout Custom:Endnote
+   LyXType     custom
+   LatexName   endnote
+   LatexType   command
+   Font
+     Size      Small
+   EndFont
+   LabelString endnote
+   Preamble
+     \usepackage{endnotes}
+   EndPreamble
+End
diff --git a/lib/layouts/foottoend.module b/lib/layouts/foottoend.module
new file mode 100644 (file)
index 0000000..bc32ef7
--- /dev/null
@@ -0,0 +1,8 @@
+#\DeclareLyXModule[endnotes.sty]{Sets all footnotes as endnotes. You will need to add \theendnotes in ERT where you want the endnotes to appear.}{Foot to End}
+
+Format 5
+
+Preamble
+  \usepackage{endnotes}
+  \let\footnote=\endnote
+EndPreamble
diff --git a/lib/layouts/theorems-ams-withinsec.module b/lib/layouts/theorems-ams-withinsec.module
new file mode 100644 (file)
index 0000000..cde3716
--- /dev/null
@@ -0,0 +1,556 @@
+#\DeclareLyXModule[amsmath.sty]{Defines theorem environments and the proof environment for use with non-AMS classes, using the extended AMS machinery. The theorems are numbered within sections.}{Theorems (AMS, By Section)}
+
+# Author: Richard Heck <rgheck@comcast.net>
+# Adapted from amsdefs.inc and amsmaths.inc
+
+# the environments defined are:
+# - Proof
+# - Theorem
+# - Theorem*
+# - Corollary
+# - Corollary*
+# - Lemma
+# - Lemma*
+# - Proposition
+# - Proposition*
+# - Conjecture
+# - Conjecture*
+# - Criterion
+# - Algorithm
+# - Axiom
+# - Definition
+# - Definition*
+# - Example
+# - Example*
+# - Condition
+# - Condition*
+# - Problem
+# - Problem*
+# - Exercise
+# - Remark
+# - Remark*
+# - Note
+# - Note*
+# - Notation
+# - Notation*
+# - Claim
+# - Claim*
+# - Summary
+# - Acknowledgement
+# - Acknowledgement*
+# - Case
+# - Conclusion
+# - Conclusion*
+# - Fact
+# - Fact*
+
+Format 5
+Preamble
+       \usepackage{amsmath}
+  \theoremstyle{plain}
+       \newtheorem{thm}{Theorem}[section]
+EndPreamble
+
+
+Counter
+       Name                 theorem
+       Within               section
+End
+
+
+Style Theorem
+       Margin                First_Dynamic
+       LatexType             Environment
+       LatexName             thm
+#DependsOn             TheoremStyle
+       NextNoIndent          1
+       LabelSep              xx
+       ParIndent             MMM
+       ParSkip               0.4
+       ItemSep               0.2
+       TopSep                0.7
+       BottomSep             0.7
+       ParSep                0.3
+       Align                 Block
+       AlignPossible         Block, Left
+       LabelType             Counter
+       LabelCounter          theorem
+       LabelString           "Theorem \thetheorem."
+       Font
+         Shape               Italic
+         Size                Normal
+       EndFont
+       LabelFont
+         Shape               Up
+         Series              Bold
+       EndFont
+End
+
+
+Style Theorem*
+       CopyStyle             Theorem
+       LatexName             thm*
+       LabelType             Static
+       LabelString           "Theorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem*{thm*}{Theorem}
+       EndPreamble
+End
+
+
+Style Corollary
+       CopyStyle             Theorem
+       LatexName             cor
+       LabelString           "Corollary \thetheorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem{cor}[thm]{Corollary}
+       EndPreamble
+End
+
+
+Style Corollary*
+       CopyStyle             Theorem*
+       LatexName             cor*
+       LabelString           "Corollary."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem*{cor*}{Corollary}
+       EndPreamble
+End
+
+
+Style Lemma
+       CopyStyle             Theorem
+       LatexName             lem
+       LabelString           "Lemma \thetheorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem{lem}[thm]{Lemma}
+       EndPreamble
+End
+
+
+Style Lemma*
+       CopyStyle             Theorem*
+       LatexName             lem*
+       LabelString           "Lemma."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem*{lem*}{Lemma}
+       EndPreamble
+End
+
+
+Style Proposition
+       CopyStyle             Theorem
+       LatexName             prop
+       LabelString           "Proposition \thetheorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem{prop}[thm]{Proposition}
+       EndPreamble
+End
+
+
+Style Proposition*
+       CopyStyle             Theorem*
+       LatexName             prop*
+       LabelString           "Proposition."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem*{prop*}{Proposition}
+       EndPreamble
+End
+
+
+Style Conjecture
+       CopyStyle             Theorem
+       LatexName             conjecture
+       LabelString           "Conjecture \thetheorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem{conjecture}[thm]{Conjecture}
+       EndPreamble
+End
+
+
+Style Conjecture*
+       CopyStyle             Theorem*
+       LatexName             conjecture*
+       LabelString           "Conjecture."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem*{conjecture*}{Conjecture}
+       EndPreamble
+End
+
+
+Style Criterion
+       CopyStyle             Theorem
+       LatexName             criterion
+       LabelString           "Criterion \thetheorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem{criterion}[thm]{Criterion}
+       EndPreamble
+End
+
+
+Style Algorithm
+       CopyStyle             Theorem
+       LatexName             algorithm
+       LabelString           "Algorithm \thetheorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem{algorithm}[thm]{Algorithm}
+       EndPreamble
+End
+
+
+Style Fact
+       CopyStyle             Theorem
+       LatexName             fact
+       LabelString           "Fact \thetheorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem{fact}[thm]{Fact}
+       EndPreamble
+End
+
+
+Style Fact*
+       CopyStyle             Theorem*
+       LatexName             fact*
+       LabelString           "Fact."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem*{fact*}{Fact}
+       EndPreamble
+End
+
+
+Style Axiom
+       CopyStyle             Theorem
+       LatexName             ax
+       LabelString           "Axiom \thetheorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem{ax}[thm]{Axiom}
+       EndPreamble
+End
+
+
+Style Definition
+       CopyStyle             Theorem
+       LatexName             defn
+       LabelString           "Definition \thetheorem."
+       Font
+         Shape               Up
+       EndFont
+       LabelFont
+         Shape               Up
+         Series              Bold
+       EndFont
+       Preamble
+         \theoremstyle{definition}
+         \newtheorem{defn}[thm]{Definition}
+       EndPreamble
+End
+
+
+Style Definition*
+       CopyStyle             Definition
+       LatexName             defn*
+       LabelType             Static
+       LabelString           "Definition."
+       Preamble
+        \theoremstyle{definition}
+        \newtheorem*{defn*}{Definition}
+       EndPreamble
+End
+
+
+Style Example
+       CopyStyle             Definition
+       LatexName             example
+       LabelString           "Example \thetheorem."
+       Preamble
+        \theoremstyle{definition}
+         \newtheorem{example}[thm]{Example}
+       EndPreamble
+End
+
+
+Style Example*
+       CopyStyle             Definition*
+       LatexName             example*
+       LabelString           "Example."
+       Preamble
+         \theoremstyle{definition}
+         \newtheorem*{example*}{Example}
+       EndPreamble
+End
+
+
+Style Condition
+       CopyStyle             Definition
+       LatexName             condition
+       LabelString           "Condition \thetheorem."
+       Preamble
+         \theoremstyle{definition}
+         \newtheorem{condition}[thm]{Condition}
+       EndPreamble
+End
+
+
+Style Condition*
+       CopyStyle             Definition*
+       LatexName             condition*
+       LabelString           "Condition."
+       Preamble
+         \theoremstyle{definition}
+         \newtheorem*{condition*}{Condition}
+       EndPreamble
+End
+
+
+Style Problem
+       CopyStyle             Definition
+       LatexName             problem
+       LabelString           "Problem \thetheorem."
+       Preamble
+         \theoremstyle{definition}
+         \newtheorem{problem}[thm]{Problem}
+       EndPreamble
+End
+
+
+Style Problem*
+       CopyStyle             Definition*
+       LatexName             problem*
+       LabelString           "Problem."
+       Preamble
+         \theoremstyle{definition}
+         \newtheorem*{problem*}{Problem}
+       EndPreamble
+End
+
+
+Style Exercise
+       CopyStyle             Definition
+       LatexName             xca
+       LabelString           "Exercise \thetheorem."
+       Preamble
+         \theoremstyle{definition}
+         %%Delete [section] for sequential numbering
+         \newtheorem{xca}[section]{Exercise}
+       EndPreamble
+End
+
+
+Style Exercise*
+       CopyStyle             Definition*
+       LatexName             xca
+       LabelString           "Exercise."
+       Preamble
+         \theoremstyle{definition}
+         \newtheorem*{xca*}{Exercise}
+       EndPreamble
+End
+
+
+Style Remark
+       CopyStyle             Theorem
+       LatexName             rem
+       LabelString           "Remark \thetheorem."
+       Font
+         Shape               Up
+         Size                Normal
+       EndFont
+       LabelFont
+         Series              Medium
+         Shape               Italic
+       EndFont
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem{rem}[thm]{Remark}
+       EndPreamble
+End
+
+
+Style Remark*
+       CopyStyle             Remark
+       LatexName             rem*
+       LabelType             Static
+       LabelString           "Remark."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem*{rem*}{Remark}
+       EndPreamble
+End
+
+
+Style Claim
+       CopyStyle             Remark
+       LatexName             claim
+       LabelString           "Claim \thetheorem."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem{claim}[thm]{Claim}
+       EndPreamble
+End
+
+
+Style Claim*
+       CopyStyle             Remark*
+       LatexName             claim*
+       LabelString           "Claim."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem*{claim*}{Claim}
+       EndPreamble
+End
+
+
+Style Note
+       CopyStyle             Remark
+       LatexName             note
+       LabelString           "Note \thetheorem."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem{note}[thm]{Note}
+       EndPreamble
+End
+
+
+Style Note*
+       CopyStyle             Remark*
+       LatexName             note*
+       LabelString           "Note."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem*{note*}{Note}
+       EndPreamble
+End
+
+
+Style Notation
+       CopyStyle             Remark
+       LatexName             notation
+       LabelString           "Notation \thetheorem."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem{notation}[thm]{Notation}
+       EndPreamble
+End
+
+
+Style Notation*
+       CopyStyle             Remark*
+       LatexName             notation*
+       LabelString           "Notation."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem*{notation*}[thm]{Notation}
+       EndPreamble
+End
+
+
+Style Summary
+       CopyStyle             Remark
+       LatexName             summary
+       LabelString           "Summary \thetheorem."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem{summary}[thm]{Summary}
+       EndPreamble
+End
+
+
+Style Acknowledgement
+       CopyStyle             Remark
+       LatexName             acknowledgement
+       LabelString           "Acknowledgement \thetheorem."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem{acknowledgement}[thm]{Acknowledgement}
+       EndPreamble
+End
+
+
+Style Acknowledgement*
+       CopyStyle             Remark*
+       LatexName             acknowledgement*
+       LabelString           "Acknowledgement."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem*{acknowledgement*}{Acknowledgement}
+       EndPreamble
+End
+
+
+Style Case
+       CopyStyle             Remark
+       LatexName             case
+       LabelString           "Case \thetheorem."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem{case}{Case} %%Numbering of Cases not keyed to sections
+       EndPreamble
+End
+
+
+Style Conclusion
+       CopyStyle             Remark
+       LatexName             conclusion
+       LabelString           "Conclusion \thetheorem."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem{conclusion}[thm]{Conclusion}
+       EndPreamble
+End
+
+
+Style Conclusion*
+       CopyStyle             Remark*
+       LatexName             conclusion*
+       LabelString           "Conclusion."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem*{conclusion*}{Conclusion}
+       EndPreamble
+End
+
+
+Style Proof
+       Margin                First_Dynamic
+       LatexType             Environment
+       LatexName             proof
+       NextNoIndent          1
+       LabelSep              xx
+       ParIndent             MMM
+       ParSkip               0.4
+       ItemSep               0.2
+       TopSep                0.7
+       BottomSep             0.7
+       ParSep                0.3
+       Align                 Block
+       AlignPossible         Block, Left
+       LabelType             Static
+       LabelString           "Proof."
+       EndLabelType          Box
+       Font
+         Shape               Up
+         Size                Normal
+       EndFont
+       LabelFont
+         Shape               Italic
+       EndFont
+       # We don't want the preamble from Theorem
+       Preamble
+       EndPreamble
+End
+
+
diff --git a/lib/layouts/theorems-ams.module b/lib/layouts/theorems-ams.module
new file mode 100644 (file)
index 0000000..cd917ca
--- /dev/null
@@ -0,0 +1,555 @@
+#\DeclareLyXModule[amsmath.sty]{Defines theorem environments and the proof environment for use with non-AMS classes, using the extended AMS machinery. The theorems are numbered consecutively throughout the document.}{Theorems (AMS)}
+
+# Author: Richard Heck <rgheck@comcast.net>
+# Adapted from amsdefs.inc and amsmaths.inc
+
+# the environments defined are:
+# - Proof
+# - Theorem
+# - Theorem*
+# - Corollary
+# - Corollary*
+# - Lemma
+# - Lemma*
+# - Proposition
+# - Proposition*
+# - Conjecture
+# - Conjecture*
+# - Criterion
+# - Algorithm
+# - Axiom
+# - Definition
+# - Definition*
+# - Example
+# - Example*
+# - Condition
+# - Condition*
+# - Problem
+# - Problem*
+# - Exercise
+# - Remark
+# - Remark*
+# - Note
+# - Note*
+# - Notation
+# - Notation*
+# - Claim
+# - Claim*
+# - Summary
+# - Acknowledgement
+# - Acknowledgement*
+# - Case
+# - Conclusion
+# - Conclusion*
+# - Fact
+# - Fact*
+
+Format 5
+Preamble
+       \usepackage{amsmath}
+  \theoremstyle{plain}
+       \newtheorem{thm}{Theorem}[section]
+EndPreamble
+
+
+Counter
+       Name                 theorem
+End
+
+
+Style Theorem
+       Margin                First_Dynamic
+       LatexType             Environment
+       LatexName             thm
+#DependsOn             TheoremStyle
+       NextNoIndent          1
+       LabelSep              xx
+       ParIndent             MMM
+       ParSkip               0.4
+       ItemSep               0.2
+       TopSep                0.7
+       BottomSep             0.7
+       ParSep                0.3
+       Align                 Block
+       AlignPossible         Block, Left
+       LabelType             Counter
+       LabelCounter          theorem
+       LabelString           "Theorem \thetheorem."
+       Font
+         Shape               Italic
+         Size                Normal
+       EndFont
+       LabelFont
+         Shape               Up
+         Series              Bold
+       EndFont
+End
+
+
+Style Theorem*
+       CopyStyle             Theorem
+       LatexName             thm*
+       LabelType             Static
+       LabelString           "Theorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem*{thm*}{Theorem}
+       EndPreamble
+End
+
+
+Style Corollary
+       CopyStyle             Theorem
+       LatexName             cor
+       LabelString           "Corollary \thetheorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem{cor}[thm]{Corollary}
+       EndPreamble
+End
+
+
+Style Corollary*
+       CopyStyle             Theorem*
+       LatexName             cor*
+       LabelString           "Corollary."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem*{cor*}{Corollary}
+       EndPreamble
+End
+
+
+Style Lemma
+       CopyStyle             Theorem
+       LatexName             lem
+       LabelString           "Lemma \thetheorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem{lem}[thm]{Lemma}
+       EndPreamble
+End
+
+
+Style Lemma*
+       CopyStyle             Theorem*
+       LatexName             lem*
+       LabelString           "Lemma."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem*{lem*}{Lemma}
+       EndPreamble
+End
+
+
+Style Proposition
+       CopyStyle             Theorem
+       LatexName             prop
+       LabelString           "Proposition \thetheorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem{prop}[thm]{Proposition}
+       EndPreamble
+End
+
+
+Style Proposition*
+       CopyStyle             Theorem*
+       LatexName             prop*
+       LabelString           "Proposition."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem*{prop*}{Proposition}
+       EndPreamble
+End
+
+
+Style Conjecture
+       CopyStyle             Theorem
+       LatexName             conjecture
+       LabelString           "Conjecture \thetheorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem{conjecture}[thm]{Conjecture}
+       EndPreamble
+End
+
+
+Style Conjecture*
+       CopyStyle             Theorem*
+       LatexName             conjecture*
+       LabelString           "Conjecture."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem*{conjecture*}{Conjecture}
+       EndPreamble
+End
+
+
+Style Criterion
+       CopyStyle             Theorem
+       LatexName             criterion
+       LabelString           "Criterion \thetheorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem{criterion}[thm]{Criterion}
+       EndPreamble
+End
+
+
+Style Algorithm
+       CopyStyle             Theorem
+       LatexName             algorithm
+       LabelString           "Algorithm \thetheorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem{algorithm}[thm]{Algorithm}
+       EndPreamble
+End
+
+
+Style Fact
+       CopyStyle             Theorem
+       LatexName             fact
+       LabelString           "Fact \thetheorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem{fact}[thm]{Fact}
+       EndPreamble
+End
+
+
+Style Fact*
+       CopyStyle             Theorem*
+       LatexName             fact*
+       LabelString           "Fact."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem*{fact*}{Fact}
+       EndPreamble
+End
+
+
+Style Axiom
+       CopyStyle             Theorem
+       LatexName             ax
+       LabelString           "Axiom \thetheorem."
+       Preamble
+         \theoremstyle{plain}
+         \newtheorem{ax}[thm]{Axiom}
+       EndPreamble
+End
+
+
+Style Definition
+       CopyStyle             Theorem
+       LatexName             defn
+       LabelString           "Definition \thetheorem."
+       Font
+         Shape               Up
+       EndFont
+       LabelFont
+         Shape               Up
+         Series              Bold
+       EndFont
+       Preamble
+         \theoremstyle{definition}
+         \newtheorem{defn}[thm]{Definition}
+       EndPreamble
+End
+
+
+Style Definition*
+       CopyStyle             Definition
+       LatexName             defn*
+       LabelType             Static
+       LabelString           "Definition."
+       Preamble
+        \theoremstyle{definition}
+        \newtheorem*{defn*}{Definition}
+       EndPreamble
+End
+
+
+Style Example
+       CopyStyle             Definition
+       LatexName             example
+       LabelString           "Example \thetheorem."
+       Preamble
+        \theoremstyle{definition}
+         \newtheorem{example}[thm]{Example}
+       EndPreamble
+End
+
+
+Style Example*
+       CopyStyle             Definition*
+       LatexName             example*
+       LabelString           "Example."
+       Preamble
+         \theoremstyle{definition}
+         \newtheorem*{example*}{Example}
+       EndPreamble
+End
+
+
+Style Condition
+       CopyStyle             Definition
+       LatexName             condition
+       LabelString           "Condition \thetheorem."
+       Preamble
+         \theoremstyle{definition}
+         \newtheorem{condition}[thm]{Condition}
+       EndPreamble
+End
+
+
+Style Condition*
+       CopyStyle             Definition*
+       LatexName             condition*
+       LabelString           "Condition."
+       Preamble
+         \theoremstyle{definition}
+         \newtheorem*{condition*}{Condition}
+       EndPreamble
+End
+
+
+Style Problem
+       CopyStyle             Definition
+       LatexName             problem
+       LabelString           "Problem \thetheorem."
+       Preamble
+         \theoremstyle{definition}
+         \newtheorem{problem}[thm]{Problem}
+       EndPreamble
+End
+
+
+Style Problem*
+       CopyStyle             Definition*
+       LatexName             problem*
+       LabelString           "Problem."
+       Preamble
+         \theoremstyle{definition}
+         \newtheorem*{problem*}{Problem}
+       EndPreamble
+End
+
+
+Style Exercise
+       CopyStyle             Definition
+       LatexName             xca
+       LabelString           "Exercise \thetheorem."
+       Preamble
+         \theoremstyle{definition}
+         %%Delete [section] for sequential numbering
+         \newtheorem{xca}[section]{Exercise}
+       EndPreamble
+End
+
+
+Style Exercise*
+       CopyStyle             Definition*
+       LatexName             xca
+       LabelString           "Exercise."
+       Preamble
+         \theoremstyle{definition}
+         \newtheorem*{xca*}{Exercise}
+       EndPreamble
+End
+
+
+Style Remark
+       CopyStyle             Theorem
+       LatexName             rem
+       LabelString           "Remark \thetheorem."
+       Font
+         Shape               Up
+         Size                Normal
+       EndFont
+       LabelFont
+         Series              Medium
+         Shape               Italic
+       EndFont
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem{rem}[thm]{Remark}
+       EndPreamble
+End
+
+
+Style Remark*
+       CopyStyle             Remark
+       LatexName             rem*
+       LabelType             Static
+       LabelString           "Remark."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem*{rem*}{Remark}
+       EndPreamble
+End
+
+
+Style Claim
+       CopyStyle             Remark
+       LatexName             claim
+       LabelString           "Claim \thetheorem."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem{claim}[thm]{Claim}
+       EndPreamble
+End
+
+
+Style Claim*
+       CopyStyle             Remark*
+       LatexName             claim*
+       LabelString           "Claim."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem*{claim*}{Claim}
+       EndPreamble
+End
+
+
+Style Note
+       CopyStyle             Remark
+       LatexName             note
+       LabelString           "Note \thetheorem."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem{note}[thm]{Note}
+       EndPreamble
+End
+
+
+Style Note*
+       CopyStyle             Remark*
+       LatexName             note*
+       LabelString           "Note."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem*{note*}{Note}
+       EndPreamble
+End
+
+
+Style Notation
+       CopyStyle             Remark
+       LatexName             notation
+       LabelString           "Notation \thetheorem."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem{notation}[thm]{Notation}
+       EndPreamble
+End
+
+
+Style Notation*
+       CopyStyle             Remark*
+       LatexName             notation*
+       LabelString           "Notation."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem*{notation*}[thm]{Notation}
+       EndPreamble
+End
+
+
+Style Summary
+       CopyStyle             Remark
+       LatexName             summary
+       LabelString           "Summary \thetheorem."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem{summary}[thm]{Summary}
+       EndPreamble
+End
+
+
+Style Acknowledgement
+       CopyStyle             Remark
+       LatexName             acknowledgement
+       LabelString           "Acknowledgement \thetheorem."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem{acknowledgement}[thm]{Acknowledgement}
+       EndPreamble
+End
+
+
+Style Acknowledgement*
+       CopyStyle             Remark*
+       LatexName             acknowledgement*
+       LabelString           "Acknowledgement."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem*{acknowledgement*}{Acknowledgement}
+       EndPreamble
+End
+
+
+Style Case
+       CopyStyle             Remark
+       LatexName             case
+       LabelString           "Case \thetheorem."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem{case}{Case} %%Numbering of Cases not keyed to sections
+       EndPreamble
+End
+
+
+Style Conclusion
+       CopyStyle             Remark
+       LatexName             conclusion
+       LabelString           "Conclusion \thetheorem."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem{conclusion}[thm]{Conclusion}
+       EndPreamble
+End
+
+
+Style Conclusion*
+       CopyStyle             Remark*
+       LatexName             conclusion*
+       LabelString           "Conclusion."
+       Preamble
+         \theoremstyle{remark}
+         \newtheorem*{conclusion*}{Conclusion}
+       EndPreamble
+End
+
+
+Style Proof
+       Margin                First_Dynamic
+       LatexType             Environment
+       LatexName             proof
+       NextNoIndent          1
+       LabelSep              xx
+       ParIndent             MMM
+       ParSkip               0.4
+       ItemSep               0.2
+       TopSep                0.7
+       BottomSep             0.7
+       ParSep                0.3
+       Align                 Block
+       AlignPossible         Block, Left
+       LabelType             Static
+       LabelString           "Proof."
+       EndLabelType          Box
+       Font
+         Shape               Up
+         Size                Normal
+       EndFont
+       LabelFont
+         Shape               Italic
+       EndFont
+       # We don't want the preamble from Theorem
+       Preamble
+       EndPreamble
+End
+
+
diff --git a/lib/layouts/theorems-std.module b/lib/layouts/theorems-std.module
new file mode 100644 (file)
index 0000000..95999b2
--- /dev/null
@@ -0,0 +1,186 @@
+#\DeclareLyXModule{Defines some theorem environments for use with non-AMS classes. The theorems are numbered consecutively throughout the document.}{Theorems}
+
+# Author: Richard Heck <rgheck@comcast.net>
+# Adapted from amsmaths.inc
+
+# The environnements defined are :
+# - Theorem
+# - Corollary
+# - Lemma
+# - Proposition
+# - Conjecture
+# - Definition
+# - Example
+# - Exercise
+# - Remark
+# - Note
+# - Claim
+# - Case
+# - Conclusion
+# - Fact
+
+Format 5
+
+Counter
+       Name                 theorem
+End
+
+
+Style Theorem
+       Margin                First_Dynamic
+       LatexType             Environment
+       LatexName             thm
+       NextNoIndent          1
+       LabelSep              xx
+       ParIndent             MMM
+       ParSkip               0.4
+       ItemSep               0.2
+       TopSep                0.7
+       BottomSep             0.7
+       ParSep                0.3
+       Align                 Block
+       AlignPossible         Block, Left
+       LabelType             Counter
+       LabelCounter          theorem
+       LabelString           "Theorem \arabic{theorem}."
+       Font
+         Shape               Italic
+         Size                Normal
+       EndFont
+       LabelFont
+         Shape               Up
+         Series              Bold
+       EndFont
+       Preamble
+               \newtheorem{thm}{Theorem}
+       EndPreamble
+End
+
+Style Corollary
+       CopyStyle             Theorem
+       LatexName             cor
+       LabelString           "Corollary \thetheorem."
+       Preamble
+         \newtheorem{cor}[thm]{Corollary}
+       EndPreamble
+End
+
+Style Lemma
+       CopyStyle             Theorem
+       LatexName             lem
+       LabelString           "Lemma \thetheorem."
+       Preamble
+         \newtheorem{lem}[thm]{Lemma}
+       EndPreamble
+End
+
+Style Proposition
+       CopyStyle             Theorem
+       LatexName             prop
+       LabelString           "Proposition \thetheorem."
+       Preamble
+         \newtheorem{prop}[thm]{Proposition}
+       EndPreamble
+End
+
+Style Conjecture
+       CopyStyle             Theorem
+       LatexName             conjecture
+       LabelString           "Conjecture \thetheorem."
+       Preamble
+         \newtheorem{conjecture}[thm]{Conjecture}
+       EndPreamble
+End
+
+Style Fact
+       CopyStyle             Theorem
+       LatexName             fact
+       LabelString           "Fact \thetheorem."
+       Preamble
+         \newtheorem{fact}[thm]{Fact}
+       EndPreamble
+End
+
+Style Definition
+       CopyStyle             Theorem
+       LatexName             defn
+       LabelString           "Definition \thetheorem."
+       Font
+         Shape               Up
+       EndFont
+       LabelFont
+         Shape               Up
+         Series              Bold
+       EndFont
+       Preamble
+         \newtheorem{defn}[thm]{Definition}
+       EndPreamble
+End
+
+
+Style Example
+       CopyStyle             Definition
+       LatexName             example
+       LabelString           "Example \thetheorem."
+       Preamble
+         \newtheorem{example}[thm]{Example}
+       EndPreamble
+End
+
+
+Style Exercise
+       CopyStyle             Definition
+       LatexName             xca
+       LabelString           "Exercise \thetheorem."
+       Preamble
+         \newtheorem{xca}{Exercise}
+       EndPreamble
+End
+
+
+Style Remark
+       CopyStyle             Theorem
+       LatexName             rem
+       LabelString           "Remark \thetheorem."
+       Font
+         Shape               Up
+         Size                Normal
+       EndFont
+       LabelFont
+         Series              Medium
+         Shape               Italic
+       EndFont
+       Preamble
+         \newtheorem{rem}[thm]{Remark}
+       EndPreamble
+End
+
+
+Style Claim
+       CopyStyle             Remark
+       LatexName             claim
+       LabelString           "Claim \thetheorem."
+       Preamble
+         \newtheorem{claim}[thm]{Claim}
+       EndPreamble
+End
+
+Style Case
+       CopyStyle             Remark
+       LatexName             case
+       LabelString           "Case \thetheorem."
+       Preamble
+         \newtheorem{case}[thm]{Case}
+       EndPreamble
+End
+
+
+Style Conclusion
+       CopyStyle             Remark
+       LatexName             conclusion
+       LabelString           "Conclusion \thetheorem."
+       Preamble
+         \newtheorem{conclusion}[thm]{Conclusion}
+       EndPreamble
+End
+
diff --git a/lib/layouts/theorems-withinchap.module b/lib/layouts/theorems-withinchap.module
new file mode 100644 (file)
index 0000000..644f29f
--- /dev/null
@@ -0,0 +1,187 @@
+#\DeclareLyXModule{Defines some theorem environments for use with non-AMS classes. The theorems are numbered within chapters of the document. This module should therefore be used only with document classes that define a chapter environment.}{Theorems (By Chapter)}
+
+# Author: Richard Heck <rgheck@comcast.net>
+# Adapted from amsmaths.inc
+
+# The environnements defined are :
+# - Theorem
+# - Corollary
+# - Lemma
+# - Proposition
+# - Conjecture
+# - Definition
+# - Example
+# - Exercise
+# - Remark
+# - Note
+# - Claim
+# - Case
+# - Conclusion
+# - Fact
+
+Format 5
+
+Counter
+       Name           theorem
+       Within         chapter
+End
+
+
+Style Theorem
+       Margin                First_Dynamic
+       LatexType             Environment
+       LatexName             thm
+       NextNoIndent          1
+       LabelSep              xx
+       ParIndent             MMM
+       ParSkip               0.4
+       ItemSep               0.2
+       TopSep                0.7
+       BottomSep             0.7
+       ParSep                0.3
+       Align                 Block
+       AlignPossible         Block, Left
+       LabelType             Counter
+       LabelCounter          theorem
+       LabelString           "Theorem \thechapter.\thetheorem."
+       Font
+         Shape               Italic
+         Size                Normal
+       EndFont
+       LabelFont
+         Shape               Up
+         Series              Bold
+       EndFont
+       Preamble
+               \newtheorem{thm}{Theorem}[chapter]
+       EndPreamble
+End
+
+Style Corollary
+       CopyStyle             Theorem
+       LatexName             cor
+       LabelString           "Corollary \thechapter.\thetheorem."
+       Preamble
+         \newtheorem{cor}[thm]{Corollary}
+       EndPreamble
+End
+
+Style Lemma
+       CopyStyle             Theorem
+       LatexName             lem
+       LabelString           "Lemma \thechapter.\thetheorem."
+       Preamble
+         \newtheorem{lem}[thm]{Lemma}
+       EndPreamble
+End
+
+Style Proposition
+       CopyStyle             Theorem
+       LatexName             prop
+       LabelString           "Proposition \thechapter.\thetheorem."
+       Preamble
+         \newtheorem{prop}[thm]{Proposition}
+       EndPreamble
+End
+
+Style Conjecture
+       CopyStyle             Theorem
+       LatexName             conjecture
+       LabelString           "Conjecture \thechapter.\thetheorem."
+       Preamble
+         \newtheorem{conjecture}[thm]{Conjecture}
+       EndPreamble
+End
+
+Style Fact
+       CopyStyle             Theorem
+       LatexName             fact
+       LabelString           "Fact \thechapter.\thetheorem."
+       Preamble
+         \newtheorem{fact}[thm]{Fact}
+       EndPreamble
+End
+
+Style Definition
+       CopyStyle             Theorem
+       LatexName             defn
+       LabelString           "Definition \thechapter.\thetheorem."
+       Font
+         Shape               Up
+       EndFont
+       LabelFont
+         Shape               Up
+         Series              Bold
+       EndFont
+       Preamble
+         \newtheorem{defn}[thm]{Definition}
+       EndPreamble
+End
+
+
+Style Example
+       CopyStyle             Definition
+       LatexName             example
+       LabelString           "Example \thechapter.\thetheorem."
+       Preamble
+         \newtheorem{example}[thm]{Example}
+       EndPreamble
+End
+
+
+Style Exercise
+       CopyStyle             Definition
+       LatexName             xca
+       LabelString           "Exercise \thechapter.\thetheorem."
+       Preamble
+         \newtheorem{xca}{Exercise}
+       EndPreamble
+End
+
+
+Style Remark
+       CopyStyle             Theorem
+       LatexName             rem
+       LabelString           "Remark \thechapter.\thetheorem."
+       Font
+         Shape               Up
+         Size                Normal
+       EndFont
+       LabelFont
+         Series              Medium
+         Shape               Italic
+       EndFont
+       Preamble
+         \newtheorem{rem}[thm]{Remark}
+       EndPreamble
+End
+
+
+Style Claim
+       CopyStyle             Remark
+       LatexName             claim
+       LabelString           "Claim \thechapter.\thetheorem."
+       Preamble
+         \newtheorem{claim}[thm]{Claim}
+       EndPreamble
+End
+
+Style Case
+       CopyStyle             Remark
+       LatexName             case
+       LabelString           "Case \thechapter.\thetheorem."
+       Preamble
+         \newtheorem{case}[thm]{Case}
+       EndPreamble
+End
+
+
+Style Conclusion
+       CopyStyle             Remark
+       LatexName             conclusion
+       LabelString           "Conclusion \thechapter.\thetheorem."
+       Preamble
+         \newtheorem{conclusion}[thm]{Conclusion}
+       EndPreamble
+End
+
diff --git a/lib/layouts/theorems-withinsec.module b/lib/layouts/theorems-withinsec.module
new file mode 100644 (file)
index 0000000..a0cf013
--- /dev/null
@@ -0,0 +1,187 @@
+#\DeclareLyXModule{Defines some theorem environments for use with non-AMS classes. The theorems are numbered within sections of the document.}{Theorems (By Section)}
+
+# Author: Richard Heck <rgheck@comcast.net>
+# Adapted from amsmaths.inc
+
+# The environnements defined are :
+# - Theorem
+# - Corollary
+# - Lemma
+# - Proposition
+# - Conjecture
+# - Definition
+# - Example
+# - Exercise
+# - Remark
+# - Note
+# - Claim
+# - Case
+# - Conclusion
+# - Fact
+
+Format 5
+
+Counter
+       Name           theorem
+       Within         section
+End
+
+
+Style Theorem
+       Margin                First_Dynamic
+       LatexType             Environment
+       LatexName             thm
+       NextNoIndent          1
+       LabelSep              xx
+       ParIndent             MMM
+       ParSkip               0.4
+       ItemSep               0.2
+       TopSep                0.7
+       BottomSep             0.7
+       ParSep                0.3
+       Align                 Block
+       AlignPossible         Block, Left
+       LabelType             Counter
+       LabelCounter          theorem
+       LabelString           "Theorem \thetheorem."
+       Font
+         Shape               Italic
+         Size                Normal
+       EndFont
+       LabelFont
+         Shape               Up
+         Series              Bold
+       EndFont
+       Preamble
+               \newtheorem{thm}{Theorem}[section]
+       EndPreamble
+End
+
+Style Corollary
+       CopyStyle             Theorem
+       LatexName             cor
+       LabelString           "Corollary \thetheorem."
+       Preamble
+         \newtheorem{cor}[thm]{Corollary}
+       EndPreamble
+End
+
+Style Lemma
+       CopyStyle             Theorem
+       LatexName             lem
+       LabelString           "Lemma \thetheorem."
+       Preamble
+         \newtheorem{lem}[thm]{Lemma}
+       EndPreamble
+End
+
+Style Proposition
+       CopyStyle             Theorem
+       LatexName             prop
+       LabelString           "Proposition \thetheorem."
+       Preamble
+         \newtheorem{prop}[thm]{Proposition}
+       EndPreamble
+End
+
+Style Conjecture
+       CopyStyle             Theorem
+       LatexName             conjecture
+       LabelString           "Conjecture \thetheorem."
+       Preamble
+         \newtheorem{conjecture}[thm]{Conjecture}
+       EndPreamble
+End
+
+Style Fact
+       CopyStyle             Theorem
+       LatexName             fact
+       LabelString           "Fact \thetheorem."
+       Preamble
+         \newtheorem{fact}[thm]{Fact}
+       EndPreamble
+End
+
+Style Definition
+       CopyStyle             Theorem
+       LatexName             defn
+       LabelString           "Definition \thetheorem."
+       Font
+         Shape               Up
+       EndFont
+       LabelFont
+         Shape               Up
+         Series              Bold
+       EndFont
+       Preamble
+         \newtheorem{defn}[thm]{Definition}
+       EndPreamble
+End
+
+
+Style Example
+       CopyStyle             Definition
+       LatexName             example
+       LabelString           "Example \thetheorem."
+       Preamble
+         \newtheorem{example}[thm]{Example}
+       EndPreamble
+End
+
+
+Style Exercise
+       CopyStyle             Definition
+       LatexName             xca
+       LabelString           "Exercise \thetheorem."
+       Preamble
+         \newtheorem{xca}{Exercise}
+       EndPreamble
+End
+
+
+Style Remark
+       CopyStyle             Theorem
+       LatexName             rem
+       LabelString           "Remark \thetheorem."
+       Font
+         Shape               Up
+         Size                Normal
+       EndFont
+       LabelFont
+         Series              Medium
+         Shape               Italic
+       EndFont
+       Preamble
+         \newtheorem{rem}[thm]{Remark}
+       EndPreamble
+End
+
+
+Style Claim
+       CopyStyle             Remark
+       LatexName             claim
+       LabelString           "Claim \thetheorem."
+       Preamble
+         \newtheorem{claim}[thm]{Claim}
+       EndPreamble
+End
+
+Style Case
+       CopyStyle             Remark
+       LatexName             case
+       LabelString           "Case \thetheorem."
+       Preamble
+         \newtheorem{case}[thm]{Case}
+       EndPreamble
+End
+
+
+Style Conclusion
+       CopyStyle             Remark
+       LatexName             conclusion
+       LabelString           "Conclusion \thetheorem."
+       Preamble
+         \newtheorem{conclusion}[thm]{Conclusion}
+       EndPreamble
+End
+
diff --git a/lib/layouts/url.module b/lib/layouts/url.module
new file mode 100644 (file)
index 0000000..ab12968
--- /dev/null
@@ -0,0 +1,15 @@
+#\DeclareLyXModule[url.sty]{Adds a character style for the \url command.}{URL}
+
+Format 4
+
+InsetLayout URL
+  LyXType charstyle
+  LatexType    command
+  LatexName url
+  Font
+       Family Typewriter
+  EndFont
+  Preamble
+    \usepackage{url}
+  EndPreamble
+End
index 69ca80e2a08d49af74af0f337af0554220de1b6c..f44ef070168de0febabb989e90de3f5890d7aa2d 100644 (file)
@@ -78,7 +78,7 @@ format_relation = [("0_06",    [200], generate_minor_versions("0.6" , 4)),
                    ("1_3",     [221], generate_minor_versions("1.3" , 7)),
                    ("1_4", range(222,246), generate_minor_versions("1.4" , 5)),
                    ("1_5", range(246,277), generate_minor_versions("1.5" , 1)),
-                   ("1_6", range(277,281), generate_minor_versions("1.6" , 0))]
+                   ("1_6", range(277,282), generate_minor_versions("1.6" , 0))]
 
 
 def formats_list():
index 9541e4cfe6bfd3ad60a48386128e91b6f8ad7bd1..693cbf913ecb718123f87e465ddf3f32d4ae502c 100644 (file)
@@ -31,6 +31,7 @@ def find_end_of_inset(lines, i):
     " Find end of inset, where lines[i] is included."
     return find_end_of(lines, i, "\\begin_inset", "\\end_inset")
 
+
 ####################################################################
 
 def fix_wrong_tables(document):
@@ -142,6 +143,17 @@ def revert_show_label(document):
                 document.warning("Malformed LyX document: no legal status line in CharStyle.")
         i += 1
 
+def revert_begin_modules(document):
+    i = 0
+    while True:
+        i = find_token(document.header, "\\begin_modules", i)
+        if i == -1:
+            return
+        j = find_end_of(document.header, i, "\\begin_modules", "\\end_modules")
+        if j == -1:
+            # this should not happen
+            break
+        document.header[i : j + 1] = []
 
 
 ##
@@ -153,10 +165,12 @@ convert = [
            [277, [fix_wrong_tables]],
            [278, [close_begin_deeper]],
            [279, [long_charstyle_names]],
-           [280, [axe_show_label]]
+           [280, [axe_show_label]],
+           [281, []]
           ]
 
 revert =  [
+           [280, [revert_begin_modules]],
            [279, [revert_show_label]],
            [278, [revert_long_charstyle_names]],
            [277, []],
index abcad36f9b164bad0b51b37bb8cec5ead2160aa4..f363d1c40e3fefe0fa6cff1759c15cffdac0ff96 100644 (file)
@@ -139,7 +139,7 @@ namespace fs = boost::filesystem;
 
 namespace {
 
-int const LYX_FORMAT = 280;
+int const LYX_FORMAT = 281;
 
 } // namespace anon
 
@@ -440,6 +440,7 @@ int Buffer::readHeader(Lexer & lex)
        params().headsep.erase();
        params().footskip.erase();
        params().listings_params.clear();
+       params().clearLayoutModules();
        
        for (int i = 0; i < 4; ++i) {
                params().user_defined_bullet(i) = ITEMIZE_DEFAULTS[i];
index bc18c35e7e146ad1d75b11ca37ad678b6c4b7000..f78a1203402f6b78404f54a61d13b6b4abc4a6a9 100644 (file)
@@ -27,6 +27,7 @@
 #include "Language.h"
 #include "LaTeXFeatures.h"
 #include "Messages.h"
+#include "ModuleList.h"
 #include "Color.h"
 #include "Font.h"
 #include "Lexer.h"
@@ -41,6 +42,7 @@
 #include "insets/InsetListingsParams.h"
 
 #include "support/convert.h"
+#include "support/filetools.h"
 #include "support/Translator.h"
 
 #include <boost/array.hpp>
@@ -55,7 +57,9 @@ using std::istringstream;
 using std::ostream;
 using std::ostringstream;
 using std::pair;
-
+using std::string;
+using lyx::support::FileName;
+using lyx::support::libFileSearch;
 using lyx::support::bformat;
 using lyx::support::rtrim;
 using lyx::support::tokenPos;
@@ -472,9 +476,13 @@ string const BufferParams::readToken(Lexer & lex, string const & token)
                                                 "for more information.\n"), from_utf8(classname));
                        frontend::Alert::warning(_("Document class not available"),
                                       msg + _("LyX will not be able to produce output."));
-               }
+               } 
+               
        } else if (token == "\\begin_preamble") {
                readPreamble(lex);
+       } else if (token == "\\begin_modules") {
+               readModules(lex);
+               makeTextClass();
        } else if (token == "\\options") {
                lex.eatLine();
                options = lex.getString();
@@ -625,6 +633,8 @@ string const BufferParams::readToken(Lexer & lex, string const & token)
        } else if (token == "\\float_placement") {
                lex >> float_placement;
        } else {
+               lyxerr << "BufferParams::readToken(): Unknown token: " << 
+                       token << endl;
                return token;
        }
 
@@ -653,6 +663,15 @@ void BufferParams::writeFile(ostream & os) const
        if (!options.empty()) {
                os << "\\options " << options << '\n';
        }
+       
+       //the modules
+       if (!layoutModules_.empty()) {
+               os << "\\begin_modules" << '\n';
+               LayoutModuleList::const_iterator it = layoutModules_.begin();
+               for (; it != layoutModules_.end(); it++)
+                       os << *it << '\n';
+               os << "\\end_modules" << '\n';
+       }
 
        // then the text parameters
        if (language != ignore_language)
@@ -1227,6 +1246,68 @@ textclass_type BufferParams::getBaseClass() const
 void BufferParams::makeTextClass()
 {
        textClass_.reset(new TextClass(textclasslist[getBaseClass()]));
+       //FIXME It might be worth loading the children's modules here,
+       //instead of just doing a check in InsetInclude.
+       LayoutModuleList::const_iterator it = layoutModules_.begin();
+       for (; it != layoutModules_.end(); it++) {
+               string const modName = *it;
+               LyXModule * lm = moduleList[modName];
+               if (!lm) {
+                       docstring const msg =
+                                               bformat(_("The module %1$s has been requested by\n"
+                                               "this document but has not been found in the list of\n"
+                                               "available modules. If you recently installed it, you\n"
+                                               "probalby need to reconfigure LyX.\n"), from_utf8(modName));
+                       frontend::Alert::warning(_("Module not available"),
+                                                                                                                        msg + _("Some layouts may not be available."));
+                       lyxerr << "BufferParams::makeTextClass(): Module " <<
+                                       modName << " requested but not found in module list." <<
+                                       endl;
+                       continue;
+               }
+               FileName layout_file = libFileSearch("layouts", lm->filename);
+               textClass_->read(layout_file, TextClass::MODULE);
+       }
+}
+
+
+std::vector<string> const & BufferParams::getModules() const {
+       return layoutModules_;
+}
+
+
+
+bool BufferParams::addLayoutModule(string modName, bool makeClass) {
+       LayoutModuleList::const_iterator it = layoutModules_.begin();
+       LayoutModuleList::const_iterator end = layoutModules_.end();
+       for (; it != end; it++) {
+               if (*it == modName) 
+                       break;
+       }
+       if (it != layoutModules_.end())
+               return false;
+       layoutModules_.push_back(modName);
+       if (makeClass)
+               makeTextClass();
+       return true;
+}
+
+
+bool BufferParams::addLayoutModules(std::vector<string>modNames)
+{
+       bool retval = true;
+       std::vector<string>::const_iterator it = modNames.begin();
+       std::vector<string>::const_iterator end = modNames.end();
+       for (; it != end; ++it)
+               retval &= addLayoutModule(*it, false);
+       makeTextClass();
+       return retval;
+}
+
+
+void BufferParams::clearLayoutModules() {
+       layoutModules_.clear();
+       makeTextClass();
 }
 
 
@@ -1327,6 +1408,23 @@ void BufferParams::readBulletsLaTeX(Lexer & lex)
 }
 
 
+void BufferParams::readModules(Lexer & lex)
+{
+       if (!lex.eatLine()) {
+               lyxerr << "Error (BufferParams::readModules):"
+                               "Unexpected end of input." << endl;
+               return;
+       }
+       while (true) {
+               string mod = lex.getString();
+               if (mod == "\\end_modules")
+                       break;
+               addLayoutModule(mod);
+               lex.eatLine();
+       }
+}
+
+
 string const BufferParams::paperSizeName() const
 {
        char real_papersize = papersize;
index 56fd7249038d13adcdad25bd92838844ac41368d..dd2422ef5d0bcaad8c147e647a9f40fbb34c92cb 100644 (file)
@@ -122,6 +122,16 @@ public:
        /// Should be called with care and would be better not being here,
        /// but it seems to be needed by CutAndPaste::putClipboard().
        void setTextClass(TextClass_ptr);
+       /// List of modules in use
+       std::vector<std::string> const & getModules() const;
+       /// Add a module to the list of modules in use.
+       /// Returns true if module was successfully added.
+       bool addLayoutModule(std::string modName, bool makeClass = true);
+       /// Add a list of modules.
+       /// Returns true if all modules were successfully added.
+       bool addLayoutModules(std::vector<std::string>modNames);
+       /// Clear the list
+       void clearLayoutModules();
 
        /// returns the main font for the buffer (document)
        Font const getFont() const;
@@ -291,6 +301,9 @@ private:
        void readBullets(Lexer &);
        ///
        void readBulletsLaTeX(Lexer &);
+       ///
+       void readModules(Lexer &);
+       /// Adds the module information to the baseClass information to
        /// create our local TextClass.
        void makeTextClass();
 
@@ -301,6 +314,10 @@ private:
        textclass_type baseClass_;
        /// the possibly modular TextClass actually in use
        TextClass_ptr textClass_;
+       ///
+       typedef std::vector<std::string> LayoutModuleList;
+       /// 
+       LayoutModuleList layoutModules_;
 
        /** Use the Pimpl idiom to hide those member variables that would otherwise
         *  drag in other header files.
index 4f3fd68881df798d6aeae8cc70646676f96cafa1..a778d4cb819529a293fc051db037c6e6847becb2 100644 (file)
@@ -36,6 +36,7 @@
 #include "LyXFunc.h"
 #include "Lexer.h"
 #include "LyXRC.h"
+#include "ModuleList.h"
 #include "Server.h"
 #include "ServerSocket.h"
 #include "TextClassList.h"
@@ -925,6 +926,8 @@ bool LyX::init()
        LYXERR(Debug::INIT) << "Reading layouts..." << endl;
        if (!LyXSetStyle())
                return false;
+       //...and the modules
+       moduleList.load();
 
        if (use_gui) {
                // Set the language defined by the user.
@@ -1114,6 +1117,7 @@ bool LyX::queryUserLyXDir(bool explicit_userdir)
                first_start = false;
 
                return needsUpdate("lyxrc.defaults")
+                       || needsUpdate("lyxmodules.lst")
                        || needsUpdate("textclass.lst")
                        || needsUpdate("packages.lst");
        }
index 8466e447ca72307e64e8e45579e504e6aa11bdc6..fcdb81b8c10839dbf8914eca7c0f37382d1319f0 100644 (file)
@@ -372,6 +372,8 @@ void LyXAction::init()
                { LFUN_CLEARPAGE_INSERT, "clearpage-insert", Noop },
                { LFUN_CLEARDOUBLEPAGE_INSERT, "cleardoublepage-insert", Noop },
                { LFUN_LISTING_INSERT, "listing-insert", Noop },
+               { LFUN_LAYOUT_MODULES_CLEAR, "layout-modules-clear", Noop },
+               { LFUN_LAYOUT_MODULE_ADD, "layout-module-add", Noop },
 
                { LFUN_NOACTION, "", Noop }
        };
index 28d9b4ad2c45891a564999a0c9a91f14debdb969..19f29fc80b10b4800ff257e120bb4f6454f7dbcc 100644 (file)
@@ -729,6 +729,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        case LFUN_TEXTCLASS_LOAD:
        case LFUN_BUFFER_SAVE_AS_DEFAULT:
        case LFUN_BUFFER_PARAMS_APPLY:
+       case LFUN_LAYOUT_MODULES_CLEAR:
+       case LFUN_LAYOUT_MODULE_ADD:
        case LFUN_LYXRC_APPLY:
        case LFUN_BUFFER_NEXT:
        case LFUN_BUFFER_PREVIOUS:
@@ -1772,6 +1774,20 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                        it->dispatch(cur, fr);
                        break;
                }
+               
+               case LFUN_LAYOUT_MODULES_CLEAR: {
+                       BOOST_ASSERT(lyx_view_);
+                       lyx_view_->buffer()->params().clearLayoutModules();
+                       updateFlags = Update::Force;
+                       break;
+               }
+               
+               case LFUN_LAYOUT_MODULE_ADD: {
+                       BOOST_ASSERT(lyx_view_);
+                       lyx_view_->buffer()->params().addLayoutModule(argument);
+                       updateFlags = Update::Force;
+                       break;
+               }
 
                case LFUN_TEXTCLASS_APPLY: {
                        BOOST_ASSERT(lyx_view_);
index 0be8085ccd6a49d307d4dc18ada0d30557a5ddab..412073fc935872039daae0df78e5acec490061a0 100644 (file)
@@ -205,6 +205,8 @@ liblyxcore_la_SOURCES = \
        Messages.h \
        MetricsInfo.cpp \
        MetricsInfo.h \
+       ModuleList.cpp \
+       ModuleList.h \
        Mover.cpp \
        Mover.h \
        output.cpp \
diff --git a/src/ModuleList.cpp b/src/ModuleList.cpp
new file mode 100644 (file)
index 0000000..4ca1496
--- /dev/null
@@ -0,0 +1,157 @@
+// -*- C++ -*-
+/**
+ * \file ModuleList.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Richard Heck
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+#include "debug.h"
+#include "Lexer.h"
+#include "ModuleList.h"
+#include "support/filetools.h"
+#include "support/docstring.h"
+
+       
+namespace lyx{
+
+using std::map;
+using std::string;
+using std::vector;
+using std::endl;
+using support::FileName;
+using support::libFileSearch;
+using support::makeDisplayPath;
+
+//global variable: module list
+ModuleList moduleList;
+
+
+// used when sorting the module list.
+class moduleSorter
+       : public std::binary_function<LyXModule, LyXModule, int>
+{
+       public:
+               int operator()(LyXModule const & lm1,
+                                                                LyXModule const & lm2) const
+               {
+                       return (lm1.name < lm2.name);
+               }
+};
+
+
+//Much of this is borrowed from TextClassList::read()
+bool ModuleList::load() {
+       support::FileName const real_file = libFileSearch("", "lyxmodules.lst");
+       LYXERR(Debug::TCLASS) << "Reading modules from `"
+                       << real_file << '\'' << endl;
+
+       if (real_file.empty()) {
+               lyxerr << "ModuleList::load(): unable to find "
+                               "modules file  `"
+                               << to_utf8(makeDisplayPath(real_file.absFilename(), 1000))
+                               << "'.\nNo modules will be available." << endl;
+               return false;
+       }
+
+       Lexer lex(0, 0);
+       if (!lex.setFile(real_file)) {
+               lyxerr << "ModuleList::load():"
+                               "lyxlex was not able to set file: "
+                               << real_file << ".\nNo modules will be available." << endl;
+               return false;
+       }
+
+       if (!lex.isOK()) {
+               lyxerr << "ModuleList::load():" <<
+                               "unable to open modules file  `"
+                               << to_utf8(makeDisplayPath(real_file.absFilename(), 1000))
+                               << "'\nNo modules will be available."
+                               << endl;
+               return false;
+       }
+
+       bool finished = false;
+       // Parse modules files
+       LYXERR(Debug::TCLASS) << "Starting parsing of lyxmodules.lst" << endl;
+       while (lex.isOK() && !finished) {
+               LYXERR(Debug::TCLASS) << "\tline by line" << endl;
+               switch (lex.lex()) {
+               case Lexer::LEX_FEOF:
+                       finished = true;
+                       break;
+               default:
+                       string const modName = lex.getString();
+                       LYXERR(Debug::TCLASS) << "Module name: " << modName << endl;
+                       if (lex.next()) {
+                               string const fname = lex.getString();
+                               LYXERR(Debug::TCLASS) << "Filename: " << fname << endl;
+                               if (lex.next()) {
+                                       string const desc = lex.getString();
+                                       LYXERR(Debug::TCLASS) << "Description: " << desc << endl;
+                                       //FIXME Add package read, and availability
+                                       // This code is run when we have
+                                       // modName, fname, and desc
+                                       addLayoutModule(modName, fname, desc);
+                               }
+                       }
+               } // end switch
+       } //end while
+       
+       LYXERR(Debug::TCLASS) << "End of parsing of lyxmodules.lst" << endl;
+
+       if (!moduleList.empty())
+               sort(moduleList.begin(), moduleList.end(), moduleSorter());
+       return true;
+}
+
+
+void ModuleList::addLayoutModule(string moduleName, 
+               string filename, string description) {
+       LyXModule lm;
+       lm.name = moduleName;
+       lm.filename = filename;
+       lm.description = description;
+       modlist_.push_back(lm);
+}
+
+
+LyXModuleList::const_iterator ModuleList::begin() const
+{
+       return modlist_.begin();
+}
+
+
+LyXModuleList::iterator ModuleList::begin()
+{
+       return modlist_.begin();
+}
+
+
+LyXModuleList::const_iterator ModuleList::end() const
+{
+       return modlist_.end();
+}
+
+
+LyXModuleList::iterator ModuleList::end()
+{
+       return modlist_.end();
+}
+
+
+LyXModule * ModuleList::operator[](string const str) {
+       LyXModuleList::iterator it = modlist_.begin();
+       for (; it != modlist_.end(); ++it)
+               if (it->name == str) {
+                       LyXModule & mod = *it;
+                       return &mod;
+               }
+       return 0;
+}
+
+}
diff --git a/src/ModuleList.h b/src/ModuleList.h
new file mode 100644 (file)
index 0000000..29931fd
--- /dev/null
@@ -0,0 +1,74 @@
+// -*- C++ -*-
+/**
+ * \file ModuleList.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Richard Heck
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef MODULELIST_H
+#define MODULELIST_H
+
+#include <vector>
+#include "support/FileName.h"
+
+#include <boost/utility.hpp>
+
+#include <map>
+
+namespace lyx {
+       
+       /**
+        *  This struct represents a particular LyX "module", which is a like a layout
+        *  file, except that it does not stand alone. In that sense, it is more like 
+        *  a LaTeX package, where a layout file corresponds to a LaTeX class.
+        */
+       struct LyXModule {
+               /// what appears in the ui
+               std::string name;
+               /// the filename, without any path
+               std::string filename;
+               /// a short description for use in the ui
+               std::string description;
+               /// the LaTeX packages on which this depends, if any (not implemented)
+               //std::vector<std::string> packageList;
+               /// whether those packages are available (not implemented yet)
+               //bool available;
+       };
+       
+       typedef std::vector<LyXModule> LyXModuleList;
+       
+       /**
+        *  The ModuleList represents the various LyXModule's that are available at
+        *  present.
+        */
+       class ModuleList : boost::noncopyable {
+               public:
+                       /// reads the modules from a file generated by configure.py
+                       bool load();
+                       /// add a module to the list
+                       void addLayoutModule(std::string name, std::string filename, 
+                                            std::string description);
+                       ///
+                       LyXModuleList::const_iterator begin() const;
+                       ///
+                       LyXModuleList::iterator begin();
+                       ///
+                       LyXModuleList::const_iterator end() const;
+                       ///
+                       LyXModuleList::iterator end();
+                       ///
+                       bool empty() { return modlist_.empty(); };
+                       /// Returns a pointer to the LyXModule with name str.
+                       /// Returns a null pointer if no such module is found.
+                       LyXModule * operator[](std::string str);
+               private:
+                       std::vector<LyXModule> modlist_;
+       };
+
+       extern ModuleList moduleList;
+}
+#endif
index 3e6b75fa83d0d1a2827f9a5c9cd9b6b5449f3ccc..dcff59a94541f8fbee64476934181882ea61b028 100644 (file)
@@ -107,6 +107,7 @@ TextClass::TextClass(string const & fn, string const & cln,
          floatlist_(new FloatList), counters_(new Counters),
          texClassAvail_(texClassAvail)
 {
+       modular_ = false;
        outputType_ = LATEX;
        columns_ = 1;
        sides_ = OneSide;
@@ -173,7 +174,7 @@ enum TextClassTags {
 
 
 // Reads a textclass structure from file.
-bool TextClass::read(FileName const & filename, bool merge)
+bool TextClass::read(FileName const & filename, ReadType rt)
 {
        if (!support::isFileReadable(filename)) {
                lyxerr << "Cannot read layout file `" << filename << "'."
@@ -208,14 +209,21 @@ bool TextClass::read(FileName const & filename, bool merge)
                { "tocdepth",        TC_TOCDEPTH }
        };
 
-       if (!merge)
-               LYXERR(Debug::TCLASS) << "Reading textclass "
-                                     << to_utf8(makeDisplayPath(filename.absFilename()))
-                                     << endl;
-       else
-               LYXERR(Debug::TCLASS) << "Reading input file "
-                                     << to_utf8(makeDisplayPath(filename.absFilename()))
-                                     << endl;
+       switch (rt) {
+       case BASECLASS:
+               LYXERR(Debug::TCLASS) << "Reading textclass ";
+               break;
+       case MERGE:
+               LYXERR(Debug::TCLASS) << "Reading input file ";
+         break;
+       case MODULE:
+               LYXERR(Debug::TCLASS) << "Reading module file ";
+               break;
+       default:
+               BOOST_ASSERT(false);
+       }
+       LYXERR(Debug::TCLASS) << to_utf8(makeDisplayPath(filename.absFilename()))
+               << endl;
 
        Lexer lexrc(textClassTags,
                sizeof(textClassTags) / sizeof(textClassTags[0]));
@@ -264,7 +272,7 @@ bool TextClass::read(FileName const & filename, bool merge)
                                        lexrc.printError("Could not find input"
                                                         "file: " + inc);
                                        error = true;
-                               } else if (read(tmp, true)) {
+                               } else if (read(tmp, MERGE)) {
                                        lexrc.printError("Error reading input"
                                                         "file: " + tmp.absFilename());
                                        error = true;
@@ -441,12 +449,20 @@ bool TextClass::read(FileName const & filename, bool merge)
                FileName const tempfile(support::tempName());
                error = !layout2layout(filename, tempfile);
                if (!error)
-                       error = read(tempfile, merge);
+                       error = read(tempfile, rt);
                support::unlink(tempfile);
                return error;
        }
 
-       if (!merge) { // we are at top level here.
+       if (rt == MODULE) 
+               LYXERR(Debug::TCLASS) << "Finished reading module file "
+                               << to_utf8(makeDisplayPath(filename.absFilename()))
+                               << endl;
+       else if (rt == MERGE)
+               LYXERR(Debug::TCLASS) << "Finished reading input file "
+                               << to_utf8(makeDisplayPath(filename.absFilename()))
+                               << endl;
+       else { // we are at top level here.
                LYXERR(Debug::TCLASS) << "Finished reading textclass "
                                      << to_utf8(makeDisplayPath(filename.absFilename()))
                                      << endl;
@@ -476,10 +492,7 @@ bool TextClass::read(FileName const & filename, bool merge)
                        << "Minimum TocLevel is " << min_toclevel_
                        << ", maximum is " << max_toclevel_ <<endl;
 
-       } else
-               LYXERR(Debug::TCLASS) << "Finished reading input file "
-                                     << to_utf8(makeDisplayPath(filename.absFilename()))
-                                     << endl;
+       }
 
        return error;
 }
index 83436e35fdb8649c1d8e4070884e6e97537e9321..699dae557d020701a92c8dea56138f4558c463df 100644 (file)
@@ -64,8 +64,8 @@ public:
        TextClass(std::string const & = std::string(),
                     std::string const & = std::string(),
                     std::string const & = std::string(),
-                    bool = false);
-
+                    bool texClassAvail = false);
+       
        /// check whether the TeX class is available
        bool isTeXClassAvailable() const;
 
@@ -74,8 +74,14 @@ public:
        /// paragraph styles end iterator
        const_iterator end() const { return layoutlist_.end(); }
 
+       ///Enum used with TextClass::read
+       enum ReadType { 
+               BASECLASS, //>This is a base class, i.e., top-level layout file
+               MERGE, //>This is a file included in a layout file
+               MODULE //>This is a layout module
+       };
        /// Performs the read of the layout file.
-       bool read(support::FileName const & filename, bool merge = false);
+       bool read(support::FileName const & filename, ReadType rt = BASECLASS);
        ///
        void readOutputType(Lexer &);
        ///
@@ -128,6 +134,11 @@ public:
        ///
        std::string const & description() const;
        ///
+       bool isModular() const { return modular_; }
+       /// Sets the layout as a modular one. There is never any
+       /// need to reset this.
+       void markAsModular() { modular_ = true; }
+       ///
        std::string const & opt_fontsize() const;
        ///
        std::string const & opt_pagestyle() const;
@@ -195,11 +206,14 @@ private:
        std::string latexname_;
        /// document class description
        std::string description_;
-       /// Specific class options
+       /// whether this is a modular layout, i.e., whether it has been
+       /// modified by loading of layout modules.
+       bool modular_;
+       ///
        std::string opt_fontsize_;
        ///
        std::string opt_pagestyle_;
-       ///
+       /// Specific class options
        std::string options_;
        ///
        std::string pagestyle_;
index 8ad44093aa7f13b8da28c8d7effee4d6588c58eb..b693079bf124953303eba69254d93bfee8995b9a 100644 (file)
@@ -493,6 +493,26 @@ int InsetInclude::latex(Buffer const & buffer, odocstream & os,
                        Alert::warning(_("Different textclasses"), text);
                        //return 0;
                }
+               
+               // Make sure modules used in child are all included in master
+               //FIXME It might be worth loading the children's modules into the master
+               //over in BufferParams rather than doing this check.
+               vector<string> const masterModules = m_buffer->params().getModules();
+               vector<string> const childModules = tmp->params().getModules();
+               vector<string>::const_iterator it = childModules.begin();
+               vector<string>::const_iterator end = childModules.end();
+               for (; it != end; ++it) {
+                       string const module = *it;
+                       vector<string>::const_iterator found = 
+                               find(masterModules.begin(), masterModules.end(), module);
+                       if (found != masterModules.end()) {
+                               docstring text = bformat(_("Included file `%1$s'\n"
+                                                       "uses module `%2$s'\n"
+                                                       "which is not used in parent file."),
+                                      makeDisplayPath(included_file.absFilename()), from_utf8(module));
+                               Alert::warning(_("Module not found"), text);
+                       }
+               }
 
                tmp->markDepClean(m_buffer->temppath());
 
index 7d4162f1e899dead655c87f2f1b8955ec26a4e92..b9c06a977428e64b963af0ec1dca2199f2ace15f 100644 (file)
@@ -400,6 +400,8 @@ enum kb_action {
        LFUN_BUFFER_WRITE_ALL,           // rgh, gpothier 200707XX
        //290
        LFUN_PARAGRAPH_PARAMS,           // rgh, 200708XX
+       LFUN_LAYOUT_MODULES_CLEAR,       // rgh, 20070825
+       LFUN_LAYOUT_MODULE_ADD,          // rgh, 20070825
 
        LFUN_LASTACTION                  // end of the table
 };