You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@corinthia.apache.org by ia...@apache.org on 2015/07/04 06:36:55 UTC

[3/3] incubator-corinthia git commit: ODF Lenses get direction

ODF Lenses get direction

Follow the Word structure for lenses and style management.


Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/92492106
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/92492106
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/92492106

Branch: refs/heads/ODFLenses
Commit: 924921065e764ba66c4170df0abb43fb943c918b
Parents: 6552f4b
Author: Ian C <ia...@apache.org>
Authored: Thu Jul 2 20:08:28 2015 +0800
Committer: Ian C <ia...@apache.org>
Committed: Thu Jul 2 20:08:28 2015 +0800

----------------------------------------------------------------------
 DocFormats/api/src/Operations.c                 |  22 +-
 DocFormats/filters/odf/CMakeLists.txt           |  32 ++-
 DocFormats/filters/odf/src/ODF.c                |  39 +++
 DocFormats/filters/odf/src/ODF.h                |  13 +-
 DocFormats/filters/odf/src/ODFConverter.c       | 178 ++++++++++++++
 DocFormats/filters/odf/src/ODFConverter.h       |  52 ++++
 DocFormats/filters/odf/src/ODFManifest.h        |   5 +-
 DocFormats/filters/odf/src/ODFPackage.c         |  27 ++-
 DocFormats/filters/odf/src/ODFPackage.h         |   7 +-
 DocFormats/filters/odf/src/ODFSheet.c           |  29 ---
 DocFormats/filters/odf/src/ODFSheet.h           |  24 +-
 .../filters/odf/src/formatting/ODFStyles.c      | 237 +++++++++++++++++++
 .../filters/odf/src/formatting/ODFStyles.h      |  44 ++++
 DocFormats/filters/odf/src/lenses/ODFBody.c     |  75 ++++++
 DocFormats/filters/odf/src/lenses/ODFDocument.c |  86 +++++++
 DocFormats/filters/odf/src/lenses/ODFHeader.c   | 110 +++++++++
 DocFormats/filters/odf/src/lenses/ODFLenses.c   |  31 +++
 DocFormats/filters/odf/src/lenses/ODFLenses.h   |  55 +++++
 .../filters/odf/src/lenses/ODFParagraph.c       |  96 ++++++++
 .../odf/src/lenses/ODFParagraphContent.c        | 118 +++++++++
 .../odf/src/lenses/ODFPresentationLens.c        |  73 ++++++
 .../filters/odf/src/lenses/ODFSpreadsheetLens.c |  73 ++++++
 DocFormats/filters/odf/src/lenses/ODFTextLens.c | 102 ++++++++
 .../filters/odf/src/lenses/ODFTextLevelLens.c   | 107 +++++++++
 DocFormats/filters/odf/src/text/ODFText.c       | 107 +++------
 DocFormats/filters/odf/src/text/ODFText.h       |   9 +-
 .../filters/odf/src/text/ODFTextConverter.h     |   1 +
 DocFormats/filters/odf/src/text/gbg_test.c      | 159 +++++++------
 28 files changed, 1681 insertions(+), 230 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/api/src/Operations.c
----------------------------------------------------------------------
diff --git a/DocFormats/api/src/Operations.c b/DocFormats/api/src/Operations.c
index f605ad8..5b71d50 100644
--- a/DocFormats/api/src/Operations.c
+++ b/DocFormats/api/src/Operations.c
@@ -21,7 +21,7 @@
 #include "DFString.h"
 #include <DocFormats/DFStorage.h>
 #include "Word.h"
-#include "ODFText.h"
+#include "ODF.h"
 #include "DFHTML.h"
 #include "DFDOM.h"
 #include "DFXML.h"
@@ -242,10 +242,10 @@ int DFGet(DFConcreteDocument *concrete,
                               error);
             break;
         case DFFileFormatOdt:
-            htmlDoc = ODFTextGet(concrete->storage,
-                                 abstract->storage,
-                                 idPrefix,
-                                 error);
+            htmlDoc = ODFGet(concrete->storage,
+                             abstract->storage,
+                             idPrefix,
+                             error);
             break;
         default:
             DFErrorFormat(error,"Unsupported file format");
@@ -308,11 +308,11 @@ int DFPut(DFConcreteDocument *concreteDoc,
                          error);
             break;
         case DFFileFormatOdt:
-            ok = ODFTextPut(concreteDoc->storage,
-                            abstractDoc->storage,
-                            abstractDoc->htmlDoc,
-                            idPrefix,
-                            error);
+            ok = ODFPut(concreteDoc->storage,
+                        abstractDoc->storage,
+                        abstractDoc->htmlDoc,
+                        idPrefix,
+                        error);
             break;
         default:
             DFErrorFormat(error,"Unsupported file format");
@@ -340,7 +340,7 @@ int DFCreate(DFConcreteDocument *concreteDoc,
                             error);
             break;
         case DFFileFormatOdt:
