Package: writer2latex / 1.4-8

no_JSON.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' writer2latex-1.4~/source/java/org/openoffice/da/comp/w2lcommon/filter/FilterDataParser.java writer2latex-1.4/source/java/org/openoffice/da/comp/w2lcommon/filter/FilterDataParser.java
--- writer2latex-1.4~/source/java/org/openoffice/da/comp/w2lcommon/filter/FilterDataParser.java	2011-06-07 11:01:15.000000000 +0200
+++ writer2latex-1.4/source/java/org/openoffice/da/comp/w2lcommon/filter/FilterDataParser.java	2015-12-23 21:35:12.644079492 +0100
@@ -55,8 +55,6 @@
  *  All errors are silently ignored
  */
 public class FilterDataParser {
-	// TODO: Use JSON format
-    
     //private static XComponentContext xComponentContext = null;
     
     private XSimpleFileAccess2 sfa2;
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' writer2latex-1.4~/source/java/writer2latex/latex/FieldConverter.java writer2latex-1.4/source/java/writer2latex/latex/FieldConverter.java
--- writer2latex-1.4~/source/java/writer2latex/latex/FieldConverter.java	2014-09-19 17:26:50.000000000 +0200
+++ writer2latex-1.4/source/java/writer2latex/latex/FieldConverter.java	2015-12-23 21:35:12.644079492 +0100
@@ -32,9 +32,6 @@
 import java.util.Vector;
 import java.util.regex.Pattern;
 
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
@@ -444,203 +441,6 @@
     
     // Try to handle this reference name as a Zotero reference, return true on success
     private boolean handleZoteroReferenceName(String sName, LaTeXDocumentPortion ldp, Context oc) {
-    	// First parse the reference name:
-    	// A Zotero reference name has the form ZOTERO_ITEM <json object> <identifier> with a single space separating the items
-    	// The identifier is a unique identifier for the reference and is not used here
-    	if (sName.startsWith(ZOTERO_ITEM)) {
-    		int nObjectStart = sName.indexOf('{');
-    		int nObjectEnd = sName.lastIndexOf('}');
-    		if (nObjectStart>-1 && nObjectEnd>-1 && nObjectStart<nObjectEnd) {
-    			String sJsonObject = sName.substring(nObjectStart, nObjectEnd+1);
-    			JSONObject jo = null;
-    			try {
-    				jo = new JSONObject(sJsonObject);
-    			} catch (JSONException e) {
-    				return false;
-    			}
-    			// Successfully parsed the reference, now generate the code
-    			// (we don't expect any errors and ignore them, if they happen anyway)
-
-    			// Sort key (purpose? currently ignored)
-    			/*boolean bSort = true;
-    			try {
-    				bSort = jo.getBoolean("sort");
-    			}
-    			catch (JSONException e) {
-    			}*/
-
-    			JSONArray citationItemsArray = null;
-    			try { // The value is an array of objects, one for each source in this citation
-    				citationItemsArray = jo.getJSONArray("citationItems");
-    			}
-    			catch (JSONException e) {	
-    			}
-
-    			if (citationItemsArray!=null) {
-    				int nCitationCount = citationItemsArray.length();
-    				
-    				if (bUseNatbib) {
-    					if (nCitationCount>1) {
-    						// For multiple citations, use \citetext, otherwise we cannot add individual prefixes and suffixes
-    						// TODO: If no prefixes or suffixes exist, it's safe to combine the citations
-    						ldp.append("\\citetext{");
-    					}
-
-    					for (int nIndex=0; nIndex<nCitationCount; nIndex++) {
-
-    						JSONObject citationItems = null;
-    						try { // Each citation is represented as an object
-    							citationItems = citationItemsArray.getJSONObject(nIndex);
-    						}
-    						catch (JSONException e) {
-    						}
-
-    						if (citationItems!=null) {
-    							if (nIndex>0) {
-    								ldp.append("; "); // Separate multiple citations in this reference
-    							}
-
-    							// Citation items
-    							String sURI = "";
-    							boolean bSuppressAuthor = false;
-    							String sPrefix = "";
-    							String sSuffix = "";
-    							String sLocator = "";
-    							String sLocatorType = "";
-
-    							try { // The URI seems to be an array with a single string value(?)
-    								sURI = citationItems.getJSONArray("uri").getString(0);
-    							}
-    							catch (JSONException e) {	
-    							}
-
-    							try { // SuppressAuthor is a boolean value
-    								bSuppressAuthor = citationItems.getBoolean("suppressAuthor");
-    							}
-    							catch (JSONException e) {	
-    							}
-
-    							try { // Prefix is a string value
-    								sPrefix = citationItems.getString("prefix");
-    							}
-    							catch (JSONException e) {	
-    							}
-
-    							try { // Suffix is a string value
-    								sSuffix = citationItems.getString("suffix");
-    							}
-    							catch (JSONException e) {	
-    							}
-
-    							try { // Locator is a string value, e.g. a page number
-    								sLocator = citationItems.getString("locator");
-    							}
-    							catch (JSONException e) {	
-    							}
-
-    							try {
-    								// LocatorType is a string value, e.g. book, verse, page (missing locatorType means page)
-    								sLocatorType = citationItems.getString("locatorType");
-    							}
-    							catch (JSONException e) {	
-    							}
-
-    							// Adjust locator type (empty locator type means "page")
-    							// TODO: Handle other locator types (localize and abbreviate): Currently the internal name (e.g. book) is used.
-    							if (sLocator.length()>0 && sLocatorType.length()==0) {
-    								// A locator of the form <number><other characters><number> is interpreted as several pages
-    								if (Pattern.compile("[0-9]+[^0-9]+[0-9]+").matcher(sLocator).find()) {
-    									sLocatorType = "pp.";
-    								}
-    								else {
-    									sLocatorType = "p.";
-    								}
-    							}
-
-    							// Insert command. TODO: Evaluate this
-    							if (nCitationCount>1) { // Use commands without parentheses
-    								if (bSuppressAuthor) { ldp.append("\\citeyear"); }
-    								else { ldp.append("\\citet"); }
-    							}
-    							else {
-    								if (bSuppressAuthor) { ldp.append("\\citeyearpar"); }
-    								else { ldp.append("\\citep"); }
-    							}
-
-    							if (sPrefix.length()>0) {
-    								ldp.append("[").append(palette.getI18n().convert(sPrefix,true,oc.getLang())).append("]");
-    							}
-
-    							if (sPrefix.length()>0 || sSuffix.length()>0 || sLocatorType.length()>0 || sLocator.length()>0) {
-    								// Note that we need to include an empty suffix if there's a prefix!
-    								ldp.append("[")
-    								.append(palette.getI18n().convert(sSuffix,true,oc.getLang()))
-    								.append(palette.getI18n().convert(sLocatorType,true,oc.getLang()));
-    								if (sLocatorType.length()>0 && sLocator.length()>0) {
-    									ldp.append("~");
-    								}
-    								ldp.append(palette.getI18n().convert(sLocator,true,oc.getLang()))
-    								.append("]");
-    							}
-
-    							ldp.append("{");
-    							int nSlash = sURI.lastIndexOf('/');
-    							if (nSlash>0) {
-    								ldp.append(sURI.substring(nSlash+1));
-    							}
-    							else {
-    								ldp.append(sURI);
-    							}
-    							ldp.append("}");
-    						}
-    					}
-
-    					if (nCitationCount>1) { // End the \citetext command
-    						ldp.append("}");
-    					}
-    				}
-    				else { // natbib is not available, use simple \cite command
-    					ldp.append("\\cite{");
-    					for (int nIndex=0; nIndex<nCitationCount; nIndex++) {
-    						JSONObject citationItems = null;
-    						try { // Each citation is represented as an object
-    							citationItems = citationItemsArray.getJSONObject(nIndex);
-    						}
-    						catch (JSONException e) {
-    						}
-
-    						if (citationItems!=null) {
-    							if (nIndex>0) {
-    								ldp.append(","); // Separate multiple citations in this reference
-    							}
-
-    							// Citation items
-    							String sURI = "";
-
-    							try { // The URI seems to be an array with a single string value(?)
-    								sURI = citationItems.getJSONArray("uri").getString(0);
-    							}
-    							catch (JSONException e) {	
-    							}
-
-    							int nSlash = sURI.lastIndexOf('/');
-    							if (nSlash>0) {
-    								ldp.append(sURI.substring(nSlash+1));
-    							}
-    							else {
-    								ldp.append(sURI);
-    							}
-    						}
-    					}
-						ldp.append("}");
-    				}
-    				
-    				oc.setInZoteroJabRefText(true);
-    				
-    				return true;
-    			}
-    		}
-    	}
     	return false;
     }
     
@@ -993,4 +793,4 @@
         return buf.toString();
     }
  
