summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2021-01-16 20:47:34 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2021-01-22 20:45:20 (GMT)
commit2ca0666d33beaa4d3533d9a21f8414378c2f9f0a (patch)
tree61f52bcbd4bb714e76bf00c2534f57277478268c
parent302ea696fae93d7f05cf0f68ce3017cd8b7c4952 (diff)
downloadDoxygen-2ca0666d33beaa4d3533d9a21f8414378c2f9f0a.zip
Doxygen-2ca0666d33beaa4d3533d9a21f8414378c2f9f0a.tar.gz
Doxygen-2ca0666d33beaa4d3533d9a21f8414378c2f9f0a.tar.bz2
Refactoring: modernize LatexDocVisitor::m_tableStateStack
-rw-r--r--src/latexdocvisitor.cpp43
-rw-r--r--src/latexdocvisitor.h60
2 files changed, 45 insertions, 58 deletions
diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp
index 10562a6..1d666ab 100644
--- a/src/latexdocvisitor.cpp
+++ b/src/latexdocvisitor.cpp
@@ -179,7 +179,6 @@ LatexDocVisitor::LatexDocVisitor(FTextStream &t,LatexCodeGenerator &ci,
m_insideItem(FALSE), m_hide(FALSE), m_hideCaption(FALSE), m_insideTabbing(insideTabbing),
m_langExt(langExt)
{
- m_tableStateStack.setAutoDelete(TRUE);
}
//--------------------------------------
@@ -1144,20 +1143,18 @@ void LatexDocVisitor::visitPost(DocHtmlRow *row)
int c=currentColumn();
while (c<=numCols()) // end of row while inside a row span?
{
- uint i;
- for (i=0;i<rowSpans().count();i++)
+ for (const auto &span : rowSpans())
{
- ActiveRowSpan *span = rowSpans().at(i);
//printf(" found row span: column=%d rs=%d cs=%d rowIdx=%d cell->rowIdx=%d i=%d c=%d\n",
// span->column, span->rowSpan,span->colSpan,row->rowIndex(),span->cell->rowIndex(),i,c);
- if (span->rowSpan>0 && span->column==c && // we are at a cell in a row span
- row->rowIndex()>span->cell->rowIndex() // but not the row that started the span
+ if (span.rowSpan>0 && span.column==c && // we are at a cell in a row span
+ row->rowIndex()>span.cell->rowIndex() // but not the row that started the span
)
{
m_t << "&";
- if (span->colSpan>1) // row span is also part of a column span
+ if (span.colSpan>1) // row span is also part of a column span
{
- m_t << "\\multicolumn{" << span->colSpan << "}{";
+ m_t << "\\multicolumn{" << span.colSpan << "}{";
m_t << "}|}{}";
}
else // solitary row span
@@ -1172,23 +1169,21 @@ void LatexDocVisitor::visitPost(DocHtmlRow *row)
m_t << "\\\\";
int col = 1;
- uint i;
- for (i=0;i<rowSpans().count();i++)
+ for (auto &span : rowSpans())
{
- ActiveRowSpan *span = rowSpans().at(i);
- if (span->rowSpan>0) span->rowSpan--;
- if (span->rowSpan<=0)
+ if (span.rowSpan>0) span.rowSpan--;
+ if (span.rowSpan<=0)
{
// inactive span
}
- else if (span->column>col)
+ else if (span.column>col)
{
- m_t << "\\cline{" << col << "-" << (span->column-1) << "}";
- col = span->column+span->colSpan;
+ m_t << "\\cline{" << col << "-" << (span.column-1) << "}";
+ col = span.column+span.colSpan;
}
else
{
- col = span->column+span->colSpan;
+ col = span.column+span.colSpan;
}
}
@@ -1229,21 +1224,19 @@ void LatexDocVisitor::visitPre(DocHtmlCell *c)
setCurrentColumn(currentColumn()+1);
//Skip columns that span from above.
- uint i;
- for (i=0;i<rowSpans().count();i++)
+ for (const auto &span : rowSpans())
{
- ActiveRowSpan *span = rowSpans().at(i);
- if (span->rowSpan>0 && span->column==currentColumn())
+ if (span.rowSpan>0 && span.column==currentColumn())
{
- if (row && span->colSpan>1)
+ if (row && span.colSpan>1)
{
- m_t << "\\multicolumn{" << span->colSpan << "}{";
+ m_t << "\\multicolumn{" << span.colSpan << "}{";
if (currentColumn() /*c->columnIndex()*/==1) // add extra | for first column
{
m_t << "|";
}
m_t << "l|}{" << (c->isHeading()? "\\columncolor{\\tableheadbgcolor}" : "") << "}"; // alignment not relevant, empty column
- setCurrentColumn(currentColumn()+span->colSpan);
+ setCurrentColumn(currentColumn()+span.colSpan);
}
else
{
@@ -1283,7 +1276,7 @@ void LatexDocVisitor::visitPre(DocHtmlCell *c)
//printf("adding row span: cell={r=%d c=%d rs=%d cs=%d} curCol=%d\n",
// c->rowIndex(),c->columnIndex(),c->rowSpan(),c->colSpan(),
// currentColumn());
- addRowSpan(new ActiveRowSpan(c,rs,cs,currentColumn()));
+ addRowSpan(ActiveRowSpan(c,rs,cs,currentColumn()));
m_t << "\\multirow{" << rs << "}{*}{";
}
if (a==DocHtmlCell::Center)
diff --git a/src/latexdocvisitor.h b/src/latexdocvisitor.h
index 45995e1..cd6c442 100644
--- a/src/latexdocvisitor.h
+++ b/src/latexdocvisitor.h
@@ -1,9 +1,6 @@
/******************************************************************************
*
- *
- *
- *
- * Copyright (C) 1997-2015 by Dimitri van Heesch.
+ * Copyright (C) 1997-2021 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation under the terms of the GNU General Public License is hereby
@@ -19,10 +16,10 @@
#ifndef _LATEXDOCVISITOR_H
#define _LATEXDOCVISITOR_H
+#include <stack>
+
#include "docvisitor.h"
-#include <qstack.h>
#include <qcstring.h>
-#include <qlist.h>
class FTextStream;
class LatexCodeGenerator;
@@ -149,7 +146,7 @@ class LatexDocVisitor : public DocVisitor
int column;
};
- typedef QList<ActiveRowSpan> RowSpanList;
+ typedef std::vector<ActiveRowSpan> RowSpanList;
//--------------------------------------
// helper functions
@@ -191,78 +188,75 @@ class LatexDocVisitor : public DocVisitor
struct TableState
{
- TableState() : numCols(0), currentColumn(0), inRowSpan(FALSE),
- inColSpan(FALSE), firstRow(FALSE)
- { rowSpans.setAutoDelete(TRUE); }
RowSpanList rowSpans;
- int numCols;
- int currentColumn;
- bool inRowSpan;
- bool inColSpan;
- bool firstRow;
+ int numCols = 0;
+ int currentColumn = 0;
+ bool inRowSpan = false;
+ bool inColSpan = false;
+ bool firstRow = false;
};
- QStack<TableState> m_tableStateStack; // needed for nested tables
+ std::stack<TableState> m_tableStateStack; // needed for nested tables
RowSpanList m_emptyRowSpanList;
void pushTableState()
{
- m_tableStateStack.push(new TableState);
+ m_tableStateStack.push(TableState());
}
void popTableState()
{
- delete m_tableStateStack.pop();
+ m_tableStateStack.pop();
}
int currentColumn() const
{
- return !m_tableStateStack.isEmpty() ? m_tableStateStack.top()->currentColumn : 0;
+ return !m_tableStateStack.empty() ? m_tableStateStack.top().currentColumn : 0;
}
void setCurrentColumn(int col)
{
- if (!m_tableStateStack.isEmpty()) m_tableStateStack.top()->currentColumn = col;
+ if (!m_tableStateStack.empty()) m_tableStateStack.top().currentColumn = col;
}
int numCols() const
{
- return !m_tableStateStack.isEmpty() ? m_tableStateStack.top()->numCols : 0;
+ return !m_tableStateStack.empty() ? m_tableStateStack.top().numCols : 0;
}
void setNumCols(int num)
{
- if (!m_tableStateStack.isEmpty()) m_tableStateStack.top()->numCols = num;
+ if (!m_tableStateStack.empty()) m_tableStateStack.top().numCols = num;
}
bool inRowSpan() const
{
- return !m_tableStateStack.isEmpty() ? m_tableStateStack.top()->inRowSpan : FALSE;
+ return !m_tableStateStack.empty() ? m_tableStateStack.top().inRowSpan : FALSE;
}
void setInRowSpan(bool b)
{
- if (!m_tableStateStack.isEmpty()) m_tableStateStack.top()->inRowSpan = b;
+ if (!m_tableStateStack.empty()) m_tableStateStack.top().inRowSpan = b;
}
bool inColSpan() const
{
- return !m_tableStateStack.isEmpty() ? m_tableStateStack.top()->inColSpan : FALSE;
+ return !m_tableStateStack.empty() ? m_tableStateStack.top().inColSpan : FALSE;
}
void setInColSpan(bool b)
{
- if (!m_tableStateStack.isEmpty()) m_tableStateStack.top()->inColSpan = b;
+ if (!m_tableStateStack.empty()) m_tableStateStack.top().inColSpan = b;
}
bool firstRow() const
{
- return !m_tableStateStack.isEmpty() ? m_tableStateStack.top()->firstRow : FALSE;
+ return !m_tableStateStack.empty() ? m_tableStateStack.top().firstRow : FALSE;
}
void setFirstRow(bool b)
{
- if (!m_tableStateStack.isEmpty()) m_tableStateStack.top()->firstRow = b;
+ if (!m_tableStateStack.empty()) m_tableStateStack.top().firstRow = b;
}
- const RowSpanList &rowSpans()
+ RowSpanList &rowSpans()
{
- return !m_tableStateStack.isEmpty() ? m_tableStateStack.top()->rowSpans : m_emptyRowSpanList;
+ return !m_tableStateStack.empty() ? m_tableStateStack.top().rowSpans : m_emptyRowSpanList;
}
- void addRowSpan(ActiveRowSpan *span)
+ void addRowSpan(ActiveRowSpan &&span)
{
- if (!m_tableStateStack.isEmpty()) m_tableStateStack.top()->rowSpans.append(span);
+ if (!m_tableStateStack.empty()) m_tableStateStack.top().rowSpans.push_back(std::move(span));
}
bool insideTable() const
{
- return !m_tableStateStack.isEmpty();
+ return !m_tableStateStack.empty();
}
};