]> git.lyx.org Git - features.git/commitdiff
Allow LyX format to be written to View>Source window.
authorRichard Heck <rgheck@lyx.org>
Tue, 5 Jun 2012 02:01:26 +0000 (22:01 -0400)
committerRichard Heck <rgheck@lyx.org>
Tue, 5 Jun 2012 14:24:15 +0000 (10:24 -0400)
src/Buffer.cpp
src/BufferParams.cpp
src/OutputParams.h
src/frontends/qt4/GuiViewSource.cpp
src/insets/InsetExternal.cpp

index c0723bea0584cadb231b28c1ef8a9369b6fd71c4..618b7d18a121a420f3ccd27e2091e935b831b1f4 100644 (file)
@@ -3317,7 +3317,13 @@ void Buffer::getSourceCode(odocstream & os, string const format,
                           << "\n\n";
                }
                // output paragraphs
-               if (runparams.flavor == OutputParams::HTML) {
+               if (runparams.flavor == OutputParams::LYX) {
+                       Paragraph const & par = text().paragraphs()[par_begin];
+                       ostringstream ods;
+                       depth_type dt = par.getDepth();
+                       par.write(ods, params(), dt);
+                       os << from_utf8(ods.str());
+               } else if (runparams.flavor == OutputParams::HTML) {
                        XHTMLStream xs(os);
                        setMathFlavor(runparams);
                        xhtmlParagraphs(text(), *this, xs, runparams);
@@ -3347,7 +3353,16 @@ void Buffer::getSourceCode(odocstream & os, string const format,
                else if (output == OnlyBody)
                        os << _("Preview body");
                os << "\n\n";
-               if (runparams.flavor == OutputParams::HTML) {
+               if (runparams.flavor == OutputParams::LYX) {
+                       ostringstream ods;
+                       if (output == FullSource)
+                               write(ods);
+                       else if (output == OnlyPreamble)
+                               params().writeFile(ods);
+                       else if (output == OnlyBody)
+                               text().write(ods);
+                       os << from_utf8(ods.str());
+               }       else if (runparams.flavor == OutputParams::HTML) {
                        writeLyXHTMLSource(os, runparams, output);
                } else if (runparams.flavor == OutputParams::TEXT) {
                        if (output == OnlyPreamble) {
index 817403f0def86b7c53c2ed56bc34392ccac32cb9..bfee4cff3f859fd1b1992015aa8f0ee473690654 100644 (file)
@@ -2180,6 +2180,8 @@ OutputParams::FLAVOR BufferParams::getOutputFlavor(string const format) const
                result = OutputParams::HTML;
        else if (dformat == "text")
                result = OutputParams::TEXT;
+       else if (dformat == "lyx")
+               result = OutputParams::LYX;
        else {
                // Try to determine flavor of default output format
                vector<string> backs = backends();
index 15736f667da4a11fc884036bcc92d3276f83a7b9..d3c2921b4654c89e11ffdfd1c4a327a92444ed99 100644 (file)
@@ -35,7 +35,8 @@ public:
                XETEX,
                XML,
                HTML,
-               TEXT
+               TEXT,
+               LYX
        };
        
        enum MathFlavor {
index 286055c4076de2c5e873a9364cf31a580575b48c..f4f197d1de8a08d9493027afe520b541e1ddcd7e 100644 (file)
@@ -209,9 +209,6 @@ void ViewSourceWidget::updateDefaultFormat()
                        LYXERR0("Can't find format for backend " << format << "!");
                        continue;
                } 
-               if (fmt->name() == "lyx")
-                       // we can't presently display the LyX format itself
-                       continue;
 
                QString const pretty = qt_(fmt->prettyname());
                QString const qformat = toqstr(format);
index 54b04b3946b8fc0d7e7c66af5dc3dd8266b472a4..ea51664978c33fca4dee8ea53e9d1791182b3240 100644 (file)
@@ -752,6 +752,9 @@ void InsetExternal::validate(LaTeXFeatures & features) const
        case OutputParams::TEXT:
                format = "text";
                break;
+       case OutputParams::LYX:
+               format = "lyx";
+               break;
        }
        external::Template::Formats::const_iterator cit =
                et.formats.find(format);