-}
\ No newline at end of file
+}
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' writer2latex-1.4~/source/java/writer2latex/latex/SectionConverter.java writer2latex-1.4/source/java/writer2latex/latex/SectionConverter.java
--- writer2latex-1.4~/source/java/writer2latex/latex/SectionConverter.java	2014-09-09 20:18:24.000000000 +0200
+++ writer2latex-1.4/source/java/writer2latex/latex/SectionConverter.java	2015-12-23 21:35:12.644079492 +0100
@@ -26,9 +26,6 @@
 
 package writer2latex.latex;
 
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
@@ -65,64 +62,7 @@
     
     // Handle a section as a Zotero bibliography
     private boolean handleZoteroBibliography(Element node, LaTeXDocumentPortion ldp, Context oc) {
-    	String sName = node.getAttribute(XMLString.TEXT_NAME);
-    	if (config.useBibtex() && config.zoteroBibtexFiles().length()>0	&& sName.startsWith("ZOTERO_BIBL")) {
-    		// This section is a Zotero bibliography, and the user wishes to handle it as such
-        	// A Zotero bibliography name has the form ZOTERO_BIBL <json object> <identifier> with a single space separating the items
-        	// The identifier is a unique identifier for the bibliography and is not used here
-    		if (!config.noIndex()) {
-    			// Parse the name (errors are ignored) and add \nocite commands as appropriate
-        		int nObjectStart = sName.indexOf('{');
-        		int nObjectEnd = sName.lastIndexOf('}');
-        		if (nObjectStart>-1 && nObjectEnd>-1 && nObjectStart<nObjectEnd) {
-        			String sJsonObject = sName.substring(nObjectStart, nObjectEnd+1);
-        			JSONObject jo = null;
-        			try {
-        				jo = new JSONObject(sJsonObject);
-        			} catch (JSONException e) {
-        			}
-        			if (jo!=null) {
-        				JSONArray uncited = null;
-        				try {
-        					uncited = jo.getJSONArray("uncited");
-        				}
-        				catch (JSONException e) {
-        				}
-        				if (uncited!=null) {
-        					int nCount = uncited.length();
-        					if (nCount>0) {
-        						ldp.append("\\nocite{");
-        						for (int nIndex=0; nIndex<nCount; nIndex++) {
-        							if (nIndex>0) {
-        								ldp.append(",");
-        							}
-        							String sURI = null;
-        							try { // Each item is an array containing a single string
-        								sURI = uncited.getJSONArray(nIndex).getString(0);
-        							}
-        							catch (JSONException e) {
-        							}
-        							if (sURI!=null) {
-        								int nSlash = sURI.lastIndexOf('/');
-        								if (nSlash>0) { ldp.append(sURI.substring(nSlash+1)); }
-        								else { ldp.append(sURI); }
-        							}
-        						}
-        						ldp.append("}").nl();
-        					}
-        				}
-        			}
-        		}
-
-    			// Use the BibTeX style and files given in the configuration
-    			ldp.append("\\bibliographystyle{").append(config.bibtexStyle()).append("}").nl()
-    			.append("\\bibliography{").append(config.zoteroBibtexFiles()).append("}").nl();
-    		}
-    		return true;
-    	}
-    	else {
-    		return false;
-    	}
+	return false;
     }
     
     // Handle a section as a JabRef bibliography
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' writer2latex-1.4~/source/readme-source.txt writer2latex-1.4/source/readme-source.txt
--- writer2latex-1.4~/source/readme-source.txt	2015-02-16 16:32:08.000000000 +0100
+++ writer2latex-1.4/source/readme-source.txt	2015-12-23 21:35:12.644079492 +0100
@@ -27,24 +27,6 @@
 Third-party software
 --------------------
 
-From JSON.org:
-
-The classes org.json.* are copyright (c) 2002 JSON.org and is used subject to the following notice
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
-(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge,
-publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
-
 From iharder.sourceforge.net:
 
 The class writer2latex.util.Base64 is Robert Harders public domain Base64 class