fixes to biblio and insetgraphics from herbert; disable LAYOUT_PARAGRAPH when needed

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3423 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2002-01-20 16:07:42 +00:00
parent 58a522ef71
commit bd31d0cb5c
9 changed files with 101 additions and 78 deletions

View File

@ -1,3 +1,13 @@
2002-01-20 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* 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 <lasgouttes@freesurf.fr>
* tabular.C (Validate): remove broken optimization (fixes bug #201)

View File

@ -1,5 +1,12 @@
2002-01-20 Herbert Voss <voss@perce.de>
* ControlGraphic.C (Browse): add extension "ps" when browsing for
a filename
2002-01-19 Herbert Voss <voss@perce.de>
* 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.

View File

@ -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");

View File

@ -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())

View File

@ -1,3 +1,8 @@
2002-01-20 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* insettabular.C (getMaxWidth):
(forceDefaultParagraphs): use Tabular::GetCellFromInset
2002-01-19 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* insettabular.C (getMaxWidthOfCell): adapt to the new definition

View File

@ -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);

View File

@ -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<InsetTabular *>(tli)
->getStatus(argument);
} else if (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
ret = static_cast<InsetTabular *>
(owner->view()->theLockingInset())->
getStatus(argument);
} else if (owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
ret = static_cast<InsetTabular *>
(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;
}

View File

@ -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())

View File

@ -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_; }
///