Skip to content

Commit efebe3c

Browse files
committed
Merge pull request #964 from ThunderFrame/next
Adds CorelDRAW
2 parents 8ba01d0 + dec0325 commit efebe3c

File tree

10 files changed

+80
-9
lines changed

10 files changed

+80
-9
lines changed

RetailCoder.VBE/UnitTesting/ProjectTestExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public static void RunMethodsWithAttribute<TAttribute>(this VBComponent componen
3636

3737
public static IEnumerable<TestMethod> TestMethods(this VBProject project)
3838
{
39-
var hostApp = project.VBE.HostApplication();
4039

4140
var result = project.VBComponents
4241
.Cast<VBComponent>()
@@ -50,7 +49,6 @@ public static IEnumerable<TestMethod> TestMethods(this VBProject project)
5049

5150
public static IEnumerable<TestMethod> TestMethods(this VBComponent component)
5251
{
53-
var hostApp = component.VBE.HostApplication();
5452

5553
if (component.Type == vbext_ComponentType.vbext_ct_StdModule
5654
&& component.CodeModule.HasAttribute<TestModuleAttribute>())

Rubberduck.Parsing/VBA/RubberduckParser.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ private void ParseParallel()
106106
try
107107
{
108108
var components = _vbe.VBProjects.Cast<VBProject>()
109+
.Where(project => project.Protection == vbext_ProjectProtection.vbext_pp_none)
109110
.SelectMany(project => project.VBComponents.Cast<VBComponent>())
110111
.ToList();
111112

Rubberduck.VBEEditor/Extensions/VbeExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ public static IHostApplication HostApplication(this VBE vbe)
6262
switch (reference.Name)
6363
{
6464
case "Excel":
65-
return new ExcelApp();
65+
return new ExcelApp(vbe);
6666
case "Access":
6767
return new AccessApp();
6868
case "Word":
69-
return new WordApp();
69+
return new WordApp(vbe);
7070
case "PowerPoint":
7171
return new PowerPointApp();
7272
case "Outlook":
@@ -75,6 +75,8 @@ public static IHostApplication HostApplication(this VBE vbe)
7575
return new PublisherApp();
7676
case "AutoCAD":
7777
return new AutoCADApp();
78+
case "CorelDRAW":
79+
return new CorelDRAWApp(vbe);
7880
}
7981
}
8082

Rubberduck.VBEEditor/Rubberduck.VBEditor.csproj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,18 @@
5555
<HintPath>..\libs\Microsoft.Office.Interop.Publisher.dll</HintPath>
5656
<EmbedInteropTypes>True</EmbedInteropTypes>
5757
</Reference>
58-
<Reference Include="Autodesk.AutoCAD.Interop">
58+
<Reference Include="Autodesk.AutoCAD.Interop">
5959
<HintPath>..\libs\Autodesk.AutoCAD.Interop.dll</HintPath>
6060
<EmbedInteropTypes>True</EmbedInteropTypes>
6161
</Reference>
62-
<Reference Include="Autodesk.AutoCAD.Interop.Common">
62+
<Reference Include="Autodesk.AutoCAD.Interop.Common">
6363
<HintPath>..\libs\Autodesk.AutoCAD.Interop.Common.dll</HintPath>
6464
<EmbedInteropTypes>True</EmbedInteropTypes>
6565
</Reference>
66+
<Reference Include="Corel.GraphicsSuite.Interop.CorelDRAW">
67+
<HintPath>..\libs\Corel.GraphicsSuite.Interop.CorelDRAW.dll</HintPath>
68+
<EmbedInteropTypes>True</EmbedInteropTypes>
69+
</Reference>
6670
<Reference Include="Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
6771
<SpecificVersion>False</SpecificVersion>
6872
<EmbedInteropTypes>True</EmbedInteropTypes>
@@ -95,14 +99,15 @@
9599
<Compile Include="Extensions\VBComponentsExtensions.cs" />
96100
<Compile Include="Extensions\VbeExtensions.cs" />
97101
<Compile Include="VBEHost\AccessApp.cs" />
102+
<Compile Include="VBEHost\CorelDRAWApp.cs" />
98103
<Compile Include="VBEHost\ExcelApp.cs" />
99104
<Compile Include="VBEHost\HostApplicationBase.cs" />
100105
<Compile Include="VBEHost\IHostApplication.cs" />
101106
<Compile Include="VBEHost\OutlookApp.cs" />
102107
<Compile Include="VBEHost\PowerPointApp.cs" />
103108
<Compile Include="VBEHost\PublisherApp.cs" />
104109
<Compile Include="VBEHost\WordApp.cs" />
105-
<Compile Include="VBEHost\AutoCADApp.cs" />
110+
<Compile Include="VBEHost\AutoCADApp.cs" />
106111
<Compile Include="Extensions\VbProjectExtensions.cs" />
107112
<Compile Include="Properties\AssemblyInfo.cs" />
108113
<Compile Include="Extensions\WindowExtensions.cs" />
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Corel.GraphicsSuite.Interop.CorelDRAW;
2+
using Microsoft.Vbe.Interop;
3+
4+
namespace Rubberduck.VBEditor.VBEHost
5+
{
6+
public class CorelDRAWApp : HostApplicationBase<Corel.GraphicsSuite.Interop.CorelDRAW.Application>
7+
{
8+
public CorelDRAWApp() : base("CorelDRAW") { }
9+
public CorelDRAWApp(VBE vbe) : base(vbe, "CorelDRAW") { }
10+
11+
//Function RunMacro(ModuleName As String, MacroName As String, Parameter() As Variant) As Variant
12+
//Where ModuleName appears to mean ProjectName, and MacroName has to be provided as "ModuleName.ProcName"
13+
14+
//TODO:RunMacro can only execute methods in stand-alone projects (not document hosted projects)
15+
//TODO:Can only get a CorelDraw application if at least one document is open in CorelDraw.
16+
17+
public override void Run(QualifiedMemberName qualifiedMemberName)
18+
{
19+
var projectName = qualifiedMemberName.QualifiedModuleName.ProjectName;
20+
var memberName = qualifiedMemberName.QualifiedModuleName.ComponentName + "." + qualifiedMemberName.MemberName;
21+
22+
if (Application != null)
23+
{
24+
Application.GMSManager.RunMacro(projectName, memberName, new object[] {});
25+
}
26+
}
27+
}
28+
}

Rubberduck.VBEEditor/VBEHost/ExcelApp.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
using System.Reflection;
22
using Microsoft.Office.Interop.Excel;
3+
using Microsoft.Vbe.Interop;
34

45
namespace Rubberduck.VBEditor.VBEHost
56
{
6-
public class ExcelApp : HostApplicationBase<Application>
7+
public class ExcelApp : HostApplicationBase<Microsoft.Office.Interop.Excel.Application>
78
{
89
public ExcelApp() : base("Excel") { }
10+
public ExcelApp(VBE vbe) : base(vbe, "Excel") { }
911

1012
public override void Run(QualifiedMemberName qualifiedMemberName)
1113
{

Rubberduck.VBEEditor/VBEHost/HostApplicationBase.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Diagnostics;
33
using System.Runtime.InteropServices;
4+
using Microsoft.Vbe.Interop;
5+
using System.Linq;
46

57
namespace Rubberduck.VBEditor.VBEHost
68
{
@@ -24,6 +26,36 @@ protected HostApplicationBase(string applicationName)
2426
}
2527
}
2628

29+
protected HostApplicationBase(VBE vbe, string applicationName)
30+
{
31+
_applicationName = applicationName;
32+
33+
try
34+
{
35+
var appProperty = vbe.VBProjects
36+
.Cast<VBProject>()
37+
.Where(project => project.Protection == vbext_ProjectProtection.vbext_pp_none)
38+
.SelectMany(project => project.VBComponents.Cast<VBComponent>())
39+
.Where(component => component.Type == vbext_ComponentType.vbext_ct_Document
40+
&& component.Properties.Count > 1)
41+
.SelectMany(component => component.Properties.OfType<Property>())
42+
.FirstOrDefault(property => property.Name == "Application");
43+
if (appProperty != null)
44+
{
45+
Application = (TApplication)appProperty.Object;
46+
}
47+
else
48+
{
49+
Application = (TApplication)Marshal.GetActiveObject(applicationName + ".Application");
50+
}
51+
52+
}
53+
catch (COMException)
54+
{
55+
Application = null; // unit tests don't need it anyway.
56+
}
57+
}
58+
2759
~HostApplicationBase()
2860
{
2961
Dispose(false);

Rubberduck.VBEEditor/VBEHost/WordApp.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using Microsoft.Office.Interop.Word;
2+
using Microsoft.Vbe.Interop;
23

34
namespace Rubberduck.VBEditor.VBEHost
45
{
5-
public class WordApp : HostApplicationBase<Application>
6+
public class WordApp : HostApplicationBase<Microsoft.Office.Interop.Word.Application>
67
{
78
public WordApp() : base("Word") { }
9+
public WordApp(VBE vbe) : base(vbe, "Word") { }
810

911
public override void Run(QualifiedMemberName qualifiedMemberName)
1012
{

Rubberduck.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1919
appveyor.yml = appveyor.yml
2020
libs\Autodesk.AutoCAD.Interop.Common.dll = libs\Autodesk.AutoCAD.Interop.Common.dll
2121
libs\Autodesk.AutoCAD.Interop.dll = libs\Autodesk.AutoCAD.Interop.dll
22+
libs\Corel.GraphicsSuite.Interop.CorelDRAW.dll = libs\Corel.GraphicsSuite.Interop.CorelDRAW.dll
2223
libs\Interop.VisioViewer.dll = libs\Interop.VisioViewer.dll
2324
libs\Microsoft.Office.Interop.Access.dll = libs\Microsoft.Office.Interop.Access.dll
2425
libs\Microsoft.Office.Interop.Excel.dll = libs\Microsoft.Office.Interop.Excel.dll
1.09 MB
Binary file not shown.

0 commit comments

Comments
 (0)