]> git.lyx.org Git - features.git/commitdiff
Small fixes to various InsetText problems.
authorJürgen Vigna <jug@sad.it>
Fri, 19 Oct 2001 15:40:01 +0000 (15:40 +0000)
committerJürgen Vigna <jug@sad.it>
Fri, 19 Oct 2001 15:40:01 +0000 (15:40 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2903 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/insets/inset.C
src/insets/inset.h
src/insets/insetcollapsable.h
src/insets/insetert.h
src/insets/insettext.h
src/mathed/math_macrotable.C
src/paragraph.C
src/paragraph_pimpl.C
src/text.C
src/text2.C

index 3bd2010c01a107b6c24bffda225180b91d65a4fd..f998df225d46a73fc6a66188fac78c4f77f0153e 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-19  Juergen Vigna  <jug@sad.it>
+
+       * text.C (workWidth): use getRow instead of wrong algorithm.
+       (setHeightOfRow): fix for MARGIN_RIGHT_ADDRESS_BOX
+
 2001-10-19  John Levon  <moz@compsoc.man.ac.uk>
 
        * lyxserver.h:
index 1b187425a5434725cbceb589d9a22c7e504a0154..90c7d74e2dbbe96c2904041858b0fa47ed6e89b3 100644 (file)
@@ -324,7 +324,6 @@ int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const
        if ((w - ((2 * TEXT_TO_INSET_OFFSET) + 5)) >= 0)
                w -= (2 * TEXT_TO_INSET_OFFSET) + 5;
        if (topx_set && owner()) {
-               lyxerr << "topx_set && owner()\n";
                w -= top_x;
                w += owner()->x();
        }
index 9c03cdf90fff379c74e0a5d3dd9e4e7e30e2062a..3e9e04f452bd5426a5f34c8ba4de9a18602cc888 100644 (file)
@@ -291,6 +291,10 @@ public:
        /// we need this here because collapsed insets are only EDITABLE
        virtual void setFont(BufferView *, LyXFont const &,
                          bool toggleall = false, bool selectall = false);
+       ///
+       // needed for spellchecking text
+       ///
+       virtual bool allowSpellcheck() { return false; }
 protected:
        ///
        mutable int top_x;
@@ -471,6 +475,8 @@ public:
        ///
        // needed for spellchecking text
        ///
+       virtual bool allowSpellcheck() { return false; }
+       ///
        virtual string const selectNextWordToSpellcheck(BufferView *, float & value) const;
        ///
        virtual void selectSelectedWord(BufferView *) { return; }
index 38cefa54e5bf3efff98ff671ad0d0f4c08c82ca3..1653bd6639ad84d793f091194e184e5decbd4f83 100644 (file)
@@ -175,6 +175,7 @@ public:
        ///
        void close(BufferView *) const;
        ///
+       bool allowSpellcheck() { return inset.allowSpellcheck(); }
        string const selectNextWordToSpellcheck(BufferView *, float &) const;
 
        void selectSelectedWord(BufferView * bv) {
index e908766d71552c5d7c06e59767368097ef903de7..655953f502043956b724b2f164eafdfd72ee26c2 100644 (file)
@@ -97,6 +97,7 @@ public:
        ///
        void close(BufferView *) const;
        ///
+       bool allowSpellcheck() { return false; }
        string const selectNextWordToSpellcheck(BufferView *, float &) const;
        ///
        bool inlined() const { return status_ == Inlined; }
index a304a1d18dd3a6c8a2c5336af415633477d8c4e4..dc574ef903c36da4e41a6fc1bf5f4eaba5493ad4 100644 (file)
@@ -229,6 +229,7 @@ public:
        ///
        void paragraph(Paragraph *);
        ///
+       bool allowSpellcheck() { return true; }
        string const selectNextWordToSpellcheck(BufferView *, float & value) const;
        void selectSelectedWord(BufferView *);
        void toggleSelection(BufferView *, bool kill_selection);
index d6e171994baf9f81e5fe928abc3aca889a9f7019..c120da64f85c6c3b7fffee53ddb7913527b2c2e8 100644 (file)
@@ -77,7 +77,6 @@ void MathMacroTable::builtinMacros()
 
        built = true;
        //lyxerr[Debug::MATHED] << "Building macros\n";
-D
        //create("emptyset",     0, "\\not0");
        create("notin",        0, "\\not\\in");
        create("slash",        0, "/");
index 9ecffaf0e9ef1273fa961d11e9855f23f8506195..36d87fbc28bbd45290ebf0e5325d3f29eef533f7 100644 (file)
@@ -492,32 +492,29 @@ bool Paragraph::checkInsertChar(LyXFont & font)
 }
 
 
-void Paragraph::insertChar(Paragraph::size_type pos,
-                             Paragraph::value_type c)
+void Paragraph::insertChar(Paragraph::size_type pos, Paragraph::value_type c)
 {
        LyXFont const f(LyXFont::ALL_INHERIT);
        insertChar(pos, c, f);
 }
 
 
-void Paragraph::insertChar(Paragraph::size_type pos,
-                             Paragraph::value_type c,
-                             LyXFont const & font)
+void Paragraph::insertChar(Paragraph::size_type pos, Paragraph::value_type c,
+                           LyXFont const & font)
 {
        pimpl_->insertChar(pos, c, font);
 }
 
 
-void Paragraph::insertInset(Paragraph::size_type pos,
-                              Inset * inset)
+void Paragraph::insertInset(Paragraph::size_type pos, Inset * inset)
 {
        LyXFont const f(LyXFont::ALL_INHERIT);
        insertInset(pos, inset, f);
 }
 
 
-void Paragraph::insertInset(Paragraph::size_type pos,
-                              Inset * inset, LyXFont const & font)
+void Paragraph::insertInset(Paragraph::size_type pos, Inset * inset,
+                            LyXFont const & font)
 {
        pimpl_->insertInset(pos, inset, font);
 }
index 6fc618418955b4ecb60e235522bb3a6317e36e91..a2a31eb5fa3a627a49cb40a93f56231604dd6904 100644 (file)
@@ -83,15 +83,15 @@ Paragraph::Pimpl::getChar(Paragraph::size_type pos) const
 
 
 void Paragraph::Pimpl::setChar(Paragraph::size_type pos,
-                              Paragraph::value_type c)
+                               Paragraph::value_type c)
 {
        text[pos] = c;
 }
 
 
 void Paragraph::Pimpl::insertChar(Paragraph::size_type pos,
-                                 Paragraph::value_type c,
-                                 LyXFont const & font)
+                                  Paragraph::value_type c,
+                                  LyXFont const & font)
 {
        lyx::Assert(pos <= size());
 
@@ -100,19 +100,22 @@ void Paragraph::Pimpl::insertChar(Paragraph::size_type pos,
        // Update the font table.
        FontTable search_font(pos, LyXFont());
        for (FontList::iterator it = std::lower_bound(fontlist.begin(),
-                                                     fontlist.end(),
-                                                     search_font, matchFT());
+                                                     fontlist.end(),
+                                                     search_font, matchFT());
             it != fontlist.end(); ++it)
+       {
                it->pos(it->pos() + 1);
+       }
    
        // Update the inset table.
        InsetTable search_inset(pos, 0);
        for (InsetList::iterator it = std::lower_bound(owner_->insetlist.begin(),
-                                                      owner_->insetlist.end(),
-                                                      search_inset, matchIT());
+                                                      owner_->insetlist.end(),
+                                                      search_inset, matchIT());
             it != owner_->insetlist.end(); ++it)
