@@ -97,9 +97,6 @@ class SpLatex
9797 const std::string& separator,
9898 const std::string& endline);
9999
100- // ! Process % tab separated (TABSEP) commands
101- void tabsep (size_t ln, size_t indent, const std::string& cmdline);
102-
103100 // ! Process % DEFMACRO commands
104101 void defmacro (size_t ln, size_t indent, const std::string& cmdline);
105102
@@ -478,136 +475,6 @@ void SpLatex::tabular(
478475 }
479476}
480477
481- // ! Process % TABSEP commands
482- void SpLatex::tabsep (size_t ln, size_t indent, const std::string& cmdline)
483- {
484- std::string query = cmdline;
485-
486- // find REFORMAT, parse format and remove clause from query
487- Reformat reformat;
488- reformat.parse_query (query);
489-
490- // execute query
491- SqlQuery sql = g_db->query (query);
492-
493- sql->read_complete ();
494-
495- // prepare reformatting
496- reformat.prepare (sql);
497-
498- // calculate width of columns data
499- std::vector<size_t > cwidth (sql->num_cols (), 0 );
500-
501- for (unsigned int i = 0 ; i < sql->num_rows (); ++i)
502- {
503- for (unsigned int j = 0 ; j < sql->num_cols (); ++j)
504- {
505- cwidth[j] = std::max (
506- cwidth[j],
507- reformat.format (i,j, sql->text (i,j)).size ()
508- );
509- }
510- }
511-
512- // generate output
513- std::vector<std::string> tlines;
514- for (unsigned int i = 0 ; i < sql->num_rows (); ++i)
515- {
516- std::ostringstream out;
517- for (unsigned j = 0 ; j < sql->num_cols (); ++j)
518- {
519- if (j != 0 ) out << " \t " ;
520- out << std::setw (cwidth[j])
521- << reformat.format (i, j, sql->text (i,j));
522- }
523- tlines.push_back (out.str ());
524- }
525-
526- // scan lines forward till next comment directive
527- size_t eln = ln;
528- while (eln < m_lines.size () && is_comment_line (eln) < 0 )
529- ++eln;
530-
531- static const boost::regex
532- re_endtabsep (" [[:blank:]]*% END TABSEP .*" );
533-
534- if (eln < m_lines.size () &&
535- boost::regex_match (m_lines[eln], re_endtabsep))
536- {
537- // found END TABSEP
538- size_t rln = ln;
539- size_t entry = 0 ;
540-
541- static const boost::regex re_tabsep (" .*?\\\\\\\\ (.*)" );
542- boost::smatch rm;
543-
544- // iterate over tabsep lines, copy styles to replacement
545- while (entry < tlines.size () && rln < eln &&
546- boost::regex_match (m_lines[rln], rm, re_tabsep))
547- {
548- tlines[entry++] += rm[1 ];
549- ++rln;
550- }
551-
552- tlines.push_back (shorten (" % END TABSEP " + query));
553- m_lines.replace (ln, eln+1 , indent, tlines, " TABSEP" );
554- }
555- else
556- {
557- // could not find END TABSEP: insert whole table.
558- tlines.push_back (shorten (" % END TABSEP " + query));
559- m_lines.replace (ln, ln, indent, tlines, " TABSEP" );
560- }
561- }
562-
563- // ! Process % DEFMACRO commands
564- void SpLatex::defmacro (size_t ln, size_t indent, const std::string& cmdline)
565- {
566- std::string query = cmdline;
567-
568- // find REFORMAT, parse format and remove clause from query
569- Reformat reformat;
570- reformat.parse_query (query);
571-
572- // execute query
573- SqlQuery sql = g_db->query (query);
574-
575- sql->read_complete ();
576-
577- // prepare reformatting
578- reformat.prepare (sql);
579-
580- std::ostringstream oss;
581- for (unsigned int row = 0 ; row < sql->num_rows (); ++row)
582- {
583- for (unsigned int col = 0 ; col < sql->num_cols (); ++col)
584- {
585- if (col != 0 ) oss << std::endl;
586- oss << " \\ def\\ "
587- << str_reduce (sql->col_name (col))
588- << " {"
589- << reformat.format (0 , col, sql->text (0 , col))
590- << " }" ;
591- }
592- }
593-
594- std::string output = oss.str ();
595-
596- // scan lines forward and gobble all lines containing \def commands
597- static const boost::regex
598- re_defmacro (" [[:blank:]]*\\\\ def\\\\ [^{]+\\ {[^}]+\\ }.*" );
599- boost::smatch rm;
600-
601- size_t eln = ln;
602- while (eln < m_lines.size () &&
603- boost::regex_match (m_lines[eln], rm, re_defmacro))
604- {
605- ++eln;
606- }
607-
608- m_lines.replace (ln, eln, indent, output, " DEFMACRO" );
609- }
610-
611478// ! process line-based file in place
612479SpLatex::SpLatex (TextLines& lines)
613480 : m_lines(lines)
@@ -668,11 +535,6 @@ SpLatex::SpLatex(TextLines& lines)
668535 OUT (ln << " % " << cmd);
669536 tabular (ln, indent, cmd.substr (space_pos+1 ), " TABTABLE" , " \t " , " " );
670537 }
671- else if (first_word == " TABSEP" )
672- {
673- OUT (ln << " % " << cmd);
674- tabsep (ln, indent, cmd.substr (space_pos+1 ));
675- }
676538 else if (first_word == " DEFMACRO" )
677539 {
678540 OUT (ln << " % " << cmd);
0 commit comments