Skip to content

Instantly share code, notes, and snippets.

@apoleon
Created May 23, 2022 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apoleon/2a7118b5ce05cc45d9fb59a4f0f341a8 to your computer and use it in GitHub Desktop.
Save apoleon/2a7118b5ce05cc45d9fb59a4f0f341a8 to your computer and use it in GitHub Desktop.
From: Markus Koschany <apo@debian.org>
Date: Sun, 8 May 2022 20:39:48 +0200
Subject: json
---
.../java/org/odftoolkit/odfdom/changes/ChangesFileSaxHandler.java | 4 ++--
.../java/org/odftoolkit/odfdom/changes/JsonOperationConsumer.java | 2 +-
.../java/org/odftoolkit/odfdom/changes/JsonOperationNormalizer.java | 6 +++---
.../java/org/odftoolkit/odfdom/changes/JsonOperationProducer.java | 6 +++---
src/main/java/org/odftoolkit/odfdom/changes/ShapeProperties.java | 4 ++--
5 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/main/java/org/odftoolkit/odfdom/changes/ChangesFileSaxHandler.java b/src/main/java/org/odftoolkit/odfdom/changes/ChangesFileSaxHandler.java
index 0f9da4a..4f5286c 100644
--- a/src/main/java/org/odftoolkit/odfdom/changes/ChangesFileSaxHandler.java
+++ b/src/main/java/org/odftoolkit/odfdom/changes/ChangesFileSaxHandler.java
@@ -2896,7 +2896,7 @@ public class ChangesFileSaxHandler extends org.odftoolkit.odfdom.pkg.OdfFileSaxH
e.getChildElement(
StyleHeaderFooterPropertiesElement.ELEMENT_NAME.getUri(), "header-footer-properties");
if (p != null) {
- pageAttrs = new JSONObject(3);
+ pageAttrs = new JSONObject();
final String sMinHeight = p.getAttribute("fo:min-height");
if (!sMinHeight.isEmpty()) {
pageAttrs.put("minHeight", MapHelper.normalizeLength(sMinHeight));
@@ -2924,7 +2924,7 @@ public class ChangesFileSaxHandler extends org.odftoolkit.odfdom.pkg.OdfFileSaxH
}
}
if (pageAttrs != null && pageAttrs.length() != 0) {
- attrs = new JSONObject(1);
+ attrs = new JSONObject();
attrs.put("page", pageAttrs);
}
diff --git a/src/main/java/org/odftoolkit/odfdom/changes/JsonOperationConsumer.java b/src/main/java/org/odftoolkit/odfdom/changes/JsonOperationConsumer.java
index cfbb50f..bc2e32e 100644
--- a/src/main/java/org/odftoolkit/odfdom/changes/JsonOperationConsumer.java
+++ b/src/main/java/org/odftoolkit/odfdom/changes/JsonOperationConsumer.java
@@ -6573,7 +6573,7 @@ public class JsonOperationConsumer {
}
}
if (putBorders) {
- JSONObject copyAttrs = new JSONObject(attrs);
+ JSONObject copyAttrs = new JSONObject();
copyAttrs.put("borderLeft", useOneBorder ? allBorder : oldLeftBorder);
copyAttrs.put("borderRight", useOneBorder ? allBorder : oldRightBorder);
copyAttrs.put("borderTop", useOneBorder ? allBorder : oldTopBorder);
diff --git a/src/main/java/org/odftoolkit/odfdom/changes/JsonOperationNormalizer.java b/src/main/java/org/odftoolkit/odfdom/changes/JsonOperationNormalizer.java
index 13c8718..63c143a 100644
--- a/src/main/java/org/odftoolkit/odfdom/changes/JsonOperationNormalizer.java
+++ b/src/main/java/org/odftoolkit/odfdom/changes/JsonOperationNormalizer.java
@@ -63,7 +63,7 @@ import java.util.logging.Logger;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-import org.json.JSONString;
+import org.json.JSONStringer;
/**
* Normalizes the content of JSONObject to make it comparable.
@@ -211,8 +211,8 @@ public class JsonOperationNormalizer {
} else if (value instanceof JSONArray) {
sb.append(asString((JSONArray) value));
- } else if (value instanceof JSONString) {
- sb.append(((JSONString) value).toJSONString());
+ } else if (value instanceof JSONStringer) {
+ sb.append(((JSONStringer) value).toJSONString());
} else if (value instanceof Number) {
sb.append(numberToString((Number) value));
} else if (value instanceof Boolean) {
diff --git a/src/main/java/org/odftoolkit/odfdom/changes/JsonOperationProducer.java b/src/main/java/org/odftoolkit/odfdom/changes/JsonOperationProducer.java
index 4dc4b2e..7fa514d 100644
--- a/src/main/java/org/odftoolkit/odfdom/changes/JsonOperationProducer.java
+++ b/src/main/java/org/odftoolkit/odfdom/changes/JsonOperationProducer.java
@@ -1085,7 +1085,7 @@ public class JsonOperationProducer {
}
} catch (SAXException ex) {
Logger.getLogger(JsonOperationProducer.class.getName()).log(Level.SEVERE, null, ex);
- } catch (IOException ex) {
+ } catch (IOException | JSONException ex) {
Logger.getLogger(JsonOperationProducer.class.getName()).log(Level.SEVERE, null, ex);
}
}
@@ -1174,7 +1174,7 @@ public class JsonOperationProducer {
/** Receives the ten list definition */
private JSONObject getListLevelDefinitions(TextListStyleElement listStyle) {
- JSONObject listDefinition = new JSONObject(9);
+ JSONObject listDefinition = new JSONObject();
NodeList listStyleChildren = listStyle.getChildNodes();
int size = listStyleChildren.getLength();
for (int i = 0; i < size; i++) {
@@ -1970,7 +1970,7 @@ public class JsonOperationProducer {
/** Adding a default footer style operation */
public void addHeaderFooter(String contextName, PageArea pageArea, JSONObject attrs) {
if (contextName != null) {
- final JSONObject newOperation = new JSONObject(4);
+ final JSONObject newOperation = new JSONObject();
try {
newOperation.put(OPK_NAME, OP_HEADER_FOOTER);
newOperation.put(OPK_ID, contextName);
diff --git a/src/main/java/org/odftoolkit/odfdom/changes/ShapeProperties.java b/src/main/java/org/odftoolkit/odfdom/changes/ShapeProperties.java
index 4e36f72..869fde1 100644
--- a/src/main/java/org/odftoolkit/odfdom/changes/ShapeProperties.java
+++ b/src/main/java/org/odftoolkit/odfdom/changes/ShapeProperties.java
@@ -155,7 +155,7 @@ public class ShapeProperties extends CachedComponent {
Object fill = mShapeHardFormatations.get("fill");
try {
if (fill == null) {
- fill = new JSONObject(1);
+ fill = new JSONObject();
mShapeHardFormatations.put("fill", fill);
((JSONObject) fill).put("color", "ffffff");
}
@@ -179,7 +179,7 @@ public class ShapeProperties extends CachedComponent {
// shapes require a default line setting
try {
if (lineObject == null) {
- lineObject = new JSONObject(1);
+ lineObject = new JSONObject();
mShapeHardFormatations.put("line", lineObject);
}
if (!((JSONObject) lineObject).has("style")) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment