Directory: | ./ |
---|---|
File: | tmp_project/PhoenixTex2Html/src/PLatexObj/updateFigureNumber.cpp |
Date: | 2025-03-24 18:12:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 33 | 33 | 100.0% |
Branches: | 34 | 34 | 100.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /*************************************** | ||
2 | Auteur : Pierre Aubert | ||
3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
4 | Licence : CeCILL-C | ||
5 | ****************************************/ | ||
6 | |||
7 | #include "convertToString.h" | ||
8 | #include "updateFigureNumber.h" | ||
9 | |||
10 | ///Update all the figure number of the given PLatexObj | ||
11 | /** @param[out] obj : PLatexObj where the figure number have to be updated | ||
12 | * @param prefix : prefix of the table or figure | ||
13 | * @param[out] figNumber : figure number of the current figure | ||
14 | */ | ||
15 | 624 | void updateFigureNumberCaption(PLatexObj & obj, const PString & prefix, size_t & figNumber){ | |
16 |
2/2✓ Branch 1 taken 76 times.
✓ Branch 2 taken 548 times.
|
624 | if(obj.getType() == PLatexType::CAPTION){ //We find a caption |
17 | //We update it | ||
18 |
1/1✓ Branch 1 taken 76 times.
|
76 | PLatexObj objFigNumber; |
19 |
1/1✓ Branch 1 taken 76 times.
|
76 | objFigNumber.setType(PLatexType::TEXTBF); |
20 | //TODO : update set name to setVecContent when TEXTBF backend will use also vecContent | ||
21 |
6/6✓ Branch 1 taken 76 times.
✓ Branch 4 taken 76 times.
✓ Branch 7 taken 76 times.
✓ Branch 10 taken 76 times.
✓ Branch 13 taken 76 times.
✓ Branch 16 taken 76 times.
|
76 | objFigNumber.setName(prefix+ " " + valueToString(figNumber) + " : "); |
22 | |||
23 |
3/3✓ Branch 1 taken 76 times.
✓ Branch 4 taken 76 times.
✓ Branch 7 taken 76 times.
|
76 | obj.setName(valueToString(figNumber)); |
24 | |||
25 | 76 | PVecLatexObj vecUpdateObj; | |
26 |
1/1✓ Branch 1 taken 76 times.
|
76 | vecUpdateObj.push_back(objFigNumber); |
27 | |||
28 |
1/1✓ Branch 1 taken 76 times.
|
76 | PVecLatexObj & vecObj = obj.getVecContent(); //Content of the current caption |
29 |
2/2✓ Branch 4 taken 76 times.
✓ Branch 5 taken 76 times.
|
152 | for(PVecLatexObj::iterator it(vecObj.begin()); it != vecObj.end(); ++it){ |
30 |
1/1✓ Branch 2 taken 76 times.
|
76 | vecUpdateObj.push_back(*it); |
31 | } | ||
32 |
1/1✓ Branch 1 taken 76 times.
|
76 | obj.setVecContent(vecUpdateObj); //Update the content of CAPTION |
33 | 76 | ++figNumber; //Update the figure number | |
34 | 76 | }else{ | |
35 | 548 | PVecLatexObj & vecObj = obj.getVecContent(); | |
36 |
2/2✓ Branch 4 taken 315 times.
✓ Branch 5 taken 548 times.
|
863 | for(PVecLatexObj::iterator it(vecObj.begin()); it != vecObj.end(); ++it){ |
37 |
1/1✓ Branch 2 taken 315 times.
|
315 | updateFigureNumberCaption(*it, prefix, figNumber); |
38 | } | ||
39 | } | ||
40 | 624 | } | |
41 | |||
42 | ///Update all the figure number of the given PLatexObj | ||
43 | /** @param[out] obj : PLatexObj where the figure number have to be updated | ||
44 | * @param[out] figType : type of the figure to take account (FIGURE, TABLE) | ||
45 | * @param prefix : prefix of the table or figure | ||
46 | * @param[out] figNumber : figure number of the current figure | ||
47 | */ | ||
48 | 41892 | void updateFigureNumberFig(PLatexObj & obj, PLatexType::PLatexType figType, const PString & prefix, size_t & figNumber){ | |
49 |
2/2✓ Branch 1 taken 155 times.
✓ Branch 2 taken 41737 times.
|
41892 | if(obj.getType() == figType){ //We find a figure |
50 | //Searching for a caption in the figure, and update it | ||
51 | 155 | PVecLatexObj & vecObj = obj.getVecContent(); | |
52 |
2/2✓ Branch 4 taken 309 times.
✓ Branch 5 taken 155 times.
|
464 | for(PVecLatexObj::iterator it(vecObj.begin()); it != vecObj.end(); ++it){ |
53 |
1/1✓ Branch 2 taken 309 times.
|
309 | updateFigureNumberCaption(*it, prefix, figNumber); |
54 | } | ||
55 | }else{ | ||
56 | 41737 | PVecLatexObj & vecObj = obj.getVecContent(); | |
57 |
2/2✓ Branch 4 taken 41638 times.
✓ Branch 5 taken 41737 times.
|
83375 | for(PVecLatexObj::iterator it(vecObj.begin()); it != vecObj.end(); ++it){ |
58 |
1/1✓ Branch 2 taken 41638 times.
|
41638 | updateFigureNumberFig(*it, figType, prefix, figNumber); |
59 | } | ||
60 | } | ||
61 | 41892 | } | |
62 | |||
63 | ///Update all the figure number of the given PLatexObj | ||
64 | /** @param[out] obj : PLatexObj where the figure number have to be updated | ||
65 | */ | ||
66 | 127 | void updateFigureNumber(PLatexObj & obj){ | |
67 | 127 | size_t figNumber(1lu); | |
68 |
2/2✓ Branch 1 taken 127 times.
✓ Branch 4 taken 127 times.
|
127 | updateFigureNumberFig(obj, PLatexType::FIGURE, "Figure", figNumber); |
69 | 127 | size_t tabNumber(1lu); | |
70 |
2/2✓ Branch 1 taken 127 times.
✓ Branch 4 taken 127 times.
|
127 | updateFigureNumberFig(obj, PLatexType::TABLE, "Table", tabNumber); |
71 | 127 | } | |
72 | |||
73 | |||
74 |