diff --git a/src/ChangeLog b/src/ChangeLog index 62a9f6bfc1..b178353f51 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2002-01-20 Jean-Marc Lasgouttes + + * tabular.C (GetCellFromInset): new method. Finds an inset in a + tabular. It is possible to provide a possible cell, which will + typically be the actcell from the corresponding insettabular + + * lyxfunc.C (getStatus): small cleanup; disable + LFUN_LAYOUT_PARAGRAPHS in insets where forceDefaultParagraphs is + true + 2002-01-19 Jean-Marc Lasgouttes * tabular.C (Validate): remove broken optimization (fixes bug #201) diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 9ee06c2ac6..9d25518941 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,5 +1,12 @@ +2002-01-20 Herbert Voss + + * ControlGraphic.C (Browse): add extension "ps" when browsing for + a filename + 2002-01-19 Herbert Voss + * biblio.C (getInfo): fix bug when no author is given + * biblio.C (parseBibTeX): change the parsing, so that '#'-characters in a bibtex entry are no more a problem. diff --git a/src/frontends/controllers/ControlGraphics.C b/src/frontends/controllers/ControlGraphics.C index 99bac62c93..a3675b159d 100644 --- a/src/frontends/controllers/ControlGraphics.C +++ b/src/frontends/controllers/ControlGraphics.C @@ -80,7 +80,7 @@ string const ControlGraphics::Browse(string const & in_name) { string const title = N_("Graphics"); // FIXME: currently we need the second '|' to prevent mis-interpretation - string const pattern = "*.(eps|png|jpeg|jpg|gif)|"; + string const pattern = "*.(ps|eps|png|jpeg|jpg|gif)|"; // Does user clipart directory exist? string clipdir = AddName (user_lyxdir, "clipart"); diff --git a/src/frontends/controllers/biblio.C b/src/frontends/controllers/biblio.C index 82ed0aebc0..a973c6e843 100644 --- a/src/frontends/controllers/biblio.C +++ b/src/frontends/controllers/biblio.C @@ -266,9 +266,10 @@ string const getInfo(InfoMap const & map, string const & key) media = parseBibTeX(it->second, "institution"); ostringstream result; - result << author; + if (!author.empty()) + result << author << ", "; if (!title.empty()) - result << ", " << title; + result << title; if (!booktitle.empty()) result << ", in " << booktitle; if (!chapter.empty()) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index dd53a6c259..edaf7196ac 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2002-01-20 Jean-Marc Lasgouttes + + * insettabular.C (getMaxWidth): + (forceDefaultParagraphs): use Tabular::GetCellFromInset + 2002-01-19 Jean-Marc Lasgouttes * insettabular.C (getMaxWidthOfCell): adapt to the new definition diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 8674770654..c504aa15ff 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -2122,27 +2122,11 @@ int InsetTabular::getMaxWidthOfCell(BufferView * bv, int cell) const int InsetTabular::getMaxWidth(BufferView * bv, UpdatableInset const * inset) const { - int cell = tabular->cur_cell; - if (tabular->GetCellInset(cell) != inset) { - cell = actcell; - if (tabular->GetCellInset(cell) != inset) { - - lyxerr[Debug::INSETTEXT] << "Actcell not equal to actual cell!\n"; - cell = -1; - } - } - - int const n = tabular->GetNumberOfCells(); + int cell = tabular->GetCellFromInset(inset, actcell); if (cell == -1) { - for (cell = 0; cell < n; ++cell) { - if (tabular->GetCellInset(cell) == inset) - break; - } - } - - if (cell >= n) { - lyxerr << "Own inset not found, shouldn't really happen!\n"; + lyxerr << "Own inset not found, shouldn't really happen!" + << endl; return -1; } @@ -2725,30 +2709,11 @@ bool InsetTabular::insetAllowed(Inset::Code code) const bool InsetTabular::forceDefaultParagraphs(Inset const * in) const { - int const n = tabular->GetNumberOfCells(); - static int last = 0; + const int cell = tabular->GetCellFromInset(in, actcell); - // maybe some speedup - if ((last < n) && tabular->GetCellInset(last) == in) { - if (tabular->GetPWidth(last).zero()) - return true; - return false; - } - if ((++last < n) && tabular->GetCellInset(last) == in) { - if (tabular->GetPWidth(last).zero()) - return true; - return false; - } + if (cell != -1) + return tabular->GetPWidth(cell).zero(); - for(int i=0; i < n; ++i) { - if (tabular->GetCellInset(i) == in) { - last = i; - if (tabular->GetPWidth(i).zero()) - return true; - return false; - } - } - last = 0; // well we didn't obviously find it so maybe our owner knows more if (owner()) return owner()->forceDefaultParagraphs(in); diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 08da670326..26d83c051c 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -379,6 +379,8 @@ FuncStatus LyXFunc::getStatus(kb_action action, } } + UpdatableInset * tli = owner->view()->theLockingInset(); + // I would really like to avoid having this switch and rather try to // encode this in the function itself. bool disable = false; @@ -413,27 +415,29 @@ FuncStatus LyXFunc::getStatus(kb_action action, break; case LFUN_LAYOUT_TABULAR: - disable = true; - if (owner->view()->theLockingInset()) { - disable = (owner->view()->theLockingInset()->lyxCode() != Inset::TABULAR_CODE) && - !owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE); - } + disable = !tli + || (tli->lyxCode() != Inset::TABULAR_CODE + && !tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)); break; + case LFUN_LAYOUT_PARAGRAPH: { + Inset * inset = TEXT(false)->cursor.par()->inInset(); + disable = inset && inset->forceDefaultParagraphs(inset); + break; + } + case LFUN_TABULAR_FEATURE: disable = true; - if (owner->view()->theLockingInset()) { + if (tli) { FuncStatus ret; //ret.disabled(true); - if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) { + if (tli->lyxCode() == Inset::TABULAR_CODE) { + ret = static_cast(tli) + ->getStatus(argument); + } else if (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) { ret = static_cast - (owner->view()->theLockingInset())-> - getStatus(argument); - } else if (owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) { - ret = static_cast - (owner->view()->theLockingInset()-> - getFirstLockingInsetOfType(Inset::TABULAR_CODE))-> - getStatus(argument); + (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) + ->getStatus(argument); } flag |= ret; disable = false; @@ -443,7 +447,8 @@ FuncStatus LyXFunc::getStatus(kb_action action, disable = true; ret = inset.getStatus(argument); - if (ret.onoff(true) || ret.onoff(false)) flag.setOnOff(false); + if (ret.onoff(true) || ret.onoff(false)) + flag.setOnOff(false); } break; @@ -471,13 +476,7 @@ FuncStatus LyXFunc::getStatus(kb_action action, disable = (TEXT(false)->getInset() == 0); break; - case LFUN_MATH_VALIGN: { - // I think this test can be simplified (Andre') - // mathcursor is != 0 iff we are in math mode - //Inset * tli = owner->view()->theLockingInset(); - //if (tli && (tli->lyxCode() == Inset::MATH_CODE - // || tli->lyxCode() == Inset::MATHMACRO_CODE)) { - // + case LFUN_MATH_VALIGN: if (mathcursor) { char align = mathcursor->valign(); if (align == '\0') { @@ -496,11 +495,8 @@ FuncStatus LyXFunc::getStatus(kb_action action, } else disable = true; break; - } - case LFUN_MATH_HALIGN: { - //Inset * tli = owner->view()->theLockingInset(); - //if (tli && (tli->lyxCode() == Inset::MATH_CODE - // || tli->lyxCode() == Inset::MATHMACRO_CODE)) { + + case LFUN_MATH_HALIGN: if (mathcursor) { char align = mathcursor->halign(); if (align == '\0') { @@ -519,9 +515,8 @@ FuncStatus LyXFunc::getStatus(kb_action action, } else disable = true; break; - } - case LFUN_MATH_MUTATE: { - Inset * tli = owner->view()->theLockingInset(); + + case LFUN_MATH_MUTATE: if (tli && (tli->lyxCode() == Inset::MATH_CODE)) { MathInsetTypes type = mathcursor->formula()->getType(); if (argument == "inline") { @@ -538,7 +533,6 @@ FuncStatus LyXFunc::getStatus(kb_action action, } else disable = true; break; - } // we just need to be in math mode to enable that case LFUN_MATH_SIZE: @@ -663,9 +657,7 @@ FuncStatus LyXFunc::getStatus(kb_action action, default: break; } - if (code != Inset::NO_CODE - && owner->view()->theLockingInset() - && !owner->view()->theLockingInset()->insetAllowed(code)) { + if (code != Inset::NO_CODE && tli && !tli->insetAllowed(code)) { disable = true; } diff --git a/src/tabular.C b/src/tabular.C index 6e7c13aba4..97b1a00ad9 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -2647,6 +2647,46 @@ InsetText * LyXTabular::GetCellInset(int row, int column) const } +int LyXTabular::GetCellFromInset(Inset const * inset, int maybe_cell) const +{ + // is this inset part of the tabular? + if (!inset || inset->owner() != owner_) { + lyxerr[Debug::INSETTEXT] + << "this is not a cell of the tabular!" << endl; + return -1; + } + + const int save_cur_cell = cur_cell; + int cell = cur_cell; + if (GetCellInset(cell) != inset) { + cell = maybe_cell; + if (cell == -1 || GetCellInset(cell) != inset) { + cell = -1; + } + } + + if (cell == -1) { + for (cell = GetNumberOfCells(); cell >= 0; --cell) { + if (GetCellInset(cell) == inset) + break; + } + lyxerr[Debug::INSETTEXT] + << "LyXTabular::GetCellFromInset: " + << "cell=" << cell + << ", cur_cell=" << save_cur_cell + << ", maybe_cell=" << maybe_cell + << endl; + // We should have found a cell at this point + if (cell == -1) { + lyxerr << "LyXTabular::GetCellFromInset: " + << "Cell not found!" << endl; + } + } + + return cell; +} + + void LyXTabular::Validate(LaTeXFeatures & features) const { if (IsLongTabular()) diff --git a/src/tabular.h b/src/tabular.h index 36b034dd76..d23f2d8883 100644 --- a/src/tabular.h +++ b/src/tabular.h @@ -376,6 +376,9 @@ public: InsetText * GetCellInset(int cell) const; /// InsetText * GetCellInset(int row, int column) const; + /// Search for \param inset in the tabular, with the + /// additional hint that it could be at \param maybe_cell + int GetCellFromInset(Inset const * inset, int maybe_cell = -1) const; /// int rows() const { return rows_; } ///