1a1b4a26bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3a1b4a26bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4a1b4a26bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5a1b4a26bSAndrew Rist  * distributed with this work for additional information
6a1b4a26bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7a1b4a26bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8a1b4a26bSAndrew Rist  * "License"); you may not use this file except in compliance
9a1b4a26bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10a1b4a26bSAndrew Rist  *
11a1b4a26bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12a1b4a26bSAndrew Rist  *
13a1b4a26bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14a1b4a26bSAndrew Rist  * software distributed under the License is distributed on an
15a1b4a26bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16a1b4a26bSAndrew Rist  * KIND, either express or implied.  See the License for the
17a1b4a26bSAndrew Rist  * specific language governing permissions and limitations
18a1b4a26bSAndrew Rist  * under the License.
19a1b4a26bSAndrew Rist  *
20a1b4a26bSAndrew Rist  *************************************************************/
21a1b4a26bSAndrew Rist 
22a1b4a26bSAndrew Rist 
23cdf0e10cSrcweir package com.sun.star.wizards.ui;
24cdf0e10cSrcweir 
25cdf0e10cSrcweir import java.beans.PropertyChangeEvent;
26cdf0e10cSrcweir 
27cdf0e10cSrcweir import com.sun.star.wizards.common.*;
28cdf0e10cSrcweir import com.sun.star.awt.*;
29cdf0e10cSrcweir import java.util.ArrayList;
30cdf0e10cSrcweir 
31cdf0e10cSrcweir public class SortingComponent
32cdf0e10cSrcweir {
33cdf0e10cSrcweir 
34cdf0e10cSrcweir     com.sun.star.lang.XMultiServiceFactory xMSF;
35cdf0e10cSrcweir     WizardDialog CurUnoDialog;
36cdf0e10cSrcweir     int MaxSortIndex = -1;
37cdf0e10cSrcweir     public String[][] FieldNames;
38cdf0e10cSrcweir     static String sNoSorting;
39cdf0e10cSrcweir     static String sSortCriteriaisduplicate;
40cdf0e10cSrcweir     static String[] sSortHeader = new String[4];
41cdf0e10cSrcweir     static String[] sSortAscend = new String[4];
42cdf0e10cSrcweir     static String[] sSortDescend = new String[4];
43cdf0e10cSrcweir     static short[] bOldSortValues = new short[4];
44cdf0e10cSrcweir     public int MAXSORTCRITERIAINDEX = 3;
45cdf0e10cSrcweir     final int SOFIRSTSORTLST = 0;
46cdf0e10cSrcweir     final int SOSECSORTLST = 1;
47cdf0e10cSrcweir     final int SOTHIRDSORTLST = 2;
48cdf0e10cSrcweir     final int SOFOURTHSORTLST = 3;
49cdf0e10cSrcweir     final int[] SOSORTLST = new int[]
50cdf0e10cSrcweir     {
51cdf0e10cSrcweir         SOFIRSTSORTLST, SOSECSORTLST, SOTHIRDSORTLST, SOFOURTHSORTLST
52cdf0e10cSrcweir     };
53cdf0e10cSrcweir     XListBox[] xSortListBox = new XListBox[4];
54cdf0e10cSrcweir 
55cdf0e10cSrcweir     class ItemListenerImpl implements com.sun.star.awt.XItemListener
56cdf0e10cSrcweir     {
57cdf0e10cSrcweir 
itemStateChanged(ItemEvent EventObject)58cdf0e10cSrcweir         public void itemStateChanged(ItemEvent EventObject)
59cdf0e10cSrcweir         {
60cdf0e10cSrcweir             Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, PropertyNames.PROPERTY_ENABLED, Boolean.FALSE);
61cdf0e10cSrcweir             int ikey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList);
62cdf0e10cSrcweir             enableNextSortListBox(ikey);
63cdf0e10cSrcweir             Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, PropertyNames.PROPERTY_ENABLED, Boolean.TRUE);
64cdf0e10cSrcweir         }
65cdf0e10cSrcweir 
disposing(com.sun.star.lang.EventObject eventObject)66cdf0e10cSrcweir         public void disposing(com.sun.star.lang.EventObject eventObject)
67cdf0e10cSrcweir         {
68cdf0e10cSrcweir         }
69cdf0e10cSrcweir     }
70cdf0e10cSrcweir 
SortingComponent(WizardDialog CurUnoDialog, int iStep, int iCompPosX, int iCompPosY, int iCompWidth, int FirstHelpIndex)71cdf0e10cSrcweir     public SortingComponent(WizardDialog CurUnoDialog, int iStep, int iCompPosX, int iCompPosY, int iCompWidth, int FirstHelpIndex)
72cdf0e10cSrcweir     {
73cdf0e10cSrcweir         try
74cdf0e10cSrcweir         {
75cdf0e10cSrcweir             this.CurUnoDialog = CurUnoDialog;
76cdf0e10cSrcweir             short curtabindex = UnoDialog.setInitialTabindex(iStep);
77cdf0e10cSrcweir             xMSF = CurUnoDialog.xMSF;
78cdf0e10cSrcweir             Integer IStep = new Integer(iStep);
79cdf0e10cSrcweir             Integer ICompPosX = new Integer(iCompPosX);
80cdf0e10cSrcweir             Integer ICompPosY = new Integer(iCompPosY);
81cdf0e10cSrcweir             Integer ICompWidth = new Integer(iCompWidth);
82cdf0e10cSrcweir 
83cdf0e10cSrcweir             Integer IListBoxPosX = new Integer(iCompPosX + 6);
84cdf0e10cSrcweir             int iOptButtonWidth = 65;
85cdf0e10cSrcweir             Integer IOptButtonWidth = new Integer(iOptButtonWidth);
86cdf0e10cSrcweir             Integer IListBoxWidth = new Integer(iCompWidth - iOptButtonWidth - 12);
87cdf0e10cSrcweir             Integer IOptButtonPosX = new Integer(IListBoxPosX.intValue() + IListBoxWidth.intValue() + 6);
88cdf0e10cSrcweir             getResources();
89cdf0e10cSrcweir             com.sun.star.awt.XWindow[] xListBoxWindow = new com.sun.star.awt.XWindow[4];
90cdf0e10cSrcweir             boolean bDoEnable;
91cdf0e10cSrcweir             String HIDString;
92cdf0e10cSrcweir             int iCurPosY = iCompPosY;
93cdf0e10cSrcweir             for (int i = 0; i < 4; i++)
94cdf0e10cSrcweir             {
95cdf0e10cSrcweir                 bDoEnable = (i < 2);
96cdf0e10cSrcweir                 CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedLineModel", "lblSort" + Integer.toString(i + 1), new String[]
97cdf0e10cSrcweir                         {
98cdf0e10cSrcweir                             PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.ORIENTATION, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH
99cdf0e10cSrcweir                         }, new Object[]
100cdf0e10cSrcweir                         {
101cdf0e10cSrcweir                                 Boolean.valueOf(bDoEnable), 8, sSortHeader[i], 0, ICompPosX, new Integer(iCurPosY), IStep, new Short(curtabindex++), ICompWidth
102cdf0e10cSrcweir                         });
103cdf0e10cSrcweir 
104cdf0e10cSrcweir                 HIDString = HelpIds.getHelpIdString(FirstHelpIndex);
105cdf0e10cSrcweir                 xSortListBox[i] = CurUnoDialog.insertListBox("lstSort" + Integer.toString(i + 1), SOSORTLST[i], null, new ItemListenerImpl(), new String[]
106cdf0e10cSrcweir                         {
107cdf0e10cSrcweir                             "Dropdown", PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, "LineCount", PropertyNames.PROPERTY_NAME, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH
108cdf0e10cSrcweir                         }, new Object[]
109cdf0e10cSrcweir                         {
110cdf0e10cSrcweir                             true, bDoEnable, 12, HIDString, new Short(UnoDialog.getListBoxLineCount()), "lstSort" + new Integer(i + 1), IListBoxPosX, new Integer(iCurPosY + 14), IStep, new Short(curtabindex++), IListBoxWidth
111cdf0e10cSrcweir                         }); //new Short((short) (17+i*4))
112cdf0e10cSrcweir 
113cdf0e10cSrcweir                 HIDString = HelpIds.getHelpIdString(FirstHelpIndex + 1);
114cdf0e10cSrcweir                 XRadioButton xRadioButtonAsc = CurUnoDialog.insertRadioButton("optAscend" + Integer.toString(i + 1), 0, new String[]
115cdf0e10cSrcweir                         {
116cdf0e10cSrcweir                             PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STATE, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, "Tag", PropertyNames.PROPERTY_WIDTH
117cdf0e10cSrcweir                         }, new Object[]
118cdf0e10cSrcweir                         {
119cdf0e10cSrcweir                             bDoEnable, 10, HIDString, sSortAscend[i], IOptButtonPosX, new Integer(iCurPosY + 10), new Short((short) 1), IStep, new Short(curtabindex++), PropertyNames.ASC, IOptButtonWidth
120cdf0e10cSrcweir                         }); //, new Short((short) (18+i*4))
121cdf0e10cSrcweir 
122cdf0e10cSrcweir                 HIDString = HelpIds.getHelpIdString(FirstHelpIndex + 2);
123cdf0e10cSrcweir                 XRadioButton xRadioButtonDesc = CurUnoDialog.insertRadioButton("optDescend" + Integer.toString(i + 1), 0, new String[]
124cdf0e10cSrcweir                         {
125cdf0e10cSrcweir                             PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STATE, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, "Tag", PropertyNames.PROPERTY_WIDTH
126cdf0e10cSrcweir                         }, new Object[]
127cdf0e10cSrcweir                         {
128cdf0e10cSrcweir                             bDoEnable, 10, HIDString, sSortDescend[i], IOptButtonPosX, new Integer(iCurPosY + 24), new Short((short) 0), IStep, new Short(curtabindex++), "DESC", IOptButtonWidth
129cdf0e10cSrcweir                         }); //, new Short((short) (19+i*4))
130cdf0e10cSrcweir                 iCurPosY = iCurPosY + 36;
131cdf0e10cSrcweir                 FirstHelpIndex += 3;
132cdf0e10cSrcweir             }
133cdf0e10cSrcweir         }
134cdf0e10cSrcweir         catch (Exception exception)
135cdf0e10cSrcweir         {
136cdf0e10cSrcweir             exception.printStackTrace(System.out);
137cdf0e10cSrcweir         }
138cdf0e10cSrcweir     }
139cdf0e10cSrcweir 
getResources()140cdf0e10cSrcweir     private boolean getResources()
141cdf0e10cSrcweir     {
142cdf0e10cSrcweir         sSortHeader[0] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 20);
143cdf0e10cSrcweir         sSortHeader[1] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 21);
144cdf0e10cSrcweir         sSortHeader[2] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 51);
145cdf0e10cSrcweir         sSortHeader[3] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 52);
146cdf0e10cSrcweir         sSortAscend[0] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 36);
147cdf0e10cSrcweir         sSortAscend[1] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 53);
148cdf0e10cSrcweir         sSortAscend[2] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 54);
149cdf0e10cSrcweir         sSortAscend[3] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 55);
150cdf0e10cSrcweir         sSortDescend[0] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 37);
151cdf0e10cSrcweir         sSortDescend[1] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 56);
152cdf0e10cSrcweir         sSortDescend[2] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 57);
153cdf0e10cSrcweir         sSortDescend[3] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 58);
154cdf0e10cSrcweir         sSortCriteriaisduplicate = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 74);
155cdf0e10cSrcweir         sNoSorting = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 8);
156cdf0e10cSrcweir         return true;
157cdf0e10cSrcweir     }
158cdf0e10cSrcweir 
initialize(String[] _FieldNames, String[][] _SortFieldNames)159cdf0e10cSrcweir     public void initialize(String[] _FieldNames, String[][] _SortFieldNames)
160cdf0e10cSrcweir     {
161cdf0e10cSrcweir         int FieldCount = _FieldNames.length;
162cdf0e10cSrcweir         String[] ViewFieldNames = new String[FieldCount + 1];
163cdf0e10cSrcweir         ViewFieldNames[0] = sNoSorting;
164cdf0e10cSrcweir         System.arraycopy(_FieldNames, 0, ViewFieldNames, 1, FieldCount);
165cdf0e10cSrcweir         short[] SelList = null;
166cdf0e10cSrcweir         for (int i = 0; i < 4; i++)
167cdf0e10cSrcweir         {
168cdf0e10cSrcweir             if (i < _SortFieldNames.length)
169cdf0e10cSrcweir             {
170cdf0e10cSrcweir                 SelList = new short[]
171cdf0e10cSrcweir                         {
172cdf0e10cSrcweir                             (short) (JavaTools.FieldInList(_FieldNames, _SortFieldNames[i][0]) + 1)
173cdf0e10cSrcweir                         };
174cdf0e10cSrcweir             }
175cdf0e10cSrcweir             else
176cdf0e10cSrcweir             {
177cdf0e10cSrcweir                 SelList = new short[]
178cdf0e10cSrcweir                         {
179cdf0e10cSrcweir                             (short) 0
180cdf0e10cSrcweir                         };
181cdf0e10cSrcweir             }
182cdf0e10cSrcweir             CurUnoDialog.setControlProperty("lstSort" + Integer.toString(i + 1), PropertyNames.STRING_ITEM_LIST, ViewFieldNames);
183cdf0e10cSrcweir             CurUnoDialog.setControlProperty("lstSort" + Integer.toString(i + 1), PropertyNames.SELECTED_ITEMS, SelList);
184cdf0e10cSrcweir             toggleSortListBox(i, (i <= _SortFieldNames.length));
185cdf0e10cSrcweir         }
186cdf0e10cSrcweir     }
187cdf0e10cSrcweir 
setMaxSortIndex()188cdf0e10cSrcweir     private void setMaxSortIndex()
189cdf0e10cSrcweir     {
190cdf0e10cSrcweir         MaxSortIndex = -1;
191cdf0e10cSrcweir         for (int i = 0; i <= MAXSORTCRITERIAINDEX; i++)
192cdf0e10cSrcweir         {
193cdf0e10cSrcweir             if (xSortListBox[i].getSelectedItemPos() > 0)
194cdf0e10cSrcweir             {
195cdf0e10cSrcweir                 MaxSortIndex += 1;
196cdf0e10cSrcweir             }
197cdf0e10cSrcweir         }
198cdf0e10cSrcweir     }
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     /**
201cdf0e10cSrcweir      * sets the controls of a Sorting criterion to readonly or not.
202cdf0e10cSrcweir      * @param _index index of the Sorting criterion
203cdf0e10cSrcweir      * @param _breadonly
204cdf0e10cSrcweir      */
setReadOnly(int _index, boolean _breadonly)205cdf0e10cSrcweir     public void setReadOnly(int _index, boolean _breadonly)
206cdf0e10cSrcweir     {
207cdf0e10cSrcweir         CurUnoDialog.setControlProperty("lstSort" + Integer.toString(_index + 1), PropertyNames.READ_ONLY, Boolean.valueOf(_breadonly));
208cdf0e10cSrcweir     }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir     /**
211cdf0e10cSrcweir      *
212cdf0e10cSrcweir      * @param _index the first Sorting criterion in which 'ReadOnly is set to 'false'
213cdf0e10cSrcweir      * @param _bcomplete
214cdf0e10cSrcweir      */
setReadOnlyUntil(int _index, boolean _bcomplete)215cdf0e10cSrcweir     public void setReadOnlyUntil(int _index, boolean _bcomplete)
216cdf0e10cSrcweir     {
217cdf0e10cSrcweir         for (int i = 0; i <= 4; i++)
218cdf0e10cSrcweir         {
219cdf0e10cSrcweir             boolean breadonly = i < _index;
220cdf0e10cSrcweir             setReadOnly(i, breadonly);
221cdf0e10cSrcweir         }
222cdf0e10cSrcweir     }
223cdf0e10cSrcweir 
224cdf0e10cSrcweir     private void enableNextSortListBox(int CurIndex)
225cdf0e10cSrcweir     {
226cdf0e10cSrcweir         try
227cdf0e10cSrcweir         {
228cdf0e10cSrcweir             setMaxSortIndex();
229cdf0e10cSrcweir             boolean bDoEnable = (xSortListBox[CurIndex].getSelectedItemPos() != 0);
230cdf0e10cSrcweir             if (!bDoEnable)
231cdf0e10cSrcweir             {
232cdf0e10cSrcweir                 moveupSortItems(CurIndex, bDoEnable); //disableListBoxesfromIndex(CurIndex);
233cdf0e10cSrcweir             }
234cdf0e10cSrcweir             else
235cdf0e10cSrcweir             {
236cdf0e10cSrcweir                 toggleSortListBox(CurIndex + 1, true);
237cdf0e10cSrcweir             }
238cdf0e10cSrcweir         }
239cdf0e10cSrcweir         catch (Exception exception)
240cdf0e10cSrcweir         {
241cdf0e10cSrcweir             exception.printStackTrace(System.out);
242cdf0e10cSrcweir         }
243cdf0e10cSrcweir     }
244cdf0e10cSrcweir 
245cdf0e10cSrcweir     public String[][] getSortFieldNames()
246cdf0e10cSrcweir     {
247cdf0e10cSrcweir         try
248cdf0e10cSrcweir         {
249cdf0e10cSrcweir             short iCurState;
250cdf0e10cSrcweir             String CurFieldName;
251cdf0e10cSrcweir             setMaxSortIndex();
252cdf0e10cSrcweir             // String[][] SortFieldNames = new String[MaxSortIndex + 1][2];
253cdf0e10cSrcweir             ArrayList<String[]> SortFieldNames = new ArrayList<String[]>();
254cdf0e10cSrcweir             ArrayList<String> SortDescriptions = new ArrayList<String>();
255cdf0e10cSrcweir             for (int i = 0; i <= MaxSortIndex; i++)
256cdf0e10cSrcweir             {
257cdf0e10cSrcweir                 if (!((Boolean) CurUnoDialog.getControlProperty("lstSort" + (i + 1), PropertyNames.READ_ONLY)))
258cdf0e10cSrcweir                 {
259cdf0e10cSrcweir                     CurFieldName = xSortListBox[i].getSelectedItem();
260cdf0e10cSrcweir                     SortDescriptions.add(CurFieldName);
261cdf0e10cSrcweir                     iCurState = ((Short) CurUnoDialog.getControlProperty("optAscend" + Integer.toString(i + 1), PropertyNames.PROPERTY_STATE)).shortValue();
262cdf0e10cSrcweir                     SortFieldNames.add(new String[]{CurFieldName,iCurState == 1 ? PropertyNames.ASC :"DESC" });
263cdf0e10cSrcweir                 }
264cdf0e10cSrcweir             }
265*74cbd1f1SMatthias Seidel             // When searching for a duplicate entry we can neglect whether the entries are to be sorted ascending or descending
266cdf0e10cSrcweir             // TODO for the future we should deliver a messagebox when two different sorting modes have been applied to one field
267cdf0e10cSrcweir             int iduplicate = JavaTools.getDuplicateFieldIndex(SortDescriptions.toArray(new String[SortDescriptions.size()]));
268cdf0e10cSrcweir             if (iduplicate != -1)
269cdf0e10cSrcweir             {
270cdf0e10cSrcweir                 String sLocSortCriteriaisduplicate = JavaTools.replaceSubString(sSortCriteriaisduplicate, SortFieldNames.get(iduplicate)[0], "<FIELDNAME>");
271cdf0e10cSrcweir                 CurUnoDialog.showMessageBox("WarningBox", VclWindowPeerAttribute.OK, sLocSortCriteriaisduplicate);
272cdf0e10cSrcweir                 CurUnoDialog.vetoableChange(new PropertyChangeEvent(CurUnoDialog, "Steps", 1, 2));
273cdf0e10cSrcweir                 CurUnoDialog.setFocus("lstSort" + (iduplicate + 1));
274cdf0e10cSrcweir                 return new String[][]
275cdf0e10cSrcweir                         {
276cdf0e10cSrcweir                         };
277cdf0e10cSrcweir             }
278cdf0e10cSrcweir             else
279cdf0e10cSrcweir             {
280cdf0e10cSrcweir                 return SortFieldNames.toArray(new String[SortFieldNames.size()][2]);
281cdf0e10cSrcweir             }
282cdf0e10cSrcweir         }
283cdf0e10cSrcweir         catch (Exception exception)
284cdf0e10cSrcweir         {
285cdf0e10cSrcweir             exception.printStackTrace(System.out);
286cdf0e10cSrcweir             return null;
287cdf0e10cSrcweir         }
288cdf0e10cSrcweir     }
289cdf0e10cSrcweir 
290cdf0e10cSrcweir     public void disableListBoxesfromIndex(int CurIndex)
291cdf0e10cSrcweir     {
292cdf0e10cSrcweir         if (CurIndex < MAXSORTCRITERIAINDEX)
293cdf0e10cSrcweir         {
294cdf0e10cSrcweir             for (int i = CurIndex + 1; i <= MAXSORTCRITERIAINDEX; i++)
295cdf0e10cSrcweir             {
296cdf0e10cSrcweir                 toggleSortListBox(i, (false));
297cdf0e10cSrcweir                 if (i < MaxSortIndex)
298cdf0e10cSrcweir                 {
299cdf0e10cSrcweir                     CurUnoDialog.setControlProperty("lstSort" + Integer.toString(i + 2), PropertyNames.SELECTED_ITEMS, new short[]
300cdf0e10cSrcweir                             {
301cdf0e10cSrcweir                                 0
302cdf0e10cSrcweir                             });
303cdf0e10cSrcweir                 }
304cdf0e10cSrcweir                 //          xSortListBox[i+1].selectItemPos((short)0, true);
305cdf0e10cSrcweir             }
306cdf0e10cSrcweir             CurUnoDialog.setFocus("lblSort" + new Integer(CurIndex + 1));
307cdf0e10cSrcweir             MaxSortIndex = CurIndex - 1;
308cdf0e10cSrcweir         }
309cdf0e10cSrcweir     }
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     //  The following code can be reactivated in a future version when task #100799 will be fixed
312cdf0e10cSrcweir     private void moveupSortItems(int CurIndex, boolean bDoEnable)
313cdf0e10cSrcweir     {
314cdf0e10cSrcweir         short iNextItemPos;
315cdf0e10cSrcweir         if ((!bDoEnable) && (MAXSORTCRITERIAINDEX > CurIndex))
316cdf0e10cSrcweir         {
317cdf0e10cSrcweir             for (int i = CurIndex; i < MAXSORTCRITERIAINDEX; i++)
318cdf0e10cSrcweir             {
319cdf0e10cSrcweir                 iNextItemPos = xSortListBox[i + 1].getSelectedItemPos();
320cdf0e10cSrcweir                 if (iNextItemPos != 0)
321cdf0e10cSrcweir                 {
322cdf0e10cSrcweir                     CurUnoDialog.setControlProperty("lstSort" + Integer.toString(i + 1), PropertyNames.SELECTED_ITEMS, new short[]
323cdf0e10cSrcweir                             {
324cdf0e10cSrcweir                                 iNextItemPos
325cdf0e10cSrcweir                             });
326cdf0e10cSrcweir                     CurUnoDialog.setControlProperty("lstSort" + Integer.toString(i + 2), PropertyNames.SELECTED_ITEMS, new short[]
327cdf0e10cSrcweir                             {
328cdf0e10cSrcweir                             });
329cdf0e10cSrcweir                     toggleSortListBox(i, true);
330cdf0e10cSrcweir                     CurUnoDialog.setControlProperty("lstSort" + Integer.toString(i + 2), PropertyNames.SELECTED_ITEMS, new short[]
331cdf0e10cSrcweir                             {
332cdf0e10cSrcweir                                 0
333cdf0e10cSrcweir                             });
334cdf0e10cSrcweir                 }
335cdf0e10cSrcweir             }
336cdf0e10cSrcweir             if (MaxSortIndex < xSortListBox.length - 2)
337cdf0e10cSrcweir             {
338cdf0e10cSrcweir                 toggleSortListBox(MaxSortIndex + 2, false);
339cdf0e10cSrcweir             }
340cdf0e10cSrcweir         }
341cdf0e10cSrcweir         else
342cdf0e10cSrcweir         {
343cdf0e10cSrcweir             toggleSortListBox(CurIndex + 1, bDoEnable);
344cdf0e10cSrcweir         }
345cdf0e10cSrcweir     }
346cdf0e10cSrcweir 
347cdf0e10cSrcweir     private void toggleSortListBox(int CurIndex, boolean bDoEnable)
348cdf0e10cSrcweir     {
349cdf0e10cSrcweir         try
350cdf0e10cSrcweir         {
351cdf0e10cSrcweir             if (CurIndex < xSortListBox.length)
352cdf0e10cSrcweir             {
353cdf0e10cSrcweir                 CurUnoDialog.setControlProperty("lblSort" + Integer.toString(CurIndex + 1), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bDoEnable));
354cdf0e10cSrcweir                 CurUnoDialog.setControlProperty("lstSort" + Integer.toString(CurIndex + 1), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bDoEnable));
355cdf0e10cSrcweir                 CurUnoDialog.setControlProperty("optAscend" + Integer.toString(CurIndex + 1), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bDoEnable));
356cdf0e10cSrcweir                 CurUnoDialog.setControlProperty("optDescend" + Integer.toString(CurIndex + 1), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bDoEnable));
357cdf0e10cSrcweir                 if (!bDoEnable)
358cdf0e10cSrcweir                 {
359cdf0e10cSrcweir                     CurUnoDialog.setControlProperty("lstSort" + Integer.toString(CurIndex + 1), PropertyNames.SELECTED_ITEMS, new short[]
360cdf0e10cSrcweir                             {
361cdf0e10cSrcweir                                 0
362cdf0e10cSrcweir                             });
363cdf0e10cSrcweir                 }
364cdf0e10cSrcweir             }
365cdf0e10cSrcweir         }
366cdf0e10cSrcweir         catch (Exception exception)
367cdf0e10cSrcweir         {
368cdf0e10cSrcweir             exception.printStackTrace(System.out);
369cdf0e10cSrcweir         }
370cdf0e10cSrcweir     }
371cdf0e10cSrcweir }
372