You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@corinthia.apache.org by ja...@apache.org on 2015/02/13 09:21:50 UTC
[21/33] incubator-corinthia git commit: Word: Remove idPrefix
parameter
Word: Remove idPrefix parameter
It used to be that code using the DocFormats library would supply a
prefix to be used on all id attributes in the HTML file which were used
to maintain a mapping back to the elements in the original document.
The reason for this was that in UX Write, if you copied & pasted from
one word document to another, the HTML code would be pasted as-is, and
this could result in incorrect mappings being stored in the destination
file.
UX Write handles this differently now (can't remember the details; it
was a long time ago I made the change), and for a long time we've been
using the fixed prefix of "word" for all id attributes. So we don't need
that as a parameter to the conversion functions.
Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/22300247
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/22300247
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/22300247
Branch: refs/heads/experiment64
Commit: 2230024704d9acda7b4a705e6b9da9e0c6304803
Parents: 1706df1
Author: Peter Kelly <pe...@uxproductivity.com>
Authored: Sun Jan 11 13:23:07 2015 +0700
Committer: Peter Kelly <pe...@uxproductivity.com>
Committed: Sun Jan 11 13:23:07 2015 +0700
----------------------------------------------------------------------
DocFormats/filters/ooxml/src/word/Word.c | 18 +++++++-----------
DocFormats/filters/ooxml/src/word/WordConverter.c | 17 ++++++-----------
DocFormats/filters/ooxml/src/word/WordConverter.h | 8 ++------
3 files changed, 15 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/22300247/DocFormats/filters/ooxml/src/word/Word.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/Word.c b/DocFormats/filters/ooxml/src/word/Word.c
index 1e06448..4f8dd31 100644
--- a/DocFormats/filters/ooxml/src/word/Word.c
+++ b/DocFormats/filters/ooxml/src/word/Word.c
@@ -34,7 +34,7 @@ DFDocument *WordGet(DFStorage *concreteStorage, DFStorage *abstractStorage, DFEr
goto end;
htmlDoc = DFDocumentNew();
- if (!WordConverterGet(htmlDoc,abstractStorage,"word",wordPackage,error))
+ if (!WordConverterGet(htmlDoc,abstractStorage,wordPackage,error))
goto end;
ok = 1;
@@ -55,13 +55,11 @@ int WordPut(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocument *
int ok = 0;
WordPackage *wordPackage = NULL;
- const char *idPrefix = "word";
-
wordPackage = WordPackageOpenFrom(concreteStorage,error);
if (wordPackage == NULL)
goto end;
- if (!WordConverterPut(htmlDoc,abstractStorage,idPrefix,wordPackage,error))
+ if (!WordConverterPut(htmlDoc,abstractStorage,wordPackage,error))
goto end;
if (!WordPackageSave(wordPackage,error))
@@ -79,19 +77,17 @@ int WordCreate(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocumen
int ok = 0;
WordPackage *wordPackage = NULL;
- const char *idPrefix = "word";
-
wordPackage = WordPackageOpenNew(concreteStorage,error);
if (wordPackage == NULL)
goto end;
- // Change any id attributes starting with "word" or "odf" to a different prefix, so they
+ // Change any id attributes starting with "word" to a different prefix, so they
// are not treated as references to nodes in the destination document. This is necessary
- // if the HTML file was previously generated from a word or odf file, and we are creating
- // a new word or odf file from it.
- HTMLBreakBDTRefs(htmlDoc->docNode,idPrefix);
+ // if the HTML file was previously generated from a word file, and we are creating
+ // a new word file from it.
+ HTMLBreakBDTRefs(htmlDoc->docNode,"word");
- if (!WordConverterPut(htmlDoc,abstractStorage,idPrefix,wordPackage,error))
+ if (!WordConverterPut(htmlDoc,abstractStorage,wordPackage,error))
goto end;
if (!WordPackageSave(wordPackage,error))
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/22300247/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 7e8f2ca..0e823bb 100644
--- a/DocFormats/filters/ooxml/src/word/WordConverter.c
+++ b/DocFormats/filters/ooxml/src/word/WordConverter.c
@@ -557,14 +557,13 @@ static void Word_postProcessHTMLDoc(WordConverter *conv)
// //
////////////////////////////////////////////////////////////////////////////////////////////////////
-static WordConverter *WordConverterNew(DFDocument *html, DFStorage *abstractStorage,
- const char *idPrefix, WordPackage *package)
+static WordConverter *WordConverterNew(DFDocument *html, DFStorage *abstractStorage, WordPackage *package)
{
WordConverter *converter = (WordConverter *)calloc(1,sizeof(WordConverter));
converter->html = DFDocumentRetain(html);
converter->abstractStorage = DFStorageRetain(abstractStorage);
assert(DFStorageFormat(converter->abstractStorage) == DFFileFormatHTML);
- converter->idPrefix = DFStrDup(idPrefix);
+ converter->idPrefix = strdup("word");
converter->package = WordPackageRetain(package);
converter->styles = WordSheetNew(converter->package->styles);
converter->numbering = WordNumberingNew(converter->package);
@@ -674,9 +673,7 @@ DFNode *WordConverterGetConcrete(WordPutData *put, DFNode *abstract)
return node;
}
-int WordConverterGet(DFDocument *html, DFStorage *abstractStorage,
- const char *idPrefix, WordPackage *package,
- DFError **error)
+int WordConverterGet(DFDocument *html, DFStorage *abstractStorage, WordPackage *package, DFError **error)
{
if (package->document == NULL) {
DFErrorFormat(error,"document.xml not found");
@@ -692,7 +689,7 @@ int WordConverterGet(DFDocument *html, DFStorage *abstractStorage,
int haveFields = Word_simplifyFields(package);
Word_mergeRuns(package);
- WordConverter *converter = WordConverterNew(html,abstractStorage,idPrefix,package);
+ WordConverter *converter = WordConverterNew(html,abstractStorage,package);
converter->haveFields = haveFields;
WordAddNbsps(converter->package->document);
WordFixLists(converter);
@@ -810,9 +807,7 @@ static void addMissingDefaultStyles(WordConverter *converter)
}
}
-int WordConverterPut(DFDocument *html, DFStorage *abstractStorage,
- const char *idPrefix, WordPackage *package,
- DFError **error)
+int WordConverterPut(DFDocument *html, DFStorage *abstractStorage, WordPackage *package, DFError **error)
{
if (package->document == NULL) {
DFErrorFormat(error,"document.xml not found");
@@ -828,7 +823,7 @@ int WordConverterPut(DFDocument *html, DFStorage *abstractStorage,
HTML_normalizeDocument(html);
HTML_pushDownInlineProperties(html->docNode);
- WordConverter *converter = WordConverterNew(html,abstractStorage,idPrefix,package);
+ WordConverter *converter = WordConverterNew(html,abstractStorage,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
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/22300247/DocFormats/filters/ooxml/src/word/WordConverter.h
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/WordConverter.h b/DocFormats/filters/ooxml/src/word/WordConverter.h
index c0565f2..5451540 100644
--- a/DocFormats/filters/ooxml/src/word/WordConverter.h
+++ b/DocFormats/filters/ooxml/src/word/WordConverter.h
@@ -98,12 +98,8 @@ struct WordConverter {
CSSSheet *styleSheet;
};
-int WordConverterGet(DFDocument *html, DFStorage *abstractStorage,
- const char *idPrefix, WordPackage *package,
- DFError **error);
-int WordConverterPut(DFDocument *html, DFStorage *abstractStorage,
- const char *idPrefix, WordPackage *package,
- DFError **error);
+int WordConverterGet(DFDocument *html, DFStorage *abstractStorage, WordPackage *package, DFError **error);
+int WordConverterPut(DFDocument *html, DFStorage *abstractStorage, WordPackage *package, DFError **error);
void WordConverterWarning(WordConverter *converter, const char *format, ...) ATTRIBUTE_FORMAT(printf,2,3);
char *WordStyleIdForStyle(CSSStyle *style);