diff gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapPrintPanel.java @ 6384:2987d81ea719

Further fix encoding handling in the print service - Strings are now html escaped additionaly to java encoding - Escaping / encoding moved into maputils - The legend url is urlencoded - Properties are no longer stored in an encoded manner but rather encoded on demand
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 21 Jun 2013 12:15:30 +0200
parents 9d5f09698d81
children 3823b8bd6bfd
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapPrintPanel.java	Fri Jun 21 11:42:35 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapPrintPanel.java	Fri Jun 21 12:15:30 2013 +0200
@@ -22,6 +22,7 @@
 import org.dive4elements.river.client.shared.model.Property;
 import org.dive4elements.river.client.shared.model.PropertySetting;
 import org.dive4elements.river.client.shared.model.Settings;
+import org.dive4elements.river.client.shared.MapUtils;
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.Window;
@@ -274,15 +275,16 @@
                 catch (MissingResourceException mre) {
                     localized = props.getName();
                 }
-                url.append(toJavaEncodedString(localized));
+                url.append(MapUtils.toSaveHTMLJavaString(localized));
                 url.append("=");
-                url.append(props.getValue());
+                url.append(MapUtils.toSaveHTMLJavaString((String)props.getValue()));
             }
         }
         // O.o
         String river = findRiver(((MapOutputTab)mapToolbar.getOutputTab()
                     ).getCollectionView().getArtifact());
-        url.append("&" + toJavaEncodedString(MSG.getString(MAPFISH_RIVER)) + "=" + river);
+        url.append("&" + MapUtils.toSaveHTMLJavaString(MSG.getString(MAPFISH_RIVER)) + "=" + 
+                MapUtils.toSaveHTMLJavaString(river));
     }
 
     // Copy of DatacageWindow's findRiver with added state for map.river
@@ -309,26 +311,6 @@
         return "";
     }
 
-    public static String toJavaEncodedString(String str) {
-        if (str == null) {
-            return null;
-        }
-        StringBuilder sb = new StringBuilder();
-        for (int i = 0, len = str.length(); i < len; i++) {
-            int unipoint = Character.codePointAt(str, i);
-            if ((unipoint < 32) || (unipoint > 127)) {
-                sb.append("\\u");
-                sb.append(Integer.toHexString((unipoint >> 3*4) & 0xf));
-                sb.append(Integer.toHexString((unipoint >> 2*4) & 0xf));
-                sb.append(Integer.toHexString((unipoint >> 1*4) & 0xf));
-                sb.append(Integer.toHexString((unipoint >> 0*4) & 0xf));
-            } else {
-                sb.append(str.charAt(i));
-            }
-        }
-        return sb.toString();
-    }
-
     protected void updateCollection() {
         final Config config = Config.getInstance();
         final String loc    = config.getLocale();
@@ -336,16 +318,16 @@
         GWT.log("MapPrintPanel.updateCollection via RPC now");
 
         List<Property> properties = new ArrayList<Property>();
-        properties.add(new PropertySetting(MAPFISH_MAPTITLE, toJavaEncodedString(pageTitle.getValueAsString())));
-//        properties.add(new PropertySetting(MAPFISH_LAYOUT, toJavaEncodedString(pageFormat.getValueAsString())));
-        properties.add(new PropertySetting(MAPFISH_SUBTITLE, toJavaEncodedString(pageSubtitle.getValueAsString())));
-        properties.add(new PropertySetting(MAPFISH_RANGE, toJavaEncodedString(pageRange.getValueAsString())));
-        properties.add(new PropertySetting(MAPFISH_STRETCH, toJavaEncodedString(pageStretch.getValueAsString())));
-        properties.add(new PropertySetting(MAPFISH_INSTITUTION, toJavaEncodedString(pageInstitution.getValueAsString())));
-        properties.add(new PropertySetting(MAPFISH_SOURCE, toJavaEncodedString(pageSource.getValueAsString())));
-        properties.add(new PropertySetting(MAPFISH_CREATOR, toJavaEncodedString(pageCreator.getValueAsString())));
-        properties.add(new PropertySetting(MAPFISH_DATEPLACE, toJavaEncodedString(pageDatePlace.getValueAsString())));
-        properties.add(new PropertySetting(MAPFISH_LOGO, toJavaEncodedString(pageLogo.getValueAsString())));
+        properties.add(new PropertySetting(MAPFISH_MAPTITLE, pageTitle.getValueAsString()));
+//        properties.add(new PropertySetting(MAPFISH_LAYOUT, pageFormat.getValueAsString()));
+        properties.add(new PropertySetting(MAPFISH_SUBTITLE, pageSubtitle.getValueAsString()));
+        properties.add(new PropertySetting(MAPFISH_RANGE, pageRange.getValueAsString()));
+        properties.add(new PropertySetting(MAPFISH_STRETCH, pageStretch.getValueAsString()));
+        properties.add(new PropertySetting(MAPFISH_INSTITUTION, pageInstitution.getValueAsString()));
+        properties.add(new PropertySetting(MAPFISH_SOURCE, pageSource.getValueAsString()));
+        properties.add(new PropertySetting(MAPFISH_CREATOR, pageCreator.getValueAsString()));
+        properties.add(new PropertySetting(MAPFISH_DATEPLACE, pageDatePlace.getValueAsString()));
+        properties.add(new PropertySetting(MAPFISH_LOGO, pageLogo.getValueAsString()));
         settings.setSettings("default", properties);
 
         collection.addSettings("print-settings", settings);

http://dive4elements.wald.intevation.org