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