Skip to content

Commit

Permalink
Support mc:alternateContent in Workbook part
Browse files Browse the repository at this point in the history
  • Loading branch information
plutext committed Jun 24, 2019
1 parent 57eeab1 commit 1e5478a
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 8 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,37 @@ CHANGELOG
=========


Version 8.1.1
=============

Release date
------------

[ ] June 2019


Contributors to this release
----------------------------

Jason Harrop


Notable Changes in Version 8.1.1
---------------------------------

Bugfix: specify UTF-8 in MainDocumentPartFilterOutputStream


xlsx4j
------

Bugfix: Correct jcSML spreadsheetDrawing package name

Support mc:alternateContent in Workbook part (ie instead of dropping it)




Version 8.1.0
=============

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,11 @@ public static String getPreferredPrefixStatic(String namespaceUri, String sugges
if (namespaceUri.equals("http://schemas.microsoft.com/office/powerpoint/2016/6/main")) {
return "p166";
}


if (namespaceUri.equals("http://schemas.microsoft.com/office/spreadsheetml/2010/11/main")) {
return "x15";
}

return suggestion;
}

Expand Down Expand Up @@ -766,6 +770,10 @@ else if (prefix.equals("xs"))
if (prefix.equals("p166"))
return "http://schemas.microsoft.com/office/powerpoint/2016/6/main";

if (prefix.equals("x15"))
return "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";


