mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 03:03:06 +00:00
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:
parent
3742ece3ec
commit
0c59c26b08
@ -20,11 +20,14 @@
|
|||||||
#include "sgml.h"
|
#include "sgml.h"
|
||||||
#include "TocBackend.h"
|
#include "TocBackend.h"
|
||||||
|
|
||||||
|
#include "support/docstream.h"
|
||||||
#include "support/gettext.h"
|
#include "support/gettext.h"
|
||||||
|
#include "support/lstrings.h"
|
||||||
|
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace lyx::support;
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
@ -45,9 +48,16 @@ int InsetIndex::latex(odocstream & os,
|
|||||||
{
|
{
|
||||||
os << "\\index";
|
os << "\\index";
|
||||||
os << '{';
|
os << '{';
|
||||||
if (hasFontChanges()) {
|
odocstringstream ods;
|
||||||
InsetText::plaintext(os, runparams);
|
InsetText::latex(ods, runparams);
|
||||||
os << '@';
|
// 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);
|
int i = InsetText::latex(os, runparams);
|
||||||
os << '}';
|
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
|
// InsetPrintIndex
|
||||||
|
@ -44,8 +44,6 @@ private:
|
|||||||
void addToToc(ParConstIterator const &) const;
|
void addToToc(ParConstIterator const &) const;
|
||||||
///
|
///
|
||||||
Inset * clone() const { return new InsetIndex(*this); }
|
Inset * clone() const { return new InsetIndex(*this); }
|
||||||
///
|
|
||||||
bool hasFontChanges() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user