From 03c2d6514f80b6ea0bb2edb094f822d648481cf1 Mon Sep 17 00:00:00 2001 From: Matt Cooley Date: Tue, 3 Dec 2019 13:28:49 -0800 Subject: [PATCH] Build GraphingCalculator against SDK 18362 (#841) --- src/CalcManager/CalcManager.vcxproj | 2 +- src/CalcViewModel/CalcViewModel.vcxproj | 4 +- src/Calculator/Calculator.vcxproj | 4 +- src/Calculator/Controls/MathRichEditBox.cpp | 67 +++++++++++++++---- .../CalculatorUnitTests.vcxproj | 2 +- src/GraphControl/GraphControl.vcxproj | 2 +- src/MockGraphingImpl/MockGraphingImpl.vcxproj | 4 +- 7 files changed, 64 insertions(+), 21 deletions(-) diff --git a/src/CalcManager/CalcManager.vcxproj b/src/CalcManager/CalcManager.vcxproj index 487df839..b30b3976 100644 --- a/src/CalcManager/CalcManager.vcxproj +++ b/src/CalcManager/CalcManager.vcxproj @@ -45,7 +45,7 @@ true Windows Store 10.0 - 10.0.19019.0 + 10.0.18362.0 10.0.17134.0 diff --git a/src/CalcViewModel/CalcViewModel.vcxproj b/src/CalcViewModel/CalcViewModel.vcxproj index 829e600d..df393fd1 100644 --- a/src/CalcViewModel/CalcViewModel.vcxproj +++ b/src/CalcViewModel/CalcViewModel.vcxproj @@ -42,7 +42,7 @@ 14.0 true Windows Store - 10.0.19019.0 + 10.0.18362.0 10.0.17134.0 10.0 @@ -440,4 +440,4 @@ - + \ No newline at end of file diff --git a/src/Calculator/Calculator.vcxproj b/src/Calculator/Calculator.vcxproj index 6bf2368b..6f54e0d2 100644 --- a/src/Calculator/Calculator.vcxproj +++ b/src/Calculator/Calculator.vcxproj @@ -8,7 +8,7 @@ 15.0 true Windows Store - 10.0.19019.0 + 10.0.18362.0 10.0.17134.0 false @@ -879,4 +879,4 @@ - + \ No newline at end of file diff --git a/src/Calculator/Controls/MathRichEditBox.cpp b/src/Calculator/Controls/MathRichEditBox.cpp index 175d7179..a98351db 100644 --- a/src/Calculator/Controls/MathRichEditBox.cpp +++ b/src/Calculator/Controls/MathRichEditBox.cpp @@ -16,6 +16,19 @@ using namespace Windows::Foundation::Collections; DEPENDENCY_PROPERTY_INITIALIZATION(MathRichEditBox, MathText); +// TODO remove when Windows 10 version 2004 SDK is adopted +namespace Windows_2004_Prerelease +{ + constexpr auto RichEditMathMode_MathOnly = 1; + + [uuid("619c20f2-cb3b-4521-981f-2865b1b93f04")] __interface ITextDocument4 : IInspectable + { + HRESULT SetMath(HSTRING value); + HRESULT GetMath(HSTRING * value); + HRESULT SetMathMode(int32_t mathMode); + }; +} + MathRichEditBox::MathRichEditBox() { static LimitedAccessFeatureStatus m_lafResultStatus; @@ -24,17 +37,19 @@ MathRichEditBox::MathRichEditBox() if (packageName == L"Microsoft.WindowsCalculator.Dev") { m_lafResultStatus = LimitedAccessFeatures::TryUnlockFeature( - "com.microsoft.windows.richeditmath", - "BeDD/jxKhz/yfVNA11t4uA==", // Microsoft.WindowsCalculator.Dev - "8wekyb3d8bbwe has registered their use of com.microsoft.windows.richeditmath with Microsoft and agrees to the terms of use.")->Status; + "com.microsoft.windows.richeditmath", + "BeDD/jxKhz/yfVNA11t4uA==", // Microsoft.WindowsCalculator.Dev + "8wekyb3d8bbwe has registered their use of com.microsoft.windows.richeditmath with Microsoft and agrees to the terms of use.") + ->Status; } else if (packageName == L"Microsoft.WindowsCalculator") { m_lafResultStatus = LimitedAccessFeatures::TryUnlockFeature( - "com.microsoft.windows.richeditmath", - "pfanNuxnzo+mAkBQ3N/rGQ==", // Microsoft.WindowsCalculator - "8wekyb3d8bbwe has registered their use of com.microsoft.windows.richeditmath with Microsoft and agrees to the terms of use.")->Status; + "com.microsoft.windows.richeditmath", + "pfanNuxnzo+mAkBQ3N/rGQ==", // Microsoft.WindowsCalculator + "8wekyb3d8bbwe has registered their use of com.microsoft.windows.richeditmath with Microsoft and agrees to the terms of use.") + ->Status; } else if (packageName == L"Microsoft.WindowsCalculator.Graphing") @@ -42,17 +57,37 @@ MathRichEditBox::MathRichEditBox() m_lafResultStatus = LimitedAccessFeatures::TryUnlockFeature( "com.microsoft.windows.richeditmath", "H6wflFFz3gkOsAHtG/D9Tg==", // Microsoft.WindowsCalculator.Graphing - "8wekyb3d8bbwe has registered their use of com.microsoft.windows.richeditmath with Microsoft and agrees to the terms of use.")->Status; + "8wekyb3d8bbwe has registered their use of com.microsoft.windows.richeditmath with Microsoft and agrees to the terms of use.") + ->Status; } - TextDocument->SetMathMode(Windows::UI::Text::RichEditMathMode::MathOnly); + // TODO when Windows 10 version 2004 SDK is adopted, replace with: + // TextDocument->SetMathMode(Windows::UI::Text::RichEditMathMode::MathOnly); + Microsoft::WRL::ComPtr textDocument4; + reinterpret_cast(this->TextDocument)->QueryInterface(IID_PPV_ARGS(&textDocument4)); + auto hr = textDocument4->SetMathMode(Windows_2004_Prerelease::RichEditMathMode_MathOnly); + if (FAILED(hr)) + { + throw Exception::CreateException(hr); + } } String ^ MathRichEditBox::GetMathTextProperty() { - String ^ text; - this->TextDocument->GetMath(&text); - return text; + // TODO when Windows 10 version 2004 SDK is adopted, replace with: + // String ^ text; + // this->TextDocument->GetMath(&text); + // return text; + + Microsoft::WRL::ComPtr textDocument4; + reinterpret_cast(this->TextDocument)->QueryInterface(IID_PPV_ARGS(&textDocument4)); + HSTRING math; + auto hr = textDocument4->GetMath(&math); + if (FAILED(hr)) + { + throw Exception::CreateException(hr); + } + return reinterpret_cast(math); } void MathRichEditBox::SetMathTextProperty(String ^ newValue) @@ -60,7 +95,15 @@ void MathRichEditBox::SetMathTextProperty(String ^ newValue) bool readOnlyState = this->IsReadOnly; this->IsReadOnly = false; - TextDocument->SetMath(newValue); + // TODO when Windows 10 version 2004 SDK is adopted, replace with: + // TextDocument->SetMath(newValue); + Microsoft::WRL::ComPtr textDocument4; + reinterpret_cast(this->TextDocument)->QueryInterface(IID_PPV_ARGS(&textDocument4)); + auto hr = textDocument4->SetMath(reinterpret_cast(newValue)); + if (FAILED(hr)) + { + throw Exception::CreateException(hr); + } this->IsReadOnly = readOnlyState; } diff --git a/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj b/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj index 712309c6..e93899d3 100644 --- a/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj +++ b/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj @@ -7,7 +7,7 @@ 15.0 true Windows Store - 10.0.19019.0 + 10.0.18362.0 10.0.17134.0 10.0 15.0 diff --git a/src/GraphControl/GraphControl.vcxproj b/src/GraphControl/GraphControl.vcxproj index 1392681c..f07da85a 100644 --- a/src/GraphControl/GraphControl.vcxproj +++ b/src/GraphControl/GraphControl.vcxproj @@ -42,7 +42,7 @@ 14.0 true Windows Store - 10.0.19019.0 + 10.0.18362.0 10.0.17134.0 10.0 diff --git a/src/MockGraphingImpl/MockGraphingImpl.vcxproj b/src/MockGraphingImpl/MockGraphingImpl.vcxproj index 7ab41b15..8c2aad51 100644 --- a/src/MockGraphingImpl/MockGraphingImpl.vcxproj +++ b/src/MockGraphingImpl/MockGraphingImpl.vcxproj @@ -42,7 +42,7 @@ 14.0 true Windows Store - 10.0.19019.0 + 10.0.18362.0 10.0.17134.0 10.0 @@ -297,4 +297,4 @@ - + \ No newline at end of file