corinthia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmke...@apache.org
Subject [2/2] incubator-corinthia git commit: Word: Move WordConverter{Get, Put}2 code
Date Sun, 11 Jan 2015 06:14:40 GMT
Word: Move WordConverter{Get,Put}2 code

Previously, the functions WordConverterGet and WordConverterPut would
simply create a WordConverter object and then call through to the '2'
version of the same function.

Given that there's little in the way of error handling that needs to
happen in the latter, it makes sense to do it all in one function.


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

Branch: refs/heads/master
Commit: 1706df12c1de93580e427a409a79f669c0e71c99
Parents: bc6827f
Author: Peter Kelly <peter@uxproductivity.com>
Authored: Sun Jan 11 12:54:32 2015 +0700
Committer: Peter Kelly <peter@uxproductivity.com>
Committed: Sun Jan 11 12:55:57 2015 +0700

----------------------------------------------------------------------
 .../filters/ooxml/src/word/WordConverter.c      | 55 +++++++++-----------
 1 file changed, 24 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/1706df12/DocFormats/filters/ooxml/src/word/WordConverter.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/WordConverter.c b/DocFormats/filters/ooxml/src/word/WordConverter.c
index f649d26..7e8f2ca 100644
--- a/DocFormats/filters/ooxml/src/word/WordConverter.c
+++ b/DocFormats/filters/ooxml/src/word/WordConverter.c
@@ -674,21 +674,26 @@ DFNode *WordConverterGetConcrete(WordPutData *put, DFNode *abstract)
     return node;
 }
 
-static int WordConverterGet2(WordConverter *converter, DFError **error)
+int WordConverterGet(DFDocument *html, DFStorage *abstractStorage,
+                     const char *idPrefix, WordPackage *package,
+                     DFError **error)
 {
-    converter->haveFields = Word_simplifyFields(converter->package);
-    Word_mergeRuns(converter->package);
-    if (converter->package->document == NULL) {
+    if (package->document == NULL) {
         DFErrorFormat(error,"document.xml not found");
         return 0;
     }
 
-    DFNode *wordDocument = DFChildWithTag(converter->package->document->docNode,WORD_DOCUMENT);
+    DFNode *wordDocument = DFChildWithTag(package->document->docNode,WORD_DOCUMENT);
     if (wordDocument == NULL) {
         DFErrorFormat(error,"word:document not found");
         return 0;
     }
 
+    int haveFields = Word_simplifyFields(package);
+    Word_mergeRuns(package);
+
+    WordConverter *converter = WordConverterNew(html,abstractStorage,idPrefix,package);
+    converter->haveFields = haveFields;
     WordAddNbsps(converter->package->document);
     WordFixLists(converter);
 
@@ -711,20 +716,12 @@ static int WordConverterGet2(WordConverter *converter, DFError **error)
 
     HTML_safeIndent(converter->html->docNode,0);
 
+    int ok = 1;
     if (converter->warnings->len > 0) {
         DFErrorFormat(error,"%s",converter->warnings->data);
-        return 0;
+        ok = 0;
     }
 
-    return 1;
-}
-
-int WordConverterGet(DFDocument *html, DFStorage *abstractStorage,
-                     const char *idPrefix, WordPackage *package,
-                     DFError **error)
-{
-    WordConverter *converter = WordConverterNew(html,abstractStorage,idPrefix,package);
-    int ok = WordConverterGet2(converter,error);
     WordConverterFree(converter);
     return ok;
 }
@@ -813,22 +810,26 @@ static void addMissingDefaultStyles(WordConverter *converter)
     }
 }
 
-static int WordConverterPut2(WordConverter *converter, DFError **error)
+int WordConverterPut(DFDocument *html, DFStorage *abstractStorage,
+                     const char *idPrefix, WordPackage *package,
+                     DFError **error)
 {
-    HTML_normalizeDocument(converter->html);
-    HTML_pushDownInlineProperties(converter->html->docNode);
-
-    if (converter->package->document == NULL) {
+    if (package->document == NULL) {
         DFErrorFormat(error,"document.xml not found");
         return 0;
     }
 
-    DFNode *wordDocument = DFChildWithTag(converter->package->document->docNode,WORD_DOCUMENT);
+    DFNode *wordDocument = DFChildWithTag(package->document->docNode,WORD_DOCUMENT);
     if (wordDocument == NULL) {
         DFErrorFormat(error,"word:document not found");
         return 0;
     }
 
+    HTML_normalizeDocument(html);
+    HTML_pushDownInlineProperties(html->docNode);
+
+    WordConverter *converter = WordConverterNew(html,abstractStorage,idPrefix,package);
+
     // FIXME: Need a more reliable way of telling whether this is a new document or not -
it could be that the
     // document already existed (with styles set up) but did not have any content
     DFNode *wordBody = DFChildWithTag(wordDocument,WORD_BODY);
@@ -906,20 +907,12 @@ static int WordConverterPut2(WordConverter *converter, DFError **error)
     DFHashTableRelease(put.numIdByHtmlId);
     DFHashTableRelease(put.htmlIdByNumId);
 
+    int ok = 1;
     if (converter->warnings->len > 0) {
         DFErrorFormat(error,"%s",converter->warnings->data);
-        return 0;
+        ok = 0;
     }
 
-    return 1;
-}
-
-int WordConverterPut(DFDocument *html, DFStorage *abstractStorage,
-                     const char *idPrefix, WordPackage *package,
-                     DFError **error)
-{
-    WordConverter *converter = WordConverterNew(html,abstractStorage,idPrefix,package);
-    int ok = WordConverterPut2(converter,error);
     WordConverterFree(converter);
     return ok;
 }


Mime
View raw message