diff --git a/src/BufferView.C b/src/BufferView.C index fc1ac3a97e..b5dc13b8a7 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -764,10 +764,9 @@ bool BufferView::ChangeInsets(Inset::Code code, ParIterator end = buffer()->par_iterator_end(); for (ParIterator it = buffer()->par_iterator_begin(); it != end; ++it) { - Paragraph * par = &*(*it); bool changed_inset = false; - for (InsetList::iterator it2 = par->insetlist.begin(); - it2 != par->insetlist.end(); ++it2) { + for (InsetList::iterator it2 = it->insetlist.begin(); + it2 != it->insetlist.end(); ++it2) { if (it2.getInset()->lyxCode() == code) { InsetCommand * inset = static_cast(it2.getInset()); if (inset->getContents() == from) { @@ -784,7 +783,7 @@ bool BufferView::ChangeInsets(Inset::Code code, // The test it.size()==1 was needed to prevent crashes. // How to set the cursor corretly when it.size()>1 ?? if (it.size() == 1) { - text->setCursorIntern(par, 0); + text->setCursorIntern(*it, 0); text->redoParagraphs(text->cursor, boost::next(text->cursor.par())); text->fullRebreak(); diff --git a/src/ChangeLog b/src/ChangeLog index 314498edae..a95d555b6b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2003-05-22 Lars Gullik Bjønnes + + * tabular.C (SetMultiColumn): ws changes + + * rowpainter.C (paintFirst): get rid of a ->previous + + * lyx_cb.C (getPossibleLabel): parlist simplification + + * BufferView.C (ChangeInsets): simplify slightly. + 2003-05-20 Jürgen Spitzmüller * LyXAction.C: new lfun space-insert, kill protected-space-insert @@ -11,7 +21,7 @@ * BufferView.C: * BufferView_pimpl.C: - * buffer.[Ch]: + * buffer.[Ch]: * lyxfunc.C: * undo_funcs.C: return a ParIterator from getParFromID. diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index d6ac8879c9..74bff0e640 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2003-05-22 Lars Gullik Bjønnes + + * insetfloat.C (addToToc): parlist simplfication + 2003-05-20 Jürgen Spitzmüller * insetspace.[Ch]: added (new space insets) diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index d987fc3ec8..7c164979a5 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -365,16 +365,14 @@ void InsetFloat::addToToc(toc::TocList & toclist, Buffer const * buf) const ParIterator pit(inset.paragraphs.begin(), inset.paragraphs); ParIterator end(inset.paragraphs.end(), inset.paragraphs); - // Find a caption layout in one of the (child inset's) pars +a // Find a caption layout in one of the (child inset's) pars for (; pit != end; ++pit) { - Paragraph * tmp = &*(*pit); - - if (tmp->layout()->name() == caplayout) { + if (pit->layout()->name() == caplayout) { string const name = floatname(params_.type, buf->params); string const str = tostr(toclist[name].size() + 1) - + ". " + tmp->asString(buf, false); - toc::TocItem const item(tmp->id(), 0 , str); + + ". " + pit->asString(buf, false); + toc::TocItem const item(pit->id(), 0 , str); toclist[name].push_back(item); } } diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 63e7aa4a9b..56caaafc3e 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -420,15 +420,18 @@ string getContentsOfAsciiFile(BufferView * bv, string const & f, bool asParagrap string const getPossibleLabel(BufferView const & bv) { - Paragraph * par = &*bv.getLyXText()->cursor.par(); - LyXLayout_ptr layout = par->layout(); - if (layout->latextype == LATEX_PARAGRAPH && par->previous()) { - Paragraph * par2 = par->previous(); + ParagraphList::iterator pit = bv.getLyXText()->cursor.par(); + ParagraphList & plist = bv.getLyXText()->ownerParagraphs(); - LyXLayout_ptr const & layout2 = par2->layout(); + LyXLayout_ptr layout = pit->layout(); + + if (layout->latextype == LATEX_PARAGRAPH && pit != plist.begin()) { + ParagraphList::iterator pit2 = boost::prior(pit); + + LyXLayout_ptr const & layout2 = pit2->layout(); if (layout2->latextype != LATEX_PARAGRAPH) { - par = par2; + pit = pit2; layout = layout2; } } @@ -442,7 +445,7 @@ string const getPossibleLabel(BufferView const & bv) lyxrc.label_init_length < 0) text.erase(); - string par_text = par->asString(bv.buffer(), false); + string par_text = pit->asString(bv.buffer(), false); for (int i = 0; i < lyxrc.label_init_length; ++i) { if (par_text.empty()) break; diff --git a/src/rowpainter.C b/src/rowpainter.C index 78d2f6545f..8a738fdc41 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -634,7 +634,7 @@ void RowPainter::paintFirst() LyXLayout_ptr const & layout = pit_->layout(); if (buffer->params.paragraph_separation == BufferParams::PARSEP_SKIP) { - if (pit_->previous()) { + if (pit_ != text_.ownerParagraphs().begin()) { if (layout->latextype == LATEX_PARAGRAPH && !pit_->getDepth()) { y_top += buffer->params.getDefSkip().inPixels(bv_); diff --git a/src/support/ChangeLog b/src/support/ChangeLog index 738e6c8d30..72e33c3073 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,7 @@ +2003-05-22 Lars Gullik Bjønnes + + * lstrings.[Ch] (prefixIs,suffixIs,subst): remove variants taking + char const *. 2003-05-19 André Pönitz @@ -21,7 +25,7 @@ 2003-05-12 André Pönitz * lstrings.[Ch]: bformat() as wrapper around boost::format - + * lyxstring.h: enable templatized constructor 2003-05-06 Lars Gullik Bjønnes diff --git a/src/support/lstrings.C b/src/support/lstrings.C index 29766f641e..1a047933fe 100644 --- a/src/support/lstrings.C +++ b/src/support/lstrings.C @@ -280,30 +280,6 @@ string const ascii_lowercase(string const & a) } -bool prefixIs(string const & a, char const * pre) -{ - lyx::Assert(pre); - - size_t const l = strlen(pre); - string::size_type const alen = a.length(); - - if (l > alen || a.empty()) - return false; - else { -#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD) - // Delete this code when the compilers get a bit better. - return ::strncmp(a.c_str(), pre, l) == 0; -#else - // This is the code that we really want to use - // but until gcc ships with a basic_string that - // implements std::string correctly we have to - // use the code above. - return a.compare(0, l, pre, l) == 0; -#endif - } -} - - bool prefixIs(string const & a, string const & pre) { string::size_type const prelen = pre.length(); @@ -328,31 +304,6 @@ bool suffixIs(string const & a, char c) } -bool suffixIs(string const & a, char const * suf) -{ - lyx::Assert(suf); - - size_t const suflen = strlen(suf); - string::size_type const alen = a.length(); - - if (suflen > alen) - return false; - else { -#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD) - // Delete this code when the compilers get a bit better. - string tmp(a, alen - suflen); - return ::strncmp(tmp.c_str(), suf, suflen) == 0; -#else - // This is the code that we really want to use - // but until gcc ships with a basic_string that - // implements std::string correctly we have to - // use the code above. - return a.compare(alen - suflen, suflen, suf) == 0; -#endif - } -} - - bool suffixIs(string const & a, string const & suf) { string::size_type const suflen = suf.length(); @@ -462,23 +413,6 @@ string const subst(string const & a, char oldchar, char newchar) } -string const subst(string const & a, - char const * oldstr, string const & newstr) -{ - lyx::Assert(oldstr); - - string lstr(a); - string::size_type i = 0; - string::size_type olen = strlen(oldstr); - while ((i = lstr.find(oldstr, i)) != string::npos) { - lstr.replace(i, olen, newstr); - i += newstr.length(); // We need to be sure that we dont - // use the same i over and over again. - } - return lstr; -} - - string const subst(string const & a, string const & oldstr, string const & newstr) { @@ -704,7 +638,7 @@ string bformat(string const & fmt, string const & arg1, string const & arg2, % STRCONV(arg3) % STRCONV(arg4)).str()); } -#else +#else string bformat(string const & fmt, string const & arg1) { diff --git a/src/support/lstrings.h b/src/support/lstrings.h index 71ab15cfba..771cba3d6f 100644 --- a/src/support/lstrings.h +++ b/src/support/lstrings.h @@ -84,18 +84,12 @@ string const lowercase(string const &); /// string const uppercase(string const &); -/// Does the string start with this prefix? -bool prefixIs(string const &, char const *); - /// Does the string start with this prefix? bool prefixIs(string const &, string const &); /// Does the string end with this char? bool suffixIs(string const &, char); -/// Does the string end with this suffix? -bool suffixIs(string const &, char const *); - /// Does the string end with this suffix? bool suffixIs(string const &, string const &); @@ -152,10 +146,6 @@ bool regexMatch(string const & a, string const & pattern); /// Substitute all \a oldchar with \a newchar string const subst(string const & a, char oldchar, char newchar); -/// Substitutes all instances of \a oldstr with \a newstr -string const subst(string const & a, - char const * oldstr, string const & newstr); - /// substitutes all instances of \a oldstr with \a newstr string const subst(string const & a, string const & oldstr, string const & newstr); diff --git a/src/tabular.C b/src/tabular.C index 91a51ecca3..1a51d8ee18 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -1337,14 +1337,14 @@ void LyXTabular::SetMultiColumn(Buffer * buffer, int cell, int number) cellinfo_of_cell(cell)->right_line = column_info[column_of_cell(cell+number-1)].right_line; #if 1 for (int i = 1; i < number; ++i) { - cellinfo_of_cell(cell+i)->multicolumn = CELL_PART_OF_MULTICOLUMN; + cellinfo_of_cell(cell + i)->multicolumn = CELL_PART_OF_MULTICOLUMN; cellinfo_of_cell(cell)->inset.appendParagraphs(buffer, cellinfo_of_cell(cell+i)->inset.paragraphs); - cellinfo_of_cell(cell+i)->inset.clear(false); + cellinfo_of_cell(cell + i)->inset.clear(false); } #else for (number--; number > 0; --number) { - cellinfo_of_cell(cell+number)->multicolumn = CELL_PART_OF_MULTICOLUMN; + cellinfo_of_cell(cell + number)->multicolumn = CELL_PART_OF_MULTICOLUMN; } #endif set_row_column_number_info();