PhoenixLecture  2.0.0
Set of tools to make lectures
update_wip.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 
8 #include "update_wip.h"
9 
11 
14 bool updateVecContent(const PVecLatexObj & vecContent){
15  bool hasWip(false);
16  for(PVecLatexObj::const_iterator it(vecContent.begin()); it != vecContent.end(); ++it){
17  if(it->getType() == PLatexType::WORK_IN_PROGRESS){
18  hasWip = true;
19  }else if(it->getVecContent().size() != 0lu){
20  hasWip |= updateVecContent(it->getVecContent());
21  }
22  }
23  return hasWip;
24 }
25 
27 
31  bool hasWip(false);
32  PVecLatexObj & vecObj = obj.getVecContent();
33  for(PVecLatexObj::iterator it(vecObj.begin()); it != vecObj.end(); ++it){
34  if(isSection(*it)){
35  hasWip |= updateSectionWip(*it);
36  }else if(it->getType() == PLatexType::WORK_IN_PROGRESS){
37  hasWip = true;
38  }else{
39  if(it->getVecContent().size() != 0lu){ //If the content contains sub latex
40  hasWip |= updateVecContent(it->getVecContent());
41  }
42  }
43  }
44  if(isSection(obj)){
45  obj.setIsWorkInProgress(hasWip);
46  if(hasWip){
47  PLatexObj wipObj;
48  wipObj.setType(PLatexType::TEXT);
49  wipObj.setText(" (WIP)");
50  obj.getComplexTitle().push_back(wipObj);
51  }
52  }
53  return hasWip;
54 }
55 
57 
59 void updateWip(PLatexObj & obj){
60  PVecLatexObj & vecObj = obj.getVecContent();
61  for(PVecLatexObj::iterator it(vecObj.begin()); it != vecObj.end(); ++it){
62  if(isSection(*it)){
63  updateSectionWip(*it);
64  }
65  }
66 }
67 
68 
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 setIsWorkInProgress(bool isWorkInProgress)
Sets the isWorkInProgress of the PLatexObj.
Definition: PLatexObj.cpp:263
const std::vector< PLatexObj > & getComplexTitle() const
Gets the complexTitle of the PLatexObj.
Definition: PLatexObj.cpp:396
void setType(const PLatexType::PLatexType &type)
Sets the type of the PLatexObj.
Definition: PLatexObj.cpp:130
void setText(const PString &text)
Sets the text of the PLatexObj.
Definition: PLatexObj.cpp:137
@ WORK_IN_PROGRESS
Definition: PLatexType.h:32
bool isSection(const PLatexObj &obj)
Say if the PLatexObj is a part, charpter, section, subsection or subsubsection.
std::vector< PLatexObj > PVecLatexObj
Vector of obj.
void updateWip(PLatexObj &obj)
Update the Part/Chapter/Section/etc if they contains a work in progress.
Definition: update_wip.cpp:59
bool updateVecContent(const PVecLatexObj &vecContent)
Check in a vector of latex objects if there is a wip.
Definition: update_wip.cpp:14
bool updateSectionWip(PLatexObj &obj)
Update the wip of a obj and say if there was a WIP inside or not.
Definition: update_wip.cpp:30