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
|
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: sta_list.cxx,v $
*
* $Revision: 1.28 $
*
* last change: $Author: kz $ $Date: 2008-03-05 17:17:59 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_automation.hxx"
#ifndef _TIME_HXX //autogen
#include <tools/time.hxx>
#endif
#ifndef _SV_SPLITWIN_HXX //autogen
#include <vcl/splitwin.hxx>
#endif
#ifndef _SV_WRKWIN_HXX //handmade
#include <vcl/wrkwin.hxx>
#endif
#ifndef _BASIC_TTRESHLP_HXX
#include <basic/ttstrhlp.hxx>
#endif
#ifndef _STATEMNT_HXX
#include "statemnt.hxx"
#endif
#ifndef _RETSRTM_HXX
#include "retstrm.hxx"
#endif
#ifndef _RCONTROL_HXX
#include "rcontrol.hxx"
#endif
#if OSL_DEBUG_LEVEL > 1
#ifndef _EDITWIN_HXX
#include "editwin.hxx"
#endif
#endif
#include "profiler.hxx"
#ifndef _SV_FLOATWIN_HXX //autogen
#include <vcl/floatwin.hxx>
#endif
#ifndef _SV_TOOLBOX_HXX //autogen
#include <vcl/toolbox.hxx>
#endif
// only needed for dynamic_cast in wintree
#ifndef _SVTOOLS_EDITBROWSEBOX_HXX_
#include <svtools/editbrowsebox.hxx>
#endif
#ifndef _VALUESET_HXX //autogen
#include <svtools/valueset.hxx>
#endif
#ifndef _SVTOOLS_ROADMAP_HXX
#include <svtools/roadmap.hxx>
#endif
#define WINDOW_ANYTYPE WINDOW_BASE
TTProfiler *StatementList::pProfiler = NULL;
StatementList *StatementList::pFirst = NULL;
BOOL StatementList::bReadingCommands = FALSE;
BOOL StatementList::bIsInReschedule = FALSE;
USHORT StatementList::nModalCount = 0;
Window *StatementList::pLastFocusWindow = NULL;
BOOL StatementList::bWasDragManager = FALSE;
BOOL StatementList::bWasPopupMenu = FALSE;
BOOL StatementList::bBasicWasRunning = FALSE;
RetStream *StatementList::pRet = NULL;
BOOL StatementList::IsError = FALSE;
BOOL StatementList::bDying = FALSE;
BOOL StatementList::bExecuting = FALSE;
StatementList *StatementList::pCurrentProfileStatement = NULL;
BOOL StatementList::bUsePostEvents = TRUE;
#if OSL_DEBUG_LEVEL > 1
EditWindow *StatementList::m_pDbgWin;
#endif
SmartId StatementList::aWindowWaitUId = SmartId();
Window *StatementList::pWindowWaitPointer = NULL;
SmartId StatementList::aWindowWaitOldHelpId = SmartId();
SmartId StatementList::aWindowWaitOldUniqueId = SmartId();
USHORT StatementList::nUseBindings = 0;
SmartId StatementList::aSubMenuId1 = SmartId(); // Untermenüs bei PopupMenus
SmartId StatementList::aSubMenuId2 = SmartId(); // erstmal 2-Stufig
SmartId StatementList::aSubMenuId3 = SmartId(); // and now even 3 levels #i31512#
SystemWindow *StatementList::pMenuWindow = NULL;
TTProperties *StatementList::pTTProperties = NULL;
USHORT StatementList::nMinTypeKeysDelay = 0; // Verzögerung der einzelnen Anschläge für TypeKeys
USHORT StatementList::nMaxTypeKeysDelay = 0;
BOOL StatementList::bDoTypeKeysDelay = FALSE;
Window* StatementList::pFirstDocFrame = NULL;
BOOL StatementList::bIsSlotInExecute = FALSE;
BOOL StatementList::bCatchGPF = TRUE;
IMPL_GEN_RES_STR;
static TTSettings* pTTSettings = NULL;
TTSettings* GetTTSettings()
{
if ( !pTTSettings )
{
pTTSettings = new TTSettings;
// DisplayHID
pTTSettings->pDisplayInstance = NULL;
pTTSettings->pDisplayHidWin = NULL;
pTTSettings->Old = NULL;
pTTSettings->Act = NULL;
pTTSettings->aOriginalCaption.Erase();
// Translate
pTTSettings->pTranslateWin = NULL;
pTTSettings->bToTop = TRUE;
}
return pTTSettings;
}
#define IS_WINP_CLOSING(pWin) (pWin->GetSmartHelpId().Matches( 4321 ) && pWin->GetSmartUniqueId().Matches( 1234 ))
/*
UniString GEN_RES_STR0( ULONG nResId ) { return ResString( nResId ); }
UniString GEN_RES_STR1( ULONG nResId, const UniString &Text1 ) { return GEN_RES_STR0( nResId ).Append( ArgString( 1, Text1 ) ); }
UniString GEN_RES_STR2( ULONG nResId, const UniString &Text1, const UniString &Text2 ) { return GEN_RES_STR1( nResId, Text1 ).Append( ArgString( 2, Text2 ) ); }
UniString GEN_RES_STR3( ULONG nResId, const UniString &Text1, const UniString &Text2, const UniString &Text3 ) { return GEN_RES_STR2( nResId, Text1, Text2 ).Append( ArgString( 3, Text3 ) );}
*/
StatementList::StatementList()
: nRetryCount(MAX_RETRIES)
, bStatementInQue(FALSE)
{
if (!pRet)
pRet = new RetStream; // so Spät wie möglich, aber dennoch Zentral und auf jeden Fall rechtzeitig, da pRet private ist.
}
void StatementList::InitProfile()
{
if ( pProfiler )
{
if ( pProfiler->IsProfilingPerCommand() || pProfiler->IsPartitioning() )
pProfiler->StartProfileInterval( pCurrentProfileStatement != this );
#if OSL_DEBUG_LEVEL > 1
if ( pCurrentProfileStatement != NULL && pCurrentProfileStatement != this )
pRet->GenReturn( RET_ProfileInfo, SmartId(), CUniString("InitProfile von anderem Statement gerufen ohne SendProfile\n") );
#endif
pCurrentProfileStatement = this;
}
}
void StatementList::SendProfile( String aText )
{
if ( pProfiler )
{
if ( pCurrentProfileStatement == this )
{
if ( pProfiler->IsProfilingPerCommand() || pProfiler->IsPartitioning() )
pProfiler->EndProfileInterval();
if ( pProfiler->IsProfilingPerCommand() )
pRet->GenReturn( RET_ProfileInfo, SmartId(), pProfiler->GetProfileLine( aText ) );
if ( pProfiler->IsPartitioning() )
pRet->GenReturn( RET_ProfileInfo, SmartId( S_ProfileTime ), static_cast<comm_ULONG>(pProfiler->GetPartitioningTime()) ); // GetPartitioningTime() ULONG != comm_ULONG on 64bit
}
if ( pProfiler->IsAutoProfiling() )
pRet->GenReturn( RET_ProfileInfo, SmartId(), pProfiler->GetAutoProfiling() );
#if OSL_DEBUG_LEVEL > 1
if ( pCurrentProfileStatement == NULL )
pRet->GenReturn( RET_ProfileInfo, SmartId(), CUniString("SendProfile ohne InitProfile\n") );
#endif
pCurrentProfileStatement = NULL;
}
}
void StatementList::QueStatement(StatementList *pAfterThis)
{
DBG_ASSERT(!bStatementInQue,"QueStatement für bereits eingetragenes Statement -> Abgebrochen")
if ( bStatementInQue )
return;
bStatementInQue = TRUE;
if ( pAfterThis )
{
if ( pAfterThis->bStatementInQue )
{
pNext = pAfterThis->pNext;
pAfterThis->pNext = this;
}
else
{ // pAfterThis not in que -> already dequed -> add to front of list
pNext = pFirst;
pFirst = this;
}
}
else // am Ende einfügen
{
pNext = NULL;
if( !pFirst )
pFirst = this;
else
{
StatementList *pList;
pList = pFirst;
while( pList->pNext )
pList = pList->pNext;
pList->pNext = this;
}
}
}
void StatementList::Advance()
{ // pFirst ist static!
pFirst = pNext;
bStatementInQue = FALSE;
pNext = NULL;
}
StatementList::~StatementList()
{
#if OSL_DEBUG_LEVEL > 1
m_pDbgWin->AddText( "Deleting \n" );
#endif
DBG_ASSERT(!bReadingCommands,"Deleting commands while reading them!");
}
Window* StatementList::GetDocWin( USHORT nNr )
{
Window* pBase = Application::GetFirstTopLevelWindow();
while ( pBase )
{
if ( IsDocWin( pBase ) )
{
if ( !nNr )
return pBase;
nNr--;
}
pBase = Application::GetNextTopLevelWindow( pBase );
}
return NULL;
}
USHORT StatementList::GetDocFrameCount()
{
Window* pBase = Application::GetFirstTopLevelWindow();
USHORT nCount = 0;
while ( pBase )
{
if ( IsDocFrame( pBase ) )
nCount++;
pBase = Application::GetNextTopLevelWindow( pBase );
}
return nCount;
}
USHORT StatementList::GetDocWinCount()
{
Window* pBase = Application::GetFirstTopLevelWindow();
USHORT nCount = 0;
while ( pBase )
{
if ( IsDocWin( pBase ) )
nCount++;
pBase = Application::GetNextTopLevelWindow( pBase );
}
return nCount;
}
Window* StatementList::SearchAllWin( Window *pBase, Search &aSearch, BOOL MaybeBase )
{
if ( !pBase && !aSearch.HasSearchFlag( SEARCH_NO_TOPLEVEL_WIN ) )
{
BOOL bSearchFocusFirst = aSearch.HasSearchFlag( SEARCH_FOCUS_FIRST );
Window *pControl = NULL;
if ( bSearchFocusFirst )
{
// first test Parent of Focus Window
pBase = Application::GetFocusWindow();
if ( pBase )
{
DBG_ASSERT( WinPtrValid( pBase ), "GetFocusWindow is no valid WindowPointer" )
Window *pPParent = pBase;
while ( pPParent->GET_REAL_PARENT() )
pPParent = pPParent->GET_REAL_PARENT();
// if ( !IsFirstDocFrame( pPParent ) )
// {
// get overlap window. Will be dialog else document itself
pBase = pBase->GetWindow( WINDOW_OVERLAP );
// set flag to find disabled elements.
// This is better than an enabled one on another Window
aSearch.AddSearchFlags( SEARCH_FIND_DISABLED );
// search on current Dialog first
pControl = SearchAllWin( pBase, aSearch );
// search on current Document
if ( !pControl && pBase != pPParent )
pControl = SearchAllWin( pPParent, aSearch );
aSearch.RemoveSearchFlags( SEARCH_FIND_DISABLED );
if ( pControl )
return pControl;
// }
}
}
pBase = Application::GetFirstTopLevelWindow();
// Skip FirstDocFrame
// if ( bSearchFocusFirst && IsFirstDocFrame( pBase ) )
// pBase = Application::GetNextTopLevelWindow( pBase );
while ( pBase )
{
pControl = SearchAllWin( pBase, aSearch );
if ( pControl )
return pControl;
pBase = Application::GetNextTopLevelWindow( pBase );
// Skip FirstDocFrame
// if ( bSearchFocusFirst && IsFirstDocFrame( pBase ) )
// pBase = Application::GetNextTopLevelWindow( pBase );
}
return NULL;
}
Window *pResult = NULL;
pResult = SearchClientWin( pBase, aSearch, MaybeBase );
if ( pResult )
return pResult;
// if ( pBase->GetType() != WINDOW_BORDERWINDOW )
// return NULL;
if ( !aSearch.HasSearchFlag( SEARCH_NOOVERLAP ) )
{
if ( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) )
pResult = SearchAllWin( pBase->GetWindow( WINDOW_FIRSTOVERLAP ), aSearch );
if ( !pResult && pBase->GetWindow( WINDOW_NEXT ) )
pResult = SearchAllWin( pBase->GetWindow( WINDOW_NEXT ), aSearch );
}
return pResult;
}
Window* StatementList::SearchClientWin( Window *pBase, Search &aSearch, BOOL MaybeBase )
{
if ( !pBase )
return NULL;
if ( MaybeBase && aSearch.IsWinOK( pBase ) )
return pBase;
Window *pResult = NULL;
USHORT i;
for( i = 0 ; i < pBase->GetChildCount() && !pResult; i++ )
pResult = SearchClientWin( pBase->GetChild(i), aSearch );
return pResult;
}
BOOL SearchUID::IsWinOK( Window *pWin )
{
if ( aUId.Matches( pWin->GetSmartUniqueOrHelpId() ) )
{
if ( ( pWin->IsEnabled() || HasSearchFlag( SEARCH_FIND_DISABLED ) ) && pWin->IsVisible() )
return TRUE;
else
{
if ( !pMaybeResult )
pMaybeResult = pWin;
return FALSE;
}
}
else if ( pWin->GetType() == WINDOW_TOOLBOX ) // Buttons and Controls on ToolBox.
{
ToolBox *pTB = ((ToolBox*)pWin);
USHORT i;
for ( i = 0; i < pTB->GetItemCount() ; i++ )
{
if ( aUId.Matches( pTB->GetItemCommand(pTB->GetItemId( i )) ) || aUId.Matches( pTB->GetHelpId(pTB->GetItemId( i )) ) )
{ // ID matches.
Window *pItemWin;
pItemWin = pTB->GetItemWindow( pTB->GetItemId( i ) );
if ( bSearchButtonOnToolbox && pTB->GetItemType( i ) == TOOLBOXITEM_BUTTON && !pItemWin )
{ // We got a Control, see if its valid also.
// Same as above.
if ( ( pTB->IsEnabled() || HasSearchFlag( SEARCH_FIND_DISABLED ) ) && pTB->IsVisible() )
{ // We got a Button, see if its valid also.
if ( ( pTB->IsItemEnabled(pTB->GetItemId(i)) || HasSearchFlag( SEARCH_FIND_DISABLED ) )
&& pTB->IsItemVisible(pTB->GetItemId(i)) )
return TRUE; // We got a Button.
else
{ // better a disabled Button on a valid ToolBox than an invalid ToolBox as below
pMaybeResult = pTB;
return FALSE;
}
}
else if ( !pMaybeResult )
{ // invalid ToolBox
pMaybeResult = pTB;
return FALSE;
}
}
if ( pItemWin )
{ // We got a Control, see if its valid also.
// Same as above.
if ( ( pItemWin->IsEnabled() || HasSearchFlag( SEARCH_FIND_DISABLED ) ) && pItemWin->IsVisible() )
{
if ( !pAlternateResult ) // only take the first found ItemWindow #i35365
pAlternateResult = pItemWin; // since we cannot return a Window here
return FALSE; // continue searching to prefer a window with the right ID #i32292
}
else if ( !pMaybeResult )
{
pMaybeResult = pItemWin;
return FALSE;
}
}
}
}
return FALSE;
}
else
return FALSE;
}
Window* StatementList::SearchTree( SmartId aUId ,BOOL bSearchButtonOnToolbox )
{
SearchUID aSearch(aUId,bSearchButtonOnToolbox);
Window *pResult = SearchAllWin( NULL, aSearch );
if ( pResult )
return pResult;
else if ( aSearch.GetAlternateResultWin() )
return aSearch.GetAlternateResultWin();
else
return aSearch.GetMaybeWin();
}
BOOL SearchWinPtr::IsWinOK( Window *pWin )
{
return pWin == pTest;
}
BOOL StatementList::WinPtrValid(Window *pTest)
{
SearchWinPtr aSearch( pTest );
return SearchAllWin( NULL, aSearch ) != NULL;
}
BOOL SearchRT::IsWinOK( Window *pWin )
{
if ( pWin->IsVisible() && pWin->GetType() == mnRT )
{
mnCount++;
if ( mnSkip )
{
mnSkip--;
return FALSE;
}
else
return TRUE;
}
return FALSE;
}
Window* StatementList::GetWinByRT( Window *pBase, WindowType nRT, BOOL MaybeBase, USHORT nSkip, BOOL bSearchAll )
{
SearchRT aSearch( nRT, 0, nSkip );
if ( bSearchAll )
aSearch.AddSearchFlags( SEARCH_FOCUS_FIRST | SEARCH_FIND_DISABLED );
else
aSearch.AddSearchFlags( SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN );
return SearchAllWin( pBase, aSearch, MaybeBase );
}
USHORT StatementList::CountWinByRT( Window *pBase, WindowType nRT, BOOL MaybeBase )
{
SearchRT aSearch( nRT, SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN, 0xFFFF );
SearchAllWin( pBase, aSearch, MaybeBase );
return aSearch.GetCount();
}
BOOL SearchScroll::IsWinOK( Window *pWin )
{
if ( SearchRT::IsWinOK( pWin ) )
{
DBG_ASSERT( pWin->GetStyle() & ( WB_HORZ | WB_VERT ), "Nither WB_HORZ nor WB_VERT set on ScrollBar");
return (( pWin->GetStyle() & WB_HORZ ) && ( nDirection == CONST_ALIGN_BOTTOM ))
|| (( pWin->GetStyle() & WB_VERT ) && ( nDirection == CONST_ALIGN_RIGHT ));
}
return FALSE;
}
ScrollBar* StatementList::GetScrollBar( Window *pBase, USHORT nDirection, BOOL MaybeBase )
{
SearchScroll aSearch( nDirection, SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN );
return (ScrollBar*)SearchAllWin( pBase, aSearch, MaybeBase );
}
BOOL SearchPopupFloatingWin::IsWinOK( Window *pWin )
{
return pWin->IsVisible() && pWin->GetType() == WINDOW_FLOATINGWINDOW && ((FloatingWindow*)pWin)->IsInPopupMode();
}
Window* StatementList::GetPopupFloatingWin( BOOL MaybeBase )
{
SearchPopupFloatingWin aSearch;
return SearchAllWin( NULL, aSearch, MaybeBase );
}
Menu* StatementList::GetMatchingMenu( Window* pWin, Menu* pBaseMenu )
{
if ( pBaseMenu )
{
if ( pBaseMenu->GetWindow() == pWin )
return pBaseMenu;
USHORT i;
// while ( pBaseMenu )
// {
i = 0;
while ( i < pBaseMenu->GetItemCount() )
{
PopupMenu* pPopup = pBaseMenu->GetPopupMenu( pBaseMenu->GetItemId( i ) );
if ( pPopup && pPopup->GetWindow() )
{
if ( pPopup->GetWindow() == pWin )
return pPopup;
else
{
pBaseMenu = pPopup;
i = 0;
}
}
else
i++;
}
// }
}
else
{
if ( PopupMenu::GetActivePopupMenu() )
{
Menu* pMenu = GetMatchingMenu( pWin, PopupMenu::GetActivePopupMenu() );
if ( pMenu )
return pMenu;
}
USHORT nSkip = 0;
Window* pMenuBarWin = NULL;
while ( (pMenuBarWin = GetWinByRT( NULL, WINDOW_MENUBARWINDOW, TRUE, nSkip++, TRUE )) != NULL )
{
Window* pParent = pMenuBarWin->GET_REAL_PARENT();
if ( pParent && pParent->GetType() == WINDOW_BORDERWINDOW && pParent->IsVisible() )
{
Menu* pMenu = NULL;
// find Menu of MenuBarWindow
USHORT nCount;
for ( nCount = 0 ; nCount < pParent->GetChildCount() ; nCount++ )
{
if ( pParent->GetChild( nCount )->GetType() == WINDOW_WORKWINDOW )
pMenu = ((WorkWindow*)(pParent->GetChild( nCount )))->GetMenuBar();
}
if ( pMenu )
{
// check for menu bar in Task Window
if ( pMenuBarWin == pWin )
return pMenu;
// search submenues
pMenu = GetMatchingMenu( pWin, pMenu );
if ( pMenu )
return pMenu;
}
}
}
}
return NULL;
}
BOOL SearchActive::IsWinOK( Window *pWin )
{
// return pWin->IsVisible() && ( (nRT == WINDOW_ANYTYPE && IsDialog(pWin) ) || pWin->GetType() == nRT ) && (nRT == WINDOW_FILEDIALOG || nRT == WINDOW_PATHDIALOG || nRT == WINDOW_PRINTDIALOG || nRT == WINDOW_PRINTERSETUPDIALOG || nRT == WINDOW_COLORDIALOG || ((SystemWindow*)pWin)->IsActive());
// only matches ResID due to problems with UNIX Window Managers
return pWin->IsVisible() && ( (nRT == WINDOW_ANYTYPE && IsDialog(pWin) ) || pWin->GetType() == nRT );
}
Window* StatementList::GetActive( WindowType nRT, BOOL MaybeBase )
{
SearchActive aSearch( nRT );
return SearchAllWin( NULL, aSearch, MaybeBase );
}
BOOL SearchFadeSplitWin::IsWinOK( Window *pWin )
{
#if OSL_DEBUG_LEVEL > 1
if ( pWin->GetType() == WINDOW_SPLITWINDOW )
{
BOOL bResult;
WindowAlign aAlign;
bResult = pWin->IsVisible();
bResult = ((SplitWindow*)pWin)->IsFadeInButtonVisible();
bResult = ((SplitWindow*)pWin)->IsFadeOutButtonVisible();
bResult = ((SplitWindow*)pWin)->IsAutoHideButtonVisible();
aAlign = ((SplitWindow*)pWin)->GetAlign();
}
#endif
return pWin->IsVisible() && ( pWin->GetType() == WINDOW_SPLITWINDOW )
&& (((SplitWindow*)pWin)->IsFadeInButtonVisible() || ((SplitWindow*)pWin)->IsFadeOutButtonVisible() )
/*&& ((SplitWindow*)pWin)->IsAutoHideButtonVisible()*/ && ((SplitWindow*)pWin)->GetAlign() == nAlign;
}
Window* StatementList::GetFadeSplitWin( Window *pBase, WindowAlign nAlign, BOOL MaybeBase )
{
SearchFadeSplitWin aSearch( nAlign );
if ( GetpApp()->GetAppWindow() == pBase && pBase->GetType() != WINDOW_BORDERWINDOW )
pBase = pBase->GetWindow( WINDOW_OVERLAP );
return SearchAllWin( pBase, aSearch, MaybeBase );
}
Window* StatementList::GetMouseWin()
{
Window *pBase = Application::GetFirstTopLevelWindow();
Window *pControl = NULL;
while ( pBase )
{
Window *pBaseFrame = pBase->GetWindow( WINDOW_OVERLAP );
Point aP = pBaseFrame->GetPointerPosPixel();
pControl = pBaseFrame->FindWindow( aP );
if ( pControl )
return pControl;
pBase = Application::GetNextTopLevelWindow( pBase );
}
return NULL;
}
Window* StatementList::GetFocus( WindowType nRT, BOOL MaybeBase )
{
if ( nRT == WINDOW_TABCONTROL )
{
Window *pResult = GetActive( WINDOW_TABDIALOG, MaybeBase);
for( USHORT i = 0 ; pResult && i < pResult->GetChildCount(); i++ )
if ( pResult->GetChild(i)->GetType() == nRT )
return pResult->GetChild(i);
}
return NULL;
}
Window* StatementList::GetAnyActive( BOOL MaybeBase )
{
Window *pControl;
pControl = GetActive( WINDOW_MESSBOX, MaybeBase);
if ( !pControl )
{
pControl = GetActive( WINDOW_INFOBOX, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_WARNINGBOX, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_ERRORBOX, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_QUERYBOX, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_BUTTONDIALOG, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_FILEDIALOG, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_PATHDIALOG, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_PRINTDIALOG, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_PRINTERSETUPDIALOG, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_COLORDIALOG, MaybeBase);
}
if ( !pControl )
{
pControl = GetFocus( WINDOW_TABCONTROL, MaybeBase);
}
return pControl;
}
void StatementList::SetFirstDocFrame( Window* pWin )
{
DBG_ASSERT( IsDocFrame( pWin ), "Non Document Frame set as first Document Frame" )
pFirstDocFrame = pWin;
}
Window* StatementList::GetFirstDocFrame()
{
if ( pFirstDocFrame && !WinPtrValid( pFirstDocFrame ) )
pFirstDocFrame = NULL;
if ( pFirstDocFrame && !pFirstDocFrame->IsVisible() )
pFirstDocFrame = NULL;
if ( pFirstDocFrame && !IsDocFrame( pFirstDocFrame ) )
pFirstDocFrame = NULL;
if ( !pFirstDocFrame )
{
Window* pBase = Application::GetFirstTopLevelWindow();
while ( pBase && !IsDocFrame( pBase ) )
pBase = Application::GetNextTopLevelWindow( pBase );
if ( pBase )
SetFirstDocFrame( pBase );
if ( !pBase ) // find just something
{
pBase = Application::GetFirstTopLevelWindow();
while ( pBase && !pBase->IsVisible() )
pBase = Application::GetNextTopLevelWindow( pBase );
return pBase; // just for now, later we will hopefully have a Window
}
}
return pFirstDocFrame;
}
BOOL StatementList::IsFirstDocFrame( Window* pWin )
{
return pWin && ( pWin == GetFirstDocFrame() || ( GetFirstDocFrame() && pWin == GetFirstDocFrame()->GetWindow( WINDOW_CLIENT ) ) ) && ( GetFirstDocFrame() && IsDocFrame( GetFirstDocFrame() ) );
}
MenuBar* StatementList::GetDocFrameMenuBar( Window* pWin )
{
if ( pWin && pWin->IsVisible() && pWin->GetType() == WINDOW_BORDERWINDOW )
{
USHORT nCount;
for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ )
{
if ( pWin->GetChild( nCount )->GetType() == WINDOW_WORKWINDOW )
return ((WorkWindow*)(pWin->GetChild( nCount )))->GetMenuBar();
}
}
return NULL;
}
// a Doc Frame is a Document or the Backing Window
BOOL StatementList::IsDocFrame( Window* pWin )
{
if ( pWin && pWin->IsVisible() && pWin->GetType() == WINDOW_BORDERWINDOW )
{
USHORT nCount;
BOOL bHasWorkWindow = FALSE;
BOOL bHasMenuBar = FALSE;
// #91724# it is now necessary to sort out the IME WIndow in Solaris as well.
// so now we check for existence of WINDOW_WORKWINDOW and newly for
// WINDOW_MENUBARWINDOW which contains the Menu and the close/min/max buttons
for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ )
{
if ( pWin->GetChild( nCount )->GetType() == WINDOW_WORKWINDOW )
bHasWorkWindow = TRUE;
if ( pWin->GetChild( nCount )->GetType() == WINDOW_MENUBARWINDOW )
bHasMenuBar = TRUE;
}
return bHasWorkWindow && bHasMenuBar;
}
return FALSE;
}
// a Doc Win is a real document (not the Backing Window)
BOOL StatementList::IsDocWin( Window* pWin )
{
if ( pWin && IsDocFrame( pWin ) )
{
if ( GetDocFrameCount() != 1 )
return TRUE;
else
{
// check for the close button to see if we are the last one or only the backing Window
if ( GetDocFrameMenuBar( pWin ) )
return GetDocFrameMenuBar( pWin )->HasCloser();
}
}
return FALSE;
}
BOOL StatementList::IsIMEWin( Window* pWin ) // Input Window for CJK under Solaris
{
if ( pWin && pWin->IsVisible() && pWin->GetType() == WINDOW_BORDERWINDOW )
{
USHORT nCount;
BOOL bHasWorkWindow = FALSE;
BOOL bHasWindow = FALSE;
// #91724# it is now necessary to sort out the IME WIndow in Solaris as well.
// so now we check for existence of WINDOW_WORKWINDOW and newly for
// WINDOW_WINDOW which contains the Menu and the close/min/max buttons
for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ )
if ( pWin->GetChild( nCount )->GetType() == WINDOW_WORKWINDOW )
bHasWorkWindow = TRUE;
for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ )
if ( pWin->GetChild( nCount )->GetType() == WINDOW_WINDOW )
bHasWindow = TRUE;
return bHasWorkWindow && !bHasWindow;
}
return FALSE;
}
UniString StatementList::Tree(Window *pBase, int Indent)
{
String aReturn, aSep;
if ( !pBase )
{
aSep.AssignAscii("============================\n");
aSep.ConvertLineEnd();
pBase = Application::GetFirstTopLevelWindow();
while ( pBase )
{
Window *pBaseFrame = pBase->GetWindow( WINDOW_OVERLAP );
aReturn += aSep;
aReturn += Tree( pBaseFrame, Indent+1 );
pBase = Application::GetNextTopLevelWindow( pBase );
}
return aReturn;
}
aSep.AssignAscii("----------------------------\n");
aSep.ConvertLineEnd();
aReturn += ClientTree( pBase, Indent );
if ( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) )
{
aReturn += aSep;
aReturn += Tree( pBase->GetWindow( WINDOW_FIRSTOVERLAP ), Indent+1 );
}
if ( pBase->GetWindow( WINDOW_NEXT ) )
{
aReturn += aSep;
aReturn += Tree( pBase->GetWindow( WINDOW_NEXT ), Indent );
}
return aReturn;
}
String StatementList::ClientTree(Window *pBase, int Indent)
{
#if OSL_DEBUG_LEVEL > 1
#define WRITE(Text) { m_pDbgWin->AddText(Text); aReturn += Text; }
#define WRITEc(Text) { m_pDbgWin->AddText(Text); aReturn.AppendAscii(Text); }
#else
#define WRITE(Text) { aReturn += Text; }
#define WRITEc(Text) { aReturn.AppendAscii(Text); }
#endif
String sIndent,aText,aReturn;
sIndent.Expand(sal::static_int_cast< xub_StrLen >(2*Indent));
aText = pBase->GetText();
UniString t1,t2;t1 = CUniString("\n"); t2 = CUniString("\\n");
aText.SearchAndReplaceAll(t1,t2 );
WRITE(sIndent);
if (pBase->IsDialog())
{
WRITEc("*(Dialog(TH))");
}
if (IsDialog( pBase ))
{
WRITEc("*(Dialog(GH))");
}
if (pBase->HasFocus())
{
WRITEc("*(Focus)");
}
if (!pBase->IsEnabled())
{
WRITEc("*(Disab)");
}
if (pBase->IsVisible())
{
WRITEc("*(Visible)");
}
if ( IsDialog(pBase) && ((SystemWindow*)pBase)->IsActive() )
{
WRITEc("*(Active)");
}
if ( pBase->GetStyle() & WB_CLOSEABLE )
{
WRITEc("*(Closable)");
}
if ( pBase->GetType() == WINDOW_DOCKINGWINDOW &&
((((DockingWindow*)pBase)->GetFloatStyle()) & WB_CLOSEABLE) )
{
WRITEc("*(Closable Docking in Floatingstyle)");
}
if ( pBase->GetStyle() & WB_DOCKABLE )
{
WRITEc("*(Dockable)");
}
if ( pBase->GetType() == WINDOW_SPLITWINDOW &&
(((SplitWindow*)pBase)->IsFadeInButtonVisible() || ((SplitWindow*)pBase)->IsFadeOutButtonVisible()) )
{
WRITEc("*(FadeIn/Out)");
}
WRITEc("Text: ");
WRITE(aText);
WRITEc("\n");
WRITE(sIndent);
WRITEc("UId : ");
WRITE(UIdString(pBase->GetSmartUniqueOrHelpId()));
WRITEc(":0x");
WRITE(
String::CreateFromInt64(
sal::static_int_cast< sal_Int64 >(
reinterpret_cast< sal_IntPtr >(pBase)),
16 ));
WRITEc(":");
WRITE(pBase->GetQuickHelpText());
WRITEc(":");
WRITE(pBase->GetHelpText());
WRITEc("\n");
WRITE(sIndent);
WRITEc("RTyp: ");
WRITE(MakeStringNumber(TypeKenn,pBase->GetType()));
if ( pBase->GetType() == WINDOW_CONTROL )
{
if ( dynamic_cast< svt::EditBrowseBox* >(pBase) )
WRITEc("/BrowseBox")
else if ( dynamic_cast< ValueSet* >(pBase) )
WRITEc("/ValueSet")
else if ( dynamic_cast< svt::ORoadmap* >(pBase) )
WRITEc("/RoadMap")
else
WRITEc("/Unknown")
}
WRITEc("\n");
aReturn.ConvertLineEnd();
USHORT i;
for (i = 0 ; i < pBase->GetChildCount() ; i++)
{
aReturn += ClientTree(pBase->GetChild(i),Indent+1);
}
return aReturn;
}
BOOL StatementList::CheckWindowWait()
{
static Time StartTime = Time(0L); // Abbruch wenn Fenster absolut nicht schliesst.
if ( StartTime == Time(0L) )
StartTime = Time();
if ( pWindowWaitPointer )
{
#if OSL_DEBUG_LEVEL > 1
m_pDbgWin->AddText( "Waiting for Window to close ... " );
#endif
if ( WinPtrValid(pWindowWaitPointer) && IS_WINP_CLOSING(pWindowWaitPointer) )
{
#if OSL_DEBUG_LEVEL > 1
m_pDbgWin->AddText( aWindowWaitUId.GetText().AppendAscii(" Still Open. RType=") );
m_pDbgWin->AddText( String::CreateFromInt32( pWindowWaitPointer->GetType() ).AppendAscii("\n") );
#endif
// Ist die Zeit schonn abgelaufen?
if ( StartTime + Time(0,0,10) < Time() ) // 10 Sekunden reichen wohl
{
#if OSL_DEBUG_LEVEL > 1
m_pDbgWin->AddText( "Close timed out. Going on!! " );
#endif
pWindowWaitPointer->SetSmartHelpId(aWindowWaitOldHelpId, SMART_SET_ALL);
pWindowWaitPointer->SetSmartUniqueId(aWindowWaitOldUniqueId, SMART_SET_ALL);
aWindowWaitUId = SmartId();
pWindowWaitPointer = NULL;
StartTime = Time(0L);
return TRUE;
}
return FALSE;
}
pWindowWaitPointer = NULL;
aWindowWaitUId = SmartId();
#if OSL_DEBUG_LEVEL > 1
m_pDbgWin->AddText( "Closed, Going on.\n" );
#endif
}
StartTime = Time(0L);
return TRUE;
}
void StatementList::ReportError(String aMessage)
{
ReportError ( SmartId(), aMessage );
}
void StatementList::ReportError(SmartId aUId, String aMessage)
{
pRet->GenError ( aUId, aMessage );
IsError = TRUE;
}
void StatementList::ReportError(String aMessage, ULONG nWhatever)
{
ReportError ( aMessage.AppendAscii(" ").Append(UniString::CreateFromInt32(nWhatever)));
}
void StatementList::DirectLog( ULONG nType, String aMessage )
{
if ( pRet )
pRet->GenReturn( RET_DirectLoging, SmartId(nType), aMessage );
}
#define CALL_EVENT_WITH_NOTIFY( EventType, Event, WinP, Method ) \
{ \
if ( StatementList::WinPtrValid( WinP ) ) \
{ \
NotifyEvent aNEvt( EventType, WinP, &Event ); \
if ( !WinP->PreNotify( aNEvt ) ) \
WinP->Method( Event ); \
} \
}
void ImplKeyInput( Window* pWin, KeyEvent &aKEvnt, BOOL bForceDirect )
{
if ( StatementList::bUsePostEvents && !bForceDirect )
{
if ( StatementList::WinPtrValid( pWin ) )
{
ULONG nID1;
ULONG nID2;
nID1 = Application::PostKeyEvent( VCLEVENT_WINDOW_KEYINPUT, pWin, &aKEvnt );
nID2 = Application::PostKeyEvent( VCLEVENT_WINDOW_KEYUP, pWin, &aKEvnt );
// wait after posting both events so deleting pWin will remove the second event also
ImplEventWait( nID1 );
ImplEventWait( nID2 );
}
}
else
{
if ( !Application::CallAccel( aKEvnt.GetKeyCode() ) )
{
CALL_EVENT_WITH_NOTIFY( EVENT_KEYINPUT, aKEvnt, pWin, KeyInput )
KeyCode aCode = aKEvnt.GetKeyCode();
if ( (aCode.GetCode() == KEY_CONTEXTMENU) || ((aCode.GetCode() == KEY_F10) && aCode.IsShift()) )
{
if ( StatementList::WinPtrValid( pWin ) )
{
Point aPos;
// simulate mouseposition at center of window
Size aSize = pWin->GetOutputSize();
aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 );
CommandEvent aEvent( aPos, COMMAND_CONTEXTMENU, FALSE );
ImplCommand( pWin, aEvent );
}
}
}
CALL_EVENT_WITH_NOTIFY( EVENT_KEYUP, aKEvnt, pWin, KeyUp )
}
};
void ImplMouseMove( Window* pWin, MouseEvent &aMEvnt, BOOL bForceDirect )
{
if ( StatementList::bUsePostEvents && !bForceDirect )
{
if ( StatementList::WinPtrValid( pWin ) )
{
ULONG nID;
nID = Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, pWin, &aMEvnt );
ImplEventWait( nID );
}
}
else
{
// DragManager* pDragManager = DragManager::GetDragManager();
// if ( pDragManager )
// pDragManager->MouseMove( aMEvnt, pWin );
// else
if ( pWin->IsTracking() )
{
TrackingEvent aTEvt( aMEvnt );
pWin->Tracking( aTEvt );
}
else
CALL_EVENT_WITH_NOTIFY( EVENT_MOUSEMOVE, aMEvnt, pWin, MouseMove )
}
};
void ImplMouseButtonDown( Window* pWin, MouseEvent &aMEvnt, BOOL bForceDirect )
{
if ( StatementList::bUsePostEvents && !bForceDirect )
{
if ( StatementList::WinPtrValid( pWin ) )
{
ULONG nID;
nID = Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pWin, &aMEvnt );
ImplEventWait( nID );
}
}
else
{
CALL_EVENT_WITH_NOTIFY( EVENT_MOUSEBUTTONDOWN, aMEvnt, pWin, MouseButtonDown )
}
};
void ImplMouseButtonUp( Window* pWin, MouseEvent &aMEvnt, BOOL bForceDirect )
{
if ( StatementList::bUsePostEvents && !bForceDirect )
{
if ( StatementList::WinPtrValid( pWin ) )
{
ULONG nID;
nID = Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONUP, pWin, &aMEvnt );
ImplEventWait( nID );
}
}
else
{
// DragManager* pDragManager = DragManager::GetDragManager();
// if ( pDragManager )
// pDragManager->ButtonUp( aMEvnt, pWin );
// else
if ( pWin->IsTracking() )
{
// siehe #64693 die Position ist für Toolboxen relevant
// #60020 Jetzt hoffentlich kein GPF mehr
// Zuerst Tracking beenden ohne Event
pWin->EndTracking( ENDTRACK_DONTCALLHDL );
// dann eigenen Event mit richtigem Maus-Event senden
TrackingEvent aTEvt( aMEvnt, ENDTRACK_END );
pWin->Tracking( aTEvt );
}
else
CALL_EVENT_WITH_NOTIFY( EVENT_MOUSEBUTTONUP, aMEvnt, pWin, MouseButtonUp )
}
};
void ImplEventWait( ULONG nID )
{
while ( !Application::IsProcessedMouseOrKeyEvent( nID ) )
Application::Yield();
}
void ImplCommand( Window* pWin, CommandEvent &aCmdEvnt )
{
CALL_EVENT_WITH_NOTIFY( EVENT_COMMAND, aCmdEvnt, pWin, Command )
};
|