From a7053861b597a56d7e4c85eaa7f65dcd82b1903e Mon Sep 17 00:00:00 2001 From: yorikvanhavre Date: Fri, 23 Dec 2011 19:15:14 -0200 Subject: [PATCH] further work on DrawingPage --- src/Mod/Drawing/App/FeaturePage.cpp | 33 +++++++++++++++++++++++++++++ src/Mod/Drawing/App/FeaturePage.h | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/Mod/Drawing/App/FeaturePage.cpp b/src/Mod/Drawing/App/FeaturePage.cpp index e5f33ba65..30559a857 100644 --- a/src/Mod/Drawing/App/FeaturePage.cpp +++ b/src/Mod/Drawing/App/FeaturePage.cpp @@ -56,6 +56,7 @@ FeaturePage::FeaturePage(void) ADD_PROPERTY_TYPE(PageResult ,(0),group,App::Prop_Output,"Resulting SVG document of that page"); ADD_PROPERTY_TYPE(Template ,(""),group,App::Prop_None ,"Template for the page"); + ADD_PROPERTY_TYPE(EditableTexts,(""),group,App::Prop_None,"Substitution values for the editable strings in the template"); } FeaturePage::~FeaturePage() @@ -129,6 +130,38 @@ App::DocumentObjectExecReturn *FeaturePage::execute(void) file.close(); ofile.close(); + // checking for freecad editable texts + boost::regex e ("(.*?)",boost::regex_constants::icase); + + // reading file contents + ifstream tfile (tempName.c_str()); + string tline; + string fragment; + + while (!tfile.eof()) { + getline (tfile,tline); + fragment += tline; + fragment += "--endOfLine--"; + } + + tfile.close(); + + //printf(fragment.c_str()); + + string::const_iterator start, end; + start = fragment.begin(); + end = fragment.end(); + //boost::smatch what; + boost::match_results what; + + cout << "Stored strings: " << EditableTexts.getValue(); + + while (boost::regex_search(start,end,what,e)) { + //cout << "match" << what.str() << endl; + cout << "new match:" << what[1] << " = " << what[2] << endl; + start = what[0].second; + } + PageResult.setValue(tempName.c_str()); //const char* text = "lskdfjlsd"; diff --git a/src/Mod/Drawing/App/FeaturePage.h b/src/Mod/Drawing/App/FeaturePage.h index e430c9e29..885bef6b8 100644 --- a/src/Mod/Drawing/App/FeaturePage.h +++ b/src/Mod/Drawing/App/FeaturePage.h @@ -47,7 +47,7 @@ public: App::PropertyFileIncluded PageResult; App::PropertyFile Template; - + App::PropertyStringList EditableTexts; /** @name methods overide Feature */ //@{