remove some deprecated code slated for removal in 3.18
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808403 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4d1907b447
commit
19d58f3657
@ -32,7 +32,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.apache.poi.hpsf.HPSFRuntimeException;
|
import org.apache.poi.hpsf.HPSFRuntimeException;
|
||||||
import org.apache.poi.hpsf.MarkUnsupportedException;
|
import org.apache.poi.hpsf.MarkUnsupportedException;
|
||||||
import org.apache.poi.hpsf.MutablePropertySet;
|
|
||||||
import org.apache.poi.hpsf.NoPropertySetStreamException;
|
import org.apache.poi.hpsf.NoPropertySetStreamException;
|
||||||
import org.apache.poi.hpsf.PropertySet;
|
import org.apache.poi.hpsf.PropertySet;
|
||||||
import org.apache.poi.hpsf.PropertySetFactory;
|
import org.apache.poi.hpsf.PropertySetFactory;
|
||||||
@ -55,9 +54,8 @@ import org.apache.poi.util.TempFile;
|
|||||||
*
|
*
|
||||||
* <p>Property set streams are copied logically, i.e. the application
|
* <p>Property set streams are copied logically, i.e. the application
|
||||||
* establishes a {@link org.apache.poi.hpsf.PropertySet} of an original property
|
* establishes a {@link org.apache.poi.hpsf.PropertySet} of an original property
|
||||||
* set, creates a {@link org.apache.poi.hpsf.MutablePropertySet} from the
|
* set, creates a {@link org.apache.poi.hpsf.PropertySet} and writes the
|
||||||
* {@link org.apache.poi.hpsf.PropertySet} and writes the
|
* {@link org.apache.poi.hpsf.PropertySet} to the destination POI file
|
||||||
* {@link org.apache.poi.hpsf.MutablePropertySet} to the destination POI file
|
|
||||||
* system. - Streams which are no property set streams are copied bit by
|
* system. - Streams which are no property set streams are copied bit by
|
||||||
* bit.</p>
|
* bit.</p>
|
||||||
*
|
*
|
||||||
@ -283,7 +281,7 @@ public class CopyCompare
|
|||||||
* everything unmodified to the destination POI filesystem. Property set
|
* everything unmodified to the destination POI filesystem. Property set
|
||||||
* streams are copied by creating a new {@link PropertySet} from the
|
* streams are copied by creating a new {@link PropertySet} from the
|
||||||
* original property set by using the {@link
|
* original property set by using the {@link
|
||||||
* MutablePropertySet#MutablePropertySet(PropertySet)} constructor.</p>
|
* PropertySet#PropertySet(PropertySet)} constructor.</p>
|
||||||
*/
|
*/
|
||||||
static class CopyFile implements POIFSReaderListener {
|
static class CopyFile implements POIFSReaderListener {
|
||||||
private String dstName;
|
private String dstName;
|
||||||
@ -377,7 +375,7 @@ public class CopyCompare
|
|||||||
final PropertySet ps)
|
final PropertySet ps)
|
||||||
throws WritingNotSupportedException, IOException {
|
throws WritingNotSupportedException, IOException {
|
||||||
final DirectoryEntry de = getPath(poiFs, path);
|
final DirectoryEntry de = getPath(poiFs, path);
|
||||||
final MutablePropertySet mps = new MutablePropertySet(ps);
|
final PropertySet mps = new PropertySet(ps);
|
||||||
de.createDocument(name, mps.toInputStream());
|
de.createDocument(name, mps.toInputStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,16 +28,7 @@ import java.io.OutputStream;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.poi.hpsf.HPSFRuntimeException;
|
import org.apache.poi.hpsf.*;
|
||||||
import org.apache.poi.hpsf.MarkUnsupportedException;
|
|
||||||
import org.apache.poi.hpsf.MutablePropertySet;
|
|
||||||
import org.apache.poi.hpsf.MutableSection;
|
|
||||||
import org.apache.poi.hpsf.NoPropertySetStreamException;
|
|
||||||
import org.apache.poi.hpsf.PropertySet;
|
|
||||||
import org.apache.poi.hpsf.PropertySetFactory;
|
|
||||||
import org.apache.poi.hpsf.SummaryInformation;
|
|
||||||
import org.apache.poi.hpsf.Variant;
|
|
||||||
import org.apache.poi.hpsf.WritingNotSupportedException;
|
|
||||||
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
|
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
|
||||||
import org.apache.poi.poifs.eventfilesystem.POIFSReader;
|
import org.apache.poi.poifs.eventfilesystem.POIFSReader;
|
||||||
import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;
|
import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;
|
||||||
@ -240,12 +231,11 @@ public class WriteAuthorAndTitle
|
|||||||
|
|
||||||
/* Create a mutable property set as a copy of the original read-only
|
/* Create a mutable property set as a copy of the original read-only
|
||||||
* property set. */
|
* property set. */
|
||||||
final MutablePropertySet mps = new MutablePropertySet(si);
|
final PropertySet mps = new PropertySet(si);
|
||||||
|
|
||||||
/* Retrieve the section containing the properties to modify. A
|
/* Retrieve the section containing the properties to modify. A
|
||||||
* summary information property set contains exactly one section. */
|
* summary information property set contains exactly one section. */
|
||||||
final MutableSection s =
|
final Section s = mps.getSections().get(0);
|
||||||
(MutableSection) mps.getSections().get(0);
|
|
||||||
|
|
||||||
/* Set the properties. */
|
/* Set the properties. */
|
||||||
s.setProperty(PropertyIDMap.PID_AUTHOR, Variant.VT_LPSTR,
|
s.setProperty(PropertyIDMap.PID_AUTHOR, Variant.VT_LPSTR,
|
||||||
@ -281,7 +271,7 @@ public class WriteAuthorAndTitle
|
|||||||
throws WritingNotSupportedException, IOException
|
throws WritingNotSupportedException, IOException
|
||||||
{
|
{
|
||||||
final DirectoryEntry de = getPath(poiFs, path);
|
final DirectoryEntry de = getPath(poiFs, path);
|
||||||
final MutablePropertySet mps = new MutablePropertySet(ps);
|
final PropertySet mps = new PropertySet(ps);
|
||||||
de.createDocument(name, mps.toInputStream());
|
de.createDocument(name, mps.toInputStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,12 +21,7 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.apache.poi.hpsf.MutableProperty;
|
import org.apache.poi.hpsf.*;
|
||||||
import org.apache.poi.hpsf.MutablePropertySet;
|
|
||||||
import org.apache.poi.hpsf.MutableSection;
|
|
||||||
import org.apache.poi.hpsf.SummaryInformation;
|
|
||||||
import org.apache.poi.hpsf.Variant;
|
|
||||||
import org.apache.poi.hpsf.WritingNotSupportedException;
|
|
||||||
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
|
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
|
||||||
import org.apache.poi.hpsf.wellknown.SectionIDMap;
|
import org.apache.poi.hpsf.wellknown.SectionIDMap;
|
||||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||||
@ -61,10 +56,10 @@ public class WriteTitle
|
|||||||
|
|
||||||
/* Create a mutable property set. Initially it contains a single section
|
/* Create a mutable property set. Initially it contains a single section
|
||||||
* with no properties. */
|
* with no properties. */
|
||||||
final MutablePropertySet mps = new MutablePropertySet();
|
final PropertySet mps = new PropertySet();
|
||||||
|
|
||||||
/* Retrieve the section the property set already contains. */
|
/* Retrieve the section the property set already contains. */
|
||||||
final MutableSection ms = (MutableSection) mps.getSections().get(0);
|
final Section ms = mps.getSections().get(0);
|
||||||
|
|
||||||
/* Turn the property set into a summary information property. This is
|
/* Turn the property set into a summary information property. This is
|
||||||
* done by setting the format ID of its first section to
|
* done by setting the format ID of its first section to
|
||||||
@ -72,7 +67,7 @@ public class WriteTitle
|
|||||||
ms.setFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
|
ms.setFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
|
||||||
|
|
||||||
/* Create an empty property. */
|
/* Create an empty property. */
|
||||||
final MutableProperty p = new MutableProperty();
|
final Property p = new Property();
|
||||||
|
|
||||||
/* Fill the property with appropriate settings so that it specifies the
|
/* Fill the property with appropriate settings so that it specifies the
|
||||||
* document's title. */
|
* document's title. */
|
||||||
|
@ -151,7 +151,7 @@ public class CustomProperties implements Map<String,Object> {
|
|||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("unsupported datatype - currently String,Short,Integer,Long,Float,Double,Boolean,BigInteger(unsigned long),Date can be processed.");
|
throw new IllegalStateException("unsupported datatype - currently String,Short,Integer,Long,Float,Double,Boolean,BigInteger(unsigned long),Date can be processed.");
|
||||||
}
|
}
|
||||||
final Property p = new MutableProperty(-1, variantType, value);
|
final Property p = new Property(-1, variantType, value);
|
||||||
return put(new CustomProperty(p, key));
|
return put(new CustomProperty(p, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ package org.apache.poi.hpsf;
|
|||||||
* properties have an optional name. If the name is not {@code null} it
|
* properties have an optional name. If the name is not {@code null} it
|
||||||
* will be maintained in the section's dictionary.
|
* will be maintained in the section's dictionary.
|
||||||
*/
|
*/
|
||||||
public class CustomProperty extends MutableProperty
|
public class CustomProperty extends Property
|
||||||
{
|
{
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -33,7 +33,7 @@ import org.apache.poi.hpsf.wellknown.SectionIDMap;
|
|||||||
*
|
*
|
||||||
* @see SummaryInformation
|
* @see SummaryInformation
|
||||||
*/
|
*/
|
||||||
public class DocumentSummaryInformation extends SpecialPropertySet {
|
public class DocumentSummaryInformation extends PropertySet {
|
||||||
/**
|
/**
|
||||||
* The document name a document summary information stream
|
* The document name a document summary information stream
|
||||||
* usually has in a POIFS filesystem.
|
* usually has in a POIFS filesystem.
|
||||||
@ -811,7 +811,7 @@ public class DocumentSummaryInformation extends SpecialPropertySet {
|
|||||||
*/
|
*/
|
||||||
private void ensureSection2() {
|
private void ensureSection2() {
|
||||||
if (getSectionCount() < 2) {
|
if (getSectionCount() < 2) {
|
||||||
Section s2 = new MutableSection();
|
Section s2 = new Section();
|
||||||
s2.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[1]);
|
s2.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[1]);
|
||||||
addSection(s2);
|
addSection(s2);
|
||||||
}
|
}
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
/* ====================================================================
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
|
||||||
this work for additional information regarding copyright ownership.
|
|
||||||
The ASF licenses this file to You 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.
|
|
||||||
==================================================================== */
|
|
||||||
|
|
||||||
package org.apache.poi.hpsf;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndianByteArrayInputStream;
|
|
||||||
import org.apache.poi.util.Removal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Adds writing capability to the {@link Property} class.</p>
|
|
||||||
*
|
|
||||||
* <p>Please be aware that this class' functionality will be merged into the
|
|
||||||
* {@link Property} class at a later time, so the API will change.</p>
|
|
||||||
*
|
|
||||||
* @deprecated POI 3.16 - use Property as base class instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Removal(version="3.18")
|
|
||||||
public class MutableProperty extends Property {
|
|
||||||
public MutableProperty() {}
|
|
||||||
|
|
||||||
public MutableProperty(final Property p) {
|
|
||||||
super(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MutableProperty(final long id, final long type, final Object value) {
|
|
||||||
super(id, type, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MutableProperty(final long id, final byte[] src, final long offset, final int length, final int codepage)
|
|
||||||
throws UnsupportedEncodingException {
|
|
||||||
super(id, src, offset, length, codepage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MutableProperty(final long id, LittleEndianByteArrayInputStream leis, final int length, final int codepage)
|
|
||||||
throws UnsupportedEncodingException {
|
|
||||||
super(id, leis, length, codepage);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
/* ====================================================================
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
|
||||||
this work for additional information regarding copyright ownership.
|
|
||||||
The ASF licenses this file to You 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.
|
|
||||||
==================================================================== */
|
|
||||||
|
|
||||||
package org.apache.poi.hpsf;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
|
|
||||||
import org.apache.poi.util.Removal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* dds writing support to the {@link PropertySet} class.<p>
|
|
||||||
*
|
|
||||||
* Please be aware that this class' functionality will be merged into the
|
|
||||||
* {@link PropertySet} class at a later time, so the API will change.
|
|
||||||
*
|
|
||||||
* @deprecated POI 3.16 - use PropertySet as base class instead
|
|
||||||
*/
|
|
||||||
@Removal(version="3.18")
|
|
||||||
public class MutablePropertySet extends PropertySet {
|
|
||||||
public MutablePropertySet() {}
|
|
||||||
|
|
||||||
public MutablePropertySet(final PropertySet ps) {
|
|
||||||
super(ps);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* package */ MutablePropertySet(final InputStream stream)
|
|
||||||
throws NoPropertySetStreamException, MarkUnsupportedException, IOException, UnsupportedEncodingException {
|
|
||||||
super(stream);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/* ====================================================================
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
|
||||||
this work for additional information regarding copyright ownership.
|
|
||||||
The ASF licenses this file to You 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.
|
|
||||||
==================================================================== */
|
|
||||||
|
|
||||||
package org.apache.poi.hpsf;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
|
|
||||||
import org.apache.poi.util.Removal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Adds writing capability to the {@link Section} class.</p>
|
|
||||||
*
|
|
||||||
* <p>Please be aware that this class' functionality will be merged into the
|
|
||||||
* {@link Section} class at a later time, so the API will change.</p>
|
|
||||||
*
|
|
||||||
* @deprecated POI 3.16 - use Section as base class instead
|
|
||||||
*/
|
|
||||||
@Removal(version="3.18")
|
|
||||||
public class MutableSection extends Section {
|
|
||||||
public MutableSection() {}
|
|
||||||
|
|
||||||
public MutableSection(final Section s) {
|
|
||||||
super(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MutableSection(final byte[] src, final int offset) throws UnsupportedEncodingException {
|
|
||||||
super(src,offset);
|
|
||||||
}
|
|
||||||
}
|
|
@ -158,7 +158,7 @@ public class PropertySet {
|
|||||||
|
|
||||||
/* Initialize the sections. Since property set must have at least
|
/* Initialize the sections. Since property set must have at least
|
||||||
* one section it is added right here. */
|
* one section it is added right here. */
|
||||||
addSection(new MutableSection());
|
addSection(new Section());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ public class PropertySet {
|
|||||||
setOSVersion(ps.getOSVersion());
|
setOSVersion(ps.getOSVersion());
|
||||||
setClassID(ps.getClassID());
|
setClassID(ps.getClassID());
|
||||||
for (final Section section : ps.getSections()) {
|
for (final Section section : ps.getSections()) {
|
||||||
sections.add(new MutableSection(section));
|
sections.add(new Section(section));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,7 +491,7 @@ public class PropertySet {
|
|||||||
* "offset" accordingly.
|
* "offset" accordingly.
|
||||||
*/
|
*/
|
||||||
for (int i = 0; i < sectionCount; i++) {
|
for (int i = 0; i < sectionCount; i++) {
|
||||||
final Section s = new MutableSection(src, o);
|
final Section s = new Section(src, o);
|
||||||
o += ClassID.LENGTH + LittleEndianConsts.INT_SIZE;
|
o += ClassID.LENGTH + LittleEndianConsts.INT_SIZE;
|
||||||
sections.add(s);
|
sections.add(s);
|
||||||
}
|
}
|
||||||
@ -580,7 +580,7 @@ public class PropertySet {
|
|||||||
* document. The input stream represents a snapshot of the property set.
|
* document. The input stream represents a snapshot of the property set.
|
||||||
* If the latter is modified while the input stream is still being
|
* If the latter is modified while the input stream is still being
|
||||||
* read, the modifications will not be reflected in the input stream but in
|
* read, the modifications will not be reflected in the input stream but in
|
||||||
* the {@link MutablePropertySet} only.
|
* the {@link PropertySet} only.
|
||||||
*
|
*
|
||||||
* @return the contents of this property set stream
|
* @return the contents of this property set stream
|
||||||
*
|
*
|
||||||
|
@ -99,7 +99,7 @@ public class Section {
|
|||||||
this._offset = -1;
|
this._offset = -1;
|
||||||
setFormatID(s.getFormatID());
|
setFormatID(s.getFormatID());
|
||||||
for (Property p : s.properties.values()) {
|
for (Property p : s.properties.values()) {
|
||||||
properties.put(p.getID(), new MutableProperty(p));
|
properties.put(p.getID(), new Property(p));
|
||||||
}
|
}
|
||||||
setDictionary(s.getDictionary());
|
setDictionary(s.getDictionary());
|
||||||
}
|
}
|
||||||
@ -228,13 +228,13 @@ public class Section {
|
|||||||
try {
|
try {
|
||||||
// fix id
|
// fix id
|
||||||
id = Math.max(PropertyIDMap.PID_MAX, offset2Id.inverseBidiMap().lastKey())+1;
|
id = Math.max(PropertyIDMap.PID_MAX, offset2Id.inverseBidiMap().lastKey())+1;
|
||||||
setProperty(new MutableProperty(id, leis, pLen, codepage));
|
setProperty(new Property(id, leis, pLen, codepage));
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
LOG.log(POILogger.INFO, "Dictionary fallback failed - ignoring property");
|
LOG.log(POILogger.INFO, "Dictionary fallback failed - ignoring property");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
setProperty(new MutableProperty(id, leis, pLen, codepage));
|
setProperty(new Property(id, leis, pLen, codepage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,7 +424,7 @@ public class Section {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void setProperty(final int id, final long variantType, final Object value) {
|
public void setProperty(final int id, final long variantType, final Object value) {
|
||||||
setProperty(new MutableProperty(id, variantType, value));
|
setProperty(new Property(id, variantType, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
/* ====================================================================
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
|
||||||
this work for additional information regarding copyright ownership.
|
|
||||||
The ASF licenses this file to You 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.
|
|
||||||
==================================================================== */
|
|
||||||
|
|
||||||
package org.apache.poi.hpsf;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
|
|
||||||
import org.apache.poi.util.Removal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for the convenience classes {@link SummaryInformation}
|
|
||||||
* and {@link DocumentSummaryInformation}.<p>
|
|
||||||
*
|
|
||||||
* This used to be an abstract class to support late loading
|
|
||||||
* of the SummaryInformation classes, as their concrete instance can
|
|
||||||
* only be determined after the PropertySet has been loaded.
|
|
||||||
*
|
|
||||||
* @deprecated POI 3.16 - use PropertySet as base class instead
|
|
||||||
*/
|
|
||||||
@Removal(version="3.18")
|
|
||||||
public class SpecialPropertySet extends MutablePropertySet {
|
|
||||||
public SpecialPropertySet() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public SpecialPropertySet(final PropertySet ps) throws UnexpectedPropertySetTypeException {
|
|
||||||
super(ps);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* package */ SpecialPropertySet(final InputStream stream)
|
|
||||||
throws NoPropertySetStreamException, MarkUnsupportedException, IOException, UnsupportedEncodingException {
|
|
||||||
super(stream);
|
|
||||||
}
|
|
||||||
}
|
|
@ -31,7 +31,7 @@ import org.apache.poi.hpsf.wellknown.SectionIDMap;
|
|||||||
*
|
*
|
||||||
* @see DocumentSummaryInformation
|
* @see DocumentSummaryInformation
|
||||||
*/
|
*/
|
||||||
public final class SummaryInformation extends SpecialPropertySet {
|
public final class SummaryInformation extends PropertySet {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The document name a summary information stream usually has in a POIFS filesystem.
|
* The document name a summary information stream usually has in a POIFS filesystem.
|
||||||
|
@ -28,7 +28,6 @@ import org.apache.poi.hpsf.DocumentSummaryInformation;
|
|||||||
import org.apache.poi.hpsf.HPSFPropertiesOnlyDocument;
|
import org.apache.poi.hpsf.HPSFPropertiesOnlyDocument;
|
||||||
import org.apache.poi.hpsf.Property;
|
import org.apache.poi.hpsf.Property;
|
||||||
import org.apache.poi.hpsf.PropertySet;
|
import org.apache.poi.hpsf.PropertySet;
|
||||||
import org.apache.poi.hpsf.SpecialPropertySet;
|
|
||||||
import org.apache.poi.hpsf.SummaryInformation;
|
import org.apache.poi.hpsf.SummaryInformation;
|
||||||
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
|
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
|
||||||
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
|
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
|
||||||
|
@ -37,7 +37,6 @@ import org.apache.poi.ss.usermodel.DataFormatter;
|
|||||||
import org.apache.poi.ss.usermodel.DateUtil;
|
import org.apache.poi.ss.usermodel.DateUtil;
|
||||||
import org.apache.poi.ss.util.DateFormatConverter;
|
import org.apache.poi.ss.util.DateFormatConverter;
|
||||||
import org.apache.poi.util.LocaleUtil;
|
import org.apache.poi.util.LocaleUtil;
|
||||||
import org.apache.poi.util.Removal;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a value according to the standard Excel behavior. This "standard" is
|
* Format a value according to the standard Excel behavior. This "standard" is
|
||||||
@ -119,15 +118,6 @@ public class CellFormat {
|
|||||||
|
|
||||||
private static String QUOTE = "\"";
|
private static String QUOTE = "\"";
|
||||||
|
|
||||||
/**
|
|
||||||
* Format a value as it would be were no format specified. This is also
|
|
||||||
* used when the format specified is <tt>General</tt>.
|
|
||||||
* @deprecated use {@link #getInstance(Locale, String)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Removal(version="3.18")
|
|
||||||
public static final CellFormat GENERAL_FORMAT = createGeneralFormat(LocaleUtil.getUserLocale());
|
|
||||||
|
|
||||||
private static CellFormat createGeneralFormat(final Locale locale) {
|
private static CellFormat createGeneralFormat(final Locale locale) {
|
||||||
return new CellFormat(locale, "General") {
|
return new CellFormat(locale, "General") {
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,17 +49,6 @@ public final class ZipHelper {
|
|||||||
*/
|
*/
|
||||||
private final static String FORWARD_SLASH = "/";
|
private final static String FORWARD_SLASH = "/";
|
||||||
|
|
||||||
/**
|
|
||||||
* Buffer to read data from file. Use big buffer to improve performaces. the
|
|
||||||
* InputStream class is reading only 8192 bytes per read call (default value
|
|
||||||
* set by sun)
|
|
||||||
*
|
|
||||||
* @deprecated in POI 3.16-beta3, not used anymore
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Removal(version="3.18")
|
|
||||||
public static final int READ_WRITE_FILE_BUFFER_SIZE = 8192;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevent this class to be instancied.
|
* Prevent this class to be instancied.
|
||||||
*/
|
*/
|
||||||
|
@ -47,6 +47,7 @@ import org.w3c.dom.Element;
|
|||||||
*/
|
*/
|
||||||
public final class ZipPartMarshaller implements PartMarshaller {
|
public final class ZipPartMarshaller implements PartMarshaller {
|
||||||
private final static POILogger logger = POILogFactory.getLogger(ZipPartMarshaller.class);
|
private final static POILogger logger = POILogFactory.getLogger(ZipPartMarshaller.class);
|
||||||
|
private final static int READ_WRITE_FILE_BUFFER_SIZE = 8192;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the specified part.
|
* Save the specified part.
|
||||||
@ -80,7 +81,7 @@ public final class ZipPartMarshaller implements PartMarshaller {
|
|||||||
|
|
||||||
// Saving data in the ZIP file
|
// Saving data in the ZIP file
|
||||||
InputStream ins = part.getInputStream();
|
InputStream ins = part.getInputStream();
|
||||||
byte[] buff = new byte[ZipHelper.READ_WRITE_FILE_BUFFER_SIZE];
|
byte[] buff = new byte[READ_WRITE_FILE_BUFFER_SIZE];
|
||||||
while (ins.available() > 0) {
|
while (ins.available() > 0) {
|
||||||
int resultRead = ins.read(buff);
|
int resultRead = ins.read(buff);
|
||||||
if (resultRead == -1) {
|
if (resultRead == -1) {
|
||||||
|
@ -42,24 +42,7 @@ import java.util.Locale;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.poi.POIDataSamples;
|
import org.apache.poi.POIDataSamples;
|
||||||
import org.apache.poi.hpsf.ClassID;
|
import org.apache.poi.hpsf.*;
|
||||||
import org.apache.poi.hpsf.DocumentSummaryInformation;
|
|
||||||
import org.apache.poi.hpsf.HPSFException;
|
|
||||||
import org.apache.poi.hpsf.IllegalPropertySetDataException;
|
|
||||||
import org.apache.poi.hpsf.MutableProperty;
|
|
||||||
import org.apache.poi.hpsf.MutablePropertySet;
|
|
||||||
import org.apache.poi.hpsf.MutableSection;
|
|
||||||
import org.apache.poi.hpsf.NoFormatIDException;
|
|
||||||
import org.apache.poi.hpsf.NoPropertySetStreamException;
|
|
||||||
import org.apache.poi.hpsf.PropertySet;
|
|
||||||
import org.apache.poi.hpsf.PropertySetFactory;
|
|
||||||
import org.apache.poi.hpsf.ReadingNotSupportedException;
|
|
||||||
import org.apache.poi.hpsf.Section;
|
|
||||||
import org.apache.poi.hpsf.SummaryInformation;
|
|
||||||
import org.apache.poi.hpsf.UnsupportedVariantTypeException;
|
|
||||||
import org.apache.poi.hpsf.Variant;
|
|
||||||
import org.apache.poi.hpsf.VariantSupport;
|
|
||||||
import org.apache.poi.hpsf.WritingNotSupportedException;
|
|
||||||
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
|
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
|
||||||
import org.apache.poi.hpsf.wellknown.SectionIDMap;
|
import org.apache.poi.hpsf.wellknown.SectionIDMap;
|
||||||
import org.apache.poi.poifs.eventfilesystem.POIFSReader;
|
import org.apache.poi.poifs.eventfilesystem.POIFSReader;
|
||||||
@ -125,9 +108,9 @@ public class TestWrite {
|
|||||||
* formatID set: */
|
* formatID set: */
|
||||||
final OutputStream out = new FileOutputStream(filename);
|
final OutputStream out = new FileOutputStream(filename);
|
||||||
final POIFSFileSystem poiFs = new POIFSFileSystem();
|
final POIFSFileSystem poiFs = new POIFSFileSystem();
|
||||||
final MutablePropertySet ps = new MutablePropertySet();
|
final PropertySet ps = new PropertySet();
|
||||||
ps.clearSections();
|
ps.clearSections();
|
||||||
ps.addSection(new MutableSection());
|
ps.addSection(new Section());
|
||||||
|
|
||||||
/* Write it to a POIFS and the latter to disk: */
|
/* Write it to a POIFS and the latter to disk: */
|
||||||
try {
|
try {
|
||||||
@ -162,8 +145,8 @@ public class TestWrite {
|
|||||||
/* Create a mutable property set and write it to a POIFS: */
|
/* Create a mutable property set and write it to a POIFS: */
|
||||||
final OutputStream out = new FileOutputStream(filename);
|
final OutputStream out = new FileOutputStream(filename);
|
||||||
final POIFSFileSystem poiFs = new POIFSFileSystem();
|
final POIFSFileSystem poiFs = new POIFSFileSystem();
|
||||||
final MutablePropertySet ps = new MutablePropertySet();
|
final PropertySet ps = new PropertySet();
|
||||||
final MutableSection s = (MutableSection) ps.getSections().get(0);
|
final Section s = ps.getSections().get(0);
|
||||||
s.setFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
|
s.setFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
|
||||||
|
|
||||||
final ByteArrayOutputStream psStream = new ByteArrayOutputStream();
|
final ByteArrayOutputStream psStream = new ByteArrayOutputStream();
|
||||||
@ -209,13 +192,13 @@ public class TestWrite {
|
|||||||
final OutputStream out = new FileOutputStream(filename);
|
final OutputStream out = new FileOutputStream(filename);
|
||||||
final POIFSFileSystem poiFs = new POIFSFileSystem();
|
final POIFSFileSystem poiFs = new POIFSFileSystem();
|
||||||
|
|
||||||
final MutablePropertySet ps = new MutablePropertySet();
|
final PropertySet ps = new PropertySet();
|
||||||
final MutableSection si = new MutableSection();
|
final Section si = new Section();
|
||||||
si.setFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
|
si.setFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
|
||||||
ps.clearSections();
|
ps.clearSections();
|
||||||
ps.addSection(si);
|
ps.addSection(si);
|
||||||
|
|
||||||
final MutableProperty p = new MutableProperty();
|
final Property p = new Property();
|
||||||
p.setID(PropertyIDMap.PID_AUTHOR);
|
p.setID(PropertyIDMap.PID_AUTHOR);
|
||||||
p.setType(Variant.VT_LPWSTR);
|
p.setType(Variant.VT_LPWSTR);
|
||||||
p.setValue(AUTHOR);
|
p.setValue(AUTHOR);
|
||||||
@ -281,18 +264,18 @@ public class TestWrite {
|
|||||||
final OutputStream out = new FileOutputStream(filename);
|
final OutputStream out = new FileOutputStream(filename);
|
||||||
|
|
||||||
final POIFSFileSystem poiFs = new POIFSFileSystem();
|
final POIFSFileSystem poiFs = new POIFSFileSystem();
|
||||||
final MutablePropertySet ps = new MutablePropertySet();
|
final PropertySet ps = new PropertySet();
|
||||||
ps.clearSections();
|
ps.clearSections();
|
||||||
|
|
||||||
final ClassID formatID = new ClassID();
|
final ClassID formatID = new ClassID();
|
||||||
formatID.setBytes(new byte[]{0, 1, 2, 3, 4, 5, 6, 7,
|
formatID.setBytes(new byte[]{0, 1, 2, 3, 4, 5, 6, 7,
|
||||||
8, 9, 10, 11, 12, 13, 14, 15});
|
8, 9, 10, 11, 12, 13, 14, 15});
|
||||||
final MutableSection s1 = new MutableSection();
|
final Section s1 = new Section();
|
||||||
s1.setFormatID(formatID);
|
s1.setFormatID(formatID);
|
||||||
s1.setProperty(2, SECTION1);
|
s1.setProperty(2, SECTION1);
|
||||||
ps.addSection(s1);
|
ps.addSection(s1);
|
||||||
|
|
||||||
final MutableSection s2 = new MutableSection();
|
final Section s2 = new Section();
|
||||||
s2.setFormatID(formatID);
|
s2.setFormatID(formatID);
|
||||||
s2.setProperty(2, SECTION2);
|
s2.setProperty(2, SECTION2);
|
||||||
ps.addSection(s2);
|
ps.addSection(s2);
|
||||||
@ -429,10 +412,10 @@ public class TestWrite {
|
|||||||
@Test
|
@Test
|
||||||
public void unicodeWrite8Bit() throws WritingNotSupportedException, IOException, NoPropertySetStreamException {
|
public void unicodeWrite8Bit() throws WritingNotSupportedException, IOException, NoPropertySetStreamException {
|
||||||
final String TITLE = "This is a sample title";
|
final String TITLE = "This is a sample title";
|
||||||
final MutablePropertySet mps = new MutablePropertySet();
|
final PropertySet mps = new PropertySet();
|
||||||
final MutableSection ms = (MutableSection) mps.getSections().get(0);
|
final Section ms = mps.getSections().get(0);
|
||||||
ms.setFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
|
ms.setFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
|
||||||
final MutableProperty p = new MutableProperty();
|
final Property p = new Property();
|
||||||
p.setID(PropertyIDMap.PID_TITLE);
|
p.setID(PropertyIDMap.PID_TITLE);
|
||||||
p.setType(Variant.VT_LPSTR);
|
p.setType(Variant.VT_LPSTR);
|
||||||
p.setValue(TITLE);
|
p.setValue(TITLE);
|
||||||
@ -495,8 +478,8 @@ public class TestWrite {
|
|||||||
/* Write: */
|
/* Write: */
|
||||||
final OutputStream out = new FileOutputStream(copy);
|
final OutputStream out = new FileOutputStream(copy);
|
||||||
final POIFSFileSystem poiFs = new POIFSFileSystem();
|
final POIFSFileSystem poiFs = new POIFSFileSystem();
|
||||||
final MutablePropertySet ps1 = new MutablePropertySet();
|
final PropertySet ps1 = new PropertySet();
|
||||||
final MutableSection s = (MutableSection) ps1.getSections().get(0);
|
final Section s = ps1.getSections().get(0);
|
||||||
final Map<Long,String> m = new HashMap<Long,String>(3, 1.0f);
|
final Map<Long,String> m = new HashMap<Long,String>(3, 1.0f);
|
||||||
m.put(Long.valueOf(1), "String 1");
|
m.put(Long.valueOf(1), "String 1");
|
||||||
m.put(Long.valueOf(2), "String 2");
|
m.put(Long.valueOf(2), "String 2");
|
||||||
@ -759,8 +742,8 @@ public class TestWrite {
|
|||||||
final OutputStream out = new FileOutputStream(copy);
|
final OutputStream out = new FileOutputStream(copy);
|
||||||
|
|
||||||
final POIFSFileSystem poiFs = new POIFSFileSystem();
|
final POIFSFileSystem poiFs = new POIFSFileSystem();
|
||||||
final MutablePropertySet ps1 = new MutablePropertySet();
|
final PropertySet ps1 = new PropertySet();
|
||||||
final MutableSection s = (MutableSection) ps1.getSections().get(0);
|
final Section s = ps1.getSections().get(0);
|
||||||
final Map<Long,String> m = new HashMap<Long, String>(3, 1.0f);
|
final Map<Long,String> m = new HashMap<Long, String>(3, 1.0f);
|
||||||
m.put(Long.valueOf(1), "String 1");
|
m.put(Long.valueOf(1), "String 1");
|
||||||
m.put(Long.valueOf(2), "String 2");
|
m.put(Long.valueOf(2), "String 2");
|
||||||
|
@ -34,20 +34,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.poi.POIDataSamples;
|
import org.apache.poi.POIDataSamples;
|
||||||
import org.apache.poi.hpsf.CustomProperties;
|
import org.apache.poi.hpsf.*;
|
||||||
import org.apache.poi.hpsf.CustomProperty;
|
|
||||||
import org.apache.poi.hpsf.DocumentSummaryInformation;
|
|
||||||
import org.apache.poi.hpsf.MarkUnsupportedException;
|
|
||||||
import org.apache.poi.hpsf.MutableProperty;
|
|
||||||
import org.apache.poi.hpsf.MutableSection;
|
|
||||||
import org.apache.poi.hpsf.NoPropertySetStreamException;
|
|
||||||
import org.apache.poi.hpsf.PropertySet;
|
|
||||||
import org.apache.poi.hpsf.PropertySetFactory;
|
|
||||||
import org.apache.poi.hpsf.SummaryInformation;
|
|
||||||
import org.apache.poi.hpsf.UnexpectedPropertySetTypeException;
|
|
||||||
import org.apache.poi.hpsf.Variant;
|
|
||||||
import org.apache.poi.hpsf.VariantSupport;
|
|
||||||
import org.apache.poi.hpsf.WritingNotSupportedException;
|
|
||||||
import org.apache.poi.hpsf.wellknown.SectionIDMap;
|
import org.apache.poi.hpsf.wellknown.SectionIDMap;
|
||||||
import org.apache.poi.poifs.filesystem.DocumentInputStream;
|
import org.apache.poi.poifs.filesystem.DocumentInputStream;
|
||||||
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
|
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
|
||||||
@ -567,14 +554,14 @@ public class TestWriteWellKnown {
|
|||||||
|
|
||||||
DocumentSummaryInformation dsi = PropertySetFactory.newDocumentSummaryInformation();
|
DocumentSummaryInformation dsi = PropertySetFactory.newDocumentSummaryInformation();
|
||||||
CustomProperties cps;
|
CustomProperties cps;
|
||||||
MutableSection s;
|
Section s;
|
||||||
|
|
||||||
/* A document summary information set stream by default does have custom properties. */
|
/* A document summary information set stream by default does have custom properties. */
|
||||||
cps = dsi.getCustomProperties();
|
cps = dsi.getCustomProperties();
|
||||||
assertNull(cps);
|
assertNull(cps);
|
||||||
|
|
||||||
/* Test an empty custom properties set. */
|
/* Test an empty custom properties set. */
|
||||||
s = new MutableSection();
|
s = new Section();
|
||||||
s.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[1]);
|
s.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[1]);
|
||||||
// s.setCodepage(CodePageUtil.CP_UNICODE);
|
// s.setCodepage(CodePageUtil.CP_UNICODE);
|
||||||
dsi.addSection(s);
|
dsi.addSection(s);
|
||||||
@ -582,7 +569,7 @@ public class TestWriteWellKnown {
|
|||||||
assertEquals(0, cps.size());
|
assertEquals(0, cps.size());
|
||||||
|
|
||||||
/* Add a custom property. */
|
/* Add a custom property. */
|
||||||
MutableProperty p = new MutableProperty();
|
Property p = new Property();
|
||||||
p.setID(ID_1);
|
p.setID(ID_1);
|
||||||
p.setType(Variant.VT_LPWSTR);
|
p.setType(Variant.VT_LPWSTR);
|
||||||
p.setValue(VALUE_1);
|
p.setValue(VALUE_1);
|
||||||
|
Loading…
Reference in New Issue
Block a user