+       {
                ++it->pos;
-
+       }
        owner_->setFont(pos, font);
 }
 
index 02afce8f7d1b087ec3ca4659d84044e895a11ea8..b859f46b550f56fc373f49ef2bdf854c6e4b4515 100644 (file)
@@ -80,9 +80,7 @@ int LyXText::workWidth(BufferView * bview, Inset * inset) const
                        break;
                }
        }
-       
        if (!par) {
-               lyxerr << "LyXText::workWidth: cannot find inset!" <<endl;
                return workWidth(bview);
        }
        
@@ -99,19 +97,19 @@ int LyXText::workWidth(BufferView * bview, Inset * inset) const
                dummyrow.pos(pos);
                return workWidth(bview) - leftMargin(bview, &dummyrow);
        } else {
-               Row * row = firstrow;
-               for(; row; row = row->next()) {
-                       if ((row->par() == par && row->pos() >= pos)) {
-                               if (!row->next())
-                                       break;
-                               else if ((row->next()->par() == par) &&
-                                        (row->next()->pos() >= pos))
-                                       continue;
-                       }
-               }
-               if (row) {
-                       return workWidth(bview) - leftMargin(bview, row);
-               } 
+               int dummy_y;
+               Row * row = getRow(par, pos, dummy_y);
+               Row * frow = row;
+               while(frow->previous() && frow->par() == frow->previous()->par())
+                       frow = frow->previous();
+               int maxw = 0;
+               while(frow->next() && frow->par() == frow->next()->par()) {
+                       if ((frow != row) && (maxw < frow->width()))
+                               maxw = frow->width();
+                       frow = frow->next();
+               }
+               if (maxw)
+                       return maxw;
        }
        return workWidth(bview);
 }
