PhoenixLecture  2.0.0
Set of tools to make lectures
updateFigureNumber.cpp
Go to the documentation of this file.
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 
11 
15 void updateFigureNumberCaption(PLatexObj & obj, const PString & prefix, size_t & figNumber){
16  if(obj.getType() == PLatexType::CAPTION){ //We find a caption
17  //We update it
18  PLatexObj objFigNumber;
19  objFigNumber.setType(PLatexType::TEXTBF);
20  //TODO : update set name to setVecContent when TEXTBF backend will use also vecContent
21  objFigNumber.setName(prefix+ " " + valueToString(figNumber) + " : ");
22 
23  obj.setName(valueToString(figNumber));
24 
25  PVecLatexObj vecUpdateObj;
26  vecUpdateObj.push_back(objFigNumber);
27 
28  PVecLatexObj & vecObj = obj.getVecContent(); //Content of the current caption
29  for(PVecLatexObj::iterator it(vecObj.begin()); it != vecObj.end(); ++it){
30  vecUpdateObj.push_back(*it);
31  }
32  obj.setVecContent(vecUpdateObj); //Update the content of CAPTION
33  ++figNumber; //Update the figure number
34  }else{
35  PVecLatexObj & vecObj = obj.getVecContent();
36  for(PVecLatexObj::iterator it(vecObj.begin()); it != vecObj.end(); ++it){
37  updateFigureNumberCaption(*it, prefix, figNumber);
38  }
39  }
40 }
41 
43 
48 void updateFigureNumberFig(PLatexObj & obj, PLatexType::PLatexType figType, const PString & prefix, size_t & figNumber){
49  if(obj.getType() == figType){ //We find a figure
50  //Searching for a caption in the figure, and update it
51  PVecLatexObj & vecObj = obj.getVecContent();
52  for(PVecLatexObj::iterator it(vecObj.begin()); it != vecObj.end(); ++it){
53  updateFigureNumberCaption(*it, prefix, figNumber);
54  }
55  }else{
56  PVecLatexObj & vecObj = obj.getVecContent();
57  for(PVecLatexObj::iterator it(vecObj.begin()); it != vecObj.end(); ++it){
58  updateFigureNumberFig(*it, figType, prefix, figNumber);
59  }
60  }
61 }
62 
64 
67  size_t figNumber(1lu);
68  updateFigureNumberFig(obj, PLatexType::FIGURE, "Figure", figNumber);
69  size_t tabNumber(1lu);
70  updateFigureNumberFig(obj, PLatexType::TABLE, "Table", tabNumber);
71 }
72 
73 
Describe a latex object.
Definition: PLatexObj.h:40
const std::vector< PLatexObj > & getVecContent() const
Gets the vecContent of the PLatexObj.
Definition: PLatexObj.cpp:410
void setVecContent(const std::vector< PLatexObj > &vecContent)
Sets the vecContent of the PLatexObj.
Definition: PLatexObj.cpp:186
const PLatexType::PLatexType & getType() const
Gets the type of the PLatexObj.
Definition: PLatexObj.cpp:298
void setName(const PString &name)
Sets the name of the PLatexObj.
Definition: PLatexObj.cpp:144
void setType(const PLatexType::PLatexType &type)
Sets the type of the PLatexObj.
Definition: PLatexObj.cpp:130
Extends the std::string.
Definition: PString.h:16
std::string valueToString(const T &val)
Convert a type into a string.
PLatexType
Type of the PLatexObj.
Definition: PLatexType.h:12
std::vector< PLatexObj > PVecLatexObj
Vector of obj.
void updateFigureNumberCaption(PLatexObj &obj, const PString &prefix, size_t &figNumber)
Update all the figure number of the given PLatexObj.
void updateFigureNumberFig(PLatexObj &obj, PLatexType::PLatexType figType, const PString &prefix, size_t &figNumber)
Update all the figure number of the given PLatexObj.
void updateFigureNumber(PLatexObj &obj)
Update all the figure number of the given PLatexObj.