xref: /aoo41x/main/svtools/workben/urange.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svtools.hxx"
30 
31 /* Test the SfxUShortRanges class */
32 
33 #ifndef _SFXITEMS_HXX
34 #include <sfxitems.hxx>
35 #endif
36 
37 sal_uInt16 nValues1[] = {340,472,482,4288,4374,4890,5026,5356,5724,6130,6186,6666,9222,9764,9908,
38 						10110,11302,11748,11946,12298,12344,12642,12958,13076,13410,13496,14462,
39 						14480,14592,16292,16788,17102,17792,17844,18182,18396,18522,18974,19292,
40 						19630,20336,21808,21972,22382,23568,25156,26978,27158,27730,28014,28280,
41 						28774,29258,30920,30938,31356,31582,32194,32734,32893,33757,33911,34013,
42 						34565,35283,38895,40273,41281,42157,44429,44553,45825,46367,48163,48417,
43 						49501,50499,52105,53035,53715,53899,54015,54131,54865,55155,55507,56325,
44 						57045,59243,59833,59859,59951,60361,61387,62453,62703,63155,63517,63621,
45 						63895,0};
46 
47 sal_uInt16 nValues2[] = {2362,3100,3286,3548,4056,4224,5058,5198,5398,5990,6910,7034,7046,8574,8762,
48 					9360,9494,9720,11432,12900,12946,13626,13844,14344,15028,16306,16494,16972,
49 					17340,17504,17610,18270,18506,19832,19962,20356,20792,21146,21270,21722,
50 					22486,22752,23554,24148,24210,24910,25006,25500,26464,26952,27216,28394,
51 					28398,29602,31130,31642,31894,33343,34191,34593,34931,36221,36637,37287,
52 					37765,39853,41231,41711,41799,44213,44863,46491,47459,48707,48911,49353,
53 					49923,49997,50117,51357,51519,52043,52563,52727,53781,54065,54249,55333,
54 					56549,57361,57777,58165,58507,59229,59719,60379,60845,62697,63123,65169,0};
55 
56 #include <sv.hxx>
57 
58 SfxUShortRanges aRanges1a( nValues1 );
59 SfxUShortRanges aRanges1b( nValues1 );
60 SfxUShortRanges aRanges1c( nValues1 );
61 SfxUShortRanges aRanges2( nValues2 );
62 
63 
64 String aStr1;
65 String aStr2;
66 String aStr3;
67 
68 
69 static String MakeString_Impl( SfxUShortRanges& aRanges )
70 {
71 	String aStr;
72 
73 	sal_uInt16 nPos = 0;
74 	const sal_uInt16* pRanges = ( const sal_uInt16*)aRanges;
75 
76 	while( pRanges[ nPos ] != 0 )
77 	{
78 		aStr += pRanges[ nPos ];
79 		aStr += " - ";
80 		aStr += pRanges[ nPos+1 ];
81 		aStr += ", ";
82 		nPos += 2;
83 	}
84 
85 
86 	return aStr;
87 }
88 
89 
90 // -------------------------------------------------------------------------
91 
92 class MyApp : public Application
93 {
94 public:
95   void Main( int, char* [] );
96 };
97 
98 // -------------------------------------------------------------------------
99 
100 class MyDialog : public ModalDialog
101 {
102 private:
103 	GroupBox aGroup1;
104 	MultiLineEdit aEdit1;
105 	GroupBox aGroup2;
106 	MultiLineEdit aEdit2;
107 	GroupBox aGroup3;
108 	MultiLineEdit aEdit3;
109 	OKButton      aBtn1;
110 	CancelButton  aBtn2;
111 
112 public:
113   MyDialog( Window* pParent );
114 
115   void MouseButtonDown( const MouseEvent& rMEvt );
116 };
117 
118 // -------------------------------------------------------------------------
119 
120 MyDialog::MyDialog( Window* pParent ) :
121 	ModalDialog( pParent, WB_STDMODAL | WB_3DLOOK ),
122 	aGroup1( this ),
123 	aEdit1( this, WB_BORDER | WB_READONLY ),
124 	aGroup2( this ),
125 	aEdit2( this, WB_BORDER | WB_READONLY ),
126 	aGroup3( this ),
127 	aEdit3( this, WB_BORDER | WB_READONLY ),
128 	aBtn1( this, WB_DEFBUTTON ),
129 	aBtn2( this )
130 {
131 	aGroup1.SetText( "Union" );
132 	aGroup1.SetPosSizePixel( Point( 5, 5 ), Size( 330, 80 ) );
133 	aGroup1.Show();
134 
135 	aEdit1.SetPosSizePixel( Point ( 10, 20 ), Size( 320, 60 ) );
136 	aEdit1.SetText( aStr1 );
137 	aEdit1.Show();
138 
139 	aGroup2.SetText( "Difference" );
140 	aGroup2.SetPosSizePixel( Point( 5, 90 ), Size( 330, 80 ) );
141 	aGroup2.Show();
142 
143 	aEdit2.SetPosSizePixel( Point( 10, 105 ), Size( 320, 60 ) );
144 	aEdit2.SetText( aStr2 );
145 	aEdit2.Show();
146 
147 	aGroup3.SetText( "Intersection" );
148 	aGroup3.SetPosSizePixel( Point( 5, 175 ), Size( 330, 80 ) );
149 	aGroup3.Show();
150 
151 	aEdit3.SetPosSizePixel( Point( 10, 190 ), Size( 320, 60 ) );
152 	aEdit3.SetText( aStr3 );
153 	aEdit3.Show();
154 
155 	aBtn1.SetPosSizePixel( Point( 10, 310 ), Size( 100, 25 ) );
156 	aBtn1.Show();
157 
158 	aBtn2.SetPosSizePixel( Point( 120, 310 ), Size( 100, 25 ) );
159 	aBtn2.Show();
160 
161 	SetOutputSizePixel( Size( 340, 345 ) );
162 	SetText( "SfxUShortRanges Test" );
163 }
164 
165 // -------------------------------------------------------------------------
166 
167 void MyDialog::MouseButtonDown( const MouseEvent& rMEvt )
168 {
169 }
170 
171 
172 // -------------------------------------------------------------------------
173 
174 class MyWin : public WorkWindow
175 {
176 public:
177   MyWin( Window* pParent, WinBits aWinStyle ) :
178 	WorkWindow( pParent, aWinStyle )
179   {}
180 
181   void MouseButtonDown( const MouseEvent& );
182 };
183 
184 
185 // -------------------------------------------------------------------------
186 
187 MyApp aMyApp;
188 
189 void MyApp::Main( int, char* [] )
190 {
191 	EnableSVLook();
192 	SetAppFont( System::GetStandardFont( STDFONT_APP ) );
193 
194 	MyWin aMainWin( NULL, WB_APP | WB_STDWORK );
195 	aMainWin.SetText( "SfxUShortRanges - Test" );
196 	aMainWin.Show();
197 
198 	aRanges1a += aRanges2;
199 	aRanges1b -= aRanges2;
200 	aRanges1c /= aRanges2;
201 
202 	aStr1 = MakeString_Impl( aRanges1a );
203 	aStr2 = MakeString_Impl( aRanges1b );
204 	aStr3 = MakeString_Impl( aRanges1c );
205 
206 	Execute();
207 }
208 
209 // -------------------------------------------------------------------------
210 
211 void MyWin::MouseButtonDown( const MouseEvent& rMEvt )
212 {
213   if( rMEvt.IsLeft() )
214 	{
215 	  MyDialog* pDialog = new MyDialog( this );
216 	  pDialog->Execute();
217 	  delete pDialog;
218 	}
219 }
220 
221