]> git.lyx.org Git - features.git/commitdiff
forward port rev 24877. Even if trunk is not affected by 4857, it is safer to only...
authorAbdelrazak Younes <younes@lyx.org>
Thu, 22 May 2008 10:14:20 +0000 (10:14 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Thu, 22 May 2008 10:14:20 +0000 (10:14 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24878 a592a061-630c-0410-9148-cb99ea01b6c8

src/Paragraph.cpp
src/Paragraph.h
src/TocBackend.cpp
src/insets/InsetCaption.cpp

index 4555e4289e6bff7af1dfc6065862edf0d99c2628..4ad0d59be0903158bfb7be0f2801e28d491bd8ab 100644 (file)
@@ -2302,6 +2302,21 @@ bool Paragraph::isMultiLingual(BufferParams const & bparams) const
 }
 
 
+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);
index 7761c5ff683b54cc31510a52467b01464da2017f..cdf2e58d97af2aa7da56e1c7a0da0f9e4c17847c 100644 (file)
@@ -98,7 +98,12 @@ public:
        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;
index e4504c47b8fbebab5ff30129873f6a18ac6d52f0..0e20e5eb003f69023ec6fa27fef7047d61f8e54e 100644 (file)
@@ -134,7 +134,7 @@ void TocBackend::updateItem(DocIterator const & dit)
                                *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 @@ void TocBackend::updateItem(DocIterator const & dit)
        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 @@ void TocBackend::update()
                                        *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 @@ void TocBackend::update()
                        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));
                }
index 193d6ba0bbb35b93fdba0073578010f75de8e433..f658b6173fefb79f9dd13cb44a2d456461c9ced0 100644 (file)
@@ -111,7 +111,7 @@ void InsetCaption::addToToc(DocIterator const & cpit)
        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));
 }