@@ -32,14 +32,8 @@ public string GetUserFormControlType(string projectName, string userFormName, st
32
32
=> VBETypeLibsAPI . GetUserFormControlType ( _ide , projectName , userFormName , controlName ) ;
33
33
public string GetDocumentClassControlType ( string projectName , string documentClassName , string controlName )
34
34
=> VBETypeLibsAPI . GetDocumentClassControlType ( _ide , projectName , documentClassName , controlName ) ;
35
- public bool IsExcelWorksheet ( string projectName , string className )
36
- => VBETypeLibsAPI . IsExcelWorksheet ( _ide , projectName , className ) ;
37
- public bool IsExcelWorkbook ( string projectName , string className )
38
- => VBETypeLibsAPI . IsExcelWorkbook ( _ide , projectName , className ) ;
39
- public bool IsAccessForm ( string projectName , string className )
40
- => VBETypeLibsAPI . IsAccessForm ( _ide , projectName , className ) ;
41
- public bool IsAccessReport ( string projectName , string className )
42
- => VBETypeLibsAPI . IsAccessReport ( _ide , projectName , className ) ;
35
+ public DocClassType DetermineDocumentClassType ( string projectName , string className )
36
+ => VBETypeLibsAPI . DetermineDocumentClassType ( _ide , projectName , className ) ;
43
37
public string DocumentAll ( )
44
38
=> VBETypeLibsAPI . DocumentAll ( _ide ) ;
45
39
}
@@ -391,209 +385,63 @@ public static void SetProjectConditionalCompilationArgs(TypeLibWrapper projectTy
391
385
}
392
386
393
387
/// <summary>
394
- /// Determines whether the specified document class is an Excel Workbook
388
+ /// Determines whether the specified document class is a known document class type (e.g. Excel._Workbook, Access._Form)
395
389
/// </summary>
396
390
/// <param name="ide">Safe-com wrapper representing the VBE</param>
397
391
/// <param name="projectName">VBA Project name, as declared in the VBE</param>
398
- /// <param name="className">Document class name, as declared in the VBA project</param>
399
- /// <returns>bool indicating whether the class is an Excel Workbook</returns>
400
- public static bool IsExcelWorkbook ( IVBE ide , string projectName , string className )
401
- {
402
- using ( var typeLibs = new VBETypeLibsAccessor ( ide ) )
403
- {
404
- return IsExcelWorkbook ( typeLibs . Get ( projectName ) , className ) ;
405
- }
406
- }
407
-
408
- /// <summary>
409
- /// Determines whether the specified document class is an Excel Workbook
410
- /// </summary>
411
- /// <param name="project">Safe-com wrapper representing the VBA project</param>
412
- /// <param name="className">Document class name, as declared in the VBA project</param>
413
- /// <returns>bool indicating whether the class is an Excel Workbook</returns>
414
- public static bool IsExcelWorkbook ( IVBProject project , string className )
415
- {
416
- using ( var typeLib = TypeLibWrapper . FromVBProject ( project ) )
417
- {
418
- return IsExcelWorkbook ( typeLib , className ) ;
419
- }
420
- }
421
-
422
- /// <summary>
423
- /// Determines whether the specified document class is an Excel Workbook
424
- /// </summary>
425
- /// <param name="project">Safe-com wrapper representing the VBA component</param>
426
- /// <returns>bool indicating whether the class is an Excel Workbook</returns>
427
- public static bool IsExcelWorkbook ( IVBComponent component )
428
- {
429
- return IsExcelWorkbook ( component . ParentProject , component . Name ) ;
430
- }
431
-
432
- /// <summary>
433
- /// Determines whether the specified document class is an Excel Workbook
434
- /// </summary>
435
- /// <param name="projectTypeLib">Low-level ITypeLib wrapper representing the VBA project</param>
436
- /// <param name="className">Document class name, as declared in the VBA project</param>
437
- /// <returns>bool indicating whether the class is an Excel Workbook</returns>
438
- public static bool IsExcelWorkbook ( TypeLibWrapper projectTypeLib , string className )
439
- {
440
- return DoesClassImplementInterface ( projectTypeLib , className , "Excel._Workbook" ) ;
441
- }
442
-
443
- /// <summary>
444
- /// Determines whether the specified document class is an Excel Worksheet
445
- /// </summary>
446
- /// <param name="ide">Safe-com wrapper representing the VBE</param>
447
- /// <param name="projectName">VBA Project name, as declared in the VBE</param>
448
- /// <param name="className">Document class name, as declared in the VBA project</param>
449
- /// <returns>bool indicating whether the class is an Excel Worksheet</returns>
450
- public static bool IsExcelWorksheet ( IVBE ide , string projectName , string className )
451
- {
452
- using ( var typeLibs = new VBETypeLibsAccessor ( ide ) )
453
- {
454
- return IsExcelWorksheet ( typeLibs . Get ( projectName ) , className ) ;
455
- }
456
- }
457
-
458
- /// <summary>
459
- /// Determines whether the specified document class is an Excel Worksheet
460
- /// </summary>
461
- /// <param name="project">Safe-com wrapper representing the VBA project</param>
462
- /// <param name="className">Document class name, as declared in the VBA project</param>
463
- /// <returns>bool indicating whether the class is an Excel Worksheet</returns>
464
- public static bool IsExcelWorksheet ( IVBProject project , string className )
465
- {
466
- using ( var typeLib = TypeLibWrapper . FromVBProject ( project ) )
467
- {
468
- return IsExcelWorksheet ( typeLib , className ) ;
469
- }
470
- }
471
-
472
- /// <summary>
473
- /// Determines whether the specified document class is an Excel Worksheet
474
- /// </summary>
475
- /// <param name="project">Safe-com wrapper representing the VBA component</param>
476
- /// <returns>bool indicating whether the class is an Excel Worksheet</returns>
477
- public static bool IsExcelWorksheet ( IVBComponent component )
478
- {
479
- return IsExcelWorksheet ( component . ParentProject , component . Name ) ;
480
- }
481
-
482
- /// <summary>
483
- /// Determines whether the specified document class is an Excel Worksheet
484
- /// </summary>
485
- /// <param name="projectTypeLib">Low-level ITypeLib wrapper representing the VBA project</param>
486
- /// <param name="className">VBA Document class name, as declared in the VBA project</param>
487
- /// <returns>bool indicating whether the class is an Excel Worksheet</returns>
488
- public static bool IsExcelWorksheet ( TypeLibWrapper projectTypeLib , string className )
489
- {
490
- return DoesClassImplementInterface ( projectTypeLib , className , "Excel._Worksheet" ) ;
491
- }
492
-
493
- /// <summary>
494
- /// Determines whether the specified document class is an Excel Workbook
495
- /// </summary>
496
- /// <param name="ide">Safe-com wrapper representing the VBE</param>
497
- /// <param name="projectName">VBA Project name, as declared in the VBE</param>
498
- /// <param name="className">Document class name, as declared in the VBA project</param>
499
- /// <returns>bool indicating whether the class is an Access Form</returns>
500
- public static bool IsAccessForm ( IVBE ide , string projectName , string className )
392
+ /// <param name="className">The name of the class document, as defined in the VBA project</param>
393
+ /// <returns>DocClassType indicating the type of the document class module, or DocType.Unrecognized</returns>
394
+ public static DocClassType DetermineDocumentClassType ( IVBE ide , string projectName , string className )
501
395
{
502
396
using ( var typeLibs = new VBETypeLibsAccessor ( ide ) )
503
397
{
504
- return IsAccessForm ( typeLibs . Get ( projectName ) , className ) ;
505
- }
506
- }
507
-
508
- /// <summary>
509
- /// Determines whether the specified document class is an Excel Workbook
510
- /// </summary>
511
- /// <param name="project">Safe-com wrapper representing the VBA project</param>
512
- /// <param name="className">Document class name, as declared in the VBA project</param>
513
- /// <returns>bool indicating whether the class is an Access Form</returns>
514
- public static bool IsAccessForm ( IVBProject project , string className )
515
- {
516
- using ( var typeLib = TypeLibWrapper . FromVBProject ( project ) )
517
- {
518
- return IsAccessForm ( typeLib , className ) ;
398
+ return DetermineDocumentClassType ( typeLibs . Get ( projectName ) , className ) ;
519
399
}
520
400
}
521
401
522
402
/// <summary>
523
- /// Determines whether the specified document class is an Excel Workbook
524
- /// </summary>
525
- /// <param name="project">Safe-com wrapper representing the VBA component</param>
526
- /// <returns>bool indicating whether the class is an Access Form</returns>
527
- public static bool IsAccessForm ( IVBComponent component )
528
- {
529
- return IsAccessForm ( component . ParentProject , component . Name ) ;
530
- }
531
-
532
- /// <summary>
533
- /// Determines whether the specified document class is an Excel Workbook
403
+ /// Determines whether the specified document class is a known document class type (e.g. Excel._Workbook, Access._Form)
534
404
/// </summary>
535
405
/// <param name="projectTypeLib">Low-level ITypeLib wrapper representing the VBA project</param>
536
- /// <param name="className">Document class name , as declared in the VBA project</param>
537
- /// <returns>bool indicating whether the class is an Access Form </returns>
538
- public static bool IsAccessForm ( TypeLibWrapper projectTypeLib , string className )
406
+ /// <param name="className">The name of the class document , as defined in the VBA project</param>
407
+ /// <returns>DocClassType indicating the type of the document class module, or DocType.Unrecognized </returns>
408
+ public static DocClassType DetermineDocumentClassType ( TypeLibWrapper projectTypeLib , string className )
539
409
{
540
- // The interface used by an Access form depends on the version of Access hosting the form
541
- // so we have to check for the current known interface prog-ids
542
- return DoesClassImplementInterface ( projectTypeLib , className ,
543
- new string [ ] { "Access._Form" , "Access._Form2" , "Access._Form3" } , out int matchIndex ) ;
410
+ return DetermineDocumentClassType ( projectTypeLib . TypeInfos . Get ( className ) ) ;
544
411
}
545
412
546
413
/// <summary>
547
- /// Determines whether the specified document class is an Excel Workbook
548
- /// </summary>
549
- /// <param name="ide">Safe-com wrapper representing the VBE</param>
550
- /// <param name="projectName">VBA Project name, as declared in the VBE</param>
551
- /// <param name="className">Document class name, as declared in the VBA project</param>
552
- /// <returns>bool indicating whether the class is an Access Form</returns>
553
- public static bool IsAccessReport ( IVBE ide , string projectName , string className )
554
- {
555
- using ( var typeLibs = new VBETypeLibsAccessor ( ide ) )
556
- {
557
- return IsAccessReport ( typeLibs . Get ( projectName ) , className ) ;
558
- }
559
- }
560
-
561
- /// <summary>
562
- /// Determines whether the specified document class is an Excel Workbook
414
+ /// Determines whether the specified document class is a known document class type (e.g. Excel._Workbook, Access._Form)
563
415
/// </summary>
564
416
/// <param name="project">Safe-com wrapper representing the VBA project</param>
565
- /// <param name="className">Document class name , as declared in the VBA project</param>
566
- /// <returns>bool indicating whether the class is an Access Form </returns>
567
- public static bool IsAccessReport ( IVBProject project , string className )
417
+ /// <param name="className">The name of the class document , as defined in the VBA project</param>
418
+ /// <returns>DocClassType indicating the type of the document class module, or DocType.Unrecognized </returns>
419
+ public static DocClassType DetermineDocumentClassType ( IVBProject project , string className )
568
420
{
569
421
using ( var typeLib = TypeLibWrapper . FromVBProject ( project ) )
570
422
{
571
- return IsAccessReport ( typeLib , className ) ;
423
+ return DetermineDocumentClassType ( typeLib . TypeInfos . Get ( className ) ) ;
572
424
}
573
425
}
574
426
575
427
/// <summary>
576
- /// Determines whether the specified document class is an Excel Workbook
428
+ /// Determines whether the specified document class is a known document class type (e.g. Excel._Workbook, Access._Form)
577
429
/// </summary>
578
430
/// <param name="project">Safe-com wrapper representing the VBA component</param>
579
- /// <returns>bool indicating whether the class is an Access Form </returns>
580
- public static bool IsAccessReport ( IVBComponent component )
431
+ /// <returns>DocClassType indicating the type of the document class module, or DocType.Unrecognized </returns>
432
+ public static DocClassType DetermineDocumentClassType ( IVBComponent component )
581
433
{
582
- return IsAccessReport ( component . ParentProject , component . Name ) ;
434
+ return DetermineDocumentClassType ( component . ParentProject , component . Name ) ;
583
435
}
584
436
585
437
/// <summary>
586
- /// Determines whether the specified document class is an Excel Workbook
438
+ /// Determines whether the specified document class is a known document class type (e.g. Excel._Workbook, Access._Form)
587
439
/// </summary>
588
- /// <param name="projectTypeLib">Low-level ITypeLib wrapper representing the VBA project</param>
589
- /// <param name="className">Document class name, as declared in the VBA project</param>
590
- /// <returns>bool indicating whether the class is an Access Form</returns>
591
- public static bool IsAccessReport ( TypeLibWrapper projectTypeLib , string className )
440
+ /// <param name="classTypeInfo">Low-level ITypeInfo wrapper representing the VBA project</param>
441
+ /// <returns>DocClassType indicating the type of the document class module, or DocType.Unrecognized</returns>
442
+ public static DocClassType DetermineDocumentClassType ( TypeInfoWrapper classTypeInfo )
592
443
{
593
- // The interface used by an Access form depends on the version of Access hosting the form
594
- // so we have to check for the current known interface prog-ids
595
- return DoesClassImplementInterface ( projectTypeLib , className ,
596
- new string [ ] { "Access._Report" , "Access._Report2" , "Access._Report3" } , out int matchIndex ) ;
444
+ return classTypeInfo . DetermineDocumentClassType ( ) ;
597
445
}
598
446
599
447
/// <summary>
0 commit comments