Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index



Hi!

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=42396

This is my first hack in Java, so let me know if something is wrong.
I tested it, it worked for me.

Szabolcs                                          
From 19f67b45799639db9549a9aa1f0beac3d4217ed8 Mon Sep 17 00:00:00 2001
From: Szabolcs Dezsi <dezsiszabi@hotmail.com>
Date: Sun, 4 Mar 2012 00:57:53 +0100
Subject: [PATCH] Dropdown list in Letter Wizard are now ordered
 alphabetically

---
 .../wizards/letter/LetterWizardDialogImpl.java     |   45 ++++++++++++++------
 1 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.java 
b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.java
index 736233c..55a1a0e 100644
--- a/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.java
+++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.java
@@ -27,6 +27,8 @@
  ************************************************************************/
 package com.sun.star.wizards.letter;
 
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.Vector;
 import com.sun.star.lang.IllegalArgumentException;
 import com.sun.star.lang.WrappedTargetException;
@@ -65,6 +67,20 @@ import com.sun.star.wizards.common.Helper;
 public class LetterWizardDialogImpl extends LetterWizardDialog
 {
 
+    private class Strings
+    {
+       public String Norm;
+       public String NormPath;
+       public String LanguageLabel;
+
+       public Strings(String norm, String normPath, String languageLabel)
+       {
+           Norm = norm;
+           NormPath = normPath;
+           LanguageLabel = languageLabel;
+       }
+    }
+
     protected void enterStep(int OldStep, int NewStep)
     {
     }
@@ -1163,9 +1179,8 @@ public class LetterWizardDialogImpl extends LetterWizardDialog
             e.printStackTrace();
         }
 
-        Vector NormsVector = new Vector();
-        Vector NormsPathVector = new Vector();
-        Vector LanguageLabelsVector = new Vector();
+       Vector StringsVector = new Vector();
+
         String[] LanguageLabels;
 
         boolean found = false;
@@ -1202,21 +1217,25 @@ public class LetterWizardDialogImpl extends LetterWizardDialog
 
             if (found)
             {
-                NormsVector.add(cIsoCode);
-                NormsPathVector.add(nameList[i]);
-                LanguageLabelsVector.add(lc.getLanguageString(MSID));
+               StringsVector.add(new Strings(cIsoCode, (String)nameList[i], 
lc.getLanguageString(MSID)));
             }
         }
 
+       Collections.sort(StringsVector, new Comparator() {
+               public int compare(Object a, Object b) {
+                       return ((Strings)a).LanguageLabel.compareTo(((Strings)b).LanguageLabel);
+               }
+       });
 
-        Norms = new String[NormsVector.size()];
-        NormsVector.toArray(Norms);
-
-        NormPaths = new String[NormsPathVector.size()];
-        NormsPathVector.toArray(NormPaths);
+        Norms = new String[StringsVector.size()];
+        NormPaths = new String[StringsVector.size()];
+        LanguageLabels = new String[StringsVector.size()];
 
-        LanguageLabels = new String[LanguageLabelsVector.size()];
-        LanguageLabelsVector.toArray(LanguageLabels);
+       for(int i = 0; i<StringsVector.size(); i++) {
+               Norms[i] = ((Strings)StringsVector.elementAt(i)).Norm;
+               NormPaths[i] = ((Strings)StringsVector.elementAt(i)).NormPath;
+               LanguageLabels[i] = ((Strings)StringsVector.elementAt(i)).LanguageLabel;
+       }
 
         setControlProperty("lstLetterNorm", PropertyNames.STRING_ITEM_LIST, LanguageLabels);
     }
-- 
1.7.7


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.