1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <config_features.h>
#include <sal/config.h>
#ifdef DBG_UTIL
#include <cstdio>
#include <cstring>
#include <cmath>
#include <limits.h>
#include <tools/debug.hxx>
#include <tools/lineend.hxx>
#include "sal/log.hxx"
#include "vcl/svapp.hxx"
#include "vcl/event.hxx"
#include "vcl/lstbox.hxx"
#include "vcl/button.hxx"
#include "vcl/edit.hxx"
#include "vcl/fixed.hxx"
#include "vcl/group.hxx"
#include "vcl/field.hxx"
#include "vcl/msgbox.hxx"
#include "vcl/settings.hxx"
#include "vcl/wrkwin.hxx"
#include "vcl/threadex.hxx"
#include "svdata.hxx"
#include "dbggui.hxx"
#include "vcl/unohelp.hxx"
#include "vcl/unohelp2.hxx"
#include "salinst.hxx"
#include "svsys.h"
#include "com/sun/star/i18n/XCharacterClassification.hpp"
#include <map>
#include <algorithm>
#include <boost/scoped_array.hpp>
#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
static const sal_Char* pDbgHelpText[] =
{
"Object Test\n",
"------------------------------------------\n",
"\n",
"--- Macros ---\n",
"\n",
"Function\n",
"When a function is passed with macros, it will be called.\n",
"\n",
"Exit\n",
"This- and Func-Test will also run when exiting the function.\n",
"\n",
"\n",
"\nOther tests and macros\n",
"------------------------------------------\n",
"\n",
"Resources\n",
"In case of resource errors an error dialog is produced before the "
"exception handler is called.\n",
"\n",
"Dialog\n",
"FixedTexts, CheckBoxes, TriStateBoxes and RadioButtons are equiped with "
"a different background color to determine the size of the controls. This "
"test also shows whether controls overlap, whether the tab order is correct "
"and whether the mnemonic characters are correctly assigned. With dialogs "
"it is indicated when no default button or no OK/CancelButton is present. "
"These tests are not 100% correct (e.g. too many warnings are given) and "
"do not form any guarantee that all problematic cases are covered. For "
"example only initial and only visible controls are tested. No errors are "
"found which will occur during the use of a dialog.\n",
"\n",
"Bold AppFont\n",
"The application font is set to bold to see if the position of texts is "
"sufficient for other systems or other system settings. With very narrow "
"fonts the dialogs are made wider because they otherwise appear too narrow.\n",
"\n",
"Trace output\n",
"DBG_TRACE() can be use to produce TRACE output. DBG_TRACEFILE() also outputs "
"the file and line number where the macro is located. DBG_TRACE1() to "
"DBG_TRACE5() can be used to produce formatted output (printf format string) "
"Trace output is enabled when the corresponding option is selected in the "
"dropdown list.\n"
"\n",
"Warnings\n",
"DBG_WARNING() can be used to output warnings. DBG_WARNING1() to "
"DBG_WARNING3() can be used to produce formatted output (printf format string). "
"In case you want to have conditional warnings DBG_ASSERTWARNING() can be "
"used. The warning will be produced if the condition was not met. The first "
"parameter is the condition and the second parameter is the message to be "
"produced. Warnings are enabled if the corresponding option is selected in the "
"dropdown box. When none are selected the condition with DBG_ASSERTWARNING() "
"is not evaluated.\n",
"\n",
"Errors\n",
"DBG_ERROR() can be used to produce error messages. DBG_ERRORFILE() also "
"produces the file and the line number where the macro is located. "
"DBG_ERROR1() bis DBG_ERROR5() can be used to produce formatted output "
"(print format string). "
"In case you want to have conditional warnings DBG_ASSERT() can be "
"used. The warning will be produced if the condition was not met. The first "
"parameter is the condition and the second parameter is the message to be "
"produced. Warnings are enabled if the corresponding option is selected in the "
"dropdown box. When none are selected the condition with DBG_ASSERT() "
"is not evaluated.\n",
"\n",
"\n",
"Output\n",
"------------------------------------------\n",
"\n",
"Overwrite - CheckBox\n",
"With every new program start the log file is overwritten if output has been "
"generated.\n",
"\n",
"Include ObjectTest filters\n",
"Only classes which contain one of the indicated filters are evaluated with "
"the object test. Filters are separated by ';' and are case sensitive. "
"Wildcards are not supported. If no text is indicated the filters are not "
"active.\n",
"\n",
"Exclude ObjectTest filters\n",
"Only classes which do not contain one of the indicated filters are evaluated "
"with the object test. Filters are separated by ';' and are case sensitive. "
"Wildcards are not supported. If no text is indicated the filters are not "
"active.\n",
"\n",
"Include filters\n",
"Only those texts which include the indicated filters are output. "
"Filters are separated by ';' and are case sensitive. "
"Wildcards are not supported. The filter is used for all output (except for "
"errors). If no text is indicated the filters are not active.\n",
"\n",
"Exclude filters\n",
"Only those texts which do not include the indicated filters are output. "
"Filters are separated by ';' and are case sensitive. "
"Wildcards are not supported. The filter is used for all output (except for "
"errors). If no text is indicated the filters are not active.\n",
"\n",
"Furthermore you can indicate where the data will be output:\n",
"\n",
"None\n",
"Output is surpressed.\n",
"\n",
"File\n",
"Outputi n debug file. Filename can be entered in the Editfield.\n",
"\n",
"Window\n",
"Output to a small debug window. The window size is stored if the debug "
"dialog is closed with OK and if the window is visible. Each assertion text can "
"be copied to the clipboard via the context menu of the respective entry.\n",
"\n",
"Shell\n",
"Output to a debug system (Windows debug window) when available or under "
"Unix in the shell window. Otherwise the same as Window.\n",
"\n",
"MessageBox\n",
"Output to a MessageBox. In this case you can select whether the program "
"must be continued, terminated (Application::Abort) or interrupted with "
"CoreDump. Additionally on some systems you get a \"Copy\" button pressing which "
"copies the text of the MessageBox to the clipboard. Because a MessageBox allows "
"further event processing other errors caused by Paint, Activate/Deactivate, "
"GetFocus/LoseFocus can cause more errors or incorrect errors and messages. "
"Therefor the message should also be directed to a file/debugger in case of "
"problems in order to produce the (right) error messages.\n",
"\n",
"TestTool\n",
"When the TestTool runs messages will be redirected inside the TestTool.\n",
"\n",
"Debugger\n",
"Attempt to activate the debugger and produce the message there, in order to "
"always obtain the corresponding stack trace in the debugger.\n",
"\n",
"Abort\n",
"Aborts the application\n",
"\n",
"\n",
"Reroute osl messages - Checkbox\n",
"OSL_ASSERT and similar messages can be intercepted by the general DBG GUI\n",
"or handled system specific as per normal handling in the sal library.\n",
"default is to reroute osl assertions\n",
"\n",
"\n",
"Settings\n",
"------------------------------------------\n",
"\n",
"Where by default the INI and LOG file is read and written the following "
"can be set:\n",
"\n",
"WIN/WNT (WIN.INI, Group SV, Default: dbgsv.ini and dbgsv.log):\n",
"INI: dbgsv\n",
"LOG: dbgsvlog\n",
"\n",
"OS2 (OS2.INI, Application SV, Default: dbgsv.ini and dbgsv.log):\n",
"INI: DBGSV\n",
"LOG: DBGSVLOG\n",
"\n",
"UNIX (Environment variable, Default: .dbgsv.init and dbgsv.log):\n",
"INI: DBGSV_INIT\n",
"LOG: DBGSV_LOG\n",
"\n",
"MAC (Default: dbgsv.ini and dbgsv.log):\n",
"INI: not possible\n",
"LOG: only debug dialog settings\n",
"\n",
"The path and file name must always be specified. The name of the log "
"file that was entered in the debug dialog has always priority.\n",
"\n",
"\n",
"Example\n",
"------------------------------------------\n",
"\n",
"\n",
"#ifdef DBG_UTIL\n",
"const sal_Char* DbgCheckString( const void* pString )\n",
"{\n",
" String* p = (String*)pString;\n",
"\n",
" if ( p->mpData->maStr[p->mpData->mnLen] != 0 )\n",
" return \"String damaged: aStr[nLen] != 0\";\n",
"\n",
" return NULL;\n",
"}\n",
"#endif\n",
"\n",
"String::String()\n",
"{\n",
" // ...\n",
"}\n",
"\n",
"String::~String()\n",
"{\n",
" //...\n",
"}\n",
"\n",
"char& String::operator [] ( sal_uInt16 nIndex )\n",
"{\n",
" DBG_ASSERT( nIndex <= pData->nLen, \"String::[] : nIndex > Len\" );\n",
"\n",
" //...\n",
"}\n",
"\n",
"\n",
NULL
};
namespace
{
typedef ::std::map< OUString, DbgChannelId > UserDefinedChannels;
UserDefinedChannels& ImplDbgGetUserDefinedChannels()
{
static UserDefinedChannels s_aChannels;
return s_aChannels;
}
void ImplAppendUserDefinedChannels( ListBox& rList )
{
const UserDefinedChannels& rChannels = ImplDbgGetUserDefinedChannels();
for ( UserDefinedChannels::const_iterator channel = rChannels.begin();
channel != rChannels.end();
++channel
)
{
sal_uInt16 nEntryPos = rList.InsertEntry( channel->first );
rList.SetEntryData( nEntryPos, reinterpret_cast< void* >( channel->second ) );
}
}
void ImplSelectChannel( ListBox& rList, sal_uLong nChannelToSelect, sal_uInt16 nPositionOffset )
{
if ( nChannelToSelect < DBG_OUT_USER_CHANNEL_0 )
rList.SelectEntryPos( (sal_uInt16)( nChannelToSelect - nPositionOffset ) );
else
{
for ( sal_uInt16 pos = 0; pos < rList.GetEntryCount(); ++pos )
{
DbgChannelId nChannelId = static_cast< DbgChannelId >( reinterpret_cast<sal_IntPtr>(rList.GetEntryData( pos )) );
if ( nChannelId == nChannelToSelect )
{
rList.SelectEntryPos( pos );
return;
}
}
}
}
DbgChannelId ImplGetChannelId( const ListBox& rList, sal_uInt16 nPositionOffset )
{
sal_uInt16 nSelectedChannelPos = rList.GetSelectEntryPos();
DbgChannelId nSelectedChannel = static_cast< DbgChannelId >( reinterpret_cast<sal_IntPtr>(rList.GetEntryData( nSelectedChannelPos )) );
if ( nSelectedChannel == 0)
return (DbgChannelId)( nSelectedChannelPos + nPositionOffset );
return nSelectedChannel;
}
}
#define DBGWIN_MAXLINES 100
class DbgWindow : public WorkWindow
{
private:
ListBox maLstBox;
public:
DbgWindow();
virtual bool Close();
virtual void Resize();
virtual bool PreNotify( NotifyEvent& rNEvt );
void InsertLine( const OUString& rLine );
void Update() { WorkWindow::Update(); maLstBox.Update(); }
private:
void GetAssertionEntryRange( sal_uInt16 nInbetweenEntry, sal_uInt16& nFirst, sal_uInt16& nLast );
};
class DbgInfoDialog : public ModalDialog
{
private:
ListBox maListBox;
OKButton maOKButton;
bool mbHelpText;
public:
DbgInfoDialog( Window* pParent, bool bHelpText = false );
void SetInfoText( const OUString& rStr );
};
class DbgDialog : public ModalDialog
{
private:
CheckBox maXtorThis;
CheckBox maXtorFunc;
CheckBox maXtorExit;
CheckBox maXtorReport;
CheckBox maXtorTrace;
GroupBox maBox1;
CheckBox maRes;
CheckBox maDialog;
CheckBox maBoldAppFont;
GroupBox maBox3;
Edit maDebugName;
CheckBox maOverwrite;
FixedText maInclClassText;
Edit maInclClassFilter;
FixedText maExclClassText;
Edit maExclClassFilter;
FixedText maInclText;
Edit maInclFilter;
FixedText maExclText;
Edit maExclFilter;
FixedText maTraceText;
ListBox maTraceBox;
FixedText maErrorText;
ListBox maErrorBox;
GroupBox maBox4;
OKButton maOKButton;
CancelButton maCancelButton;
PushButton maInfoButton;
HelpButton maHelpButton;
sal_uInt16 mnErrorOff;
public:
DbgDialog();
DECL_LINK( ClickHdl, Button* );
void RequestHelp( const HelpEvent& rHEvt );
};
static sal_Char aDbgInfoBuf[12288];
static sal_Char aDbgOutBuf[DBG_BUF_MAXLEN];
DbgWindow::DbgWindow() :
WorkWindow( NULL, WB_STDWORK ),
maLstBox( this, WB_AUTOHSCROLL )
{
DbgData* pData = DbgGetData();
maLstBox.Show();
maLstBox.SetPosPixel( Point( 0, 0 ) );
SetOutputSizePixel( Size( 600, 480 ) );
if ( pData->aDbgWinState[0] )
{
OString aState( pData->aDbgWinState );
SetWindowState( aState );
}
SetText("StarView Debug Window");
Show();
Update();
}
bool DbgWindow::Close()
{
// remember window position
OString aState( GetWindowState() );
DbgData* pData = DbgGetData();
size_t nCopy = (sizeof( pData->aDbgWinState ) < size_t(aState.getLength() + 1U ))
? sizeof( pData->aDbgWinState ) : size_t(aState.getLength() + 1U );
strncpy( pData->aDbgWinState, aState.getStr(), nCopy );
pData->aDbgWinState[ sizeof( pData->aDbgWinState ) - 1 ] = 0;
// and save for next session
DbgSaveData( *pData );
delete this;
ImplGetSVData()->maWinData.mpDbgWin = NULL;
return true;
}
void DbgWindow::Resize()
{
maLstBox.SetSizePixel( GetOutputSizePixel() );
}
void DbgWindow::GetAssertionEntryRange( sal_uInt16 nInbetweenEntry, sal_uInt16& nFirst, sal_uInt16& nLast )
{
nFirst = nInbetweenEntry;
while ( nFirst > 0 )
{
if ( maLstBox.GetEntryData( nFirst ) != NULL )
break;
--nFirst;
}
sal_uInt16 nEntryCount = maLstBox.GetEntryCount();
nLast = nInbetweenEntry + 1;
while ( nLast < nEntryCount )
{
if ( maLstBox.GetEntryData( nLast ) != NULL )
break;
++nLast;
}
}
bool DbgWindow::PreNotify( NotifyEvent& rNEvt )
{
if ( rNEvt.GetType() == EVENT_COMMAND )
{
if ( maLstBox.IsWindowOrChild( rNEvt.GetWindow() ) )
{
const CommandEvent& rCommand = *rNEvt.GetCommandEvent();
if ( rCommand.GetCommand() == COMMAND_CONTEXTMENU )
{
PopupMenu aMenu;
aMenu.InsertItem( 1, OUString("copy to clipboard") );
Point aPos;
if ( rCommand.IsMouseEvent() )
aPos = rCommand.GetMousePosPixel();
else
{
Rectangle aEntryRect( maLstBox.GetBoundingRectangle( maLstBox.GetSelectEntryPos() ) );
aPos = aEntryRect.Center();
}
sal_uInt16 nSelected = aMenu.Execute( rNEvt.GetWindow(), aPos );
if ( nSelected == 1 )
{
// search all entries which belong to this assertion
sal_uInt16 nAssertionFirst = 0;
sal_uInt16 nAssertionLast = 0;
GetAssertionEntryRange( maLstBox.GetSelectEntryPos(), nAssertionFirst, nAssertionLast );
// build the string to copy to the clipboard
OUStringBuffer sAssertion;
OUString sLineFeed = convertLineEnd(
OUString("\n"),
GetSystemLineEnd());
while ( nAssertionFirst < nAssertionLast )
{
sAssertion.append(maLstBox.GetEntry( nAssertionFirst++ ));
sAssertion.append(sLineFeed);
}
::vcl::unohelper::TextDataObject::CopyStringTo(
sAssertion.makeStringAndClear(), GetClipboard());
}
}
return true; // handled
}
}
return WorkWindow::PreNotify( rNEvt );
}
void DbgWindow::InsertLine( const OUString& rLine )
{
OUString aStr = convertLineEnd(rLine, LINEEND_LF);
sal_Int32 nPos = aStr.indexOf( '\n' );
bool bFirstEntry = true;
while ( nPos != -1 )
{
if ( maLstBox.GetEntryCount() >= DBGWIN_MAXLINES )
maLstBox.RemoveEntry( 0 );
sal_uInt16 nInsertionPos = maLstBox.InsertEntry( aStr.copy( 0, nPos ) );
if ( bFirstEntry )
maLstBox.SetEntryData( nInsertionPos, reinterpret_cast< void* >( 1 ) );
bFirstEntry = false;
aStr = aStr.replaceAt( 0, nPos+1, "" );
nPos = aStr.indexOf( '\n' );
}
if ( maLstBox.GetEntryCount() >= DBGWIN_MAXLINES )
maLstBox.RemoveEntry( 0 );
sal_uInt16 nInsertionPos = maLstBox.InsertEntry( aStr );
if ( bFirstEntry )
maLstBox.SetEntryData( nInsertionPos, reinterpret_cast< void* >( 1 ) );
maLstBox.SetTopEntry( DBGWIN_MAXLINES-1 );
maLstBox.Update();
}
DbgDialog::DbgDialog() :
ModalDialog( NULL, WB_STDMODAL | WB_SYSTEMWINDOW ),
maXtorThis( this ),
maXtorFunc( this ),
maXtorExit( this ),
maXtorReport( this ),
maXtorTrace( this ),
maBox1( this ),
maRes( this ),
maDialog( this ),
maBoldAppFont( this ),
maBox3( this ),
maDebugName( this ),
maOverwrite( this ),
maInclClassText( this ),
maInclClassFilter( this ),
maExclClassText( this ),
maExclClassFilter( this ),
maInclText( this ),
maInclFilter( this ),
maExclText( this ),
maExclFilter( this ),
maTraceText( this ),
maTraceBox( this, WB_DROPDOWN ),
maErrorText( this ),
maErrorBox( this, WB_DROPDOWN ),
maBox4( this ),
maOKButton( this, WB_DEFBUTTON ),
maCancelButton( this ),
maInfoButton( this ),
maHelpButton( this )
{
DbgData* pData = DbgGetData();
MapMode aAppMap( MAP_APPFONT );
Size aButtonSize = LogicToPixel( Size( 60, 12 ), aAppMap );
{
maXtorThis.Show();
maXtorThis.SetText("T~his");
if ( pData->nTestFlags & DBG_TEST_XTOR_THIS )
maXtorThis.Check( true );
maXtorThis.SetPosSizePixel( LogicToPixel( Point( 10, 15 ), aAppMap ),
aButtonSize );
}
{
maXtorFunc.Show();
maXtorFunc.SetText("~Function");
if ( pData->nTestFlags & DBG_TEST_XTOR_FUNC )
maXtorFunc.Check( true );
maXtorFunc.SetPosSizePixel( LogicToPixel( Point( 75, 15 ), aAppMap ),
aButtonSize );
}
{
maXtorExit.Show();
maXtorExit.SetText("E~xit");
if ( pData->nTestFlags & DBG_TEST_XTOR_EXIT )
maXtorExit.Check( true );
maXtorExit.SetPosSizePixel( LogicToPixel( Point( 140, 15 ), aAppMap ),
aButtonSize );
}
{
maXtorReport.Show();
maXtorReport.SetText("~Report");
if ( pData->nTestFlags & DBG_TEST_XTOR_REPORT )
maXtorReport.Check( true );
maXtorReport.SetPosSizePixel( LogicToPixel( Point( 205, 15 ), aAppMap ),
aButtonSize );
}
{
maXtorTrace.Show();
maXtorTrace.SetText("~Trace");
if ( pData->nTestFlags & DBG_TEST_XTOR_TRACE )
maXtorTrace.Check( true );
maXtorTrace.SetPosSizePixel( LogicToPixel( Point( 270, 15 ), aAppMap ),
aButtonSize );
}
{
maBox1.Show();
maBox1.SetText("Object Tests");
maBox1.SetPosSizePixel( LogicToPixel( Point( 5, 5 ), aAppMap ),
LogicToPixel( Size( 330, 30 ), aAppMap ) );
}
{
maRes.Show();
maRes.SetText("~Resourcen");
if ( pData->nTestFlags & DBG_TEST_RESOURCE )
maRes.Check( true );
maRes.SetPosSizePixel( LogicToPixel( Point( 75, 95 ), aAppMap ),
aButtonSize );
}
{
maDialog.Show();
maDialog.SetText("~Dialog");
if ( pData->nTestFlags & DBG_TEST_DIALOG )
maDialog.Check( true );
maDialog.SetPosSizePixel( LogicToPixel( Point( 140, 95 ), aAppMap ),
aButtonSize );
}
{
maBoldAppFont.Show();
maBoldAppFont.SetText("~Bold AppFont");
if ( pData->nTestFlags & DBG_TEST_BOLDAPPFONT )
maBoldAppFont.Check( true );
maBoldAppFont.SetPosSizePixel( LogicToPixel( Point( 205, 95 ), aAppMap ),
aButtonSize );
maBoldAppFont.SaveValue();
}
{
maBox3.Show();
maBox3.SetText("Test Options");
maBox3.SetPosSizePixel( LogicToPixel( Point( 5, 85 ), aAppMap ),
LogicToPixel( Size( 330, 30 ), aAppMap ) );
}
{
maDebugName.Show();
maDebugName.SetText(OStringToOUString(pData->aDebugName, RTL_TEXTENCODING_UTF8));
maDebugName.SetMaxTextLen( sizeof( pData->aDebugName ) );
maDebugName.SetPosSizePixel( LogicToPixel( Point( 10, 130 ), aAppMap ),
LogicToPixel( Size( 185, 14 ), aAppMap ) );
}
{
maOverwrite.Show();
maOverwrite.SetText("Overwrite ~File");
if ( pData->bOverwrite )
maOverwrite.Check( true );
maOverwrite.SetPosSizePixel( LogicToPixel( Point( 205, 130 ), aAppMap ),
aButtonSize );
}
{
maInclClassText.Show();
maInclClassText.SetText("~Include-ObjectTest-Filter");
maInclClassText.SetPosSizePixel( LogicToPixel( Point( 10, 150 ), aAppMap ),
LogicToPixel( Size( 95, 9 ), aAppMap ) );
}
{
maInclClassFilter.Show();
maInclClassFilter.SetText(OStringToOUString(pData->aInclClassFilter, RTL_TEXTENCODING_UTF8));
maInclClassFilter.SetMaxTextLen( sizeof( pData->aInclClassFilter ) );
maInclClassFilter.SetPosSizePixel( LogicToPixel( Point( 10, 160 ), aAppMap ),
LogicToPixel( Size( 95, 14 ), aAppMap ) );
}
{
maExclClassText.Show();
maExclClassText.SetText("~Exclude-ObjectTest-Filter");
maExclClassText.SetPosSizePixel( LogicToPixel( Point( 115, 150 ), aAppMap ),
LogicToPixel( Size( 95, 9 ), aAppMap ) );
}
{
maExclClassFilter.Show();
maExclClassFilter.SetText(OStringToOUString(pData->aExclClassFilter, RTL_TEXTENCODING_UTF8));
maExclClassFilter.SetMaxTextLen( sizeof( pData->aExclClassFilter ) );
maExclClassFilter.SetPosSizePixel( LogicToPixel( Point( 115, 160 ), aAppMap ),
LogicToPixel( Size( 95, 14 ), aAppMap ) );
}
{
maInclText.Show();
maInclText.SetText("~Include-Filter");
maInclText.SetPosSizePixel( LogicToPixel( Point( 10, 180 ), aAppMap ),
LogicToPixel( Size( 95, 9 ), aAppMap ) );
}
{
maInclFilter.Show();
maInclFilter.SetText(OStringToOUString(pData->aInclFilter, RTL_TEXTENCODING_UTF8));
maInclFilter.SetMaxTextLen( sizeof( pData->aInclFilter ) );
maInclFilter.SetPosSizePixel( LogicToPixel( Point( 10, 190 ), aAppMap ),
LogicToPixel( Size( 95, 14 ), aAppMap ) );
}
{
maExclText.Show();
maExclText.SetText("~Exclude-Filter");
maExclText.SetPosSizePixel( LogicToPixel( Point( 115, 180 ), aAppMap ),
LogicToPixel( Size( 95, 9 ), aAppMap ) );
}
{
maExclFilter.Show();
maExclFilter.SetText(OStringToOUString(pData->aExclFilter, RTL_TEXTENCODING_UTF8));
maExclFilter.SetMaxTextLen( sizeof( pData->aExclFilter ) );
maExclFilter.SetPosSizePixel( LogicToPixel( Point( 115, 190 ), aAppMap ),
LogicToPixel( Size( 95, 14 ), aAppMap ) );
}
{
maTraceText.Show();
maTraceText.SetText("~Trace");
maTraceText.SetPosSizePixel( LogicToPixel( Point( 10, 210 ), aAppMap ),
LogicToPixel( Size( 95, 9 ), aAppMap ) );
}
{
maTraceBox.InsertEntry(OUString("None"));
maTraceBox.InsertEntry(OUString("File"));
maTraceBox.InsertEntry(OUString("Window"));
maTraceBox.InsertEntry(OUString("Shell"));
maTraceBox.InsertEntry(OUString("MessageBox"));
maTraceBox.InsertEntry(OUString("TestTool"));
maTraceBox.InsertEntry(OUString("Debugger"));
maTraceBox.InsertEntry(OUString("Abort"));
ImplAppendUserDefinedChannels( maTraceBox );
ImplSelectChannel( maTraceBox, pData->nTraceOut, 0 );
maTraceBox.Show();
maTraceBox.SetPosSizePixel( LogicToPixel( Point( 10, 220 ), aAppMap ),
LogicToPixel( Size( 95, 80 ), aAppMap ) );
}
{
maErrorText.Show();
maErrorText.SetText("~Error");
maErrorText.SetPosSizePixel( LogicToPixel( Point( 220, 210 ), aAppMap ),
LogicToPixel( Size( 95, 9 ), aAppMap ) );
}
{
if ( DbgIsAllErrorOut() )
{
maErrorBox.InsertEntry( OUString("None") );
maErrorBox.InsertEntry( OUString("File") );
maErrorBox.InsertEntry( OUString("Window") );
maErrorBox.InsertEntry( OUString("Shell") );
mnErrorOff = 0;
}
else
mnErrorOff = 4;
maErrorBox.InsertEntry( OUString("MessageBox") );
maErrorBox.InsertEntry( OUString("TestTool") );
maErrorBox.InsertEntry( OUString("Debugger") );
maErrorBox.InsertEntry( OUString("Abort") );
ImplAppendUserDefinedChannels( maErrorBox );
ImplSelectChannel( maErrorBox, pData->nErrorOut, mnErrorOff );
maErrorBox.Show();
maErrorBox.SetPosSizePixel( LogicToPixel( Point( 220, 220 ), aAppMap ),
LogicToPixel( Size( 95, 80 ), aAppMap ) );
}
{
maBox4.Show();
maBox4.SetText("Output");
maBox4.SetPosSizePixel( LogicToPixel( Point( 5, 120 ), aAppMap ),
LogicToPixel( Size( 330, 135 ), aAppMap ) );
}
{
maOKButton.Show();
maOKButton.SetClickHdl( LINK( this, DbgDialog, ClickHdl ) );
maOKButton.SetPosSizePixel( LogicToPixel( Point( 10, 260 ), aAppMap ),
LogicToPixel( Size( 50, 15 ), aAppMap ) );
}
{
maCancelButton.Show();
maCancelButton.SetPosSizePixel( LogicToPixel( Point( 70, 260 ), aAppMap ),
LogicToPixel( Size( 50, 15 ), aAppMap ) );
}
{
maInfoButton.Show();
maInfoButton.SetClickHdl( LINK( this, DbgDialog, ClickHdl ) );
maInfoButton.SetText("~Info...");
maInfoButton.SetPosSizePixel( LogicToPixel( Point( 130, 260 ), aAppMap ),
LogicToPixel( Size( 50, 15 ), aAppMap ) );
}
{
maHelpButton.Show();
maHelpButton.SetPosSizePixel( LogicToPixel( Point( 190, 260 ), aAppMap ),
LogicToPixel( Size( 50, 15 ), aAppMap ) );
}
{
SetText("VCL Debug Options");
SetOutputSizePixel( LogicToPixel( Size( 340, 280 ), aAppMap ) );
}
}
IMPL_LINK( DbgDialog, ClickHdl, Button*, pButton )
{
if ( pButton == &maOKButton )
{
DbgData aData;
memcpy( &aData, DbgGetData(), sizeof( DbgData ) );
aData.nTestFlags = 0;
aData.nTraceOut = ImplGetChannelId( maTraceBox, 0 );
aData.nErrorOut = ImplGetChannelId( maErrorBox, mnErrorOff );
strncpy( aData.aDebugName, OUStringToOString(maDebugName.GetText(), RTL_TEXTENCODING_UTF8).getStr(), sizeof( aData.aDebugName ) );
strncpy( aData.aInclClassFilter, OUStringToOString(maInclClassFilter.GetText(), RTL_TEXTENCODING_UTF8).getStr(), sizeof( aData.aInclClassFilter ) );
strncpy( aData.aExclClassFilter, OUStringToOString(maExclClassFilter.GetText(), RTL_TEXTENCODING_UTF8).getStr(), sizeof( aData.aExclClassFilter ) );
strncpy( aData.aInclFilter, OUStringToOString(maInclFilter.GetText(), RTL_TEXTENCODING_UTF8).getStr(), sizeof( aData.aInclFilter ) );
strncpy( aData.aExclFilter, OUStringToOString(maExclFilter.GetText(), RTL_TEXTENCODING_UTF8).getStr(), sizeof( aData.aExclFilter ) );
aData.aDebugName[sizeof( aData.aDebugName )-1] = '\0';
aData.aInclClassFilter[sizeof( aData.aInclClassFilter )-1] = '\0';
aData.aExclClassFilter[sizeof( aData.aExclClassFilter )-1] = '\0';
aData.aInclFilter[sizeof( aData.aInclFilter )-1] = '\0';
aData.aExclFilter[sizeof( aData.aExclFilter )-1] = '\0';
aData.bOverwrite = maOverwrite.IsChecked() ? true : false;
if ( maXtorThis.IsChecked() )
aData.nTestFlags |= DBG_TEST_XTOR_THIS;
if ( maXtorFunc.IsChecked() )
aData.nTestFlags |= DBG_TEST_XTOR_FUNC;
if ( maXtorExit.IsChecked() )
aData.nTestFlags |= DBG_TEST_XTOR_EXIT;
if ( maXtorReport.IsChecked() )
aData.nTestFlags |= DBG_TEST_XTOR_REPORT;
if ( maXtorTrace.IsChecked() )
aData.nTestFlags |= DBG_TEST_XTOR_TRACE;
if ( maRes.IsChecked() )
aData.nTestFlags |= DBG_TEST_RESOURCE;
if ( maDialog.IsChecked() )
aData.nTestFlags |= DBG_TEST_DIALOG;
if ( maBoldAppFont.IsChecked() )
aData.nTestFlags |= DBG_TEST_BOLDAPPFONT;
// Daten speichern
DbgSaveData( aData );
// Umschalten der Laufzeitwerte
DBG_INSTOUTTRACE( aData.nTraceOut );
DBG_INSTOUTERROR( aData.nErrorOut );
DbgData* pData = DbgGetData();
#define IMMEDIATE_FLAGS (DBG_TEST_RESOURCE | DBG_TEST_DIALOG | DBG_TEST_BOLDAPPFONT)
pData->nTestFlags &= ~IMMEDIATE_FLAGS;
pData->nTestFlags |= aData.nTestFlags & IMMEDIATE_FLAGS;
strncpy( pData->aInclClassFilter, aData.aInclClassFilter, sizeof( pData->aInclClassFilter ) );
strncpy( pData->aExclClassFilter, aData.aExclClassFilter, sizeof( pData->aExclClassFilter ) );
strncpy( pData->aInclFilter, aData.aInclFilter, sizeof( pData->aInclFilter ) );
strncpy( pData->aExclFilter, aData.aExclFilter, sizeof( pData->aExclFilter ) );
if ( maBoldAppFont.GetSavedValue() != TriState(maBoldAppFont.IsChecked()) )
{
AllSettings aSettings = Application::GetSettings();
StyleSettings aStyleSettings = aSettings.GetStyleSettings();
Font aFont = aStyleSettings.GetAppFont();
if ( maBoldAppFont.IsChecked() )
aFont.SetWeight( WEIGHT_BOLD );
else
aFont.SetWeight( WEIGHT_NORMAL );
aStyleSettings.SetAppFont( aFont );
aSettings.SetStyleSettings( aStyleSettings );
Application::SetSettings( aSettings );
}
if( (aData.nTestFlags & ~IMMEDIATE_FLAGS) != (pData->nTestFlags & ~IMMEDIATE_FLAGS) )
{
InfoBox aBox( this, OUString(
"Some of the changed settings will only be active after "
"restarting the process"
) );
aBox.Execute();
}
EndDialog( RET_OK );
}
else if ( pButton == &maInfoButton )
{
DbgInfoDialog aInfoDialog( this );
aDbgInfoBuf[0] = '\0';
DbgXtorInfo( aDbgInfoBuf );
OUString aInfoText( aDbgInfoBuf, strlen(aDbgInfoBuf), RTL_TEXTENCODING_UTF8 );
aInfoDialog.SetText( "Debug InfoReport" );
aInfoDialog.SetInfoText( aInfoText );
aInfoDialog.Execute();
}
return 0;
}
void DbgDialog::RequestHelp( const HelpEvent& rHEvt )
{
if ( rHEvt.GetMode() & HELPMODE_CONTEXT )
{
DbgInfoDialog aInfoDialog( this, true );
OUString aHelpText;
const sal_Char** pHelpStrs = pDbgHelpText;
while ( *pHelpStrs )
{
aHelpText += OUString::createFromAscii(*pHelpStrs);
pHelpStrs++;
}
aInfoDialog.SetText( "Debug Hilfe" );
aInfoDialog.SetInfoText( aHelpText );
aInfoDialog.Execute();
}
}
DbgInfoDialog::DbgInfoDialog( Window* pParent, bool bHelpText ) :
ModalDialog( pParent, WB_STDMODAL ),
maListBox( this, WB_BORDER | WB_AUTOHSCROLL ),
maOKButton( this, WB_DEFBUTTON )
{
mbHelpText = bHelpText;
if ( !bHelpText )
{
Font aFont = GetDefaultFont( DEFAULTFONT_FIXED, LANGUAGE_ENGLISH_US, 0 );
aFont.SetHeight( 8 );
aFont.SetPitch( PITCH_FIXED );
maListBox.SetControlFont( aFont );
}
maListBox.SetPosSizePixel( Point( 5, 5 ), Size( 630, 380 ) );
maListBox.Show();
maOKButton.SetPosSizePixel( Point( 290, 390 ), Size( 60, 25 ) );
maOKButton.Show();
SetOutputSizePixel( Size( 640, 420 ) );
}
void DbgInfoDialog::SetInfoText( const OUString& rStr )
{
maListBox.SetUpdateMode( false );
maListBox.Clear();
OUString aStr = convertLineEnd(rStr, LINEEND_LF);
sal_Int32 nStrIndex = 0;
sal_Int32 nFoundIndex;
do
{
nFoundIndex = aStr.indexOf( '\n', nStrIndex );
OUString aTextParagraph = aStr.copy( nStrIndex, nFoundIndex-nStrIndex );
if ( mbHelpText )
{
long nMaxWidth = maListBox.GetOutputSizePixel().Width()-30;
sal_Int32 nLastIndex = 0;
sal_Int32 nIndex = aTextParagraph.indexOf( ' ' );
while ( nIndex != -1 )
{
if ( maListBox.GetTextWidth( aTextParagraph, 0, nIndex ) > nMaxWidth )
{
if ( !nLastIndex )
nLastIndex = nIndex+1;
OUString aTempStr = aTextParagraph.copy( 0, nLastIndex );
aTextParagraph = aTextParagraph.replaceAt( 0, nLastIndex, "" );
maListBox.InsertEntry( aTempStr );
nLastIndex = 0;
}
else
nLastIndex = nIndex+1;
nIndex = aTextParagraph.indexOf( ' ', nLastIndex );
}
if ( maListBox.GetTextWidth( aTextParagraph, 0, nIndex ) > nMaxWidth )
{
if ( !nLastIndex )
nLastIndex = nIndex+1;
OUString aTempStr = aTextParagraph.copy( 0, nLastIndex );
aTextParagraph = aTextParagraph.replaceAt( 0, nLastIndex, "" );
maListBox.InsertEntry( aTempStr );
}
}
maListBox.InsertEntry( aTextParagraph );
nStrIndex = nFoundIndex+1;
}
while ( nFoundIndex != -1 );
maListBox.SetUpdateMode( true );
}
void DbgDialogTest( Window* pWindow )
{
bool aAccelBuf[65536] = {false};
sal_uInt16 nChildCount = pWindow->GetChildCount();
Window* pGetChild = pWindow->GetWindow( WINDOW_FIRSTCHILD );
Window* pChild;
Point aTabPos;
if ( !pGetChild )
return;
boost::scoped_array<Rectangle> pRectAry((Rectangle*)new long[(sizeof(Rectangle)*nChildCount)/sizeof(long)]);
memset( pRectAry.get(), 0, sizeof(Rectangle)*nChildCount );
if ( pWindow->IsDialog() )
{
bool bOKCancelButton = false;
bool bDefPushButton = false;
bool bButton = false;
pGetChild = pWindow->GetWindow( WINDOW_FIRSTCHILD );
while ( pGetChild )
{
pChild = pGetChild->ImplGetWindow();
if ( pChild->ImplIsPushButton() )
{
bButton = true;
if ( (pChild->GetType() == WINDOW_OKBUTTON) || (pChild->GetType() == WINDOW_CANCELBUTTON) )
bOKCancelButton = true;
if ( pChild->GetStyle() & WB_DEFBUTTON )
bDefPushButton = true;
}
pGetChild = pGetChild->GetWindow( WINDOW_NEXT );
}
if ( bButton )
{
SAL_WARN_IF(
!bOKCancelButton, "vcl",
"Dialogs should have a OK- or CancelButton");
SAL_WARN_IF(
!bDefPushButton, "vcl",
"Dialogs should have a Button with WB_DEFBUTTON");
}
}
sal_uInt16 i = 0;
pGetChild = pWindow->GetWindow( WINDOW_FIRSTCHILD );
while ( pGetChild )
{
pChild = pGetChild->ImplGetWindow();
if ( (pChild->GetType() != WINDOW_TABCONTROL) &&
(pChild->GetType() != WINDOW_TABPAGE) &&
(pChild->GetType() != WINDOW_GROUPBOX) )
{
OUString aText = pChild->GetText();
OUString aErrorText = aText;
sal_Int32 nAccelPos = -1;
sal_Unicode cAccel = 0;
if ( aErrorText.getLength() > 128 )
{
aErrorText = aErrorText.replaceAt( 128, aErrorText.getLength()-128, "" );
aErrorText += "...";
}
if ( !aText.isEmpty() && (aText.getLength() < 1024) )
{
nAccelPos = aText.indexOf( '~' );
if ( nAccelPos != -1 )
{
const ::com::sun::star::lang::Locale& rLocale = Application::GetSettings().GetLanguageTag().getLocale();
uno::Reference < i18n::XCharacterClassification > xCharClass = vcl::unohelper::CreateCharacterClassification();
OUString aUpperText = xCharClass->toUpper( aText, 0, aText.getLength(), rLocale );
cAccel = aUpperText[nAccelPos+1];
if ( pChild->IsVisible() )
{
if ( aAccelBuf[cAccel] )
DbgOutTypef( DBG_OUT_ERROR, "Double mnemonic char: %c", cAccel );
else
aAccelBuf[cAccel] = true;
}
}
}
if ( (pChild->GetType() == WINDOW_RADIOBUTTON) ||
(pChild->GetType() == WINDOW_CHECKBOX) ||
(pChild->GetType() == WINDOW_TRISTATEBOX) ||
(pChild->GetType() == WINDOW_PUSHBUTTON) )
{
if ( !aText.isEmpty() && aText != "..." )
{
const char* pClass;
if ( pChild->GetType() == WINDOW_RADIOBUTTON )
pClass = "RadioButton";
else if ( pChild->GetType() == WINDOW_CHECKBOX )
pClass = "CheckBox";
else if ( pChild->GetType() == WINDOW_TRISTATEBOX )
pClass = "TriStateBox";
else if ( pChild->GetType() == WINDOW_PUSHBUTTON )
pClass = "PushButton";
else
pClass = "Dontknow";
if( !cAccel )
DbgOutTypef( DBG_OUT_ERROR,
"%s should have a mnemonic char (~): %s",
pClass,
OUStringToOString(aErrorText, RTL_TEXTENCODING_UTF8).getStr() );
// check text width
int aWidth=0;
switch( pChild->GetType() )
{
case WINDOW_RADIOBUTTON:
aWidth = ((RadioButton*)pChild)->CalcMinimumSize(0).Width();
break;
case WINDOW_CHECKBOX:
case WINDOW_TRISTATEBOX:
aWidth = ((CheckBox*)pChild)->CalcMinimumSize(0).Width();
break;
case WINDOW_PUSHBUTTON:
aWidth = ((PushButton*)pChild)->CalcMinimumSize(0).Width();
break;
default: break;
}
if( pChild->IsVisible() && pChild->GetSizePixel().Width() < aWidth )
DbgOutTypef( DBG_OUT_ERROR,
"%s exceeds window width: %s",
pClass,
OUStringToOString(aErrorText, RTL_TEXTENCODING_UTF8).getStr() );
}
}
if ( pChild->GetType() == WINDOW_FIXEDLINE )
{
if ( pChild->GetSizePixel().Width() < pChild->GetTextWidth( aText ) )
DbgOutTypef( DBG_OUT_ERROR,
"FixedLine exceeds window width: %s",
OUStringToOString(aErrorText, RTL_TEXTENCODING_UTF8).getStr() );
}
if ( pChild->GetType() == WINDOW_FIXEDTEXT )
{
if ( (pChild->GetSizePixel().Height() >= pChild->GetTextHeight()*2) &&
!(pChild->GetStyle() & WB_WORDBREAK) )
{
DbgOutTypef( DBG_OUT_ERROR,
"FixedText greater than one line, but WordBreak is not set: %s",
OUStringToOString(aErrorText, RTL_TEXTENCODING_UTF8).getStr() );
}
if ( pChild->IsVisible() )
{
int aWidth=0;
if( nAccelPos != -1 )
{
aWidth = pChild->GetTextWidth( aText, 0, nAccelPos ) +
pChild->GetTextWidth( aText, nAccelPos+1, aText.getLength() - nAccelPos - 1);
}
else
aWidth = pChild->GetTextWidth( aText );
if ( pChild->GetSizePixel().Width() < aWidth && !(pChild->GetStyle() & WB_WORDBREAK) )
{
DbgOutTypef( DBG_OUT_ERROR,
"FixedText exceeds window width: %s",
OUStringToOString(aErrorText, RTL_TEXTENCODING_UTF8).getStr() );
}
}
if ( (i+1 < nChildCount) && !aText.isEmpty() )
{
Window* pTempChild = pGetChild->GetWindow( WINDOW_NEXT )->ImplGetWindow();
if ( (pTempChild->GetType() == WINDOW_EDIT) ||
(pTempChild->GetType() == WINDOW_MULTILINEEDIT) ||
(pTempChild->GetType() == WINDOW_SPINFIELD) ||
(pTempChild->GetType() == WINDOW_PATTERNFIELD) ||
(pTempChild->GetType() == WINDOW_NUMERICFIELD) ||
(pTempChild->GetType() == WINDOW_METRICFIELD) ||
(pTempChild->GetType() == WINDOW_CURRENCYFIELD) ||
(pTempChild->GetType() == WINDOW_DATEFIELD) ||
(pTempChild->GetType() == WINDOW_TIMEFIELD) ||
(pTempChild->GetType() == WINDOW_LISTBOX) ||
(pTempChild->GetType() == WINDOW_MULTILISTBOX) ||
(pTempChild->GetType() == WINDOW_COMBOBOX) ||
(pTempChild->GetType() == WINDOW_PATTERNBOX) ||
(pTempChild->GetType() == WINDOW_NUMERICBOX) ||
(pTempChild->GetType() == WINDOW_METRICBOX) ||
(pTempChild->GetType() == WINDOW_CURRENCYBOX) ||
(pTempChild->GetType() == WINDOW_DATEBOX) ||
(pTempChild->GetType() == WINDOW_TIMEBOX) )
{
if ( !cAccel )
{
DbgOutTypef( DBG_OUT_ERROR,
"Labels befor Fields (Edit,ListBox,...) should have a mnemonic char (~): %s",
OUStringToOString(aErrorText, RTL_TEXTENCODING_UTF8).getStr() );
}
if ( !pTempChild->IsEnabled() && pChild->IsEnabled() )
{
DbgOutTypef( DBG_OUT_ERROR,
"Labels befor Fields (Edit,ListBox,...) should be disabled, when the field is disabled: %s",
OUStringToOString(aErrorText, RTL_TEXTENCODING_UTF8).getStr() );
}
}
}
}
SAL_WARN_IF(
(pChild->GetType() == WINDOW_MULTILINEEDIT
&& (pChild->GetStyle() & (WB_IGNORETAB | WB_READONLY)) == 0),
"vcl",
("editable MultiLineEdits in Dialogs should have the Style"
" WB_IGNORETAB"));
if ( (pChild->GetType() == WINDOW_RADIOBUTTON) ||
(pChild->GetType() == WINDOW_CHECKBOX) ||
(pChild->GetType() == WINDOW_TRISTATEBOX) ||
(pChild->GetType() == WINDOW_FIXEDTEXT) )
{
pChild->SetBackground( Wallpaper( Color( COL_LIGHTGREEN ) ) );
}
if ( pChild->IsVisible() )
{
bool bMaxWarning = false;
if ( pChild->GetType() == WINDOW_NUMERICFIELD )
{
NumericField* pField = (NumericField*)pChild;
if ( pField->GetMax() == LONG_MAX )
bMaxWarning = true;
}
else if ( pChild->GetType() == WINDOW_METRICFIELD )
{
MetricField* pField = (MetricField*)pChild;
if ( pField->GetMax() == LONG_MAX )
bMaxWarning = true;
}
else if ( pChild->GetType() == WINDOW_CURRENCYFIELD )
{
CurrencyField* pField = (CurrencyField*)pChild;
if ( pField->GetMax() == LONG_MAX )
bMaxWarning = true;
}
else if ( pChild->GetType() == WINDOW_TIMEFIELD )
{
TimeField* pField = (TimeField*)pChild;
if ( pField->GetMax() == Time( 23, 59, 59, 99 ) )
bMaxWarning = true;
}
else if ( pChild->GetType() == WINDOW_DATEFIELD )
{
DateField* pField = (DateField*)pChild;
if ( pField->GetMax() == Date( 31, 12, 9999 ) )
bMaxWarning = true;
}
else if ( pChild->GetType() == WINDOW_NUMERICBOX )
{
NumericBox* pBox = (NumericBox*)pChild;
if ( pBox->GetMax() == LONG_MAX )
bMaxWarning = true;
}
else if ( pChild->GetType() == WINDOW_METRICBOX )
{
MetricBox* pBox = (MetricBox*)pChild;
if ( pBox->GetMax() == LONG_MAX )
bMaxWarning = true;
}
else if ( pChild->GetType() == WINDOW_CURRENCYBOX )
{
CurrencyBox* pBox = (CurrencyBox*)pChild;
if ( pBox->GetMax() == LONG_MAX )
bMaxWarning = true;
}
else if ( pChild->GetType() == WINDOW_TIMEBOX )
{
TimeBox* pBox = (TimeBox*)pChild;
if ( pBox->GetMax() == Time( 23, 59, 59, 99 ) )
bMaxWarning = true;
}
else if ( pChild->GetType() == WINDOW_DATEBOX )
{
DateBox* pBox = (DateBox*)pChild;
if ( pBox->GetMax() == Date( 31, 12, 9999 ) )
bMaxWarning = true;
}
if ( bMaxWarning )
{
DbgOutTypef( DBG_OUT_ERROR,
"No Max-Value is set: %s",
OUStringToOString(aErrorText, RTL_TEXTENCODING_UTF8).getStr() );
}
if ( (pChild->GetType() == WINDOW_RADIOBUTTON) ||
(pChild->GetType() == WINDOW_CHECKBOX) ||
(pChild->GetType() == WINDOW_TRISTATEBOX) ||
(pChild->GetType() == WINDOW_PUSHBUTTON) ||
(pChild->GetType() == WINDOW_OKBUTTON) ||
(pChild->GetType() == WINDOW_CANCELBUTTON) ||
(pChild->GetType() == WINDOW_HELPBUTTON) ||
(pChild->GetType() == WINDOW_IMAGEBUTTON) ||
(pChild->GetType() == WINDOW_FIXEDTEXT) ||
(pChild->GetType() == WINDOW_EDIT) ||
(pChild->GetType() == WINDOW_MULTILINEEDIT) ||
(pChild->GetType() == WINDOW_SPINFIELD) ||
(pChild->GetType() == WINDOW_PATTERNFIELD) ||
(pChild->GetType() == WINDOW_NUMERICFIELD) ||
(pChild->GetType() == WINDOW_METRICFIELD) ||
(pChild->GetType() == WINDOW_CURRENCYFIELD) ||
(pChild->GetType() == WINDOW_DATEFIELD) ||
(pChild->GetType() == WINDOW_TIMEFIELD) ||
(pChild->GetType() == WINDOW_LISTBOX) ||
(pChild->GetType() == WINDOW_MULTILISTBOX) ||
(pChild->GetType() == WINDOW_COMBOBOX) ||
(pChild->GetType() == WINDOW_PATTERNBOX) ||
(pChild->GetType() == WINDOW_NUMERICBOX) ||
(pChild->GetType() == WINDOW_METRICBOX) ||
(pChild->GetType() == WINDOW_CURRENCYBOX) ||
(pChild->GetType() == WINDOW_DATEBOX) ||
(pChild->GetType() == WINDOW_TIMEBOX) )
{
Point aNewPos = pChild->GetPosPixel();
Rectangle aChildRect( aNewPos, pChild->GetSizePixel() );
if ( cAccel || (pChild->GetStyle() & WB_TABSTOP) ||
(pChild->GetType() == WINDOW_RADIOBUTTON) )
{
if ( (aNewPos.X() <= aTabPos.X()) && (aNewPos.Y() <= aTabPos.Y()) )
{
DbgOutTypef( DBG_OUT_ERROR,
"Possible wrong childorder for dialogcontrol: %s",
OUStringToOString(aErrorText, RTL_TEXTENCODING_UTF8).getStr() );
}
aTabPos = aNewPos;
}
for ( sal_uInt16 j = 0; j < i; j++ )
{
if ( ((pRectAry[j].Right() != 0) || (pRectAry[j].Bottom() != 0)) &&
aChildRect.IsOver( pRectAry[j] ) )
{
DbgOutTypef( DBG_OUT_ERROR,
"Window overlaps with sibling window: %s",
OUStringToOString(aErrorText, RTL_TEXTENCODING_UTF8).getStr() );
}
}
pRectAry[i] = aChildRect;
}
}
}
pGetChild = pGetChild->GetWindow( WINDOW_NEXT );
i++;
}
}
#ifndef WNT
#define USE_VCL_MSGBOX
#define COPY_BUTTON_ID 25
class DbgMessageBox : public ErrorBox
{
OUString m_aMessage;
public:
DbgMessageBox( const OUString& rMessage ) :
ErrorBox( NULL, WB_YES_NO_CANCEL | WB_DEF_NO, rMessage ),
m_aMessage( rMessage )
{
SetText("Debug Output");
AddButton(OUString("Copy"), COPY_BUTTON_ID, 0);
}
virtual void Click()
{
if( GetCurButtonId() == COPY_BUTTON_ID )
vcl::unohelper::TextDataObject::CopyStringTo( m_aMessage, GetClipboard() );
else
ErrorBox::Click();
}
};
#endif
class SolarMessageBoxExecutor : public ::vcl::SolarThreadExecutor
{
private:
OUString m_sDebugMessage;
public:
SolarMessageBoxExecutor( const OUString& _rDebugMessage )
:m_sDebugMessage( _rDebugMessage )
{
}
protected:
virtual long doIt();
};
long SolarMessageBoxExecutor::doIt()
{
long nResult = RET_NO;
// Stop tracking and release mouse, to assure boxes do not hang
ImplSVData* pSVData = ImplGetSVData();
if ( pSVData->maWinData.mpTrackWin )
pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL );
if ( pSVData->maWinData.mpCaptureWin )
pSVData->maWinData.mpCaptureWin->ReleaseMouse();
#if ! defined USE_VCL_MSGBOX
#ifdef WNT
bool bOldCallTimer = pSVData->mbNoCallTimer;
pSVData->mbNoCallTimer = true;
nResult = MessageBoxW( 0, (LPWSTR)m_sDebugMessage.getStr(), L"Debug Output",
MB_TASKMODAL | MB_YESNOCANCEL | MB_DEFBUTTON2 | MB_ICONSTOP );
pSVData->mbNoCallTimer = bOldCallTimer;
switch ( nResult )
{
case IDYES:
nResult = RET_YES;
break;
case IDNO:
nResult = RET_NO;
break;
case IDCANCEL:
nResult = RET_CANCEL;
break;
}
#endif // WNT
#else
sal_uInt16 nOldMode = Application::GetSystemWindowMode();
Application::SetSystemWindowMode( nOldMode & ~SYSTEMWINDOW_MODE_NOAUTOMODE );
DbgMessageBox aBox( m_sDebugMessage );
Application::SetSystemWindowMode( nOldMode );
nResult = aBox.Execute();
#endif
return nResult;
}
void DbgPrintMsgBox( const char* pLine )
{
// are modal message boxes prohibited at the moment?
if ( Application::IsDialogCancelEnabled() )
{
#if defined( WNT )
// TODO: Shouldn't this be a IsDebuggerPresent()?
if ( GetSystemMetrics( SM_DEBUG ) )
{
strcpy( aDbgOutBuf, pLine );
strcat( aDbgOutBuf, "\r\n" );
OutputDebugString( aDbgOutBuf );
return;
}
#endif
#ifdef UNX
fprintf( stderr, "%s\n", pLine );
return;
#else
DbgPrintFile( pLine );
return;
#endif
}
strcpy( aDbgOutBuf, pLine );
#if defined UNX && HAVE_FEATURE_DESKTOP
strcat( aDbgOutBuf, "\nAbort ? (Yes=abort / No=ignore / Cancel=core dump)" );
#elif defined _WIN32
strcat( aDbgOutBuf, "\nAbort ? (Yes=abort / No=ignore / Cancel=try to invoke debugger)" );
#else
strcat( aDbgOutBuf, "\nAbort ? (Yes=abort / No=ignore / Cancel=crash)" );
#endif
SolarMessageBoxExecutor aMessageBox( OUString( aDbgOutBuf, strlen(aDbgOutBuf), RTL_TEXTENCODING_UTF8 ) );
TimeValue aTimeout; aTimeout.Seconds = 2; aTimeout.Nanosec = 0;
long nResult = aMessageBox.execute( aTimeout );
if ( aMessageBox.didTimeout() )
DbgPrintShell( pLine );
else if ( nResult == RET_YES )
GetpApp()->Abort( OUString("Debug-Utilities-Error") );
else if ( nResult == RET_CANCEL )
DbgCoreDump();
}
class SolarWindowPrinter : public ::vcl::SolarThreadExecutor
{
private:
OUString m_sDebugMessage;
public:
SolarWindowPrinter( const OUString& _rDebugMessage )
:m_sDebugMessage( _rDebugMessage )
{
}
protected:
virtual long doIt();
};
long SolarWindowPrinter::doIt()
{
DbgWindow* pDbgWindow = ImplGetSVData()->maWinData.mpDbgWin;
if ( !pDbgWindow )
{
pDbgWindow = new DbgWindow;
ImplGetSVData()->maWinData.mpDbgWin = pDbgWindow;
}
pDbgWindow->InsertLine( m_sDebugMessage );
return 0L;
}
void DbgPrintWindow( const char* pLine )
{
static bool bIn = false;
// keine rekursiven Traces
if ( bIn )
return;
bIn = true;
SolarWindowPrinter aPrinter( OUString( pLine, strlen(pLine), RTL_TEXTENCODING_UTF8 ) );
TimeValue aTimeout; aTimeout.Seconds = 2; aTimeout.Nanosec = 0;
aPrinter.execute( aTimeout );
if ( aPrinter.didTimeout() )
DbgPrintShell( pLine );
bIn = false;
}
void DbgAbort( char const * i_message )
{
OUString const message( i_message, strlen( i_message ), osl_getThreadTextEncoding() );
Application::Abort( message );
}
void ImplDbgTestSolarMutex()
{
assert(ImplGetSVData()->mpDefInst->CheckYieldMutex());
}
void DbgGUIInit()
{
DbgSetPrintMsgBox( DbgPrintMsgBox );
DbgSetPrintWindow( DbgPrintWindow );
DbgSetTestSolarMutex( ImplDbgTestSolarMutex );
DbgSetAbort( DbgAbort );
}
void DbgGUIDeInit()
{
DbgSetPrintMsgBox( NULL );
DbgSetPrintWindow( NULL );
DbgSetAbort( NULL );
DbgWindow* pDbgWindow = ImplGetSVData()->maWinData.mpDbgWin;
delete pDbgWindow;
}
void DbgGUIDeInitSolarMutexCheck()
{
DbgSetTestSolarMutex( NULL );
}
void DbgGUIStart()
{
DbgData* pData = DbgGetData();
if ( pData )
{
boost::scoped_ptr<DbgDialog> pDialog(new DbgDialog);
// we switch off dialog tests for the debug dialog
sal_uLong nOldFlags = pData->nTestFlags;
pData->nTestFlags &= ~DBG_TEST_DIALOG;
if ( !pDialog->Execute() )
pData->nTestFlags |= (nOldFlags & DBG_TEST_DIALOG);
}
else
{
ErrorBox( 0, WB_OK, OUString("TOOLS Library has no Debug-Routines") ).Execute();
}
}
#endif // DBG_UTIL
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|