[EMAIL PROTECTED] wrote:
Author: younes
Date: Thu May 22 12:14:20 2008
New Revision: 24878

URL: http://www.lyx.org/trac/changeset/24878
Log:
forward port rev 24877. Even if trunk is not affected by 4857, it is safer to 
only display printable characters in the toc items and not go inside insets.

Somebody has an objection to this?

Abdel.


Modified:
    lyx-devel/trunk/src/Paragraph.cpp
    lyx-devel/trunk/src/Paragraph.h
    lyx-devel/trunk/src/TocBackend.cpp
    lyx-devel/trunk/src/insets/InsetCaption.cpp

Modified: lyx-devel/trunk/src/Paragraph.cpp
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/Paragraph.cpp?rev=24878
==============================================================================
--- lyx-devel/trunk/src/Paragraph.cpp (original)
+++ lyx-devel/trunk/src/Paragraph.cpp Thu May 22 12:14:20 2008
@@ -2302,6 +2302,21 @@
 }
+docstring const Paragraph::printableString(bool label) const
+{
+       odocstringstream os;
+       if (label && !params().labelString().empty())
+               os << params().labelString() << ' ';
+       pos_type end = size();
+       for (pos_type i = 0; i < end; ++i) {
+               char_type const c = d->text_[i];
+               if (isPrintable(c))
+                       os.put(c);
+       }
+       return os.str();
+}
+
+
 docstring Paragraph::asString(bool label) const
 {
        return asString(0, size(), label);

Modified: lyx-devel/trunk/src/Paragraph.h
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/Paragraph.h?rev=24878
==============================================================================
--- lyx-devel/trunk/src/Paragraph.h (original)
+++ lyx-devel/trunk/src/Paragraph.h Thu May 22 12:14:20 2008
@@ -98,7 +98,12 @@
        bool isMultiLingual(BufferParams const &) const;
/// Convert the paragraph to a string.
+       /// This method doesn't go inside insets, only printable characters in 
this
+       /// paragraph are used.
        /// Used for building the table of contents
+       docstring const printableString(bool label) const;
+
+       /// Convert the paragraph to a string.
        docstring asString(bool label) const;
        ///
        docstring asString(pos_type beg, pos_type end, bool label) const;

Modified: lyx-devel/trunk/src/TocBackend.cpp
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/TocBackend.cpp?rev=24878
==============================================================================
--- lyx-devel/trunk/src/TocBackend.cpp (original)
+++ lyx-devel/trunk/src/TocBackend.cpp Thu May 22 12:14:20 2008
@@ -134,7 +134,7 @@
                                
*static_cast<InsetOptArg&>(inset).paragraphs().begin();
                        if (!par.labelString().empty())
                                tocstring = par.labelString() + ' ';
-                       tocstring += inset_par.asString(false);
+                       tocstring += inset_par.printableString(false);
                        break;
                }
        }
@@ -142,7 +142,7 @@
        int const toclevel = par.layout().toclevel;
        if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel
                && tocstring.empty())
-                       tocstring = par.asString(true);
+                       tocstring = par.printableString(true);
const_cast<TocItem &>(*toc_item).str_ = tocstring;
 }
@@ -181,7 +181,7 @@
                                        
*static_cast<InsetOptArg&>(inset).paragraphs().begin();
                                if (!pit->labelString().empty())
                                        tocstring = pit->labelString() + ' ';
-                               tocstring += par.asString(false);
+                               tocstring += par.printableString(false);
                                break;
                        }
                        default:
@@ -196,7 +196,7 @@
                        pit.pos() = 0;
                        // insert this into the table of contents
                        if (tocstring.empty())
-                               tocstring = pit->asString(true);
+                               tocstring = pit->printableString(true);
                        toc.push_back(TocItem(pit, toclevel - min_toclevel,
                                tocstring));
                }

Modified: lyx-devel/trunk/src/insets/InsetCaption.cpp
URL: 
http://www.lyx.org/trac/file/lyx-devel/trunk/src/insets/InsetCaption.cpp?rev=24878
==============================================================================
--- lyx-devel/trunk/src/insets/InsetCaption.cpp (original)
+++ lyx-devel/trunk/src/insets/InsetCaption.cpp Thu May 22 12:14:20 2008
@@ -111,7 +111,7 @@
        pit.push_back(CursorSlice(*this));
Toc & toc = buffer().tocBackend().toc(type_);
-       docstring const str = full_label_ + ". " + 
text_.getPar(0).asString(false);
+       docstring const str = full_label_ + ". " + 
text_.getPar(0).printableString(false);
        toc.push_back(TocItem(pit, 0, str));
 }



Reply via email to