]> git.lyx.org Git - features.git/commitdiff
Fixed insert File inside tabulars/insettext (fix #301,#302).
authorJürgen Vigna <jug@sad.it>
Tue, 26 Mar 2002 11:05:30 +0000 (11:05 +0000)
committerJürgen Vigna <jug@sad.it>
Tue, 26 Mar 2002 11:05:30 +0000 (11:05 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3833 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/ChangeLog
src/insets/insettabular.C
src/insets/insettext.C
src/insets/insettext.h

index c301dc1448309a15d0d63733384f6a7da91f5f67..ad2df8cd1df60132b9c52b56ddc45ac7d02a4732 100644 (file)
@@ -1,5 +1,12 @@
 2002-03-26  Juergen Vigna  <jug@sad.it>
 
+       * insettext.C (setText): added a LyXFont param and call reinitLyXText()
+       (collapseParagraphs): fixed inserting of separator ' '
+
+       * insettabular.C (insertAsciiString): only check for buffer lenght
+       not if we have \t or \n inside the buffer as if we don't have we only
+       have 1 cell and that's it!
+
        * insetert.C (close): don't collapse if inlined.
 
 2002-03-25  Herbert Voss  <voss@lyx.org>
index 9baa61cf251c1de553162507a416d6abcadf14e1..8fb923bdefb25f97f38c3186b0c4e547bb91c43c 100644 (file)
@@ -2802,9 +2802,9 @@ bool InsetTabular::forceDefaultParagraphs(Inset const * in) const
 bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
                                     bool usePaste)
 {
-       if (buf.find('\t') == string::npos)
-               return false;
-
+       if (buf.length() <= 0)
+               return true;
+       
        int cols = 1;
        int rows = 1;
        int maxCols = 1;
@@ -2859,15 +2859,22 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
                case '\t':
                        // we can only set this if we are not too far right
                        if (cols < columns) {
-                               loctab->GetCellInset(cell)->setText(buf.substr(op, p-op));
+                               InsetText * ti = loctab->GetCellInset(cell);
+                               LyXFont const font = ti->getLyXText(bv)->
+                                       getFont(bv->buffer(), ti->paragraph(), 0);
+                               ti->setText(buf.substr(op, p-op), font);
                                ++cols;
                                ++cell;
                        }
                        break;
                case '\n':
                        // we can only set this if we are not too far right
-                       if (cols < columns)
-                               loctab->GetCellInset(cell)->setText(buf.substr(op, p-op));
+                       if (cols < columns) {
+                               InsetText * ti = loctab->GetCellInset(cell);
+                               LyXFont const font = ti->getLyXText(bv)->
+                                       getFont(bv->buffer(), ti->paragraph(), 0);
+                               ti->setText(buf.substr(op, p-op), font);
+                       }
                        cols = ocol;
                        ++row;
                        if (row < rows)
@@ -2878,8 +2885,12 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
                op = p;
        }
        // check for the last cell if there is no trailing '\n'
-       if ((cell < cells) && (op < len))
-               loctab->GetCellInset(cell)->setText(buf.substr(op, len-op));
+       if ((cell < cells) && (op < len)) {
+               InsetText * ti = loctab->GetCellInset(cell);
+               LyXFont const font = ti->getLyXText(bv)->
+                       getFont(bv->buffer(), ti->paragraph(), 0);
+               ti->setText(buf.substr(op, len-op), font);
+       }
 
        return true;
 }
index b0e85b677eaff165305f293a48f2d51f0b571164..4eb85c6df570933dadbdd2ef3758cf37a775a26b 100644 (file)
@@ -553,6 +553,10 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
                in_update = false;
                return;
        }
+
+       if (!autoBreakRows && par->next())
+               collapseParagraphs(bv->buffer()->params);
+
        if (the_locking_inset) {
                inset_x = cx(bv) - top_x + drawTextXOffset;
                inset_y = cy(bv) + drawTextYOffset;
@@ -2059,12 +2063,12 @@ void InsetText::setParagraphData(Paragraph * p, bool same_id)
 }
 
 
-void InsetText::setText(string const & data)
+void InsetText::setText(string const & data, LyXFont const & font)
 {
        clear();
-       LyXFont font(LyXFont::ALL_SANE);
        for (unsigned int i=0; i < data.length(); ++i)
                par->insertChar(i, data[i], font);
+       reinitLyXText();
 }
 
 
@@ -2646,8 +2650,11 @@ bool InsetText::checkInsertChar(LyXFont & font)
 void InsetText::collapseParagraphs(BufferParams const & bparams) const
 {
        while(par->next()) {
-               if (!par->isSeparator(par->size()-1))
-                       par->insertChar(par->size()-1, ' ');
+               if (par->size() && par->next()->size() &&
+                       !par->isSeparator(par->size()-1))
+               {
+                       par->insertChar(par->size(), ' ');
+               }
                par->pasteParagraph(bparams);
        }
        reinitLyXText();
index d7d80b0c1b6e547525d2f8e121befd89096f89e7..cf5977a20a81022fd2941fa8ba54ed738a9469f3 100644 (file)
@@ -180,7 +180,7 @@ public:
        ///
        void setParagraphData(Paragraph *, bool same_id = false);
        ///
-       void setText(string const &);
+       void setText(string const &, LyXFont const &);
        ///
        void setAutoBreakRows(bool);
        ///