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