You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@corinthia.apache.org by pm...@apache.org on 2015/01/11 08:15:01 UTC
[1/2] incubator-corinthia git commit: Word: Remove idPrefix parameter
Repository: incubator-corinthia
Updated Branches:
refs/heads/master 1706df12c -> 23837161e
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/master
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);
[2/2] incubator-corinthia git commit: ODF: Skeleton functions for
get/put/create
Posted by pm...@apache.org.
ODF: Skeleton functions for get/put/create
These match their counterparts in filters/ooxml/src/word/Word.c
Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/23837161
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/23837161
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/23837161
Branch: refs/heads/master
Commit: 23837161eaa9cf88b02451095604bb78d7514683
Parents: 2230024
Author: Peter Kelly <pe...@uxproductivity.com>
Authored: Sun Jan 11 14:04:43 2015 +0700
Committer: Peter Kelly <pe...@uxproductivity.com>
Committed: Sun Jan 11 14:04:43 2015 +0700
----------------------------------------------------------------------
DocFormats/api/CMakeLists.txt | 1 +
DocFormats/api/src/Operations.c | 10 ++++++++
DocFormats/filters/odf/CMakeLists.txt | 10 ++++++--
DocFormats/filters/odf/src/text/ODFText.c | 33 ++++++++++++++++++++++++++
DocFormats/filters/odf/src/text/ODFText.h | 26 ++++++++++++++++++++
5 files changed, 78 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/23837161/DocFormats/api/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/DocFormats/api/CMakeLists.txt b/DocFormats/api/CMakeLists.txt
index e0146ef..148be77 100644
--- a/DocFormats/api/CMakeLists.txt
+++ b/DocFormats/api/CMakeLists.txt
@@ -56,6 +56,7 @@ include_directories(../core/src/names)
include_directories(../core/src/xml)
include_directories(../filters/latex/src)
include_directories(../filters/odf/src)
+include_directories(../filters/odf/src/text)
include_directories(../filters/ooxml/src/common)
include_directories(../filters/ooxml/src/word)
include_directories(../filters/ooxml/src/word/formatting)
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/23837161/DocFormats/api/src/Operations.c
----------------------------------------------------------------------
diff --git a/DocFormats/api/src/Operations.c b/DocFormats/api/src/Operations.c
index 18575cd..3b4500f 100644
--- a/DocFormats/api/src/Operations.c
+++ b/DocFormats/api/src/Operations.c
@@ -18,6 +18,7 @@
#include "DFString.h"
#include <DocFormats/DFStorage.h>
#include "Word.h"
+#include "ODFText.h"
#include "DFHTML.h"
#include "DFDOM.h"
#include "DFXML.h"
@@ -153,6 +154,9 @@ int DFGet(DFConcreteDocument *concrete, DFAbstractDocument *abstract, DFError **
case DFFileFormatDocx:
htmlDoc = WordGet(concrete->storage,abstract->storage,error);
break;
+ case DFFileFormatOdt:
+ htmlDoc = ODFTextGet(concrete->storage,abstract->storage,error);
+ break;
default:
DFErrorFormat(error,"Unsupported file format");
break;
@@ -178,6 +182,9 @@ int DFPut(DFConcreteDocument *concreteDoc, DFAbstractDocument *abstractDoc, DFEr
case DFFileFormatDocx:
ok = WordPut(concreteDoc->storage,abstractDoc->storage,abstractDoc->htmlDoc,error);
break;
+ case DFFileFormatOdt:
+ ok = ODFTextPut(concreteDoc->storage,abstractDoc->storage,abstractDoc->htmlDoc,error);
+ break;
default:
DFErrorFormat(error,"Unsupported file format");
break;
@@ -197,6 +204,9 @@ int DFCreate(DFConcreteDocument *concreteDoc, DFAbstractDocument *abstractDoc, D
case DFFileFormatDocx:
ok = WordCreate(concreteDoc->storage,abstractDoc->storage,abstractDoc->htmlDoc,error);
break;
+ case DFFileFormatOdt:
+ ok = ODFTextCreate(concreteDoc->storage,abstractDoc->storage,abstractDoc->htmlDoc,error);
+ break;
default:
DFErrorFormat(error,"Unsupported file format");
break;
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/23837161/DocFormats/filters/odf/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/DocFormats/filters/odf/CMakeLists.txt b/DocFormats/filters/odf/CMakeLists.txt
index 7787ad6..b38a965 100644
--- a/DocFormats/filters/odf/CMakeLists.txt
+++ b/DocFormats/filters/odf/CMakeLists.txt
@@ -25,6 +25,10 @@ set(GroupSrc
src/ODFSheet.c
src/ODFSheet.h)
+set(GroupSrcText
+ src/text/ODFText.h
+ src/text/ODFText.c)
+
set(GroupTests
tests/ODFTests.c)
@@ -62,7 +66,9 @@ include_directories(../../unittest)
###
add_library(odf OBJECT
${GroupSrc}
+ ${GroupSrcText}
${GroupTests})
-source_group(src FILES ${GroupSrc})
-source_group(tests FILES ${GroupTests})
+source_group(src FILES ${GroupSrc})
+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/23837161/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
new file mode 100644
index 0000000..6986499
--- /dev/null
+++ b/DocFormats/filters/odf/src/text/ODFText.c
@@ -0,0 +1,33 @@
+// Copyright 2012-2014 UX Productivity Pty Ltd
+//
+// Licensed 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 "ODFText.h"
+
+DFDocument *ODFTextGet(DFStorage *concreteStorage, DFStorage *abstractStorage, DFError **error)
+{
+ DFErrorFormat(error,"ODFTextGet: Not yet implemented");
+ return NULL;
+}
+
+int ODFTextPut(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocument *htmlDoc, DFError **error)
+{
+ DFErrorFormat(error,"ODFTextPut: Not yet implemented");
+ return 0;
+}
+
+int ODFTextCreate(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocument *htmlDoc, DFError **error)
+{
+ DFErrorFormat(error,"ODFTextCreate: Not yet implemented");
+ return 0;
+}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/23837161/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
new file mode 100644
index 0000000..16f0e5a
--- /dev/null
+++ b/DocFormats/filters/odf/src/text/ODFText.h
@@ -0,0 +1,26 @@
+// Copyright 2012-2014 UX Productivity Pty Ltd
+//
+// Licensed 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.
+
+#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, DFError **error);
+int ODFTextPut(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocument *htmlDoc, DFError **error);
+int ODFTextCreate(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocument *htmlDoc, DFError **error);
+
+#endif