Java cleanup - remove unnecessary null checks
Change-Id: I72a847b1180e9aeb8dec18bcaedee7286eee7754
This commit is contained in:
committed by
Stephan Bergmann
parent
0439c5189a
commit
4e2c95c786
@@ -253,10 +253,8 @@ public class List extends DescendantManager implements javax.accessibility.Acces
|
||||
XAccessibleContext xAccessibleContext = unoAccessible.getAccessibleContext();
|
||||
if (xAccessibleContext != null) {
|
||||
javax.accessibility.AccessibleContext ac = new AccessibleListItem(xAccessibleContext);
|
||||
if (ac != null) {
|
||||
ac.setAccessibleParent(List.this);
|
||||
accessibleContext = ac;
|
||||
}
|
||||
ac.setAccessibleParent(List.this);
|
||||
accessibleContext = ac;
|
||||
AccessibleStateAdapter.setComponentState(this, xAccessibleContext.getAccessibleStateSet());
|
||||
}
|
||||
} catch (com.sun.star.uno.RuntimeException e) {
|
||||
|
@@ -478,11 +478,9 @@ public class Table extends DescendantManager implements javax.accessibility.Acce
|
||||
try {
|
||||
XAccessibleContext xAccessibleContext = unoAccessible.getAccessibleContext();
|
||||
if (xAccessibleContext != null) {
|
||||
javax.accessibility.AccessibleContext ac = new AccessibleTableCell(xAccessibleContext);
|
||||
if (ac != null) {
|
||||
ac.setAccessibleParent(Table.this);
|
||||
accessibleContext = ac;
|
||||
}
|
||||
javax.accessibility.AccessibleContext ac = new AccessibleTableCell(xAccessibleContext);
|
||||
ac.setAccessibleParent(Table.this);
|
||||
accessibleContext = ac;
|
||||
}
|
||||
} catch (com.sun.star.uno.RuntimeException e) {
|
||||
}
|
||||
|
@@ -490,11 +490,9 @@ public class Tree extends DescendantManager implements javax.accessibility.Acces
|
||||
try {
|
||||
XAccessibleContext xAccessibleContext = unoAccessible.getAccessibleContext();
|
||||
if (xAccessibleContext != null) {
|
||||
javax.accessibility.AccessibleContext ac = new AccessibleTreeItem(xAccessibleContext);
|
||||
if (ac != null) {
|
||||
ac.setAccessibleParent(Tree.this);
|
||||
accessibleContext = ac;
|
||||
}
|
||||
javax.accessibility.AccessibleContext ac = new AccessibleTreeItem(xAccessibleContext);
|
||||
ac.setAccessibleParent(Tree.this);
|
||||
accessibleContext = ac;
|
||||
}
|
||||
} catch (com.sun.star.uno.RuntimeException e) {
|
||||
}
|
||||
|
@@ -350,12 +350,10 @@ final class InstallationFinder {
|
||||
"reading which command output failed: " + e );
|
||||
return null;
|
||||
} finally {
|
||||
if ( br != null ) {
|
||||
try {
|
||||
br.close();
|
||||
} catch ( IOException e ) {
|
||||
// closing standard input stream failed, ignore
|
||||
}
|
||||
try {
|
||||
br.close();
|
||||
} catch ( IOException e ) {
|
||||
// closing standard input stream failed, ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -127,9 +127,7 @@ class WseHeader extends Wse {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (bs != null) {
|
||||
return bs.toByteArray();
|
||||
} else return null;
|
||||
return bs.toByteArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -510,106 +510,107 @@ public abstract class OfficeDocument
|
||||
throw new OfficeDocumentException(ex);
|
||||
}
|
||||
|
||||
if (isZip)
|
||||
{
|
||||
if (isZip) {
|
||||
read(is);
|
||||
}
|
||||
else{
|
||||
try{
|
||||
Reader r = secondHack(is);
|
||||
InputSource ins = new InputSource(r);
|
||||
org.w3c.dom.Document newDoc = builder.parse(ins);
|
||||
Element rootElement=newDoc.getDocumentElement();
|
||||
} else {
|
||||
try {
|
||||
Reader r = secondHack(is);
|
||||
InputSource ins = new InputSource(r);
|
||||
org.w3c.dom.Document newDoc = builder.parse(ins);
|
||||
Element rootElement = newDoc.getDocumentElement();
|
||||
|
||||
NodeList nodeList;
|
||||
Node tmpNode;
|
||||
Node rootNode = rootElement;
|
||||
if (newDoc !=null){
|
||||
/*content*/
|
||||
contentDoc = createDOM(TAG_OFFICE_DOCUMENT_CONTENT);
|
||||
rootElement=contentDoc.getDocumentElement();
|
||||
rootNode = rootElement;
|
||||
NodeList nodeList;
|
||||
Node tmpNode;
|
||||
Node rootNode = rootElement;
|
||||
|
||||
// FIX (HJ): Include office:font-decls in content DOM
|
||||
nodeList= newDoc.getElementsByTagName(TAG_OFFICE_FONT_DECLS);
|
||||
if (nodeList.getLength()>0){
|
||||
tmpNode = contentDoc.importNode(nodeList.item(0),true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
/* content */
|
||||
contentDoc = createDOM(TAG_OFFICE_DOCUMENT_CONTENT);
|
||||
rootElement = contentDoc.getDocumentElement();
|
||||
rootNode = rootElement;
|
||||
|
||||
nodeList= newDoc.getElementsByTagName(TAG_OFFICE_AUTOMATIC_STYLES);
|
||||
if (nodeList.getLength()>0){
|
||||
tmpNode = contentDoc.importNode(nodeList.item(0),true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
|
||||
nodeList= newDoc.getElementsByTagName(TAG_OFFICE_BODY);
|
||||
if (nodeList.getLength()>0){
|
||||
tmpNode = contentDoc.importNode(nodeList.item(0),true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
|
||||
/*Styles*/
|
||||
styleDoc = createDOM(TAG_OFFICE_DOCUMENT_STYLES);
|
||||
rootElement=styleDoc.getDocumentElement();
|
||||
rootNode = rootElement;
|
||||
|
||||
// FIX (HJ): Include office:font-decls in styles DOM
|
||||
nodeList= newDoc.getElementsByTagName(TAG_OFFICE_FONT_DECLS);
|
||||
if (nodeList.getLength()>0){
|
||||
tmpNode = styleDoc.importNode(nodeList.item(0),true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
|
||||
nodeList= newDoc.getElementsByTagName(TAG_OFFICE_STYLES);
|
||||
if (nodeList.getLength()>0){
|
||||
tmpNode = styleDoc.importNode(nodeList.item(0),true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
|
||||
// FIX (HJ): Include office:automatic-styles in styles DOM
|
||||
nodeList= newDoc.getElementsByTagName(TAG_OFFICE_AUTOMATIC_STYLES);
|
||||
if (nodeList.getLength()>0){
|
||||
tmpNode = styleDoc.importNode(nodeList.item(0),true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
|
||||
// FIX (HJ): Include office:master-styles in styles DOM
|
||||
nodeList= newDoc.getElementsByTagName(TAG_OFFICE_MASTER_STYLES);
|
||||
if (nodeList.getLength()>0){
|
||||
tmpNode = styleDoc.importNode(nodeList.item(0),true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
|
||||
/*Settings*/
|
||||
settingsDoc = createDOM(TAG_OFFICE_DOCUMENT_SETTINGS);
|
||||
rootElement=settingsDoc.getDocumentElement();
|
||||
rootNode = rootElement;
|
||||
nodeList= newDoc.getElementsByTagName(TAG_OFFICE_SETTINGS);
|
||||
if (nodeList.getLength()>0){
|
||||
tmpNode = settingsDoc.importNode(nodeList.item(0),true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
/*Meta*/
|
||||
metaDoc = createDOM(TAG_OFFICE_DOCUMENT_META);
|
||||
rootElement=metaDoc.getDocumentElement();
|
||||
rootNode = rootElement;
|
||||
nodeList= newDoc.getElementsByTagName(TAG_OFFICE_META);
|
||||
if (nodeList.getLength()>0){
|
||||
tmpNode = metaDoc.importNode(nodeList.item(0),true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
// FIX (HJ): Include office:font-decls in content DOM
|
||||
nodeList = newDoc
|
||||
.getElementsByTagName(TAG_OFFICE_FONT_DECLS);
|
||||
if (nodeList.getLength() > 0) {
|
||||
tmpNode = contentDoc.importNode(nodeList.item(0), true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
|
||||
nodeList = newDoc
|
||||
.getElementsByTagName(TAG_OFFICE_AUTOMATIC_STYLES);
|
||||
if (nodeList.getLength() > 0) {
|
||||
tmpNode = contentDoc.importNode(nodeList.item(0), true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
|
||||
nodeList = newDoc.getElementsByTagName(TAG_OFFICE_BODY);
|
||||
if (nodeList.getLength() > 0) {
|
||||
tmpNode = contentDoc.importNode(nodeList.item(0), true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
|
||||
/* Styles */
|
||||
styleDoc = createDOM(TAG_OFFICE_DOCUMENT_STYLES);
|
||||
rootElement = styleDoc.getDocumentElement();
|
||||
rootNode = rootElement;
|
||||
|
||||
// FIX (HJ): Include office:font-decls in styles DOM
|
||||
nodeList = newDoc
|
||||
.getElementsByTagName(TAG_OFFICE_FONT_DECLS);
|
||||
if (nodeList.getLength() > 0) {
|
||||
tmpNode = styleDoc.importNode(nodeList.item(0), true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
|
||||
nodeList = newDoc.getElementsByTagName(TAG_OFFICE_STYLES);
|
||||
if (nodeList.getLength() > 0) {
|
||||
tmpNode = styleDoc.importNode(nodeList.item(0), true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
|
||||
// FIX (HJ): Include office:automatic-styles in styles DOM
|
||||
nodeList = newDoc
|
||||
.getElementsByTagName(TAG_OFFICE_AUTOMATIC_STYLES);
|
||||
if (nodeList.getLength() > 0) {
|
||||
tmpNode = styleDoc.importNode(nodeList.item(0), true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
|
||||
// FIX (HJ): Include office:master-styles in styles DOM
|
||||
nodeList = newDoc
|
||||
.getElementsByTagName(TAG_OFFICE_MASTER_STYLES);
|
||||
if (nodeList.getLength() > 0) {
|
||||
tmpNode = styleDoc.importNode(nodeList.item(0), true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
|
||||
/* Settings */
|
||||
settingsDoc = createDOM(TAG_OFFICE_DOCUMENT_SETTINGS);
|
||||
rootElement = settingsDoc.getDocumentElement();
|
||||
rootNode = rootElement;
|
||||
nodeList = newDoc.getElementsByTagName(TAG_OFFICE_SETTINGS);
|
||||
if (nodeList.getLength() > 0) {
|
||||
tmpNode = settingsDoc
|
||||
.importNode(nodeList.item(0), true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
/* Meta */
|
||||
metaDoc = createDOM(TAG_OFFICE_DOCUMENT_META);
|
||||
rootElement = metaDoc.getDocumentElement();
|
||||
rootNode = rootElement;
|
||||
nodeList = newDoc.getElementsByTagName(TAG_OFFICE_META);
|
||||
if (nodeList.getLength() > 0) {
|
||||
tmpNode = metaDoc.importNode(nodeList.item(0), true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
} catch (SAXException ex) {
|
||||
throw new OfficeDocumentException(ex);
|
||||
}
|
||||
}
|
||||
catch (SAXException ex) {
|
||||
throw new OfficeDocumentException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parse given <code>byte</code> array into a DOM
|
||||
* <code>Document</code> object using the
|
||||
|
@@ -100,89 +100,113 @@ public final class DocumentSerializerImpl
|
||||
* @throws IOException If any I/O error occurs.
|
||||
*/
|
||||
public ConvertData serialize() throws ConvertException, IOException {
|
||||
String docName = sxwDoc.getName();
|
||||
org.w3c.dom.Document domDoc = sxwDoc.getContentDOM();
|
||||
org.w3c.dom.Document metaDoc = sxwDoc.getMetaDOM();
|
||||
org.w3c.dom.Document styleDoc = sxwDoc.getStyleDOM();
|
||||
ByteArrayOutputStream baos= new ByteArrayOutputStream();
|
||||
ConvertData cd = new ConvertData();
|
||||
Node offnode = domDoc.getDocumentElement();
|
||||
if (!(offnode.getNodeName()).equals("office:document")){
|
||||
try{
|
||||
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder= builderFactory.newDocumentBuilder();
|
||||
DOMImplementation domImpl = builder.getDOMImplementation();
|
||||
DocumentType docType =domImpl.createDocumentType("office:document","-//OpenOffice.org//DTD OfficeDocument 1.0//EN",null);
|
||||
org.w3c.dom.Document newDoc = domImpl.createDocument("http://openoffice.org/2000/office","office:document",docType);
|
||||
String docName = sxwDoc.getName();
|
||||
org.w3c.dom.Document domDoc = sxwDoc.getContentDOM();
|
||||
org.w3c.dom.Document metaDoc = sxwDoc.getMetaDOM();
|
||||
org.w3c.dom.Document styleDoc = sxwDoc.getStyleDOM();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ConvertData cd = new ConvertData();
|
||||
Node offnode = domDoc.getDocumentElement();
|
||||
if (!(offnode.getNodeName()).equals("office:document")) {
|
||||
try {
|
||||
DocumentBuilderFactory builderFactory = DocumentBuilderFactory
|
||||
.newInstance();
|
||||
DocumentBuilder builder = builderFactory.newDocumentBuilder();
|
||||
DOMImplementation domImpl = builder.getDOMImplementation();
|
||||
DocumentType docType = domImpl.createDocumentType(
|
||||
"office:document",
|
||||
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN", null);
|
||||
org.w3c.dom.Document newDoc = domImpl.createDocument(
|
||||
"http://openoffice.org/2000/office", "office:document",
|
||||
docType);
|
||||
|
||||
Element rootElement = newDoc.getDocumentElement();
|
||||
rootElement.setAttribute("xmlns:office",
|
||||
"http://openoffice.org/2000/office");
|
||||
rootElement.setAttribute("xmlns:style",
|
||||
"http://openoffice.org/2000/style");
|
||||
rootElement.setAttribute("xmlns:text",
|
||||
"http://openoffice.org/2000/text");
|
||||
rootElement.setAttribute("xmlns:table",
|
||||
"http://openoffice.org/2000/table");
|
||||
|
||||
Element rootElement=newDoc.getDocumentElement();
|
||||
rootElement.setAttribute("xmlns:office","http://openoffice.org/2000/office");
|
||||
rootElement.setAttribute("xmlns:style","http://openoffice.org/2000/style" );
|
||||
rootElement.setAttribute("xmlns:text","http://openoffice.org/2000/text");
|
||||
rootElement.setAttribute("xmlns:table","http://openoffice.org/2000/table");
|
||||
rootElement.setAttribute("xmlns:draw",
|
||||
"http://openoffice.org/2000/drawing");
|
||||
rootElement.setAttribute("xmlns:fo",
|
||||
"http://www.w3.org/1999/XSL/Format");
|
||||
rootElement.setAttribute("xmlns:xlink",
|
||||
"http://www.w3.org/1999/xlink");
|
||||
rootElement.setAttribute("xmlns:dc",
|
||||
"http://purl.org/dc/elements/1.1/");
|
||||
rootElement.setAttribute("xmlns:meta",
|
||||
"http://openoffice.org/2000/meta");
|
||||
rootElement.setAttribute("xmlns:number",
|
||||
"http://openoffice.org/2000/datastyle");
|
||||
rootElement.setAttribute("xmlns:svg",
|
||||
"http://www.w3.org/2000/svg");
|
||||
rootElement.setAttribute("xmlns:chart",
|
||||
"http://openoffice.org/2000/chart");
|
||||
rootElement.setAttribute("xmlns:dr3d",
|
||||
"http://openoffice.org/2000/dr3d");
|
||||
rootElement.setAttribute("xmlns:math",
|
||||
"http://www.w3.org/1998/Math/MathML");
|
||||
rootElement.setAttribute("xmlns:form",
|
||||
"http://openoffice.org/2000/form");
|
||||
rootElement.setAttribute("xmlns:script",
|
||||
"http://openoffice.org/2000/script");
|
||||
rootElement.setAttribute("xmlns:config",
|
||||
"http://openoffice.org/2001/config");
|
||||
rootElement.setAttribute("office:class", "text");
|
||||
rootElement.setAttribute("office:version", "1.0");
|
||||
|
||||
rootElement.setAttribute("xmlns:draw","http://openoffice.org/2000/drawing");
|
||||
rootElement.setAttribute("xmlns:fo","http://www.w3.org/1999/XSL/Format" );
|
||||
rootElement.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink" );
|
||||
rootElement.setAttribute("xmlns:dc","http://purl.org/dc/elements/1.1/" );
|
||||
rootElement.setAttribute("xmlns:meta","http://openoffice.org/2000/meta" );
|
||||
rootElement.setAttribute("xmlns:number","http://openoffice.org/2000/datastyle" );
|
||||
rootElement.setAttribute("xmlns:svg","http://www.w3.org/2000/svg" );
|
||||
rootElement.setAttribute("xmlns:chart","http://openoffice.org/2000/chart" );
|
||||
rootElement.setAttribute("xmlns:dr3d","http://openoffice.org/2000/dr3d" );
|
||||
rootElement.setAttribute("xmlns:math","http://www.w3.org/1998/Math/MathML" );
|
||||
rootElement.setAttribute("xmlns:form","http://openoffice.org/2000/form" );
|
||||
rootElement.setAttribute("xmlns:script","http://openoffice.org/2000/script" );
|
||||
rootElement.setAttribute("xmlns:config","http://openoffice.org/2001/config" );
|
||||
rootElement.setAttribute("office:class","text" );
|
||||
rootElement.setAttribute("office:version","1.0");
|
||||
NodeList nodeList;
|
||||
Node tmpNode;
|
||||
Node rootNode = rootElement;
|
||||
if (metaDoc != null) {
|
||||
nodeList = metaDoc.getElementsByTagName(TAG_OFFICE_META);
|
||||
if (nodeList.getLength() > 0) {
|
||||
tmpNode = newDoc.importNode(nodeList.item(0), true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
}
|
||||
if (styleDoc != null) {
|
||||
nodeList = styleDoc.getElementsByTagName(TAG_OFFICE_STYLES);
|
||||
if (nodeList.getLength() > 0) {
|
||||
tmpNode = newDoc.importNode(nodeList.item(0), true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
}
|
||||
nodeList = domDoc
|
||||
.getElementsByTagName(TAG_OFFICE_AUTOMATIC_STYLES);
|
||||
if (nodeList.getLength() > 0) {
|
||||
tmpNode = newDoc.importNode(nodeList.item(0), true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
nodeList = domDoc.getElementsByTagName(TAG_OFFICE_BODY);
|
||||
if (nodeList.getLength() > 0) {
|
||||
tmpNode = newDoc.importNode(nodeList.item(0), true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
domDoc = newDoc;
|
||||
} catch (Exception e) {
|
||||
System.out
|
||||
.println("\nAn Exception occurred with Xslt Serializer"
|
||||
+ e);
|
||||
}
|
||||
|
||||
|
||||
NodeList nodeList;
|
||||
Node tmpNode;
|
||||
Node rootNode = rootElement;
|
||||
if (metaDoc !=null){
|
||||
nodeList= metaDoc.getElementsByTagName(TAG_OFFICE_META);
|
||||
if (nodeList.getLength()>0){
|
||||
tmpNode = newDoc.importNode(nodeList.item(0),true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
} if (styleDoc !=null){
|
||||
nodeList= styleDoc.getElementsByTagName(TAG_OFFICE_STYLES);
|
||||
if (nodeList.getLength()>0){
|
||||
tmpNode = newDoc.importNode(nodeList.item(0),true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
}if (domDoc !=null){
|
||||
nodeList= domDoc.getElementsByTagName(TAG_OFFICE_AUTOMATIC_STYLES);
|
||||
if (nodeList.getLength()>0){
|
||||
tmpNode = newDoc.importNode(nodeList.item(0),true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
nodeList= domDoc.getElementsByTagName(TAG_OFFICE_BODY);
|
||||
if (nodeList.getLength()>0){
|
||||
tmpNode = newDoc.importNode(nodeList.item(0),true);
|
||||
rootNode.appendChild(tmpNode);
|
||||
}
|
||||
}
|
||||
domDoc=newDoc;
|
||||
}catch(Exception e){
|
||||
System.out.println("\nAn Exception occurred with Xslt Serializer"+e);
|
||||
}
|
||||
|
||||
}
|
||||
try {
|
||||
baos = transform(domDoc);
|
||||
} catch (Exception e) {
|
||||
System.out.println("\n Error with Xslt\n");
|
||||
}
|
||||
|
||||
try{
|
||||
baos=transform(domDoc);
|
||||
}
|
||||
catch (Exception e){
|
||||
System.out.println("\n Error with Xslt\n");
|
||||
}
|
||||
|
||||
DOMDocument resultDomDoc=(DOMDocument)pluginFactory.createDeviceDocument(docName,new ByteArrayInputStream(baos.toByteArray()));
|
||||
cd.addDocument (resultDomDoc);
|
||||
return cd;
|
||||
DOMDocument resultDomDoc = (DOMDocument) pluginFactory
|
||||
.createDeviceDocument(docName,
|
||||
new ByteArrayInputStream(baos.toByteArray()));
|
||||
cd.addDocument(resultDomDoc);
|
||||
return cd;
|
||||
}
|
||||
|
||||
public Source resolve(String href,String base)
|
||||
|
Reference in New Issue
Block a user