some index fixes:

* src/insets/InsetIndex.{cpp,h} (latex):
	- a more general method to get the index sorting of
	  formatted strings and macros right (bug 4800).

Please test, everybody. 

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24515 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2008-04-27 08:52:43 +00:00
parent 3742ece3ec
commit 0c59c26b08
2 changed files with 13 additions and 15 deletions

View File

@ -20,11 +20,14 @@
#include "sgml.h"
#include "TocBackend.h"
#include "support/docstream.h"
#include "support/gettext.h"
#include "support/lstrings.h"
#include <ostream>
using namespace std;
using namespace lyx::support;
namespace lyx {
@ -45,9 +48,16 @@ int InsetIndex::latex(odocstream & os,
{
os << "\\index";
os << '{';
if (hasFontChanges()) {
InsetText::plaintext(os, runparams);
os << '@';
odocstringstream ods;
InsetText::latex(ods, runparams);
// correctly sort macros and formatted strings
// if we do find a command, prepend a plain text
// version of the content to get sorting right,
// e.g. \index{LyX@\LyX}, \index{text@\textbf{text}}
// Don't do that if the user entered '@' himself, though.
if (contains(ods.str(), '\\') && !contains(ods.str(), '@')) {
if (InsetText::plaintext(os, runparams) > 0)
os << '@';
}
int i = InsetText::latex(os, runparams);
os << '}';
@ -83,16 +93,6 @@ void InsetIndex::addToToc(ParConstIterator const & cpit) const
}
bool InsetIndex::hasFontChanges() const
{
// we only have one par
Paragraph par = paragraphs().back();
FontSpan const font_span = par.fontSpan(0);
Font firstfont = par.getFirstFontSettings(buffer().params());
return (firstfont.fontInfo() != inherit_font || par.size() > font_span.last + 1);
}
/////////////////////////////////////////////////////////////////////
//
// InsetPrintIndex

View File

@ -44,8 +44,6 @@ private:
void addToToc(ParConstIterator const &) const;
///
Inset * clone() const { return new InsetIndex(*this); }
///
bool hasFontChanges() const;
};