merge the formfield patch from ooo-build
[ooovba.git] / basic / source / app / dialogs.cxx
blobfa770f985fcceac0671a9008bd70af0800da80d4
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: dialogs.cxx,v $
10 * $Revision: 1.37 $
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_basic.hxx"
33 #include <tools/solar.h>
35 #include <algorithm>
36 #include <tools/rc.hxx>
37 #include <vcl/metric.hxx>
38 #ifndef _DIALOG_HXX //autogen
39 #include <vcl/dialog.hxx>
40 #endif
41 #ifndef _BUTTON_HXX //autogen
42 #include <vcl/button.hxx>
43 #endif
44 #ifndef _FIXED_HXX //autogen
45 #include <vcl/fixed.hxx>
46 #endif
47 #ifndef _EDIT_HXX //autogen
48 #include <vcl/edit.hxx>
49 #endif
50 #include <tools/config.hxx>
51 #ifndef _MSGBOX_HXX //autogen
52 #include <vcl/msgbox.hxx>
53 #endif
54 #include <tools/debug.hxx>
55 #ifndef _SV_FILEDLG_HXX //autogen
56 #include <svtools/filedlg.hxx>
57 #endif
58 #include <tools/stream.hxx>
59 #include <tools/fsys.hxx>
60 #include <svtools/stringtransfer.hxx>
61 #include <vcl/splitwin.hxx>
62 #ifndef _ZFORLIST_HXX //autogen
63 #include <svtools/zformat.hxx>
64 #endif
65 #include <svtools/ctrltool.hxx>
67 // Ohne Includeschutz
68 #include <svtools/svtdata.hxx>
69 #include <svtools/solar.hrc>
72 #include <basic/dispdefs.hxx>
73 #include <basic/testtool.hxx>
74 #include "dialogs.hxx"
75 #include "resids.hrc"
76 #include "basic.hrc"
78 #include "app.hxx"
79 #include "basrid.hxx"
81 #include "_version.h"
83 AboutDialog::AboutDialog( Window* pParent, const ResId& id )
84 : ModalDialog( pParent, id )
85 , a1( this, ResId( 1, *id.GetResMgr() ) )
86 , a4( this, ResId( 4, *id.GetResMgr() ) )
87 , aVersionString( this, ResId( RID_VERSIONSTRING, *id.GetResMgr() ) )
88 , aOk ( this, ResId( RID_OK, *id.GetResMgr() ) )
90 FreeResource();
93 ////////////////////////////////////////////////////////////////////
95 FindDialog::FindDialog( Window* pParent, const ResId& id, String& Text )
96 : ModalDialog( pParent, id )
97 , aFT1( this, ResId( RID_FIXEDTEXT1, *id.GetResMgr() ) )
98 , aFind( this, ResId( RID_FIND, *id.GetResMgr() ) )
99 , aOk( this, ResId( RID_OK, *id.GetResMgr() ) )
100 , aCancel( this, ResId( RID_CANCEL, *id.GetResMgr() ) )
102 FreeResource();
103 pFind = &Text;
104 // Button-Handler:
105 aOk.SetClickHdl( LINK( this, FindDialog, ButtonClick ) );
106 aCancel.SetClickHdl( LINK( this, FindDialog, ButtonClick ) );
107 aFind.SetText( Text );
110 IMPL_LINK_INLINE_START( FindDialog, ButtonClick, Button *, pB )
112 if( pB == &aOk ) {
113 *pFind = aFind.GetText();
114 EndDialog( TRUE );
115 } else EndDialog( FALSE );
116 return TRUE;
118 IMPL_LINK_INLINE_END( FindDialog, ButtonClick, Button *, pB )
120 ReplaceDialog::ReplaceDialog(Window* pParent, const ResId& id, String& Old, String& New )
121 : ModalDialog( pParent, id )
122 , aFT1( this, ResId( RID_FIXEDTEXT1, *id.GetResMgr() ) )
123 , aFT2( this, ResId( RID_FIXEDTEXT2, *id.GetResMgr() ) )
124 , aFind( this, ResId( RID_FIND, *id.GetResMgr() ) )
125 , aReplace(this, ResId( RID_REPLACE, *id.GetResMgr() ) )
126 , aOk( this, ResId( RID_OK, *id.GetResMgr() ) )
127 , aCancel( this, ResId( RID_CANCEL, *id.GetResMgr() ) )
129 FreeResource();
130 pFind = &Old;
131 pReplace = &New;
132 // Button-Handler:
133 aOk.SetClickHdl( LINK( this, ReplaceDialog, ButtonClick ) );
134 aCancel.SetClickHdl( LINK( this, ReplaceDialog, ButtonClick ) );
135 aFind.SetText( Old );
136 aReplace.SetText( New );
139 IMPL_LINK( ReplaceDialog, ButtonClick, Button *, pB )
141 if( pB == &aOk ) {
142 *pFind = aFind.GetText();
143 *pReplace = aReplace.GetText();
144 EndDialog( TRUE );
145 } else EndDialog( FALSE );
146 return TRUE;
149 ////////////////////////////////////////////////////////////////////
152 void CheckButtons( ComboBox &aCB, Button &aNewB, Button &aDelB )
154 aNewB.Enable( aCB.GetEntryPos( aCB.GetText() ) == COMBOBOX_ENTRY_NOTFOUND && aCB.GetText().Len() );
155 aDelB.Enable( aCB.GetEntryPos( aCB.GetText() ) != COMBOBOX_ENTRY_NOTFOUND );
159 void ConfEdit::Init( Config &aConf )
161 aConf.SetGroup("Misc");
162 ByteString aCurrentProfile = aConf.ReadKey( "CurrentProfile", "Path" );
163 aConf.SetGroup( aCurrentProfile );
165 String aTemp = UniString( aConf.ReadKey( aKeyName ), RTL_TEXTENCODING_UTF8 );
166 aEdit.SetText( aTemp );
169 ConfEdit::ConfEdit( Window* pParent, USHORT nResText, USHORT nResEdit, USHORT nResButton, const ByteString& aKN, Config &aConf )
170 : PushButton( pParent, SttResId(nResButton) )
171 , aText( pParent, SttResId(nResText) )
172 , aEdit( pParent, SttResId(nResEdit) )
173 , aKeyName(aKN)
175 Init( aConf );
178 ConfEdit::ConfEdit( Window* pParent, USHORT nResEdit, USHORT nResButton, const ByteString& aKN, Config &aConf )
179 : PushButton( pParent, SttResId(nResButton) )
180 , aText( pParent )
181 , aEdit( pParent, SttResId(nResEdit) )
182 , aKeyName(aKN)
184 Init( aConf );
185 aText.Hide();
188 void ConfEdit::Save( Config &aConf )
190 aConf.SetGroup("Misc");
191 ByteString aCurrentProfile = aConf.ReadKey( "CurrentProfile", "Path" );
192 aConf.SetGroup( aCurrentProfile );
193 aConf.WriteKey( aKeyName, ByteString( aEdit.GetText(), RTL_TEXTENCODING_UTF8 ) );
196 void ConfEdit::Reload( Config &aConf )
198 aConf.SetGroup("Misc");
199 ByteString aCurrentProfile = aConf.ReadKey( "CurrentProfile", "Path" );
200 aConf.SetGroup( aCurrentProfile );
201 String aValue = String( aConf.ReadKey( aKeyName ), RTL_TEXTENCODING_UTF8 );
202 aEdit.SetText( aValue );
205 void ConfEdit::Click()
207 PathDialog aPD( this );
208 aPD.SetPath( aEdit.GetText() );
209 if ( aPD.Execute() )
211 aEdit.SetText( aPD.GetPath() );
212 aEdit.Modify();
216 OptConfEdit::OptConfEdit( Window* pParent, USHORT nResCheck, USHORT nResEdit, USHORT nResButton, const ByteString& aKN, ConfEdit& rBaseEdit, Config& aConf )
217 : ConfEdit( pParent, nResEdit, nResButton, aKN, aConf )
218 , aCheck( pParent, SttResId( nResCheck ) )
219 , rBase( rBaseEdit )
221 aCheck.SetToggleHdl( LINK( this, OptConfEdit, ToggleHdl ) );
222 rBase.SetModifyHdl( LINK( this, OptConfEdit, BaseModifyHdl ) );
225 void OptConfEdit::Reload( Config &aConf )
227 ConfEdit::Reload( aConf );
229 DirEntry aCalculatedHIDDir( rBase.GetValue() );
230 aCalculatedHIDDir += DirEntry( "global/hid", FSYS_STYLE_FAT );
232 DirEntry aCurrentHIDDir( aEdit.GetText() );
234 aCheck.Check( aCalculatedHIDDir == aCurrentHIDDir || aEdit.GetText().Len() == 0 );
235 aEdit.Enable( !aCheck.IsChecked() );
236 Enable( !aCheck.IsChecked() );
239 IMPL_LINK( OptConfEdit, ToggleHdl, CheckBox*, EMPTYARG )
241 BaseModifyHdl( &aEdit );
242 aEdit.Enable( !aCheck.IsChecked() );
243 Enable( !aCheck.IsChecked() );
244 return 0;
247 IMPL_LINK( OptConfEdit, BaseModifyHdl, Edit*, EMPTYARG )
249 if ( aCheck.IsChecked() )
251 DirEntry aCalculatedHIDDir( rBase.GetValue() );
252 aCalculatedHIDDir += DirEntry( "global/hid", FSYS_STYLE_FAT );
253 aEdit.SetText( aCalculatedHIDDir.GetFull() );
255 return 0;
259 OptionsDialog::OptionsDialog( Window* pParent, const ResId& aResId )
260 : TabDialog( pParent, aResId )
261 , aTabCtrl( this, ResId( RES_TC_OPTIONS, *aResId.GetResMgr() ) )
262 , aOK( this )
263 , aCancel( this )
264 , aConfig( Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") ) )
266 aConfig.EnablePersistence( FALSE );
267 FreeResource();
268 aTabCtrl.SetActivatePageHdl( LINK( this, OptionsDialog, ActivatePageHdl ) );
269 aTabCtrl.SetCurPageId( RID_TP_PRO );
270 ActivatePageHdl( &aTabCtrl );
272 aOK.SetClickHdl( LINK( this, OptionsDialog, OKClick ) );
274 aOK.Show();
275 aCancel.Show();
278 OptionsDialog::~OptionsDialog()
280 for ( USHORT i = 0; i < aTabCtrl.GetPageCount(); i++ )
281 delete aTabCtrl.GetTabPage( aTabCtrl.GetPageId( i ) );
284 BOOL OptionsDialog::Close()
286 if ( TabDialog::Close() )
288 delete this;
289 return TRUE;
291 else
292 return FALSE;
296 IMPL_LINK( OptionsDialog, ActivatePageHdl, TabControl *, pTabCtrl )
298 USHORT nId = pTabCtrl->GetCurPageId();
299 // If TabPage was not yet created, do it
300 if ( !pTabCtrl->GetTabPage( nId ) )
302 TabPage *pNewTabPage = NULL;
303 switch ( nId )
305 case RID_TP_GEN:
306 pNewTabPage = new GenericOptions( pTabCtrl, aConfig );
307 break;
308 case RID_TP_PRO:
309 pNewTabPage = new ProfileOptions( pTabCtrl, aConfig );
310 break;
311 case RID_TP_CRA:
312 pNewTabPage = new CrashreportOptions( pTabCtrl, aConfig );
313 break;
314 case RID_TP_MIS:
315 pNewTabPage = new MiscOptions( pTabCtrl, aConfig );
316 break;
317 case RID_TP_FON:
318 pNewTabPage = new FontOptions( pTabCtrl, aConfig );
319 break;
320 default: DBG_ERROR( "PageHdl: Unbekannte ID!" );
322 DBG_ASSERT( pNewTabPage, "Keine Page!" );
323 pTabCtrl->SetTabPage( nId, pNewTabPage );
325 return 0;
331 IMPL_LINK( OptionsDialog, OKClick, Button *, pButton )
333 (void) pButton; /* avoid warning about unused parameter */
334 aConfig.EnablePersistence();
335 GenericOptions *pGeneric;
336 pGeneric = (GenericOptions*)aTabCtrl.GetTabPage( RID_TP_GEN );
337 if ( pGeneric )
338 pGeneric->Save( aConfig );
340 ProfileOptions *pProfile;
341 pProfile = (ProfileOptions*)aTabCtrl.GetTabPage( RID_TP_PRO );
342 if ( pProfile )
343 pProfile->Save( aConfig );
345 CrashreportOptions *pCrash;
346 pCrash = (CrashreportOptions*)aTabCtrl.GetTabPage( RID_TP_CRA );
347 if ( pCrash )
348 pCrash->Save( aConfig );
350 MiscOptions *pMisc;
351 pMisc = (MiscOptions*)aTabCtrl.GetTabPage( RID_TP_MIS );
352 if ( pMisc )
353 pMisc->Save( aConfig );
355 FontOptions *pFonts;
356 pFonts = (FontOptions*)aTabCtrl.GetTabPage( RID_TP_FON );
357 if ( pFonts )
358 pFonts->Save( aConfig );
360 aConfig.Flush();
362 ((BasicApp*)GetpApp())->LoadIniFile();
363 Close();
364 return 0;
367 const ByteString ProfilePrefix("_profile_");
368 const USHORT ProfilePrefixLen = ProfilePrefix.Len();
370 ProfileOptions::ProfileOptions( Window* pParent, Config &rConfig )
371 : TabPage( pParent, SttResId( RID_TP_PROFILE ) )
372 , rConf( rConfig )
374 , aFlProfile( this, SttResId( RID_FL_PROFILE ) )
375 , aCbProfile( this, SttResId( RID_CB_PROFILE ) )
376 , aPbNewProfile( this, SttResId( RID_PB_NEW_PROFILE ) )
377 , aPbDelProfile( this, SttResId( RID_PD_DEL_PROFILE ) )
379 , aDirs( this, SttResId(FL_DIRECTORIES) )
380 , aLog( this, LOG_TEXT, LOG_NAME, LOG_SET, "LogBaseDir", rConfig )
381 , aBasis( this, BASIS_TEXT, BASIS_NAME, BASIS_SET, "BaseDir", rConfig )
382 , aHID( this, HID_CHECK, HID_NAME, HID_SET, "HIDDir", aBasis, rConfig )
384 , aAutoReload( this, SttResId(CB_AUTORELOAD) )
385 , aAutoSave( this, SttResId(CB_AUTOSAVE) )
386 , aStopOnSyntaxError( this, SttResId(CB_STOPONSYNTAXERRORS) )
388 FreeResource();
390 aCbProfile.EnableAutocomplete( TRUE );
392 aCbProfile.SetSelectHdl( LINK( this, ProfileOptions, Select ) );
394 aPbNewProfile.SetClickHdl( LINK( this, ProfileOptions, NewProfile ) );
395 aPbDelProfile.SetClickHdl( LINK( this, ProfileOptions, DelProfile ) );
396 aCbProfile.SetModifyHdl( LINK( this, ProfileOptions, CheckButtonsHdl ) );
398 LoadData();
399 ReloadProfile();
402 void ProfileOptions::LoadData()
404 // collect all profiles (all groups starting with the ProfilePrefix)
405 for ( USHORT i = 0 ; i < rConf.GetGroupCount() ; i++ )
407 ByteString aProfile = rConf.GetGroupName( i );
408 if ( aProfile.Match( ProfilePrefix ) )
409 aCbProfile.InsertEntry( String( aProfile.Copy( ProfilePrefixLen ), RTL_TEXTENCODING_UTF8 ) );
411 // set the current profile
412 rConf.SetGroup( "Misc" );
413 ByteString aCurrentProfile = rConf.ReadKey( "CurrentProfile", "Path" );
414 aCbProfile.SetText( String( aCurrentProfile.Copy( ProfilePrefixLen ), RTL_TEXTENCODING_UTF8 ) );
415 CheckButtons( aCbProfile, aPbNewProfile, aPbDelProfile );
418 IMPL_LINK( ProfileOptions, Select, ComboBox*, EMPTYARG )
420 if ( aCbProfile.GetEntryPos( aCbProfile.GetText() ) == LISTBOX_ENTRY_NOTFOUND )
421 return 1;
422 Save();
423 ByteString aProfileKey( ByteString( ProfilePrefix ).Append( ByteString( aCbProfile.GetText(), RTL_TEXTENCODING_UTF8 ) ) );
424 rConf.SetGroup( "Misc" );
425 rConf.WriteKey( "CurrentProfile", aProfileKey );
426 ReloadProfile();
428 return 0;
431 void ProfileOptions::ReloadProfile()
433 aLog.Reload( rConf );
434 aBasis.Reload( rConf );
435 aHID.Reload( rConf );
437 ByteString aTemp;
438 rConf.SetGroup( "Misc" );
439 ByteString aCurrentProfile = rConf.ReadKey( "CurrentProfile", "Misc" );
440 rConf.SetGroup( aCurrentProfile );
441 aTemp = rConf.ReadKey( "AutoReload", "0" );
442 aAutoReload.Check( aTemp.Equals("1") );
443 aTemp = rConf.ReadKey( "AutoSave", "0" );
444 aAutoSave.Check( aTemp.Equals("1") );
445 aTemp = rConf.ReadKey( "StopOnSyntaxError", "0" );
446 aStopOnSyntaxError.Check( aTemp.Equals("1") );
448 CheckButtons( aCbProfile, aPbNewProfile, aPbDelProfile );
451 IMPL_LINK( ProfileOptions, DelProfile, Button*, EMPTYARG )
453 String aProfile = aCbProfile.GetText();
454 ByteString aProfileKey( ByteString( ProfilePrefix ).Append( ByteString( aProfile, RTL_TEXTENCODING_UTF8 ) ) );
455 if ( aCbProfile.GetEntryPos( aProfile ) != COMBOBOX_ENTRY_NOTFOUND )
457 aCbProfile.RemoveEntry( aProfile );
458 rConf.DeleteGroup( aProfileKey );
460 // Set first remaining profile as current profile
461 aCbProfile.SetText( aCbProfile.GetEntry( 0 ) );
462 aProfile = aCbProfile.GetText();
463 aProfileKey = ByteString( ProfilePrefix ).Append( ByteString( aProfile, RTL_TEXTENCODING_UTF8 ) );
464 rConf.SetGroup( "Misc" );
465 rConf.WriteKey( "CurrentProfile", aProfileKey );
466 ReloadProfile();
467 CheckButtons( aCbProfile, aPbNewProfile, aPbDelProfile );
469 return 0;
472 IMPL_LINK( ProfileOptions, NewProfile, Button*, EMPTYARG )
474 aCbProfile.InsertEntry( aCbProfile.GetText() );
475 ByteString aProfileKey( ByteString( ProfilePrefix ).Append( ByteString( aCbProfile.GetText(), RTL_TEXTENCODING_UTF8 ) ) );
476 rConf.SetGroup( "Misc" );
477 rConf.WriteKey( "CurrentProfile", aProfileKey );
478 // save last profile as new data for new profile
479 Save();
480 CheckButtons( aCbProfile, aPbNewProfile, aPbDelProfile );
482 return 0;
485 IMPL_LINK( ProfileOptions, CheckButtonsHdl, ComboBox*, pCB )
487 (void) pCB; /* avoid warning about unused parameter */
488 CheckButtons( aCbProfile, aPbNewProfile, aPbDelProfile );
489 return 0;
492 void ProfileOptions::Save()
494 Save(rConf);
497 void ProfileOptions::Save( Config &rConfig )
499 // save data to current profile
500 aLog.Save( rConfig );
501 aBasis.Save( rConfig );
502 aHID.Save( rConfig );
504 rConfig.SetGroup( "Misc" );
505 ByteString aCurrentProfile = rConfig.ReadKey( "CurrentProfile", "Misc" );
506 rConfig.SetGroup( aCurrentProfile );
507 rConfig.WriteKey( "AutoReload", aAutoReload.IsChecked()?"1":"0" );
508 rConfig.WriteKey( "AutoSave", aAutoSave.IsChecked()?"1":"0" );
509 rConfig.WriteKey( "StopOnSyntaxError", aStopOnSyntaxError.IsChecked()?"1":"0" );
512 CrashreportOptions::CrashreportOptions( Window* pParent, Config &aConfig )
513 : TabPage( pParent, SttResId( RID_TP_CRASH ) )
514 , aFLCrashreport( this, SttResId( FL_CRASHREPORT ) )
515 , aCBUseProxy( this, SttResId( CB_USEPROXY ) )
516 , aFTCRHost( this, SttResId( FT_CRHOST ) )
517 , aEDCRHost( this, SttResId( ED_CRHOST ) )
518 , aFTCRPort( this, SttResId( FT_CRPORT ) )
519 , aNFCRPort( this, SttResId( NF_CRPORT ) )
520 , aCBAllowContact( this, SttResId( CB_ALLOWCONTACT ) )
521 , aFTEMail( this, SttResId( FT_EMAIL ) )
522 , aEDEMail( this, SttResId( ED_EMAIL ) )
524 FreeResource();
526 aNFCRPort.SetUseThousandSep( FALSE );
528 ByteString aTemp;
530 aConfig.SetGroup("Crashreporter");
532 aTemp = aConfig.ReadKey( "UseProxy", "false" );
533 if ( aTemp.EqualsIgnoreCaseAscii( "true" ) || aTemp.Equals( "1" ) )
534 aCBUseProxy.Check();
535 else
536 aCBUseProxy.Check( FALSE );
538 aCBUseProxy.SetToggleHdl( LINK( this, CrashreportOptions, CheckProxy ) );
539 LINK( this, CrashreportOptions, CheckProxy ).Call( NULL ); // call once to initialize
541 aTemp = aConfig.ReadKey( "ProxyServer" );
542 aEDCRHost.SetText( String( aTemp, RTL_TEXTENCODING_UTF8 ) );
543 aTemp = aConfig.ReadKey( "ProxyPort", "8080" );
544 aNFCRPort.SetValue( aTemp.ToInt32() );
547 aTemp = aConfig.ReadKey( "AllowContact", "false" );
548 if ( aTemp.EqualsIgnoreCaseAscii( "true" ) || aTemp.Equals( "1" ) )
549 aCBAllowContact.Check();
550 else
551 aCBAllowContact.Check( FALSE );
553 aCBAllowContact.SetToggleHdl( LINK( this, CrashreportOptions, CheckResponse ) );
554 LINK( this, CrashreportOptions, CheckResponse ).Call( NULL ); // call once to initialize
556 aTemp = aConfig.ReadKey( "ReturnAddress" );
557 aEDEMail.SetText( String( aTemp, RTL_TEXTENCODING_UTF8 ) );
561 void CrashreportOptions::Save( Config &aConfig )
563 aConfig.SetGroup("Crashreporter");
565 if ( aCBUseProxy.IsChecked() )
566 aConfig.WriteKey( "UseProxy", "true" );
567 else
568 aConfig.WriteKey( "UseProxy", "false" );
570 aConfig.WriteKey( "ProxyServer", ByteString( aEDCRHost.GetText(), RTL_TEXTENCODING_UTF8 ) );
571 aConfig.WriteKey( "ProxyPort", ByteString::CreateFromInt64( aNFCRPort.GetValue() ) );
573 if ( aCBAllowContact.IsChecked() )
574 aConfig.WriteKey( "AllowContact", "true" );
575 else
576 aConfig.WriteKey( "AllowContact", "false" );
578 aConfig.WriteKey( "ReturnAddress", ByteString( aEDEMail.GetText(), RTL_TEXTENCODING_UTF8 ) );
581 IMPL_LINK( CrashreportOptions, CheckProxy, void*, EMPTYARG )
583 aFTCRHost.Enable( aCBUseProxy.IsChecked() );
584 aEDCRHost.Enable( aCBUseProxy.IsChecked() );
585 aFTCRPort.Enable( aCBUseProxy.IsChecked() );
586 aNFCRPort.Enable( aCBUseProxy.IsChecked() );
588 return 0;
590 IMPL_LINK( CrashreportOptions, CheckResponse, void*, EMPTYARG )
592 aFTEMail.Enable( aCBAllowContact.IsChecked() );
593 aEDEMail.Enable( aCBAllowContact.IsChecked() );
594 return 0;
597 MiscOptions::MiscOptions( Window* pParent, Config &aConfig )
598 : TabPage( pParent, SttResId( RID_TP_MISC ) )
599 , aFLCommunication( this, SttResId(FL_COMMUNICATION) )
600 , aFTHost( this, SttResId(FT_HOST) )
601 , aEDHost( this, SttResId(ED_HOST) )
602 , aFTTTPort( this, SttResId(FT_TTPORT) )
603 , aNFTTPort( this, SttResId(NF_TTPORT) )
604 , aFTUNOPort( this, SttResId(FT_UNOPORT) )
605 , aNFUNOPort( this, SttResId(NF_UNOPORT) )
606 , aOther( this, SttResId(FL_OTHER) )
607 , aTimeoutText( this, SttResId(TIMEOUT_TEXT) )
608 , aServerTimeout( this, SttResId(SERVER_TIMEOUT) )
609 , aFTLRU( this, SttResId(FT_LRU) )
610 , aTFMaxLRU( this, SttResId(TF_MAX_LRU) )
611 , aFTProgDir( this, SttResId(FT_PROGDIR) )
612 , aEDProgDir( this, SttResId(ED_PROGDIR) )
613 , aPBProgDir( this, SttResId(PB_PROGDIR) )
615 FreeResource();
617 aNFTTPort.SetUseThousandSep( FALSE );
618 aNFUNOPort.SetUseThousandSep( FALSE );
619 aTFMaxLRU.SetUseThousandSep( FALSE );
621 ByteString aTemp;
623 aConfig.SetGroup("Communication");
624 aTemp = aConfig.ReadKey( "Host", DEFAULT_HOST );
625 aEDHost.SetText( String( aTemp, RTL_TEXTENCODING_UTF8 ) );
626 aTemp = aConfig.ReadKey( "TTPort", ByteString::CreateFromInt32( TESTTOOL_DEFAULT_PORT ) );
627 aNFTTPort.SetValue( aTemp.ToInt32() );
628 aTemp = aConfig.ReadKey( "UnoPort", ByteString::CreateFromInt32( UNO_DEFAULT_PORT ) );
629 aNFUNOPort.SetValue( aTemp.ToInt32() );
631 aConfig.SetGroup("Misc");
632 aTemp = aConfig.ReadKey( "ServerTimeout", "10000" ); // Default 1 Minute
633 aServerTimeout.SetTime( Time(aTemp.ToInt32()) );
635 aConfig.SetGroup("LRU");
636 aTemp = aConfig.ReadKey( "MaxLRU", "4" );
637 aTFMaxLRU.SetValue( aTemp.ToInt32() );
639 aConfig.SetGroup("OOoProgramDir");
640 aTemp = aConfig.ReadKey( "Current" );
641 aEDProgDir.SetText( String( aTemp, RTL_TEXTENCODING_UTF8 ) );
642 aPBProgDir.SetClickHdl( LINK( this, MiscOptions, Click ) );
645 IMPL_LINK( MiscOptions, Click, void*, EMPTYARG )
647 PathDialog aPD( this );
648 aPD.SetPath( aEDProgDir.GetText() );
649 if ( aPD.Execute() )
650 aEDProgDir.SetText( aPD.GetPath() );
651 return 0;
655 void MiscOptions::Save( Config &aConfig )
657 aConfig.SetGroup("Communication");
658 aConfig.WriteKey( "Host", ByteString( aEDHost.GetText(), RTL_TEXTENCODING_UTF8 ) );
659 aConfig.WriteKey( "TTPort", ByteString::CreateFromInt64( aNFTTPort.GetValue() ) );
660 aConfig.WriteKey( "UnoPort", ByteString::CreateFromInt64( aNFUNOPort.GetValue() ) );
662 aConfig.SetGroup("Misc");
663 aConfig.WriteKey( "ServerTimeout", ByteString::CreateFromInt32( aServerTimeout.GetTime().GetTime() ) );
665 aConfig.SetGroup("LRU");
666 ByteString aTemp = aConfig.ReadKey( "MaxLRU", "4" );
667 USHORT nOldMaxLRU = (USHORT)aTemp.ToInt32();
668 USHORT n;
669 for ( n = nOldMaxLRU ; n > aTFMaxLRU.GetValue() ; n-- )
670 aConfig.DeleteKey( ByteString("LRU").Append( ByteString::CreateFromInt32( n ) ) );
671 aConfig.WriteKey( "MaxLRU", ByteString::CreateFromInt64( aTFMaxLRU.GetValue() ) );
673 aConfig.SetGroup("OOoProgramDir");
674 aConfig.WriteKey( C_KEY_AKTUELL, ByteString( aEDProgDir.GetText(), RTL_TEXTENCODING_UTF8 ) );
675 aConfig.WriteKey( C_KEY_TYPE, ByteString( "PATH" ) );
679 FontOptions::FontOptions( Window* pParent, Config &aConfig )
680 : TabPage( pParent, SttResId( RID_TP_FONT ) )
681 , aFTFontName( this, SttResId(FT_FONTNAME) )
682 , aFontName( this, SttResId(CB_FONTNAME) )
683 , aFTStyle( this, SttResId(FT_FONTSTYLE) )
684 , aFontStyle( this, SttResId(CB_FONTSTYLE) )
685 , aFTSize( this, SttResId(FT_FONTSIZE) )
686 , aFontSize( this, SttResId(MB_FONTSIZE) )
687 , aFTPreview( this, SttResId(FT_PREVIEW) )
688 , aFontList( this )
690 FreeResource();
692 aFontName.Fill( &aFontList );
693 aFontName.EnableWYSIWYG();
694 aFontName.EnableSymbols();
696 // aFontSize.SetUnit( FUNIT_POINT );
697 // MapMode aMode( MAP_POINT );
698 // aFTPreview.SetMapMode( aMode );
700 aFontName.SetModifyHdl( LINK( this, FontOptions, FontNameChanged ) );
701 aFontStyle.SetModifyHdl( LINK( this, FontOptions, FontStyleChanged ) );
702 aFontSize.SetModifyHdl( LINK( this, FontOptions, FontSizeChanged ) );
704 ByteString aTemp;
705 aConfig.SetGroup("Misc");
706 aTemp = aConfig.ReadKey( "ScriptFontName", "Courier" );
707 aFontName.SetText( String( aTemp, RTL_TEXTENCODING_UTF8 ) );
708 aFontName.Modify();
709 aTemp = aConfig.ReadKey( "ScriptFontStyle", "normal" );
710 aFontStyle.SetText( String( aTemp, RTL_TEXTENCODING_UTF8 ) );
711 aFontStyle.Modify();
712 aTemp = aConfig.ReadKey( "ScriptFontSize", "12" );
713 aFontSize.SetText( String( aTemp, RTL_TEXTENCODING_UTF8 ) );
714 aFontSize.Modify();
717 IMPL_LINK( FontOptions, FontNameChanged, void*, EMPTYARG )
719 aFontStyle.Fill( aFontName.GetText(), &aFontList );
720 FontStyleChanged( NULL );
721 return 0;
724 IMPL_LINK( FontOptions, FontStyleChanged, void*, EMPTYARG )
726 FontInfo aFontInfo( aFontList.Get( aFontName.GetText(), aFontStyle.GetText() ) );
727 aFontSize.Fill( &aFontInfo, &aFontList );
728 FontSizeChanged( NULL );
729 return 0;
732 IMPL_LINK( FontOptions, FontSizeChanged, void*, EMPTYARG )
734 UpdatePreview();
735 return 0;
738 void FontOptions::UpdatePreview()
740 Font aFont = aFontList.Get( aFontName.GetText(), aFontStyle.GetText() );
741 // ULONG nFontSize = aFontSize.GetValue( FUNIT_POINT );
742 ULONG nFontSize = static_cast<ULONG>((aFontSize.GetValue() + 5) / 10);
743 aFont.SetHeight( nFontSize );
744 aFTPreview.SetFont( aFont );
745 aFTPreview.SetText( aFontName.GetText() );
746 aFTPreview.Invalidate();
750 void FontOptions::Save( Config &aConfig )
752 aConfig.SetGroup("Misc");
753 aConfig.WriteKey( "ScriptFontName", aFontName.GetText(), RTL_TEXTENCODING_UTF8 );
754 aConfig.WriteKey( "ScriptFontStyle", aFontStyle.GetText(), RTL_TEXTENCODING_UTF8 );
755 aConfig.WriteKey( "ScriptFontSize", aFontSize.GetText(), RTL_TEXTENCODING_UTF8 );
759 GenericOptions::GenericOptions( Window* pParent, Config &aConfig )
760 : TabPage( pParent, SttResId( RID_TP_GENERIC ) )
761 , aConf( aConfig )
763 , aFlArea( this, SttResId( RID_FL_AREA ) )
764 , aCbArea( this, SttResId( RID_CB_AREA ) )
765 , aPbNewArea( this, SttResId( RID_PB_NEW_AREA ) )
766 , aPbDelArea( this, SttResId( RID_PD_DEL_AREA ) )
768 , aFlValue( this, SttResId( RID_FL_VALUE ) )
769 , aCbValue( this, SttResId( RID_CB_VALUE ) )
771 , aPbSelectPath( this, SttResId( RID_PB_SELECT_FILE ) )
772 , aPbNewValue( this, SttResId( RID_PB_NEW_VALUE ) )
773 , aPbDelValue( this, SttResId( RID_PB_DEL_VALUE ) )
775 , nMoveButtons( 0 )
776 , bShowSelectPath( FALSE )
778 FreeResource();
779 LoadData();
781 aCbArea.EnableAutocomplete( TRUE );
782 aCbValue.EnableAutocomplete( TRUE );
784 aCbArea.SetSelectHdl( LINK( this, GenericOptions, LoadGroup ) );
786 aPbNewArea.SetClickHdl( LINK( this, GenericOptions, NewGroup ) );
787 aPbDelArea.SetClickHdl( LINK( this, GenericOptions, DelGroup ) );
789 aPbSelectPath.SetClickHdl( LINK( this, GenericOptions, SelectPath ) );
790 aPbNewValue.SetClickHdl( LINK( this, GenericOptions, NewValue ) );
791 aPbDelValue.SetClickHdl( LINK( this, GenericOptions, DelValue ) );
793 aCbArea.SetModifyHdl( LINK( this, GenericOptions, CheckButtonsHdl ) );
794 aCbValue.SetModifyHdl( LINK( this, GenericOptions, CheckButtonsHdl ) );
795 aCbValue.SetSelectHdl( LINK( this, GenericOptions, CheckButtonsHdl ) );
797 aMoveTimer.SetTimeout( 60 );
798 aMoveTimer.SetTimeoutHdl( LINK( this, GenericOptions, MoveButtons ) );
801 GenericOptions::~GenericOptions()
805 StringList* GenericOptions::GetAllGroups()
807 StringList* pGroups = new StringList();
808 for ( USHORT i = 0 ; i < aConf.GetGroupCount() ; i++ )
810 String *pGroup = new String( aConf.GetGroupName( i ), RTL_TEXTENCODING_UTF8 );
811 pGroups->Insert( pGroup );
813 return pGroups;
816 void GenericOptions::LoadData()
818 StringList* pGroups = GetAllGroups();
819 String* pGroup;
820 while ( (pGroup = pGroups->First()) != NULL )
822 pGroups->Remove( pGroup );
823 aConf.SetGroup( ByteString( *pGroup, RTL_TEXTENCODING_UTF8 ) );
824 if ( aConf.ReadKey( C_KEY_AKTUELL ).Len() > 0 )
826 aCbArea.InsertEntry( *pGroup );
828 delete pGroup;
830 delete pGroups;
831 aCbArea.SetText( aCbArea.GetEntry( 0 ) );
832 CheckButtons( aCbArea, aPbNewArea, aPbDelArea );
834 // Add load the data
835 LINK( this, GenericOptions, LoadGroup ).Call( NULL );
838 void GenericOptions::ShowSelectPath( const String aType )
840 Point aNPos = aPbNewValue.GetPosPixel();
841 Point aDPos = aPbDelValue.GetPosPixel();
842 long nDelta = aDPos.Y() - aNPos.Y();
843 if ( aType.EqualsIgnoreCaseAscii( "PATH" ) && !bShowSelectPath )
844 { // Show Path button
845 nMoveButtons += nDelta;
846 aMoveTimer.Start();
847 bShowSelectPath = TRUE;
848 aPbSelectPath.Show( TRUE );
849 aPbSelectPath.Enable( TRUE );
851 else if ( !aType.EqualsIgnoreCaseAscii( "PATH" ) && bShowSelectPath )
852 { // Hide Path button
853 nMoveButtons -= nDelta;
854 aMoveTimer.Start();
855 bShowSelectPath = FALSE;
856 aPbSelectPath.Enable( FALSE );
860 IMPL_LINK( GenericOptions, MoveButtons, AutoTimer*, aTimer )
862 if ( nMoveButtons == 0 )
864 aTimer->Stop();
865 aPbSelectPath.Show( bShowSelectPath );
866 return 0;
869 int nStep = (nMoveButtons > 0) ? 2 : -2;
870 if ( nMoveButtons <= 1 && nMoveButtons >= -1 )
871 nStep = nMoveButtons;
873 nMoveButtons -= nStep ;
875 Point aPos;
877 aPos = aPbNewValue.GetPosPixel();
878 aPos.Y() += nStep;
879 aPbNewValue.SetPosPixel( aPos );
881 aPos = aPbDelValue.GetPosPixel();
882 aPos.Y() += nStep;
883 aPbDelValue.SetPosPixel( aPos );
884 return 0;
887 String GenericOptions::ReadKey( const ByteString &aGroup, const ByteString &aKey )
889 aConf.SetGroup( aGroup );
890 return UniString( aConf.ReadKey( aKey ), RTL_TEXTENCODING_UTF8 );
893 IMPL_LINK( GenericOptions, LoadGroup, ComboBox*, EMPTYARG )
895 String aCurrentValue;
896 String aAllValues;
897 String aType;
899 if ( aLastGroupName.Len() )
900 { // Cache values?
901 aCurrentValue = aCbValue.GetText();
902 if ( aCbValue.GetEntryPos( aCurrentValue ) == COMBOBOX_ENTRY_NOTFOUND )
903 { // Create a new value
904 LINK( this, GenericOptions, NewValue ).Call( NULL );
907 aConf.SetGroup( aLastGroupName );
908 aConf.WriteKey( C_KEY_AKTUELL, ByteString( aCurrentValue, RTL_TEXTENCODING_UTF8 ) );
909 USHORT i;
910 for ( i=0 ; i < aCbValue.GetEntryCount() ; i++ )
912 if ( i > 0 )
913 aAllValues += ';';
914 aAllValues += aCbValue.GetEntry( i );
916 aConf.WriteKey( C_KEY_ALLE, ByteString( aAllValues, RTL_TEXTENCODING_UTF8 ) );
919 aCbValue.Clear();
921 ByteString aGroupName = ByteString( aCbArea.GetText(), RTL_TEXTENCODING_UTF8 );
922 aCurrentValue = ReadKey( aGroupName, C_KEY_AKTUELL );
923 aAllValues = ReadKey( aGroupName, C_KEY_ALLE );
924 aType = ReadKey( aGroupName, C_KEY_TYPE );
926 xub_StrLen i;
927 for ( i=0 ; i < aAllValues.GetTokenCount() ; i++ )
929 aCbValue.InsertEntry( aAllValues.GetToken( i ) );
931 aCbValue.SetText( aCurrentValue );
933 aLastGroupName = aGroupName;
934 CheckButtons( aCbArea, aPbNewArea, aPbDelArea );
935 CheckButtons( aCbValue, aPbNewValue, aPbDelValue );
936 ShowSelectPath( aType );
937 return 0;
940 IMPL_LINK( GenericOptions, DelGroup, Button*, EMPTYARG )
942 String aGroup = aCbArea.GetText();
943 if ( aCbArea.GetEntryPos( aGroup ) != COMBOBOX_ENTRY_NOTFOUND )
945 aCbArea.RemoveEntry( aGroup );
946 ByteString aByteGroup( aGroup, RTL_TEXTENCODING_UTF8 );
947 aConf.DeleteGroup( aByteGroup );
950 aCbArea.SetText( aCbArea.GetEntry( 0 ) );
951 LINK( this, GenericOptions, LoadGroup ).Call( NULL );
953 return 0;
956 IMPL_LINK( GenericOptions, NewGroup, Button*, EMPTYARG )
958 aCbArea.InsertEntry( aCbArea.GetText() );
960 LINK( this, GenericOptions, LoadGroup ).Call( NULL );
962 return 0;
965 IMPL_LINK( GenericOptions, SelectPath, Button*, EMPTYARG )
967 PathDialog aPD( this );
968 aPD.SetPath( aCbValue.GetText() );
969 if ( aPD.Execute() )
971 aCbValue.SetText( aPD.GetPath() );
972 CheckButtons( aCbValue, aPbNewValue, aPbDelValue );
973 if ( aPbNewValue.IsEnabled() )
975 LINK( this, GenericOptions, NewValue ).Call( NULL );
978 return 1;
981 IMPL_LINK( GenericOptions, DelValue, Button*, EMPTYARG )
983 String aValue = aCbValue.GetText();
984 if ( aCbValue.GetEntryPos( aValue ) != COMBOBOX_ENTRY_NOTFOUND )
986 aCbValue.RemoveEntry( aValue );
989 aCbValue.SetText( aCbValue.GetEntry( 0 ) );
990 CheckButtons( aCbValue, aPbNewValue, aPbDelValue );
991 return 0;
994 IMPL_LINK( GenericOptions, NewValue, Button*, EMPTYARG )
996 aCbValue.InsertEntry( aCbValue.GetText() );
997 CheckButtons( aCbValue, aPbNewValue, aPbDelValue );
998 return 0;
1001 IMPL_LINK( GenericOptions, CheckButtonsHdl, ComboBox*, pCB )
1003 if ( pCB == &aCbArea )
1004 CheckButtons( aCbArea, aPbNewArea, aPbDelArea );
1005 if ( pCB == &aCbValue )
1006 CheckButtons( aCbValue, aPbNewValue, aPbDelValue );
1007 return 0;
1010 void GenericOptions::Save( Config &aConfig )
1012 (void) aConfig; /* avoid warning about unused parameter */
1013 DBG_ASSERT( &aConfig == &aConf, "Saving to different Configuration" );
1015 // Save changes
1016 LINK( this, GenericOptions, LoadGroup ).Call( NULL );
1020 class TextAndWin : public DockingWindow
1022 FixedText *pFt;
1023 Window *pWin;
1024 Window* pFtOriginalParent;
1025 Window* pWinOriginalParent;
1026 long nSpace; // default space
1027 BOOL bAlignTop;
1029 public:
1030 TextAndWin( Window *pParent, FixedText *pFtP, Window *pWinP, long nSpaceP, BOOL bAlignTopP );
1031 ~TextAndWin();
1033 virtual void Resize();
1036 TextAndWin::TextAndWin( Window *pParent, FixedText *pFtP, Window *pWinP, long nSpaceP, BOOL bAlignTopP )
1037 : DockingWindow( pParent )
1038 , pFt( pFtP )
1039 , pWin( pWinP )
1040 , nSpace( nSpaceP )
1041 , bAlignTop( bAlignTopP )
1043 pFtOriginalParent = pFt->GetParent();
1044 pWinOriginalParent = pWin->GetParent();
1045 pFt->SetParent( this );
1046 pWin->SetParent( this );
1049 TextAndWin::~TextAndWin()
1051 pFt->SetParent( pFtOriginalParent );
1052 pWin->SetParent( pWinOriginalParent );
1055 void TextAndWin::Resize()
1057 long nTopSpace = bAlignTop ? 0 : nSpace;
1058 long nBottomSpace = bAlignTop ? nSpace : 0;
1060 long nFixedTextOffset;
1061 if ( GetOutputSizePixel().Height() < 3 * pFt->GetSizePixel().Height() )
1063 pFt->Hide();
1064 nFixedTextOffset = 0;
1066 else
1068 pFt->Show();
1069 nFixedTextOffset = pFt->GetSizePixel().Height() + nSpace;
1071 // FixedText positioning
1072 pFt->SetPosPixel( Point( 0, nTopSpace ) );
1075 // Window positioning
1076 long nWinPosY = nFixedTextOffset;
1077 nWinPosY += nTopSpace;
1078 pWin->SetPosPixel( Point( 0, nWinPosY ) );
1080 // Set size of window
1081 long nWinHeight = GetOutputSizePixel().Height();
1082 nWinHeight -= nWinPosY;
1083 nWinHeight -= nBottomSpace;
1084 pWin->SetSizePixel( Size( GetOutputSizePixel().Width(), nWinHeight ) );
1087 DisplayHidDlg::DisplayHidDlg( Window * pParent )
1088 : FloatingWindow( pParent, SttResId( IDD_DISPLAY_HID ) )
1089 , aTbConf( this, SttResId( RID_TB_CONF ) )
1090 , aFtControls( this, SttResId( RID_FT_CONTROLS ) )
1091 , aMlbControls( this, SttResId( RID_MLB_CONTROLS ) )
1092 , aFtSlots( this, SttResId( RID_FT_SLOTS ) )
1093 , aMlbSlots( this, SttResId( RID_MLB_SLOTS ) )
1094 , aPbKopieren( this, SttResId( RID_PB_KOPIEREN ) )
1095 , aPbBenennen( this, SttResId( RID_PB_BENENNEN ) )
1096 , aPbSelectAll( this, SttResId( RID_PB_SELECTALL ) )
1097 , aOKClose( this, SttResId( RID_OK_CLOSE ) )
1098 , nDisplayMode( DH_MODE_KURZNAME | DH_MODE_LANGNAME ) // If we have an old office use this default
1100 FreeResource();
1102 /* ResMgr* pRM = CREATERESMGR( svt );
1103 ToolBox aOrig( this, ResId( 12345, pRM ) );
1104 delete pRM;
1106 aTbConf.CopyItem( aOrig, 4 );
1107 aTbConf.InsertSeparator();
1108 aTbConf.CopyItem( aOrig, 5 );
1109 aTbConf.CopyItem( aOrig, 6 );
1110 aTbConf.CopyItem( aOrig, 7 ); */
1111 aTbConf.SetOutStyle( TOOLBOX_STYLE_FLAT );
1113 #if OSL_DEBUG_LEVEL < 2
1114 aTbConf.Hide();
1115 #endif
1117 pSplit = new SplitWindow( this );
1118 pControls = new TextAndWin( pSplit, &aFtControls, &aMlbControls, aMlbControls.GetPosPixel().X(), TRUE );
1119 pSlots = new TextAndWin( pSplit, &aFtSlots, &aMlbSlots, aMlbControls.GetPosPixel().X(), FALSE );
1121 pSplit->SetPosPixel( aFtControls.GetPosPixel() );
1122 pSplit->InsertItem( 1, pControls, 70, SPLITWINDOW_APPEND, 0, SWIB_PERCENTSIZE );
1123 pSplit->InsertItem( 2, pSlots, 30, SPLITWINDOW_APPEND, 0, SWIB_PERCENTSIZE );
1124 pSplit->Show();
1126 aTbConf.SetBorderStyle( WINDOW_BORDER_NORMAL );
1127 aPbKopieren.SetClickHdl( LINK( this, DisplayHidDlg, CopyToClipboard ) );
1128 aPbSelectAll.SetClickHdl( LINK( this, DisplayHidDlg, SelectAll ) );
1130 aMlbControls.SetSelectHdl( LINK( this, DisplayHidDlg, Select ) );
1131 aMlbSlots.SetSelectHdl( LINK( this, DisplayHidDlg, Select ) );
1132 Select( NULL );
1135 DisplayHidDlg::~DisplayHidDlg()
1137 delete pControls;
1138 delete pSlots;
1139 delete pSplit;
1142 IMPL_LINK( DisplayHidDlg, CopyToClipboard, void*, EMPTYARG )
1144 String aSammel;
1145 USHORT i;
1147 for ( i=0 ; i < aMlbControls.GetSelectEntryCount() ; i++ )
1149 if ( aSammel.Len() )
1150 aSammel += '\n';
1151 aSammel += aMlbControls.GetSelectEntry( i );
1153 for ( i=0 ; i < aMlbSlots.GetSelectEntryCount() ; i++ )
1155 if ( aSammel.Len() )
1156 aSammel += '\n';
1157 aSammel += aMlbSlots.GetSelectEntry( i );
1159 ::svt::OStringTransfer::CopyString( aSammel, this );
1160 return 0;
1163 IMPL_LINK( DisplayHidDlg, SelectAll, PushButton*, pButton )
1165 if ( pButton->GetState() != STATE_CHECK )
1167 USHORT i;
1168 for ( i=0 ; i < aMlbControls.GetEntryCount() ; i++ )
1169 aMlbControls.SelectEntryPos( i );
1170 for ( i=0 ; i < aMlbSlots.GetEntryCount() ; i++ )
1171 aMlbSlots.SelectEntryPos( i );
1173 else
1175 aMlbControls.SetNoSelection();
1176 aMlbControls.Invalidate();
1177 aMlbSlots.SetNoSelection();
1178 aMlbSlots.Invalidate();
1180 Select( NULL );
1181 return 0;
1184 IMPL_LINK( DisplayHidDlg, Select, void*, EMPTYARG )
1186 if ( !aMlbControls.GetSelectEntryCount() && !aMlbSlots.GetSelectEntryCount() )
1187 aPbSelectAll.SetState( STATE_NOCHECK );
1188 else if ( aMlbControls.GetSelectEntryCount() == aMlbControls.GetEntryCount()
1189 && aMlbSlots.GetSelectEntryCount() == aMlbSlots.GetEntryCount() )
1190 aPbSelectAll.SetState( STATE_CHECK );
1191 else
1192 aPbSelectAll.SetState( STATE_DONTKNOW );
1193 return 0;
1196 void DisplayHidDlg::AddData( WinInfoRec* pWinInfo )
1198 if ( pWinInfo->bIsReset )
1200 aMlbControls.Clear();
1201 aMlbSlots.Clear();
1203 if ( pWinInfo->nRType & DH_MODE_DATA_VALID ) // no old office
1204 nDisplayMode = pWinInfo->nRType; // Is used for mode transmission while reset
1205 // if ( pWinInfo->aUId.GetULONG() & DH_MODE_DATA_VALID ) // kein altes Office
1206 // nDisplayMode = pWinInfo->aUId.GetULONG(); // Wird im Reset zur �bermittlung des Modus verwendet
1208 return;
1211 String aMsg;
1212 if ( ( nDisplayMode & DH_MODE_KURZNAME ) )
1214 if ( pWinInfo->aKurzname.Len() > 0 )
1215 aMsg += pWinInfo->aKurzname;
1216 else
1218 aMsg.AppendAscii( "--" );
1219 aMsg += pWinInfo->aUId;
1220 aMsg.AppendAscii( ": " );
1221 aMsg += pWinInfo->aRName;
1223 aMsg.Expand(20);
1225 else
1227 aMsg += pWinInfo->aUId;
1228 aMsg.Expand(13);
1230 aMsg.AppendAscii( " " ); // At least three blanks
1232 if ( nDisplayMode & DH_MODE_LANGNAME )
1234 if ( pWinInfo->aLangname.Len() > 0 )
1235 aMsg += pWinInfo->aLangname;
1236 else
1237 aMsg += String( SttResId( IDS_NO_LONGNAME ) );
1240 aMlbControls.InsertEntry( aMsg );
1243 // Do we have a Slotname?
1244 if ( ( nDisplayMode & DH_MODE_KURZNAME ) && pWinInfo->aSlotname.Len() > 0 )
1246 aMsg = pWinInfo->aSlotname;
1247 aMsg.Expand(20);
1248 aMsg.AppendAscii( " " );
1250 if ( nDisplayMode & DH_MODE_LANGNAME )
1252 if ( pWinInfo->aLangname.Len() > 0 )
1253 aMsg += pWinInfo->aLangname;
1254 else
1255 aMsg += String( SttResId( IDS_NO_LONGNAME ) );
1258 aMlbSlots.InsertEntry( aMsg );
1262 void DisplayHidDlg::Resize()
1265 if ( IsRollUp() )
1267 // We want only the toolbox to be seend
1268 SetOutputSizePixel( aTbConf.GetSizePixel() );
1270 else
1272 // SetUpdateMode( FALSE );
1274 // Minimum size
1275 Size aSize( GetOutputSizePixel() );
1276 aSize.Width() = std::max( aSize.Width(), (long)(aOKClose.GetSizePixel().Width() * 3 ));
1277 aSize.Height() = std::max( aSize.Height(), (long)(aOKClose.GetSizePixel().Height() * 8 ));
1278 SetOutputSizePixel( aSize );
1280 // Default space
1281 long nSpace = pSplit->GetPosPixel().X();
1283 // Adapt ToolBox width
1284 aTbConf.SetSizePixel( Size ( GetSizePixel().Width(), aTbConf.CalcWindowSizePixel().Height() ) );
1285 aTbConf.SetSizePixel( Size() ); // Hide at first
1287 // SplitWindow positioning
1288 pSplit->SetPosPixel( Point( nSpace, nSpace + aTbConf.GetPosPixel().Y() + aTbConf.GetSizePixel().Height() ) );
1290 // Calculate width of SplitWindows
1291 long nSplitWidth = GetSizePixel().Width();
1292 nSplitWidth -= aPbBenennen.GetSizePixel().Width();
1293 nSplitWidth -= 3 * nSpace; // Spaces
1294 nSplitWidth -= nSpace / 2; // Little more space at right margin
1296 // Calculate hight of SplitWindows
1297 long nSplitHeight = GetOutputSizePixel().Height();
1298 nSplitHeight -= pSplit->GetPosPixel().Y();
1299 nSplitHeight -= nSpace; // bottom margin
1301 // Set size of SplitWindows
1302 pSplit->SetSizePixel( Size( nSplitWidth, nSplitHeight ) );
1304 Point aPos;
1306 // Button "Copy" positioning
1307 aPos = pSplit->GetPosPixel();
1308 aPos.Move( nSplitWidth, 0 );
1309 aPos.Move( nSpace, 0 );
1310 aPbKopieren.SetPosPixel( aPos );
1312 // Button "Get all"
1313 aPos.Move( 0, aPbKopieren.GetSizePixel().Height() );
1314 aPos.Move( 0, nSpace );
1315 aPbSelectAll.SetPosPixel( aPos );
1317 // Button "Name"
1318 aPos.Move( 0, aPbSelectAll.GetSizePixel().Height() );
1319 aPos.Move( 0, nSpace );
1320 aPbBenennen.SetPosPixel( aPos );
1322 // "Close" Button
1323 aPos = pSplit->GetPosPixel();
1324 aPos.Move( nSpace, -aOKClose.GetSizePixel().Height() );
1325 aPos.Move( pSplit->GetSizePixel().Width(), pSplit->GetSizePixel().Height() );
1326 aOKClose.SetPosPixel( aPos );
1328 // SetUpdateMode( TRUE );
1329 // Invalidate();
1331 FloatingWindow::Resize();
1335 VarEditDialog::VarEditDialog( Window * pParent, SbxVariable *pPVar )
1336 : ModelessDialog( pParent, SttResId( IDD_EDIT_VAR ) )
1337 , aFixedTextRID_FT_NAME( this, SttResId( RID_FT_NAME ) )
1338 , aFixedTextRID_FT_CONTENT( this, SttResId( RID_FT_CONTENT ) )
1339 , aFixedTextRID_FT_NEW_CONTENT( this, SttResId( RID_FT_NEW_CONTENT ) )
1340 , aFixedTextRID_FT_NAME_VALUE( this, SttResId( RID_FT_NAME_VALUE ) )
1341 , aFixedTextRID_FT_CONTENT_VALUE( this, SttResId( RID_FT_CONTENT_VALUE ) )
1343 , aRadioButtonRID_RB_NEW_BOOL_T( this, SttResId( RID_RB_NEW_BOOL_T ) )
1344 , aRadioButtonRID_RB_NEW_BOOL_F( this, SttResId( RID_RB_NEW_BOOL_F ) )
1345 , aNumericFieldRID_NF_NEW_INTEGER( this, SttResId( RID_NF_NEW_INTEGER ) )
1346 , aNumericFieldRID_NF_NEW_LONG( this, SttResId( RID_NF_NEW_LONG ) )
1347 , aEditRID_ED_NEW_STRING( this, SttResId( RID_ED_NEW_STRING ) )
1349 , aOKButtonRID_OK( this, SttResId( RID_OK ) )
1350 , aCancelButtonRID_CANCEL( this, SttResId( RID_CANCEL ) )
1351 , pVar( pPVar )
1353 aFixedTextRID_FT_NAME_VALUE.SetText( pVar->GetName() );
1354 aFixedTextRID_FT_CONTENT_VALUE.SetText( pVar->GetString() );
1356 SbxDataType eType = pVar->GetType();
1357 if ( ( eType & ( SbxVECTOR | SbxARRAY | SbxBYREF )) == 0 )
1359 switch ( eType )
1361 case SbxBOOL:
1362 aRadioButtonRID_RB_NEW_BOOL_T.Show();
1363 aRadioButtonRID_RB_NEW_BOOL_F.Show();
1364 if ( pVar->GetBool() )
1365 aRadioButtonRID_RB_NEW_BOOL_T.Check();
1366 else
1367 aRadioButtonRID_RB_NEW_BOOL_F.Check();
1368 break;
1369 // case SbxCURRENCY:
1370 // case SbxDATE:
1371 // break;
1372 case SbxINTEGER:
1373 aNumericFieldRID_NF_NEW_INTEGER.Show();
1374 aNumericFieldRID_NF_NEW_INTEGER.SetText( pVar->GetString() );
1375 aNumericFieldRID_NF_NEW_INTEGER.Reformat();
1376 break;
1377 case SbxLONG:
1378 aNumericFieldRID_NF_NEW_LONG.Show();
1379 aNumericFieldRID_NF_NEW_LONG.SetText( pVar->GetString() );
1380 aNumericFieldRID_NF_NEW_LONG.Reformat();
1381 // Must be hardcoded otherwise the Rsc Compiler will fail
1382 aNumericFieldRID_NF_NEW_LONG.SetMin( -aNumericFieldRID_NF_NEW_LONG.GetMax()-1 );
1383 aNumericFieldRID_NF_NEW_LONG.SetFirst( -aNumericFieldRID_NF_NEW_LONG.GetLast()-1 );
1384 break;
1385 // case SbxOBJECT: // cannot be edited
1386 // break;
1387 case SbxSINGLE:
1388 case SbxDOUBLE:
1389 case SbxSTRING:
1390 case SbxVARIANT:
1391 case SbxEMPTY:
1392 aEditRID_ED_NEW_STRING.Show();
1393 aEditRID_ED_NEW_STRING.SetText( pVar->GetString() );
1394 break;
1395 default: // don't know how to edit
1401 aOKButtonRID_OK.SetClickHdl( LINK( this, VarEditDialog, OKClick ) );
1405 IMPL_LINK( VarEditDialog, OKClick, Button *, pButton )
1407 (void) pButton; /* avoid warning about unused parameter */
1408 BOOL bWasError = SbxBase::IsError(); // Probably an error is thrown
1411 SbxDataType eType = pVar->GetType();
1413 Boolean
1414 Currency
1415 Date
1416 Double
1417 Integer
1418 Long
1419 Object
1420 Single
1421 String
1422 Variant
1425 atof
1427 ecvt
1429 gcvt
1431 SvNumberformat::
1432 static double StringToDouble( const xub_Unicode* pStr,
1433 const International& rIntl,
1434 int& nErrno,
1435 const xub_Unicode** ppEnd = NULL );
1436 // Converts just as strtod a decimal string to a double.
1437 // Decimal and thousand separators come from International,
1438 // leading spaces are omitted.
1439 // If ppEnd!=NULL then *ppEnd is set after the parsed data.
1440 // If pStr contains only the String to be parsed, then if success:
1441 // **ppEnd=='\0' and *ppEnd-pStr==strlen(pStr).
1442 // If overflow fVal=+/-HUGE_VAL, if underflow 0,
1443 // nErrno is in this cases set to ERANGE otherwise 0.
1444 // "+/-1.#INF" are recognized as +/-HUGE_VAL.
1450 String aContent( aEditRID_ED_NEW_STRING.GetText() );
1451 BOOL bError = FALSE;
1452 switch ( eType )
1454 case SbxBOOL:
1455 pVar->PutBool( aRadioButtonRID_RB_NEW_BOOL_T.IsChecked() );
1456 break;
1457 // case SbxCURRENCY:
1458 // pVar->PutCurrency( aContent );
1459 // break;
1460 // case SbxDATE:
1461 // pVar->PutDate( aContent );
1462 // break;
1463 case SbxINTEGER:
1464 pVar->PutInteger( (INT16)aNumericFieldRID_NF_NEW_INTEGER.GetValue() );
1465 break;
1466 case SbxLONG:
1467 pVar->PutLong( static_cast<INT32>(aNumericFieldRID_NF_NEW_LONG.GetValue()) );
1468 break;
1469 case SbxDOUBLE:
1470 case SbxSINGLE:
1471 bError = !pVar->PutStringExt( aContent );
1472 break;
1473 case SbxSTRING:
1474 pVar->PutString( aContent );
1475 break;
1476 case SbxVARIANT:
1477 case SbxEMPTY:
1478 bError = !pVar->PutStringExt( aContent );
1479 break;
1480 default: // don't know how to edit
1485 // pVar->PutStringExt( aEditRID_ED_NEW_STRING.GetText() );
1486 if ( !bWasError && SbxBase::IsError() )
1488 bError = TRUE;
1489 SbxBase::ResetError();
1492 if ( bError )
1494 ErrorBox( this, SttResId( IDS_INVALID_VALUE ) ).Execute();
1495 return 1;
1498 // if ( aEditRID_ED_NEW_STRING.GetText().Compare( pVar->GetString() ) != COMPARE_EQUAL )
1499 // {
1500 // aFixedTextRID_FT_CONTENT_VALUE.SetText( pVar->GetString() );
1501 // aEditRID_ED_NEW_STRING.SetText( pVar->GetString() );
1502 // return 1;
1503 // }
1505 Close();
1506 return 0;