From 92bcd7b0cab352a31fbd3ddac472d8785fcbb836 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 21 May 2008 18:15:09 +0000 Subject: [PATCH] Really, I mean *really* fix bug 4857. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@24877 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Paragraph.cpp | 15 +++++++++++++++ src/Paragraph.h | 2 ++ src/TocBackend.cpp | 8 ++++---- src/insets/InsetCaption.cpp | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 257886063d..c3cb09a700 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -2548,6 +2548,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) { + value_type const c = getChar(i); + if (isPrintable(c)) + os.put(c); + } + return os.str(); +} + + // Convert the paragraph to a string. // Used for building the table of contents docstring const Paragraph::asString(Buffer const & buffer, bool label) const diff --git a/src/Paragraph.h b/src/Paragraph.h index 8fd17c2897..e2c7b4cbca 100644 --- a/src/Paragraph.h +++ b/src/Paragraph.h @@ -100,6 +100,8 @@ public: /// bool isMultiLingual(BufferParams const &) const; + /// + docstring const printableString(bool label) const; /// docstring const asString(Buffer const &, bool label) const; /// diff --git a/src/TocBackend.cpp b/src/TocBackend.cpp index 03f3a7433f..0241dad68d 100644 --- a/src/TocBackend.cpp +++ b/src/TocBackend.cpp @@ -113,7 +113,7 @@ void TocBackend::updateItem(ParConstIterator const & par_it) *static_cast(inset).paragraphs().begin(); if (!toc_item->par_it_->getLabelstring().empty()) tocstring = toc_item->par_it_->getLabelstring() + ' '; - tocstring += par.asString(*buffer_, false); + tocstring += par.printableString(false); break; } } @@ -122,7 +122,7 @@ void TocBackend::updateItem(ParConstIterator const & par_it) if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel && tocstring.empty()) - tocstring = toc_item->par_it_->asString(*buffer_, true); + tocstring = toc_item->par_it_->printableString(true); const_cast(*toc_item).str_ = tocstring; } @@ -158,7 +158,7 @@ void TocBackend::update() *static_cast(inset).paragraphs().begin(); if (!pit->getLabelstring().empty()) tocstring = pit->getLabelstring() + ' '; - tocstring += par.asString(*buffer_, false); + tocstring += par.printableString(false); break; } default: @@ -172,7 +172,7 @@ void TocBackend::update() && toclevel >= min_toclevel) { // insert this into the table of contents if (tocstring.empty()) - tocstring = pit->asString(*buffer_, true); + tocstring = pit->printableString(true); toc.push_back(TocItem(pit, toclevel - min_toclevel, tocstring)); } diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp index ffbd6fcd49..8de9f89e22 100644 --- a/src/insets/InsetCaption.cpp +++ b/src/insets/InsetCaption.cpp @@ -127,7 +127,7 @@ void InsetCaption::addToToc(TocList & toclist, Buffer const & buf, Toc & toc = toclist[type_]; docstring const str = convert(counter_) - + ". " + pit->asString(buf, false); + + ". " + pit->printableString(false); toc.push_back(TocItem(pit, 0, str)); }