PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
pinkscape_slide.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 <sys/stat.h>
8 #include <sys/types.h>
9 #include <fstream>
10 
11 #include "data_all.h"
12 #include "convertToString.h"
13 
14 #include "pinkscape_slide.h"
15 
17 
19 void pinkscape_loadSlideMap(PMapSlide & mapFormula, const PPath & baseOutputName){
20  PPath fileName(baseOutputName + PPath(SLIDE_RECOVER_FILE));
21  if(!data_load(fileName, mapFormula)){return;}
22 }
23 
25 
27 void pinkscape_saveSlideMap(const PMapSlide & mapFormula, const PPath & baseOutputName){
28  PPath fileName(baseOutputName + PPath(SLIDE_RECOVER_FILE));
29  if(!data_save(fileName, mapFormula)){return;}
30 }
31 
33 
37 bool pinkscape_isSlideKnown(POutoutMode & outputMode, const PPath & outputSlide, const PString & slideContent){
38  PMapSlide & mapSlide = outputMode.mapSlide;
39  PMapSlide::iterator it(mapSlide.find(outputSlide));
40  if(it != mapSlide.end()){ //The slide is already known
41  if(it->second == slideContent){ //If the slide content is the same
42  if(outputSlide.isFileExist()){ //We do not need to save it because it already exist
43  return true;
44  }else{
45  std::cout << "pinkscape_isSlideKnown : file '"<<outputSlide<<"' does not exist" << std::endl;
46  }
47  }else{
48  std::cout << "pinkscape_isSlideKnown : '"<<outputSlide<<" 'slide content changed" << std::endl;
49  }
50  }
51  //The slide is not known
52 
53  //Let's update the slide content (or create it)
54  mapSlide[outputSlide] = slideContent;
55  return false;
56 }
57 
58 
59 
60 
61 
Path of a directory or a file.
Definition: PPath.h:17
bool isFileExist() const
Say if the current file path does exist.
Definition: PPath.cpp:139
Extends the std::string.
Definition: PString.h:16
bool data_load(FILE *iter, T &data)
Load data from a message.
Definition: data_file.h:39
bool data_save(FILE *iter, const T &data)
Save data in a message.
Definition: data_file.h:18
void pinkscape_loadSlideMap(PMapSlide &mapFormula, const PPath &baseOutputName)
Load the map file of all the formulae if it exists.
void pinkscape_saveSlideMap(const PMapSlide &mapFormula, const PPath &baseOutputName)
Save the map file of the formulae to avoid extra latex call.
bool pinkscape_isSlideKnown(POutoutMode &outputMode, const PPath &outputSlide, const PString &slideContent)
Check if the slide we are going to save was already saved (with the same content) or not.
#define SLIDE_RECOVER_FILE
Define the name of the file which contains the formulae and the path to the created file.
std::map< PPath, PPath > PMapSlide
Map of the formulae generated by the ptex2html which can be reused by other PLatexObj which have the ...
Output mode of the html backend.
PMapSlide mapSlide
Map of the formula which are already saved as png files.