* Fix display of horizontal alignment in fixed width tabular cells (bug 3484)

* src/Inset.h:
	- new member content Alignment that indicates whether the content
	  of text insets should be displayed with a specific alignment
* src/TextMetrics.cpp:
	- handle inset's contentAlignment
* src/insets/InsetTabular.{cpp,h}:
	- set contentAlignment for tabular cells.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26380 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2008-09-13 10:10:01 +00:00
parent 6d5a959ade
commit a942cf9e86
4 changed files with 31 additions and 1 deletions

View File

@ -550,6 +550,22 @@ void TextMetrics::computeRowMetrics(pit_type const pit,
else
align = par.params().align();
// handle alignment inside tabular cells
if (Inset const * owner = par.inInset()) {
switch (owner->contentAlignment()) {
case LYX_ALIGN_CENTER:
case LYX_ALIGN_LEFT:
case LYX_ALIGN_RIGHT:
if (align == LYX_ALIGN_NONE
|| align == LYX_ALIGN_BLOCK)
align = owner->contentAlignment();
break;
default:
// unchanged (use align)
break;
}
}
// Display-style insets should always be on a centred row
if (Inset const * inset = par.getInset(row.pos())) {
switch (inset->display()) {

View File

@ -17,6 +17,7 @@
#include "ColorCode.h"
#include "InsetCode.h"
#include "Layout.h"
#include "support/strfwd.h"
#include "support/types.h"
@ -403,6 +404,8 @@ public:
/// should we have a non-filled line before this inset?
virtual DisplayType display() const { return Inline; }
///
virtual LyXAlignment contentAlignment() const { return LYX_ALIGN_NONE; }
/// should we break lines after this inset?
virtual bool isLineSeparator() const { return false; }
/// should paragraph indendation be ommitted in any case?

View File

@ -945,6 +945,7 @@ void Tabular::setAlignment(idx_type cell, LyXAlignment align,
column_info[cellColumn(cell)].alignment = align;
if (!onlycolumn)
cellInfo(cell).alignment = align;
cellInset(cell).get()->setContentAlignment(align);
}
@ -1423,6 +1424,8 @@ void Tabular::read(Lexer & lex)
}
getTokenValue(line, "multicolumn", cell_info[i][j].multicolumn);
getTokenValue(line, "alignment", cell_info[i][j].alignment);
setAlignment(cellIndex(i, j), cell_info[i][j].alignment,
cell_info[i][j].multicolumn);
getTokenValue(line, "valignment", cell_info[i][j].valignment);
getTokenValue(line, "topline", cell_info[i][j].top_line);
getTokenValue(line, "bottomline", cell_info[i][j].bottom_line);
@ -2732,7 +2735,8 @@ Tabular::BoxType Tabular::useParbox(idx_type cell) const
/////////////////////////////////////////////////////////////////////
InsetTableCell::InsetTableCell(Buffer & buf)
: InsetText(buf), isFixedWidth(false)
: InsetText(buf), isFixedWidth(false),
contentAlign(LYX_ALIGN_CENTER)
{}

View File

@ -643,6 +643,8 @@ public:
FuncStatus & status) const;
///
void toggleFixedWidth(bool fw) { isFixedWidth = fw; }
///
void setContentAlignment(LyXAlignment al) {contentAlign = al; }
/// writes the contents of the cell as a string, optionally
/// descending into insets
docstring asString(bool intoInsets = true);
@ -676,9 +678,14 @@ private:
// --rgh
///
bool isFixedWidth;
// FIXME: Here the thoughts from the comment above also apply.
///
LyXAlignment contentAlign;
/// should paragraph indendation be omitted in any case?
bool neverIndent() const { return true; }
///
LyXAlignment contentAlignment() const { return contentAlign; }
///
virtual bool usePlainLayout() const { return true; }
///
virtual bool forcePlainLayout(idx_type = 0) const;