From b05499223916879e051d102e1b7e2fd080f46e7d Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Thu, 8 Jan 2015 20:31:30 +0100 Subject: further extended advanced document (now list domain is supported as well) and extended DemoOutput accordingly. --- src/core/model/Domain.cpp | 20 ++++++++++---------- src/core/model/Domain.hpp | 6 ------ src/plugins/html/DemoOutput.cpp | 38 +++++++++++++++++++++++++++----------- src/plugins/html/DemoOutput.hpp | 4 ++-- 4 files changed, 39 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/core/model/Domain.cpp b/src/core/model/Domain.cpp index f9e2a55..49a3200 100644 --- a/src/core/model/Domain.cpp +++ b/src/core/model/Domain.cpp @@ -53,16 +53,16 @@ void Descriptor::doResolve(std::vector> &res, // &DESCRIPTOR_ATTRIBUTES_ALIAS); } -void StructuredClass::doResolve(std::vector> &res, - const std::vector &path, - Filter filter, void *filterData, unsigned idx, - VisitorSet &visited) -{ - Descriptor::doResolve(res, path, filter, filterData, idx, visited); - if (!isa.isNull()) { - isa->doResolve(res, path, filter, filterData, idx, visited); - } -} +//void StructuredClass::doResolve(std::vector> &res, +// const std::vector &path, +// Filter filter, void *filterData, unsigned idx, +// VisitorSet &visited) +//{ +// Descriptor::doResolve(res, path, filter, filterData, idx, visited); +// if (!isa.isNull()) { +// isa->doResolve(res, path, filter, filterData, idx, visited); +// } +//} void Domain::doResolve(std::vector> &res, const std::vector &path, Filter filter, diff --git a/src/core/model/Domain.hpp b/src/core/model/Domain.hpp index 8d5de0c..6a07b32 100644 --- a/src/core/model/Domain.hpp +++ b/src/core/model/Domain.hpp @@ -468,12 +468,6 @@ private: Owned isa; NodeVector parents; -protected: - void doResolve(std::vector> &res, - const std::vector &path, Filter filter, - void *filterData, unsigned idx, - VisitorSet &visited) override; - public: const bool transparent; // TODO: Is it possible to have root=true and cardinality other than 1? diff --git a/src/plugins/html/DemoOutput.cpp b/src/plugins/html/DemoOutput.cpp index eac240b..307d37a 100644 --- a/src/plugins/html/DemoOutput.cpp +++ b/src/plugins/html/DemoOutput.cpp @@ -147,9 +147,8 @@ Rooted DemoHTMLTransformer::transformSection( Rooted child; if (childDescriptorName == "paragraph") { child = transformParagraph(n); - // TODO: Implement - // } else if(childDescriptorName == "ul"){ - // writeList(n, out); + } else if (childDescriptorName == "ul" || childDescriptorName == "ol") { + child = transformList(n); } else { child = transformSection(n); } @@ -199,13 +198,30 @@ Rooted DemoHTMLTransformer::transformParagraph( return p; } -// Rooted -// DemoHTMLTransformer::transformList(Handle list){ -// Manager &mgr = list->getManager(); -// // create the list Element, which is either ul or ol (depends on descriptor) -// std::string listclass = list->getDescriptor()->getName(); -// Rooted l{new xml::Element{mgr, listclass}}; -// // iterate through -//} +Rooted DemoHTMLTransformer::transformList( + Handle list) +{ + Manager &mgr = list->getManager(); + // create the list Element, which is either ul or ol (depends on descriptor) + std::string listclass = list->getDescriptor()->getName(); + Rooted l{new xml::Element{mgr, listclass}}; + // iterate through list items. + for (auto &item : list->getField()) { + std::string itDescrName = item->getDescriptor()->getName(); + if (itDescrName == "item") { + // create the list item. + Rooted li{new xml::Element{mgr, "li"}}; + l->children.push_back(li); + // extract the item text, enveloped in a paragraph Element. + Rooted li_content = transformParagraph(item); + // We omit the paragraph Element and add the children directly to + // the list item + for (auto &n : li_content->children) { + li->children.push_back(n); + } + } + } + return l; +} } } diff --git a/src/plugins/html/DemoOutput.hpp b/src/plugins/html/DemoOutput.hpp index 0819d7f..6c046e7 100644 --- a/src/plugins/html/DemoOutput.hpp +++ b/src/plugins/html/DemoOutput.hpp @@ -46,8 +46,8 @@ private: */ Rooted transformSection(Handle sec); Rooted transformParagraph(Handle par); -// Rooted transformList(Handle list); - //TODO: Implement emphasis. + Rooted transformList(Handle list); +// TODO: Implement emphasis. public: /** -- cgit v1.2.3