]> git.lyx.org Git - lyx.git/blobdiff - src/TextClass.cpp
HTML for stackrel.
[lyx.git] / src / TextClass.cpp
index 7adad256be7b3ad9aa856b58ae4279b270972c18..6bc0bc0c8e65aded738618c509014955e8c4588b 100644 (file)
@@ -66,7 +66,7 @@ private:
 };
 
 // Keep the changes documented in the Customization manual. 
-int const FORMAT = 25;
+int const FORMAT = 26;
 
 
 bool layout2layout(FileName const & filename, FileName const & tempfile)
@@ -197,7 +197,8 @@ enum TextClassTags {
        TC_DEFAULTMODULE,
        TC_PROVIDESMODULE,
        TC_EXCLUDESMODULE,
-       TC_HTMLTOCSECTION
+       TC_HTMLTOCSECTION,
+       TC_CITEFORMAT
 };
 
 
@@ -206,6 +207,7 @@ namespace {
        LexerKeyword textClassTags[] = {
                { "addtohtmlpreamble", TC_ADDTOHTMLPREAMBLE },
                { "addtopreamble",     TC_ADDTOPREAMBLE },
+               { "citeformat",        TC_CITEFORMAT },
                { "classoptions",      TC_CLASSOPTIONS },
                { "columns",           TC_COLUMNS },
                { "counter",           TC_COUNTER },
@@ -634,6 +636,10 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
                case TC_FLOAT:
                        readFloat(lexrc);
                        break;
+               
+               case TC_CITEFORMAT:
+                       readCiteFormat(lexrc);
+                       break;
 
                case TC_IFCOUNTER:
                        ifcounter = true;
@@ -846,6 +852,28 @@ void TextClass::readClassOptions(Lexer & lexrc)
 }
 
 
+void TextClass::readCiteFormat(Lexer & lexrc)
+{
+       string etype;
+       string definition;
+       while (lexrc.isOK()) {
+               lexrc.next();
+               etype = lexrc.getString();
+               if (!lexrc.isOK() || compare_ascii_no_case(etype, "end") == 0)
+                       break;
+               lexrc.eatLine();
+               definition = lexrc.getString();
+               char initchar = etype[0];
+               if (initchar == '#')
+                       continue;
+               if (initchar == '!' || initchar == '_')
+                       cite_macros_[etype] = definition;
+               else
+                       cite_formats_[etype] = definition;
+       }
+}
+
+
 void TextClass::readFloat(Lexer & lexrc)
 {
        enum {
@@ -1003,6 +1031,15 @@ void TextClass::readFloat(Lexer & lexrc)
 }
 
 
+string const & TextClass::prerequisites() const
+{ 
+       if (contains(prerequisites_, ',')) {
+               vector<string> const pres = getVectorFromString(prerequisites_);
+               prerequisites_ = getStringFromVector(pres, "\n\t");
+       }
+       return prerequisites_; 
+}
+
 bool TextClass::hasLayout(docstring const & n) const
 {
        docstring const name = n.empty() ? defaultLayoutName() : n;
@@ -1319,6 +1356,27 @@ Layout const & DocumentClass::htmlTOCLayout() const
 }
 
 
+string const & DocumentClass::getCiteFormat(string const & entry_type) const
+{
+       static string default_format = N_("{%author%[[%author%, ]][[{%editor%[[%editor%, ed., ]]}]]}\"%title%\"{%journal%[[, {!<i>!}%journal%{!</i>!}]][[{%publisher%[[, %publisher%]][[{%institution%[[, %institution%]]}]]}]]}{%year%[[ (%year%)]]}{%pages%[[, %pages%]]}.");
+       
+       map<string, string>::const_iterator it = cite_formats_.find(entry_type);
+       if (it != cite_formats_.end())
+               return it->second;
+       return default_format;
+}
+
+
+string const & DocumentClass::getCiteMacro(string const & macro) const
+{
+       static string empty;
+       map<string, string>::const_iterator it = cite_macros_.find(macro);
+       if (it != cite_macros_.end())
+               return it->second;
+       return empty;
+}
+
+
 /////////////////////////////////////////////////////////////////////////
 //
 // PageSides