Return-Path: X-Original-To: apmail-corinthia-commits-archive@minotaur.apache.org Delivered-To: apmail-corinthia-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 49F2310712 for ; Fri, 13 Feb 2015 08:52:54 +0000 (UTC) Received: (qmail 38048 invoked by uid 500); 13 Feb 2015 08:52:54 -0000 Delivered-To: apmail-corinthia-commits-archive@corinthia.apache.org Received: (qmail 38029 invoked by uid 500); 13 Feb 2015 08:52:54 -0000 Mailing-List: contact commits-help@corinthia.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@corinthia.incubator.apache.org Delivered-To: mailing list commits@corinthia.incubator.apache.org Received: (qmail 38020 invoked by uid 99); 13 Feb 2015 08:52:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Feb 2015 08:52:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 13 Feb 2015 08:52:16 +0000 Received: (qmail 36445 invoked by uid 99); 13 Feb 2015 08:52:13 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Feb 2015 08:52:13 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4C0E9E08E3; Fri, 13 Feb 2015 08:52:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jani@apache.org To: commits@corinthia.incubator.apache.org Date: Fri, 13 Feb 2015 08:52:33 -0000 Message-Id: <19f29af75f7546da94b00aebc9ce5344@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [21/38] incubator-corinthia git commit: Word: Remove idPrefix parameter X-Virus-Checked: Checked by ClamAV on apache.org 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/experimentZip Commit: 2230024704d9acda7b4a705e6b9da9e0c6304803 Parents: 1706df1 Author: Peter Kelly Authored: Sun Jan 11 13:23:07 2015 +0700 Committer: Peter Kelly 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);