Commit bda99a2b authored by Jos van den Oever's avatar Jos van den Oever

Also put rng files in the history.

parent bd95e278
This diff is collapsed.
......@@ -2,8 +2,10 @@ package odf;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.CopyOption;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
......@@ -54,13 +56,19 @@ public class OdfHistory {
}
for (OdfHistoryEntry file : files) {
Path zip = repoDir.resolve("odt").resolve(file.path);
Path dir = repoDir.resolve(file.dir);
// remove files from a previous commit
if (Files.exists(dir)) {
Utils.removeRecursive(dir);
final Path odtpath = repoDir.resolve("odt").resolve(file.path);
if (file.dir != null) {
Path dir = repoDir.resolve(file.dir);
// remove files from a previous commit if there
if (Files.exists(dir)) {
Utils.removeRecursive(dir);
}
Unzip.unzip(odtpath, dir);
} else {
final Path target = repoDir.resolve(file.target);
Files.createDirectories(target.getParent());
Files.copy(odtpath, target, StandardCopyOption.REPLACE_EXISTING);
}
Unzip.unzip(zip, dir);
Utils.cmd(repoDir, "git", "add", "-A");
Utils.cmd(repoDir, "git", "commit", "-m", file.path + " "
......
......@@ -9,6 +9,7 @@ import java.util.Set;
import javax.xml.transform.TransformerException;
import org.eclipse.jdt.annotation.Nullable;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
......@@ -33,17 +34,20 @@ public class OdfHistoryParser {
.elementIterator(doc,
"/office:document/office:body/office:spreadsheet/table:table/table:table-row");
for (Element row : rows) {
String path = getCellText(row, 1);
String dir = getCellText(row, 2);
String date = getCellText(row, 3);
if ("".equals(path) || "".equals(dir) || "".equals(date)) {
final String path = getCellText(row, 1);
final String dir = getCellText(row, 2);
final String date = getCellText(row, 3);
final String target = getCellText(row, 4);
if ("".equals(path) || ("".equals(dir) && "".equals(target))
|| "".equals(date)) {
continue;
}
if (paths.contains(path)) {
throw new IOException("The path " + path + " occurs twice.");
}
paths.add(path);
files.add(new OdfHistoryEntry(path, dir,date));
files.add(new OdfHistoryEntry(path, dir.length() == 0 ? null : dir,
date, target.length() == 0 ? null : target));
}
return files;
}
......@@ -57,12 +61,17 @@ public class OdfHistoryParser {
class OdfHistoryEntry {
final String path;
@Nullable
final String dir;
@Nullable
final String target;
final String date;
OdfHistoryEntry(String path, String dir, String date) {
OdfHistoryEntry(String path, @Nullable String dir, String date,
@Nullable String target) {
this.path = path;
this.dir = dir;
this.date = date;
this.target = target;
}
}
\ No newline at end of file
......@@ -95,7 +95,7 @@ public class OdfInfo {
errorHandler);
return driver11;
} else {
driver11 = load("src/rng/OpenDocument-schema-v1.1.rng",
driver11 = load("src/rng/OpenDocument-schema-v1.1-errata01-complete.rng",
errorHandler);
return driver11;
}
......
......@@ -17,7 +17,6 @@ class PrettyPrinter implements XMLStreamWriter {
final private HashSet<QName> elementsWithNoText;
PrettyPrinter(XMLStreamWriter out, HashSet<QName> elementsWithNoText) {
System.err.println(elementsWithNoText.size());
this.out = out;
this.elementsWithNoText = elementsWithNoText;
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
OASIS OpenDocument v1.1
OASIS Standard, 1 Feb 2007
Relax-NG Schema
$Id$
© 2002-2007 OASIS Open
© 1999-2007 Sun Microsystems, Inc.
-->
Open Document Format for Office Applications (OpenDocument) v1.1
OASIS Standard incorporating Approved Errata 01
22 July 2013
Copyright (c) OASIS Open 2013. All Rights Reserved.
Source: http://docs.oasis-open.org/office/v1.1/errata01/os/
-->
<!--
This is an adaptation of OpenDocument-schema-v1.1.rng that reflects the changes
made to the schema in accordance with OpenDocument v1.1 Errata 01.
The original is retained in the package for comparison purposes.
-->
<grammar
xmlns="http://relaxng.org/ns/structure/1.0"
......@@ -789,22 +795,22 @@
</attribute>
</optional>
<optional>
<attribute name="frame-count">
<attribute name="meta:frame-count">
<ref name="nonNegativeInteger"/>
</attribute>
</optional>
<optional>
<attribute name="sentence-count">
<attribute name="meta:sentence-count">
<ref name="nonNegativeInteger"/>
</attribute>
</optional>
<optional>
<attribute name="syllable-count">
<attribute name="meta:syllable-count">
<ref name="nonNegativeInteger"/>
</attribute>
</optional>
<optional>
<attribute name="non-whitespace-character-count">
<attribute name="meta:non-whitespace-character-count">
<ref name="nonNegativeInteger"/>
</attribute>
</optional>
......@@ -11516,11 +11522,11 @@
<attribute name="text:style-name">
<ref name="styleNameRef"/>
</attribute>
<attribute name="text:paragraph-style-name">
<optional>
<optional>
<attribute name="text:paragraph-style-name">
<ref name="styleNameRef"/>
</optional>
</attribute>
</attribute>
</optional>
</define>
<define name="style-font-face">
<element name="style:font-face">
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
OASIS OpenDocument v1.1
OASIS Standard, 1 Feb 2007
Strict Relax-NG Schema
$Id$
© 2002-2007 OASIS Open
© 1999-2007 Sun Microsystems, Inc.
Open Document Format for Office Applications (OpenDocument) v1.1
OASIS Standard incorporating Approved Errata 01
22 July 2013
Copyright (c) OASIS Open 2013. All Rights Reserved.
Source: http://docs.oasis-open.org/office/v1.1/errata01/os/
-->
<!--
This is a modification of OpenDocument-strict-schema-v1.1.rng that links to
OpenDocument-schema-v1.1-errata01-complete.rng instead of the file
OpenDocument-schema-v1.1.rng. The original is retained in the package
for comparison purposes.
-->
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<include href="OpenDocument-schema-v1.1.rng">
<include href="OpenDocument-schema-v1.1-errata01-complete.rng">
<define name="office-meta-content">
<ref name="office-meta-content-strict"/>
</define>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment