Skip to content

Commit b96664e

Browse files
ThunderFrameretailcoder
authored andcommitted
Adds Unit Test support for MS Project, adds basic bitmap copy of Code Explorer treeview (#1701)
* Adds RTF and XML Spreadsheet data formats Still need to RTF-escape content values Temporary Fix in InspectionResultBase, for instances of unsaved filename boom. * XML Spreadsheet builds from XMLWriter instead of StringBuilder Adds ColumnInfos helper classes, for specifying and formatting column titles, not yet fully implemented. * Improves Clipboard export formatter Adds a DocumentName property to QualifiedModuleName, adds DocumentName to column output. * adds notes and placeholder for Outllook's Application.Run alternative not implemented - need to write to events in the ThisOutlookSession before this will work. * Adds columns to inspection results, and adds column titles changes to Column alignment, font weights, colspans * improvements to InspectionResults Clipboard Refines DocumentName of QualifiedModule * Adds DisplayName and Title for Projects and Components ProjectDisplayName eg. `Book1` ProjectTitle eg. `VBA Project (Book1) ComponentDisplayName eg. `Home` ComponentTitle eg. `shtHome (Home)` * corrects ComponentTitle behaviour still needs testing across multiple hosts. * removes temporary comments * adds DisplayName to extra QualifiedModuleName constructor was out of Sync with Next, so had to add these fields to the newly discovered ctor. * Adds Unit Test support for Visio, clipboard formats for Test Explorer Adds Start and End Times for Unit Test results (only viewable in Clipboard exports) Title and Headings aren't yet localized. No plain-text clipboard export format yet * Adjusts treeview border to correct jagged edge of Code Explorer window sought and received @Hosch250 approval * Adds Copy button to Code Explorer, allows copy of *all* User Declarations WIP... * Fixes GetDisplayName Adds extra method for projects that have documents without a document-component (eg. PowerPoint) * Adds experimental Bitmap WPF copy element is clipped if there is overflow... See http://stackoverflow.com/questions/37572471/how-to-copy-a-frameworkelement-including-the-overflowed-content * Adds Unit Testing for MSProject Application.Run() does exist but doesn't seem to work, so using Application.Macro() instead. * Adds MS Project Application.Macro method
1 parent 1d5a7af commit b96664e

File tree

7 files changed

+53
-4
lines changed

7 files changed

+53
-4
lines changed

RetailCoder.VBE/Common/ClipboardWriter.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
using System.Text;
66
using System.Threading.Tasks;
77
using System.Windows;
8+
using System.Windows.Media.Imaging;
89

910
namespace Rubberduck.Common
1011
{
1112
public interface IClipboardWriter
1213
{
1314
void Write(string text);
15+
void AppendImage(BitmapSource image);
1416
void AppendString(string formatName, string data);
1517
void AppendStream(string formatName, MemoryStream stream);
1618
void Flush();
@@ -26,6 +28,16 @@ public void Write(string text)
2628
this.Flush();
2729
}
2830

31+
public void AppendImage(BitmapSource image)
32+
{
33+
if (_data == null)
34+
{
35+
_data = new DataObject();
36+
}
37+
_data.SetImage(image);
38+
}
39+
40+
2941
public void AppendString(string formatName, string data)
3042
{
3143
if (_data == null)

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using System.Collections.ObjectModel;
44
using System.Linq;
55
using System.Windows.Input;
6+
using System.Windows.Media;
7+
using System.Windows.Media.Imaging;
68
using Microsoft.Vbe.Interop;
79
using Rubberduck.Navigation.Folders;
810
using Rubberduck.Parsing.Annotations;

RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,8 @@
703703
</Button>
704704

705705
<Separator />
706-
707-
<Button Command="{Binding CopyResultsCommand}">
706+
707+
<Button Command="{Binding CopyResultsCommand}" CommandParameter="{Binding ElementName=ProjectTree}">
708708
<Image Height="16" Source="../../Resources/document-copy.png" />
709709
<Button.ToolTip>
710710
<TextBlock Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_CopyToolTip}" />
@@ -714,11 +714,14 @@
714714
</ToolBar>
715715
</ToolBarTray>
716716

717-
<TreeView Grid.Row="1" Background="White"
717+
<TreeView x:Name="ProjectTree"
718+
Grid.Row="1"
719+
Background="White"
718720
ItemContainerStyle="{StaticResource ShinyTreeView}"
719721
HorizontalContentAlignment="Stretch"
720722
MouseDoubleClick="TreeView_OnMouseDoubleClick"
721-
Style="{StaticResource CodeExplorerTreeViewStyle}" BorderThickness="0,1">
723+
Style="{StaticResource CodeExplorerTreeViewStyle}" BorderThickness="0,1"
724+
VirtualizingPanel.IsVirtualizing="False">
722725
<i:Interaction.Behaviors>
723726
<controls:BindableSelectedItemBehavior SelectedItem="{Binding SelectedItem, Mode=TwoWay}" />
724727
</i:Interaction.Behaviors>

Rubberduck.VBEEditor/Extensions/VbeExtensions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public static IHostApplication HostApplication(this VBE vbe)
6666
return new PowerPointApp();
6767
case "Microsoft Outlook":
6868
return new OutlookApp();
69+
case "Microsoft Project":
70+
return new ProjectApp();
6971
case "Microsoft Publisher":
7072
return new PublisherApp();
7173
case "Microsoft Visio":
@@ -94,6 +96,8 @@ public static IHostApplication HostApplication(this VBE vbe)
9496
return new PowerPointApp();
9597
case "Outlook":
9698
return new OutlookApp();
99+
case "MSProject":
100+
return new ProjectApp();
97101
case "Publisher":
98102
return new PublisherApp();
99103
case "Visio":

Rubberduck.VBEEditor/Rubberduck.VBEditor.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
<EmbedInteropTypes>True</EmbedInteropTypes>
4343
<HintPath>..\libs\Microsoft.Office.Interop.Excel.dll</HintPath>
4444
</Reference>
45+
<Reference Include="Microsoft.Office.Interop.MSProject, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
46+
<SpecificVersion>False</SpecificVersion>
47+
<EmbedInteropTypes>True</EmbedInteropTypes>
48+
<HintPath>..\libs\Microsoft.Office.Interop.MSProject.dll</HintPath>
49+
</Reference>
4550
<Reference Include="Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
4651
<SpecificVersion>False</SpecificVersion>
4752
<EmbedInteropTypes>True</EmbedInteropTypes>
@@ -114,6 +119,7 @@
114119
</Compile>
115120
<Compile Include="VBEHost\AccessApp.cs" />
116121
<Compile Include="VBEHost\CorelDRAWApp.cs" />
122+
<Compile Include="VBEHost\ProjectApp.cs" />
117123
<Compile Include="VBEHost\ExcelApp.cs" />
118124
<Compile Include="VBEHost\FallbackApp.cs" />
119125
<Compile Include="VBEHost\HostApplicationBase.cs" />
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Microsoft.Vbe.Interop;
2+
3+
namespace Rubberduck.VBEditor.VBEHost
4+
{
5+
public class ProjectApp : HostApplicationBase<Microsoft.Office.Interop.MSProject.Application>
6+
{
7+
public ProjectApp() : base("MSProject") { }
8+
public ProjectApp(VBE vbe) : base(vbe, "MSProject") { }
9+
10+
public override void Run(QualifiedMemberName qualifiedMemberName)
11+
{
12+
var call = GenerateMethodCall(qualifiedMemberName);
13+
Application.Macro(call);
14+
}
15+
16+
protected virtual string GenerateMethodCall(QualifiedMemberName qualifiedMemberName)
17+
{
18+
var moduleName = qualifiedMemberName.QualifiedModuleName.Component.Name;
19+
return string.Concat(moduleName, ".", qualifiedMemberName.MemberName);
20+
}
21+
}
22+
}
763 KB
Binary file not shown.

0 commit comments

Comments
 (0)