]> git.lyx.org Git - features.git/blobdiff - src/insets/insettabular.C
change "support/std_sstream.h" to <sstream>
[features.git] / src / insets / insettabular.C
index 3e99fad906fe5ed99052dde643242d8f0992c113..515f95cf227b5399f3e7718181774e6f1dbdb5b2 100644 (file)
@@ -37,8 +37,7 @@
 #include "frontends/LyXView.h"
 #include "frontends/Painter.h"
 
-#include "support/std_sstream.h"
-
+#include <sstream>
 #include <iostream>
 
 using lyx::graphics::PreviewLoader;
@@ -183,7 +182,7 @@ Buffer const & InsetTabular::buffer() const
 }
 
 
-void InsetTabular::buffer(Buffer * b)
+void InsetTabular::buffer(Buffer const * b)
 {
        buffer_ = b;
 }
@@ -410,6 +409,7 @@ void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd)
        lyxerr << "# InsetTabular::dispatch: cmd: " << cmd << endl;
        //lyxerr << "  cur:\n" << cur << endl;
        CursorSlice sl = cur.top();
+       LCursor & bvcur = cur.bv().cursor();
 
        switch (cmd.action) {
 
@@ -420,7 +420,7 @@ void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd)
                cur.selection() = false;
                setPos(cur, cmd.x, cmd.y);
                cur.resetAnchor();
-               cur.bv().cursor().setCursor(cur, false);
+               bvcur = cur;
                //if (cmd.button() == mouse_button::button2)
                //      dispatch(cur, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
                //lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl;
@@ -429,13 +429,16 @@ void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_MOUSE_MOTION:
                if (cmd.button() != mouse_button::button1)
                        break;
+               // ignore motions deeper nested than the real anchor
+               if (bvcur.selection() && bvcur.anchor_.size() < cur.size())
+                       break;
                setPos(cur, cmd.x, cmd.y);
-               cur.bv().cursor().setCursor(cur, true);
-               //lyxerr << "# InsetTabular::MouseMotion\n" << cur.bv().cursor() << endl;
+               bvcur.setCursor(cur, true);
+               //lyxerr << "# InsetTabular::MouseMotion\n" << bvcur << endl;
                break;
 
        case LFUN_MOUSE_RELEASE:
-               //lyxerr << "# InsetTabular::MouseRelease\n" << cur.bv().cursor() << endl;
+               //lyxerr << "# InsetTabular::MouseRelease\n" << bvcur << endl;
                if (cmd.button() == mouse_button::button3)
                        InsetTabularMailer(*this).showDialog(&cur.bv());
                break;
@@ -471,7 +474,7 @@ void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd)
                }
                break;
 
-       case LFUN_LEFTSEL: 
+       case LFUN_LEFTSEL:
        case LFUN_LEFT:
                cell(cur.idx()).dispatch(cur, cmd);
                cur.dispatched(); // override the cell's decision
@@ -627,7 +630,7 @@ void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest & cmd)
                        maxCols = max(cols, maxCols);
 
                        paste_tabular.reset(
-                               new LyXTabular(cur.bv().buffer()->params(), rows, maxCols));
+                               new LyXTabular(cur.buffer().params(), rows, maxCols));
 
                        string::size_type op = 0;
                        int cell = 0;
@@ -695,7 +698,7 @@ bool InsetTabular::getStatus(LCursor & cur, FuncRequest const & cmd,
        switch (cmd.action) {
        case LFUN_TABULAR_FEATURE: {
                int actcell = cur.idx();
-               int action = LyXTabular::LAST_ACTION;   
+               int action = LyXTabular::LAST_ACTION;
                int i = 0;
                for (; tabularFeature[i].action != LyXTabular::LAST_ACTION; ++i) {
                        string const tmp = tabularFeature[i].feature;
@@ -898,7 +901,9 @@ int InsetTabular::docbook(Buffer const & buf, ostream & os,
        int ret = 0;
        InsetOld * master = 0;
 
+#ifdef WITH_WARNINGS
 #warning Why not pass a proper DocIterator here?
+#endif
 #if 0
        // if the table is inside a float it doesn't need the informaltable
        // wrapper. Search for it.
@@ -942,7 +947,7 @@ InsetText & InsetTabular::cell(int idx)
 }
 
 
-void InsetTabular::getCursorPos(CursorSlice const & cur, int & x, int & y) const
+void InsetTabular::getCursorPos(LCursor const & cur, int & x, int & y) const
 {
        cell(cur.idx()).getCursorPos(cur, x, y);
 }
@@ -1318,7 +1323,7 @@ void InsetTabular::tabularFeatures(LCursor & cur,
 #if 0
                // just multicol for one Single Cell
                if (!hasSelection()) {
-                       // check wether we are completly in a multicol
+                       // check whether we are completly in a multicol
                        if (tabular.isMultiColumn(actcell))
                                tabular.unsetMultiColumn(actcell);
                        else
@@ -1494,7 +1499,7 @@ bool InsetTabular::copySelection(LCursor & cur)
 
        ostringstream os;
        OutputParams const runparams;
-       paste_tabular->plaintext(*cur.bv().buffer(), os, runparams, 0, true, '\t');
+       paste_tabular->plaintext(cur.buffer(), os, runparams, 0, true, '\t');
        cur.bv().stuffClipboard(os.str());
        return true;
 }
@@ -1538,9 +1543,9 @@ void InsetTabular::cutSelection(LCursor & cur)
        if (!cur.selection())
                return;
 
-       bool const track = cur.bv().buffer()->params().tracking_changes;
+       bool const track = cur.buffer().params().tracking_changes;
        int rs, re, cs, ce;
-       getSelection(cur, rs, re, cs, ce); 
+       getSelection(cur, rs, re, cs, ce);
        for (int i = rs; i <= re; ++i)
                for (int j = cs; j <= ce; ++j)
                        cell(tabular.getCellNumber(i, j)).clear(track);
@@ -1723,7 +1728,7 @@ void InsetTabular::addPreview(PreviewLoader & loader) const
 
 bool InsetTabular::tablemode(LCursor & cur) const
 {
-       return cur.selBegin().idx() != cur.selEnd().idx();
+       return cur.selection() && cur.selBegin().idx() != cur.selEnd().idx();
 }
 
 
@@ -1749,7 +1754,9 @@ int InsetTabularMailer::string2params(string const & in, InsetTabular & inset)
        LyXLex lex(0,0);
        lex.setStream(data);
 
+#ifdef WITH_WARNINGS
 #warning CHECK verify that this is a sane value to return.
+#endif
        if (in.empty())
                return -1;
 
@@ -1794,11 +1801,12 @@ int InsetTabularMailer::string2params(string const & in, InsetTabular & inset)
 string const InsetTabularMailer::params2string(InsetTabular const & inset)
 {
        ostringstream data;
+#ifdef WITH_WARNINGS
 #warning wrong!
+#endif
        //data << name_ << " \\active_cell " << inset.getActCell() << '\n';
        data << name_ << " \\active_cell " << 0 << '\n';
        inset.write(inset.buffer(), data);
        data << "\\end_inset\n";
        return data.str();
 }
-