]> git.lyx.org Git - lyx.git/blobdiff - src/paragraph_funcs.C
more cursor dispatch
[lyx.git] / src / paragraph_funcs.C
index ec55e8bea656246813e1c992b0b850f5d804cae7..07c9703dc1f6abd3279ed68cdd96436446ac3dd8 100644 (file)
@@ -77,7 +77,7 @@ bool moveItem(Paragraph & from, Paragraph & to,
        LyXFont tmpfont = from.getFontSettings(params, i);
 
        if (tmpchar == Paragraph::META_INSET) {
-               InsetOld * tmpinset = 0;
+               InsetBase * tmpinset = 0;
                if (from.getInset(i)) {
                        // the inset is not in a paragraph anymore
                        tmpinset = from.insetlist.release(i);
@@ -132,9 +132,6 @@ void breakParagraph(BufferParams const & bparams,
                tmp->params().align(par->params().align());
                tmp->setLabelWidthString(par->params().labelWidthString());
 
-               tmp->params().spaceBottom(par->params().spaceBottom());
-               par->params().spaceBottom(VSpace(VSpace::NONE));
-
                tmp->params().depth(par->params().depth());
                tmp->params().noindent(par->params().noindent());
 
@@ -167,7 +164,6 @@ void breakParagraph(BufferParams const & bparams,
        if (pos)
                return;
 
-       tmp->params().spaceTop(par->params().spaceTop());
        par->params().clear();
 
        par->layout(bparams.getLyXTextClass().defaultLayout());
@@ -223,9 +219,6 @@ void mergeParagraph(BufferParams const & bparams,
 {
        ParagraphList::iterator the_next = boost::next(par);
 
-       // first the DTP-stuff
-       par->params().spaceBottom(the_next->params().spaceBottom());
-
        pos_type pos_end = the_next->size() - 1;
        pos_type pos_insert = par->size();
 
@@ -310,7 +303,8 @@ int getEndLabel(ParagraphList::iterator p, ParagraphList const & plist)
 
 namespace {
 
-int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & token)
+int readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
+       string const & token)
 {
        static LyXFont font;
        static Change change;
@@ -362,7 +356,7 @@ int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & tok
                lyxerr << "Solitary \\end_inset in line " << lex.getLineNo() << "\n"
                       << "Missing \\begin_inset?.\n";
        } else if (token == "\\begin_inset") {
-               InsetOld * inset = readInset(lex, buf);
+               InsetBase * inset = readInset(lex, buf);
                if (inset)
                        par.insertInset(par.size(), inset, font, change);
                else {
@@ -437,7 +431,7 @@ int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & tok
                                }
                        }
                } else {
-                       auto_ptr<InsetOld> inset;
+                       auto_ptr<InsetBase> inset;
                        if (token == "\\SpecialChar" )
                                inset.reset(new InsetSpecialChar);
                        else
@@ -447,17 +441,17 @@ int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & tok
                                        font, change);
                }
        } else if (token == "\\i") {
-               auto_ptr<InsetOld> inset(new InsetLatexAccent);
+               auto_ptr<InsetBase> inset(new InsetLatexAccent);
                inset->read(buf, lex);
                par.insertInset(par.size(), inset.release(), font, change);
        } else if (token == "\\backslash") {
                par.insertChar(par.size(), '\\', font, change);
        } else if (token == "\\newline") {
-               auto_ptr<InsetOld> inset(new InsetNewline);
+               auto_ptr<InsetBase> inset(new InsetNewline);
                inset->read(buf, lex);
                par.insertInset(par.size(), inset.release(), font, change);
        } else if (token == "\\LyXTable") {
-               auto_ptr<InsetOld> inset(new InsetTabular(buf));
+               auto_ptr<InsetBase> inset(new InsetTabular(buf));
                inset->read(buf, lex);
                par.insertInset(par.size(), inset.release(), font, change);
        } else if (token == "\\bibitem") {
@@ -506,7 +500,7 @@ int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & tok
 }
 
 
-int readParagraph(Buffer & buf, Paragraph & par, LyXLex & lex)
+int readParagraph(Buffer const & buf, Paragraph & par, LyXLex & lex)
 {
        int unknown = 0;
 
@@ -565,16 +559,15 @@ LyXFont const outerFont(ParagraphList::iterator pit,
 }
 
 
-ParagraphList::iterator outerPar(Buffer const & buf, InsetOld const * inset)
+ParagraphList::iterator outerPar(Buffer const & buf, InsetBase const * inset)
 {
        ParIterator pit = const_cast<Buffer &>(buf).par_iterator_begin();
        ParIterator end = const_cast<Buffer &>(buf).par_iterator_end();
        for ( ; pit != end; ++pit) {
-
-               ParagraphList * plist;
+               LyXText * text;
                // the second '=' below is intentional
-               for (int i = 0; (plist = inset->getParagraphs(i)); ++i)
-                       if (plist == &pit.plist())
+               for (int i = 0; (text = inset->getText(i)); ++i)
+                       if (&text->paragraphs() == &pit.plist())
                                return pit.outerPar();
 
                InsetList::iterator ii = pit->insetlist.begin();
@@ -589,15 +582,15 @@ ParagraphList::iterator outerPar(Buffer const & buf, InsetOld const * inset)
 }
 
 
-Paragraph const & ownerPar(Buffer const & buf, InsetOld const * inset)
+Paragraph const & ownerPar(Buffer const & buf, InsetBase const * inset)
 {
        ParConstIterator pit = buf.par_iterator_begin();
        ParConstIterator end = buf.par_iterator_end();
        for ( ; pit != end; ++pit) {
-               ParagraphList * plist;
+               LyXText * text;
                // the second '=' below is intentional
-               for (int i = 0; (plist = inset->getParagraphs(i)); ++i)
-                       if (plist == &pit.plist())
+               for (int i = 0; (text = inset->getText(i)); ++i)
+                       if (&text->paragraphs() == &pit.plist())
                                return *pit.pit();
 
                InsetList::const_iterator ii = pit->insetlist.begin();
@@ -610,3 +603,24 @@ Paragraph const & ownerPar(Buffer const & buf, InsetOld const * inset)
        BOOST_ASSERT(false);
        return buf.paragraphs().front(); // shut up compiler
 }
+
+
+/// return the range of pars [beg, end[ owning the range of y [ystart, yend] 
+void getParsInRange(ParagraphList & pl,
+                               int ystart, int yend,
+                               ParagraphList::iterator & beg,
+                               ParagraphList::iterator & end)
+{
+       ParagraphList::iterator const endpar = pl.end();
+       ParagraphList::iterator const begpar = pl.begin();
+
+       BOOST_ASSERT(begpar != endpar);
+
+       beg = endpar;
+       for (--beg; beg != begpar && beg->y > ystart; --beg)
+               ;
+
+       for (end = beg ; end != endpar && end->y <= yend; ++end)
+               ;
+}
+