Skip to content

Commit 5f5cac9

Browse files
authored
Implement Presentation.AutoSaveOn property in PowerPointApi (#444)
Backports the new `Presentation.AutoSaveOn` property from PR #439 to release v1.9.8 branch
2 parents fefd4d3 + 0c2e33a commit 5f5cac9

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed

Source/NetOffice.Tests/NetOffice.Tests.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,12 @@
4242
<EmbeddedResource Include="Data\SampleImage.png" />
4343
<EmbeddedResource Include="Data\SampleText.txt" />
4444
</ItemGroup>
45+
<ItemGroup>
46+
<Folder Include="PowerPointApi\Docs\" />
47+
</ItemGroup>
48+
<ItemGroup>
49+
<None Update="PowerPointApi\Docs\AutoSaveOn_PresentationSavedLocally_FeatureAutoSaveIsOff.pptx">
50+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
51+
</None>
52+
</ItemGroup>
4553
</Project>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
using System;
2+
using NUnit.Framework;
3+
using NetOffice.PowerPointApi;
4+
using System.IO;
5+
6+
namespace NetOffice.Tests.PowerPointApi
7+
{
8+
[TestFixture]
9+
[Category("IntegrationTests")]
10+
[Category("IntegrationTests_PowerPoint")]
11+
public class PresentationTests
12+
{
13+
public Application PowerPointApp { get; set; }
14+
public Documents Docs { get; set; }
15+
16+
[SetUp]
17+
public void SetUp()
18+
{
19+
this.PowerPointApp = new Application();
20+
this.Docs = new Documents(TestContext.CurrentContext);
21+
}
22+
23+
[TearDown]
24+
public void TearDown()
25+
{
26+
this.PowerPointApp?.Quit();
27+
this.PowerPointApp?.Dispose();
28+
}
29+
30+
[Test]
31+
public void AutoSaveOn_PresentationSavedLocally_FeatureAutoSaveIsOff_ReturnsFalse()
32+
{
33+
// Arrange
34+
var presentation = PowerPointApp.Presentations.Open(this.Docs.AutoSaveOn_PresentationSavedLocally_FeatureAutoSaveIsOff, false);
35+
36+
// Act
37+
var actualValue = presentation.AutoSaveOn;
38+
39+
// Assert
40+
Assert.IsFalse(actualValue);
41+
42+
// Cleanup
43+
presentation.Close();
44+
}
45+
46+
[Test]
47+
public void AutoSaveOn_PresentationSavedInOneDrive_FeatureAutoSaveIsOn_ReturnsTrue()
48+
{
49+
// Arrange
50+
var presentation = PowerPointApp.Presentations.Open(this.Docs.AutoSaveOn_PresentationSavedInOneDrive_FeatureAutoSaveIsOn, false);
51+
52+
// Act
53+
var actualValue = presentation.AutoSaveOn;
54+
55+
// Assert
56+
Assert.IsTrue(actualValue);
57+
58+
// Cleanup
59+
presentation.Close();
60+
}
61+
62+
public class Documents
63+
{
64+
public string AutoSaveOn_PresentationSavedLocally_FeatureAutoSaveIsOff { get; set; }
65+
public string AutoSaveOn_PresentationSavedInOneDrive_FeatureAutoSaveIsOn { get; set; }
66+
67+
public Documents(TestContext context)
68+
{
69+
this.AutoSaveOn_PresentationSavedLocally_FeatureAutoSaveIsOff = Path.Combine(context.TestDirectory, @"PowerPointApi\Docs", "AutoSaveOn_PresentationSavedLocally_FeatureAutoSaveIsOff.pptx");
70+
71+
// Public link: https://1drv.ms/p/c/8cd14a64b99957bc/EVX1bUNmBtxDvfvg-aNQjKkBX35RJ3BJ6_2ey2Ox5gnIfA?e=DVyExX
72+
this.AutoSaveOn_PresentationSavedInOneDrive_FeatureAutoSaveIsOn = @"https://d.docs.live.net/8CD14A64B99957BC/Developer/NetOfficeFw/PowerPoint/AutoSaveOn_PresentationSavedInOneDrive_FeatureAutoSaveIsOn.pptx";
73+
}
74+
}
75+
}
76+
}

Source/PowerPoint/DispatchInterfaces/_Presentation.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,28 @@ public NetOffice.PowerPointApi.Guides Guides
12721272
return Factory.ExecuteKnownReferencePropertyGet<NetOffice.PowerPointApi.Guides>(this, "Guides", NetOffice.PowerPointApi.Guides.LateBindingApiWrapperType);
12731273
}
12741274
}
1275+
1276+
/// <summary>
1277+
/// True if the edits in the Presentation are automatically saved. Read/write Boolean.
1278+
///
1279+
/// SupportByVersion PowerPoint 16
1280+
/// Get/Set
1281+
/// </summary>
1282+
/// <remarks> Docs: <see href="https://learn.microsoft.com/en-us/office/vba/api/powerpoint.presentation.autosaveon"/> </remarks>
1283+
[SupportByVersion("PowerPoint", 16)]
1284+
public bool AutoSaveOn
1285+
{
1286+
get
1287+
{
1288+
return Factory.ExecuteBoolPropertyGet(this, "AutoSaveOn");
1289+
}
1290+
set
1291+
{
1292+
Factory.ExecuteValuePropertySet(this, "AutoSaveOn", value);
1293+
}
1294+
}
1295+
1296+
12751297

12761298
#endregion
12771299

0 commit comments

Comments
 (0)