GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixTex2Html/src/PLatexObj/platexobj_text.cpp
Date: 2025-03-24 18:12:43
Exec Total Coverage
Lines: 44 44 100.0%
Branches: 84 113 74.3%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7
8 #include "platexobj_html.h"
9
10 #include "platexobj_text.h"
11
12 ///Convert a PLatexObj into a string
13 /** @param[out] outputMode : output mode of the html backend
14 * @param obj : PLatexObj to be converted into a string
15 * @return output string which contains the PLatexObj
16 */
17 3 PString platexobj_textHref(const PLatexObj & obj){
18 3 PString body("");
19
8/8
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
3 body += "<a id=\""+valueToString(obj.getId())+"\" href=\"" + obj.getName() + "\">";
20
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 body += platexobj_text(obj.getVecContent());
21
1/1
✓ Branch 1 taken 3 times.
3 body += "</a>";
22 3 return body;
23 }
24
25 ///Convert a PLatexObj into a string
26 /** @param obj : PLatexObj to be converted into a string
27 * @return output string which contains the PLatexObj
28 */
29 8 PString platexobj_textExtraFunction(const PLatexObj & obj){
30 8 PString body("");
31
11/11
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
✓ Branch 13 taken 8 times.
✓ Branch 16 taken 8 times.
✓ Branch 19 taken 8 times.
✓ Branch 22 taken 8 times.
✓ Branch 25 taken 8 times.
✓ Branch 28 taken 8 times.
✓ Branch 31 taken 8 times.
8 body += "<"+obj.getBalise()+" id=\""+valueToString(obj.getId())+"\" class=\"" + obj.getName() + "Style\">";
32
6/6
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
✓ Branch 13 taken 8 times.
✓ Branch 16 taken 8 times.
8 body += platexobj_text(obj.getVecContent()) + platexobj_createLabelSearchLink(obj.getLabelName());
33
4/4
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
8 body += "</"+obj.getBalise()+">";
34 8 return body;
35 }
36
37 ///Convert a PLatexObj in text
38 /** @param vecObj : vector of PLatexObj
39 * @return corresponding text
40 */
41 1275 PString platexobj_text(const std::vector<PLatexObj> & vecObj){
42 1275 PString body("");
43
2/2
✓ Branch 3 taken 1275 times.
✓ Branch 4 taken 1275 times.
2550 for(std::vector<PLatexObj>::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){
44
2/2
✓ Branch 2 taken 1275 times.
✓ Branch 5 taken 1275 times.
1275 body += platexobj_text(*it);
45 }
46 1275 return body;
47 }
48
49 ///Convert a PLatexObj into a string
50 /** @param obj : PLatexObj to be converted into a string
51 * @return output string which contains the PLatexObj
52 */
53 47 PString platexobj_htmlStrImage(const PLatexObj & obj){
54 47 PString body("");
55 // option(obj.getText());
56
8/8
✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
✓ Branch 7 taken 47 times.
✓ Branch 10 taken 47 times.
✓ Branch 13 taken 47 times.
✓ Branch 16 taken 47 times.
✓ Branch 19 taken 47 times.
✓ Branch 22 taken 47 times.
47 body += "<img id=\""+valueToString(obj.getId())+"\" src=\"" + obj.getName() + "\"";
57 // if(option != ""){ //Not a good idea for now, because firefox does not like this style property
58 // body += " style=\""+replaceCharInStr(option, '=', ':')+"%\"";
59 // }
60
4/4
✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
✓ Branch 7 taken 47 times.
✓ Branch 10 taken 47 times.
47 body += " alt=\"nothing\" />" + platexobj_createLabelSearchLink(obj.getLabelName());
61 47 return body;
62 }
63
64 ///Convert a PLatexObj into a string
65 /** @param obj : PLatexObj to be converted into a string
66 * @return output string which contains the PLatexObj
67 */
68 377 PString platexobj_textFile(const PLatexObj & obj){
69 377 PString body("");
70
1/1
✓ Branch 1 taken 377 times.
377 const PVecLatexObj & vecObj = obj.getVecContent();
71
2/2
✓ Branch 3 taken 378 times.
✓ Branch 4 taken 377 times.
755 for(PVecLatexObj::const_iterator it(vecObj.begin()); it != vecObj.end(); ++it){
72
2/2
✓ Branch 2 taken 378 times.
✓ Branch 5 taken 378 times.
378 body += platexobj_text(*it);
73 }
74 377 return body;
75 }
76
77 ///Convert a PLatexObj in text
78 /** @param obj : PLatexObj
79 * @return corresponding text
80 */
81 2030 PString platexobj_text(const PLatexObj & obj){
82 2030 PString body("");
83
1/1
✓ Branch 1 taken 2030 times.
2030 PLatexType::PLatexType type(obj.getType());
84
4/4
✓ Branch 0 taken 1639 times.
✓ Branch 1 taken 391 times.
✓ Branch 3 taken 1639 times.
✓ Branch 6 taken 1639 times.
2030 if(type == PLatexType::TEXT){body = platexobj_htmlStrText(obj);}
85
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 391 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
391 else if(type == PLatexType::URL){body = platexobj_htmlStrUrl(obj);}
86
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 390 times.
✓ Branch 3 taken 1 times.
✓ Branch 6 taken 1 times.
391 else if(type == PLatexType::GETENV){body = platexobj_htmlStrGetEnv(obj);}
87
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
390 else if(type == PLatexType::PERCENT){body += "%";}
88
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
390 else if(type == PLatexType::REF){body = platexobj_htmlStrRef(obj);}
89
90
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 387 times.
✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
390 else if(type == PLatexType::HREF){body = platexobj_textHref(obj);}
91
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
387 else if(type == PLatexType::TEXTBF){body = platexobj_htmlStrTextBf(obj);}
92
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
387 else if(type == PLatexType::TEXTIT){body = platexobj_htmlStrTextIt(obj);}
93
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
387 else if(type == PLatexType::DEBUG){body = platexobj_htmlStrTextDebug(obj);}
94
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 379 times.
✓ Branch 3 taken 8 times.
✓ Branch 6 taken 8 times.
387 else if(type == PLatexType::FUNCTION){body = platexobj_textExtraFunction(obj);}
95
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 377 times.
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
379 else if(type == PLatexType::IMAGE){body = platexobj_htmlStrImage(obj);}
96
3/4
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 377 times.
✓ Branch 6 taken 377 times.
377 else if(type == PLatexType::FILE){body = platexobj_textFile(obj);}
97 2030 return body;
98 }
99
100
101