|
15 | 15 | // You should have received a copy of the GNU General Public License
|
16 | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17 | 17 |
|
| 18 | +using QuickLook.Common.Plugin; |
18 | 19 | using System;
|
19 | 20 | using System.IO;
|
20 | 21 | using System.Linq;
|
21 | 22 | using System.Windows;
|
22 |
| -using QuickLook.Common.Plugin; |
| 23 | +using System.Windows.Controls; |
| 24 | +using UnblockZoneIdentifier; |
23 | 25 |
|
24 | 26 | namespace QuickLook.Plugin.OfficeViewer;
|
25 | 27 |
|
@@ -55,11 +57,42 @@ public bool CanHandle(string path)
|
55 | 57 |
|
56 | 58 | public void Prepare(string path, ContextObject context)
|
57 | 59 | {
|
58 |
| - context.SetPreferredSizeFit(new Size { Width = 800, Height = 800 }, 0.8); |
| 60 | + context.SetPreferredSizeFit(new Size { Width = 1000, Height = 800 }, 0.8); |
59 | 61 | }
|
60 | 62 |
|
61 | 63 | public void View(string path, ContextObject context)
|
62 | 64 | {
|
| 65 | + // MS Office interface does not allow loading of protected view (It's also possible that I haven't found a way) |
| 66 | + // Therefore, we need to predict in advance and then let users choose whether to lift the protection |
| 67 | + if (ZoneIdentifierManager.IsZoneBlocked(path)) |
| 68 | + { |
| 69 | + context.Title = $"[PROTECTED VIEW] {Path.GetFileName(path)}"; |
| 70 | + |
| 71 | + MessageBoxResult result = MessageBox.Show( |
| 72 | + """ |
| 73 | + Be careful - files from the Internet can contain viruses. |
| 74 | + The MS Office interface prevents loading in Protected View. |
| 75 | +
|
| 76 | + Would you like OfficeViewer-Native to unblock the ZoneIdentifier of Internet? |
| 77 | + """, |
| 78 | + "PROTECTED VIEW", |
| 79 | + MessageBoxButton.YesNo, |
| 80 | + MessageBoxImage.Question |
| 81 | + ); |
| 82 | + |
| 83 | + if (result == MessageBoxResult.Yes) |
| 84 | + { |
| 85 | + ZoneIdentifierManager.UnblockZone(path); |
| 86 | + } |
| 87 | + else |
| 88 | + { |
| 89 | + context.ViewerContent = new Label() { Content = "The MS Office interface prevents loading in Protected View." }; |
| 90 | + context.Title = $"[PROTECTED VIEW] {Path.GetFileName(path)}"; |
| 91 | + context.IsBusy = false; |
| 92 | + return; |
| 93 | + } |
| 94 | + } |
| 95 | + |
63 | 96 | _panel = new PreviewPanel();
|
64 | 97 | context.ViewerContent = _panel;
|
65 | 98 | context.Title = Path.GetFileName(path);
|
|
0 commit comments