The branch, 2.0.x, has been updated.

- Log -----------------------------------------------------------------

commit 4eab9d49a4f4a90a4c19b1b3de2f6be1b52e0e30
Author: Richard Heck <[email protected]>
Date:   Wed Jul 11 11:20:15 2012 -0400

    Allow LyX format to be shown in View>Source.
    
    Cherry-picked from b7ac2d69e7125bbe6b0bcc7a226cf8245773122a.

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index ec525f7..97ed9d8 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -3215,14 +3215,14 @@ void Buffer::getSourceCode(odocstream & os, string 
const format,
                                        convert<docstring>(par_end - 1))
                           << "\n\n";
                }
-               TexRow texrow;
-               texrow.reset();
-               texrow.newline();
-               texrow.newline();
                // output paragraphs
-               if (params().isDocBook())
-                       docbookParagraphs(text(), *this, os, runparams);
-               else 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);
@@ -3232,6 +3232,8 @@ void Buffer::getSourceCode(odocstream & os, string const 
format,
                        // Probably should have some routine with a signature 
like them.
                        writePlaintextParagraph(*this,
                                text().paragraphs()[par_begin], os, runparams, 
dummy);
+               } else if (params().isDocBook()) {
+                       docbookParagraphs(text(), *this, os, runparams);
                } else {
                        // We need to validate the Buffer params' features here
                        // in order to know if we should output polyglossia
@@ -3239,28 +3241,46 @@ void Buffer::getSourceCode(odocstream & os, string 
const format,
                        LaTeXFeatures features(*this, params(), runparams);
                        params().validate(features);
                        runparams.use_polyglossia = features.usePolyglossia();
+                       TexRow texrow;
+                       texrow.reset();
+                       texrow.newline();
+                       texrow.newline();
                        // latex or literate
                        otexstream ots(os, texrow);
                        latexParagraphs(*this, text(), ots, runparams);
                }
        } else {
                os << "% ";
-               if (output == FullSource) 
+               if (output == FullSource)
                        os << _("Preview source code");
                else if (output == OnlyPreamble)
                        os << _("Preview preamble");
                else if (output == OnlyBody)
                        os << _("Preview body");
                os << "\n\n";
-               d->texrow.reset();
-               d->texrow.newline();
-               d->texrow.newline();
-               if (params().isDocBook())
-                       writeDocBookSource(os, absFileName(), runparams, 
output);
-               else 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 {
+               } else if (runparams.flavor == OutputParams::TEXT) {
+                       if (output == OnlyPreamble) {
+                               os << _("% Plaintext does not have a 
preamble.");
+                       } else
+                               writePlaintextFile(*this, os, runparams);
+               } else if (params().isDocBook()) {
+                               writeDocBookSource(os, absFileName(), 
runparams, output);
+               } else {
                        // latex or literate
+                       d->texrow.reset();
+                       d->texrow.newline();
+                       d->texrow.newline();
                        otexstream ots(os, d->texrow);
                        writeLaTeXSource(ots, string(), runparams, output);
                }
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 3a07c01..a224874 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -2181,6 +2181,8 @@ OutputParams::FLAVOR BufferParams::getOutputFlavor(string 
const format) const
                result = OutputParams::LUATEX;
        else if (dformat == "dviluatex")
                result = OutputParams::DVILUATEX;
+       else if (dformat == "lyx")
+               result = OutputParams::LYX;
        else {
                // Try to determine flavor of default output format
                vector<string> backs = backends();
diff --git a/src/OutputParams.h b/src/OutputParams.h
index 1a7326d..97f4661 100644
--- a/src/OutputParams.h
+++ b/src/OutputParams.h
@@ -35,7 +35,8 @@ public:
                XETEX,
                XML,
                HTML,
-               TEXT
+               TEXT,
+               LYX
        };
        
        enum MathFlavor {
diff --git a/src/frontends/qt4/GuiViewSource.cpp 
b/src/frontends/qt4/GuiViewSource.cpp
index 6a49feb..83114eb 100644
--- a/src/frontends/qt4/GuiViewSource.cpp
+++ b/src/frontends/qt4/GuiViewSource.cpp
@@ -203,11 +203,10 @@ void ViewSourceWidget::updateDefaultFormat()
        for (; it != en; ++it) {
                string const format = *it;
                Format const * fmt = formats.getFormat(format);
-               if (!fmt)
+               if (!fmt) {
                        LYXERR0("Can't find format for backend " << format << 
"!");
-               else if (fmt->name() == "lyx")
-                       // we can't presently display the LyX format itself
                        continue;
+               }
 
                QString const pretty =
                        fmt ? qt_(fmt->prettyname()) : toqstr(format);
diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp
index 6b19135..464353b 100644
--- a/src/insets/InsetExternal.cpp
+++ b/src/insets/InsetExternal.cpp
@@ -746,6 +746,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);
diff --git a/status.20x b/status.20x
index 54d1ff3..db0b860 100644
--- a/status.20x
+++ b/status.20x
@@ -43,6 +43,8 @@ What's new
 
 - Show backends, not formats, in View>Source (bug #7652).
 
+- Allow native LyX format to be shown in View>Source.
+
 
 * DOCUMENTATION AND LOCALIZATION
 
@@ -90,6 +92,8 @@ What's new
 
 - Fix enumitem module translation (bug #8201).
 
+- Set math display format when showing XHTML in View>Source.
+
 
 * DOCUMENTATION AND LOCALIZATION
 

-----------------------------------------------------------------------

Summary of changes:
 src/Buffer.cpp                      |   50 ++++++++++++++++++++++++----------
 src/BufferParams.cpp                |    2 +
 src/OutputParams.h                  |    3 +-
 src/frontends/qt4/GuiViewSource.cpp |    5 +--
 src/insets/InsetExternal.cpp        |    3 ++
 status.20x                          |    4 +++
 6 files changed, 48 insertions(+), 19 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to