1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.editors.win32.ole;
14 import org.eclipse.swt.ole.win32.OLE;
15 import org.eclipse.swt.ole.win32.OleAutomation;
16 import org.eclipse.swt.ole.win32.OleClientSite;
17 import org.eclipse.swt.ole.win32.OleFrame;
18 import org.eclipse.swt.ole.win32.Variant;
19 import org.simantics.editors.win32.OLEEditorInput;
23 * Utility for Windows Picture and Fax Preview
25 * @author Marko Luukkainen <marko.luukkainen@vtt.fi>
28 public class PreviewController implements OleController {
34 public PreviewController(OleFrame frame, OleClientSite site, OleAutomation auto) {
40 public void show(OLEEditorInput input) {
41 site.doVerb(OLE.OLEIVERB_SHOW);
42 loadFile(input.getFile().getAbsoluteFile().toString());
45 public void loadFile(String file) {
48 rgdispid = auto.getIDsOfNames(new String[]{"Show"});
50 if (rgdispid != null) {
51 int dispIdMember = rgdispid[0];
52 auto.invoke(dispIdMember, new Variant[]{new Variant(file)});
56 public void bestFit() {
58 rgdispid = auto.getIDsOfNames(new String[]{"BestFit"});
60 if (rgdispid != null) {
61 int dispIdMember = rgdispid[0];
62 auto.invoke(dispIdMember);
66 public void actualSize() {
68 rgdispid = auto.getIDsOfNames(new String[]{"ActualSize"});
70 if (rgdispid != null) {
71 int dispIdMember = rgdispid[0];
72 auto.invoke(dispIdMember);
76 public void zoom(int i) {
79 rgdispid = auto.getIDsOfNames(new String[]{"Zoom"});
81 if (rgdispid != null) {
82 int dispIdMember = rgdispid[0];
83 auto.invoke(dispIdMember, new Variant[]{new Variant(i)});