mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
optimization
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3747 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
8794b7da67
commit
8407bdc22f
@ -1,3 +1,8 @@
|
|||||||
|
2002-03-13 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||||
|
|
||||||
|
* paragraph.C: change several algorithm to be more appripriate for
|
||||||
|
the problem domain. This is lookip in FontList and in the InsetList.
|
||||||
|
|
||||||
2002-03-13 André Pönitz <poenitz@gmx.net>
|
2002-03-13 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* commandtags.h:
|
* commandtags.h:
|
||||||
|
182
src/paragraph.C
182
src/paragraph.C
@ -346,19 +346,20 @@ void Paragraph::validate(LaTeXFeatures & features) const
|
|||||||
|
|
||||||
// then the fonts
|
// then the fonts
|
||||||
Language const * doc_language = bparams.language;
|
Language const * doc_language = bparams.language;
|
||||||
|
|
||||||
for (Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
|
Pimpl::FontList::const_iterator fcit = pimpl_->fontlist.begin();
|
||||||
cit != pimpl_->fontlist.end(); ++cit) {
|
Pimpl::FontList::const_iterator fend = pimpl_->fontlist.end();
|
||||||
if (cit->font().noun() == LyXFont::ON) {
|
for (; fcit != fend; ++fcit) {
|
||||||
|
if (fcit->font().noun() == LyXFont::ON) {
|
||||||
lyxerr[Debug::LATEX] << "font.noun: "
|
lyxerr[Debug::LATEX] << "font.noun: "
|
||||||
<< cit->font().noun()
|
<< fcit->font().noun()
|
||||||
<< endl;
|
<< endl;
|
||||||
features.require("noun");
|
features.require("noun");
|
||||||
lyxerr[Debug::LATEX] << "Noun enabled. Font: "
|
lyxerr[Debug::LATEX] << "Noun enabled. Font: "
|
||||||
<< cit->font().stateText(0)
|
<< fcit->font().stateText(0)
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
switch (cit->font().color()) {
|
switch (fcit->font().color()) {
|
||||||
case LColor::none:
|
case LColor::none:
|
||||||
case LColor::inherit:
|
case LColor::inherit:
|
||||||
case LColor::ignore:
|
case LColor::ignore:
|
||||||
@ -370,11 +371,11 @@ void Paragraph::validate(LaTeXFeatures & features) const
|
|||||||
default:
|
default:
|
||||||
features.require("color");
|
features.require("color");
|
||||||
lyxerr[Debug::LATEX] << "Color enabled. Font: "
|
lyxerr[Debug::LATEX] << "Color enabled. Font: "
|
||||||
<< cit->font().stateText(0)
|
<< fcit->font().stateText(0)
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Language const * language = cit->font().language();
|
Language const * language = fcit->font().language();
|
||||||
if (language->babel() != doc_language->babel() &&
|
if (language->babel() != doc_language->babel() &&
|
||||||
language != ignore_language &&
|
language != ignore_language &&
|
||||||
#ifdef INHERIT_LANGUAGE
|
#ifdef INHERIT_LANGUAGE
|
||||||
@ -391,12 +392,13 @@ void Paragraph::validate(LaTeXFeatures & features) const
|
|||||||
// then the insets
|
// then the insets
|
||||||
LyXLayout const & lout = textclasslist[bparams.textclass][layout()];
|
LyXLayout const & lout = textclasslist[bparams.textclass][layout()];
|
||||||
|
|
||||||
for (InsetList::const_iterator cit = insetlist.begin();
|
InsetList::const_iterator icit = insetlist.begin();
|
||||||
cit != insetlist.end(); ++cit) {
|
InsetList::const_iterator iend = insetlist.end();
|
||||||
if (cit->inset) {
|
for (; icit != iend; ++icit) {
|
||||||
cit->inset->validate(features);
|
if (icit->inset) {
|
||||||
|
icit->inset->validate(features);
|
||||||
if (lout.needprotect &&
|
if (lout.needprotect &&
|
||||||
cit->inset->lyxCode() == Inset::FOOT_CODE)
|
icit->inset->lyxCode() == Inset::FOOT_CODE)
|
||||||
features.require("NeedLyXFootnoteCode");
|
features.require("NeedLyXFootnoteCode");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -435,12 +437,14 @@ void Paragraph::cutIntoMinibuffer(BufferParams const & bparams, pos_type pos)
|
|||||||
// the inset, not just a clone. Otherwise
|
// the inset, not just a clone. Otherwise
|
||||||
// the inset would be deleted when calling Erase(pos)
|
// the inset would be deleted when calling Erase(pos)
|
||||||
// find the entry
|
// find the entry
|
||||||
InsetTable search_elem(pos, 0);
|
InsetList::iterator it = insetlist.begin();
|
||||||
InsetList::iterator it =
|
InsetList::iterator end = insetlist.end();
|
||||||
lower_bound(insetlist.begin(),
|
for (; it != end; ++it) {
|
||||||
insetlist.end(),
|
if (it->pos == pos)
|
||||||
search_elem, Pimpl::matchIT());
|
break;
|
||||||
if (it != insetlist.end() && it->pos == pos)
|
}
|
||||||
|
|
||||||
|
if (it != end && it->pos == pos)
|
||||||
it->inset = 0;
|
it->inset = 0;
|
||||||
// the inset is not in a paragraph anymore
|
// the inset is not in a paragraph anymore
|
||||||
minibuffer_inset->parOwner(0);
|
minibuffer_inset->parOwner(0);
|
||||||
@ -532,15 +536,18 @@ Inset * Paragraph::getInset(pos_type pos)
|
|||||||
lyx::Assert(pos < size());
|
lyx::Assert(pos < size());
|
||||||
|
|
||||||
// Find the inset.
|
// Find the inset.
|
||||||
InsetTable search_inset(pos, 0);
|
InsetList::iterator it = insetlist.begin();
|
||||||
InsetList::iterator it = lower_bound(insetlist.begin(),
|
InsetList::iterator end = insetlist.end();
|
||||||
insetlist.end(),
|
for (; it != end; ++it) {
|
||||||
search_inset, Pimpl::matchIT());
|
if (it->pos == pos)
|
||||||
if (it != insetlist.end() && it->pos == pos)
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (it != end && it->pos == pos)
|
||||||
return it->inset;
|
return it->inset;
|
||||||
|
|
||||||
lyxerr << "ERROR (Paragraph::getInset): "
|
lyxerr << "ERROR (Paragraph::getInset): "
|
||||||
"Inset does not exist: " << pos << endl;
|
<< "Inset does not exist: " << pos << endl;
|
||||||
//::raise(SIGSTOP);
|
//::raise(SIGSTOP);
|
||||||
|
|
||||||
// text[pos] = ' '; // WHY!!! does this set the pos to ' '????
|
// text[pos] = ' '; // WHY!!! does this set the pos to ' '????
|
||||||
@ -557,15 +564,18 @@ Inset const * Paragraph::getInset(pos_type pos) const
|
|||||||
lyx::Assert(pos < size());
|
lyx::Assert(pos < size());
|
||||||
|
|
||||||
// Find the inset.
|
// Find the inset.
|
||||||
InsetTable search_inset(pos, 0);
|
InsetList::const_iterator cit = insetlist.begin();
|
||||||
InsetList::const_iterator cit = lower_bound(insetlist.begin(),
|
InsetList::const_iterator end = insetlist.end();
|
||||||
insetlist.end(),
|
for (; cit != end; ++cit) {
|
||||||
search_inset, Pimpl::matchIT());
|
if (cit->pos == pos)
|
||||||
if (cit != insetlist.end() && cit->pos == pos)
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cit != end && cit->pos == pos)
|
||||||
return cit->inset;
|
return cit->inset;
|
||||||
|
|
||||||
lyxerr << "ERROR (Paragraph::GetInset): "
|
lyxerr << "ERROR (Paragraph::getInset): "
|
||||||
"Inset does not exist: " << pos << endl;
|
<< "Inset does not exist: " << pos << endl;
|
||||||
//::raise(SIGSTOP);
|
//::raise(SIGSTOP);
|
||||||
//text[pos] = ' '; // WHY!!! does this set the pos to ' '????
|
//text[pos] = ' '; // WHY!!! does this set the pos to ' '????
|
||||||
// Did this commenting out introduce a bug? So far I have not
|
// Did this commenting out introduce a bug? So far I have not
|
||||||
@ -581,13 +591,16 @@ LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
|
|||||||
pos_type pos) const
|
pos_type pos) const
|
||||||
{
|
{
|
||||||
lyx::Assert(pos <= size());
|
lyx::Assert(pos <= size());
|
||||||
|
|
||||||
Pimpl::FontTable search_font(pos, LyXFont());
|
Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
|
||||||
Pimpl::FontList::const_iterator cit = lower_bound(pimpl_->fontlist.begin(),
|
Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
|
||||||
pimpl_->fontlist.end(),
|
for (; cit != end; ++cit) {
|
||||||
search_font, Pimpl::matchFT());
|
if (cit->pos() > pos)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
LyXFont retfont;
|
LyXFont retfont;
|
||||||
if (cit != pimpl_->fontlist.end()) {
|
if (cit != end) {
|
||||||
retfont = cit->font();
|
retfont = cit->font();
|
||||||
} else if (pos == size() && size()) {
|
} else if (pos == size() && size()) {
|
||||||
retfont = getFontSettings(bparams, pos - 1);
|
retfont = getFontSettings(bparams, pos - 1);
|
||||||
@ -679,21 +692,23 @@ Paragraph::highestFontInRange(pos_type startpos, pos_type endpos,
|
|||||||
if (pimpl_->fontlist.empty())
|
if (pimpl_->fontlist.empty())
|
||||||
return def_size;
|
return def_size;
|
||||||
|
|
||||||
LyXFont::FONT_SIZE maxsize = LyXFont::SIZE_TINY;
|
Pimpl::FontList::const_iterator end_it = pimpl_->fontlist.begin();
|
||||||
Pimpl::FontTable end_search(endpos, LyXFont());
|
Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
|
||||||
Pimpl::FontList::const_iterator end_it =
|
for (; end_it != end; ++end_it) {
|
||||||
lower_bound(pimpl_->fontlist.begin(),
|
if (end_it->pos() > endpos)
|
||||||
pimpl_->fontlist.end(),
|
break;
|
||||||
end_search, Pimpl::matchFT());
|
}
|
||||||
if (end_it != pimpl_->fontlist.end())
|
|
||||||
|
if (end_it != end)
|
||||||
++end_it;
|
++end_it;
|
||||||
|
|
||||||
Pimpl::FontTable start_search(startpos, LyXFont());
|
Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
|
||||||
Pimpl::FontList::const_iterator cit =
|
for (; cit != end; ++cit) {
|
||||||
lower_bound(pimpl_->fontlist.begin(),
|
if (cit->pos() > startpos)
|
||||||
pimpl_->fontlist.end(),
|
break;
|
||||||
start_search, Pimpl::matchFT());
|
}
|
||||||
|
|
||||||
|
LyXFont::FONT_SIZE maxsize = LyXFont::SIZE_TINY;
|
||||||
for (; cit != end_it; ++cit) {
|
for (; cit != end_it; ++cit) {
|
||||||
LyXFont::FONT_SIZE size = cit->font().size();
|
LyXFont::FONT_SIZE size = cit->font().size();
|
||||||
if (size == LyXFont::INHERIT_SIZE)
|
if (size == LyXFont::INHERIT_SIZE)
|
||||||
@ -757,18 +772,21 @@ void Paragraph::setFont(pos_type pos, LyXFont const & font)
|
|||||||
// in a new kernel. (Asger)
|
// in a new kernel. (Asger)
|
||||||
// Next search font table
|
// Next search font table
|
||||||
|
|
||||||
Pimpl::FontTable search_font(pos, LyXFont());
|
Pimpl::FontList::iterator beg = pimpl_->fontlist.begin();
|
||||||
Pimpl::FontList::iterator it = lower_bound(pimpl_->fontlist.begin(),
|
Pimpl::FontList::iterator it = beg;
|
||||||
pimpl_->fontlist.end(),
|
Pimpl::FontList::iterator endit = pimpl_->fontlist.end();
|
||||||
search_font, Pimpl::matchFT());
|
for (; it != endit; ++it) {
|
||||||
unsigned int i = it - pimpl_->fontlist.begin();
|
if (it->pos() > pos)
|
||||||
bool notfound = it == pimpl_->fontlist.end();
|
break;
|
||||||
|
}
|
||||||
|
unsigned int i = std::distance(beg, it);
|
||||||
|
bool notfound = (it == endit);
|
||||||
|
|
||||||
if (!notfound && pimpl_->fontlist[i].font() == font)
|
if (!notfound && pimpl_->fontlist[i].font() == font)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool begin = pos == 0 || notfound ||
|
bool begin = pos == 0 || notfound ||
|
||||||
(i > 0 && pimpl_->fontlist[i-1].pos() == pos - 1);
|
(i > 0 && pimpl_->fontlist[i - 1].pos() == pos - 1);
|
||||||
// Is position pos is a beginning of a font block?
|
// Is position pos is a beginning of a font block?
|
||||||
bool end = !notfound && pimpl_->fontlist[i].pos() == pos;
|
bool end = !notfound && pimpl_->fontlist[i].pos() == pos;
|
||||||
// Is position pos is the end of a font block?
|
// Is position pos is the end of a font block?
|
||||||
@ -1191,10 +1209,13 @@ Paragraph const * Paragraph::outerHook() const
|
|||||||
Paragraph::inset_iterator
|
Paragraph::inset_iterator
|
||||||
Paragraph::InsetIterator(pos_type pos)
|
Paragraph::InsetIterator(pos_type pos)
|
||||||
{
|
{
|
||||||
InsetTable search_inset(pos, 0);
|
InsetList::iterator it = insetlist.begin();
|
||||||
InsetList::iterator it = lower_bound(insetlist.begin(),
|
InsetList::iterator end = insetlist.end();
|
||||||
insetlist.end(),
|
for (; it != end; ++it) {
|
||||||
search_inset, Pimpl::matchIT());
|
if (it->pos == pos)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return inset_iterator(it);
|
return inset_iterator(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1203,8 +1224,9 @@ Paragraph::InsetIterator(pos_type pos)
|
|||||||
int Paragraph::getPositionOfInset(Inset const * inset) const
|
int Paragraph::getPositionOfInset(Inset const * inset) const
|
||||||
{
|
{
|
||||||
// Find the entry.
|
// Find the entry.
|
||||||
for (InsetList::const_iterator cit = insetlist.begin();
|
InsetList::const_iterator cit = insetlist.begin();
|
||||||
cit != insetlist.end(); ++cit) {
|
InsetList::const_iterator end = insetlist.end();
|
||||||
|
for (; cit != end; ++cit) {
|
||||||
if (cit->inset == inset) {
|
if (cit->inset == inset) {
|
||||||
return cit->pos;
|
return cit->pos;
|
||||||
}
|
}
|
||||||
@ -1974,8 +1996,10 @@ void Paragraph::changeLanguage(BufferParams const & bparams,
|
|||||||
bool Paragraph::isMultiLingual(BufferParams const & bparams)
|
bool Paragraph::isMultiLingual(BufferParams const & bparams)
|
||||||
{
|
{
|
||||||
Language const * doc_language = bparams.language;
|
Language const * doc_language = bparams.language;
|
||||||
for (Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
|
Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
|
||||||
cit != pimpl_->fontlist.end(); ++cit)
|
Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
|
||||||
|
|
||||||
|
for (; cit != end; ++cit)
|
||||||
if (cit->font().language() != ignore_language &&
|
if (cit->font().language() != ignore_language &&
|
||||||
cit->font().language() != latex_language &&
|
cit->font().language() != latex_language &&
|
||||||
#ifdef INHERIT_LANGUAGE
|
#ifdef INHERIT_LANGUAGE
|
||||||
@ -2044,8 +2068,9 @@ string const Paragraph::asString(Buffer const * buffer,
|
|||||||
void Paragraph::setInsetOwner(Inset * i)
|
void Paragraph::setInsetOwner(Inset * i)
|
||||||
{
|
{
|
||||||
pimpl_->inset_owner = i;
|
pimpl_->inset_owner = i;
|
||||||
for (InsetList::const_iterator cit = insetlist.begin();
|
InsetList::const_iterator cit = insetlist.begin();
|
||||||
cit != insetlist.end(); ++cit) {
|
InsetList::const_iterator end = insetlist.end();
|
||||||
|
for (; cit != end; ++cit) {
|
||||||
if (cit->inset)
|
if (cit->inset)
|
||||||
cit->inset->setOwner(i);
|
cit->inset->setOwner(i);
|
||||||
}
|
}
|
||||||
@ -2055,13 +2080,12 @@ void Paragraph::setInsetOwner(Inset * i)
|
|||||||
void Paragraph::deleteInsetsLyXText(BufferView * bv)
|
void Paragraph::deleteInsetsLyXText(BufferView * bv)
|
||||||
{
|
{
|
||||||
// then the insets
|
// then the insets
|
||||||
for (InsetList::const_iterator cit = insetlist.begin();
|
InsetList::const_iterator cit = insetlist.begin();
|
||||||
cit != insetlist.end(); ++cit) {
|
InsetList::const_iterator end = insetlist.end();
|
||||||
if (cit->inset) {
|
for (; cit != end; ++cit) {
|
||||||
if (cit->inset->isTextInset()) {
|
if (cit->inset && cit->inset->isTextInset()) {
|
||||||
static_cast<UpdatableInset *>
|
static_cast<UpdatableInset *>
|
||||||
(cit->inset)->deleteLyXText(bv, true);
|
(cit->inset)->deleteLyXText(bv, true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2070,9 +2094,9 @@ void Paragraph::deleteInsetsLyXText(BufferView * bv)
|
|||||||
void Paragraph::resizeInsetsLyXText(BufferView * bv)
|
void Paragraph::resizeInsetsLyXText(BufferView * bv)
|
||||||
{
|
{
|
||||||
// then the insets
|
// then the insets
|
||||||
for (InsetList::const_iterator cit = insetlist.begin();
|
InsetList::const_iterator cit = insetlist.begin();
|
||||||
cit != insetlist.end(); ++cit)
|
InsetList::const_iterator end = insetlist.end();
|
||||||
{
|
for (; cit != end; ++cit) {
|
||||||
if (cit->inset) {
|
if (cit->inset) {
|
||||||
if (cit->inset->isTextInset()) {
|
if (cit->inset->isTextInset()) {
|
||||||
static_cast<UpdatableInset *>
|
static_cast<UpdatableInset *>
|
||||||
|
Loading…
Reference in New Issue
Block a user