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