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
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
|
Attribute VB_Name = "AnalysisDriver"
'/*************************************************************************
' *
' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
'
' Copyright 2000, 2010 Oracle and/or its affiliates.
'
' OpenOffice.org - a multi-platform office productivity suite
'
' This file is part of OpenOffice.org.
'
' OpenOffice.org is free software: you can redistribute it and/or modify
' it under the terms of the GNU Lesser General Public License version 3
' only, as published by the Free Software Foundation.
'
' OpenOffice.org 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 version 3 for more details
' (a copy is included in the LICENSE file that accompanied this code).
'
' You should have received a copy of the GNU Lesser General Public License
' version 3 along with OpenOffice.org. If not, see
' <http://www.openoffice.org/license.html>
' for a copy of the LGPLv3 License.
'
' ************************************************************************/
Option Explicit
' Declare Public variables.
Public Type ShortItemId
cb As Long
abID As Byte
End Type
Public Type ITEMIDLIST
mkid As ShortItemId
End Type
Public Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As Long) As Long
Private Declare Function GetTickCount Lib "kernel32" () As Long
'This function saves the passed value to the file,
'under the section and key names specified.
'If the ini file, lpFileName, does not exist, it is created.
'If the section, lpSectionName, does not exist, it is created.
'If the key name, lpKeyName, does not exist, it is created.
'If the key name exists, it's value, lpString, is replaced.
Private Declare Function WritePrivateProfileString Lib "kernel32" _
Alias "WritePrivateProfileStringA" _
(ByVal lpSectionName As String, _
ByVal lpKeyName As Any, _
ByVal lpString As Any, _
ByVal lpFileName As String) As Long
Private Declare Function GetPrivateProfileString Lib "kernel32" _
Alias "GetPrivateProfileStringA" _
(ByVal lpSectionName As String, _
ByVal lpKeyName As Any, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Long, _
ByVal lpFileName As String) As Long
Private Declare Function UrlEscape Lib "shlwapi" _
Alias "UrlEscapeA" _
(ByVal pszURL As String, _
ByVal pszEscaped As String, _
pcchEscaped As Long, _
ByVal dwFlags As Long) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32.dll" _
(ByVal pidl As Long, ByVal pszPath As String) As Long
Public Declare Function SHGetSpecialFolderLocation Lib _
"shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder _
As Long, pidl As ITEMIDLIST) As Long
Public Const LOCALE_ILANGUAGE As Long = &H1 'language id
Public Const LOCALE_SLANGUAGE As Long = &H2 'localized name of lang
Public Const LOCALE_SENGLANGUAGE As Long = &H1001 'English name of lang
Public Const LOCALE_SABBREVLANGNAME As Long = &H3 'abbreviated lang name
Public Const LOCALE_SNATIVELANGNAME As Long = &H4 'native name of lang
Public Const LOCALE_ICOUNTRY As Long = &H5 'country code
Public Const LOCALE_SCOUNTRY As Long = &H6 'localized name of country
Public Const LOCALE_SENGCOUNTRY As Long = &H1002 'English name of country
Public Const LOCALE_SABBREVCTRYNAME As Long = &H7 'abbreviated country name
Public Const LOCALE_SNATIVECTRYNAME As Long = &H8 'native name of country
Public Const LOCALE_SINTLSYMBOL As Long = &H15 'intl monetary symbol
Public Const LOCALE_IDEFAULTLANGUAGE As Long = &H9 'def language id
Public Const LOCALE_IDEFAULTCOUNTRY As Long = &HA 'def country code
Public Const LOCALE_IDEFAULTCODEPAGE As Long = &HB 'def oem code page
Public Const LOCALE_IDEFAULTANSICODEPAGE As Long = &H1004 'def ansi code page
Public Const LOCALE_IDEFAULTMACCODEPAGE As Long = &H1011 'def mac code page
Public Const LOCALE_IMEASURE As Long = &HD '0 = metric, 1 = US
Public Const LOCALE_SSHORTDATE As Long = &H1F 'short date format string
'#if(WINVER >= &H0400)
Public Const LOCALE_SISO639LANGNAME As Long = &H59 'ISO abbreviated language name
Public Const LOCALE_SISO3166CTRYNAME As Long = &H5A 'ISO abbreviated country name
'#endif /* WINVER >= as long = &H0400 */
'#if(WINVER >= &H0500)
Public Const LOCALE_SNATIVECURRNAME As Long = &H1008 'native name of currency
Public Const LOCALE_IDEFAULTEBCDICCODEPAGE As Long = &H1012 'default ebcdic code page
Public Const LOCALE_SSORTNAME As Long = &H1013 'sort name
'#endif /* WINVER >= &H0500 */
Public Declare Function GetSystemDefaultLangID Lib "kernel32" () As Long
Public Declare Function GetUserDefaultLangID Lib "kernel32" () As Long
Public Declare Function GetLocaleInfo Lib "kernel32" _
Alias "GetLocaleInfoA" _
(ByVal Locale As Long, _
ByVal LCType As Long, _
ByVal lpLCData As String, _
ByVal cchData As Long) As Long
Public Const CWIZARD = "analysis"
Const CROWOFFSET = 2
Const CDOCPROP_PAW_ROWOFFSET = 3
Private mDocPropRowOffset As Long
Const CNUMBERDOC_ALL = "All"
Const CTOTAL_DOCS_ANALYZED = "TotalDocsAnalysed"
Const CNUMDAYS_IN_MONTH = 30
Const CMAX_LIMIT = 10000
Const CISSUE_DETDOCNAME = 1
Const CISSUE_DETDOCAPPLICATION = CISSUE_DETDOCNAME + 1
Const CISSUE_DETTYPE = CISSUE_DETDOCAPPLICATION + 1
Const CISSUE_DETSUBTYPE = CISSUE_DETTYPE + 1
Const CISSUE_DETLOCATION = CISSUE_DETSUBTYPE + 1
Const CISSUE_DETSUBLOCATION = CISSUE_DETLOCATION + 1
Const CISSUE_DETLINE = CISSUE_DETSUBLOCATION + 1
Const CISSUE_DETCOLUMN = CISSUE_DETLINE + 1
Const CISSUE_DETATTRIBUTES = CISSUE_DETCOLUMN + 1
Const CISSUE_DETNAMEANDPATH = CISSUE_DETATTRIBUTES + 1
Const CREF_DETDOCNAME = 1
Const CREF_DETDOCAPPLICATION = CREF_DETDOCNAME + 1
Const CREF_DETREFERENCE = CREF_DETDOCAPPLICATION + 1
Const CREF_DETDESCRIPTION = CREF_DETREFERENCE + 1
Const CREF_DETLOCATION = CREF_DETDESCRIPTION + 1
Const CREF_DETATTRIBUTES = CREF_DETLOCATION + 1
Const CREF_DETNAMEANDPATH = CREF_DETATTRIBUTES + 1
Const CINPUT_DIR = "indir"
Const COUTPUT_DIR = "outdir"
Const CRESULTS_FILE = "resultsfile"
Const CLOG_FILE = "logfile"
Const CRESULTS_TEMPLATE = "resultstemplate"
Const CRESULTS_EXIST = "resultsexist"
Const COVERWRITE_FILE = "overwritefile"
Const CNEW_RESULTS_FILE = "newresultsfile"
Const CINCLUDE_SUBDIRS = "includesubdirs"
Const CDEBUG_LEVEL = "debuglevel"
Const COUTPUT_TYPE = "outputtype"
Const COUTPUT_TYPE_XLS = "xls"
Const COUTPUT_TYPE_XML = "xml"
Const COUTPUT_TYPE_BOTH = "both"
Const COVERVIEW_TITLE_LABEL = "OV_Document_Analysis_Overview_lbl"
Const CDEFAULT_PASSWORD = "defaultpassword"
Const CVERSION = "version"
Const CTITLE = "title"
Const CDOPREPARE = "prepare"
Const CISSUES_LIMIT = "issuesmonthlimit"
Const CSINGLE_FILE = "singlefile"
Const CFILE_LIST = "filelist"
Const CSTAT_FILE = "statfilename"
Const C_ABORT_ANALYSIS = "abortanalysis"
Const C_DOCS_LESS_3_MONTH = "DocumentsYoungerThan3Month"
Const C_DOCS_LESS_6_MONTH = "DocumentsYoungerThan6Month"
Const C_DOCS_LESS_12_MONTH = "DocumentsYoungerThan12Month"
Const C_DOCS_MORE_12_MONTH = "DocumentsOlderThan12Month"
Private Const C_ANALYSIS As String = "Analysis"
Private Const C_LAST_CHECKPOINT As String = "LastCheckpoint"
Private Const C_NEXT_FILE As String = "NextFile"
Private Const C_MAX_CHECK_INI As String = "FilesBeforeSave"
Private Const C_MAX_WAIT_BEFORE_WRITE_INI As String = "SecondsBeforeSave"
Private Const C_MAX_RANGE_PROCESS_TIME_INI As String = "ExcelMaxRangeProcessTime"
Private Const C_ERROR_HANDLING_DOC As String = "_ERROR_HANDLING_DOC_"
Private Const C_MAX_CHECK As Long = 100
Private Const C_MAX_WAIT_BEFORE_WRITE As Long = 300 ' sec
Private Const C_MAX_RANGE_PROCESS_TIME As Integer = 30 'sec
Private Const C_STAT_STARTING As Integer = 1
Private Const C_STAT_DONE As Integer = 2
Private Const C_STAT_FINISHED As Integer = 3
Private Type DocumentCount
numDocsAnalyzed As Long
numDocsAnalyzedWithIssues As Long
numMinorIssues As Long
numComplexIssues As Long
numMacroIssues As Long
numPreparableIssues As Long
totalMacroCosts As Long
totalDocIssuesCosts As Long
totalPreparableIssuesCosts As Long
End Type
Private Type DocModificationDates
lessThanThreemonths As Long
threeToSixmonths As Long
sixToTwelvemonths As Long
greaterThanOneYear As Long
End Type
Private Type DocMacroClassifications
None As Long
Simple As Long
Medium As Long
complex As Long
End Type
Private Type DocIssueClassifications
None As Long
Minor As Long
complex As Long
End Type
Const CCOST_COL_OFFSET = -1
Private mLogFilePath As String
Private mDocIndex As String
Private mDebugLevel As Long
Private mIniFilePath As String
Private mUserFormTypesDict As Scripting.Dictionary
Private mIssuesDict As Scripting.Dictionary
Private mMacroDict As Scripting.Dictionary
Private mPreparedIssuesDict As Scripting.Dictionary
Private mIssuesClassificationDict As Scripting.Dictionary
Private mIssuesCostDict As Scripting.Dictionary
Private mIssuesLimit As Date
Public Const CWORD_DRIVER_FILE = "_OOoDocAnalysisWordDriver.doc"
Public Const CEXCEL_DRIVER_FILE = "_OOoDocAnalysisExcelDriver.xls"
Public Const CPP_DRIVER_FILE = "_OOoDocAnalysisPPTDriver.ppt"
Public Const CWORD_DRIVER_FILE_TEMP = "~$OoDocAnalysisWordDriver.doc"
Public Const CEXCEL_DRIVER_FILE_TEMP = "~$OoDocAnalysisExcelDriver.xls"
Public Const CPP_DRIVER_FILE_TEMP = "~$OoDocAnalysisPPTDriver.ppt"
'Doc Properties Offsets - used in WriteDocProperties and GetPreparableFilesFromDocProps
Const CDOCINFONAME = 1
Const CDOCINFOAPPLICATION = CDOCINFONAME + 1
Const CDOCINFOISSUE_CLASS = CDOCINFOAPPLICATION + 1
Const CDOCINFOCOMPLEXISSUES = CDOCINFOISSUE_CLASS + 1
Const CDOCINFOMINORISSUES = CDOCINFOCOMPLEXISSUES + 1
Const CDOCINFOPREPAREDISSUES = CDOCINFOMINORISSUES + 1
Const CDOCINFOMACRO_CLASS = CDOCINFOPREPAREDISSUES + 1
Const CDOCINFOMACRO_USERFORMS = CDOCINFOMACRO_CLASS + 1
Const CDOCINFOMACRO_LINESOFCODE = CDOCINFOMACRO_USERFORMS + 1
Const CDOCINFODOCISSUECOSTS = CDOCINFOMACRO_LINESOFCODE + 1
Const CDOCINFOPREPARABLEISSUECOSTS = CDOCINFODOCISSUECOSTS + 1
Const CDOCINFOMACROISSUECOSTS = CDOCINFOPREPARABLEISSUECOSTS + 1
Const CDOCINFONUMBERPAGES = CDOCINFOMACROISSUECOSTS + 1
Const CDOCINFOCREATED = CDOCINFONUMBERPAGES + 1
Const CDOCINFOLASTMODIFIED = CDOCINFOCREATED + 1
Const CDOCINFOLASTACCESSED = CDOCINFOLASTMODIFIED + 1
Const CDOCINFOLASTPRINTED = CDOCINFOLASTACCESSED + 1
Const CDOCINFOLASTSAVEDBY = CDOCINFOLASTPRINTED + 1
Const CDOCINFOREVISION = CDOCINFOLASTSAVEDBY + 1
Const CDOCINFOTEMPLATE = CDOCINFOREVISION + 1
Const CDOCINFONAMEANDPATH = CDOCINFOTEMPLATE + 1
'Overview shapes
Const COV_DOC_MOD_DATES_CHART = "Chart 21"
Const COV_DOC_MACRO_CHART = "Chart 22"
Const COV_DOC_ANALYSIS_CHART = "Chart 23"
Const COV_DOC_MOD_DATES_COMMENT_TXB = "Text Box 25"
Const COV_DOC_MOD_DATES_LEGEND_TXB = "Text Box 12"
Const COV_DOC_MACRO_COMMENT_TXB = "Text Box 26"
Const COV_DOC_MACRO_LEGEND_TXB = "Text Box 16"
Const COV_DOC_ANALYSIS_COMMENT_TXB = "Text Box 27"
Const COV_DOC_ANALYSIS_LEGEND_DAW_TXB = "Text Box 28"
Const COV_DOC_ANALYSIS_LEGEND_PAW_TXB = "Text Box 18"
Const COV_HIGH_LEVEL_ANALYSIS_RANGE = "OV_High_Level_Analysis_Range"
Const COV_COST_RANGE = "OV_Cost_Range"
'Sheet labels
Const COV_HIGH_LEVEL_ANALYSIS_LBL = "OV_High_level_analysis_lbl"
Const COV_DP_PREPISSUES_COL_LBL = "DocProperties_PreparedIssues_Column"
Const COV_COSTS_PREPISSUE_COUNT_COL_LBL = "Costs_PreparedIssueCount_Column"
Const CDP_DAW_HIDDEN_COLS_LBL = "DP_DAW_HIDDEN_COLS_RANGE"
Const CDP_DAW_HIDDEN_COLS2_LBL = "DP_DAW_HIDDEN_COLS_RANGE2"
Const CDP_DAW_HIDDEN_ROW_LBL = "DP_DAW_HIDDEN_ROW_RANGE"
Const COV_DAW_SETUP_SHEETS_RUN_LBL = "OV_DAW_SETUP_SHEETS_RUN"
Const COV_PAW_SETUP_SHEETS_RUN_LBL = "OV_PAW_SETUP_SHEETS_RUN"
Const COV_Internal_Attributes_Cols_LBL = "OV_Internal_Attributes_Cols"
Const CR_STR = "<CR>"
Const CR_TOPIC = "<TOPIC>"
Const CR_PRODUCT = "<PRODUCT>"
Const CLEGEND_FONT_SIZE = 8
Const CCOMMENTS_FONT_SIZE = 10
Dim mTstart As Single
Dim mTend As Single
Public gExcelMaxRangeProcessTime As Integer
Sub AnalyseDirectory()
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "AnalyseDirectory"
Dim iniFilePath As String
Dim startDir As String
Dim fileList As String
Dim storeToDir As String
Dim resultsFile As String
Dim resultsTemplate As String
Dim statFileName As String
Dim bOverwriteResultsFile As Boolean
Dim bNewResultsFile As Boolean
Dim outputType As String
Dim singleFile As String
Dim nTimeNeeded As Long
Dim nIncrementFileCounter As Long
Dim nMaxWaitBeforeWrite As Long
Dim fso As Scripting.FileSystemObject
Set fso = New Scripting.FileSystemObject
SetAppToMinimized
If InDocPreparation Then
mDocPropRowOffset = CDOCPROP_PAW_ROWOFFSET
Else
mDocPropRowOffset = CROWOFFSET
End If
'Get Wizard input variables
SetupWizardVariables fileList, storeToDir, resultsFile, _
mLogFilePath, resultsTemplate, bOverwriteResultsFile, bNewResultsFile, _
statFileName, mDebugLevel, outputType, singleFile
startDir = ProfileGetItem("Analysis", CINPUT_DIR, "", mIniFilePath)
nIncrementFileCounter = CLng(ProfileGetItem("Analysis", _
C_MAX_CHECK_INI, C_MAX_CHECK, mIniFilePath))
nMaxWaitBeforeWrite = CLng(ProfileGetItem("Analysis", _
C_MAX_WAIT_BEFORE_WRITE_INI, C_MAX_WAIT_BEFORE_WRITE, mIniFilePath))
gExcelMaxRangeProcessTime = CInt(ProfileGetItem("Analysis", _
C_MAX_RANGE_PROCESS_TIME_INI, C_MAX_RANGE_PROCESS_TIME, mIniFilePath))
LocalizeResources
'Setup File List
'For Prepare - get list from results spreadsheet with docs analysis found as preparable
'If no results spreadsheet then just try to prepare all the docs - run over full analysis list
Dim myFiles As Collection
Set myFiles = New Collection
Dim sAnalysisOrPrep As String
If InDocPreparation And CheckDoPrepare Then
sAnalysisOrPrep = "Prepared"
If fso.FileExists(storeToDir & "\" & resultsFile) Then
If Not GetPrepareFilesToAnalyze(storeToDir & "\" & resultsFile, myFiles, fso) Then
SetPrepareToNone
WriteDebug currentFunctionName & ": No files to analyse!"
GoTo FinalExit 'No files to prepare - exit
End If
Else
If Not GetFilesToAnalyze(fileList, singleFile, myFiles) Then
SetPrepareToNone
WriteDebug currentFunctionName & ": No files to analyse! Filelist (" & fileList & ") empty?"
GoTo FinalExit 'No files to prepare - exit
End If
End If
Else
sAnalysisOrPrep = "Analyzed"
If Not GetFilesToAnalyze(fileList, singleFile, myFiles) Then
WriteDebug currentFunctionName & ": No files to analyse! Filelist (" & fileList & ") empty?"
GoTo FinalExit
End If
End If
Dim index As Long
Dim numFiles As Long
Dim nextSave As Long
Dim startIndex As Long
Dim bResultsWaiting As Boolean
Dim AnalysedDocs As Collection
Dim startDate As Date
Dim currentDate As Date
Set AnalysedDocs = New Collection
numFiles = myFiles.count
bResultsWaiting = False
If (singleFile <> "") Then
' No recovery handling for single file analysis and the value in the
' ini file should be used for bNewResultsFile
startIndex = 1
Else
bNewResultsFile = bNewResultsFile And GetIndexValues(startIndex, nextSave, myFiles)
End If
startDate = Now()
' Analyse all files
For index = startIndex To numFiles
Set mIssuesClassificationDict = New Scripting.Dictionary
mIssuesClassificationDict.CompareMode = TextCompare
Set mIssuesCostDict = New Scripting.Dictionary
'mIssuesCostDict.CompareMode = TextCompare
Set mUserFormTypesDict = New Scripting.Dictionary
Set mIssuesDict = New Scripting.Dictionary
Set mMacroDict = New Scripting.Dictionary
Set mPreparedIssuesDict = New Scripting.Dictionary
'Write to Application log
Dim myAnalyser As MigrationAnalyser
Set myAnalyser = New MigrationAnalyser
If (CheckForAbort) Then GoTo FinalExit
'Log Analysis
WriteToStatFile statFileName, C_STAT_STARTING, myFiles.item(index), fso
WriteToLog "Analyzing", myFiles.item(index)
WriteToIni C_NEXT_FILE, myFiles.item(index)
mDocIndex = index
'Do Analysis
myAnalyser.DoAnalyse myFiles.item(index), mUserFormTypesDict, startDir, storeToDir, fso
AnalysedDocs.Add myAnalyser.Results
bResultsWaiting = True
WriteToLog sAnalysisOrPrep, index & "of" & numFiles & _
" " & getAppSpecificApplicationName & " Documents"
WriteToLog "Analyzing", "Done"
WriteToLog sAnalysisOrPrep & "Doc" & index, myFiles.item(index)
Set myAnalyser = Nothing
If (CheckForAbort) Then GoTo FinalExit
'No need to output results spreadsheet, just doing prepare
If CheckDoPrepare Then GoTo CONTINUE_FOR
nTimeNeeded = val(DateDiff("s", startDate, Now()))
If ((nTimeNeeded > nMaxWaitBeforeWrite) Or _
(index >= nextSave)) Then
If WriteResults(storeToDir, resultsFile, resultsTemplate, _
bOverwriteResultsFile, bNewResultsFile, _
outputType, AnalysedDocs, fso) Then
nextSave = index + C_MAX_CHECK
bResultsWaiting = False
Set AnalysedDocs = New Collection
WriteToIni C_LAST_CHECKPOINT, myFiles.item(index)
startDate = Now()
Else
'write error
End If
End If
WriteToStatFile statFileName, C_STAT_DONE, myFiles.item(index), fso
CONTINUE_FOR:
Next index
If (bResultsWaiting) Then
If WriteResults(storeToDir, resultsFile, resultsTemplate, _
bOverwriteResultsFile, bNewResultsFile, _
outputType, AnalysedDocs, fso) Then
WriteToIni C_LAST_CHECKPOINT, myFiles.item(index - 1)
Else
'write error
End If
End If
WriteToStatFile statFileName, C_STAT_FINISHED, "", fso
FinalExit:
Set fso = Nothing
Set myFiles = Nothing
Set mIssuesClassificationDict = Nothing
Set mIssuesCostDict = Nothing
Set mUserFormTypesDict = Nothing
Set mIssuesDict = Nothing
Set mMacroDict = Nothing
Set mPreparedIssuesDict = Nothing
Set AnalysedDocs = Nothing
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Function WriteResults(storeToDir As String, resultsFile As String, resultsTemplate As String, _
bOverwriteResultsFile As Boolean, bNewResultsFile As Boolean, _
outputType As String, AnalysedDocs As Collection, _
fso As FileSystemObject) As Boolean
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteResults"
If InDocPreparation Then
If outputType = COUTPUT_TYPE_XML Or outputType = COUTPUT_TYPE_BOTH Then
WriteXMLOutput storeToDir, resultsFile, _
bOverwriteResultsFile, bNewResultsFile, AnalysedDocs, fso
End If
End If
If outputType = COUTPUT_TYPE_XLS Or outputType = COUTPUT_TYPE_BOTH Then
WriteXLSOutput storeToDir, resultsFile, fso.GetAbsolutePathName(resultsTemplate), _
bOverwriteResultsFile, bNewResultsFile, AnalysedDocs, fso
End If
WriteResults = True
bNewResultsFile = False
FinalExit:
Exit Function
HandleErrors:
WriteResults = False
WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Function GetFilesToAnalyze_old(startDir As String, bIncludeSubdirs As Boolean, _
myFiles As Collection) As Boolean
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "GetFilesToAnalyze"
Dim fso As New FileSystemObject
Dim theResultsFile As String
theResultsFile = ProfileGetItem("Analysis", CINPUT_DIR, "c:\", mIniFilePath) & "\" & ProfileGetItem("Analysis", CRESULTS_FILE, "", mIniFilePath)
GetFilesToAnalyze = False
Dim searchTypes As Collection
Set searchTypes = New Collection
SetupSearchTypes searchTypes
If searchTypes.count = 0 Then
GoTo FinalExit
End If
Dim myDocFiles As CollectedFiles
Set myDocFiles = New CollectedFiles
With myDocFiles
.BannedList.Add fso.GetAbsolutePathName(getAppSpecificPath & "\" & CWORD_DRIVER_FILE)
.BannedList.Add fso.GetAbsolutePathName(getAppSpecificPath & "\" & CEXCEL_DRIVER_FILE)
.BannedList.Add fso.GetAbsolutePathName(getAppSpecificPath & "\" & CPP_DRIVER_FILE)
.BannedList.Add fso.GetAbsolutePathName(getAppSpecificPath & "\" & CWORD_DRIVER_FILE_TEMP)
.BannedList.Add fso.GetAbsolutePathName(getAppSpecificPath & "\" & CEXCEL_DRIVER_FILE_TEMP)
.BannedList.Add fso.GetAbsolutePathName(getAppSpecificPath & "\" & CPP_DRIVER_FILE_TEMP)
.BannedList.Add theResultsFile
End With
myDocFiles.Search rootDir:=startDir, FileSpecs:=searchTypes, _
IncludeSubdirs:=bIncludeSubdirs
If getAppSpecificApplicationName = CAPPNAME_WORD Then
Set myFiles = myDocFiles.WordFiles
ElseIf getAppSpecificApplicationName = CAPPNAME_EXCEL Then
Set myFiles = myDocFiles.ExcelFiles
ElseIf getAppSpecificApplicationName = CAPPNAME_POWERPOINT Then
Set myFiles = myDocFiles.PowerPointFiles
Else
WriteDebug currentFunctionName & " : invalid application " & getAppSpecificApplicationName
GoTo FinalExit
End If
GetFilesToAnalyze = True
FinalExit:
Set searchTypes = Nothing
Set myDocFiles = Nothing
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Function GetFilesToAnalyze(fileList As String, startFile As String, _
myFiles As Collection) As Boolean
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "GetFilesToAnalyze"
Dim fso As New FileSystemObject
Dim fileContent As TextStream
Dim fileName As String
GetFilesToAnalyze = False
If (startFile = "") Then
If (fso.FileExists(fileList)) Then
Set fileContent = fso.OpenTextFile(fileList, ForReading, False, TristateTrue)
While (Not fileContent.AtEndOfStream)
fileName = fileContent.ReadLine
fileName = Trim(fileName)
If (fileName <> "") Then
myFiles.Add (fileName)
End If
Wend
fileContent.Close
End If
Else
myFiles.Add (startFile)
End If
If (myFiles.count <> 0) Then GetFilesToAnalyze = True
FinalExit:
Set fileContent = Nothing
Set fso = Nothing
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Function GetPrepareFilesToAnalyze(resultsFilePath As String, myFiles As Collection, _
fso As FileSystemObject) As Boolean
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "GetPrepareFilesToAnalyze"
GetPrepareFilesToAnalyze = False
If Not fso.FileExists(resultsFilePath) Then
WriteDebug currentFunctionName & ": results file does not exist : " & resultsFilePath
GoTo FinalExit
End If
'Open results spreadsheet
Dim xl As Excel.Application
If getAppSpecificApplicationName = CAPPNAME_EXCEL Then
Set xl = Application
xl.Visible = True
Else
Set xl = GetExcelInstance
xl.Visible = False
End If
Dim logWb As WorkBook
Set logWb = xl.Workbooks.Open(resultsFilePath)
Dim wsDocProp As Worksheet
Set wsDocProp = logWb.Sheets(RID_STR_COMMON_RESULTS_SHEET_NAME_DOCPROP)
Dim startRow As Long
Dim endRow As Long
startRow = mDocPropRowOffset + 1
endRow = GetWorkbookNameValueAsLong(logWb, CTOTAL_DOCS_ANALYZED) + mDocPropRowOffset
GetPreparableFilesFromDocProps wsDocProp, startRow, endRow, fso, myFiles
GetPrepareFilesToAnalyze = (myFiles.count > 0)
FinalExit:
Set wsDocProp = Nothing
If Not logWb Is Nothing Then logWb.Close
Set logWb = Nothing
If getAppSpecificApplicationName <> CAPPNAME_EXCEL Then
If Not xl Is Nothing Then
If xl.Workbooks.count = 0 Then
xl.Quit
End If
End If
End If
Set xl = Nothing
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Function GetPreparableFilesFromDocProps(wsDocProp As Worksheet, startRow As Long, _
endRow As Long, fso As FileSystemObject, myFiles As Collection) As Boolean
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "GetPreparableFilesFromDocProps"
GetPreparableFilesFromDocProps = False
Dim index As Long
Dim fileName As String
Dim fileExt As String
Dim docExt As String
Dim templateExt As String
docExt = getAppSpecificDocExt
templateExt = getAppSpecificTemplateExt
For index = startRow To endRow
If GetWorksheetCellValueAsLong(wsDocProp, index, CDOCINFOPREPAREDISSUES) > 0 Then
fileName = GetWorksheetCellValueAsString(wsDocProp, index, CDOCINFONAME)
fileExt = "." & fso.GetExtensionName(fileName)
'Don't have to worry about search types - just looking at existing results
'so just check both legal extensions for this application
If fileExt = docExt Or fileExt = templateExt Then
myFiles.Add GetWorksheetCellValueAsString(wsDocProp, index, CDOCINFONAMEANDPATH)
End If
End If
Next index
GetPreparableFilesFromDocProps = myFiles.count > 0
FinalExit:
Exit Function
HandleErrors:
GetPreparableFilesFromDocProps = False
WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Sub OpenXLSResultFile(resultsFile As String, _
resultsTemplate As String, _
bNewResultsFile As Boolean, _
excelApp As Excel.Application, _
resultSheet As Excel.WorkBook)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "OpenXLSResultFile"
If getAppSpecificApplicationName = CAPPNAME_EXCEL Then
Set excelApp = Application
excelApp.Visible = True
Else
Set excelApp = GetExcelInstance
excelApp.Visible = False
End If
If bNewResultsFile Then
Set resultSheet = excelApp.Workbooks.Add(Template:=resultsTemplate)
Localize_WorkBook resultSheet
Else
Set resultSheet = excelApp.Workbooks.Open(resultsFile)
End If
FinalExit:
Exit Sub
HandleErrors:
excelApp.DisplayAlerts = False
WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub CloseXLSResultFile(excelApp As Excel.Application, _
resultSheet As Excel.WorkBook)
On Error Resume Next
If Not resultSheet Is Nothing Then resultSheet.Close
Set resultSheet = Nothing
If getAppSpecificApplicationName <> CAPPNAME_EXCEL Then
If Not excelApp Is Nothing Then
excelApp.Visible = True
If excelApp.Workbooks.count = 0 Then
excelApp.Quit
End If
End If
End If
Set excelApp = Nothing
Exit Sub
End Sub
Sub WriteXLSOutput(storeToDir As String, resultsFile As String, resultsTemplate As String, _
bOverwriteResultsFile As Boolean, bNewResultsFile As Boolean, AnalysedDocs As Collection, _
fso As Scripting.FileSystemObject)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteXLSOutput"
Dim offsetDocPropRow As Long
Dim offsetDocIssuesRow As Long
Dim offsetDocIssueDetailsRow As Long
Dim offsetDocRefDetailsRow As Long
Const COVERVIEW_SHEET_IDX = 1
Const CDOCLIST_SHEET_IDX = 2
Const CISSUES_ANALYSED_SHEET = 3
Const CISSUE_DETAILS_SHEET = 4
Const CWORD_ISSUES_SHEET = 5
Const CEXCEL_ISSUES_SHEET = 6
Const CPOWERPOINT_ISSUES_SHEET = 7
Const CREFERENCE_ISSUES_SHEET = 8
'Begin writing stats to excel
Dim xl As Excel.Application
If getAppSpecificApplicationName = CAPPNAME_EXCEL Then
Set xl = Application
xl.Visible = True
Else
Set xl = GetExcelInstance
xl.Visible = False
End If
Dim logWb As WorkBook
If bNewResultsFile Then
Set logWb = xl.Workbooks.Add(Template:=resultsTemplate)
Localize_WorkBook logWb
Else
Set logWb = xl.Workbooks.Open(storeToDir & "\" & resultsFile)
End If
SetupAnalysisResultsVariables logWb, offsetDocPropRow, _
offsetDocIssuesRow, offsetDocIssueDetailsRow, offsetDocRefDetailsRow
' Iterate through results and write info
Dim aAnalysis As DocumentAnalysis
Dim row As Long
Dim docCounts As DocumentCount
Dim templateCounts As DocumentCount
Dim issuesRow As Long
Dim issueDetailsRow As Long
Dim refDetailsRow As Long
Dim wsOverview As Worksheet
Dim wsCosts As Worksheet
Dim wsPgStats As Worksheet
Dim wsIssues As Worksheet
Dim wsIssueDetails As Worksheet
Dim wsRefDetails As Worksheet
Set wsOverview = logWb.Sheets(COVERVIEW_SHEET_IDX)
Set wsPgStats = logWb.Sheets(CDOCLIST_SHEET_IDX)
'Some localized names might be longer than 31 chars, excel doesn't
'allow such names!
On Error Resume Next
wsOverview.name = RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW
wsPgStats.name = RID_STR_COMMON_RESULTS_SHEET_NAME_DOCPROP
On Error GoTo HandleErrors
If InDocPreparation Then
Set wsCosts = logWb.Sheets(CISSUES_ANALYSED_SHEET)
Dim appName As String
appName = getAppSpecificApplicationName
Select Case appName
Case "Word"
Set wsIssues = logWb.Worksheets(CWORD_ISSUES_SHEET)
Case "Excel"
Set wsIssues = logWb.Worksheets(CEXCEL_ISSUES_SHEET)
Case "PowerPoint"
Set wsIssues = logWb.Worksheets(CPOWERPOINT_ISSUES_SHEET)
Case Default
Err.Raise Number:=-1, Description:="BadAppName"
End Select
Set wsIssueDetails = logWb.Sheets(CISSUE_DETAILS_SHEET)
Set wsRefDetails = logWb.Sheets(CREFERENCE_ISSUES_SHEET)
issuesRow = 1 + CROWOFFSET + offsetDocIssuesRow
issueDetailsRow = 1 + CROWOFFSET + offsetDocIssueDetailsRow
refDetailsRow = 1 + CROWOFFSET + offsetDocRefDetailsRow
' localize PAW worksheets
Dim wsWordIssues As Worksheet
Dim wsExcelIssues As Worksheet
Dim wsPowerPointIssues As Worksheet
Set wsWordIssues = logWb.Worksheets(CWORD_ISSUES_SHEET)
Set wsExcelIssues = logWb.Worksheets(CEXCEL_ISSUES_SHEET)
Set wsPowerPointIssues = logWb.Worksheets(CPOWERPOINT_ISSUES_SHEET)
On Error Resume Next
wsCosts.name = RID_STR_COMMON_RESULTS_SHEET_NAME_COSTS
wsIssueDetails.name = RID_STR_COMMON_RESULTS_SHEET_NAME_DOCISSUE_DETAILS
wsRefDetails.name = RID_STR_COMMON_RESULTS_SHEET_NAME_DOCREF_DETAILS
wsWordIssues.name = RID_STR_COMMON_RESULTS_SHEET_NAME_DOCISSUES_WORD
wsExcelIssues.name = RID_STR_COMMON_RESULTS_SHEET_NAME_DOCISSUES_EXCEL
wsPowerPointIssues.name = RID_STR_COMMON_RESULTS_SHEET_NAME_DOCISSUES_POWERPOINT
On Error GoTo HandleErrors
End If
Dim fileName As String
Dim macroClasses As DocMacroClassifications
Dim issueClasses As DocIssueClassifications
For row = 1 To AnalysedDocs.count 'Need Row count - so not using Eor Each
Set aAnalysis = AnalysedDocs.item(row)
fileName = fso.GetFileName(aAnalysis.name)
If InDocPreparation Then
issuesRow = WriteDocIssues(wsIssues, issuesRow, aAnalysis, fileName)
issueDetailsRow = _
ProcessIssuesAndWriteDocIssueDetails(logWb, wsIssueDetails, issueDetailsRow, aAnalysis, fileName)
refDetailsRow = _
WriteDocRefDetails(wsRefDetails, refDetailsRow, aAnalysis, fileName)
aAnalysis.MacroCosts = getMacroIssueCosts(logWb, aAnalysis)
WriteDocProperties wsPgStats, row + offsetDocPropRow, aAnalysis, fileName
Else
ProcessIssuesForDAW logWb, aAnalysis, fileName
WriteDocProperties wsPgStats, row + offsetDocPropRow, aAnalysis, fileName
End If
UpdateAllCounts aAnalysis, docCounts, templateCounts, macroClasses, issueClasses, fso
Set aAnalysis = Nothing
Next row
' We change the font used for text box shapes here for the japanese
' version, because office 2000 sometimes displays squares instead of
' chars
Dim langStr As String
Dim userLCID As Long
Dim textSize As Long
Dim fontName As String
userLCID = GetUserDefaultLangID()
langStr = GetUserLocaleInfo(userLCID, LOCALE_SISO639LANGNAME)
If (langStr = "ja") Then
WriteDebug currentFunctionName & " : Setting font to MS PGothic for 'ja' locale"
fontName = "MS PGothic"
textSize = 10
Else
fontName = "Arial"
textSize = CLEGEND_FONT_SIZE
End If
'DAW - PAW switches
If InDocPreparation Then
SaveAnalysisResultsVariables logWb, issueDetailsRow - (1 + CROWOFFSET), _
refDetailsRow - (1 + CROWOFFSET)
WriteOverview logWb, docCounts, templateCounts, macroClasses, issueClasses
SetupPAWResultsSpreadsheet logWb, fontName, textSize
WriteIssueCounts logWb
Else
WriteOverview logWb, docCounts, templateCounts, macroClasses, issueClasses
'StartTiming
SetupDAWResultsSpreadsheet logWb, fontName, textSize
'EndTiming "SetupDAWResultsSpreadsheet"
End If
SetupPrintRanges logWb, row, issuesRow, issueDetailsRow, refDetailsRow
If resultsFile <> "" Then
'Overwrite existing results file without prompting
If bOverwriteResultsFile Or (Not bNewResultsFile) Then
xl.DisplayAlerts = False
End If
logWb.SaveAs fileName:=storeToDir & "\" & resultsFile
xl.DisplayAlerts = True
End If
FinalExit:
If Not xl Is Nothing Then
xl.Visible = True
End If
Set wsOverview = Nothing
Set wsPgStats = Nothing
If InDocPreparation Then
Set wsCosts = Nothing
Set wsIssues = Nothing
Set wsIssueDetails = Nothing
Set wsRefDetails = Nothing
End If
If Not logWb Is Nothing Then logWb.Close
Set logWb = Nothing
If getAppSpecificApplicationName <> CAPPNAME_EXCEL Then
If Not xl Is Nothing Then
If xl.Workbooks.count = 0 Then
xl.Quit
End If
End If
End If
Set xl = Nothing
Exit Sub
HandleErrors:
xl.DisplayAlerts = False
WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Public Sub StartTiming()
mTstart = 0
mTend = 0
mTstart = GetTickCount()
End Sub
Public Sub EndTiming(what As String)
mTend = GetTickCount()
WriteDebug "Timing: " & what & ": " & (FormatNumber((mTend - mTstart) / 1000, 0) & " seconds")
mTstart = 0
mTend = 0
End Sub
Sub WriteIssueCounts(logWb As WorkBook)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteIssueCounts"
Dim Str As String
Dim str1 As String
Dim val1 As Long
Dim count As Long
Dim vKeyArray As Variant
Dim vItemArray As Variant
Dim vPrepKeyArray As Variant
Dim vPrepItemArray As Variant
vKeyArray = mIssuesDict.Keys
vItemArray = mIssuesDict.Items
vPrepKeyArray = mPreparedIssuesDict.Keys
vPrepItemArray = mPreparedIssuesDict.Items
'Write Issue Counts across all Documents
For count = 0 To mIssuesDict.count - 1
str1 = vKeyArray(count)
val1 = CInt(vItemArray(count))
logWb.Names(str1).RefersToRange.Cells(1, 1) = _
logWb.Names(str1).RefersToRange.Cells(1, 1).value + vItemArray(count)
'DEBUG: str = str & "Key: " & str1 & " Value: " & val1 & vbLf
Next count
'Write Prepared Issues Counts across all Documents
For count = 0 To mPreparedIssuesDict.count - 1
str1 = vPrepKeyArray(count)
val1 = CInt(vPrepItemArray(count))
AddVariantToWorkbookNameValue logWb, str1, vPrepItemArray(count)
'DEBUG: str = str & "Key: " & str1 & " Value: " & val1 & vbLf
Next count
'User Form control type count across all analyzed documents of this type
str1 = getAppSpecificApplicationName & "_" & _
CSTR_ISSUE_VBA_MACROS & "_" & _
CSTR_SUBISSUE_PROPERTIES & "_" & _
CSTR_SUBISSUE_VBA_MACROS_USERFORMS_CONTROLTYPE_COUNT
SetWorkbookNameValueToLong logWb, str1, mUserFormTypesDict.count
'Add list of User Form controls and counts to ...USERFORMS_CONTROLTYPE_COUNT field
If mUserFormTypesDict.count > 0 Then
vKeyArray = mUserFormTypesDict.Keys
vItemArray = mUserFormTypesDict.Items
Str = RID_STR_COMMON_ATTRIBUTE_CONTROLS & ": "
For count = 0 To mUserFormTypesDict.count - 1
Str = Str & vbLf & vKeyArray(count) & " " & vItemArray(count)
Next count
WriteUserFromControlTypesComment logWb, str1, Str
End If
'DEBUG: MsgBox str & vbLf & mIssuesDict.count
WriteUniqueModuleCount logWb
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" : logging costs : " & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub WriteUniqueModuleCount(logWb As WorkBook)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteUniqueModuleCount"
Dim strLabel As String
Dim uniqueLineCount As Long
Dim uniqueModuleCount As Long
Dim count As Long
Dim vItemArray As Variant
vItemArray = mMacroDict.Items
'Write Issues Costs
uniqueLineCount = 0
For count = 0 To mMacroDict.count - 1
uniqueLineCount = uniqueLineCount + CInt(vItemArray(count))
Next count
uniqueModuleCount = mMacroDict.count
strLabel = getAppSpecificApplicationName & "_" & _
CSTR_ISSUE_VBA_MACROS & "_" & _
CSTR_SUBISSUE_PROPERTIES & "_" & _
CSTR_SUBISSUE_VBA_MACROS_UNIQUE_MODULE_COUNT
SetWorkbookNameValueToLong logWb, strLabel, uniqueModuleCount
strLabel = getAppSpecificApplicationName & "_" & _
CSTR_ISSUE_VBA_MACROS & "_" & _
CSTR_SUBISSUE_PROPERTIES & "_" & _
CSTR_SUBISSUE_VBA_MACROS_UNIQUE_LINE_COUNT
SetWorkbookNameValueToLong logWb, strLabel, uniqueLineCount
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" : logging Unique Module/ Line Counts : " & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub WriteUserFromControlTypesComment(logWb As WorkBook, name As String, comment As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteUserFromControlTypesComment"
On Error Resume Next 'Ignore error if trying to add comment again - would happen on append to results
logWb.Names(name).RefersToRange.Cells(1, 1).AddComment
On Error GoTo HandleErrors
logWb.Names(name).RefersToRange.Cells(1, 1).comment.Text Text:=comment
'Autosize not supported - Office 2000
'logWb.Names(name).RefersToRange.Cells(1, 1).comment.AutoSize = True
logWb.Names(name).RefersToRange.Cells(1, 1).comment.Visible = False
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" : name : " & name & _
" : comment : " & comment & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub UpdateAllCounts(aAnalysis As DocumentAnalysis, counts As DocumentCount, templateCounts As DocumentCount, _
macroClasses As DocMacroClassifications, issueClasses As DocIssueClassifications, _
fso As FileSystemObject)
Const CMODDATE_LESS3MONTHS = 91
Const CMODDATE_LESS6MONTHS = 182
Const CMODDATE_LESS12MONTHS = 365
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "UpdateAllCounts"
'DocIssue Classification occurs in setDocOverallIssueClassification under
' ProcessIssuesAndWriteDocIssueDetails when all DocIssues are being traversed.
'MacroClass for the Doc is setup at the end of the Analyze_Macros in DoAnalysis
'Mod Dates are determined in SetDocProperties in DoAnalysis
'DocMacroClassifications
Select Case aAnalysis.MacroOverallClass
Case enMacroComplex
macroClasses.complex = macroClasses.complex + 1
Case enMacroMedium
macroClasses.Medium = macroClasses.Medium + 1
Case enMacroSimple
macroClasses.Simple = macroClasses.Simple + 1
Case Else
macroClasses.None = macroClasses.None + 1
End Select
'DocIssueClassifications
aAnalysis.BelowIssuesLimit = True
Select Case aAnalysis.DocOverallIssueClass
Case enComplex
issueClasses.complex = issueClasses.complex + 1
Case enMinor
issueClasses.Minor = issueClasses.Minor + 1
Case Else
issueClasses.None = issueClasses.None + 1
End Select
'DocumentCounts
Dim extStr As String
extStr = "." & LCase(fso.GetExtensionName(aAnalysis.name))
If extStr = getAppSpecificDocExt Then
UpdateDocCounts counts, aAnalysis
ElseIf extStr = getAppSpecificTemplateExt Then
UpdateDocCounts templateCounts, aAnalysis
Else
WriteDebug currentFunctionName & " : path " & aAnalysis.name & _
": unhandled file extesnion " & extStr & " : " & Err.Number & " " & Err.Description & " " & Err.Source
End If
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : path " & aAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub UpdateDocCounts(counts As DocumentCount, aAnalysis As DocumentAnalysis)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "UpdateDocCounts"
counts.numDocsAnalyzed = counts.numDocsAnalyzed + 1
If aAnalysis.IssuesCount > 0 Then 'During Analysis incremented
counts.numDocsAnalyzedWithIssues = counts.numDocsAnalyzedWithIssues + 1
If aAnalysis.BelowIssuesLimit Then
counts.numMinorIssues = _
counts.numMinorIssues + aAnalysis.MinorIssuesCount
'MinorIssuesCount incemented as all DocIssues are being traversed are being written out - ProcessIssuesAndWriteDocIssueDetails
counts.numComplexIssues = counts.numComplexIssues + aAnalysis.ComplexIssuesCount 'Calculated
counts.totalDocIssuesCosts = counts.totalDocIssuesCosts + _
aAnalysis.DocIssuesCosts
counts.totalPreparableIssuesCosts = counts.totalPreparableIssuesCosts + _
aAnalysis.PreparableIssuesCosts
End If
counts.numMacroIssues = counts.numMacroIssues + aAnalysis.MacroIssuesCount 'During Analysis incremented
counts.totalMacroCosts = counts.totalMacroCosts + aAnalysis.MacroCosts
End If
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : path " & aAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub WriteDocProperties(wsPgStats As Worksheet, row As Long, aAnalysis As DocumentAnalysis, _
fileName As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteDocProperties"
Dim rowIndex As Long
rowIndex = row + mDocPropRowOffset
If aAnalysis.Application = RID_STR_COMMON_CANNOT_OPEN Then
SetWorksheetCellValueToString wsPgStats, rowIndex, CDOCINFONAME, fileName
SetWorksheetCellValueToString wsPgStats, rowIndex, CDOCINFOAPPLICATION, aAnalysis.Application
SetWorksheetCellValueToString wsPgStats, rowIndex, CDOCINFONAMEANDPATH, aAnalysis.name
GoTo FinalExit
End If
If InDocPreparation Then
SetWorksheetCellValueToString wsPgStats, rowIndex, CDOCINFONAME, fileName
SetWorksheetCellValueToString wsPgStats, rowIndex, CDOCINFOAPPLICATION, aAnalysis.Application
SetWorksheetCellValueToLong wsPgStats, rowIndex, CDOCINFODOCISSUECOSTS, aAnalysis.DocIssuesCosts
SetWorksheetCellValueToLong wsPgStats, rowIndex, CDOCINFOPREPARABLEISSUECOSTS, aAnalysis.PreparableIssuesCosts
SetWorksheetCellValueToLong wsPgStats, rowIndex, CDOCINFOMACROISSUECOSTS, aAnalysis.MacroCosts
SetWorksheetCellValueToString wsPgStats, rowIndex, CDOCINFOISSUE_CLASS, _
getDocOverallIssueClassificationAsString(aAnalysis.DocOverallIssueClass)
SetWorksheetCellValueToLong wsPgStats, rowIndex, CDOCINFOCOMPLEXISSUES, aAnalysis.ComplexIssuesCount
SetWorksheetCellValueToLong wsPgStats, rowIndex, CDOCINFOMINORISSUES, aAnalysis.MinorIssuesCount
SetWorksheetCellValueToLong wsPgStats, rowIndex, CDOCINFOPREPAREDISSUES, aAnalysis.PreparableIssuesCount
SetWorksheetCellValueToString wsPgStats, rowIndex, CDOCINFOMACRO_CLASS, _
getDocOverallMacroClassAsString(aAnalysis.MacroOverallClass)
SetWorksheetCellValueToLong wsPgStats, rowIndex, CDOCINFOMACRO_USERFORMS, aAnalysis.MacroNumUserForms
SetWorksheetCellValueToLong wsPgStats, rowIndex, CDOCINFOMACRO_LINESOFCODE, aAnalysis.MacroTotalNumLines
SetWorksheetCellValueToLong wsPgStats, rowIndex, CDOCINFONUMBERPAGES, aAnalysis.PageCount
SetWorksheetCellValueToVariant wsPgStats, rowIndex, CDOCINFOCREATED, CheckDate(aAnalysis.Created)
SetWorksheetCellValueToVariant wsPgStats, rowIndex, CDOCINFOLASTMODIFIED, CheckDate(aAnalysis.Modified)
SetWorksheetCellValueToVariant wsPgStats, rowIndex, CDOCINFOLASTACCESSED, CheckDate(aAnalysis.Accessed)
SetWorksheetCellValueToVariant wsPgStats, rowIndex, CDOCINFOLASTPRINTED, CheckDate(aAnalysis.Printed)
SetWorksheetCellValueToString wsPgStats, rowIndex, CDOCINFOLASTSAVEDBY, aAnalysis.SavedBy
SetWorksheetCellValueToString wsPgStats, rowIndex, CDOCINFOREVISION, aAnalysis.Revision
SetWorksheetCellValueToString wsPgStats, rowIndex, CDOCINFOTEMPLATE, aAnalysis.Template
SetWorksheetCellValueToString wsPgStats, rowIndex, CDOCINFONAMEANDPATH, aAnalysis.name
Else
SetWorksheetCellValueToString wsPgStats, rowIndex, CDOCINFONAME, fileName
SetWorksheetCellValueToString wsPgStats, rowIndex, CDOCINFOAPPLICATION, aAnalysis.Application
SetWorksheetCellValueToString wsPgStats, rowIndex, CDOCINFOISSUE_CLASS, _
getDocOverallIssueClassificationAsString(aAnalysis.DocOverallIssueClass)
SetWorksheetCellValueToString wsPgStats, rowIndex, CDOCINFOMACRO_CLASS, _
getDocOverallMacroClassAsString(aAnalysis.MacroOverallClass)
SetWorksheetCellValueToVariant wsPgStats, rowIndex, CDOCINFOLASTMODIFIED, CheckDate(aAnalysis.Modified)
SetWorksheetCellValueToString wsPgStats, rowIndex, CDOCINFONAMEANDPATH, aAnalysis.name
End If
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : path " & aAnalysis.name & " : " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Function CheckDate(myDate As Date) As Variant
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "CheckDate"
Dim lowerNTDateLimit As Date
If Not IsDate(myDate) Then
CheckDate = RID_STR_COMMON_NA
Exit Function
End If
lowerNTDateLimit = DateSerial(1980, 1, 1)
CheckDate = IIf(myDate < lowerNTDateLimit, RID_STR_COMMON_NA, myDate)
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : date " & myDate & " : " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Function WriteDocIssues(wsIssues As Worksheet, row As Long, _
aAnalysis As DocumentAnalysis, fileName As String) As Long
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteDocIssues"
Const CNAME = 1
Const CAPPLICATION = CNAME + 1
Const CISSUE_COLUMNOFFSET = CAPPLICATION
If aAnalysis.IssuesCount = 0 Then
WriteDocIssues = row
Exit Function
End If
SetWorksheetCellValueToString wsIssues, row, CNAME, fileName
SetWorksheetCellValueToString wsIssues, row, CAPPLICATION, aAnalysis.Application
Dim index As Integer
For index = 1 To aAnalysis.TotalIssueTypes
If aAnalysis.IssuesCountArray(index) > 0 Then
SetWorksheetCellValueToString wsIssues, row, CISSUE_COLUMNOFFSET + index, aAnalysis.IssuesCountArray(index)
End If
Next index
SetWorksheetCellValueToString wsIssues, row, CISSUE_COLUMNOFFSET + aAnalysis.TotalIssueTypes + 1, aAnalysis.name
WriteDocIssues = row + 1
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : path " & aAnalysis.name & " : " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Sub ProcessIssuesForDAW(logWb As WorkBook, aAnalysis As DocumentAnalysis, fileName As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "ProcessIssuesForDAW"
Dim myIssue As IssueInfo
Dim issueClass As EnumDocOverallIssueClass
Dim index As Integer
For index = 1 To aAnalysis.Issues.count
Set myIssue = aAnalysis.Issues(index)
If Not isMacroIssue(myIssue) Then
issueClass = getDocIssueClassification(logWb, myIssue)
CountDocIssuesForDoc issueClass, aAnalysis
SetOverallDocIssueClassification issueClass, aAnalysis
End If
Set myIssue = Nothing
Next index
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : path " & aAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Function ProcessIssuesAndWriteDocIssueDetails(logWb As WorkBook, wsIssueDetails As Worksheet, DetailsRow As Long, _
aAnalysis As DocumentAnalysis, fileName As String) As Long
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "ProcessIssueAndWriteDocIssueDetails"
Dim myIssue As IssueInfo
Dim rowIndex As Long
Dim issueClass As EnumDocOverallIssueClass
Dim issueCost As Long
rowIndex = DetailsRow
Dim index As Integer
For index = 1 To aAnalysis.Issues.count
Set myIssue = aAnalysis.Issues(index)
' Process Document Issues and Costs for the Document
' Will be output to List of Documents sheet by WriteDocProperties( )
If Not isMacroIssue(myIssue) Then
issueClass = getDocIssueClassification(logWb, myIssue)
CountDocIssuesForDoc issueClass, aAnalysis
SetOverallDocIssueClassification issueClass, aAnalysis
issueCost = getDocIssueCost(logWb, aAnalysis, myIssue)
aAnalysis.DocIssuesCosts = aAnalysis.DocIssuesCosts + issueCost
If myIssue.Preparable Then
aAnalysis.PreparableIssuesCosts = aAnalysis.PreparableIssuesCosts + issueCost
End If
End If
'Collate Issue and Factor counts across all Documents
'Will be output to the Issues Analyzed sheet by WriteIssueCounts( )
CollateIssueAndFactorCountsAcrossAllDocs aAnalysis, myIssue, fileName
OutputCommonIssueDetails wsIssueDetails, rowIndex, aAnalysis, myIssue, fileName
OutputCommonIssueAttributes wsIssueDetails, rowIndex, myIssue
rowIndex = rowIndex + 1
Set myIssue = Nothing
Next index
ProcessIssuesAndWriteDocIssueDetails = rowIndex
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : path " & aAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Function getDocIssueCost(logWb As WorkBook, aAnalysis As DocumentAnalysis, myIssue As IssueInfo) As Long
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "getDocIssueCost"
Dim issueKey As String
Dim ret As Long
ret = 0
issueKey = getAppSpecificApplicationName & "_" & myIssue.IssueTypeXML & "_" & myIssue.SubTypeXML
ret = getIssueValueFromXLSorDict(logWb, aAnalysis, mIssuesCostDict, issueKey, 1, CCOST_COL_OFFSET)
FinalExit:
getDocIssueCost = ret
Exit Function
HandleErrors:
ret = 0
WriteDebug currentFunctionName & " : path " & aAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Function getMacroIssueCosts(logWb As WorkBook, aAnalysis As DocumentAnalysis) As Long
'Error handling not required
getMacroIssueCosts = getVBAMacroIssueCost(logWb, aAnalysis) '+ getMacroExtRefIssueCost(logWb, aAnalysis)
'NOTE: Currently not counting External Refs as Macro Cost
'could be added if porting off Windows
End Function
Function getVBAMacroIssueCost(logWb As WorkBook, aAnalysis As DocumentAnalysis) As Long
Const CMACRO_ROW_OFFSET_UNIQUE_LINES_COST = 4
Const CMACRO_ROW_OFFSET_USER_FORMS_COUNT_COST = 5
Const CMACRO_ROW_OFFSET_USER_FORMS_CONTROL_COUNT_COST = 6
Const CMACRO_ROW_OFFSET_USER_FORMS_CONTROL_TYPE_COUNT_COST = 7
Const CMACRO_NUM_OF_LINES_FACTOR_KEY = "_UniqueLineCount"
Const CMACRO_USER_FORMS_COUNT_FACTOR_KEY = "_UserFormsCount"
Const CMACRO_USER_FORMS_CONTROL_COUNT_FACTOR_KEY = "_UserFormsControlCount"
Const CMACRO_USER_FORMS_CONTROL_TYPE_COUNT_FACTOR_KEY = "_UserFormsControlTypeCount"
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "getVBAMacroIssueCost"
Dim baseIssueKey As String
Dim ret As Long
ret = 0
If Not aAnalysis.HasMacros Then GoTo FinalExit
'Fetch VBA Macro Cost Factors - if required
baseIssueKey = getAppSpecificApplicationName & "_" & CSTR_ISSUE_VBA_MACROS & "_" & CSTR_SUBISSUE_PROPERTIES
'Num Lines - Costing taken from "Lines in Unique Modules"
If aAnalysis.MacroTotalNumLines > 0 Then
ret = ret + aAnalysis.MacroTotalNumLines * _
getValueFromXLSorDict(logWb, aAnalysis, mIssuesCostDict, _
baseIssueKey & CMACRO_NUM_OF_LINES_FACTOR_KEY, baseIssueKey, _
CMACRO_ROW_OFFSET_UNIQUE_LINES_COST, CCOST_COL_OFFSET)
End If
'User Forms Count
If aAnalysis.MacroNumUserForms > 0 Then
ret = ret + aAnalysis.MacroNumUserForms * _
getValueFromXLSorDict(logWb, aAnalysis, mIssuesCostDict, _
baseIssueKey & CMACRO_USER_FORMS_COUNT_FACTOR_KEY, baseIssueKey, _
CMACRO_ROW_OFFSET_USER_FORMS_COUNT_COST, CCOST_COL_OFFSET)
End If
'User Forms Control Count
If aAnalysis.MacroNumUserFormControls > 0 Then
ret = ret + aAnalysis.MacroNumUserFormControls * _
getValueFromXLSorDict(logWb, aAnalysis, mIssuesCostDict, _
baseIssueKey & CMACRO_USER_FORMS_CONTROL_COUNT_FACTOR_KEY, baseIssueKey, _
CMACRO_ROW_OFFSET_USER_FORMS_CONTROL_COUNT_COST, CCOST_COL_OFFSET)
End If
'User Forms Control Type Count
If aAnalysis.MacroNumUserFormControlTypes > 0 Then
ret = ret + aAnalysis.MacroNumUserFormControlTypes * getValueFromXLSorDict(logWb, aAnalysis, mIssuesCostDict, _
baseIssueKey & CMACRO_USER_FORMS_CONTROL_TYPE_COUNT_FACTOR_KEY, baseIssueKey, CMACRO_ROW_OFFSET_USER_FORMS_CONTROL_TYPE_COUNT_COST, CCOST_COL_OFFSET)
End If
FinalExit:
getVBAMacroIssueCost = ret
Exit Function
HandleErrors:
ret = 0
WriteDebug currentFunctionName & " : path " & aAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Function getMacroExtRefIssueCost(logWb As WorkBook, aAnalysis As DocumentAnalysis) As Long
Const CMACRO_ROW_OFFSET_NUM_EXTERNAL_REFS_COST = 2
Const CMACRO_NUM_EXTERNAL_REFS_FACTOR_KEY = "_ExternalRefs"
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "getMacroExtRefIssueCost"
Dim baseIssueKey As String
Dim ret As Long
ret = 0
If aAnalysis.MacroNumExternalRefs <= 0 Then GoTo FinalExit
'Fetch External Ref Cost Factors
baseIssueKey = getAppSpecificApplicationName & "_" & CSTR_ISSUE_PORTABILITY & "_" & _
CSTR_SUBISSUE_EXTERNAL_REFERENCES_IN_MACRO
ret = ret + aAnalysis.MacroNumExternalRefs * _
getValueFromXLSorDict(logWb, aAnalysis, mIssuesCostDict, _
baseIssueKey & CMACRO_NUM_EXTERNAL_REFS_FACTOR_KEY, baseIssueKey, _
CMACRO_ROW_OFFSET_NUM_EXTERNAL_REFS_COST, CCOST_COL_OFFSET)
FinalExit:
getMacroExtRefIssueCost = ret
Exit Function
HandleErrors:
ret = 0
WriteDebug currentFunctionName & " : path " & aAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Function getIssueValueFromXLSorDict(logWb As WorkBook, aAnalysis As DocumentAnalysis, dict As Scripting.Dictionary, _
key As String, row As Long, column As Long) As Long
'Error handling not required
getIssueValueFromXLSorDict = getValueFromXLSorDict(logWb, aAnalysis, dict, key, key, row, column)
End Function
Function getValueFromXLSorDict(logWb As WorkBook, aAnalysis As DocumentAnalysis, dict As Scripting.Dictionary, _
dictKey As String, xlsKey As String, row As Long, column As Long) As Long
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "getValueFromXLSorDict"
Dim ret As Long
ret = 0
If dict.Exists(dictKey) Then
ret = dict.item(dictKey)
Else
On Error Resume Next
ret = logWb.Names(xlsKey).RefersToRange.Cells(row, column).value
'Log as error missing key
If Err.Number <> 0 Then
WriteDebug currentFunctionName & _
" : Issue Cost Key - " & xlsKey & ": label missing from results.xlt Costs sheet, check sheet and add/ check spelling label" & Err.Number & " " & Err.Description & " " & Err.Source
WriteDebug currentFunctionName & " : dictKey " & dictKey & " : xlsKey " & xlsKey & " : " & Err.Number & " " & Err.Description & " " & Err.Source
ret = 0
End If
On Error GoTo HandleErrors
dict.Add dictKey, ret
End If
FinalExit:
getValueFromXLSorDict = ret
Exit Function
HandleErrors:
ret = 0
WriteDebug currentFunctionName & " : path " & aAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Function isMacroIssue(myIssue As IssueInfo)
'Error handling not required
isMacroIssue = False
If myIssue.IssueTypeXML = CSTR_ISSUE_VBA_MACROS Or _
(myIssue.IssueTypeXML = CSTR_ISSUE_PORTABILITY And _
myIssue.SubTypeXML = CSTR_SUBISSUE_EXTERNAL_REFERENCES_IN_MACRO) Then
isMacroIssue = True
End If
End Function
Sub CountDocIssuesForDoc(issueClass As EnumDocOverallIssueClass, aAnalysis As DocumentAnalysis)
'Error handling not required
If issueClass = enMinor Then
aAnalysis.MinorIssuesCount = aAnalysis.MinorIssuesCount + 1
End If
' Macro issues are counted during analysis
' Complex issues is calculated from: mIssues.count - mMinorIssuesCount - mMacroIssuesCount
End Sub
Sub SetOverallDocIssueClassification(issueClass As EnumDocOverallIssueClass, aAnalysis As DocumentAnalysis)
'Error handling not required
If aAnalysis.DocOverallIssueClass = enComplex Then Exit Sub
If issueClass = enComplex Then
aAnalysis.DocOverallIssueClass = enComplex
Else
aAnalysis.DocOverallIssueClass = enMinor
End If
End Sub
Function getDocIssueClassification(logWb As WorkBook, myIssue As IssueInfo) As EnumDocOverallIssueClass
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "getDocIssueClassification"
Dim issueKey As String
Dim bRet As Boolean
bRet = False
getDocIssueClassification = enMinor
issueKey = getAppSpecificApplicationName & "_" & myIssue.IssueTypeXML & "_" & myIssue.SubTypeXML
If mIssuesClassificationDict.Exists(issueKey) Then
bRet = mIssuesClassificationDict.item(issueKey)
Else
On Error Resume Next
bRet = logWb.Names(issueKey).RefersToRange.Cells(1, 0).value
'Log as error missing key
If Err.Number <> 0 Then
WriteDebug currentFunctionName & _
" : Issue Cost Key - " & issueKey & ": label missing from results.xlt Costs sheet, check sheet and add/ check spelling label" & Err.Number & " " & Err.Description & " " & Err.Source
bRet = False
End If
On Error GoTo HandleErrors
mIssuesClassificationDict.Add issueKey, bRet
End If
FinalExit:
If bRet Then
getDocIssueClassification = enComplex
End If
Exit Function
HandleErrors:
bRet = False
WriteDebug currentFunctionName & " : issueKey " & issueKey & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Function getDocOverallIssueClassificationAsString(docIssueClass As EnumDocOverallIssueClass) As String
Dim Str As String
'Error handling not required
Select Case docIssueClass
Case enComplex
Str = RID_STR_COMMON_ISSUE_CLASS_COMPLEX
Case enMinor
Str = RID_STR_COMMON_ISSUE_CLASS_MINOR
Case Else
Str = RID_STR_COMMON_ISSUE_CLASS_NONE
End Select
getDocOverallIssueClassificationAsString = Str
End Function
Public Function getDocOverallMacroClassAsString(docMacroClass As EnumDocOverallMacroClass) As String
Dim Str As String
'Error handling not required
Select Case docMacroClass
Case enMacroComplex
Str = RID_STR_COMMON_MACRO_CLASS_COMPLEX
Case enMacroMedium
Str = RID_STR_COMMON_MACRO_CLASS_MEDIUM
Case enMacroSimple
Str = RID_STR_COMMON_MACRO_CLASS_SIMPLE
Case Else
Str = RID_STR_COMMON_MACRO_CLASS_NONE
End Select
getDocOverallMacroClassAsString = Str
End Function
Function WriteDocRefDetails(wsRefDetails As Worksheet, DetailsRow As Long, _
aAnalysis As DocumentAnalysis, fileName As String) As Long
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteDocRefDetails"
Dim myIssue As IssueInfo
Dim rowIndex As Long
rowIndex = DetailsRow
Dim index As Integer
'Output References for Docs with Macros
If aAnalysis.HasMacros And (aAnalysis.References.count > 0) Then
For index = 1 To aAnalysis.References.count
Set myIssue = aAnalysis.References(index)
OutputReferenceAttributes wsRefDetails, rowIndex, aAnalysis, myIssue, fileName
rowIndex = rowIndex + 1
Set myIssue = Nothing
Next index
End If
WriteDocRefDetails = rowIndex
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & _
" : path " & aAnalysis.name & ": " & _
" : row " & DetailsRow & ": " & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Sub OutputReferenceAttributes(wsIssueDetails As Worksheet, rowIndex As Long, _
aAnalysis As DocumentAnalysis, myIssue As IssueInfo, fileName As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "OutputReferenceAttributes"
Dim strAttributes As String
With myIssue
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CREF_DETDOCNAME, fileName
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CREF_DETDOCAPPLICATION, aAnalysis.Application
strAttributes = .Values(RID_STR_COMMON_ATTRIBUTE_MAJOR) & "." & .Values(RID_STR_COMMON_ATTRIBUTE_MINOR)
strAttributes = IIf(strAttributes = "0.0" Or strAttributes = ".", .Values(RID_STR_COMMON_ATTRIBUTE_NAME), _
.Values(RID_STR_COMMON_ATTRIBUTE_NAME) & " " & .Values(RID_STR_COMMON_ATTRIBUTE_MAJOR) & _
"." & .Values(RID_STR_COMMON_ATTRIBUTE_MINOR))
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CREF_DETREFERENCE, strAttributes
If .Values(RID_STR_COMMON_ATTRIBUTE_TYPE) = RID_STR_COMMON_ATTRIBUTE_PROJECT Then
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CREF_DETDESCRIPTION, RID_STR_COMMON_ATTRIBUTE_PROJECT
Else
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CREF_DETDESCRIPTION, _
IIf(.Values(RID_STR_COMMON_ATTRIBUTE_DESCRIPTION) <> "", .Values(RID_STR_COMMON_ATTRIBUTE_DESCRIPTION), RID_STR_COMMON_NA)
End If
If .Values(RID_STR_COMMON_ATTRIBUTE_ISBROKEN) <> RID_STR_COMMON_ATTRIBUTE_BROKEN Then
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CREF_DETLOCATION, _
.Values(RID_STR_COMMON_ATTRIBUTE_FILE)
Else
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CREF_DETLOCATION, _
RID_STR_COMMON_NA
End If
'Reference Details
strAttributes = RID_STR_COMMON_ATTRIBUTE_TYPE & ": " & .Values(RID_STR_COMMON_ATTRIBUTE_TYPE) & vbLf
strAttributes = strAttributes & RID_STR_COMMON_ATTRIBUTE_PROPERTIES & ": " & _
.Values(RID_STR_COMMON_ATTRIBUTE_BUILTIN) & " " & .Values(RID_STR_COMMON_ATTRIBUTE_ISBROKEN)
strAttributes = IIf(.Values(RID_STR_COMMON_ATTRIBUTE_GUID) <> "", _
strAttributes & vbLf & RID_STR_COMMON_ATTRIBUTE_GUID & ": " & .Values(RID_STR_COMMON_ATTRIBUTE_GUID), _
strAttributes)
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CREF_DETATTRIBUTES, strAttributes
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CREF_DETNAMEANDPATH, aAnalysis.name
End With
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" : path " & aAnalysis.name & ": " & _
" : rowIndex " & rowIndex & ": " & _
" : myIssue " & myIssue.IssueTypeXML & "_" & myIssue.SubTypeXML & ": " & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub OutputCommonIssueAttributes(wsIssueDetails As Worksheet, rowIndex As Long, _
myIssue As IssueInfo)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "OutputCommonIssueAttributes"
Dim index As Integer
Dim strAttributes As String
strAttributes = ""
For index = 1 To myIssue.Attributes.count
strAttributes = strAttributes & myIssue.Attributes(index) & " - " & _
myIssue.Values(index)
strAttributes = strAttributes & IIf(index <> myIssue.Attributes.count, vbLf, "")
Next index
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CISSUE_DETATTRIBUTES, strAttributes
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" : rowIndex " & rowIndex & ": " & _
" : myIssue " & myIssue.IssueTypeXML & "_" & myIssue.SubTypeXML & ": " & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
'Store issue cost and factor costs across all documents
Sub CollateIssueAndFactorCountsAcrossAllDocs(aAnalysis As DocumentAnalysis, myIssue As IssueInfo, fileName As String)
Const CSTR_USER_FORM = "User Form"
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "CollateIssueAndFactorCountsAcrossAllDocs"
'Don't want to cost ISSUE_INFORMATION issues
If myIssue.IssueTypeXML = CSTR_ISSUE_INFORMATION Then Exit Sub
Dim issueKey As String
issueKey = getAppSpecificApplicationName & "_" & myIssue.IssueTypeXML & "_" & myIssue.SubTypeXML
'Store costing metrics for Issue
AddIssueAndOneToDict issueKey
'Store prepeared issue for costing metrics
If myIssue.Preparable Then
AddPreparedIssueAndOneToDict issueKey & "_Prepared"
End If
'Additional costing Factors output for VB macros
If (myIssue.IssueTypeXML = CSTR_ISSUE_VBA_MACROS) And _
(myIssue.SubTypeXML <> CSTR_SUBISSUE_MACRO_PASSWORD_PROTECTION) Then
'Unique Macro Module and Line count
AddMacroModuleHashToMacroDict myIssue
'Line count
AddIssueAndValToDict issueKey & "_" & CSTR_SUBISSUE_VBA_MACROS_NUMLINES, myIssue, _
RID_STR_COMMON_ATTRIBUTE_NUMBER_OF_LINES
'User From info
If myIssue.SubLocation = CSTR_USER_FORM Then
AddIssueAndOneToDict issueKey & "_" & CSTR_SUBISSUE_VBA_MACROS_USERFORMS_COUNT
AddIssueAndValToDict issueKey & "_" & CSTR_SUBISSUE_VBA_MACROS_USERFORMS_CONTROL_COUNT, myIssue, _
RID_STR_COMMON_ATTRIBUTE_CONTROLS
End If
'Additional costing Factors output for External References
ElseIf (myIssue.IssueTypeXML = CSTR_ISSUE_PORTABILITY And _
myIssue.SubTypeXML = CSTR_SUBISSUE_EXTERNAL_REFERENCES_IN_MACRO) Then
AddIssueAndValToDict issueKey & "_" & CSTR_SUBISSUE_EXTERNAL_REFERENCES_IN_MACRO_COUNT, myIssue, _
RID_STR_COMMON_ATTRIBUTE_NON_PORTABLE_EXTERNAL_REFERENCES_COUNT
End If
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" : path " & aAnalysis.name & ": " & _
" : myIssue " & myIssue.IssueTypeXML & "_" & myIssue.SubTypeXML & ": " & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub OutputCommonIssueDetails(wsIssueDetails As Worksheet, rowIndex As Long, _
aAnalysis As DocumentAnalysis, myIssue As IssueInfo, fileName As String)
Const CSTR_USER_FORM = "User Form"
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "OutputCommonIssueDetails"
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CISSUE_DETDOCNAME, fileName
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CISSUE_DETDOCAPPLICATION, aAnalysis.Application
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CISSUE_DETTYPE, myIssue.IssueType
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CISSUE_DETSUBTYPE, myIssue.SubType
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CISSUE_DETLOCATION, myIssue.Location
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CISSUE_DETSUBLOCATION, _
IIf(myIssue.SubLocation = "", RID_STR_COMMON_NA, myIssue.SubLocation)
SetWorksheetCellValueToVariant wsIssueDetails, rowIndex, CISSUE_DETLINE, _
IIf(myIssue.Line = -1, RID_STR_COMMON_NA, myIssue.Line)
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CISSUE_DETCOLUMN, _
IIf(myIssue.column = "", RID_STR_COMMON_NA, myIssue.column)
SetWorksheetCellValueToString wsIssueDetails, rowIndex, CISSUE_DETNAMEANDPATH, aAnalysis.name
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" : path " & aAnalysis.name & ": " & _
" : rowIndex " & rowIndex & ": " & _
" : myIssue " & myIssue.IssueTypeXML & "_" & myIssue.SubTypeXML & ": " & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub AddIssueAndBoolValToDict(issueKey As String, issue As IssueInfo, valKey As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "AddIssueAndBoolValToDict"
If mIssuesDict.Exists(issueKey) Then
mIssuesDict.item(issueKey) = mIssuesDict.item(issueKey) + _
IIf(issue.Values(valKey) > 0, 1, 0)
Else
mIssuesDict.Add issueKey, IIf(issue.Values(valKey) > 0, 1, 0)
End If
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" : issueKey " & issueKey & ": " & _
" : valKey " & valKey & ": " & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub AddIssueAndValToDict(issueKey As String, issue As IssueInfo, valKey As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "AddIssueAndValToDict"
If mIssuesDict.Exists(issueKey) Then
mIssuesDict.item(issueKey) = mIssuesDict.item(issueKey) + issue.Values(valKey)
Else
mIssuesDict.Add issueKey, issue.Values(valKey)
End If
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" : issueKey " & issueKey & ": " & _
" : valKey " & valKey & ": " & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub AddMacroModuleHashToMacroDict(issue As IssueInfo)
On Error GoTo HandleErrors
Dim currentFunctionName As String
Dim issueKey As String
Dim issueVal As String
currentFunctionName = "AddMacroModuleHashToMacroDict"
issueKey = issue.Values(RID_STR_COMMON_ATTRIBUTE_SIGNATURE)
If issueKey = RID_STR_COMMON_NA Then Exit Sub
If Not mMacroDict.Exists(issueKey) Then
mMacroDict.Add issueKey, issue.Values(RID_STR_COMMON_ATTRIBUTE_NUMBER_OF_LINES)
End If
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" : issueKey " & issueKey & ": " & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub AddIssueAndOneToDict(key As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "AddIssueAndOneToDict"
If mIssuesDict.Exists(key) Then
mIssuesDict.item(key) = mIssuesDict.item(key) + 1
Else
mIssuesDict.Add key, 1
End If
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : key " & key & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub AddPreparedIssueAndOneToDict(key As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "AddPreparedIssueAndOneToDict"
If mPreparedIssuesDict.Exists(key) Then
mPreparedIssuesDict.item(key) = mPreparedIssuesDict.item(key) + 1
Else
mPreparedIssuesDict.Add key, 1
End If
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : key " & key & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Function GetExcelInstance() As Excel.Application
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "GetExcelInstance"
Dim xl As Excel.Application
On Error Resume Next
'Try and get an existing instance
Set xl = GetObject(, "Excel.Application")
If Err.Number = 429 Then
Set xl = CreateObject("Excel.Application")
ElseIf Err.Number <> 0 Then
Set xl = Nothing
MsgBox "Error: " & Err.Description
Exit Function
End If
Set GetExcelInstance = xl
Set xl = Nothing
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Sub WriteOverview(logWb As WorkBook, DocCount As DocumentCount, templateCount As DocumentCount, _
macroClasses As DocMacroClassifications, issueClasses As DocIssueClassifications)
Const COV_ISSUECLASS_COMPLEX = "MAW_ISSUECLASS_COMPLEX"
Const COV_ISSUECLASS_MINOR = "MAW_ISSUECLASS_MINOR"
Const COV_ISSUECLASS_NONE = "MAW_ISSUECLASS_NONE"
Const COV_MACROCLASS_COMPLEX = "MAW_MACROCLASS_COMPLEX"
Const COV_MACROCLASS_MEDIUM = "MAW_MACROCLASS_MEDIUM"
Const COV_MACROCLASS_SIMPLE = "MAW_MACROCLASS_SIMPLE"
Const COV_MACROCLASS_NONE = "MAW_MACROCLASS_NONE"
Const COV_ISSUECOUNT_COMPLEX = "MAW_ISSUECOUNT_COMPLEX"
Const COV_ISSUECOUNT_MINOR = "MAW_ISSUECOUNT_MINOR"
Const COV_MODDATES_LESS3MONTHS = "MAW_MODDATES_LESS3MONTHS"
Const COV_MODDATES_3TO6MONTHS = "MAW_MODDATES_3TO6MONTHS"
Const COV_MODDATES_6TO12MONTHS = "MAW_MODDATES_6TO12MONTHS"
Const COV_MODDATES_MORE12MONTHS = "MAW_MODDATES_MORE12MONTHS"
Const COV_DOC_MIGRATION_COSTS = "Document_Migration_Costs"
Const COV_DOC_PREPARABLE_COSTS = "Document_Migration_Preparable_Costs"
Const COV_MACRO_MIGRATION_COSTS = "Macro_Migration_Costs"
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteOverview"
Dim appName As String
appName = getAppSpecificApplicationName
'OV - Title
SetWorkbookNameValueToString logWb, COVERVIEW_TITLE_LABEL, GetTitle
SetWorkbookNameValueToVariant logWb, "AnalysisDate", Now
SetWorkbookNameValueToString logWb, "AnalysisVersion", _
RID_STR_COMMON_OV_VERSION_STR & ": " & GetTitle & " " & GetVersion
'OV - Number of Documents Analyzed
AddLongToWorkbookNameValue logWb, CNUMBERDOC_ALL & getAppSpecificDocExt, DocCount.numDocsAnalyzed
AddLongToWorkbookNameValue logWb, CNUMBERDOC_ALL & getAppSpecificTemplateExt, templateCount.numDocsAnalyzed
'OV - Documents with Document Migration Issues (excludes macro issues)
AddLongToWorkbookNameValue logWb, appName & "_" & COV_ISSUECLASS_COMPLEX, issueClasses.complex
AddLongToWorkbookNameValue logWb, appName & "_" & COV_ISSUECLASS_MINOR, issueClasses.Minor
AddLongToWorkbookNameValue logWb, appName & "_" & COV_ISSUECLASS_NONE, issueClasses.None
'OV - Documents with Macro Migration Issues
AddLongToWorkbookNameValue logWb, appName & "_" & COV_MACROCLASS_COMPLEX, macroClasses.complex
AddLongToWorkbookNameValue logWb, appName & "_" & COV_MACROCLASS_MEDIUM, macroClasses.Medium
AddLongToWorkbookNameValue logWb, appName & "_" & COV_MACROCLASS_SIMPLE, macroClasses.Simple
AddLongToWorkbookNameValue logWb, appName & "_" & COV_MACROCLASS_NONE, macroClasses.None
'OV - Document Modification Dates
Dim modDates As DocModificationDates
Call GetDocModificationDates(modDates)
SetWorkbookNameValueToLong logWb, COV_MODDATES_LESS3MONTHS, modDates.lessThanThreemonths
SetWorkbookNameValueToLong logWb, COV_MODDATES_3TO6MONTHS, modDates.threeToSixmonths
SetWorkbookNameValueToLong logWb, COV_MODDATES_6TO12MONTHS, modDates.sixToTwelvemonths
SetWorkbookNameValueToLong logWb, COV_MODDATES_MORE12MONTHS, modDates.greaterThanOneYear
If InDocPreparation Then
'OV - Document Migration Issues(excludes macro issues)
AddLongToWorkbookNameValue logWb, appName & "_" & COV_ISSUECOUNT_COMPLEX, _
DocCount.numComplexIssues + templateCount.numComplexIssues
AddLongToWorkbookNameValue logWb, appName & "_" & COV_ISSUECOUNT_MINOR, _
DocCount.numMinorIssues + templateCount.numMinorIssues
'OV - Document Migration Costs
AddLongToWorkbookNameValue logWb, appName & "_" & COV_DOC_MIGRATION_COSTS, _
DocCount.totalDocIssuesCosts + templateCount.totalDocIssuesCosts
'OV - Document Migration Preparable Costs
AddLongToWorkbookNameValue logWb, COV_DOC_PREPARABLE_COSTS, _
DocCount.totalPreparableIssuesCosts + templateCount.totalPreparableIssuesCosts
'OV - Macro Migration Costs
AddLongToWorkbookNameValue logWb, appName & "_" & COV_MACRO_MIGRATION_COSTS, _
DocCount.totalMacroCosts + templateCount.totalMacroCosts
End If
'OV - Internal Attributes
AddLongToWorkbookNameValue logWb, appName & "_" & "TotalDocsAnalysedWithIssues", _
DocCount.numDocsAnalyzedWithIssues + templateCount.numDocsAnalyzedWithIssues
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : Problem writing overview: " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub SetupDAWResultsSpreadsheet(logWb As WorkBook, fontName As String, fontSize As Long)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetupDAWResultsSpreadsheet"
Dim bSetupRun As Boolean
bSetupRun = CBool(GetWorkbookNameValueAsLong(logWb, COV_DAW_SETUP_SHEETS_RUN_LBL))
If bSetupRun Then Exit Sub
'Setup Text Boxes
SetupSheetTextBox logWb, RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW, COV_DOC_MOD_DATES_COMMENT_TXB, _
RID_STR_COMMON_OV_DOC_MOD_DATES_COMMENT_TITLE, RID_STR_COMMON_OV_DOC_MOD_DATES_COMMENT_BODY, _
CCOMMENTS_FONT_SIZE, fontName
SetupSheetTextBox logWb, RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW, COV_DOC_MOD_DATES_LEGEND_TXB, _
RID_STR_COMMON_OV_LEGEND_TITLE, RID_STR_COMMON_OV_DOC_MOD_DATES_LEGEND_BODY, fontSize, fontName
SetupSheetTextBox logWb, RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW, COV_DOC_MACRO_COMMENT_TXB, _
RID_STR_COMMON_OV_DOC_MACRO_COMMENT_TITLE, RID_STR_COMMON_OV_DOC_MACRO_COMMENT_BODY, _
CCOMMENTS_FONT_SIZE, fontName
SetupSheetTextBox logWb, RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW, COV_DOC_MACRO_LEGEND_TXB, _
RID_STR_COMMON_OV_LEGEND_TITLE, RID_STR_COMMON_OV_DOC_MACRO_LEGEND_BODY, fontSize, fontName
Dim monthLimit As Long
monthLimit = GetIssuesLimitInDays / CNUMDAYS_IN_MONTH
SetWorkbookNameValueToString logWb, COV_HIGH_LEVEL_ANALYSIS_LBL, _
IIf(monthLimit <> CMAX_LIMIT, _
ReplaceTopicTokens(RID_STR_COMMON_OV_HIGH_LEVEL_ANALYSIS_DAW, CR_TOPIC, CStr(monthLimit)), _
RID_STR_COMMON_OV_HIGH_LEVEL_ANALYSIS_PAW_NO_LIMIT)
SetupSheetTextBox logWb, RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW, COV_DOC_ANALYSIS_COMMENT_TXB, _
RID_STR_COMMON_OV_DOC_ANALYSIS_COMMENT_TITLE, RID_STR_COMMON_OV_DOC_ANALYSIS_COMMENT_BODY, _
CCOMMENTS_FONT_SIZE, fontName
SetupSheetTextBox logWb, RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW, COV_DOC_ANALYSIS_LEGEND_DAW_TXB, _
RID_STR_COMMON_OV_LEGEND_TITLE, RID_STR_COMMON_OV_DOC_ANALYSIS_DAW_LEGEND_BODY, fontSize, fontName
'Setup Chart Titles
SetupSheetChartTitles logWb, RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW, COV_DOC_MOD_DATES_CHART, _
RID_STR_COMMON_OV_DOC_MOD_DATES_CHART_TITLE
SetupSheetChartTitles logWb, RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW, COV_DOC_MACRO_CHART, _
RID_STR_COMMON_OV_DOC_MACRO_CHART_TITLE
SetupSheetChartTitles logWb, RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW, COV_DOC_ANALYSIS_CHART, _
RID_STR_COMMON_OV_DOC_ANALYSIS_CHART_TITLE
'Set selection to top cell of Overview
logWb.Sheets(RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW).Range("A1").Select
bSetupRun = True
SetWorkbookNameValueToBoolean logWb, COV_DAW_SETUP_SHEETS_RUN_LBL, bSetupRun
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : Problem setting up spreadsheet for DAW: " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub SetupPAWResultsSpreadsheet(logWb As WorkBook, fontName As String, fontSize As Long)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetupPAWResultsSpreadsheet"
Dim bSetupRun As Boolean
bSetupRun = CBool(GetWorkbookNameValueAsLong(logWb, COV_PAW_SETUP_SHEETS_RUN_LBL))
If bSetupRun Then Exit Sub
'Costs
logWb.Names(COV_COSTS_PREPISSUE_COUNT_COL_LBL).RefersToRange.EntireColumn.Hidden = False
'Setup Text Boxes
SetupSheetTextBox logWb, RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW, COV_DOC_MOD_DATES_LEGEND_TXB, _
RID_STR_COMMON_OV_LEGEND_TITLE, RID_STR_COMMON_OV_DOC_MOD_DATES_LEGEND_BODY, fontSize, fontName
SetupSheetTextBox logWb, RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW, COV_DOC_MACRO_LEGEND_TXB, _
RID_STR_COMMON_OV_LEGEND_TITLE, RID_STR_COMMON_OV_DOC_MACRO_LEGEND_BODY, fontSize, fontName
SetWorkbookNameValueToString logWb, COV_HIGH_LEVEL_ANALYSIS_LBL, _
RID_STR_COMMON_OV_HIGH_LEVEL_ANALYSIS_PAW_NO_LIMIT
SetupSheetTextBox logWb, RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW, COV_DOC_ANALYSIS_LEGEND_PAW_TXB, _
RID_STR_COMMON_OV_LEGEND_TITLE, RID_STR_COMMON_OV_DOC_ANALYSIS_PAW_LEGEND_BODY, fontSize, fontName
'Setup Chart Titles
SetupSheetChartTitles logWb, RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW, COV_DOC_MOD_DATES_CHART, _
RID_STR_COMMON_OV_DOC_MOD_DATES_CHART_TITLE
SetupSheetChartTitles logWb, RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW, COV_DOC_MACRO_CHART, _
RID_STR_COMMON_OV_DOC_MACRO_CHART_TITLE
SetupSheetChartTitles logWb, RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW, COV_DOC_ANALYSIS_CHART, _
RID_STR_COMMON_OV_DOC_ANALYSIS_CHART_TITLE
'Set selection to top cell of Overview
logWb.Sheets(RID_STR_COMMON_RESULTS_SHEET_NAME_OVERVIEW).Range("A1").Select
bSetupRun = True
SetWorkbookNameValueToBoolean logWb, COV_PAW_SETUP_SHEETS_RUN_LBL, bSetupRun
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : Problem setting up spreadsheet for PAW: " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub SetupPrintRanges(logWb As WorkBook, docPropRow As Long, appIssuesRow As Long, issueDetailsRow As Long, _
refDetailsRow As Long)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetupPrintRanges"
'Set Print Ranges
If InDocPreparation Then
logWb.Worksheets(RID_STR_COMMON_RESULTS_SHEET_NAME_DOCPROP).PageSetup.PrintArea = "$A1:$U" & (docPropRow + mDocPropRowOffset)
logWb.Worksheets(RID_STR_COMMON_RESULTS_SHEET_NAME_DOCISSUE_DETAILS).PageSetup.PrintArea = "$A1:$J" & issueDetailsRow
logWb.Worksheets(RID_STR_COMMON_RESULTS_SHEET_NAME_DOCREF_DETAILS).PageSetup.PrintArea = "$A1:$G" & refDetailsRow
If getAppSpecificApplicationName = CAPPNAME_WORD Then
logWb.Worksheets(RID_STR_COMMON_RESULTS_SHEET_NAME_DOCISSUES_WORD).PageSetup.PrintArea = _
"$A1:$N" & appIssuesRow
ElseIf getAppSpecificApplicationName = CAPPNAME_EXCEL Then
logWb.Worksheets(RID_STR_COMMON_RESULTS_SHEET_NAME_DOCISSUES_EXCEL).PageSetup.PrintArea = _
"$A1:$M" & appIssuesRow
Else
logWb.Worksheets(RID_STR_COMMON_RESULTS_SHEET_NAME_DOCISSUES_POWERPOINT).PageSetup.PrintArea = _
"$A1:$K" & appIssuesRow
End If
Else
logWb.Worksheets(RID_STR_COMMON_RESULTS_SHEET_NAME_DOCPROP).PageSetup.PrintArea = "$A1:$U" & (docPropRow + mDocPropRowOffset)
End If
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : Problem setting print ranges: " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub SetupSheetChartTitles(logWb As WorkBook, namedWorksheet As String, namedChart As String, _
chartTitle As String)
Const CCHART_TITLE_FONT_SIZE = 11
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetupSheetChartTitles"
With logWb.Sheets(namedWorksheet).ChartObjects(namedChart).Chart
.HasTitle = True
.chartTitle.Characters.Text = chartTitle
.chartTitle.Font.Size = CCHART_TITLE_FONT_SIZE
End With
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" namedWorkSheet: " & namedWorksheet & _
" namedChart: " & namedChart & _
" chartTitle: " & chartTitle & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub SetupSheetTextBox(logWb As WorkBook, namedWorksheet As String, _
textBoxName As String, textBoxTitle As String, textBoxBody As String, _
textSize As Long, fontName As String)
Const CMAX_INSERTABLE_STRING_LEN = 255
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetupSheetTextBox"
Dim strTextBody As String
Dim allText As String
strTextBody = ReplaceTopic2Tokens(textBoxBody, CR_STR, Chr(10), CR_PRODUCT, RID_STR_COMMON_OV_PRODUCT_STR)
'Setup Text Boxes
logWb.Sheets(namedWorksheet).Activate
logWb.Sheets(namedWorksheet).Shapes(textBoxName).Select
'*** Workaround Excel bug: 213841 XL: Passed Strings Longer Than 255 Characters Are Truncated
Dim I As Long
logWb.Application.Selection.Text = ""
logWb.Application.Selection.Characters.Text = textBoxTitle & Chr(10)
With logWb.Application.Selection
For I = 0 To Int(Len(strTextBody) / CMAX_INSERTABLE_STRING_LEN)
.Characters(.Characters.count + 1).Text = Mid(strTextBody, _
(I * CMAX_INSERTABLE_STRING_LEN) + 1, CMAX_INSERTABLE_STRING_LEN)
Next
End With
'Highlight title only
With logWb.Application.Selection.Characters(start:=1, Length:=Len(textBoxTitle)).Font
.name = fontName
.FontStyle = "Bold"
.Size = textSize
End With
With logWb.Application.Selection.Characters(start:=Len(textBoxTitle) + 1, _
Length:=Len(strTextBody) + 1).Font
.name = fontName
.FontStyle = "Regular"
.Size = textSize
End With
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" namedWorkSheet: " & namedWorksheet & _
" textBoxName: " & textBoxName & _
" textBoxTitle: " & textBoxTitle & _
" textBoxBody: " & textBoxBody & _
" textSize: " & textSize & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Function GetWorkbookNameValueAsLong(logWb As WorkBook, name As String) As Long
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "GetWorkbookNameValueAsLong"
GetWorkbookNameValueAsLong = logWb.Names(name).RefersToRange.Cells(1, 1).value
FinalExit:
Exit Function
HandleErrors:
GetWorkbookNameValueAsLong = 0
WriteDebug currentFunctionName & " : name " & name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Function GetWorksheetCellValueAsLong(logWs As Worksheet, row As Long, col As Long) As Long
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "GetWorksheetCellValueAsLong"
GetWorksheetCellValueAsLong = logWs.Cells(row, col).value
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & _
" : row " & row & _
" : col " & col & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Function GetWorksheetCellValueAsString(logWs As Worksheet, row As Long, col As Long) As String
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "GetWorksheetCellValueToString"
GetWorksheetCellValueAsString = logWs.Cells(row, col).value
FinalExit:
Exit Function
HandleErrors:
GetWorksheetCellValueAsString = ""
WriteDebug currentFunctionName & _
" : row " & row & _
" : col " & col & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Sub SetWorksheetCellValueToLong(logWs As Worksheet, row As Long, col As Long, val As Long)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetWorksheetCellValueToLong"
logWs.Cells(row, col) = val
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" : row " & row & _
" : col " & col & _
" : val " & val & ": " & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub SetWorksheetCellValueToInteger(logWs As Worksheet, row As Long, col As Long, intVal As Integer)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetWorksheetCellValueToInteger"
logWs.Cells(row, col) = intVal
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" : row " & row & _
" : col " & col & _
" : intVal " & intVal & ": " & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub SetWorksheetCellValueToVariant(logWs As Worksheet, row As Long, col As Long, varVal As Variant)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetWorksheetCellValueToInteger"
logWs.Cells(row, col) = varVal
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" : row " & row & _
" : col " & col & _
" : varVal " & varVal & ": " & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub SetWorksheetCellValueToString(logWs As Worksheet, row As Long, col As Long, strVal As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetWorksheetCellValueToString"
logWs.Cells(row, col) = strVal
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" : row " & row & _
" : col " & col & _
" : strVal " & strVal & ": " & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub SetWorkbookNameValueToBoolean(logWb As WorkBook, name As String, bVal As Boolean)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetWorkbookNameValueToBoolean"
logWb.Names(name).RefersToRange.Cells(1, 1) = bVal
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : name " & name & " : boolean value " & bVal & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub SetWorkbookNameValueToString(logWb As WorkBook, name As String, val As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetWorkbookNameValueToString"
logWb.Names(name).RefersToRange.Cells(1, 1) = val
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : name " & name & " : value " & val & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub SetWorkbookNameValueToLong(logWb As WorkBook, name As String, val As Long)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetWorkbookNameValueToLong"
logWb.Names(name).RefersToRange.Cells(1, 1) = val
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : name " & name & " : value " & val & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub SetWorkbookNameValueToVariant(logWb As WorkBook, name As String, val As Variant)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetWorkbookNameValueToVariant"
logWb.Names(name).RefersToRange.Cells(1, 1) = val
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : name " & name & " : value " & val & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub AddLongToWorkbookNameValue(logWb As WorkBook, name As String, val As Long)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "AddLongToWorkbookNameValue"
logWb.Names(name).RefersToRange.Cells(1, 1) = logWb.Names(name).RefersToRange.Cells(1, 1).value + val
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : name " & name & " : value " & val & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub AddVariantToWorkbookNameValue(logWb As WorkBook, name As String, varVal As Variant)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "AddVariantToWorkbookNameValue"
logWb.Names(name).RefersToRange.Cells(1, 1) = logWb.Names(name).RefersToRange.Cells(1, 1).value + varVal
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : name " & name & " : value " & varVal & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub SaveAnalysisResultsVariables(logWb As WorkBook, offsetDocIssueDetailsRow As Long, _
offsetDocRefDetailsRow As Long)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SaveAnalysisResultsVariables"
'OV - Internal Attributes
SetWorkbookNameValueToLong logWb, "TotalIssuesAnalysed", offsetDocIssueDetailsRow
SetWorkbookNameValueToLong logWb, "TotalRefsAnalysed", offsetDocRefDetailsRow
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : offsetDocIssueDetailsRow " & offsetDocIssueDetailsRow & _
" : offsetDocRefDetailsRow " & offsetDocRefDetailsRow & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub SetupAnalysisResultsVariables(logWb As WorkBook, _
offsetDocPropRow As Long, offsetDocIssuesRow As Long, _
offsetDocIssueDetailsRow As Long, offsetDocRefDetailsRow As Long)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetupAnalysisResultsVariables"
offsetDocPropRow = GetWorkbookNameValueAsLong(logWb, CTOTAL_DOCS_ANALYZED)
offsetDocIssueDetailsRow = GetWorkbookNameValueAsLong(logWb, "TotalIssuesAnalysed")
offsetDocRefDetailsRow = GetWorkbookNameValueAsLong(logWb, "TotalRefsAnalysed")
offsetDocIssuesRow = GetWorkbookNameValueAsLong(logWb, getAppSpecificApplicationName & "_" & "TotalDocsAnalysedWithIssues")
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
" : offsetDocPropRow " & offsetDocPropRow & _
" : offsetDocIssueDetailsRow " & offsetDocIssueDetailsRow & _
" : offsetDocRefDetailsRow " & offsetDocRefDetailsRow & _
" : offsetDocIssuesRow " & offsetDocIssuesRow & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub WriteToIni(key As String, value As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteToIni"
If mIniFilePath = "" Then Exit Sub
Call WritePrivateProfileString("Analysis", key, value, mIniFilePath)
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : key " & key & " : value " & value & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub WriteToLog(key As String, value As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteToLog"
If mLogFilePath = "" Then Exit Sub
Dim sSection As String
sSection = getAppSpecificApplicationName
Call WritePrivateProfileString(sSection, key, value, mLogFilePath)
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : key " & key & " : value " & value & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub WriteDebug(value As String)
On Error Resume Next 'Ignore errors in our error writing routines - could get circular dependency otherwise
Static ErrCount As Long
If mLogFilePath = "" Then Exit Sub
Dim sSection As String
sSection = getAppSpecificApplicationName & "Debug"
If mDebugLevel > 0 Then
Call WritePrivateProfileString(sSection, "Doc" & mDocIndex & "_debug" & ErrCount, value, mLogFilePath)
ErrCount = ErrCount + 1
Else
Debug.Print
End If
End Sub
Sub WriteDebugLevelTwo(value As String)
On Error Resume Next 'Ignore errors in our error writing routines - could get circular dependency otherwise
Static ErrCountTwo As Long
If mLogFilePath = "" Then Exit Sub
Dim sSection As String
sSection = getAppSpecificApplicationName & "Debug"
If mDebugLevel > 1 Then
Call WritePrivateProfileString(sSection, "Doc" & mDocIndex & "_debug" & ErrCountTwo, "Level2: " & value, mLogFilePath)
ErrCountTwo = ErrCountTwo + 1
Else
Debug.Print
End If
End Sub
Public Function ProfileLoadDict(dict As Scripting.Dictionary, _
lpSectionName As String, _
inifile As String) As Long
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "ProfileLoadDict"
Dim success As Long
Dim c As Long
Dim nSize As Long
Dim KeyData As String
Dim lpKeyName As String
Dim ret As String
ret = Space$(2048)
nSize = Len(ret)
success = GetPrivateProfileString( _
lpSectionName, vbNullString, "", ret, nSize, inifile)
If success Then
ret = Left$(ret, success)
Do Until ret = ""
lpKeyName = StripNulls(ret)
KeyData = ProfileGetItem( _
lpSectionName, lpKeyName, "", inifile)
dict.Add lpKeyName, KeyData
Loop
End If
ProfileLoadDict = dict.count
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & _
" : dict.Count " & dict.count & _
" : lpSectionName " & lpSectionName & _
" : inifile " & inifile & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Private Function StripNulls(startStrg As String) As String
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "StripNulls"
Dim pos As Long
Dim item As String
pos = InStr(1, startStrg, Chr$(0))
If pos Then
item = Mid$(startStrg, 1, pos - 1)
startStrg = Mid$(startStrg, pos + 1, Len(startStrg))
StripNulls = item
End If
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : startStrg " & startStrg & " : " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Public Function ProfileGetItem(lpSectionName As String, _
lpKeyName As String, _
defaultValue As String, _
inifile As String) As String
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "ProfileGetItem"
Dim success As Long
Dim nSize As Long
Dim ret As String
ret = Space$(2048)
nSize = Len(ret)
success = GetPrivateProfileString(lpSectionName, _
lpKeyName, _
defaultValue, _
ret, _
nSize, _
inifile)
If success Then
ProfileGetItem = Left$(ret, success)
Else
ProfileGetItem = defaultValue
End If
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & _
" : lpSectionName " & lpSectionName & _
" : lpKeyName " & lpKeyName & _
" : defaultValue " & defaultValue & _
" : inifile " & inifile & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Public Function GetDefaultPassword() As String
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "GetDefaultPassword"
Static myPassword As String
If myPassword = "" Then
myPassword = ProfileGetItem("Analysis", CDEFAULT_PASSWORD, "", mIniFilePath)
End If
GetDefaultPassword = myPassword
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Public Function GetVersion() As String
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "GetVersion"
Static myVersion As String
If myVersion = "" Then
myVersion = ProfileGetItem("Analysis", CVERSION, "", mIniFilePath)
End If
GetVersion = myVersion
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Public Function GetTitle() As String
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "GetTitle"
Static myTitle As String
If myTitle = "" Then
myTitle = ProfileGetItem("Analysis", CTITLE, RID_STR_COMMON_ANALYSIS_STR, mIniFilePath)
End If
GetTitle = myTitle
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Sub SetPrepareToNone()
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetPrepareToNone"
Call WritePrivateProfileString("Analysis", CDOPREPARE, CStr(0), mIniFilePath)
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Function CheckForAbort() As Boolean
Dim currentFunctionName As String
Dim bAbort As Boolean
currentFunctionName = "CheckForAbort"
bAbort = False
On Error GoTo HandleErrors
bAbort = CBool(ProfileGetItem("Analysis", C_ABORT_ANALYSIS, "false", mIniFilePath))
'reset the flag
If (bAbort) Then Call WriteToIni(C_ABORT_ANALYSIS, "false")
FinalExit:
CheckForAbort = bAbort
Exit Function
HandleErrors:
WriteDebug currentFunctionName & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Function CheckDoPrepare() As Boolean
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "CheckDoPrepare"
Static bDoPrepare As Boolean
Static myDoPrepare As String
If myDoPrepare = "" Then
bDoPrepare = CBool(ProfileGetItem("Analysis", _
CDOPREPARE, "False", mIniFilePath))
myDoPrepare = "OK"
End If
CheckDoPrepare = bDoPrepare
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Function GetIssuesLimitInDays() As Long
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "GetIssuesLimitInDays"
Static issuesLimit As Long
Static myDoPrepare As String
If issuesLimit = 0 Then
issuesLimit = CLng(ProfileGetItem("Analysis", _
CISSUES_LIMIT, CMAX_LIMIT, mIniFilePath)) * CNUMDAYS_IN_MONTH
End If
GetIssuesLimitInDays = issuesLimit
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Public Sub AddIssueDetailsNote(myIssue As IssueInfo, noteNum As Long, noteStr As String, _
Optional preStr As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "AddIssueDetailsNote"
If IsMissing(preStr) Then
preStr = RID_STR_COMMON_NOTE_PRE
End If
myIssue.Attributes.Add preStr & "[" & noteNum & "]"
myIssue.Values.Add noteStr
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : noteNum " & noteNum & " : noteStr " & noteStr & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Public Sub SetupWizardVariables( _
fileList As String, storeToDir As String, resultsFile As String, _
logFile As String, resultsTemplate As String, bOverwriteFile As Boolean, _
bNewResultsFile As Boolean, statFileName As String, debugLevel As Long, _
outputType As String, singleFile As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetupWizardVariables"
If mIniFilePath = "" Then
mIniFilePath = GetAppDataFolder & "\Sun\AnalysisWizard\" & CWIZARD & ".ini"
End If
statFileName = ProfileGetItem("Analysis", CSTAT_FILE, "", mIniFilePath)
fileList = ProfileGetItem("Analysis", CFILE_LIST, "", mIniFilePath)
storeToDir = ProfileGetItem("Analysis", COUTPUT_DIR, "", mIniFilePath)
resultsFile = ProfileGetItem("Analysis", CRESULTS_FILE, "", mIniFilePath)
logFile = ProfileGetItem("Analysis", CLOG_FILE, "", mIniFilePath)
resultsTemplate = ProfileGetItem("Analysis", CRESULTS_TEMPLATE, "", mIniFilePath)
bOverwriteFile = IIf(ProfileGetItem("Analysis", CRESULTS_EXIST, COVERWRITE_FILE, mIniFilePath) = COVERWRITE_FILE, _
True, False)
bNewResultsFile = CBool(ProfileGetItem("Analysis", CNEW_RESULTS_FILE, "True", mIniFilePath))
debugLevel = CLng(ProfileGetItem("Analysis", CDEBUG_LEVEL, "1", mIniFilePath))
outputType = ProfileGetItem("Analysis", COUTPUT_TYPE, COUTPUT_TYPE_XLS, mIniFilePath)
singleFile = ProfileGetItem("Analysis", CSINGLE_FILE, "", mIniFilePath)
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & _
": mIniFilePath " & mIniFilePath & ": " & _
Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Public Sub SetupSearchTypes(searchTypes As Collection)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetupSearchTypes"
Dim bDocument As Boolean
Dim bTemplate As Boolean
bDocument = CBool(ProfileGetItem("Analysis", LCase("type" & getAppSpecificApplicationName & "doc"), "False", mIniFilePath))
bTemplate = CBool(ProfileGetItem("Analysis", LCase("type" & getAppSpecificApplicationName & "dot"), "False", mIniFilePath))
If bDocument = True Then searchTypes.Add "*" & getAppSpecificDocExt
If bTemplate = True Then searchTypes.Add "*" & getAppSpecificTemplateExt
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & ": searchTypes.Count " & searchTypes.count & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub WriteXMLHeader(out As TextStream)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteXMLHeader"
out.WriteLine "<?xml version=""1.0"" encoding=""ISO-8859-1""?>"
out.WriteLine "<!DOCTYPE results SYSTEM 'analysis.dtd'>"
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub WriteXMLResultsStartTag(out As TextStream)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteXMLResultsStartTag"
out.WriteLine "<results generated-by=""" & IIf(InDocPreparation, "documentanalysis_preparation", "documentanalysis") & """"
out.WriteLine " version=""" & GetVersion & """ timestamp=""" & Now & """"
out.WriteLine " type=""" & getAppSpecificApplicationName & """ >"
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub WriteXMLResultsEndTag(out As TextStream)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteXMLResultsEndTag"
out.WriteLine "</results>"
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub WriteXMLDocProperties(out As TextStream, aAnalysis As DocumentAnalysis)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteXMLDocProperties"
out.WriteLine "<document location=""" & EncodeXML(aAnalysis.name) & """"
out.WriteLine " application=""" & aAnalysis.Application & """"
out.WriteLine " issues-count=""" & (aAnalysis.IssuesCount) & """"
out.WriteLine " pages=""" & aAnalysis.PageCount & """"
out.WriteLine " created=""" & CheckDate(aAnalysis.Created) & """"
out.WriteLine " modified=""" & CheckDate(aAnalysis.Modified) & """"
out.WriteLine " accessed=""" & CheckDate(aAnalysis.Accessed) & """"
out.WriteLine " printed=""" & CheckDate(aAnalysis.Printed) & """"
out.WriteLine " last-save-by=""" & aAnalysis.SavedBy & """"
out.WriteLine " revision=""" & aAnalysis.Revision & """"
out.WriteLine " based-on-template=""" & EncodeXML(aAnalysis.Template) & """"
out.WriteLine ">"
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : path " & aAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub WriteXMLDocPropertiesEndTag(out As TextStream)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteXMLDocPropertiesEndTag"
out.WriteLine "</document>"
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub WriteXMLDocRefDetails(out As TextStream, aAnalysis As DocumentAnalysis)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteXMLDocRefDetails"
Dim myIssue As IssueInfo
'Output References for Docs with Macros
If aAnalysis.HasMacros And (aAnalysis.References.count > 0) Then
out.WriteLine "<references>"
For Each myIssue In aAnalysis.References
OutputXMLReferenceAttributes out, aAnalysis, myIssue
Next myIssue
out.WriteLine "</references>"
End If
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : path " & aAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub OutputXMLReferenceAttributes(out As TextStream, aAnalysis As DocumentAnalysis, myIssue As IssueInfo)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "OutputXMLReferenceAttributes"
Dim strAttributes As String
With myIssue
out.WriteLine "<reference"
strAttributes = .Values("Major") & "." & .Values("Minor")
strAttributes = IIf(strAttributes = "0.0" Or strAttributes = ".", .Values("Name"), _
.Values("Name") & " " & .Values("Major") & "." & .Values("Minor"))
out.WriteLine " name=""" & EncodeXML(strAttributes) & """"
If .Values("Type") = "Project" Then
strAttributes = "Project reference"
Else
strAttributes = IIf(.Values("Description") <> "", .Values("Description"), RID_STR_COMMON_NA)
End If
out.WriteLine " description=""" & EncodeXML(strAttributes) & """"
If .Values("IsBroken") <> RID_STR_COMMON_ATTRIBUTE_BROKEN Then
out.WriteLine " location=""" & .Values("File") & """"
End If
out.WriteLine " type=""" & .Values("Type") & """"
strAttributes = IIf(.Values("GUID") <> "", .Values("GUID"), RID_STR_COMMON_NA)
out.WriteLine " GUID=""" & strAttributes & """"
out.WriteLine " is-broken=""" & .Values("IsBroken") & """"
out.WriteLine " builtin=""" & .Values("BuiltIn") & """"
out.WriteLine " />"
End With
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : path " & aAnalysis.name & " : myIssue " & myIssue.IssueTypeXML & "_" & myIssue.SubTypeXML & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub WriteXMLDocIssueDetails(out As TextStream, aAnalysis As DocumentAnalysis)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteXMLDocIssueDetails"
Dim myIssue As IssueInfo
If aAnalysis.Issues.count = 0 Then Exit Sub
out.WriteLine "<issues>"
For Each myIssue In aAnalysis.Issues
OutputXMLCommonIssueDetails out, aAnalysis, myIssue
OutputXMLCommonIssueAttributes out, myIssue
out.WriteLine "</issue>"
Next myIssue
out.WriteLine "</issues>"
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : path " & aAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub OutputXMLCommonIssueDetails(out As TextStream, aAnalysis As DocumentAnalysis, myIssue As IssueInfo)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "OutputXMLCommonIssueDetails"
out.WriteLine "<issue category=""" & myIssue.IssueTypeXML & """"
out.WriteLine " type=""" & myIssue.SubTypeXML & """"
'NOTE: Dropping severity - now stored in results.xlt, do not want to open it to fetch this data
'out.WriteLine " severity=""" & IIf(CheckForMinorIssue(aAnalysis, myIssue), "Minor", "Major") & """"
out.WriteLine " prepared=""" & IIf((myIssue.Preparable), "True", "False") & """ >"
out.WriteLine "<location type=""" & myIssue.locationXML & """ >"
If myIssue.SubLocation <> "" Then
out.WriteLine "<property name=""sublocation"" value=""" & myIssue.SubLocation & """ />"
End If
If myIssue.Line <> -1 Then
out.WriteLine "<property name=""line"" value=""" & myIssue.Line & """ />"
End If
If myIssue.column <> "" Then
out.WriteLine "<property name=""column"" value=""" & myIssue.column & """ />"
End If
out.WriteLine "</location>"
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : path " & aAnalysis.name & " : myIssue " & myIssue.IssueTypeXML & "_" & myIssue.SubTypeXML & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub OutputXMLCommonIssueAttributes(out As TextStream, myIssue As IssueInfo)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "OutputXMLCommonIssueAttributes"
Dim index As Integer
Dim valStr As String
Dim attStr As String
If myIssue.Attributes.count = 0 Then Exit Sub
out.WriteLine "<details>"
For index = 1 To myIssue.Attributes.count
attStr = myIssue.Attributes(index)
If InStr(attStr, RID_STR_COMMON_NOTE_PRE & "[") = 1 Then
attStr = Right$(attStr, Len(attStr) - Len(RID_STR_COMMON_NOTE_PRE & "["))
attStr = Left$(attStr, Len(attStr) - 1)
out.WriteLine "<note index=""" & attStr & """ value=""" & EncodeXML(myIssue.Values(index)) & """ />"
Else
out.WriteLine "<property name=""" & EncodeXML(myIssue.Attributes(index)) & """ value=""" & EncodeXML(myIssue.Values(index)) & """ />"
End If
Next index
out.WriteLine "</details>"
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : myIssue " & myIssue.IssueTypeXML & "_" & myIssue.SubTypeXML & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub WriteXMLOutput(storeToDir As String, resultsFile As String, _
bOverwriteResultsFile As Boolean, bNewResultsFile As Boolean, AnalysedDocs As Collection, _
fso As Scripting.FileSystemObject)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WriteXMLOutput"
Dim xmlOutput As TextStream
Dim xmlOrigOutput As TextStream
Dim origOutput As String
Dim analysis As DocumentAnalysis
Dim outFilePath As String
outFilePath = storeToDir & "\" & fso.GetBaseName(resultsFile) & "_" & _
getAppSpecificApplicationName & ".xml"
Set xmlOutput = fso.CreateTextFile(outFilePath, True)
WriteXMLHeader xmlOutput
'Set xmlOrigOutput = fso.OpenTextFile(outFilePath, ForReading)
'Set xmlOutput = fso.OpenTextFile(outFilePath, ForWriting)
WriteXMLResultsStartTag xmlOutput
For Each analysis In AnalysedDocs
WriteXMLDocProperties xmlOutput, analysis
WriteXMLDocRefDetails xmlOutput, analysis
WriteXMLDocIssueDetails xmlOutput, analysis
WriteXMLDocPropertiesEndTag xmlOutput
Next analysis
WriteXMLResultsEndTag xmlOutput
FinalExit:
xmlOutput.Close
Set xmlOutput = Nothing
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : path " & outFilePath & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Private Function EncodeUrl(ByVal sUrl As String) As String
Const MAX_PATH As Long = 260
Const ERROR_SUCCESS As Long = 0
Const URL_DONT_SIMPLIFY As Long = &H8000000
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "EncodeUrl"
Dim sUrlEsc As String
Dim dwSize As Long
Dim dwFlags As Long
If Len(sUrl) > 0 Then
sUrlEsc = Space$(MAX_PATH)
dwSize = Len(sUrlEsc)
dwFlags = URL_DONT_SIMPLIFY
If UrlEscape(sUrl, _
sUrlEsc, _
dwSize, _
dwFlags) = ERROR_SUCCESS Then
EncodeUrl = Left$(sUrlEsc, dwSize)
End If 'If UrlEscape
End If 'If Len(sUrl) > 0
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : sUrl " & sUrl & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Private Function EncodeXML(Str As String) As String
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "EncodeXML"
Str = Replace(Str, "^", "^")
Str = Replace(Str, "&", "&")
Str = Replace(Str, "`", "'")
Str = Replace(Str, "{", "{")
Str = Replace(Str, "}", "}")
Str = Replace(Str, "|", "|")
Str = Replace(Str, "]", "]")
Str = Replace(Str, "[", "[")
Str = Replace(Str, """", """)
Str = Replace(Str, "<", "<")
Str = Replace(Str, ">", ">")
'str = Replace(str, "\", "\")
'str = Replace(str, "#", "#")
'str = Replace(str, "?", "?")
'str = Replace(str, "/", "/")
EncodeXML = Str
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : string " & Str & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Function ReplaceTopicTokens(sString As String, _
sToken As String, _
sReplacement As String) As String
On Error Resume Next
Dim p As Integer
Dim sTmp As String
sTmp = sString
Do
p = InStr(sTmp, sToken)
If p Then
sTmp = Left(sTmp, p - 1) + sReplacement + Mid(sTmp, p + Len(sToken))
End If
Loop While p > 0
ReplaceTopicTokens = sTmp
End Function
Function ReplaceTopic2Tokens(sString As String, _
sToken1 As String, _
sReplacement1 As String, _
sToken2 As String, _
sReplacement2 As String) As String
On Error Resume Next
ReplaceTopic2Tokens = _
ReplaceTopicTokens(ReplaceTopicTokens(sString, sToken1, sReplacement1), _
sToken2, sReplacement2)
End Function
'Language setting functions
Function GetResourceDataFileName(thisDir As String) As String
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "GetResourceDataFileName"
Dim fso As FileSystemObject
Set fso = New FileSystemObject
'A debug method - if a file called debug.dat exists load it.
If fso.FileExists(fso.GetAbsolutePathName(thisDir & "\debug.dat")) Then
GetResourceDataFileName = fso.GetAbsolutePathName(thisDir & "\debug.dat")
GoTo FinalExit
End If
Dim isoLangStr As String
Dim isoCountryStr As String
Dim langDir As String
langDir = thisDir & "\" & "lang"
Dim userLCID As Long
userLCID = GetUserDefaultLangID()
Dim sysLCID As Long
sysLCID = GetSystemDefaultLangID()
isoLangStr = GetUserLocaleInfo(userLCID, LOCALE_SISO639LANGNAME)
isoCountryStr = GetUserLocaleInfo(userLCID, LOCALE_SISO3166CTRYNAME)
'check for locale data in following order:
' user language
' isoLangStr & "_" & isoCountryStr & ".dat"
' isoLangStr & ".dat"
' system language
' isoLangStr & "_" & isoCountryStr & ".dat"
' isoLangStr & ".dat"
' "en_US" & ".dat"
If fso.FileExists(fso.GetAbsolutePathName(langDir & "\" & isoLangStr & "-" & isoCountryStr & ".dat")) Then
GetResourceDataFileName = fso.GetAbsolutePathName(langDir & "\" & isoLangStr & "-" & isoCountryStr & ".dat")
ElseIf fso.FileExists(fso.GetAbsolutePathName(langDir & "\" & isoLangStr & ".dat")) Then
GetResourceDataFileName = fso.GetAbsolutePathName(langDir & "\" & isoLangStr & ".dat")
Else
isoLangStr = GetUserLocaleInfo(sysLCID, LOCALE_SISO639LANGNAME)
isoCountryStr = GetUserLocaleInfo(sysLCID, LOCALE_SISO3166CTRYNAME)
If fso.FileExists(fso.GetAbsolutePathName(langDir & "\" & isoLangStr & "-" & isoCountryStr & ".dat")) Then
GetResourceDataFileName = fso.GetAbsolutePathName(langDir & "\" & isoLangStr & "-" & isoCountryStr & ".dat")
ElseIf fso.FileExists(fso.GetAbsolutePathName(langDir & "\" & isoLangStr & ".dat")) Then
GetResourceDataFileName = fso.GetAbsolutePathName(langDir & "\" & isoLangStr & ".dat")
Else
GetResourceDataFileName = fso.GetAbsolutePathName(langDir & "\" & "en-US.dat")
End If
End If
FinalExit:
Set fso = Nothing
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Public Function GetUserLocaleInfo(ByVal dwLocaleID As Long, ByVal dwLCType As Long) As String
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "GetUserLocaleInfo"
Dim sReturn As String
Dim r As Long
'call the function passing the Locale type
'variable to retrieve the required size of
'the string buffer needed
r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))
'if successful..
If r Then
'pad the buffer with spaces
sReturn = Space$(r)
'and call again passing the buffer
r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))
'if successful (r > 0)
If r Then
'r holds the size of the string
'including the terminating null
GetUserLocaleInfo = Left$(sReturn, r - 1)
End If
End If
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
' This function returns the Application Data Folder Path
Function GetAppDataFolder() As String
Dim idlstr As Long
Dim sPath As String
Dim IDL As ITEMIDLIST
Const NOERROR = 0
Const MAX_LENGTH = 260
Const CSIDL_APPDATA = &H1A
On Error GoTo Err_GetFolder
' Fill the idl structure with the specified folder item.
idlstr = SHGetSpecialFolderLocation(0, CSIDL_APPDATA, IDL)
If idlstr = NOERROR Then
' Get the path from the idl list, and return
' the folder with a slash at the end.
sPath = Space$(MAX_LENGTH)
idlstr = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath)
If idlstr Then
GetAppDataFolder = Left$(sPath, InStr(sPath, Chr$(0)) - 1)
End If
End If
Exit_GetFolder:
Exit Function
Err_GetFolder:
MsgBox "An Error was Encountered" & Chr(13) & Err.Description, _
vbCritical Or vbOKOnly
Resume Exit_GetFolder
End Function
Sub WriteToStatFile(statFileName As String, statValue As Integer, _
currDocument As String, fso As Scripting.FileSystemObject)
On Error Resume Next
Dim fileCont As TextStream
Set fileCont = fso.OpenTextFile(statFileName, ForWriting, True, TristateTrue)
If (statValue = C_STAT_STARTING) Then
fileCont.WriteLine ("analysing=" & currDocument)
ElseIf (statValue = C_STAT_DONE) Then
fileCont.WriteLine ("analysed=" & currDocument)
ElseIf (statValue = C_STAT_FINISHED) Then
fileCont.WriteLine ("finished")
End If
fileCont.Close
End Sub
' The function FindIndex looks for a document in the given document list
' starting at the position lastIndex in that list. If the document could
' not be found, the function starts searching from the beginning
Function FindIndex(myDocument As String, _
myDocList As Collection, _
lastIndex As Long) As Long
Dim lastEntry As Long
Dim curIndex As Long
Dim curEntry As String
Dim entryFound As Boolean
entryFound = False
lastEntry = myDocList.count
If (lastIndex > lastEntry) Then lastIndex = lastEntry
If (lastIndex > 1) Then
curIndex = lastIndex
Else
curIndex = 1
End If
While Not entryFound And curIndex <= lastEntry
curEntry = myDocList.item(curIndex)
If (curEntry = myDocument) Then
entryFound = True
Else
curIndex = curIndex + 1
End If
Wend
If (Not entryFound) Then
curIndex = 1
While Not entryFound And curIndex < lastIndex
curEntry = myDocList.item(curIndex)
If (curEntry = myDocument) Then
entryFound = True
Else
curIndex = curIndex + 1
End If
Wend
End If
If entryFound Then
FindIndex = curIndex
Else
FindIndex = 0
End If
End Function
' The sub GetIndexValues calulates the start index of the analysis and the index
' of the file after which the next intermediate reult will be written
Function GetIndexValues(startIndex As Long, nextCheck As Long, _
myFiles As Collection) As Boolean
Dim lastCheckpoint As String
Dim nextFile As String
Dim newResultsFile As Boolean
lastCheckpoint = ProfileGetItem(C_ANALYSIS, C_LAST_CHECKPOINT, "", mIniFilePath)
nextFile = ProfileGetItem(C_ANALYSIS, C_NEXT_FILE, "", mIniFilePath)
newResultsFile = True
If (nextFile = "") Then
' No Analysis done yet
startIndex = 1
nextCheck = C_MAX_CHECK
Else
If (lastCheckpoint = "") Then
startIndex = 1
Else
startIndex = FindIndex(lastCheckpoint, myFiles, 1) + 1
If (startIndex > 0) Then newResultsFile = False
End If
nextCheck = FindIndex(nextFile, myFiles, startIndex - 1)
If (nextCheck = 0) Then ' Next file not in file list, restarting
startIndex = 1
nextCheck = C_MAX_CHECK
newResultsFile = True
ElseIf (nextCheck < startIndex) Then 'we are done?
nextCheck = startIndex + C_MAX_CHECK
ElseIf (nextCheck = startIndex) Then 'skip this one
WriteToLog C_ERROR_HANDLING_DOC & nextCheck, nextFile
startIndex = startIndex + 1
nextCheck = startIndex + C_MAX_CHECK
Else 'last time an error occured with that file, write before analysing
nextCheck = nextCheck - 1
End If
End If
GetIndexValues = newResultsFile
End Function
Private Sub GetDocModificationDates(docCounts As DocModificationDates)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "GetDocModificationDates"
docCounts.lessThanThreemonths = CLng(ProfileGetItem("Analysis", C_DOCS_LESS_3_MONTH, "0", mIniFilePath))
docCounts.threeToSixmonths = CLng(ProfileGetItem("Analysis", C_DOCS_LESS_6_MONTH, "0", mIniFilePath))
docCounts.sixToTwelvemonths = CLng(ProfileGetItem("Analysis", C_DOCS_LESS_12_MONTH, "0", mIniFilePath))
docCounts.greaterThanOneYear = CLng(ProfileGetItem("Analysis", C_DOCS_MORE_12_MONTH, "0", mIniFilePath))
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
|