Directory: | ./ |
---|---|
File: | tmp_project/PhoenixTex2Html/src/PLatexObj/updateLabelCitation.cpp |
Date: | 2025-03-24 18:12:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 31 | 31 | 100.0% |
Branches: | 36 | 38 | 94.7% |
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 "updateLabelCitation.h" | ||
9 | |||
10 | ///Update the map of label | ||
11 | /** @param[out] obj : PLatexObj to be updated | ||
12 | * @param mapBiblioEntry : map of label to be used | ||
13 | */ | ||
14 | 378 | void useMapLabelCite(PLatexObj & obj, const PMapBiblioEntry & mapBiblioEntry){ | |
15 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 2 taken 369 times.
|
378 | if(obj.getType() == PLatexType::CITATION){ //We find a citation |
16 |
3/3✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
|
9 | PString allCitation = obj.getName().eraseChar(" \n\t"); |
17 |
1/1✓ Branch 1 taken 9 times.
|
9 | PVecString listCitation = allCitation.split(','); |
18 | |||
19 | 9 | PVecLatexObj vecObjCitation; | |
20 |
2/2✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
|
18 | for(PVecString::iterator it(listCitation.begin()); it != listCitation.end(); ++it){ |
21 |
1/1✓ Branch 2 taken 9 times.
|
9 | PMapBiblioEntry::const_iterator itCite(mapBiblioEntry.find(*it)); //Let's find the corresponding article |
22 |
1/2✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | if(itCite != mapBiblioEntry.end()){ |
23 | 9 | const PBiblioEntry & bibiEntry = itCite->second; | |
24 |
4/4✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 10 taken 9 times.
|
18 | PString link("bibliography.html#"+valueToString(bibiEntry.getId())); |
25 |
1/1✓ Branch 1 taken 9 times.
|
9 | PLatexObj tmpObjCitation(obj); |
26 |
1/1✓ Branch 1 taken 9 times.
|
9 | tmpObjCitation.setLink(link); |
27 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | tmpObjCitation.setLabelName(obj.getName()); //Save the biblio entry label (maybe usefull in case of debugging) |
28 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | tmpObjCitation.setName(bibiEntry.getTitle()); //Name becomes the title of the article |
29 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | tmpObjCitation.setAuthor(bibiEntry.getAuthor()); //Author becomes the author of the article |
30 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | tmpObjCitation.setDate(bibiEntry.getYear()); //Date becomes the year of the article |
31 |
4/4✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 10 taken 9 times.
|
9 | tmpObjCitation.setText(valueToString(bibiEntry.getId())); //Text becomes the id of the citation |
32 |
1/1✓ Branch 1 taken 9 times.
|
9 | vecObjCitation.push_back(tmpObjCitation); |
33 | 9 | } | |
34 | } | ||
35 |
1/2✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
|
9 | if(vecObjCitation.size() == 1lu){ |
36 |
1/1✓ Branch 2 taken 9 times.
|
9 | obj = vecObjCitation.front(); |
37 | } | ||
38 |
1/1✓ Branch 1 taken 9 times.
|
9 | obj.setType(PLatexType::NONE); |
39 |
1/1✓ Branch 1 taken 9 times.
|
9 | obj.setVecContent(vecObjCitation); |
40 | 9 | }else{ | |
41 | 369 | PVecLatexObj & vecObj = obj.getVecContent(); | |
42 |
2/2✓ Branch 4 taken 375 times.
✓ Branch 5 taken 369 times.
|
744 | for(PVecLatexObj::iterator it(vecObj.begin()); it != vecObj.end(); ++it){ |
43 |
1/1✓ Branch 2 taken 375 times.
|
375 | useMapLabelCite(*it, mapBiblioEntry); |
44 | } | ||
45 | } | ||
46 | 378 | } | |
47 | |||
48 | |||
49 | ///Update the label of the references | ||
50 | /** @param[out] obj : PLatexObj to be updated | ||
51 | * @param mapBiblioEntry : map of label to be used | ||
52 | */ | ||
53 | 3 | void updateLabelCitation(PLatexObj & obj, const PMapBiblioEntry & mapBiblioEntry){ | |
54 | 3 | useMapLabelCite(obj, mapBiblioEntry); | |
55 | 3 | } | |
56 | |||
57 | |||
58 |