]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettabular.C
Enable the external inset to handle unknown templates gracefully.
[lyx.git] / src / insets / insettabular.C
index cf36af15f0c72e732aab16a42e2a7fb48f836433..0007786eb3eedbcb404262801403fe7acd21153e 100644 (file)
@@ -151,7 +151,7 @@ bool InsetTabular::hasPasteBuffer() const
 
 
 InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
-       : buffer(&buf)
+       : buffer_(&buf)
 {
        if (rows <= 0)
                rows = 1;
@@ -174,10 +174,10 @@ InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
 }
 
 
-InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf)
-       : UpdatableInset(tab), buffer(&buf)
+InsetTabular::InsetTabular(InsetTabular const & tab)
+       : UpdatableInset(tab), buffer_(tab.buffer_)
 {
-       tabular.reset(new LyXTabular(buf.params,
+       tabular.reset(new LyXTabular(buffer_->params,
                                     this, *(tab.tabular)));
        the_locking_inset = 0;
        old_locking_inset = 0;
@@ -200,15 +200,21 @@ InsetTabular::~InsetTabular()
 }
 
 
-Inset * InsetTabular::clone(Buffer const & buf) const
+Inset * InsetTabular::clone() const
 {
-       return new InsetTabular(*this, buf);
+       return new InsetTabular(*this);
 }
 
 
 BufferView * InsetTabular::view() const
 {
-       return buffer->getUser();
+       return buffer_->getUser();
+}
+
+
+void InsetTabular::buffer(Buffer * b)
+{
+       buffer_ = b;
 }
 
 
@@ -243,7 +249,7 @@ void InsetTabular::read(Buffer const * buf, LyXLex & lex)
 }
 
 
-void InsetTabular::dimension(BufferView *, LyXFont const &,
+void InsetTabular::metrics(MetricsInfo &,
        Dimension & dim) const
 {
        dim.asc = tabular->GetAscentOfRow(0);
@@ -307,10 +313,16 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
                        ++cell;
                }
 
+// Would be nice, but for some completely unfathomable reason,
+// on a col resize to a new fixed width, even though the insettexts
+// are resized, the cell isn't, but drawing all cells in a tall table
+// has the desired effect somehow. Complete dark magic.
+#if 0
                // avoiding drawing the rest of a long table is
                // a pretty big speedup
                if (y > bv->workHeight())
                        break;
+#endif
 
                y += tabular->GetDescentOfRow(i) +
                        tabular->GetAscentOfRow(i + 1) +
@@ -1754,6 +1766,11 @@ void InsetTabular::tabularFeatures(BufferView * bv,
                bool const update = (tmplen != vallen);
                tabular->SetColumnPWidth(actcell, vallen);
                if (update) {
+                       // We need this otherwise we won't resize
+                       // the insettext of the active cell (if any)
+                       // until later (see InsetText::do_resize)
+                       unlockInsetInInset(bv, the_locking_inset);
+
                        int cell;
                        for (int i = 0; i < tabular->rows(); ++i) {
                                cell = tabular->GetCellNumber(i,column);
@@ -1778,6 +1795,11 @@ void InsetTabular::tabularFeatures(BufferView * bv,
                bool const update = (tmplen != vallen);
                tabular->SetMColumnPWidth(actcell, vallen);
                if (update) {
+                       // We need this otherwise we won't resize
+                       // the insettext of the active cell (if any)
+                       // until later (see InsetText::do_resize)
+                       unlockInsetInInset(bv, the_locking_inset);
+
                        for (int i = 0; i < tabular->rows(); ++i) {
                                tabular->GetCellInset(tabular->GetCellNumber(i, column))->
                                        resizeLyXText(bv);
@@ -2881,6 +2903,7 @@ int InsetTabularMailer::string2params(string const & in, InsetTabular & inset)
        if (!lex.isOK())
                return -1;
 
+       // FIXME: even current_view would be better than this.
        BufferView * const bv = inset.view();
        Buffer const * const buffer = bv ? bv->buffer() : 0;
        if (buffer)
@@ -2894,6 +2917,7 @@ int InsetTabularMailer::string2params(string const & in, InsetTabular & inset)
 
 string const InsetTabularMailer::params2string(InsetTabular const & inset)
 {
+       // FIXME: even current_view would be better than this.
        BufferView * const bv = inset.view();
        Buffer const * const buffer = bv ? bv->buffer() : 0;
        if (!buffer)