]> git.lyx.org Git - features.git/blobdiff - src/TextClass.cpp
Allow literate documents other than noweb to work out of the box. Currently
[features.git] / src / TextClass.cpp
index 3b45e8f8345bcb4303dd88d636385eca56b20434..de60bb1e964bac847ee3fdd284acc908b161c86d 100644 (file)
@@ -62,7 +62,7 @@ private:
 };
 
 // Keep the changes documented in the Customization manual. 
-int const FORMAT = 13;
+int const FORMAT = 15;
 
 
 bool layout2layout(FileName const & filename, FileName const & tempfile)
@@ -127,6 +127,7 @@ InsetLayout DocumentClass::plain_insetlayout_;
 TextClass::TextClass()
 {
        outputType_ = LATEX;
+       outputFormat_ = "latex";
        columns_ = 1;
        sides_ = OneSide;
        secnumdepth_ = 3;
@@ -160,6 +161,7 @@ bool TextClass::readStyle(Lexer & lexrc, Layout & lay) const
 
 enum TextClassTags {
        TC_OUTPUTTYPE = 1,
+       TC_OUTPUTFORMAT,
        TC_INPUT,
        TC_STYLE,
        TC_DEFAULTSTYLE,
@@ -208,6 +210,7 @@ namespace {
                { "leftmargin",      TC_LEFTMARGIN },
                { "nofloat",         TC_NOFLOAT },
                { "nostyle",         TC_NOSTYLE },
+               { "outputformat",    TC_OUTPUTFORMAT },
                { "outputtype",      TC_OUTPUTTYPE },
                { "pagestyle",       TC_PAGESTYLE },
                { "preamble",        TC_PREAMBLE },
@@ -232,17 +235,18 @@ bool TextClass::convertLayoutFormat(support::FileName const & filename, ReadType
        FileName const tempfile = FileName::tempName("convert_layout");
        bool success = layout2layout(filename, tempfile);
        if (success)
-               success = read(tempfile, rt);
+               success = readWithoutConv(tempfile, rt) == OK;
        tempfile.removeFile();
        return success;
 }
 
-bool TextClass::read(FileName const & filename, ReadType rt)
+
+TextClass::ReturnValues TextClass::readWithoutConv(FileName const & filename, ReadType rt)
 {
        if (!filename.isReadableFile()) {
                lyxerr << "Cannot read layout file `" << filename << "'."
                       << endl;
-               return false;
+               return ERROR;
        }
 
        LYXERR(Debug::TCLASS, "Reading " + translateRT(rt) + ": " +
@@ -260,10 +264,17 @@ bool TextClass::read(FileName const & filename, ReadType rt)
        
        LYXERR(Debug::TCLASS, "Finished reading " + translateRT(rt) + ": " +
                        to_utf8(makeDisplayPath(filename.absFilename())));
-       
-       if (retval != FORMAT_MISMATCH) 
+
+       return retval;
+}
+
+
+bool TextClass::read(FileName const & filename, ReadType rt)
+{
+       ReturnValues const retval = readWithoutConv(filename, rt);
+       if (retval != FORMAT_MISMATCH)
                return retval == OK;
-       
+
        bool const worx = convertLayoutFormat(filename, rt);
        if (!worx) {
                LYXERR0 ("Unable to convert " << filename << 
@@ -344,8 +355,24 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
                                format = lexrc.getInteger();
                        break;
 
-               case TC_OUTPUTTYPE:   // output type definition
+               case TC_OUTPUTFORMAT:
+                       if (lexrc.next())
+                               outputFormat_ = lexrc.getString();
+                       break;
+
+               case TC_OUTPUTTYPE:
                        readOutputType(lexrc);
+                       switch(outputType_) {
+                       case LATEX:
+                               outputFormat_ = "latex";
+                               break;
+                       case DOCBOOK:
+                               outputFormat_ = "docbook";
+                               break;
+                       case LITERATE:
+                               outputFormat_ = "literate";
+                               break;
+                       }
                        break;
 
                case TC_INPUT: // Include file