GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixTex2Html/src/PLatexObj/createOutlineHtml.cpp
Date: 2025-03-24 18:12:43
Exec Total Coverage
Lines: 34 36 94.4%
Branches: 59 72 81.9%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #include "parser_utils.h"
8 #include "platexobj_html.h"
9 #include "createOutlineHtml.h"
10
11 ///Create the outline
12 /** @param[out] outputMode : deal with the formulae
13 * @param obj : PLatexObj to deal with
14 * @return output string
15 */
16 8327 PString createOutlineHtmlStr(POutoutMode & outputMode, const PLatexObj & obj){
17
8/9
✓ Branch 1 taken 8327 times.
✓ Branch 3 taken 8134 times.
✓ Branch 4 taken 193 times.
✓ Branch 6 taken 8134 times.
✓ Branch 8 taken 8134 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 8134 times.
✓ Branch 11 taken 193 times.
✓ Branch 13 taken 8134 times.
8327 if(!isSection(obj) && obj.getType() != PLatexType::FILE){return "";}
18
1/1
✓ Branch 1 taken 193 times.
193 PString body("");
19
11/11
✓ Branch 1 taken 193 times.
✓ Branch 4 taken 193 times.
✓ Branch 7 taken 193 times.
✓ Branch 10 taken 193 times.
✓ Branch 13 taken 193 times.
✓ Branch 16 taken 193 times.
✓ Branch 19 taken 193 times.
✓ Branch 22 taken 193 times.
✓ Branch 25 taken 193 times.
✓ Branch 28 taken 193 times.
✓ Branch 31 taken 193 times.
193 body += "\t\t\t<li><a href=\""+obj.getLink()+"\">"+vecNumberToString(obj.getVecSecNumber())+" : "+getSectionTitle(outputMode, obj)+"</a></li>\n";
20
1/1
✓ Branch 1 taken 193 times.
193 const PVecLatexObj & vecObj = obj.getVecContent();
21
1/2
✓ Branch 1 taken 193 times.
✗ Branch 2 not taken.
193 if(vecObj.size() != 0lu){
22
1/1
✓ Branch 1 taken 193 times.
193 body += "\t\t\t\t<ul>\n";
23
2/2
✓ Branch 3 taken 2051 times.
✓ Branch 4 taken 193 times.
2244 for(PVecLatexObj::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){
24
2/2
✓ Branch 2 taken 2051 times.
✓ Branch 5 taken 2051 times.
2051 body += createOutlineHtmlStr(outputMode, *it);
25 }
26
1/1
✓ Branch 1 taken 193 times.
193 body += "\t\t\t\t</ul>\n";
27 }
28
1/1
✓ Branch 1 taken 193 times.
193 return body;
29 193 }
30
31 ///Create the outline
32 /** @param[out] outputMode : deal with the formulae
33 * @param obj : PLatexObj to deal with
34 * @param isBibliography : true if there is a bibliography, false otherwise
35 * @return true on success, false otherwise
36 */
37 107 bool createOutlineHtml(POutoutMode & outputMode, const PLatexObj & obj, bool isBibliography){
38
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(outputMode.isBookTheme){return false;}
39
1/1
✓ Branch 1 taken 107 times.
107 PString body("");
40
3/3
✓ Branch 1 taken 107 times.
✓ Branch 4 taken 107 times.
✓ Branch 7 taken 107 times.
107 body += getHtmlHeader("Outline", false, false, outputMode.currentStyle);
41
1/1
✓ Branch 1 taken 107 times.
107 body += "\t\t<h1 class=\"mainTitle\">Outline</h1>\n";
42
1/1
✓ Branch 1 taken 107 times.
107 body += "\t\t<ul class=\"sommairePage\">\n";
43
1/1
✓ Branch 1 taken 107 times.
107 body += "\t\t\t<ul>\n";
44
1/1
✓ Branch 1 taken 107 times.
107 body += "\t\t\t\t<li><a href=\"index.html\">Main Page</a></li>\n";
45
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 106 times.
107 if(isBibliography){
46
1/1
✓ Branch 1 taken 1 times.
1 body += "\t\t\t\t<li><a href=\"bibliography.html\">Bibliographie</a></li>\n";
47 }
48
49
1/1
✓ Branch 1 taken 107 times.
107 const PVecLatexObj & vecObj = obj.getVecContent();
50
1/2
✓ Branch 1 taken 107 times.
✗ Branch 2 not taken.
107 if(vecObj.size() != 0lu){
51
2/2
✓ Branch 3 taken 6276 times.
✓ Branch 4 taken 107 times.
6383 for(PVecLatexObj::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){
52
2/2
✓ Branch 2 taken 6276 times.
✓ Branch 5 taken 6276 times.
6276 body += createOutlineHtmlStr(outputMode, *it);
53 }
54 }
55
1/1
✓ Branch 1 taken 107 times.
107 body += "\t\t\t</ul>\n";
56
1/1
✓ Branch 1 taken 107 times.
107 body += "\t\t</ul>\n";
57
2/2
✓ Branch 1 taken 107 times.
✓ Branch 4 taken 107 times.
107 body += getHtmlFooter();
58
2/2
✓ Branch 1 taken 107 times.
✓ Branch 4 taken 107 times.
107 PPath fileName("outline.html");
59
2/3
✓ Branch 1 taken 107 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107 times.
107 if(!fileName.saveFileContent(body)){
60 std::cerr << "createOutlineHtml : can't save file name '"<<fileName<<"'" << std::endl;
61 return false;
62 }else{
63
4/4
✓ Branch 1 taken 107 times.
✓ Branch 4 taken 107 times.
✓ Branch 7 taken 107 times.
✓ Branch 10 taken 107 times.
107 std::cerr << "createOutlineHtml : save file name '"<<fileName<<"'" << std::endl;
64 }
65
66 107 return true;
67 107 }
68
69
70
71