merge the formfield patch from ooo-build
[ooovba.git] / svtools / workben / stest.cxx
blobe4b5d6e135ff8d064a50a886f5cf8c995e15f4bb
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: stest.cxx,v $
10 * $Revision: 1.6 $
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"
33 #include <svtools/svmedit.hxx>
34 #include <txtcmp.hxx>
36 #ifndef _SV_BUTTON_HXX //autogen
37 #include <vcl/button.hxx>
38 #endif
39 #include <vcl/wrkwin.hxx>
40 #include <vcl/fixed.hxx>
41 #include <vcl/svapp.hxx>
43 class MyApp : public Application
45 public:
46 virtual void Main( );
49 class SearchWindow : public WorkWindow
51 PushButton aPB;
52 FixedText aFT1, aFT2, aFT3;
53 MultiLineEdit aEText, aESrch;
54 RadioButton aModeN, aModeR, aModeL;
55 SearchParam aParam;
57 public:
58 SearchWindow();
60 DECL_LINK( ClickHdl, Button * );
63 // --- SearchWindow::SearchWindow() ------------------------------------
65 SearchWindow::SearchWindow() :
66 WorkWindow( NULL, WinBits( WB_APP | WB_STDWORK )),
67 aPB( this, WinBits( 0 )),
68 aFT1( this, WinBits( 0 )),
69 aFT2( this, WinBits( 0 )),
70 aFT3( this, WinBits( 0 )),
71 aEText( this, WinBits( WB_BORDER )),
72 aESrch( this, WinBits( WB_BORDER )),
73 aModeN( this, WinBits( 0 )),
74 aModeR( this, WinBits( 0 )),
75 aModeL( this, WinBits( 0 )),
76 aParam( "" )
78 aPB.SetClickHdl( LINK( this, SearchWindow, ClickHdl ));
79 aModeN.SetClickHdl( LINK( this, SearchWindow, ClickHdl ));
80 aModeR.SetClickHdl( LINK( this, SearchWindow, ClickHdl ));
81 aModeL.SetClickHdl( LINK( this, SearchWindow, ClickHdl ));
83 SetMapMode( MapMode( MAP_APPFONT ));
84 SetSizePixel( LogicToPixel( Size( 300, 180 ) ) );
86 aEText.SetPosSizePixel( LogicToPixel( Point( 0, 22 )), LogicToPixel(Size( 270, 32 )) );
87 aFT1.SetPosSizePixel( LogicToPixel( Point( 0, 10 )), LogicToPixel(Size( 18, 11 )) );
88 aFT2.SetPosSizePixel( LogicToPixel( Point( 0, 60 )), LogicToPixel(Size( 24, 10 )) );
89 aESrch.SetPosSizePixel( LogicToPixel( Point( 0, 70 )), LogicToPixel(Size( 270, 24 )) );
90 aPB.SetPosSizePixel( LogicToPixel( Point( 223, 139 )), LogicToPixel(Size( 48, 12 )) );
91 aFT3.SetPosSizePixel( LogicToPixel( Point( 0, 104 )), LogicToPixel(Size( 270, 15 )) );
92 aModeN.SetPosSizePixel( LogicToPixel( Point( 5, 116 ) ), LogicToPixel( Size( 40, 12 ) ) );
93 aModeR.SetPosSizePixel( LogicToPixel( Point( 5, 126 ) ), LogicToPixel( Size( 40, 12 ) ) );
94 aModeL.SetPosSizePixel( LogicToPixel( Point( 5, 136 ) ), LogicToPixel( Size( 40, 12 ) ) );
96 aEText.Show();
97 aFT1.Show();
98 aFT2.Show();
99 aESrch.Show();
100 aPB.Show();
101 aFT3.Show();
102 aModeN.Show();
103 aModeR.Show();
104 aModeL.Show();
106 aFT3.SetText( "gefunden:" );
107 aFT1.SetText( "Text:" );
108 aFT2.SetText( "Suche:" );
109 aPB.SetText( "starte Suche" );
110 aModeN.SetText( "normal" );
111 aModeR.SetText( "RegExp" );
112 aModeL.SetText( "LevDis" );
114 SetText( "Such-Demo" );
118 // --- SearchWindow::SearchSelectHdl() ---------------------------------
120 IMPL_LINK( SearchWindow, ClickHdl, Button *, pButton )
122 if( pButton == &aPB )
124 String sText( aEText.GetText() );
125 String sSrch( aESrch.GetText() );
127 /* InfoBox( this, String( "T: " ) + sText +
128 String( "\nS: " ) + sSrch ).Execute();
130 BOOL bRet = FALSE;
131 USHORT nStt = 0, nEnd = sText.Len();
134 aParam.SetSrchStr( sSrch );
135 SearchText aSrchText( aParam, GetpApp()->GetAppInternational() );
136 bRet = aSrchText.SearchFrwrd( sText, &nStt, &nEnd );
138 // BOOL SearchBkwrd( const String &rStr, USHORT* pStart, USHORT* pEnde );
141 String sFound( "gefunden" );
142 if( !bRet )
143 sFound.Insert( "nicht ", 0 );
145 sFound += ": S<";
146 sFound += nStt;
147 sFound += "> E<";
148 sFound += nEnd;
149 sFound += '>';
151 if( bRet )
153 sFound += '<';
154 sFound += sText.Copy( nStt, nEnd - nStt +1 );
155 sFound += '>';
158 aFT3.SetText( sFound );
160 else if( pButton == &aModeN )
162 aParam.SetSrchType( SearchParam::SRCH_NORMAL );
164 else if( pButton == &aModeR )
166 aParam.SetSrchType( SearchParam::SRCH_REGEXP );
168 else if( pButton == &aModeL )
170 aParam.SetSrchType( SearchParam::SRCH_LEVDIST );
172 return 0;
176 // --- MyApp::Main() -----------------------------------------------
178 void MyApp::Main( )
180 SearchWindow* pSearchWindow = new SearchWindow;
181 pSearchWindow->Show();
182 Execute();
183 delete pSearchWindow;
187 // --- aMyApp ------------------------------------------------------
189 MyApp aMyApp;