corinthia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmke...@apache.org
Subject [12/14] incubator-corinthia git commit: dfutil: Fix pretty-printing option (-pp)
Date Sat, 10 Jan 2015 18:21:24 GMT
dfutil: Fix pretty-printing option (-pp)

Word_toPlainFromDir was incorrectly interpreting relative path names in
OPC relationship files for word documents. Instead of calculating the
path relative to the root of the package, it would use the path relative
to the location of the document.xml file.

This was causing the pretty-printing routine to encounter an error when
looking for files like styles.xml, because it would check for them in
the root of the package, rather than the directory in which they were
located (usually /word).


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

Branch: refs/heads/stable
Commit: cd6ccd0e7625384733db58d92dca7a87249d1247
Parents: cc208a6
Author: Peter Kelly <peter@uxproductivity.com>
Authored: Sun Jan 11 01:10:58 2015 +0700
Committer: Peter Kelly <peter@uxproductivity.com>
Committed: Sun Jan 11 01:10:58 2015 +0700

----------------------------------------------------------------------
 DocFormats/filters/ooxml/tests/word/WordPlain.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/cd6ccd0e/DocFormats/filters/ooxml/tests/word/WordPlain.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/tests/word/WordPlain.c b/DocFormats/filters/ooxml/tests/word/WordPlain.c
index ffbbe8a..b1f4d4b 100644
--- a/DocFormats/filters/ooxml/tests/word/WordPlain.c
+++ b/DocFormats/filters/ooxml/tests/word/WordPlain.c
@@ -107,10 +107,12 @@ static char *computeDocumentRelsPath(const char *documentPath)
     return documentRelsPath;
 }
 
-static void parseDocumentRels(DFDocument *relsDoc, DFHashTable *rels, DFError **error)
+static void parseDocumentRels(const char *documentPath, DFDocument *relsDoc, DFHashTable
*rels, DFError **error)
 {
     if (relsDoc == NULL)
         return;
+    const char *basePrefix = (documentPath[0] == '/') ? "" : "/";
+    char *basePath = DFFormatString("%s%s",basePrefix,documentPath);
     for (DFNode *child = relsDoc->root->first; child != NULL; child = child->next)
{
         if (child->tag != REL_RELATIONSHIP)
             continue;
@@ -119,8 +121,11 @@ static void parseDocumentRels(DFDocument *relsDoc, DFHashTable *rels,
DFError **
         if ((type == NULL) || (target == NULL))
             continue;
 
-        DFHashTableAdd(rels,type,target);
+        char *absTarget = DFPathResolveAbsolute(basePath,target);
+        DFHashTableAdd(rels,type,absTarget);
+        free(absTarget);
     }
+    free(basePath);
 }
 
 static int addRelatedDoc(DFHashTable *parts, DFHashTable *documentRels, const char *relName,
const char *filename,
@@ -257,7 +262,7 @@ static char *Word_toPlainFromDir(DFStorage *storage, DFHashTable *parts,
DFError
         goto end;
     }
 
-    parseDocumentRels(relsDoc,rels,error);
+    parseDocumentRels(documentPath,relsDoc,rels,error);
 
     if (!processParts(parts,documentPath,relsDoc,rels,output,storage,error))
         goto end;


Mime
View raw message