1*a1b4a26bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*a1b4a26bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*a1b4a26bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*a1b4a26bSAndrew Rist  * distributed with this work for additional information
6*a1b4a26bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*a1b4a26bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*a1b4a26bSAndrew Rist  * "License"); you may not use this file except in compliance
9*a1b4a26bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*a1b4a26bSAndrew Rist  *
11*a1b4a26bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*a1b4a26bSAndrew Rist  *
13*a1b4a26bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*a1b4a26bSAndrew Rist  * software distributed under the License is distributed on an
15*a1b4a26bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*a1b4a26bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*a1b4a26bSAndrew Rist  * specific language governing permissions and limitations
18*a1b4a26bSAndrew Rist  * under the License.
19*a1b4a26bSAndrew Rist  *
20*a1b4a26bSAndrew Rist  *************************************************************/
21*a1b4a26bSAndrew Rist 
22*a1b4a26bSAndrew Rist 
23cdf0e10cSrcweir package com.sun.star.wizards.ui;
24cdf0e10cSrcweir 
25cdf0e10cSrcweir import com.sun.star.beans.*;
26cdf0e10cSrcweir import com.sun.star.awt.*;
27cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
28cdf0e10cSrcweir import com.sun.star.wizards.common.*;
29cdf0e10cSrcweir import com.sun.star.wizards.common.HelpIds;
30cdf0e10cSrcweir 
31cdf0e10cSrcweir import java.util.*;
32cdf0e10cSrcweir 
33cdf0e10cSrcweir public abstract class ControlScroller
34cdf0e10cSrcweir {
35cdf0e10cSrcweir 
36cdf0e10cSrcweir     protected WizardDialog CurUnoDialog;
37cdf0e10cSrcweir     protected XMultiServiceFactory xMSF;
38cdf0e10cSrcweir     private Object oImgControl;
39cdf0e10cSrcweir     protected int ncurfieldcount;
40cdf0e10cSrcweir     protected int nblockincrement;
41cdf0e10cSrcweir     private int nlineincrement;
42cdf0e10cSrcweir     protected int nscrollvalue = 0;
43cdf0e10cSrcweir     protected int ntotfieldcount;
44cdf0e10cSrcweir     XScrollBar xScrollBar;
45cdf0e10cSrcweir     protected Vector scrollfields;
46cdf0e10cSrcweir     protected Integer ICompPosX;
47cdf0e10cSrcweir     protected int iCompPosX;
48cdf0e10cSrcweir     protected Integer ICompPosY;
49cdf0e10cSrcweir     protected int iCompPosY;
50cdf0e10cSrcweir     protected Integer ICompWidth;
51cdf0e10cSrcweir     protected int iCompWidth;
52cdf0e10cSrcweir     protected Integer ICompHeight;
53cdf0e10cSrcweir     protected int iCompHeight;
54cdf0e10cSrcweir     protected int iStartPosY;
55cdf0e10cSrcweir     protected short curtabindex;
56cdf0e10cSrcweir     int iStep;
57cdf0e10cSrcweir     protected Integer IStep;
58cdf0e10cSrcweir     protected int linedistance;
59cdf0e10cSrcweir     int iScrollBarWidth = 10;
60cdf0e10cSrcweir     int SORELFIRSTPOSY = 3;
61cdf0e10cSrcweir     protected int curHelpIndex;
62cdf0e10cSrcweir     String sIncSuffix;
63cdf0e10cSrcweir     protected Vector ControlGroupVector = new Vector();
64cdf0e10cSrcweir     protected PeerConfig oTitlePeerConfig;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     class AdjustmentListenerImpl implements com.sun.star.awt.XAdjustmentListener
67cdf0e10cSrcweir     {
68cdf0e10cSrcweir 
disposing(com.sun.star.lang.EventObject eventObject)69cdf0e10cSrcweir         public void disposing(com.sun.star.lang.EventObject eventObject)
70cdf0e10cSrcweir         {
71cdf0e10cSrcweir         }
72cdf0e10cSrcweir 
adjustmentValueChanged(AdjustmentEvent AdjustEvent)73cdf0e10cSrcweir         public void adjustmentValueChanged(AdjustmentEvent AdjustEvent)
74cdf0e10cSrcweir         {
75cdf0e10cSrcweir             scrollControls();
76cdf0e10cSrcweir         }
77cdf0e10cSrcweir     }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     /**
80cdf0e10cSrcweir      *
81cdf0e10cSrcweir      * @param _CurUnoDialog
82cdf0e10cSrcweir      * @param iStep
83cdf0e10cSrcweir      * @param iCompPosX
84cdf0e10cSrcweir      * @param iCompPosY
85cdf0e10cSrcweir      * @param iCompWidth
86cdf0e10cSrcweir      * @param _nblockincrement
87cdf0e10cSrcweir      * @param _firsthelpindex
88cdf0e10cSrcweir      * @author bc93774
89cdf0e10cSrcweir      */
90cdf0e10cSrcweir     // TODO add parameters for tabindices and helpindex
ControlScroller(WizardDialog _CurUnoDialog, XMultiServiceFactory _xMSF, int _iStep, int _iCompPosX, int _iCompPosY, int _iCompWidth, int _nblockincrement, int _nlinedistance, int _firsthelpindex)91cdf0e10cSrcweir     protected ControlScroller(WizardDialog _CurUnoDialog, XMultiServiceFactory _xMSF, int _iStep, int _iCompPosX, int _iCompPosY, int _iCompWidth, int _nblockincrement, int _nlinedistance, int _firsthelpindex)
92cdf0e10cSrcweir     {
93cdf0e10cSrcweir         this.xMSF = _xMSF;
94cdf0e10cSrcweir         this.nblockincrement = _nblockincrement;
95cdf0e10cSrcweir         this.CurUnoDialog = _CurUnoDialog;
96cdf0e10cSrcweir         this.iStep = _iStep;
97cdf0e10cSrcweir         this.curHelpIndex = _firsthelpindex;
98cdf0e10cSrcweir         curtabindex = UnoDialog.setInitialTabindex(iStep);
99cdf0e10cSrcweir         this.linedistance = _nlinedistance;
100cdf0e10cSrcweir         IStep = new Integer(iStep);
101cdf0e10cSrcweir         this.iCompPosX = _iCompPosX;
102cdf0e10cSrcweir         this.iCompPosY = _iCompPosY;
103cdf0e10cSrcweir         this.ICompPosX = new Integer(iCompPosX);
104cdf0e10cSrcweir         this.ICompPosY = new Integer(iCompPosY);
105cdf0e10cSrcweir         this.iCompWidth = _iCompWidth;
106cdf0e10cSrcweir         this.ICompWidth = new Integer(iCompWidth);
107cdf0e10cSrcweir         this.iCompHeight = 2 * SORELFIRSTPOSY + nblockincrement * linedistance;
108cdf0e10cSrcweir         iStartPosY = iCompPosY + SORELFIRSTPOSY;
109cdf0e10cSrcweir         int ScrollHeight = iCompHeight - 2;
110cdf0e10cSrcweir         nlineincrement = 1;
111cdf0e10cSrcweir         sIncSuffix = com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.getDlgNameAccess(), "imgBackground");
112cdf0e10cSrcweir         oImgControl = CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlImageControlModel", "imgBackground" + sIncSuffix,
113cdf0e10cSrcweir                 new String[]
114cdf0e10cSrcweir                 {
115cdf0e10cSrcweir                     PropertyNames.PROPERTY_BORDER, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH
116cdf0e10cSrcweir                 },
117cdf0e10cSrcweir                 new Object[]
118cdf0e10cSrcweir                 {
119cdf0e10cSrcweir                     new Short("1"), new Integer(iCompHeight), ICompPosX, new Integer(iCompPosY), IStep, ICompWidth
120cdf0e10cSrcweir                 });
121cdf0e10cSrcweir         oImgControl = CurUnoDialog.xDlgContainer.getControl("imgBackground" + sIncSuffix);
122cdf0e10cSrcweir         setComponentMouseTransparent();
123cdf0e10cSrcweir         xScrollBar = CurUnoDialog.insertScrollBar("TitleScrollBar" + sIncSuffix, 0,
124cdf0e10cSrcweir                 new AdjustmentListenerImpl(),
125cdf0e10cSrcweir                 new String[]
126cdf0e10cSrcweir                 {
127cdf0e10cSrcweir                     PropertyNames.PROPERTY_BORDER, PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.ORIENTATION, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH
128cdf0e10cSrcweir                 },
129cdf0e10cSrcweir                 new Object[]
130cdf0e10cSrcweir                 {
131cdf0e10cSrcweir                     new Short((short) 0), Boolean.TRUE, new Integer(ScrollHeight), HelpIds.getHelpIdString(curHelpIndex), new Integer(ScrollBarOrientation.VERTICAL), new Integer(iCompPosX + iCompWidth - iScrollBarWidth - 1), new Integer(iCompPosY + 1), IStep, new Integer(iScrollBarWidth)
132cdf0e10cSrcweir                 });
133cdf0e10cSrcweir         scrollfields = new Vector();
134cdf0e10cSrcweir         int ypos = iStartPosY + SORELFIRSTPOSY;
135cdf0e10cSrcweir         for (int i = 0; i < nblockincrement; i++)
136cdf0e10cSrcweir         {
137cdf0e10cSrcweir             insertControlGroup(i, ypos);
138cdf0e10cSrcweir             ypos += linedistance;
139cdf0e10cSrcweir         }
140cdf0e10cSrcweir     }
141cdf0e10cSrcweir 
setComponentMouseTransparent()142cdf0e10cSrcweir     public void setComponentMouseTransparent()
143cdf0e10cSrcweir     {
144cdf0e10cSrcweir         CurUnoDialog.getPeerConfiguration().setPeerProperties(oImgControl, new String[]
145cdf0e10cSrcweir                 {
146cdf0e10cSrcweir                     "MouseTransparent"
147cdf0e10cSrcweir                 }, new Boolean[]
148cdf0e10cSrcweir                 {
149cdf0e10cSrcweir                     Boolean.TRUE
150cdf0e10cSrcweir                 });
151cdf0e10cSrcweir     }
152cdf0e10cSrcweir 
setScrollBarOrientationHorizontal()153cdf0e10cSrcweir     protected void setScrollBarOrientationHorizontal()
154cdf0e10cSrcweir     {
155cdf0e10cSrcweir         Helper.setUnoPropertyValue(xScrollBar, PropertyNames.ORIENTATION, new Integer(ScrollBarOrientation.HORIZONTAL));
156cdf0e10cSrcweir     }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     /**
159cdf0e10cSrcweir      * @author bc93774
160cdf0e10cSrcweir      * @param _ntotfieldcount: The number of fields that are to be administered by the ControlScroller
161cdf0e10cSrcweir      */
initialize(int _ntotfieldcount)162cdf0e10cSrcweir     protected void initialize(int _ntotfieldcount)
163cdf0e10cSrcweir     {
164cdf0e10cSrcweir         try
165cdf0e10cSrcweir         {
166cdf0e10cSrcweir             boolean bisVisible;
167cdf0e10cSrcweir             ntotfieldcount = _ntotfieldcount;
168cdf0e10cSrcweir             setCurFieldCount();
169cdf0e10cSrcweir             nscrollvalue = 0;
170cdf0e10cSrcweir             Helper.setUnoPropertyValue(UnoDialog.getModel(xScrollBar), "ScrollValue", new Integer(nscrollvalue));
171cdf0e10cSrcweir             if (ntotfieldcount > nblockincrement)
172cdf0e10cSrcweir             {
173cdf0e10cSrcweir                 Helper.setUnoPropertyValues(UnoDialog.getModel(xScrollBar), new String[]
174cdf0e10cSrcweir                         {
175cdf0e10cSrcweir                             PropertyNames.PROPERTY_ENABLED, "BlockIncrement", "LineIncrement", "ScrollValue", "ScrollValueMax"
176cdf0e10cSrcweir                         }, new Object[]
177cdf0e10cSrcweir                         {
178cdf0e10cSrcweir                             Boolean.TRUE, new Integer(nblockincrement), new Integer(nlineincrement), new Integer(nscrollvalue), new Integer(ntotfieldcount - nblockincrement)
179cdf0e10cSrcweir                         });
180cdf0e10cSrcweir             }
181cdf0e10cSrcweir             else
182cdf0e10cSrcweir             {
183cdf0e10cSrcweir                 Helper.setUnoPropertyValues(UnoDialog.getModel(xScrollBar), new String[]
184cdf0e10cSrcweir                         {
185cdf0e10cSrcweir                             PropertyNames.PROPERTY_ENABLED, "ScrollValue"
186cdf0e10cSrcweir                         }, new Object[]
187cdf0e10cSrcweir                         {
188cdf0e10cSrcweir                             Boolean.FALSE, new Integer(nscrollvalue)
189cdf0e10cSrcweir                         });
190cdf0e10cSrcweir             }
191cdf0e10cSrcweir             fillupControls(true);
192cdf0e10cSrcweir         }
193cdf0e10cSrcweir         catch (java.lang.Exception ex)
194cdf0e10cSrcweir         {
195cdf0e10cSrcweir             ex.printStackTrace();
196cdf0e10cSrcweir         }
197cdf0e10cSrcweir     }
198cdf0e10cSrcweir 
fillupControls(boolean binitialize)199cdf0e10cSrcweir     protected void fillupControls(boolean binitialize)
200cdf0e10cSrcweir     {
201cdf0e10cSrcweir         int newindex;
202cdf0e10cSrcweir         PropertyValue[] oldproperties;
203cdf0e10cSrcweir         PropertyValue[] newproperties;
204cdf0e10cSrcweir         for (int a = 0; a < this.nblockincrement; a++)
205cdf0e10cSrcweir         {
206cdf0e10cSrcweir             if (a < ncurfieldcount)
207cdf0e10cSrcweir             {
208cdf0e10cSrcweir                 fillupControls(a);
209cdf0e10cSrcweir             }
210cdf0e10cSrcweir             if (binitialize)
211cdf0e10cSrcweir             {
212cdf0e10cSrcweir                 setControlGroupVisible(a, (a < this.ncurfieldcount));
213cdf0e10cSrcweir             }
214cdf0e10cSrcweir         }
215cdf0e10cSrcweir         if (binitialize)
216cdf0e10cSrcweir         {
217cdf0e10cSrcweir             CurUnoDialog.repaintDialogStep();
218cdf0e10cSrcweir         }
219cdf0e10cSrcweir     }
220cdf0e10cSrcweir 
fillupControls(int guiRow)221cdf0e10cSrcweir     protected void fillupControls(int guiRow)
222cdf0e10cSrcweir     {
223cdf0e10cSrcweir         PropertyValue[] nameProps = (PropertyValue[]) scrollfields.get(guiRow);
224cdf0e10cSrcweir         PropertyValue[] valueProps = (PropertyValue[]) scrollfields.get(guiRow + nscrollvalue);
225cdf0e10cSrcweir         for (int n = 0; n < nameProps.length; n++)
226cdf0e10cSrcweir         {
227cdf0e10cSrcweir             if (CurUnoDialog.getDlgNameAccess().hasByName(nameProps[n].Name))
228cdf0e10cSrcweir             {
229cdf0e10cSrcweir                 setControlData(nameProps[n].Name, valueProps[n].Value);
230cdf0e10cSrcweir             }
231cdf0e10cSrcweir             else
232cdf0e10cSrcweir             {
233cdf0e10cSrcweir                 throw new IllegalArgumentException("No such control !");
234cdf0e10cSrcweir             }
235cdf0e10cSrcweir         }
236cdf0e10cSrcweir     }
237cdf0e10cSrcweir 
setScrollValue(int _nscrollvalue)238cdf0e10cSrcweir     protected void setScrollValue(int _nscrollvalue)
239cdf0e10cSrcweir     {
240cdf0e10cSrcweir         if (_nscrollvalue >= 0)
241cdf0e10cSrcweir         {
242cdf0e10cSrcweir             Helper.setUnoPropertyValue(UnoDialog.getModel(xScrollBar), "ScrollValue", new Integer(_nscrollvalue));
243cdf0e10cSrcweir             scrollControls();
244cdf0e10cSrcweir         }
245cdf0e10cSrcweir     }
246cdf0e10cSrcweir 
setScrollValue(int _nscrollvalue, int _ntotfieldcount)247cdf0e10cSrcweir     protected void setScrollValue(int _nscrollvalue, int _ntotfieldcount)
248cdf0e10cSrcweir     {
249cdf0e10cSrcweir         setTotalFieldCount(_ntotfieldcount);
250cdf0e10cSrcweir         setScrollValue(_nscrollvalue);
251cdf0e10cSrcweir     }
252cdf0e10cSrcweir 
getTotalFieldCount()253cdf0e10cSrcweir     protected int getTotalFieldCount()
254cdf0e10cSrcweir     {
255cdf0e10cSrcweir         return ntotfieldcount;
256cdf0e10cSrcweir     }
257cdf0e10cSrcweir 
getCurFieldCount()258cdf0e10cSrcweir     protected int getCurFieldCount()
259cdf0e10cSrcweir     {
260cdf0e10cSrcweir         return ncurfieldcount;
261cdf0e10cSrcweir     }
262cdf0e10cSrcweir 
setCurFieldCount()263cdf0e10cSrcweir     private void setCurFieldCount()
264cdf0e10cSrcweir     {
265cdf0e10cSrcweir         if (ntotfieldcount > nblockincrement)
266cdf0e10cSrcweir         {
267cdf0e10cSrcweir             ncurfieldcount = nblockincrement;
268cdf0e10cSrcweir         }
269cdf0e10cSrcweir         else
270cdf0e10cSrcweir         {
271cdf0e10cSrcweir             ncurfieldcount = ntotfieldcount;
272cdf0e10cSrcweir         }
273cdf0e10cSrcweir     }
274cdf0e10cSrcweir 
setTotalFieldCount(int _ntotfieldcount)275cdf0e10cSrcweir     protected void setTotalFieldCount(int _ntotfieldcount)
276cdf0e10cSrcweir     {
277cdf0e10cSrcweir         this.ntotfieldcount = _ntotfieldcount;
278cdf0e10cSrcweir         setCurFieldCount();
279cdf0e10cSrcweir         if (ntotfieldcount > nblockincrement)
280cdf0e10cSrcweir         {
281cdf0e10cSrcweir             Helper.setUnoPropertyValues(UnoDialog.getModel(xScrollBar), new String[]
282cdf0e10cSrcweir                     {
283cdf0e10cSrcweir                         PropertyNames.PROPERTY_ENABLED, "ScrollValueMax"
284cdf0e10cSrcweir                     }, new Object[]
285cdf0e10cSrcweir                     {
286cdf0e10cSrcweir                         Boolean.TRUE, new Integer(ntotfieldcount - nblockincrement)
287cdf0e10cSrcweir                     });
288cdf0e10cSrcweir         }
289cdf0e10cSrcweir         else
290cdf0e10cSrcweir         {
291cdf0e10cSrcweir             Helper.setUnoPropertyValue(UnoDialog.getModel(xScrollBar), PropertyNames.PROPERTY_ENABLED, Boolean.FALSE);
292cdf0e10cSrcweir         }
293cdf0e10cSrcweir     }
294cdf0e10cSrcweir 
toggleComponent(boolean _bdoenable)295cdf0e10cSrcweir     protected void toggleComponent(boolean _bdoenable)
296cdf0e10cSrcweir     {
297cdf0e10cSrcweir         boolean bdoenable = _bdoenable && (ntotfieldcount > nblockincrement);
298cdf0e10cSrcweir         CurUnoDialog.setControlProperty("TitleScrollBar" + sIncSuffix, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdoenable));
299cdf0e10cSrcweir     }
300cdf0e10cSrcweir 
toggleControls(boolean _bdoenable)301cdf0e10cSrcweir     protected void toggleControls(boolean _bdoenable)
302cdf0e10cSrcweir     {
303cdf0e10cSrcweir         for (int n = 0; n < scrollfields.size(); n++)
304cdf0e10cSrcweir         {
305cdf0e10cSrcweir             PropertyValue[] curproperties = (PropertyValue[]) scrollfields.elementAt(n);
306cdf0e10cSrcweir             for (int m = 0; m < curproperties.length; m++)
307cdf0e10cSrcweir             {
308cdf0e10cSrcweir                 PropertyValue curproperty = curproperties[m];
309cdf0e10cSrcweir                 CurUnoDialog.setControlProperty(curproperty.Name, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(_bdoenable));
310cdf0e10cSrcweir             }
311cdf0e10cSrcweir         }
312cdf0e10cSrcweir 
313cdf0e10cSrcweir     }
314cdf0e10cSrcweir 
getScrollValue()315cdf0e10cSrcweir     protected int getScrollValue()
316cdf0e10cSrcweir     {
317cdf0e10cSrcweir         return nscrollvalue;
318cdf0e10cSrcweir     }
319cdf0e10cSrcweir 
setLineIncrementation(int _nlineincrement)320cdf0e10cSrcweir     protected void setLineIncrementation(int _nlineincrement)
321cdf0e10cSrcweir     {
322cdf0e10cSrcweir         this.nlineincrement = _nlineincrement;
323cdf0e10cSrcweir         Helper.setUnoPropertyValue(UnoDialog.getModel(xScrollBar), "LineIncrement", new Integer(nlineincrement));
324cdf0e10cSrcweir 
325cdf0e10cSrcweir     }
326cdf0e10cSrcweir 
getLineIncrementation()327cdf0e10cSrcweir     protected int getLineIncrementation()
328cdf0e10cSrcweir     {
329cdf0e10cSrcweir         return nlineincrement;
330cdf0e10cSrcweir     }
331cdf0e10cSrcweir 
setBlockIncrementation(int _nblockincrement)332cdf0e10cSrcweir     protected void setBlockIncrementation(int _nblockincrement)
333cdf0e10cSrcweir     {
334cdf0e10cSrcweir         this.nblockincrement = _nblockincrement;
335cdf0e10cSrcweir         Helper.setUnoPropertyValues(UnoDialog.getModel(xScrollBar), new String[]
336cdf0e10cSrcweir                 {
337cdf0e10cSrcweir                     PropertyNames.PROPERTY_ENABLED, "BlockIncrement", "ScrollValueMax"
338cdf0e10cSrcweir                 }, new Object[]
339cdf0e10cSrcweir                 {
340cdf0e10cSrcweir                         Boolean.valueOf(ntotfieldcount > nblockincrement), new Integer(nblockincrement), new Integer(ntotfieldcount - nblockincrement)
341cdf0e10cSrcweir                 });
342cdf0e10cSrcweir     }
343cdf0e10cSrcweir 
getBlockIncrementation()344cdf0e10cSrcweir     protected int getBlockIncrementation()
345cdf0e10cSrcweir     {
346cdf0e10cSrcweir         return nblockincrement;
347cdf0e10cSrcweir     }
348cdf0e10cSrcweir 
scrollControls()349cdf0e10cSrcweir     private void scrollControls()
350cdf0e10cSrcweir     {
351cdf0e10cSrcweir         try
352cdf0e10cSrcweir         {
353cdf0e10cSrcweir             scrollRowsInfo();
354cdf0e10cSrcweir             nscrollvalue = ((Integer) Helper.getUnoPropertyValue(UnoDialog.getModel(xScrollBar), "ScrollValue")).intValue();
355cdf0e10cSrcweir             if (nscrollvalue + nblockincrement >= ntotfieldcount)
356cdf0e10cSrcweir             {
357cdf0e10cSrcweir                 nscrollvalue = (ntotfieldcount) - nblockincrement;
358cdf0e10cSrcweir             }
359cdf0e10cSrcweir             fillupControls(false);
360cdf0e10cSrcweir         }
361cdf0e10cSrcweir         catch (java.lang.Exception ex)
362cdf0e10cSrcweir         {
363cdf0e10cSrcweir             ex.printStackTrace();
364cdf0e10cSrcweir         }
365cdf0e10cSrcweir     }
366cdf0e10cSrcweir 
scrollRowsInfo()367cdf0e10cSrcweir     protected void scrollRowsInfo()
368cdf0e10cSrcweir     {
369cdf0e10cSrcweir         int cols =
370cdf0e10cSrcweir                 scrollfields.size() > 0
371cdf0e10cSrcweir                 ? ((PropertyValue[]) scrollfields.get(0)).length
372cdf0e10cSrcweir                 : 0;
373cdf0e10cSrcweir         for (int a = 0; a < ncurfieldcount; a++)
374cdf0e10cSrcweir         {
375cdf0e10cSrcweir             for (int n = 0; n < cols; n++)
376cdf0e10cSrcweir             {
377cdf0e10cSrcweir                 fieldInfo(a, n);
378cdf0e10cSrcweir             }
379cdf0e10cSrcweir         }
380cdf0e10cSrcweir     }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir     /**
383cdf0e10cSrcweir      * updates the corresponding data to
384cdf0e10cSrcweir      * the control in guiRow and column
385cdf0e10cSrcweir      * @param guiRow 0 based row index
386cdf0e10cSrcweir      * @param column 0 based column index
387cdf0e10cSrcweir      * @return the propertyValue object corresponding to
388cdf0e10cSrcweir      * this control.
389cdf0e10cSrcweir      */
fieldInfo(int guiRow, int column)390cdf0e10cSrcweir     protected PropertyValue fieldInfo(int guiRow, int column)
391cdf0e10cSrcweir     {
392cdf0e10cSrcweir         if (guiRow + nscrollvalue < scrollfields.size())
393cdf0e10cSrcweir         {
394cdf0e10cSrcweir             return fieldInfo(
395cdf0e10cSrcweir                     ((PropertyValue[]) scrollfields.elementAt(guiRow + nscrollvalue))[column],
396cdf0e10cSrcweir                     ((PropertyValue[]) scrollfields.elementAt(guiRow))[column]);
397cdf0e10cSrcweir             //System.out.println("getting field info for : " + guiRow + "/" + column  + ":" + pv.Value + "(" + pv.Name + ")" );
398cdf0e10cSrcweir         }
399cdf0e10cSrcweir         else
400cdf0e10cSrcweir         {
401cdf0e10cSrcweir             return null;
402cdf0e10cSrcweir         }
403cdf0e10cSrcweir     }
404cdf0e10cSrcweir 
fieldInfo(PropertyValue valueProp, PropertyValue nameProp)405cdf0e10cSrcweir     protected PropertyValue fieldInfo(PropertyValue valueProp, PropertyValue nameProp)
406cdf0e10cSrcweir     {
407cdf0e10cSrcweir         if (CurUnoDialog.getDlgNameAccess().hasByName(nameProp.Name))
408cdf0e10cSrcweir         {
409cdf0e10cSrcweir             valueProp.Value = getControlData(nameProp.Name);
410cdf0e10cSrcweir         }
411cdf0e10cSrcweir         else
412cdf0e10cSrcweir         {
413cdf0e10cSrcweir             valueProp.Value = nameProp.Value;
414cdf0e10cSrcweir         }
415cdf0e10cSrcweir         return valueProp;
416cdf0e10cSrcweir     }
417cdf0e10cSrcweir 
unregisterControlGroup(int _index)418cdf0e10cSrcweir     protected void unregisterControlGroup(int _index)
419cdf0e10cSrcweir     {
420cdf0e10cSrcweir         scrollfields.remove(_index);
421cdf0e10cSrcweir     }
422cdf0e10cSrcweir 
registerControlGroup(PropertyValue[] _currowproperties, int _i)423cdf0e10cSrcweir     protected void registerControlGroup(PropertyValue[] _currowproperties, int _i)
424cdf0e10cSrcweir     {
425cdf0e10cSrcweir         if (_i == 0)
426cdf0e10cSrcweir         {
427cdf0e10cSrcweir             scrollfields.removeAllElements();
428cdf0e10cSrcweir         }
429cdf0e10cSrcweir         if (_i >= scrollfields.size())
430cdf0e10cSrcweir         {
431cdf0e10cSrcweir             scrollfields.addElement(_currowproperties);
432cdf0e10cSrcweir         }
433cdf0e10cSrcweir         else
434cdf0e10cSrcweir         {
435cdf0e10cSrcweir             scrollfields.setElementAt(_currowproperties, _i);
436cdf0e10cSrcweir         }
437cdf0e10cSrcweir     }
438cdf0e10cSrcweir 
getControlGroupInfo(int _i)439cdf0e10cSrcweir     protected PropertyValue[] getControlGroupInfo(int _i)
440cdf0e10cSrcweir     {
441cdf0e10cSrcweir         return (PropertyValue[]) scrollfields.elementAt(_i);
442cdf0e10cSrcweir     }
443cdf0e10cSrcweir 
setControlData(String controlname, Object newvalue)444cdf0e10cSrcweir     protected void setControlData(String controlname, Object newvalue)
445cdf0e10cSrcweir     {
446cdf0e10cSrcweir         Object oControlModel = UnoDialog.getModel(CurUnoDialog.xDlgContainer.getControl(controlname));
447cdf0e10cSrcweir         String propertyname = UnoDialog.getDisplayProperty(oControlModel);
448cdf0e10cSrcweir         if (!propertyname.equals(PropertyNames.EMPTY_STRING))
449cdf0e10cSrcweir         {
450cdf0e10cSrcweir             CurUnoDialog.setControlProperty(controlname, propertyname, newvalue);
451cdf0e10cSrcweir         }
452cdf0e10cSrcweir     }
453cdf0e10cSrcweir 
getControlData(String controlname)454cdf0e10cSrcweir     protected Object getControlData(String controlname)
455cdf0e10cSrcweir     {
456cdf0e10cSrcweir         Object oControlModel = UnoDialog.getModel(CurUnoDialog.xDlgContainer.getControl(controlname));
457cdf0e10cSrcweir         String propertyname = UnoDialog.getDisplayProperty(oControlModel);
458cdf0e10cSrcweir         if (!propertyname.equals(PropertyNames.EMPTY_STRING))
459cdf0e10cSrcweir         {
460cdf0e10cSrcweir             return CurUnoDialog.getControlProperty(controlname, propertyname);
461cdf0e10cSrcweir         }
462cdf0e10cSrcweir         else
463cdf0e10cSrcweir         {
464cdf0e10cSrcweir             return null;
465cdf0e10cSrcweir         }
466cdf0e10cSrcweir     }
467cdf0e10cSrcweir 
getScrollFieldValues()468cdf0e10cSrcweir     protected PropertyValue[][] getScrollFieldValues()
469cdf0e10cSrcweir     {
470cdf0e10cSrcweir         scrollRowsInfo();
471cdf0e10cSrcweir         PropertyValue[] curproperties;
472cdf0e10cSrcweir         PropertyValue[][] retproperties;
473cdf0e10cSrcweir         retproperties = new PropertyValue[scrollfields.size()][];
474cdf0e10cSrcweir         try
475cdf0e10cSrcweir         {
476cdf0e10cSrcweir             for (int i = 0; i < scrollfields.size(); i++)
477cdf0e10cSrcweir             {
478cdf0e10cSrcweir                 curproperties = (PropertyValue[]) scrollfields.elementAt(i);
479cdf0e10cSrcweir                 retproperties[i] = curproperties;
480cdf0e10cSrcweir             }
481cdf0e10cSrcweir             return retproperties;
482cdf0e10cSrcweir         }
483cdf0e10cSrcweir         catch (java.lang.Exception ex)
484cdf0e10cSrcweir         {
485cdf0e10cSrcweir             ex.printStackTrace(System.out);
486cdf0e10cSrcweir             return null;
487cdf0e10cSrcweir         }
488cdf0e10cSrcweir     }
489cdf0e10cSrcweir 
initializeScrollFields()490cdf0e10cSrcweir     protected abstract void initializeScrollFields();
491cdf0e10cSrcweir 
492cdf0e10cSrcweir     /** inserts a group of controls into the component. The group may either be a row or a column of controls
493cdf0e10cSrcweir      *  The controls should be put on Step 99 (means made invisible at first). All the controlrows that are needed are than
494cdf0e10cSrcweir      *  made visible automatically when calling "initialize(_fieldcount)"
495cdf0e10cSrcweir      * @author bc93774
496cdf0e10cSrcweir      * @param i: The index of the control group
497cdf0e10cSrcweir      * @param npos: Can be an x coordinate or an y coordinate which depends on the orientation of the scrollbar
498cdf0e10cSrcweir      */
insertControlGroup(int _index, int npos)499cdf0e10cSrcweir     protected abstract void insertControlGroup(int _index, int npos);
500cdf0e10cSrcweir 
setControlGroupVisible(int _index, boolean _bIsVisible)501cdf0e10cSrcweir     protected abstract void setControlGroupVisible(int _index, boolean _bIsVisible);
502cdf0e10cSrcweir }
503