xref: /aoo41x/main/svtools/workben/stest.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 #include <svtools/svmedit.hxx>
27cdf0e10cSrcweir #include <txtcmp.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX //autogen
30cdf0e10cSrcweir #include <vcl/button.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
33cdf0e10cSrcweir #include <vcl/fixed.hxx>
34cdf0e10cSrcweir #include <vcl/svapp.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir class MyApp : public Application
37cdf0e10cSrcweir {
38cdf0e10cSrcweir public:
39cdf0e10cSrcweir 	virtual void Main( );
40cdf0e10cSrcweir };
41cdf0e10cSrcweir 
42cdf0e10cSrcweir class SearchWindow : public WorkWindow
43cdf0e10cSrcweir {
44cdf0e10cSrcweir 	PushButton		aPB;
45cdf0e10cSrcweir 	FixedText 		aFT1, aFT2, aFT3;
46cdf0e10cSrcweir 	MultiLineEdit 	aEText, aESrch;
47cdf0e10cSrcweir 	RadioButton 	aModeN, aModeR, aModeL;
48cdf0e10cSrcweir 	SearchParam 	aParam;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir public:
51cdf0e10cSrcweir 					SearchWindow();
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 	DECL_LINK( ClickHdl, Button * );
54cdf0e10cSrcweir };
55cdf0e10cSrcweir 
56cdf0e10cSrcweir // --- SearchWindow::SearchWindow() ------------------------------------
57cdf0e10cSrcweir 
SearchWindow()58cdf0e10cSrcweir SearchWindow::SearchWindow() :
59cdf0e10cSrcweir 				WorkWindow( NULL, WinBits( WB_APP | WB_STDWORK )),
60cdf0e10cSrcweir 	aPB( this, WinBits( 0 )),
61cdf0e10cSrcweir 	aFT1( this, WinBits( 0 )),
62cdf0e10cSrcweir 	aFT2( this, WinBits( 0 )),
63cdf0e10cSrcweir 	aFT3( this, WinBits( 0 )),
64cdf0e10cSrcweir 	aEText( this, WinBits( WB_BORDER )),
65cdf0e10cSrcweir 	aESrch( this, WinBits( WB_BORDER )),
66cdf0e10cSrcweir 	aModeN( this, WinBits( 0 )),
67cdf0e10cSrcweir 	aModeR( this, WinBits( 0 )),
68cdf0e10cSrcweir 	aModeL( this, WinBits( 0 )),
69cdf0e10cSrcweir 	aParam( "" )
70cdf0e10cSrcweir {
71cdf0e10cSrcweir 	aPB.SetClickHdl( LINK( this, SearchWindow, ClickHdl ));
72cdf0e10cSrcweir 	aModeN.SetClickHdl( LINK( this, SearchWindow, ClickHdl ));
73cdf0e10cSrcweir 	aModeR.SetClickHdl( LINK( this, SearchWindow, ClickHdl ));
74cdf0e10cSrcweir 	aModeL.SetClickHdl( LINK( this, SearchWindow, ClickHdl ));
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	SetMapMode( MapMode( MAP_APPFONT ));
77cdf0e10cSrcweir 	SetSizePixel( LogicToPixel( Size( 300, 180 ) ) );
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	aEText.SetPosSizePixel( LogicToPixel( Point( 0, 22 )), LogicToPixel(Size( 270, 32 )) );
80cdf0e10cSrcweir 	aFT1.SetPosSizePixel( LogicToPixel( Point( 0, 10 )), LogicToPixel(Size( 18, 11 )) );
81cdf0e10cSrcweir 	aFT2.SetPosSizePixel( LogicToPixel( Point( 0, 60 )), LogicToPixel(Size( 24, 10 )) );
82cdf0e10cSrcweir 	aESrch.SetPosSizePixel( LogicToPixel( Point( 0, 70 )), LogicToPixel(Size( 270, 24 )) );
83cdf0e10cSrcweir 	aPB.SetPosSizePixel( LogicToPixel( Point( 223, 139 )), LogicToPixel(Size( 48, 12 )) );
84cdf0e10cSrcweir 	aFT3.SetPosSizePixel( LogicToPixel( Point( 0, 104 )), LogicToPixel(Size( 270, 15 )) );
85cdf0e10cSrcweir 	aModeN.SetPosSizePixel( LogicToPixel( Point( 5, 116 ) ), LogicToPixel( Size( 40, 12 ) ) );
86cdf0e10cSrcweir 	aModeR.SetPosSizePixel( LogicToPixel( Point( 5, 126 ) ), LogicToPixel( Size( 40, 12 ) ) );
87cdf0e10cSrcweir 	aModeL.SetPosSizePixel( LogicToPixel( Point( 5, 136 ) ), LogicToPixel( Size( 40, 12 ) ) );
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	aEText.Show();
90cdf0e10cSrcweir 	aFT1.Show();
91cdf0e10cSrcweir 	aFT2.Show();
92cdf0e10cSrcweir 	aESrch.Show();
93cdf0e10cSrcweir 	aPB.Show();
94cdf0e10cSrcweir 	aFT3.Show();
95cdf0e10cSrcweir 	aModeN.Show();
96cdf0e10cSrcweir 	aModeR.Show();
97cdf0e10cSrcweir 	aModeL.Show();
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 	aFT3.SetText( "gefunden:" );
100cdf0e10cSrcweir 	aFT1.SetText( "Text:" );
101cdf0e10cSrcweir 	aFT2.SetText( "Suche:" );
102cdf0e10cSrcweir 	aPB.SetText( "starte Suche" );
103cdf0e10cSrcweir 	aModeN.SetText( "normal" );
104cdf0e10cSrcweir 	aModeR.SetText( "RegExp" );
105cdf0e10cSrcweir 	aModeL.SetText( "LevDis" );
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	SetText( "Such-Demo" );
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 
111cdf0e10cSrcweir // --- SearchWindow::SearchSelectHdl() ---------------------------------
112cdf0e10cSrcweir 
IMPL_LINK(SearchWindow,ClickHdl,Button *,pButton)113cdf0e10cSrcweir IMPL_LINK( SearchWindow, ClickHdl, Button *, pButton )
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	if( pButton == &aPB )
116cdf0e10cSrcweir 	{
117cdf0e10cSrcweir 		String sText( aEText.GetText() );
118cdf0e10cSrcweir 		String sSrch( aESrch.GetText() );
119cdf0e10cSrcweir 
120cdf0e10cSrcweir /*		InfoBox( this, String( "T: " ) + sText +
121cdf0e10cSrcweir 					   String( "\nS: " ) + sSrch ).Execute();
122cdf0e10cSrcweir */
123cdf0e10cSrcweir 		sal_Bool bRet = sal_False;
124cdf0e10cSrcweir 		sal_uInt16 nStt = 0, nEnd = sText.Len();
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 		{
127cdf0e10cSrcweir 			aParam.SetSrchStr( sSrch );
128cdf0e10cSrcweir 			SearchText aSrchText( aParam, GetpApp()->GetAppInternational() );
129cdf0e10cSrcweir 			bRet = aSrchText.SearchFrwrd( sText, &nStt, &nEnd );
130cdf0e10cSrcweir 
131cdf0e10cSrcweir //			sal_Bool SearchBkwrd( const String &rStr, sal_uInt16* pStart, sal_uInt16* pEnde );
132cdf0e10cSrcweir 		}
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 		String sFound( "gefunden" );
135cdf0e10cSrcweir 		if( !bRet )
136cdf0e10cSrcweir 			sFound.Insert( "nicht ", 0 );
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 		sFound += ": S<";
139cdf0e10cSrcweir 		sFound += nStt;
140cdf0e10cSrcweir 		sFound += "> E<";
141cdf0e10cSrcweir 		sFound += nEnd;
142cdf0e10cSrcweir 		sFound += '>';
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 		if( bRet )
145cdf0e10cSrcweir 		{
146cdf0e10cSrcweir 			sFound += '<';
147cdf0e10cSrcweir 			sFound += sText.Copy( nStt, nEnd - nStt +1 );
148cdf0e10cSrcweir 			sFound += '>';
149cdf0e10cSrcweir 		}
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 		aFT3.SetText( sFound );
152cdf0e10cSrcweir 	}
153cdf0e10cSrcweir 	else if( pButton == &aModeN )
154cdf0e10cSrcweir 	{
155cdf0e10cSrcweir 		aParam.SetSrchType( SearchParam::SRCH_NORMAL );
156cdf0e10cSrcweir 	}
157cdf0e10cSrcweir 	else if( pButton == &aModeR )
158cdf0e10cSrcweir 	{
159cdf0e10cSrcweir 		aParam.SetSrchType( SearchParam::SRCH_REGEXP );
160cdf0e10cSrcweir 	}
161cdf0e10cSrcweir 	else if( pButton == &aModeL )
162cdf0e10cSrcweir 	{
163cdf0e10cSrcweir 		aParam.SetSrchType( SearchParam::SRCH_LEVDIST );
164cdf0e10cSrcweir 	}
165cdf0e10cSrcweir 	return 0;
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 
169cdf0e10cSrcweir // --- MyApp::Main() -----------------------------------------------
170cdf0e10cSrcweir 
Main()171cdf0e10cSrcweir void MyApp::Main( )
172cdf0e10cSrcweir {
173cdf0e10cSrcweir 	SearchWindow*	pSearchWindow = new SearchWindow;
174cdf0e10cSrcweir 	pSearchWindow->Show();
175cdf0e10cSrcweir 	Execute();
176cdf0e10cSrcweir 	delete pSearchWindow;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir }
179cdf0e10cSrcweir 
180cdf0e10cSrcweir // --- aMyApp ------------------------------------------------------
181cdf0e10cSrcweir 
182cdf0e10cSrcweir MyApp aMyApp;
183