Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintPanel.java @ 5714:1103308b19ca
Add toJavaEncodedString function to encode strings in utf-16 notation
used by java. This fixes printing of unicode characters.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 15 Apr 2013 11:34:28 +0200 |
parents | 10aac4ec2d76 |
children | 22e03ca8c39d |
comparison
equal
deleted
inserted
replaced
5713:f5d966428703 | 5714:1103308b19ca |
---|---|
284 } | 284 } |
285 | 285 |
286 return ""; | 286 return ""; |
287 } | 287 } |
288 | 288 |
289 public static String toJavaEncodedString(String str) { | |
290 if (str == null) { | |
291 return null; | |
292 } | |
293 StringBuilder sb = new StringBuilder(); | |
294 for (int i = 0, len = str.length(); i < len; i++) { | |
295 int unipoint = Character.codePointAt(str, i); | |
296 if ((unipoint < 32) || (unipoint > 127)) { | |
297 sb.append("\\u"); | |
298 sb.append(Integer.toHexString((unipoint >> 3*4) & 0xf)); | |
299 sb.append(Integer.toHexString((unipoint >> 2*4) & 0xf)); | |
300 sb.append(Integer.toHexString((unipoint >> 1*4) & 0xf)); | |
301 sb.append(Integer.toHexString((unipoint >> 0*4) & 0xf)); | |
302 } else { | |
303 sb.append(str.charAt(i)); | |
304 } | |
305 } | |
306 return sb.toString(); | |
307 } | |
308 | |
289 protected void updateCollection() { | 309 protected void updateCollection() { |
290 final Config config = Config.getInstance(); | 310 final Config config = Config.getInstance(); |
291 final String loc = config.getLocale(); | 311 final String loc = config.getLocale(); |
292 | 312 |
293 GWT.log("MapPrintPanel.updateCollection via RPC now"); | 313 GWT.log("MapPrintPanel.updateCollection via RPC now"); |
294 | 314 |
295 List<Property> properties = new ArrayList<Property>(); | 315 List<Property> properties = new ArrayList<Property>(); |
296 properties.add(new PropertySetting(MAPFISH_MAPTITLE, this.pageTitle.getValueAsString())); | 316 properties.add(new PropertySetting(MAPFISH_MAPTITLE, toJavaEncodedString(pageTitle.getValueAsString()))); |
297 // properties.add(new PropertySetting(MAPFISH_LAYOUT, this.pageFormat.getValueAsString())); | 317 // properties.add(new PropertySetting(MAPFISH_LAYOUT, toJavaEncodedString(pageFormat.getValueAsString()))); |
298 properties.add(new PropertySetting(MAPFISH_SUBTITLE, this.pageSubtitle.getValueAsString())); | 318 properties.add(new PropertySetting(MAPFISH_SUBTITLE, toJavaEncodedString(pageSubtitle.getValueAsString()))); |
299 properties.add(new PropertySetting(MAPFISH_RANGE, this.pageRange.getValueAsString())); | 319 properties.add(new PropertySetting(MAPFISH_RANGE, toJavaEncodedString(pageRange.getValueAsString()))); |
300 properties.add(new PropertySetting(MAPFISH_STRETCH, this.pageStrech.getValueAsString())); | 320 properties.add(new PropertySetting(MAPFISH_STRETCH, toJavaEncodedString(pageStrech.getValueAsString()))); |
301 properties.add(new PropertySetting(MAPFISH_CREATED, this.pageCreated.getValueAsString())); | 321 properties.add(new PropertySetting(MAPFISH_CREATED, toJavaEncodedString(pageCreated.getValueAsString()))); |
302 properties.add(new PropertySetting(MAPFISH_SOURCE, this.pageSource.getValueAsString())); | 322 properties.add(new PropertySetting(MAPFISH_SOURCE, toJavaEncodedString(pageSource.getValueAsString()))); |
303 properties.add(new PropertySetting(MAPFISH_CREATOR, this.pageCreator.getValueAsString())); | 323 properties.add(new PropertySetting(MAPFISH_CREATOR, toJavaEncodedString(pageCreator.getValueAsString()))); |
304 properties.add(new PropertySetting(MAPFISH_DATEPLACE, this.pageDatePlace.getValueAsString())); | 324 properties.add(new PropertySetting(MAPFISH_DATEPLACE, toJavaEncodedString(pageDatePlace.getValueAsString()))); |
305 settings.setSettings("default", properties); | 325 settings.setSettings("default", properties); |
306 | 326 |
307 collection.addSettings("print-settings", settings); | 327 collection.addSettings("print-settings", settings); |
308 updater.update(collection, loc, new AsyncCallback<Collection>() { | 328 updater.update(collection, loc, new AsyncCallback<Collection>() { |
309 @Override | 329 @Override |