@@ -681,8 +679,8 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
                // make a corresponding row. Needed to call LeftMargin()
                
                // check wether it is a sufficent paragraph 
-               if (newpar
-                   && tclass[newpar->getLayout()].isEnvironment()) {
+               if (newpar && tclass[newpar->getLayout()].isEnvironment())
+               {
                        Row dummyrow;
                        dummyrow.par(newpar);
                        dummyrow.pos(newpar->size());
@@ -1011,7 +1009,8 @@ int LyXText::fill(BufferView * bview, Row * row, int paper_width) const
        // special handling of the right address boxes
        if (textclasslist.Style(bview->buffer()->params.textclass,
                                row->par()->getLayout()).margintype
-           == MARGIN_RIGHT_ADDRESS_BOX) {
+           == MARGIN_RIGHT_ADDRESS_BOX)
+       {
                int const tmpfill = row->fill();
                row->fill(0); // the minfill in MarginLeft()
                w = leftMargin(bview, row);
@@ -1507,9 +1506,11 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
        row_ptr->baseline(maxasc + labeladdon);
        
        height += row_ptr->height();
-       float x;
-       float dummy;
-       prepareToPrint(bview, row_ptr, x, dummy, dummy, dummy, false);
+       float x = 0;
+       if (layout.margintype != MARGIN_RIGHT_ADDRESS_BOX) {
+               float dummy;
+               prepareToPrint(bview, row_ptr, x, dummy, dummy, dummy, false);
+       }
        row_ptr->width(int(maxwidth + x));
        if (inset_owner) {
                Row * r = firstrow;
@@ -2297,7 +2298,7 @@ bool LyXText::selectWordWhenUnderCursor(BufferView * bview,
 // This function is only used by the spellchecker for NextWord().
 // It doesn't handle LYX_ACCENTs and probably never will.
 string const LyXText::selectNextWordToSpellcheck(BufferView * bview,
-                                     float & value) const
+                                                 float & value) const
 {
        if (the_locking_inset) {
                string str = the_locking_inset->selectNextWordToSpellcheck(bview, value);
@@ -2331,7 +2332,7 @@ string const LyXText::selectNextWordToSpellcheck(BufferView * bview,
        while ((cursor.par()->size() > cursor.pos()
               && (!cursor.par()->isLetter(cursor.pos()))
               && (!cursor.par()->isInset(cursor.pos()) ||
-                  !cursor.par()->getInset(cursor.pos())->isTextInset()))
+                          !cursor.par()->getInset(cursor.pos())->allowSpellcheck()))
               || (cursor.par()->size() == cursor.pos()
                   && cursor.par()->next()))
        {      
index c3c0be6f3aefb11779a06e92b6a879196695f17f..500b2a7a536e3447f96ff8985b158979741aa150 100644 (file)
@@ -1984,7 +1984,7 @@ bool LyXText::gotoNextInset(BufferView * bview,
 
 
 void LyXText::checkParagraph(BufferView * bview, Paragraph * par,
-                            Paragraph::size_type pos)
+                             Paragraph::size_type pos)
 {
        LyXCursor tmpcursor;                    
 
@@ -2027,7 +2027,8 @@ void LyXText::checkParagraph(BufferView * bview, Paragraph * par,
        // check the special right address boxes
        if (textclasslist.Style(bview->buffer()->params.textclass,
                                par->getLayout()).margintype
-           == MARGIN_RIGHT_ADDRESS_BOX) {
+           == MARGIN_RIGHT_ADDRESS_BOX)
+       {
                tmpcursor.par(par);
                tmpcursor.row(row);
                tmpcursor.y(y);