Skip to content

Commit fa71258

Browse files
authored
Merge pull request #11690 from albert-github/feature/bug_tblr_header
Improve headings of tables
2 parents 2582b7f + cc385e1 commit fa71258

File tree

5 files changed

+23
-35
lines changed

5 files changed

+23
-35
lines changed

src/docnode.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,13 +2185,19 @@ const DocNodeVariant *DocHtmlTable::caption() const
21852185
return m_caption.get();
21862186
}
21872187

2188-
const DocNodeVariant *DocHtmlTable::firstRow() const
2188+
size_t DocHtmlTable::numberHeaderRows() const
21892189
{
2190-
if (!children().empty() && std::holds_alternative<DocHtmlRow>(children().front()))
2190+
size_t hl = 0;
2191+
for (auto &rowNode : children())
21912192
{
2192-
return &children().front();
2193+
const DocHtmlRow *row = std::get_if<DocHtmlRow>(&rowNode);
2194+
if (row)
2195+
{
2196+
if (!row->isHeading()) break;
2197+
hl++;
2198+
}
21932199
}
2194-
return nullptr;
2200+
return hl;
21952201
}
21962202

21972203
Token DocHtmlTable::parse()

src/docnode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ class DocHtmlTable : public DocCompoundNode
12771277
Token parseXml();
12781278
size_t numColumns() const { return m_numCols; }
12791279
const DocNodeVariant *caption() const;
1280-
const DocNodeVariant *firstRow() const;
1280+
size_t numberHeaderRows() const;
12811281

12821282
private:
12831283
void computeTableGrid();

src/latexdocvisitor.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,6 @@ void LatexDocVisitor::writeStartTableCommand(const DocNodeVariant *n,size_t cols
12801280
{
12811281
m_t << "\n\\begin{DoxyTable}{" << cols << "}";
12821282
}
1283-
//return isNested ? "TabularNC" : "TabularC";
12841283
}
12851284

12861285
void LatexDocVisitor::writeEndTableCommand(const DocNodeVariant *n)
@@ -1293,7 +1292,6 @@ void LatexDocVisitor::writeEndTableCommand(const DocNodeVariant *n)
12931292
{
12941293
m_t << "\\end{DoxyTable}\n";
12951294
}
1296-
//return isNested ? "TabularNC" : "TabularC";
12971295
}
12981296

12991297
void LatexDocVisitor::operator()(const DocHtmlTable &t)
@@ -1312,7 +1310,6 @@ void LatexDocVisitor::operator()(const DocHtmlTable &t)
13121310
m_t << "\n";
13131311
}
13141312

1315-
const DocHtmlRow *firstRow = std::get_if<DocHtmlRow>(t.firstRow());
13161313
writeStartTableCommand(t.parent(),t.numColumns());
13171314
if (!isTableNested(t.parent()))
13181315
{
@@ -1331,18 +1328,9 @@ void LatexDocVisitor::operator()(const DocHtmlTable &t)
13311328
}
13321329
m_t << "}";
13331330
}
1334-
// write head row
1335-
m_t << "{";
1336-
if (firstRow && firstRow->isHeading())
1337-
{
1338-
m_t << "1";
1339-
}
1340-
else
1341-
{
1342-
m_t << "0";
1343-
}
1344-
m_t << "}";
1345-
m_t << "\n";
1331+
1332+
// write head row(s)
1333+
m_t << "{" << t.numberHeaderRows() << "}\n";
13461334

13471335
setNumCols(t.numColumns());
13481336

@@ -1467,6 +1455,11 @@ void LatexDocVisitor::operator()(const DocHtmlCell &c)
14671455
setCurrentColumn(currentColumn()+cs-1);
14681456
appendOpt("c="+QCString().setNum(cs));
14691457
}
1458+
if (c.isHeading())
1459+
{
1460+
appendSpec("bg=\\tableheadbgcolor");
1461+
appendSpec("font=\\bfseries");
1462+
}
14701463
switch(va) // vertical alignment
14711464
{
14721465
case DocHtmlCell::Top:

src/latexdocvisitor.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ class LatexDocVisitor : public DocVisitor
188188
RowSpanList rowSpans;
189189
size_t numCols = 0;
190190
size_t currentColumn = 0;
191-
bool firstRow = false;
192191
};
193192
std::stack<TableState> m_tableStateStack; // needed for nested tables
194193
RowSpanList m_emptyRowSpanList;
@@ -227,14 +226,6 @@ class LatexDocVisitor : public DocVisitor
227226
{
228227
if (!m_tableStateStack.empty()) m_tableStateStack.top().numCols = num;
229228
}
230-
bool firstRow() const
231-
{
232-
return !m_tableStateStack.empty() ? m_tableStateStack.top().firstRow : FALSE;
233-
}
234-
void setFirstRow(bool b)
235-
{
236-
if (!m_tableStateStack.empty()) m_tableStateStack.top().firstRow = b;
237-
}
238229
RowSpanList &rowSpans()
239230
{
240231
return !m_tableStateStack.empty() ? m_tableStateStack.top().rowSpans : m_emptyRowSpanList;

templates/latex/doxygen.sty

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,17 +393,15 @@
393393
\begin{longtblr}{hlines,vlines,% automatically set horizontal and vertical cell lines
394394
measure=vbox,% needed to allow nested lists and tables
395395
colspec={*{#1}{X[-1]}},% set column type for all columns
396-
rowhead=#4,% set which row is the header (0=disable, 1=enable)
397-
row{#4}={bg=\tableheadbgcolor,font=\bfseries}}% set header background color and font weight
396+
rowhead=#4} % set which row is the header (0=disable, 1=enable)
398397
#5
399398
\end{longtblr}%
400399
\else% use fixed left aligned columns
401400
% now render the table for real
402401
\begin{longtblr}{hlines,vlines,% automatically set horizontal and vertical cell lines
403402
measure=vbox,% needed to allow nested lists and tables
404403
colspec={*{#1}{l}},% set column type for all columns
405-
rowhead=#4,% set which row is the header (0=disable, 1=enable)
406-
row{#4}={bg=\tableheadbgcolor,font=\bfseries}}% set header background color and font weight
404+
rowhead=#4} % set which row is the header (0=disable, 1=enable)
407405
#5
408406
\end{longtblr}%
409407
\fi%
@@ -419,8 +417,8 @@
419417
\begin{tblr}{hlines,vlines,% automatically set horizontal and vertical cell lines
420418
measure=vbox,% needed to allow nested lists and tables
421419
colspec={*{#1}{X[-1]}},% set column type for all columns
422-
rowhead=#2,% set which row is the header (0=disable, 1=enable)
423-
row{#2}={bg=\tableheadbgcolor,font=\bfseries}}% set header background color and font weight
420+
rowhead=#2% set which row is the header (0=disable, 1=enable)
421+
}
424422
}{% no end marker needed anymore
425423
\end{tblr}
426424
}%

0 commit comments

Comments
 (0)