From a1245cf2ad80cba0a71ffb184966ee77a7e166cc Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Thu, 15 Jan 2015 14:18:07 +0100 Subject: Further simplified document buildup by doing the addition to parents of StructureNodes in the constructor and refactored Anchor as standalone class instead of AnnotationEntity child. This made some changes in the test bench necessary as well. --- test/core/model/TestAdvanced.hpp | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'test/core/model/TestAdvanced.hpp') diff --git a/test/core/model/TestAdvanced.hpp b/test/core/model/TestAdvanced.hpp index 15a4042..f8585d1 100644 --- a/test/core/model/TestAdvanced.hpp +++ b/test/core/model/TestAdvanced.hpp @@ -115,11 +115,9 @@ static Rooted constructEmphasisDomain(Manager &mgr, // set up domain node. Rooted domain{new Domain(mgr, sys, "emphasis")}; // create AnnotationClasses - Rooted em{ - new AnnotationClass(mgr, "emphasized", domain)}; + Rooted em{new AnnotationClass(mgr, "emphasized", domain)}; - Rooted strong{ - new AnnotationClass(mgr, "strong", domain)}; + Rooted strong{new AnnotationClass(mgr, "strong", domain)}; return domain; } @@ -135,12 +133,8 @@ static bool addText(Logger &logger, Handle doc, } // And the primitive content Variant content_var{content.c_str()}; - Rooted primitive = - buildPrimitiveEntity(logger, text, content_var, "content"); - if (primitive.isNull()) { - return false; - } - + Rooted primitive{new DocumentPrimitive( + parent->getManager(), text, content_var, "content")}; return true; } @@ -167,19 +161,12 @@ static bool addAnnotation(Logger &logger, Handle doc, Handle parent, const std::string &text, const std::string &annoClass) { - Rooted start = - buildAnchor(logger, parent, std::to_string(annoIdx++)); - if (start.isNull()) { - return false; - } + Manager& mgr = parent->getManager(); + Rooted start{new Anchor(mgr, std::to_string(annoIdx++), parent)}; if (!addText(logger, doc, parent, text)) { return false; } - Rooted end = - buildAnchor(logger, parent, std::to_string(annoIdx++)); - if (end.isNull()) { - return false; - } + Rooted end{new Anchor(mgr, std::to_string(annoIdx++), parent)}; Rooted anno = buildAnnotationEntity(doc, logger, {annoClass}, start, end); if (anno.isNull()) { @@ -191,7 +178,6 @@ static bool addAnnotation(Logger &logger, Handle doc, /** * This constructs a more advanced book document using not only the book * domain but also headings, emphasis and lists. - * TODO: insert emphasis and lists. */ static Rooted constructAdvancedDocument(Manager &mgr, Logger &logger, Handle bookDom, -- cgit v1.2.3