X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText.cpp;h=932a3929d79bb4da2965b8cad4e1d8d671d9abe5;hb=f08f5821ec5d29232bccb342a5b1ff86600b0716;hp=d3a122660da0636278e2972f3d3b387edcf243df;hpb=8abb5429b92ab44ca064604576765463a00ff801;p=lyx.git diff --git a/src/Text.cpp b/src/Text.cpp index d3a122660d..932a3929d7 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -30,7 +30,6 @@ #include "Cursor.h" #include "CutAndPaste.h" #include "DispatchResult.h" -#include "Encoding.h" #include "ErrorList.h" #include "FuncRequest.h" #include "factory.h" @@ -55,10 +54,12 @@ #include "insets/InsetNewline.h" #include "insets/InsetNewpage.h" #include "insets/InsetArgument.h" +#include "insets/InsetIPAMacro.h" #include "insets/InsetSpace.h" #include "insets/InsetSpecialChar.h" #include "insets/InsetTabular.h" +#include "support/convert.h" #include "support/debug.h" #include "support/docstream.h" #include "support/gettext.h" @@ -68,6 +69,7 @@ #include +#include #include @@ -262,15 +264,28 @@ bool Text::isFirstInSequence(pit_type par_offset) const } +int Text::getTocLevel(pit_type par_offset) const +{ + Paragraph const & par = pars_[par_offset]; + + if (par.layout().isEnvironment() && !isFirstInSequence(par_offset)) + return Layout::NOT_IN_TOC; + + return par.layout().toclevel; +} + + Font const Text::outerFont(pit_type par_offset) const { depth_type par_depth = pars_[par_offset].getDepth(); FontInfo tmpfont = inherit_font; - + depth_type prev_par_depth = 0; // Resolve against environment font information while (par_offset != pit_type(pars_.size()) + && par_depth != prev_par_depth && par_depth && !tmpfont.resolved()) { + prev_par_depth = par_depth; par_offset = outerHook(par_offset); if (par_offset != pit_type(pars_.size())) { tmpfont.realize(pars_[par_offset].layout().font); @@ -476,6 +491,12 @@ void Text::readParToken(Paragraph & par, Lexer & lex, inset->read(lex); inset->setBuffer(*buf); par.insertInset(par.size(), inset.release(), font, change); + } else if (token == "\\IPAChar") { + auto_ptr inset; + inset.reset(new InsetIPAChar); + inset->read(lex); + inset->setBuffer(*buf); + par.insertInset(par.size(), inset.release(), font, change); } else if (token == "\\backslash") { par.appendChar('\\', font, change); } else if (token == "\\LyXTable") { @@ -721,8 +742,7 @@ void Text::breakParagraph(Cursor & cur, bool inverse_logic) return; } - // a layout change may affect also the following paragraph - recUndo(cur, cur.pit(), undoSpan(cur.pit()) - 1); + cur.recordUndo(); // Always break behind a space // It is better to erase the space (Dekel) @@ -1693,7 +1713,7 @@ bool Text::dissolveInset(Cursor & cur) // change it to the buffer language. ParagraphList::iterator it = plist.begin(); ParagraphList::iterator it_end = plist.end(); - for (; it != it_end; it++) + for (; it != it_end; ++it) it->changeLanguage(b.params(), latex_language, b.language()); pasteParagraphList(cur, plist, b.params().documentClassPtr(), @@ -1802,6 +1822,7 @@ bool Text::read(Lexer & lex, return res; } + // Returns the current font and depth as a message. docstring Text::currentState(Cursor const & cur) const { @@ -1927,7 +1948,7 @@ docstring Text::getPossibleLabel(Cursor const & cur) const // For captions, we just take the caption type Inset * caption_inset = cur.innerInsetOfType(CAPTION_CODE); if (caption_inset) { - string const & ftype = static_cast(caption_inset)->type(); + string const & ftype = static_cast(caption_inset)->floattype(); FloatList const & fl = cur.buffer()->params().documentClass().floats(); if (fl.typeExist(ftype)) { Floating const & flt = fl.getType(ftype); @@ -1946,7 +1967,15 @@ docstring Text::getPossibleLabel(Cursor const & cur) const if (!name.empty()) text = name + ':' + text; - return text; + // We need a unique label + docstring label = text; + int i = 1; + while (cur.buffer()->insetLabel(label)) { + label = text + '-' + convert(i); + ++i; + } + + return label; } @@ -1970,7 +1999,10 @@ docstring Text::asString(pit_type beg, pit_type end, int options) const void Text::forToc(docstring & os, size_t maxlen, bool shorten) const { - LASSERT(maxlen > 10, maxlen = 30); + if (maxlen == 0) + maxlen = std::numeric_limits::max(); + else + LASSERT(maxlen >= 8, maxlen = TOC_ENTRY_LENGTH); for (size_t i = 0; i != pars_.size() && os.length() < maxlen; ++i) pars_[i].forToc(os, maxlen); if (shorten && os.length() >= maxlen)