]> git.lyx.org Git - features.git/commitdiff
Inside the same the same paragraph don't change CDATA status.
authorJosé Matox <jamatos@lyx.org>
Sat, 30 Oct 2004 22:14:02 +0000 (22:14 +0000)
committerJosé Matox <jamatos@lyx.org>
Sat, 30 Oct 2004 22:14:02 +0000 (22:14 +0000)
Don't output paragraphs inside inline elements (char styles). (docbook)

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

src/ChangeLog
src/insets/ChangeLog
src/insets/insetcharstyle.C
src/paragraph.C
src/paragraph.h

index f682a02f68cce46acfab0f8db3f66bc3c069d9a3..f67a4a020ba9489b0f6a107293bac37e310f1c94 100644 (file)
@@ -1,3 +1,9 @@
+2004-10-30  José Matos  <jamatos@lyx.org>
+
+       * paragraph.[Ch] (onlyText): Checks if the paragraph contains only
+       text and no inset or font change. This allows to use CDATA
+       sections just for the whole paragraph.
+
 2004-10-30  José Matos  <jamatos@lyx.org>
 
        * paragraph.C (getFirstWord): remove unused variable.
index 75a8de79d31992f312b110eaedb0a174a78a6b0a..e9674b7d6eb7405e35dcfb0d26eac5f03af7d550 100644 (file)
@@ -1,3 +1,8 @@
+2004-10-30  José Matos  <jamatos@lyx.org>
+
+       * insetcharstyle.C (docbook): a compromisse solution. Don't output
+       paragraph tags inside inline elements.
+
 2004-10-30  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * insetcharstyle.C (latex, linuxdoc, docbook, plaintext): use
index ce726e776d9b05ee0e3979ad46765ad67d4e3f21..b13cfdbca55bc55b8c18a38d0e00bd48ab002a50 100644 (file)
@@ -24,6 +24,7 @@
 #include "lyxtext.h"
 #include "metricsinfo.h"
 #include "paragraph.h"
+#include "paragraph_funcs.h"
 #include "sgml.h"
 
 #include "frontends/font_metrics.h"
@@ -189,10 +190,19 @@ int InsetCharStyle::linuxdoc(Buffer const & buf, ostream & os,
 int InsetCharStyle::docbook(Buffer const & buf, ostream & os,
                            OutputParams const & runparams) const
 {
-       sgml::openTag(os, params_.latexname, params_.latexparam);
-       int i = InsetText::docbook(buf, os, runparams);
+       ParagraphList::const_iterator par = paragraphs().begin();
+        ParagraphList::const_iterator end = paragraphs().end();
+
+       sgml::openTag(os, params_.latexname, par->getID() + params_.latexparam);
+
+        for (; par != end; ++par) {
+               par->simpleDocBookOnePar(buf, os, runparams,
+                                        outerFont(par - paragraphs().begin(),
+                                                  paragraphs()));
+        }
+
        sgml::closeTag(os, params_.latexname);
-       return i;
+       return 0;
 }
 
 
index c9ce2a6e9faacb50fc9157739b0b60b6f9824867..f45a5db3298e2419b2fb353cb11943de3fac0a45 100644 (file)
@@ -1394,6 +1394,25 @@ pos_type Paragraph::getFirstWord(Buffer const & buf, ostream & os, OutputParams
        return i;
 }
 
+
+bool Paragraph::onlyText(Buffer const & buf, LyXFont const & outerfont, pos_type initial) const
+{
+       LyXLayout_ptr const & style = layout();
+       LyXFont font_old;
+
+       for (pos_type i = initial; i < size(); ++i) {
+               LyXFont font = getFont(buf.params(), i, outerfont);
+               if (isInset(i))
+                       return false;
+               if ( i != initial and font != font_old)
+                       return false;
+               font_old = font;
+       }
+
+       return true;
+}
+
+
 void Paragraph::simpleDocBookOnePar(Buffer const & buf,
                                    ostream & os,
                                    OutputParams const & runparams,
@@ -1406,7 +1425,8 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
        LyXFont font_old =
                style->labeltype == LABEL_MANUAL ? style->labelfont : style->font;
 
-       bool cdata = style->pass_thru;
+       if (style->pass_thru and not onlyText(buf, outerfont, initial))
+               os << "]]>";
        // parsing main loop
        for (pos_type i = initial; i < size(); ++i) {
                LyXFont font = getFont(buf.params(), i, outerfont);
@@ -1414,29 +1434,17 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
                // handle <emphasis> tag
                if (font_old.emph() != font.emph()) {
                        if (font.emph() == LyXFont::ON) {
-                               if (cdata)
-                                       os << "]]>";
                                os << "<emphasis>";
-                               if (cdata)
-                                       os << "<![CDATA[";
                                emph_flag = true;
                        } else if (i != initial) {
-                               if (cdata)
-                                       os << "]]>";
                                os << "</emphasis>";
-                               if (cdata)
-                                       os << "<![CDATA[";
                                emph_flag = false;
                        }
                }
 
                if (isInset(i)) {
                        InsetBase const * inset = getInset(i);
-                       if (cdata)
-                               os << "]]>";
                        inset->docbook(buf, os, runparams);
-                       if (cdata)
-                               os << "<![CDATA[";
                } else {
                        char c = getChar(i);
                        bool ws;
@@ -1452,15 +1460,13 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
        }
 
        if (emph_flag) {
-               if (cdata)
-                       os << "]]>";
                os << "</emphasis>";
-               if (cdata)
-                       os << "<![CDATA[";
        }
 
        if (style->free_spacing)
                os << '\n';
+       if (style->pass_thru and not onlyText(buf, outerfont, initial))
+               os << "<![CDATA[";
 }
 
 
index d72caec5209534c34acbe8f46b18db02bbd20394..58f25960f6bdd2b7fd77e6e50f4594b1fa490f8c 100644 (file)
@@ -140,6 +140,10 @@ public:
                                   std::ostream & os,
                                   OutputParams const & runparams) const;
 
+       /// Checks if the paragraph contains only text and no inset or font change.
+       bool onlyText(Buffer const & buf, LyXFont const & outerfont,
+                     lyx::pos_type initial) const;
+
        /// Writes to stream the docbook representation
        void simpleDocBookOnePar(Buffer const & buf,
                                 std::ostream &,