-            ok = ODFTextCreate(concreteDoc->storage,
+            ok = ODFCreate(concreteDoc->storage,
                                abstractDoc->storage,
                                abstractDoc->htmlDoc,
                                error);

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/CMakeLists.txt b/DocFormats/filters/odf/CMakeLists.txt
index 521b915..ada627e 100644
--- a/DocFormats/filters/odf/CMakeLists.txt
+++ b/DocFormats/filters/odf/CMakeLists.txt
@@ -22,9 +22,30 @@ set(GroupSrc
     src/ODFManifest.h
     src/ODFPackage.c
     src/ODFPackage.h
+    src/ODFConverter.c
+    src/ODFConverter.h
     src/ODFSheet.c
     src/ODFSheet.h)
 
+###
+## group odf lenses objects
+###
+set(GroupODFLenses
+    src/lenses/ODFLenses.c
+    src/lenses/ODFDocument.c
+    src/lenses/ODFBody.c
+    src/lenses/ODFSpreadsheetLens.c
+    src/lenses/ODFTextLens.c
+    src/lenses/ODFTextLevelLens.c
+    src/lenses/ODFPresentationLens.c
+    src/lenses/ODFParagraph.c
+    src/lenses/ODFParagraphContent.c
+    src/lenses/ODFHeader.c)
+
+set(GroupODFFormatting
+    src/formatting/ODFStyles.c
+    src/formatting/ODFStyles.h)
+
 set(GroupSrcText
     src/text/color.h
     src/text/color.c
@@ -73,8 +94,13 @@ include_directories(../../unittest)
 add_library(odf OBJECT
     ${GroupSrc}
     ${GroupSrcText}
+    ${GroupODFLenses}
+    ${GroupODFFormatting}
     ${GroupTests})
-source_group(src         FILES ${GroupSrc})
-source_group(src\\text   FILES ${GroupSrcText})
-source_group(tests       FILES ${GroupTests})
+    
+source_group(src                FILES ${GroupSrc})
+source_group(src\\lenses        FILES ${GroupODFLenses})
+source_group(src\\formatting    FILES ${GroupODFFormatting})
+source_group(src\\text          FILES ${GroupSrcText})
+source_group(tests              FILES ${GroupTests})
 set_property(TARGET odf PROPERTY FOLDER DocFormats/filters)

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/ODF.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/ODF.c b/DocFormats/filters/odf/src/ODF.c
index f2091de..5400175 100644
--- a/DocFormats/filters/odf/src/ODF.c
+++ b/DocFormats/filters/odf/src/ODF.c
@@ -18,3 +18,42 @@
 #include "DFPlatform.h"
 #include "ODF.h"
 #include "DFCommon.h"
+#include "ODFConverter.h"
+
+#include <stdio.h>
+
+DFDocument *ODFGet(DFStorage *concreteStorage, DFStorage *abstractStorage, const char *idPrefix, DFError **error)
+{
+    int ok = 0;
+    DFDocument *html = NULL;
+    ODFPackage *package = NULL;
+    ODFConverter *conv = NULL;
+
+    printf("ODFGet\n");
+    package = ODFPackageOpenFrom(concreteStorage, error);
+    if (package == NULL)
+        goto end;
+    printf("ODFGet\n");
+    html = DFDocumentNewWithRoot(HTML_HTML);
+    if(ODFConverterGet(html, abstractStorage, package, idPrefix, error) == 0)
+        goto end;
+    ok = 1;
+
+end:
+    ODFPackageRelease(package);
+    if (!ok) {
+        DFDocumentRelease(html);
+        return NULL;
+    }
+    return html;
+}
+
+int ODFPut(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocument *htmlDoc, const char *idPrefix, DFError **error)
+{
+    //TBD
+}
+
+int ODFCreate(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocument *htmlDoc, DFError **error)
+{
+    //TBD
+}

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/ODF.h
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/ODF.h b/DocFormats/filters/odf/src/ODF.h
index d34d3c5..e5ee24c 100644
--- a/DocFormats/filters/odf/src/ODF.h
+++ b/DocFormats/filters/odf/src/ODF.h
@@ -15,6 +15,17 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#pragma once
+#ifndef DocFormats_ODF_h
+#define DocFormats_ODF_h
+
+#include <DocFormats/DFError.h>
+#include <DocFormats/DFStorage.h>
 
 #include "ODFPackage.h"
+
+DFDocument *ODFGet(DFStorage *concreteStorage, DFStorage *abstractStorage, const char *idPrefix, DFError **error);
+int ODFPut(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocument *htmlDoc, const char *idPrefix, DFError **error);
+int ODFCreate(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocument *htmlDoc, DFError **error);
+
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/ODFConverter.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/ODFConverter.c b/DocFormats/filters/odf/src/ODFConverter.c
new file mode 100644
index 0000000..94bb98d
--- /dev/null
+++ b/DocFormats/filters/odf/src/ODFConverter.c
@@ -0,0 +1,178 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "DFPlatform.h"
+#include "ODFConverter.h"
+#include "DFString.h"
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include "ODFSheet.h"
+#include "text/ODFText.h"
+#include "lenses/ODFLenses.h"
+#include "DFHTML.h"
+#include "DFHTMLNormalization.h"
+
+#include "text/gbg_test.h"
+
+#include <stdio.h>
+
+
+static ODFConverter *ODFConverterNew(DFDocument *html, DFStorage *abstractStorage, ODFPackage *package, const char *idPrefix)
+{
+    ODFConverter *converter = (ODFConverter *)xcalloc(1,sizeof(ODFConverter));
+    converter->html = DFDocumentRetain(html);
+    converter->abstractStorage = DFStorageRetain(abstractStorage);
+    assert(DFStorageFormat(converter->abstractStorage) == DFFileFormatHTML);
+    converter->idPrefix = (idPrefix != NULL) ? xstrdup(idPrefix) : xstrdup("odf");
+    converter->package = ODFPackageRetain(package);
+    converter->styles = ODFSheetNew(converter->package->stylesDoc, converter->package->contentDoc);
+    converter->warnings = DFBufferNew();
+    return converter;
+}
+
+static void ODFConverterFree(ODFConverter *converter)
+{
+    DFDocumentRelease(converter->html);
+    DFStorageRelease(converter->abstractStorage);
+    free(converter->idPrefix);
+    ODFSheetRelease(converter->styles);
+    DFBufferRelease(converter->warnings);
+    CSSSheetRelease(converter->styleSheet);
+    ODFPackageRelease(converter->package);
+    free(converter);
+}
+
+
+int ODFConverterGet(DFDocument *html, DFStorage *abstractStorage, ODFPackage *package, const char *idPrefix, DFError **error)
+{
+    printf("ODFConverterGet\n");
+
+    if (package->contentDoc == NULL) {
+        DFErrorFormat(error,"document.xml not found");
+        return 0;
+    }
+    printf("doc node %s\n", translateXMLEnumName[package->contentDoc->root->tag]);
+    if (package->contentDoc->root->tag != OFFICE_DOCUMENT_CONTENT) {
+        DFErrorFormat(error,"odf:document content not found");
+        return 0;
+    }
+
+    DFNode *odfDocument = package->contentDoc->root;
+
+    ODFConverter *converter = ODFConverterNew(html,abstractStorage,package,idPrefix);
+
+    //Get the styles data
+    //CSSSheetRelease(converter->styleSheet);
+    converter->styleSheet = ODFStylesGet(converter);
+
+    //Try a lenses approach
+    ODFGetData get;
+    get.conv = converter;
+    DFNode *abstract = ODFDocumentLens.get(&get,odfDocument);
+    DFAppendChild(converter->html->docNode,abstract);
+    converter->html->root = abstract;
+    //ODF_postProcessHTMLDoc(converter);
+
+    //Convert the content.xml to an html beastie
+    //ODFTextGet(converter);
+
+    char *cssText = CSSSheetCopyCSSText(converter->styleSheet);
+    HTMLAddInternalStyleSheet(converter->html, cssText);
+    HTML_safeIndent(converter->html->docNode,0);
+
+    int ok = 1;
+    if (converter->warnings->len > 0) {
+        DFErrorFormat(error,"%s",converter->warnings->data);
+        ok = 0;
+    }
+
+    ODFConverterFree(converter);
+    return ok;
+}
+
+DFNode *ODFConverterCreateAbstract(ODFGetData *get, Tag tag, DFNode *concrete)
+{
+    DFNode *element = DFCreateElement(get->conv->html,tag);
+
+   if (concrete != NULL) {
+        char *idStr;
+        if (concrete->doc == get->conv->package->contentDoc)
+            idStr = DFFormatString("%s%u",get->conv->idPrefix,concrete->seqNo);
+        else
+            idStr = DFFormatString("%s%u-%s",get->conv->idPrefix,concrete->seqNo,DFNodeName(concrete->doc->root));
+        DFSetAttribute(element,HTML_ID,idStr);
+        free(idStr);
+    }
+    return element;
+}
+
+DFNode *ODFConverterGetConcrete(ODFPutData *put, DFNode *abstract)
+{
+    // Is the abstract node an element, and does it have an id that matches the prefix used for
+    // conversion? That is, does it look like it has a corresponding node in the concrete document?
+    if ((abstract == NULL) || (abstract->tag < MIN_ELEMENT_TAG))
+        return NULL;;
+    const char *idStr = DFGetAttribute(abstract,HTML_ID);
+    if ((idStr == NULL) || !DFStringHasPrefix(idStr,put->conv->idPrefix))
+        return NULL;;
+
+    // Determine the node sequence number and the document based on the id attribute.
+    // The format of the attribute is <prefix><seqno>(-<docname>)?, where
+    //
+    //     <prefix>  is the BDT prefix we use to identify nodes that match the original document
+    //     <seqno>   is an integer uniquely identifying a node in a given document
+    //     <docname> is the name of the document, either footnotes or endnotes. If absent, it is
+    //               the main content document (that is, document.xml)
+    //
+    // Note that the sequence number only makes sense within the context of a specific document. It
+    // is possible to have two different nodes in different documents that have the same sequence number.
+    // It is for this reason that the id string identifies both the node and the document.
+
+    size_t idLen = strlen(idStr);
+    size_t prefixLen = strlen(put->conv->idPrefix);
+
+    unsigned int seqNo = 0;
+    size_t pos = prefixLen;
+    while ((pos < idLen) && (idStr[pos] >= '0') && (idStr[pos] <= '9'))
+        seqNo = seqNo*10 + (idStr[pos++] - '0');
+
+    const char *docName = NULL;
+    if ((pos < idLen) && (idStr[pos] == '-')) {
+        pos++;
+        docName = &idStr[pos];
+    }
+
+/*    DFDocument *doc = NULL;
+    if (docName == NULL)
+        doc = put->conv->package->document;
+    else if (!strcmp(docName,"footnotes"))
+        doc = put->conv->package->footnotes;
+    else if (!strcmp(docName,"endnotes"))
+        doc = put->conv->package->endnotes;
+    else
+        return NULL; */
+
+    // Check to see if we have a node in the concrete document matching that sequence number
+    DFNode *node = DFNodeForSeqNo(put->conv->package->contentDoc,seqNo);
+
+    // Only return the node if it's actually an element
+    if ((node == NULL) || (node->tag < MIN_ELEMENT_TAG))
+        return NULL;
+    return node;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/ODFConverter.h
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/ODFConverter.h b/DocFormats/filters/odf/src/ODFConverter.h
new file mode 100644
index 0000000..410df50
--- /dev/null
+++ b/DocFormats/filters/odf/src/ODFConverter.h
@@ -0,0 +1,52 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <DocFormats/DFStorage.h>
+#include "DFDOM.h"
+#include "ODFPackage.h"
+
+#include "CSS.h"
+#include "CSSSheet.h"
+
+typedef struct {
+    DFDocument *html;
+    DFNode *body; //just cos its easier for the moment
+    DFStorage *abstractStorage;
+    char *idPrefix;
+    ODFPackage *package;
+    struct ODFSheet *styles;
+    DFBuffer *warnings;
+    CSSSheet *styleSheet;
+} ODFConverter ;
+
+typedef struct {
+    ODFConverter *conv;
+} ODFGetData;
+
+typedef struct {
+    ODFConverter *conv;
+    DFDocument *contentDoc;
+    DFHashTable *numIdByHtmlId;
+    DFHashTable *htmlIdByNumId;
+} ODFPutData;
+
+int ODFConverterGet(DFDocument *html, DFStorage *abstractStorage, ODFPackage *package, const char *idPrefix, DFError **error);
+
+DFNode *ODFConverterCreateAbstract(ODFGetData *get, Tag tag, DFNode *concrete);
+DFNode *ODFConverterGetConcrete(ODFPutData *put, DFNode *abstract);

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/ODFManifest.h
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/ODFManifest.h b/DocFormats/filters/odf/src/ODFManifest.h
index 9a57e1f..45eb903 100644
--- a/DocFormats/filters/odf/src/ODFManifest.h
+++ b/DocFormats/filters/odf/src/ODFManifest.h
@@ -15,7 +15,8 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#pragma once
+#ifndef DocFormats_ODFManifest_h
+#define DocFormats_ODFManifest_h
 
 #include "DFDOM.h"
 #include "DFHashTable.h"
@@ -82,3 +83,5 @@ void ODFManifestRelease(ODFManifest *manifest);
 
 void ODFManifestAddEntry(ODFManifest *manifest, const char *path, const char *mediaType,
                          const char *version);
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/ODFPackage.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/ODFPackage.c b/DocFormats/filters/odf/src/ODFPackage.c
index 3507586..e559c3c 100644
--- a/DocFormats/filters/odf/src/ODFPackage.c
+++ b/DocFormats/filters/odf/src/ODFPackage.c
@@ -93,9 +93,6 @@ ODFPackage *ODFPackageOpenNew(DFStorage *storage, DFError **error)
     ODFManifestAddEntry(package->manifest,"settings.xml","text/xml",NULL);
     ODFManifestAddEntry(package->manifest,"styles.xml","text/xml",NULL);
 
-    // Setup ODF objects
-    package->sheet = ODFSheetNew(package->stylesDoc,package->contentDoc);
-
     return package;
 }
 
@@ -106,21 +103,28 @@ ODFPackage *ODFPackageOpenFrom(DFStorage *storage, DFError **error)
     package->storage = DFStorageRetain(storage);
 
     // Read XML documents
-    if ((package->contentDoc = readDocument(package,"content.xml",error)) == NULL)
+    if ((package->contentDoc = readDocument(package,"content.xml",error)) == NULL) {
+        DFErrorFormat(error,"Unable to read content.xml");
         goto end;
-    if ((package->metaDoc = readDocument(package,"meta.xml",error)) == NULL)
+    }
+    if ((package->metaDoc = readDocument(package,"meta.xml",error)) == NULL) {
+        DFErrorFormat(error,"Unable to read meta.xml");
         goto end;
-    if ((package->settingsDoc = readDocument(package,"settings.xml",error)) == NULL)
+    }
+    if ((package->settingsDoc = readDocument(package,"settings.xml",error)) == NULL) {
+        DFErrorFormat(error,"Unable to read settings.xml");
         goto end;
-    if ((package->stylesDoc = readDocument(package,"styles.xml",error)) == NULL)
+    }
+    if ((package->stylesDoc = readDocument(package,"styles.xml",error)) == NULL) {
+        DFErrorFormat(error,"Unable to read styles.xml");
         goto end;
+    }
 
     // Read manifest
-    if ((package->manifest = readManifest(package,error)) == NULL)
+    if ((package->manifest = readManifest(package,error)) == NULL) {
+        DFErrorFormat(error,"Unable to read manifest.xml");
         goto end;
-
-    // Setup ODF objects
-    package->sheet = ODFSheetNew(package->stylesDoc,package->contentDoc);
+    }
 
     return package;
 
@@ -143,7 +147,6 @@ void ODFPackageRelease(ODFPackage *package)
 
     DFStorageRelease(package->storage);
     ODFManifestRelease(package->manifest);
-    ODFSheetRelease(package->sheet);
     DFDocumentRelease(package->contentDoc);
     DFDocumentRelease(package->metaDoc);
     DFDocumentRelease(package->settingsDoc);

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/ODFPackage.h
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/ODFPackage.h b/DocFormats/filters/odf/src/ODFPackage.h
index f30d5ca..610539e 100644
--- a/DocFormats/filters/odf/src/ODFPackage.h
+++ b/DocFormats/filters/odf/src/ODFPackage.h
@@ -15,13 +15,13 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#pragma once
+#ifndef DocFormats_ODFPackage_h
+#define DocFormats_ODFPackage_h
 
 #include <DocFormats/DFXMLForward.h>
 #include <DocFormats/DFError.h>
 #include <DocFormats/DFStorage.h>
 #include "ODFManifest.h"
-#include "ODFSheet.h"
 
 typedef struct ODFPackage ODFPackage;
 
@@ -33,7 +33,6 @@ struct ODFPackage {
     DFDocument *settingsDoc;
     DFDocument *stylesDoc;
     ODFManifest *manifest;
-    ODFSheet *sheet;
 };
 
 ODFPackage *ODFPackageOpenNew(DFStorage *storage, DFError **error);
@@ -41,3 +40,5 @@ ODFPackage *ODFPackageOpenFrom(DFStorage *storage, DFError **error);
 ODFPackage *ODFPackageRetain(ODFPackage *package);
 void ODFPackageRelease(ODFPackage *package);
 int ODFPackageSave(ODFPackage *package, DFError **error);
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/ODFSheet.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/ODFSheet.c b/DocFormats/filters/odf/src/ODFSheet.c
index c2ea092..609bca5 100644
--- a/DocFormats/filters/odf/src/ODFSheet.c
+++ b/DocFormats/filters/odf/src/ODFSheet.c
@@ -24,35 +24,6 @@
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 //                                                                                                //
-//                                            ODFStyle                                            //
-//                                                                                                //
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-ODFStyle *ODFStyleNew()
-{
-    ODFStyle *style = (ODFStyle *)xcalloc(1,sizeof(ODFStyle));
-    style->retainCount = 1;
-    return style;
-}
-
-ODFStyle *ODFStyleRetain(ODFStyle *style)
-{
-    if (style != NULL)
-        style->retainCount++;
-    return style;
-}
-
-void ODFStyleRelease(ODFStyle *style)
-{
-    if ((style == NULL) || (--style->retainCount > 0))
-        return;
-
-    free(style->selector);
-    free(style);
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-//                                                                                                //
 //                                            ODFSheet                                            //
 //                                                                                                //
 ////////////////////////////////////////////////////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/ODFSheet.h
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/ODFSheet.h b/DocFormats/filters/odf/src/ODFSheet.h
index 72e95e7..900cf98 100644
--- a/DocFormats/filters/odf/src/ODFSheet.h
+++ b/DocFormats/filters/odf/src/ODFSheet.h
@@ -15,28 +15,12 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#pragma once
+#ifndef DocFormats_ODFSheet_h
+#define DocFormats_ODFSheet_h
 
 #include <DocFormats/DFXMLForward.h>
 #include "DFTypes.h"
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-//                                                                                                //
-//                                            ODFStyle                                            //
-//                                                                                                //
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-typedef struct ODFStyle ODFStyle;
-
-struct ODFStyle {
-    size_t retainCount;
-    DFNode *element;
-    char *selector;
-};
-
-ODFStyle *ODFStyleNew();
-ODFStyle *ODFStyleRetain(ODFStyle *style);
-void ODFStyleRelease(ODFStyle *style);
+#include "formatting/ODFStyles.h"
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 //                                                                                                //
@@ -50,3 +34,5 @@ ODFSheet *ODFSheetNew(DFDocument *stylesDoc, DFDocument *contentDoc);
 ODFSheet *ODFSheetRetain(ODFSheet *sheet);
 void ODFSheetRelease(ODFSheet *sheet);
 ODFStyle *ODFSheetStyleForSelector(ODFSheet *sheet, const char *selector);
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/formatting/ODFStyles.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/formatting/ODFStyles.c b/DocFormats/filters/odf/src/formatting/ODFStyles.c
new file mode 100644
index 0000000..187a94d
--- /dev/null
+++ b/DocFormats/filters/odf/src/formatting/ODFStyles.c
@@ -0,0 +1,237 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "ODFSheet.h"
+#include "DFDOM.h"
+#include "DFHashTable.h"
+#include "DFCommon.h"
+#include "DFPlatform.h"
+#include "DFDOM.h"
+#include "DFCommon.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include "text/color.c"
+#include "text/gbg_test.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                            ODFStyle                                            //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * There can be text properties and paragraph properties under a style definition
+ * and a bunch of others that we are ignoring for the moment
+ *
+ * A style can have a parent definition. If a parent style is not specified,
+ * the default style which has the same family as the current style is used.
+ *
+ * we need to make sure the correct CSSStyle is used for both
+ *
+ */
+static void styleTextPropsGet(DFNode *textProps, CSSSheet *styleSheet)
+{
+    const char* styleName = DFGetAttribute(textProps->parent, STYLE_NAME);
+    printf(CYAN "Create CSS Properties for %s\n", styleName, RESET);
+    //if this is a heading? look for the TEXT_OUTLINE_LEVEL
+    const char* outlevel = DFGetAttribute(textProps->parent, STYLE_DEFAULT_OUTLINE_LEVEL);
+    CSSStyle* cssStyle = NULL;
+    if(outlevel != NULL && outlevel[0] < 55) { //'7'
+        char hlevel[4] = "h";
+        hlevel[1] = outlevel[0];
+        hlevel[2] = 0;
+
+        cssStyle = CSSSheetLookupElement(styleSheet,
+                                         hlevel,
+                                         styleName,
+                                         1,
+                                         0);
+    } else {
+        if(outlevel == NULL) {
+            printf("Outlevel was NULL\n");
+            cssStyle = CSSSheetLookupElement(styleSheet,
+                                             "",
+                                             styleName,
+                                             1,
+                                             0);
+        }
+        else {
+            printf("Outlevel was %x hex\n", outlevel[0]);
+            cssStyle = CSSSheetLookupElement(styleSheet,
+                                             "div",
+                                             styleName,
+                                             1,
+                                             0);
+        }
+    }
+    if(cssStyle != NULL) {
+        //just looking for bolds as a first cut
+        for (unsigned int i = 0; i < textProps->attrsCount; i++)
+        {
+            Tag t = textProps->attrs[i].tag;
+            switch(t) {
+                case FO_FONT_WEIGHT: {
+                    CSSProperties * localproperties = CSSStyleRule(cssStyle);
+                    CSSPut(localproperties,"font-weight",textProps->attrs[i].value);
+                    break;
+                }
+                case FO_FONT_SIZE: {
+                    CSSProperties * localproperties = CSSStyleRule(cssStyle);
+                    CSSPut(localproperties,"font-size",textProps->attrs[i].value);
+                    break;
+                }
+                case STYLE_FONT_NAME: {
+                    CSSProperties * localproperties = CSSStyleRule(cssStyle);
+                    CSSPut(localproperties,"font-family",textProps->attrs[i].value);
+                    break;
+                }
+                case FO_FONT_STYLE: {
+                    CSSProperties * localproperties = CSSStyleRule(cssStyle);
+                    CSSPut(localproperties,"font-style",textProps->attrs[i].value);
+                    break;
+                }
+                case FO_COLOR: {
+                    CSSProperties * localproperties = CSSStyleRule(cssStyle);
+                    CSSPut(localproperties,"color",textProps->attrs[i].value);
+                    break;
+                }
+                case STYLE_TEXT_UNDERLINE_STYLE: {
+                    CSSProperties * localproperties = CSSStyleRule(cssStyle);
+                    CSSPut(localproperties,"text-decoration", "underline");
+                    //This becomes browser specific - default to firefox
+                    //Chrome need an inner outer and span arund the element
+                    CSSPut(localproperties,"text-decoration-style", textProps->attrs[i].value);
+                }
+                default: {
+                    printf(RED "Ignored text properties attrbute %s:%s\n", translateXMLEnumName[t], textProps->attrs[i].value, RESET);
+                    break;
+                }
+            }
+        }
+    }
+}
+
+/**
+ * The Style:Style element is the main node for text style inof
+ * There are many attributes that do no map into CSSProperties
+ * Log/Record those we do map
+ * and perhaps more importantly those we do not
+ */
+static void styleStyleGet(DFNode *styleStyleNode, CSSSheet *styleSheet)
+{
+    for (DFNode *styleStylChildNode = styleStyleNode->first; styleStylChildNode != NULL; styleStylChildNode = styleStylChildNode->next)
+    {
+        //switch on its tag
+        switch(styleStylChildNode->tag) {
+            case STYLE_TEXT_PROPERTIES: {
+                //figure out what we have..
+                styleTextPropsGet(styleStylChildNode, styleSheet);
+                break;
+            }
+            default: {
+                printf(RED "Ignoring Style:Style element %s\n", translateXMLEnumName[styleStylChildNode->tag], RESET);
+            }
+        }
+    }
+}
+
+static void OfficeStylesGet(DFNode *officStyles, CSSSheet *styleSheet)
+{
+    printf(CYAN "Processing office styles\n" RESET);
+    for (DFNode *officStylesNode = officStyles->first; officStylesNode != NULL; officStylesNode = officStylesNode->next)
+    {
+        //switch on its tag
+        switch(officStylesNode->tag){
+            case STYLE_STYLE: {
+                //figure out what we have..
+                styleStyleGet(officStylesNode, styleSheet);
+            }
+            break;
+            case STYLE_DEFAULT_STYLE: {
+                //not supported yet
+            }
+            default:
+            {
+                printf(RED "Ignoring Office:Style element %s\n", translateXMLEnumName[officStylesNode->tag], RESET);
+            }
+        }
+    }
+}
+
+ODFStyle *ODFStyleNew()
+{
+    ODFStyle *style = (ODFStyle *)xcalloc(1,sizeof(ODFStyle));
+    style->retainCount = 1;
+    return style;
+}
+
+ODFStyle *ODFStyleRetain(ODFStyle *style)
+{
+    if (style != NULL)
+        style->retainCount++;
+    return style;
+}
+
+void ODFStyleRelease(ODFStyle *style)
+{
+    if ((style == NULL) || (--style->retainCount > 0))
+        return;
+
+    free(style->selector);
+    free(style);
+}
+
+CSSSheet *ODFStylesGet(ODFConverter *converter)
+{
+    CSSSheet *styleSheet = CSSSheetNew();
+    CSSStyle *bodyStyle = CSSSheetLookupElement(styleSheet,"body",NULL,1,0);
+    CSSPut(CSSStyleRule(bodyStyle),"counter-reset","h1 h2 h3 h4 h5 h6 figure table");
+
+
+    DFNode *body = NULL;
+    body = DFCreateChildElement(converter->html->root, HTML_BODY);
+    converter->body = body;
+    DFNode *head = DFChildWithTag(converter->html->root,HTML_HEAD);
+    if (head == NULL) {
+        head = DFCreateElement(converter->html,HTML_HEAD);
+        DFNode *body = DFChildWithTag(converter->html->root,HTML_BODY);
+        converter->body = body;
+        DFInsertBefore(converter->html->root,head,body);
+    }
+
+    printf(RED
+    "============================================================\n"
+    "Process ODF style nodes prior to the traverseContent function\n"
+    "============================================================\n"
+    RESET);
+
+    printf(GREEN "Number of style nodes: %lu\n" RESET, (unsigned long)converter->package->stylesDoc->nodesCount);
+    //show_nodes(converter->package->stylesDoc->root, 0);
+
+    //walk through the nodes
+    // go to the office:styles can we find it?
+    //iterate each style:style
+    // make a css
+    // dip down to get its attributes
+    DFNode *odfNode = converter->package->stylesDoc->root;
+    printf("buildCSS_Styles\n");
+    printf("name = %s\n", translateXMLEnumName[odfNode->tag]);
+
+    DFNode *officStyles = DFChildWithTag(converter->package->stylesDoc->root,OFFICE_STYLES);
+    OfficeStylesGet(officStyles, styleSheet);
+    return styleSheet;
+}

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/formatting/ODFStyles.h
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/formatting/ODFStyles.h b/DocFormats/filters/odf/src/formatting/ODFStyles.h
new file mode 100644
index 0000000..da4f77a
--- /dev/null
+++ b/DocFormats/filters/odf/src/formatting/ODFStyles.h
@@ -0,0 +1,44 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+#pragma once
+
+#include <DocFormats/DFXMLForward.h>
+#include "DFTypes.h"
+#include "ODFConverter.h"
+#include "CSS.h"
+#include "CSSSheet.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                            ODFStyle                                            //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+typedef struct ODFStyle ODFStyle;
+
+struct ODFStyle {
+    size_t retainCount;
+    DFNode *element;
+    char *selector;
+};
+
+ODFStyle *ODFStyleNew();
+ODFStyle *ODFStyleRetain(ODFStyle *style);
+void ODFStyleRelease(ODFStyle *style);
+
+CSSSheet *ODFStylesGet(ODFConverter *converter);
+

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/lenses/ODFBody.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/lenses/ODFBody.c b/DocFormats/filters/odf/src/lenses/ODFBody.c
new file mode 100644
index 0000000..201e8ba
--- /dev/null
+++ b/DocFormats/filters/odf/src/lenses/ODFBody.c
@@ -0,0 +1,75 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "DFPlatform.h"
+#include "ODFLenses.h"
+#include "DFCommon.h"
+#include "DFDOM.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                          ODFBodylens                                          //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Not a standard lens because we switch to the correct lense
+ * from the first child
+ */
+static DFNode *ODFBodyGet(ODFGetData *get, DFNode *concrete)
+{
+    printf("ODFBodyGet\n");
+    DFNode *abstract = ODFConverterCreateAbstract(get,HTML_BODY,concrete);
+    //An office:body element contains the text,spreadsheet, or presenation
+    //elements (plus others we are not going to consider.
+    DFNode* docType = concrete->first;
+    switch (docType->tag) {
+        case OFFICE_TEXT:
+            ODFContainerGet(get,&ODFTextLens,abstract,concrete);
+            break;
+        case OFFICE_SPREADSHEET:
+            ODFContainerGet(get,&ODFSpreadsheetLens,abstract,concrete);
+            break;
+        case OFFICE_PRESENTATION:
+            ODFContainerGet(get,&ODFPresentationLens,abstract,concrete);
+            break;
+        default:
+            //Add a message to the html document to say document type not supported
+            break;
+    }
+
+    return abstract;
+}
+
+static void ODFBodyPut(ODFPutData *put, DFNode *abstract, DFNode *concrete)
+{
+    //ODFContainerPut(put,&ODFBlockLevelLens,abstract,concrete);
+}
+
+static void ODFBodyRemove(ODFPutData *put, DFNode *concrete)
+{
+    //for (DFNode *child = concrete->first; child != NULL; child = child->next)
+    //    ODFBlockLevelLens.remove(put,child);
+}
+
+ODFLens ODFBodyLens = {
+    .isVisible = NULL, // LENS FIXME
+    .get = ODFBodyGet,
+    .put = ODFBodyPut,
+    .create = NULL, // LENS FIXME
+    .remove = ODFBodyRemove,
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/lenses/ODFDocument.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/lenses/ODFDocument.c b/DocFormats/filters/odf/src/lenses/ODFDocument.c
new file mode 100644
index 0000000..d7378f9
--- /dev/null
+++ b/DocFormats/filters/odf/src/lenses/ODFDocument.c
@@ -0,0 +1,86 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "DFPlatform.h"
+#include "ODFLenses.h"
+#include "DFDOM.h"
+#include "DFCommon.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                        ODFDocumentLens                                        //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * The general pattern for a lens is
+ *      for the type of tag create the corresponding abstract DFNode
+ *      via call to ODFConverterCreateAbstract
+ *      eg TEXT_P -> HTML_P
+ *      then add attributes as required
+ *
+ *      call ODFContainerGet to walk down through the concrete tree
+ *      to build on the abstact DFNode
+ *
+ *      return the abstract DFNode
+ */
+
+
+/**
+ * Not a standard lens because we manually find the OFFICE_BODY
+ * and call its lens and append its node to the html node
+ */
+static DFNode *ODFDocumentGet(ODFGetData *get, DFNode *concrete)
+{
+    printf("ODFDocumentGet\n");
+    if (concrete->tag != OFFICE_DOCUMENT_CONTENT)
+        return NULL;;
+
+    DFNode *html = ODFConverterCreateAbstract(get,HTML_HTML,concrete);
+    DFNode *head = ODFConverterCreateAbstract(get,HTML_HEAD,NULL);
+    DFAppendChild(html,head);
+    DFNode *meta = ODFConverterCreateAbstract(get,HTML_META,NULL);
+    DFAppendChild(head,meta);
+    DFSetAttribute(meta,HTML_CHARSET,"utf-8");
+
+    //Find the OFFICE_BODY
+    DFNode *ODFBody = DFChildWithTag(concrete,OFFICE_BODY);
+    if (ODFBody != NULL) {
+        DFNode *htmlBody = ODFBodyLens.get(get,ODFBody);
+        DFAppendChild(html,htmlBody);
+    }
+    return html;
+}
+
+static void ODFDocumentPut(ODFPutData *put, DFNode *abstract, DFNode *concrete)
+{
+    if ((abstract->tag == HTML_HTML) && (concrete->tag == OFFICE_DOCUMENT_CONTENT)) {
+        DFNode *htmlBody = DFChildWithTag(abstract,HTML_BODY);
+        DFNode *ODFBody = DFChildWithTag(concrete,OFFICE_BODY);
+
+        if ((htmlBody != NULL) && (ODFBody != NULL))
+            ODFBodyLens.put(put,htmlBody,ODFBody);
+    }
+}
+
+ODFLens ODFDocumentLens = {
+    .isVisible = NULL, // LENS FIXME
+    .get = ODFDocumentGet,
+    .put = ODFDocumentPut,
+    .create = NULL, // LENS FIXME
+    .remove = NULL, // LENS FIXME
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/lenses/ODFHeader.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/lenses/ODFHeader.c b/DocFormats/filters/odf/src/lenses/ODFHeader.c
new file mode 100644
index 0000000..3315c7a
--- /dev/null
+++ b/DocFormats/filters/odf/src/lenses/ODFHeader.c
@@ -0,0 +1,110 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "DFPlatform.h"
+#include "ODFLenses.h"
+#include "DFHTML.h"
+#include "DFNameMap.h"
+#include "DFString.h"
+#include "DFCommon.h"
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include "text/gbg_test.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                        ODFHeaderLens                                       //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * We know we have a header - but need to work out which level
+ */
+
+static DFNode *ODFHeaderCreateAbstractNode(ODFGetData *get, DFNode *concrete)
+{
+    DFNode *abstract = NULL;
+    const char * styleName = DFGetAttribute(concrete,TEXT_STYLE_NAME);
+    const char * outlevel = DFGetAttribute(concrete,TEXT_OUTLINE_LEVEL);
+    if(outlevel != NULL) {
+        int s_val = atoi(&outlevel[strlen(outlevel)-1]);
+        if(s_val > 6) {
+            abstract = ODFConverterCreateAbstract(get, HTML_DIV, concrete);
+        } else {
+            abstract = ODFConverterCreateAbstract(get, HTML_H1 + s_val - 1, concrete);
+        }
+    } else { //no outline level assume 1
+        printf("Header with no ooutline level!!!\n");
+        abstract = ODFConverterCreateAbstract(get, HTML_H1, concrete);;
+    }
+    if(styleName != NULL) {
+        printf("Found style name %s\n", styleName);
+        DFSetAttribute(abstract, HTML_CLASS, styleName); //DFGetAttribute(odfNode,TEXT_STYLE_NAME));
+    }
+  return abstract;
+}
+
+/**
+ * For the moment just create an H1 tag
+ * and treat as a paragraph
+ */
+static DFNode *ODFHeaderGet(ODFGetData *get, DFNode *concrete)
+{
+    //DFNode *abstract = ODFConverterCreateAbstract(get,HTML_H1,concrete);
+    DFNode *abstract = ODFHeaderCreateAbstractNode(get, concrete);
+    ODFContainerGet(get,&ODFParagraphContentLens,abstract,concrete);
+    printf("Header tag %s\n", translateXMLEnumName[abstract->tag]);
+
+    return abstract;
+}
+
+static void ODFHeaderPut(ODFPutData *put, DFNode *abstract, DFNode *concrete)
+{
+    if (!HTML_isParagraphTag(abstract->tag) && (abstract->tag != HTML_FIGURE))
+        return;
+
+    if (concrete->tag != TEXT_P)
+        return;
+
+}
+
+static DFNode *ODFHeaderCreate(ODFPutData *put, DFNode *abstract)
+{
+    DFNode *concrete = DFCreateElement(put->contentDoc,TEXT_P);
+    ODFHeaderPut(put,abstract,concrete);
+    return concrete;
+}
+
+static int ODFHeaderIsVisible(ODFPutData *put, DFNode *concrete)
+{
+    return 1;
+}
+
+static void ODFHeaderRemove(ODFPutData *put, DFNode *concrete)
+{
+//    for (DFNode *child = concrete->first; child != NULL; child = child->next)
+//        ODFHeaderContentLens.remove(put,child);
+}
+
+ODFLens ODFHeaderLens = {
+    .isVisible = ODFHeaderIsVisible,
+    .get = ODFHeaderGet,
+    .put = ODFHeaderPut,
+    .create = ODFHeaderCreate,
+    .remove = ODFHeaderRemove,
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/lenses/ODFLenses.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/lenses/ODFLenses.c b/DocFormats/filters/odf/src/lenses/ODFLenses.c
new file mode 100644
index 0000000..b7039d6
--- /dev/null
+++ b/DocFormats/filters/odf/src/lenses/ODFLenses.c
@@ -0,0 +1,31 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "DFPlatform.h"
+#include "ODFLenses.h"
+#include "DFCommon.h"
+
+DFNode *ODFContainerGet(ODFGetData *get, ODFLens *childLens, DFNode *abstract, DFNode *concrete)
+{
+    return BDTContainerGet(get,(DFLens *)childLens,abstract,concrete);
+}
+
+void ODFContainerPut(ODFPutData *put, ODFLens *childLens, DFNode *abstract, DFNode *concrete)
+{
+    BDTContainerPut(put,(DFLens *)childLens,abstract,concrete,
+                    (DFLookupConcreteFunction)ODFConverterGetConcrete);
+}

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/lenses/ODFLenses.h
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/lenses/ODFLenses.h b/DocFormats/filters/odf/src/lenses/ODFLenses.h
new file mode 100644
index 0000000..426adc4
--- /dev/null
+++ b/DocFormats/filters/odf/src/lenses/ODFLenses.h
@@ -0,0 +1,55 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include "DFBDT.h"
+#include "ODFConverter.h"
+#include "OOXMLTypedefs.h"
+#include "text/color.h"
+#include <stdio.h>
+
+typedef struct {
+    int (*isVisible)(ODFPutData *put, DFNode *concrete);
+    DFNode *(*get)(ODFGetData *get, DFNode *concrete);
+    void (*put)(ODFPutData *put, DFNode *abstract, DFNode *concrete);
+    DFNode *(*create)(ODFPutData *put, DFNode *abstract);
+    void (*remove)(ODFPutData *put, DFNode *concrete);
+}ODFLens;
+
+/**
+ * Elements of interest at the top level of an ODF Content XML
+ * are the body, automatic styles.
+ *
+ * The body will then have the type of document text, spreadsheet
+ * or presentation.
+ *
+ */
+extern ODFLens ODFDocumentLens;
+extern ODFLens ODFContentLens;
+extern ODFLens ODFBodyLens;
+extern ODFLens ODFTextLens;
+extern ODFLens ODFTextLevelLens;
+extern ODFLens ODFSpreadsheetLens;
+extern ODFLens ODFPresentationLens;
+extern ODFLens ODFParagraphLens;
+extern ODFLens ODFHeaderLens;
+extern ODFLens ODFParagraphContentLens;
+
+DFNode *ODFContainerGet(ODFGetData *get, ODFLens *childLens, DFNode *abstract, DFNode *concrete);
+void ODFContainerPut(ODFPutData *put, ODFLens *childLens, DFNode *abstract, DFNode *concrete);
+

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/lenses/ODFParagraph.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/lenses/ODFParagraph.c b/DocFormats/filters/odf/src/lenses/ODFParagraph.c
new file mode 100644
index 0000000..e180556
--- /dev/null
+++ b/DocFormats/filters/odf/src/lenses/ODFParagraph.c
@@ -0,0 +1,96 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "DFPlatform.h"
+#include "ODFLenses.h"
+#include "DFHTML.h"
+#include "DFNameMap.h"
+#include "DFString.h"
+#include "DFCommon.h"
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                        ODFParagraphLens                                       //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static DFNode *ODFParagraphCreateAbstractNode(ODFGetData *get, DFNode *concrete)
+{
+    DFNode *abstract = NULL;
+    abstract = ODFConverterCreateAbstract(get, HTML_P, concrete);
+    const char * styleName = DFGetAttribute(concrete,TEXT_STYLE_NAME);
+    if(styleName != NULL) {
+        printf("Found style name %s\n", styleName);
+        DFSetAttribute(abstract, HTML_CLASS, styleName); //DFGetAttribute(odfNode,TEXT_STYLE_NAME));
+    }
+    return abstract;
+}
+
+/**
+ * Map to an HTML_P
+ * and treat as a paragraph
+ */
+static DFNode *ODFParagraphGet(ODFGetData *get, DFNode *concrete)
+{
+    printf("ODFParagraphGet look at the content\n");
+
+    //DFNode *abstract = ODFParagraphCreateAbstractNode(get,concrete);
+    DFNode *abstract = ODFParagraphCreateAbstractNode(get, concrete);
+    ODFContainerGet(get,&ODFParagraphContentLens,abstract,concrete);
+
+    return abstract;
+}
+
+static void ODFParagraphPut(ODFPutData *put, DFNode *abstract, DFNode *concrete)
+{
+    if (!HTML_isParagraphTag(abstract->tag) && (abstract->tag != HTML_FIGURE))
+        return;
+
+    if (concrete->tag != TEXT_P)
+        return;
+
+    ODFContainerPut(put,&ODFParagraphContentLens,abstract,concrete);
+}
+
+static DFNode *ODFParagraphCreate(ODFPutData *put, DFNode *abstract)
+{
+    DFNode *concrete = DFCreateElement(put->contentDoc,TEXT_P);
+    ODFParagraphPut(put,abstract,concrete);
+    return concrete;
+}
+
+static int ODFParagraphIsVisible(ODFPutData *put, DFNode *concrete)
+{
+    return 1;
+}
+
+static void ODFParagraphRemove(ODFPutData *put, DFNode *concrete)
+{
+    for (DFNode *child = concrete->first; child != NULL; child = child->next)
+        ODFParagraphContentLens.remove(put,child);
+}
+
+ODFLens ODFParagraphLens = {
+    .isVisible = ODFParagraphIsVisible,
+    .get = ODFParagraphGet,
+    .put = ODFParagraphPut,
+    .create = ODFParagraphCreate,
+    .remove = ODFParagraphRemove,
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/lenses/ODFParagraphContent.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/lenses/ODFParagraphContent.c b/DocFormats/filters/odf/src/lenses/ODFParagraphContent.c
new file mode 100644
index 0000000..76776b5
--- /dev/null
+++ b/DocFormats/filters/odf/src/lenses/ODFParagraphContent.c
@@ -0,0 +1,118 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "DFPlatform.h"
+#include "ODFLenses.h"
+#include "DFDOM.h"
+#include "DFString.h"
+#include "DFHTML.h"
+#include "DFCommon.h"
+#include <stdlib.h>
+#include "text/gbg_test.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                    ODFParagraphContentLens                                    //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static ODFLens *ODFParagraphContentLensForConcrete(ODFConverter *converter, DFNode *concrete)
+{
+/*        switch (concrete->tag) {
+        case ODF_R:
+            return &ODFRunLens;
+        case ODF_INS:
+        case ODF_DEL:
+        case ODF_MOVEFROM:
+        case ODF_MOVETO:
+            return &ODFChangeLens;
+        case ODF_FLDSIMPLE:
+            return &ODFFieldLens;
+        case ODF_BOOKMARK:
+            return &ODFBookmarkLens;
+        case ODF_HYPERLINK:
+            return &ODFHyperlinkLens;
+        case ODF_SMARTTAG:
+            return &ODFSmartTagLens;
+        default:
+            return NULL;
+    }*/
+    return NULL;
+}
+
+/**
+ * Could be a bunch of things here
+ * for moment just look for the text
+ */
+static DFNode *ODFParagraphContentGet(ODFGetData *get, DFNode *concrete)
+{
+    printf(CYAN "ODFParagraphContentGet\n" RESET);
+    printf("Tag %s\n", translateXMLEnumName[concrete->tag]);
+    if (concrete->tag == DOM_TEXT) { // we have some text
+        DFBuffer *buf = DFBufferNew();
+        DFNodeTextToBuffer(concrete,buf);
+        printf("Text %s\n", buf->data);
+        DFNode *abstract = DFCreateTextNode(get->conv->html,buf->data);
+        DFBufferRelease(buf);
+        return abstract;
+    }
+    else { //not text could be a bunch of things - get the correct lens
+/*        ODFLens *lens = ODFParagraphContentLensForConcrete(get->conv,concrete);
+        if ((lens != NULL) && (lens->get != NULL))
+            return lens->get(get,concrete);
+        else {
+            return NULL;
+        }*/
+        return NULL;
+    }
+}
+
+static int ODFParagraphContentIsVisible(ODFPutData *put, DFNode *concrete)
+{
+    ODFLens *lens = ODFParagraphContentLensForConcrete(put->conv,concrete);
+    if ((lens != NULL) && (lens->isVisible != NULL))
+        return lens->isVisible(put,concrete);
+    else
+        return 0;
+}
+
+static void ODFParagraphContentPut(ODFPutData *put, DFNode *abstract, DFNode *concrete)
+{
+    ODFLens *lens = ODFParagraphContentLensForConcrete(put->conv,concrete);
+    if ((lens != NULL) && (lens->put != NULL))
+        lens->put(put,abstract,concrete);
+}
+
+static void ODFParagraphContentRemove(ODFPutData *put, DFNode *concrete)
+{
+    ODFLens *lens = ODFParagraphContentLensForConcrete(put->conv,concrete);
+    if ((lens != NULL) && (lens->remove != NULL))
+        lens->remove(put,concrete);
+}
+
+static DFNode *ODFParagraphContentCreate(ODFPutData *put, DFNode *abstract)
+{
+    return NULL;
+}
+
+ODFLens ODFParagraphContentLens = {
+    .isVisible = ODFParagraphContentIsVisible,
+    .get = ODFParagraphContentGet,
+    .put = ODFParagraphContentPut,
+    .create = ODFParagraphContentCreate,
+    .remove = ODFParagraphContentRemove,
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/lenses/ODFPresentationLens.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/lenses/ODFPresentationLens.c b/DocFormats/filters/odf/src/lenses/ODFPresentationLens.c
new file mode 100644
index 0000000..42533df
--- /dev/null
+++ b/DocFormats/filters/odf/src/lenses/ODFPresentationLens.c
@@ -0,0 +1,73 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "DFPlatform.h"
+#include "WordLenses.h"
+#include "DFDOM.h"
+#include "DFCommon.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                       ODFPresentationLens                                       //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static DFNode *ODFPresentationGet(WordGetData *get, DFNode *concrete)
+{
+    switch (concrete->tag) {
+        default:
+            return NULL;
+    }
+}
+
+static int ODFPresentationIsVisible(WordPutData *put, DFNode *concrete)
+{
+    switch (concrete->tag) {
+        default:
+            return 0;
+    }
+}
+
+static void ODFPresentationPut(WordPutData *put, DFNode *abstract, DFNode *concrete)
+{
+    switch (concrete->tag) {
+        default:
+            break;
+    }
+}
+
+static void ODFPresentationRemove(WordPutData *put, DFNode *concrete)
+{
+    switch (concrete->tag) {
+        default:
+            break;
+    }
+}
+
+static DFNode *ODFPresentationCreate(WordPutData *put, DFNode *abstract)
+{
+    DFNode *concrete = NULL;
+    return concrete;
+}
+
+WordLens ODFPresentationLens = {
+    .isVisible = ODFPresentationIsVisible,
+    .get = ODFPresentationGet,
+    .put = ODFPresentationPut,
+    .create = ODFPresentationCreate,
+    .remove = ODFPresentationRemove,
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/lenses/ODFSpreadsheetLens.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/lenses/ODFSpreadsheetLens.c b/DocFormats/filters/odf/src/lenses/ODFSpreadsheetLens.c
new file mode 100644
index 0000000..1891b4a
--- /dev/null
+++ b/DocFormats/filters/odf/src/lenses/ODFSpreadsheetLens.c
@@ -0,0 +1,73 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "DFPlatform.h"
+#include "ODFLenses.h"
+#include "DFDOM.h"
+#include "DFCommon.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                       ODFSpreadsheetLens                                       //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static DFNode *ODFSpreadsheetGet(ODFGetData *get, DFNode *concrete)
+{
+    switch (concrete->tag) {
+        default:
+            return NULL;
+    }
+}
+
+static int ODFSpreadsheetIsVisible(ODFPutData *put, DFNode *concrete)
+{
+    switch (concrete->tag) {
+        default:
+            return 0;
+    }
+}
+
+static void ODFSpreadsheetPut(ODFPutData *put, DFNode *abstract, DFNode *concrete)
+{
+    switch (concrete->tag) {
+        default:
+            break;
+    }
+}
+
+static void ODFSpreadsheetRemove(ODFPutData *put, DFNode *concrete)
+{
+    switch (concrete->tag) {
+        default:
+            break;
+    }
+}
+
+static DFNode *ODFSpreadsheetCreate(ODFPutData *put, DFNode *abstract)
+{
+    DFNode *concrete = NULL;
+    return concrete;
+}
+
+ODFLens ODFSpreadsheetLens = {
+    .isVisible = ODFSpreadsheetIsVisible,
+    .get = ODFSpreadsheetGet,
+    .put = ODFSpreadsheetPut,
+    .create = ODFSpreadsheetCreate,
+    .remove = ODFSpreadsheetRemove,
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/lenses/ODFTextLens.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/lenses/ODFTextLens.c b/DocFormats/filters/odf/src/lenses/ODFTextLens.c
new file mode 100644
index 0000000..41e397b
--- /dev/null
+++ b/DocFormats/filters/odf/src/lenses/ODFTextLens.c
@@ -0,0 +1,102 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "DFPlatform.h"
+#include "ODFLenses.h"
+#include "DFDOM.h"
+#include "DFCommon.h"
+#include "text/gbg_test.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                       ODFTextLens                                       //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ *  There is no direct HTML to map to here. Just create a div
+ *  And maybe it can be styled with page attributes or something
+ */
+static DFNode *ODFTextGet(ODFGetData *get, DFNode *concrete)
+{
+    printf("ODFTextLensGet\n");
+    DFNode *abstract = ODFConverterCreateAbstract(get,HTML_DIV,concrete);
+    ODFContainerGet(get,&ODFTextLevelLens,abstract,concrete);
+    return abstract;
+}
+
+static int ODFTextIsVisible(ODFPutData *put, DFNode *concrete)
+{
+    switch (concrete->tag) {
+        case TEXT_P:
+            return ODFParagraphLens.isVisible(put,concrete);
+        case TEXT_H:
+            return ODFHeaderLens.isVisible(put,concrete);
+            //        case ODF_TBL:
+//            return ODFTableLens.isVisible(put,concrete);
+        default:
+            return 0;
+    }
+}
+
+static void ODFTextPut(ODFPutData *put, DFNode *abstract, DFNode *concrete)
+{
+    switch (concrete->tag) {
+        case TEXT_P:
+            ODFParagraphLens.put(put,abstract,concrete);
+            break;
+        case TEXT_H:
+            ODFHeaderLens.put(put,abstract,concrete);
+            break;
+        //case ODF_TBL:
+//            ODFTableLens.put(put,abstract,concrete);
+            break;
+        default:
+            break;
+    }
+}
+
+static void ODFTextRemove(ODFPutData *put, DFNode *concrete)
+{
+    switch (concrete->tag) {
+        case TEXT_P:
+            ODFParagraphLens.remove(put,concrete);
+            break;
+        case TEXT_H:
+            ODFHeaderLens.remove(put,concrete);
+            break;
+//        case ODF_TBL:
+//            ODFTableLens.remove(put,concrete);
+            break;
+        default:
+            break;
+    }
+}
+
+static DFNode *ODFTextCreate(ODFPutData *put, DFNode *abstract)
+{
+    DFNode *concrete = NULL;
+    return concrete;
+}
+
+ODFLens ODFTextLens = {
+    .isVisible = ODFTextIsVisible,
+    .get = ODFTextGet,
+    .put = ODFTextPut,
+    .create = ODFTextCreate,
+    .remove = ODFTextRemove,
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/lenses/ODFTextLevelLens.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/lenses/ODFTextLevelLens.c b/DocFormats/filters/odf/src/lenses/ODFTextLevelLens.c
new file mode 100644
index 0000000..1beb10b
--- /dev/null
+++ b/DocFormats/filters/odf/src/lenses/ODFTextLevelLens.c
@@ -0,0 +1,107 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "DFPlatform.h"
+#include "ODFLenses.h"
+#include "DFDOM.h"
+#include "DFCommon.h"
+#include "text/gbg_test.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                       ODFTextLens                                       //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Not a standard lens - we switch to the correct lens
+ * based on our tag value
+ */
+static DFNode *ODFTextLevelGet(ODFGetData *get, DFNode *concrete)
+{
+    printf(CYAN "ODFTextLevelLensGet\n" RESET);
+    printf("Tag %s\n", translateXMLEnumName[concrete->tag]);
+    switch (concrete->tag) {
+        case TEXT_P:
+            printf("ODFTextLevelGet found TEXT_P\n");
+            return ODFParagraphLens.get(get,concrete);
+        case TEXT_H:
+            printf("ODFTextLevelGet found TEXT_H\n");
+            return ODFHeaderLens.get(get,concrete);
+            //        case ODF_TBL:
+//            return ODFTableLens.get(get,concrete);
+        default:
+            printf("Tag %s\n", translateXMLEnumName[concrete->tag]);
+            return NULL;
+    }
+}
+
+static int ODFTextLevelIsVisible(ODFPutData *put, DFNode *concrete)
+{
+    switch (concrete->tag) {
+        case TEXT_P:
+            return ODFParagraphLens.isVisible(put,concrete);
+        case TEXT_H:
+            return ODFHeaderLens.isVisible(put,concrete);
+            //        case ODF_TBL:
+//            return ODFTableLens.isVisible(put,concrete);
+        default:
+            return 0;
+    }
+}
+
+static void ODFTextLevelPut(ODFPutData *put, DFNode *abstract, DFNode *concrete)
+{
+    switch (concrete->tag) {
+        case TEXT_P:
+            ODFParagraphLens.put(put,abstract,concrete);
+            break;
+        case TEXT_H:
+            ODFHeaderLens.put(put,abstract,concrete);
+            break;
+        default:
+            break;
+    }
+}
+
+static void ODFTextLevelRemove(ODFPutData *put, DFNode *concrete)
+{
+    switch (concrete->tag) {
+        case TEXT_P:
+            ODFParagraphLens.remove(put,concrete);
+            break;
+        case TEXT_H:
+            ODFHeaderLens.remove(put,concrete);
+            break;
+        default:
+            break;
+    }
+}
+
+static DFNode *ODFTextLevelCreate(ODFPutData *put, DFNode *abstract)
+{
+    DFNode *concrete = NULL;
+    return concrete;
+}
+
+ODFLens ODFTextLevelLens = {
+    .isVisible = ODFTextLevelIsVisible,
+    .get = ODFTextLevelGet,
+    .put = ODFTextLevelPut,
+    .create = ODFTextLevelCreate,
+    .remove = ODFTextLevelRemove,
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/text/ODFText.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/text/ODFText.c b/DocFormats/filters/odf/src/text/ODFText.c
index b122031..56cfbfc 100644
--- a/DocFormats/filters/odf/src/text/ODFText.c
+++ b/DocFormats/filters/odf/src/text/ODFText.c
@@ -31,15 +31,15 @@
 #include "gbg_test.h"
 #include "color.h"
 
-typedef struct {
+/*typedef struct {
     ODFTextConverter *conv;
     DFDocument *contentDoc;
     DFHashTable *numIdByHtmlId;
     DFHashTable *htmlIdByNumId;
-} ODFPutData;
+} ODFPutData;*/
 
 // I'm not sure what ODFTextConverter ise used here for.  
-static void traverseContent(ODFTextConverter *conv, DFNode *odfNode, DFNode *htmlNode)
+static void traverseContent(ODFConverter *conv, DFNode *odfNode, DFNode *htmlNode)
 {
     for (DFNode *odfChild = odfNode->first; odfChild != NULL; odfChild = odfChild->next) {
 
@@ -64,31 +64,32 @@ static void traverseContent(ODFTextConverter *conv, DFNode *odfNode, DFNode *htm
             else if (newTag == TAG_NOT_MATCHED) {  
                 // we find tag that we have not managed to match, but
                 // that is in find_HTML() already.
-
                 DFCreateChildTextNode(htmlNode, missing_tag_info(odfChild));
-                ;
             }
             else if (!newTag) {
                 ;  // we added an attribute node already in find_HTML (for now)
                 // DFNode *newChild =  DFCreateChildElement(htmlNode, newTag);
             }
             else {
-		
-                DFNode *node = DFCreateChildElement(htmlNode, HTML_DIV);
-		const char * styleName = DFGetAttribute(odfChild,TEXT_STYLE_NAME);
-		printf("Found style name %s\n", styleName);
-		DFSetAttribute(node, HTML_CLASS, styleName); //DFGetAttribute(odfNode,TEXT_STYLE_NAME));
-		for (DFNode *domChild = odfChild->first; domChild != NULL; domChild = domChild->next) 
-		{
-		  if (domChild->tag == DOM_TEXT) { // we have some text or a text modfier here.
-		    // DFNode *check = 
-		    DFCreateChildTextNode(node, domChild->value);
-		    printf(YELLOW "DOM_TEXT: %s \n" RESET,
-		    domChild->value
-		    );
-		  }
-		}
-           }
+                //what do we have here a header or a paragraph
+                DFNode *node = NULL;
+                const char * styleName = DFGetAttribute(odfChild,TEXT_STYLE_NAME);
+                const char * outlevel = DFGetAttribute(odfChild,TEXT_OUTLINE_LEVEL);
+                if(outlevel != NULL) {
+                    int s_val = atoi(&outlevel[strlen(outlevel)-1]) - 1;
+                    node = DFCreateChildElement(htmlNode, HTML_H1 + s_val);
+                } else {
+                    node = DFCreateChildElement(htmlNode, HTML_P);
+                }
+                printf("Found style name %s\n", styleName);
+                DFSetAttribute(node, HTML_CLASS, styleName); //DFGetAttribute(odfNode,TEXT_STYLE_NAME));
+                for (DFNode *domChild = odfChild->first; domChild != NULL; domChild = domChild->next) {
+                    if (domChild->tag == DOM_TEXT) { // we have some text or a text modfier here.
+                        DFCreateChildTextNode(node, domChild->value);
+                        printf(YELLOW "DOM_TEXT: %s \n" RESET, domChild->value);
+                    }
+                }
+            }
         }
         traverseContent(conv,odfChild,htmlNode);
     }
@@ -98,77 +99,50 @@ static void traverseContent(ODFTextConverter *conv, DFNode *odfNode, DFNode *htm
     // split it up into several functions
 }
 
-DFDocument *ODFTextGet(DFStorage *concreteStorage, DFStorage *abstractStorage, const char *idPrefix, DFError **error)
+DFDocument *ODFTextGet(ODFConverter *converter)
 {
-    int ok = 0;
-    DFDocument *html = NULL;
-    ODFPackage *package = NULL;
-    ODFTextConverter *conv = NULL;
-    DFNode *body = NULL;
-
-    package = ODFPackageOpenFrom(concreteStorage, error);
-    if (package == NULL)
-        goto end;
-
-    html = DFDocumentNewWithRoot(HTML_HTML);
-    body = DFCreateChildElement(html->root, HTML_BODY);
-    DFNode *head = DFChildWithTag(html->root,HTML_HEAD);
-    if (head == NULL) {
-        head = DFCreateElement(html,HTML_HEAD);
-        DFNode *body = DFChildWithTag(html->root,HTML_BODY);
-        DFInsertBefore(html->root,head,body);
-    }
-    conv = ODFTextConverterNew(html, abstractStorage, package, idPrefix);
+/*    print_line(2);
+    print_line(2);
+    print_line(2);
 
     printf(RED
            "============================================================\n"
-           "Process ODF style nodes prior to the traverseContent function\n"
+           "Showing ODF content nodes prior to the traverseContent function\n"
            "============================================================\n"
            RESET);
 
-    printf(GREEN "Number of style nodes: %lu\n" RESET, (unsigned long)package->stylesDoc->nodesCount);
-    show_nodes(package->stylesDoc->root, 0);
-    //we want to build up the CSS Stylesheet
-    CSSSheet * cssSheet = CSSSheetNew();
-    buildCSS_Styles(cssSheet, package->stylesDoc->root);
-    
-    printf(GREEN "CSS: %s\n" RESET, CSSSheetCopyCSSText(cssSheet));
-
-    
+    show_nodes(converter->package->contentDoc->root, 0);
     print_line(2);
     print_line(2);
     print_line(2);
 
+
     printf(YELLOW
            "============================================================\n"
            "Showing ODF content nodes prior to the traverseContent function\n"
            "============================================================\n"
            RESET);
 
-    show_nodes(package->contentDoc->root, 0);
+    show_nodes(converter->package->contentDoc->root, 0);
     print_line(2);
     print_line(2);
     print_line(2);
-    
+*/
 
     // TODO: Traverse the DOM tree of package->contentDoc, adding elements to the HTML document.
     // contentDoc is loaded from content.xml, and represents the most important information in
     // the document, i.e. the text, tables, lists, etc.
 
-    traverseContent(conv, package->contentDoc->root, body);
-    char *cssText = CSSSheetCopyCSSText(cssSheet);
-    HTMLAddInternalStyleSheet(conv->html, cssText);
-    HTML_safeIndent(conv->html->docNode,0);
+    traverseContent(converter, converter->package->contentDoc->root, converter->body);
     // uncomment to see the result. (spammy!)
-    printf(GREEN
+/*    printf(GREEN
            "============================================================\n"
            "Showing HTML nodes after the traverseContent function\n"
            "============================================================\n"
            RESET);
 
-    show_nodes(body, 0);
-
-
+    show_nodes(converter->body, 0);
+*/
     // TODO: Once this basic traversal is implemented and is capable of producing paragraphs,
     // tables, lists, and spans, add ids to the HTML elements as they are created. That is, set
     // the id attribute of each new HTML element to a string containing the idPrefix followed by
@@ -180,17 +154,6 @@ DFDocument *ODFTextGet(DFStorage *concreteStorage, DFStorage *abstractStorage, c
     //
     // See WordConverterCreateAbstract and WordConverterGetConcrete for how this is done in the
     // Word filter.
-
-    ok = 1;
-
- end:
-    ODFPackageRelease(package);
-    ODFTextConverterRelease(conv);
-    if (!ok) {
-        DFDocumentRelease(html);
-        return NULL;
-    }
-    return html;
 }
 
 int ODFTextPut(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocument *htmlDoc, const char *idPrefix, DFError **error)

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/text/ODFText.h
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/text/ODFText.h b/DocFormats/filters/odf/src/text/ODFText.h
index 996d930..a69779d 100644
--- a/DocFormats/filters/odf/src/text/ODFText.h
+++ b/DocFormats/filters/odf/src/text/ODFText.h
@@ -15,12 +15,17 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#pragma once
+#ifndef DocFormats_ODFText_h
+#define DocFormats_ODFText_h
 
 #include <DocFormats/DFError.h>
 #include <DocFormats/DFStorage.h>
 #include <DocFormats/DFXMLForward.h>
 
-DFDocument *ODFTextGet(DFStorage *concreteStorage, DFStorage *abstractStorage, const char *idPrefix, DFError **error);
+#include "ODFConverter.h"
+
+DFDocument *ODFTextGet(ODFConverter *converter);
 int ODFTextPut(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocument *htmlDoc, const char *idPrefix, DFError **error);
 int ODFTextCreate(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocument *htmlDoc, DFError **error);
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/92492106/DocFormats/filters/odf/src/text/ODFTextConverter.h
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/src/text/ODFTextConverter.h b/DocFormats/filters/odf/src/text/ODFTextConverter.h
index 524a4e9..ac4882c 100644
--- a/DocFormats/filters/odf/src/text/ODFTextConverter.h
+++ b/DocFormats/filters/odf/src/text/ODFTextConverter.h
@@ -20,6 +20,7 @@
 #include <DocFormats/DFStorage.h>
 #include "DFDOM.h"
 #include "ODFPackage.h"
+#include "lenses/ODFLenses.h"
 
 typedef struct ODFTextConverter ODFTextConverter;