The branch, master, has been updated.

- Log -----------------------------------------------------------------

commit 5eb9ece39e8a1057dfdefff596cb9715125ca609
Author: Juergen Spitzmueller <[email protected]>
Date:   Sat Jun 30 13:34:49 2012 +0200

    Properly escape splitindex shortcut and try to encode splitindex name 
properly (part of bug #8227)

diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 40ab0dc..6882883 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -1744,10 +1744,20 @@ bool BufferParams::writeLaTeX(otexstream & os, 
LaTeXFeatures & features,
                IndicesList::const_iterator iit = indiceslist().begin();
                IndicesList::const_iterator iend = indiceslist().end();
                for (; iit != iend; ++iit) {
+                       pair<docstring, docstring> indexname_latex =
+                               
features.runparams().encoding->latexString(iit->index(), 
features.runparams().dryrun);
+                       if (!indexname_latex.second.empty()) {
+                               // issue a warning about omitted characters
+                               // FIXME: should be passed to the error dialog
+                               frontend::Alert::warning(_("Uncodable 
characters"),
+                                       bformat(_("The following characters 
that are used in an index name are not\n"
+                                                         "representable in the 
current encoding and therefore have been omitted:\n%1$s."),
+                                                       
indexname_latex.second));
+                       }
                        lyxpreamble += "\\newindex[";
-                       lyxpreamble += iit->index();
+                       lyxpreamble += indexname_latex.first;
                        lyxpreamble += "]{";
-                       lyxpreamble += iit->shortcut();
+                       lyxpreamble += escape(iit->shortcut());
                        lyxpreamble += "}\n";
                }
        }
diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp
index 935cbec..1dc8b4c 100644
--- a/src/insets/InsetIndex.cpp
+++ b/src/insets/InsetIndex.cpp
@@ -65,7 +65,7 @@ void InsetIndex::latex(otexstream & os, OutputParams const & 
runparams_in) const
        if (buffer().masterBuffer()->params().use_indices && 
!params_.index.empty()
            && params_.index != "idx") {
                os << "\\sindex[";
-               os << params_.index;
+        os << escape(params_.index);
                os << "]{";
        } else {
                os << "\\index";
@@ -134,15 +134,11 @@ void InsetIndex::latex(otexstream & os, OutputParams 
const & runparams_in) const
                        // the sorting part are representable in the current
                        // encoding. If not try the LaTeX macro which might
                        // or might not be a good choice, and issue a warning.
-                       docstring spart2;
-                       for (size_t n = 0; n < spart.size(); ++n) {
-                               try {
-                                       spart2 += 
runparams.encoding->latexChar(spart[n]).first;
-                               } catch (EncodingException & /* e */) {
+                       pair<docstring, docstring> spart_latexed =
+                               runparams.encoding->latexString(spart, 
runparams.dryrun);
+                       if (!spart_latexed.second.empty())
                                        LYXERR0("Uncodable character in index 
entry. Sorting might be wrong!");
-                               }
-                       }
-                       if (spart != spart2 && !runparams.dryrun) {
+                       if (spart != spart_latexed.first && !runparams.dryrun) {
                                // FIXME: warning should be passed to the error 
dialog
                                frontend::Alert::warning(_("Index sorting 
failed"),
                                bformat(_("LyX's automatic index sorting 
algorithm faced\n"
@@ -152,7 +148,7 @@ void InsetIndex::latex(otexstream & os, OutputParams const 
& runparams_in) const
                        }
                        // remove remaining \'s for the sorting part
                        docstring const ppart =
-                               subst(spart2, from_ascii("\\"), docstring());
+                               subst(spart_latexed.first, from_ascii("\\"), 
docstring());
                        os << ppart;
                        os << '@';
                }
@@ -429,7 +425,8 @@ ParamInfo const & InsetPrintIndex::findInfo(string const & 
/* cmdName */)
 {
        static ParamInfo param_info_;
        if (param_info_.empty()) {
-               param_info_.add("type", ParamInfo::LATEX_OPTIONAL);
+               param_info_.add("type", ParamInfo::LATEX_OPTIONAL,
+                        ParamInfo::HANDLING_ESCAPE);
                param_info_.add("name", ParamInfo::LATEX_REQUIRED);
        }
        return param_info_;

-----------------------------------------------------------------------

Summary of changes:
 src/BufferParams.cpp      |   14 ++++++++++++--
 src/insets/InsetIndex.cpp |   19 ++++++++-----------
 2 files changed, 20 insertions(+), 13 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to