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