// Registered prefixes
String result = namespaces.get(prefix);
if (result==null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import org.docx4j.jaxb.McIgnorableNamespaceDeclarator;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.exceptions.InvalidFormatException;
import org.docx4j.openpackaging.parts.Part;
Expand Down Expand Up @@ -40,6 +41,19 @@ public void init() {

}

@Override
protected void setMceIgnorable(McIgnorableNamespaceDeclarator namespacePrefixMapper) {

namespacePrefixMapper.setMcIgnorable(
this.getJaxbElement().getIgnorable() );
}

@Override
public String getMceIgnorable() {
return this.getJaxbElement().getIgnorable();
}


public SharedStrings getSharedStrings() {
return sharedStrings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import org.docx4j.mce.AlternateContent;
import org.docx4j.sharedtypes.STConformanceClass;
import org.jvnet.jaxb2_commons.ppp.Child;

Expand All @@ -46,6 +47,7 @@
* <element name="fileVersion" type="{http://schemas.openxmlformats.org/spreadsheetml/2006/main}CT_FileVersion" minOccurs="0"/>
* <element name="fileSharing" type="{http://schemas.openxmlformats.org/spreadsheetml/2006/main}CT_FileSharing" minOccurs="0"/>
* <element name="workbookPr" type="{http://schemas.openxmlformats.org/spreadsheetml/2006/main}CT_WorkbookPr" minOccurs="0"/>
* <element ref="{http://schemas.openxmlformats.org/markup-compatibility/2006}AlternateContent"/>
* <element name="workbookProtection" type="{http://schemas.openxmlformats.org/spreadsheetml/2006/main}CT_WorkbookProtection" minOccurs="0"/>
* <element name="bookViews" type="{http://schemas.openxmlformats.org/spreadsheetml/2006/main}CT_BookViews" minOccurs="0"/>
* <element name="sheets" type="{http://schemas.openxmlformats.org/spreadsheetml/2006/main}CT_Sheets"/>
Expand All @@ -64,6 +66,7 @@
* <element name="extLst" type="{http://schemas.openxmlformats.org/spreadsheetml/2006/main}CT_ExtensionList" minOccurs="0"/>
* </sequence>
* <attribute name="conformance" type="{http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes}ST_ConformanceClass" />
* <attribute ref="{http://schemas.openxmlformats.org/markup-compatibility/2006}Ignorable"/>
* </restriction>
* </complexContent>
* </complexType>
Expand All @@ -76,6 +79,7 @@
"fileVersion",
"fileSharing",
"workbookPr",
"alternateContent",
"workbookProtection",
"bookViews",
"sheets",
Expand All @@ -100,6 +104,8 @@ public class Workbook implements Child
protected FileVersion fileVersion;
protected CTFileSharing fileSharing;
protected WorkbookPr workbookPr;
@XmlElement(name = "AlternateContent", namespace = "http://schemas.openxmlformats.org/markup-compatibility/2006", required = true)
protected AlternateContent alternateContent;
protected CTWorkbookProtection workbookProtection;
protected BookViews bookViews;
@XmlElement(required = true)
Expand All @@ -119,6 +125,8 @@ public class Workbook implements Child
protected CTExtensionList extLst;
@XmlAttribute(name = "conformance")
protected STConformanceClass conformance;
@XmlAttribute(name = "Ignorable", namespace = "http://schemas.openxmlformats.org/markup-compatibility/2006")
protected String ignorable;
@XmlTransient
private Object parent;

Expand Down Expand Up @@ -194,6 +202,30 @@ public void setWorkbookPr(WorkbookPr value) {
this.workbookPr = value;
}

/**
* Gets the value of the alternateContent property.
*
* @return
* possible object is
* {@link AlternateContent }
*
*/
public AlternateContent getAlternateContent() {
return alternateContent;
}

/**
* Sets the value of the alternateContent property.
*
* @param value
* allowed object is
* {@link AlternateContent }
*
*/
public void setAlternateContent(AlternateContent value) {
this.alternateContent = value;
}

/**
* Gets the value of the workbookProtection property.
*
Expand Down Expand Up @@ -607,6 +639,30 @@ public void setConformance(STConformanceClass value) {
this.conformance = value;
}

/**
* Gets the value of the ignorable property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getIgnorable() {
return ignorable;
}

/**
* Sets the value of the ignorable property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setIgnorable(String value) {
this.ignorable = value;
}

/**
* Gets the parent object in the object tree representing the unmarshalled xml document.
*
Expand Down
42 changes: 36 additions & 6 deletions xsd/sml/sml_ECMA376_4ed_transitional.xsd
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
xmlns:s="http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes"
targetNamespace="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
elementFormDefault="qualified"
xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
xmlns:s="http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes"
targetNamespace="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
elementFormDefault="qualified"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:version="2.1">

Expand Down Expand Up @@ -37,6 +38,10 @@
<xsd:import
namespace="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
schemaLocation="../dml/dml-spreadsheetDrawing.xsd"/>

<!-- since docx4j 8.1.1 -->
<xsd:import id="mce" namespace="http://schemas.openxmlformats.org/markup-compatibility/2006"
schemaLocation="../mce/markup-compatibility-2006-MINIMAL.xsd"/>

<xsd:complexType name="CT_Xstring_Whitespace">
<xsd:annotation>
Expand Down Expand Up @@ -4202,6 +4207,30 @@
<xsd:element name="fileVersion" type="CT_FileVersion" minOccurs="0" maxOccurs="1"/>
<xsd:element name="fileSharing" type="CT_FileSharing" minOccurs="0" maxOccurs="1"/>
<xsd:element name="workbookPr" type="CT_WorkbookPr" minOccurs="0" maxOccurs="1"/>

<!--
<workbookPr/>
<mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
<mc:Choice Requires="x15">
<x15ac:absPath url="X:\materna\" xmlns:x15ac="http://schemas.microsoft.com/office/spreadsheetml/2010/11/ac"/>
</mc:Choice>
</mc:AlternateContent>
<xr:revisionPtr revIDLastSave="0" documentId="8_{65A72AF2-7164-4011-8DAF-B5C3DB113568}" xr6:coauthVersionLast="43" xr6:coauthVersionMax="43" xr10:uidLastSave="{00000000-0000-0000-0000-000000000000}"/>
<workbookProtection lockStructure="1"/>
Part can have: mc:Ignorable="x15 xr xr6 xr10 xr2"
xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision"
xmlns:xr6="http://schemas.microsoft.com/office/spreadsheetml/2016/revision6"
xmlns:xr10="http://schemas.microsoft.com/office/spreadsheetml/2016/revision10"
xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2"
-->

<!-- added docx4j 8.1.1 -->
<xsd:element ref="mc:AlternateContent" />


<xsd:element name="workbookProtection" type="CT_WorkbookProtection" minOccurs="0"
maxOccurs="1"/>
<xsd:element name="bookViews" type="CT_BookViews" minOccurs="0" maxOccurs="1"/>
Expand All @@ -4224,6 +4253,7 @@
<xsd:element name="extLst" type="CT_ExtensionList" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="conformance" type="s:ST_ConformanceClass"/>
<xsd:attribute ref="mc:Ignorable" use="optional" />
</xsd:complexType>
<xsd:complexType name="CT_FileVersion">
<xsd:annotation>
Expand Down
6 changes: 5 additions & 1 deletion xsd/sml/sml_root.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ That's because there is a name collision in:
org.xlsx4j.sml.CTCalculatedMember
org.xlsx4j.sml.CTPCDKPI
You can use
You can use (2019)
sh /bvols/\@Overflow/No_COW//java/jaxb-ri-2.2.11/bin/xjc.sh -classpath /bvols/\@Overflow/No_COW/java/parent-pointer-plugin-1.2.jar -Xparent-pointer sml_root.xsd -d tmp -no-header -target 2.0
\Java\jaxb-ri-2.2.6\bin\xjc sml_root.xsd -d tmp -no-header -target 2.0
Expand All @@ -57,6 +60,7 @@ or better, you can use ppp 1.2,
REVISION HISTORY
2019 06 24 - added mce to workbook
2013 01 20 - moved to ECMA 376 4ed; add parent pointer
2013 01 20 - added @xml:space in shared strings
2010 09 06 - First compiled and added to docx4j
Expand Down

0 comments on commit 1e5478a

Please sign in to comment.