void LatexDocVisitor::visitPre(DocHtmlTable *t)
{
   m_rowSpans.clear();
   m_insideTable = true;

   if (m_hide) {
      return;
   }

   if (t->hasCaption()) {
      m_t << "\\begin{table}[h]";
   }

   m_t << "\\begin{" << getTableName(t->parent()) << "}{" << t->numColumns() << "}\n";
   m_numCols = t->numColumns();
   m_t << "\\hline\n";

   // check if first row is a heading and then render the row already here
   // and end it with \endfirsthead (triggered via m_firstRow == TRUE)
   // then repeat the row as normal and end it with \endhead (m_firstRow == FALSE)

   DocHtmlRow *firstRow = t->firstRow();

   if (firstRow && firstRow->isHeading()) {
      m_firstRow = true;
      firstRow->accept(this);
      m_firstRow = false;
   }
}
Beispiel #2
0
void LatexDocVisitor::visitPre(DocHtmlCell *c)
{
  if (m_hide) return;

  DocHtmlRow *row = 0;
  if (c->parent() && c->parent()->kind()==DocNode::Kind_HtmlRow)
  {
    row = (DocHtmlRow*)c->parent();
  }
  
  m_currentColumn++;

  //Skip columns that span from above.
  uint i;
  for (i=0;i<m_rowSpans.count();i++)
  {
    ActiveRowSpan *span = m_rowSpans.at(i);
    if (span->rowSpan>0 && span->column==m_currentColumn)
    {
      if (row && span->colSpan>1)
      {
        m_t << "\\multicolumn{" << span->colSpan << "}{";
        if (m_currentColumn /*c->columnIndex()*/==1) // add extra | for first column
        {
          m_t << "|";
        }
        m_t << "p{(\\linewidth-\\tabcolsep*" 
            << m_numCols << "-\\arrayrulewidth*"
            << row->visibleCells() << ")*" 
            << span->colSpan <<"/"<< m_numCols << "}|}{}";
        m_currentColumn+=span->colSpan;
      }
      else
      {
        m_currentColumn++;
      }
      m_t << "&";
    }
  }

#if 0
  QMap<int, int>::Iterator it = m_rowspanIndices.find(m_currentColumn);
  if (it!=m_rowspanIndices.end() && it.data()>0)
  {
    m_t << "&";
    m_currentColumn++;
    it++;
  }
#endif

  int cs = c->colSpan();
  if (cs>1 && row)
  {
    m_inColspan = TRUE;
    m_t << "\\multicolumn{" << cs << "}{";
    if (c->columnIndex()==1) // add extra | for first column
    {
      m_t << "|";
    }
    m_t << "p{(\\linewidth-\\tabcolsep*" 
        << m_numCols << "-\\arrayrulewidth*"
        << row->visibleCells() << ")*" 
        << cs <<"/"<< m_numCols << "}|}{";
    if (c->isHeading()) m_t << "\\cellcolor{lightgray}";
  }
  int rs = c->rowSpan();
  if (rs>0)
  {
    m_inRowspan = TRUE;
    //m_rowspanIndices[m_currentColumn] = rs;
    m_rowSpans.append(new ActiveRowSpan(c,rs,cs,m_currentColumn));
    m_t << "\\multirow{" << rs << "}{\\linewidth}{";
  }
  int a = c->alignment();
  if (a==DocHtmlCell::Center)
  {
    m_t << "\\PBS\\centering ";
  }
  else if (a==DocHtmlCell::Right)
  {
    m_t << "\\PBS\\raggedleft ";
  }
  if (c->isHeading())
  {
    m_t << "{\\bf ";
  }
  if (cs>1)
  {
    m_currentColumn+=cs-1;
  }
}
void LatexDocVisitor::visitPre(DocHtmlCell *c)
{
   if (m_hide) {
      return;
   }

   DocHtmlRow *row = 0;
   if (c->parent() && c->parent()->kind() == DocNode::Kind_HtmlRow) {
      row = (DocHtmlRow *)c->parent();
   }

   m_currentColumn++;

   //Skip columns that span from above.
   uint i;

   for (i = 0; i < m_rowSpans.count(); i++) {
      ActiveRowSpan &span = m_rowSpans[i];

      if (span.rowSpan > 0 && span.column == m_currentColumn) {

         if (row && span.colSpan > 1) {
            m_t << "\\multicolumn{" << span.colSpan << "}{";

            if (m_currentColumn /*c->columnIndex()*/ == 1) { // add extra | for first column
               m_t << "|";
            }

            m_t << "p{(\\linewidth-\\tabcolsep*"
                << m_numCols << "-\\arrayrulewidth*"
                << row->visibleCells() << ")*"
                << span.colSpan << "/" << m_numCols << "}|}{}";

            m_currentColumn += span.colSpan;

         } else {
            m_currentColumn++;
         }

         m_t << "&";
      }
   }

   int cs = c->colSpan();

   if (cs > 1 && row) {
      m_inColspan = true;

      m_t << "\\multicolumn{" << cs << "}{";

      if (c->columnIndex() == 1) { // add extra | for first column
         m_t << "|";
      }

      m_t << "p{(\\linewidth-\\tabcolsep*"
          << m_numCols << "-\\arrayrulewidth*"
          << row->visibleCells() << ")*"
          << cs << "/" << m_numCols << "}|}{";

      if (c->isHeading()) {
         m_t << "\\cellcolor{\\tableheadbgcolor}";
      }
   }

   int rs = c->rowSpan();

   if (rs > 0) {
      m_inRowspan = true;
      
      m_rowSpans.append(ActiveRowSpan(c, rs, cs, m_currentColumn));
      m_t << "\\multirow{" << rs << "}{\\linewidth}{";
   }

   int a = c->alignment();

   if (a == DocHtmlCell::Center) {
      m_t << "\\PBS\\centering ";
   } else if (a == DocHtmlCell::Right) {
      m_t << "\\PBS\\raggedleft ";
   }

   if (c->isHeading()) {
      m_t << "{\\bf ";
   }

   if (cs > 1) {
      m_currentColumn += cs - 1;
   }
}