]> git.lyx.org Git - lyx.git/blobdiff - src/Text.cpp
Output column width info for XHTML.
[lyx.git] / src / Text.cpp
index 89028c8db661baf3e34a99a287870781c0f85175..12ab04f043397925fbfdd47059172509702d7149 100644 (file)
@@ -69,6 +69,7 @@
 #include "support/lyxalgo.h"
 #include "support/lyxtime.h"
 #include "support/textutils.h"
+#include "support/unique_ptr.h"
 
 #include <sstream>
 
@@ -109,12 +110,12 @@ static bool moveItem(Paragraph & fromPar, pos_type fromPos,
 
 
 void breakParagraphConservative(BufferParams const & bparams,
-       ParagraphList & pars, pit_type par_offset, pos_type pos)
+       ParagraphList & pars, pit_type pit, pos_type pos)
 {
        // create a new paragraph
-       Paragraph & tmp = *pars.insert(lyx::next(pars.begin(), par_offset + 1),
+       Paragraph & tmp = *pars.insert(lyx::next(pars.begin(), pit + 1),
                                       Paragraph());
-       Paragraph & par = pars[par_offset];
+       Paragraph & par = pars[pit];
 
        tmp.setInsetOwner(&par.inInset());
        tmp.makeSameLayout(par);
@@ -187,9 +188,8 @@ Text::Text(InsetText * owner, bool use_default_layout)
 
 
 Text::Text(InsetText * owner, Text const & text)
-       : owner_(owner)
+       : owner_(owner), pars_(text.pars_)
 {
-       pars_ = text.pars_;
        ParagraphList::iterator const end = pars_.end();
        ParagraphList::iterator it = pars_.begin();
        for (; it != end; ++it)
@@ -464,8 +464,7 @@ void Text::readParToken(Paragraph & par, Lexer & lex,
        } else if (token == "\\SpecialChar" ||
                   (token == "\\SpecialCharNoPassThru" &&
                    !par.layout().pass_thru && !inset().isPassThru())) {
-               auto_ptr<Inset> inset;
-               inset.reset(new InsetSpecialChar);
+               auto inset = make_unique<InsetSpecialChar>();
                inset->read(lex);
                inset->setBuffer(*buf);
                par.insertInset(par.size(), inset.release(), font, change);
@@ -474,8 +473,7 @@ void Text::readParToken(Paragraph & par, Lexer & lex,
                docstring const s = ltrim(lex.getDocString(), "\\");
                par.insert(par.size(), s, font, change);
        } else if (token == "\\IPAChar") {
-               auto_ptr<Inset> inset;
-               inset.reset(new InsetIPAChar);
+               auto inset = make_unique<InsetIPAChar>();
                inset->read(lex);
                inset->setBuffer(*buf);
                par.insertInset(par.size(), inset.release(), font, change);
@@ -500,7 +498,7 @@ void Text::readParToken(Paragraph & par, Lexer & lex,
        } else if (token == "\\backslash") {
                par.appendChar('\\', font, change);
        } else if (token == "\\LyXTable") {
-               auto_ptr<Inset> inset(new InsetTabular(buf));
+               auto inset = make_unique<InsetTabular>(buf);
                inset->read(lex);
                par.insertInset(par.size(), inset.release(), font, change);
        } else if (token == "\\change_unchanged") {
@@ -907,11 +905,11 @@ void Text::insertChar(Cursor & cur, char_type c)
        if (lyxrc.auto_number) {
                static docstring const number_operators = from_ascii("+-/*");
                static docstring const number_unary_operators = from_ascii("+-");
-               static docstring const number_seperators = from_ascii(".,:");
+               static docstring const number_separators = from_ascii(".,:");
 
                if (cur.current_font.fontInfo().number() == FONT_ON) {
                        if (!isDigitASCII(c) && !contains(number_operators, c) &&
-                           !(contains(number_seperators, c) &&
+                           !(contains(number_separators, c) &&
                              cur.pos() != 0 &&
                              cur.pos() != cur.lastpos() &&
                              tm.displayFont(pit, cur.pos()).fontInfo().number() == FONT_ON &&
@@ -932,7 +930,7 @@ void Text::insertChar(Cursor & cur, char_type c)
                                  ) {
                                        setCharFont(pit, cur.pos() - 1, cur.current_font,
                                                tm.font_);
-                               } else if (contains(number_seperators, c)
+                               } else if (contains(number_separators, c)
                                     && cur.pos() >= 2
                                     && tm.displayFont(pit, cur.pos() - 2).fontInfo().number() == FONT_ON) {
                                        setCharFont(pit, cur.pos() - 1, cur.current_font,
@@ -1601,7 +1599,7 @@ bool Text::erase(Cursor & cur)
        if (needsUpdate) {
                // Make sure the cursor is correct. Is this really needed?
                // No, not really... at least not here!
-               cur.text()->setCursor(cur.top(), cur.pit(), cur.pos());
+               cur.top().setPitPos(cur.pit(), cur.pos());
                cur.checkBufferStructure();
        }
 
@@ -1708,7 +1706,7 @@ bool Text::backspace(Cursor & cur)
 
        // A singlePar update is not enough in this case.
 //             cur.screenUpdateFlags(Update::Force);
-       setCursor(cur.top(), cur.pit(), cur.pos());
+       cur.top().setPitPos(cur.pit(), cur.pos());
 
        return needsUpdate;
 }