]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.editors.win32/src/org/simantics/editors/win32/ole/PreviewController.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.editors.win32 / src / org / simantics / editors / win32 / ole / PreviewController.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.editors.win32.ole;
13
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;
20
21
22 /**
23  * Utility for Windows Picture and Fax Preview
24  * 
25  * @author Marko Luukkainen <marko.luukkainen@vtt.fi>
26  *
27  */
28 public class PreviewController implements OleController {
29
30         OleFrame frame;
31         OleClientSite site;
32         OleAutomation auto;
33         
34         public PreviewController(OleFrame frame, OleClientSite site, OleAutomation auto) {
35                 this.frame = frame;
36                 this.site = site;
37                 this.auto = auto;
38         }
39         
40         public void show(OLEEditorInput input) {
41                 site.doVerb(OLE.OLEIVERB_SHOW);
42                 loadFile(input.getFile().getAbsoluteFile().toString());
43         }
44         
45         public void loadFile(String file) {
46                 
47                 int[] rgdispid;
48                 rgdispid = auto.getIDsOfNames(new String[]{"Show"});
49                 
50                 if (rgdispid != null) {
51                         int dispIdMember = rgdispid[0];
52                         auto.invoke(dispIdMember, new Variant[]{new Variant(file)});
53                 }       
54         }
55         
56         public void bestFit() {
57                 int[] rgdispid;
58                 rgdispid = auto.getIDsOfNames(new String[]{"BestFit"});
59                 
60                 if (rgdispid != null) {
61                         int dispIdMember = rgdispid[0];
62                         auto.invoke(dispIdMember);
63                 }
64         }
65         
66         public void actualSize() {
67                 int[] rgdispid;
68                 rgdispid = auto.getIDsOfNames(new String[]{"ActualSize"});
69                 
70                 if (rgdispid != null) {
71                         int dispIdMember = rgdispid[0];
72                         auto.invoke(dispIdMember);
73                 }
74         }
75         
76         public void zoom(int i) {
77                 
78                 int[] rgdispid;
79                 rgdispid = auto.getIDsOfNames(new String[]{"Zoom"});
80                 
81                 if (rgdispid != null) {
82                         int dispIdMember = rgdispid[0];
83                         auto.invoke(dispIdMember, new Variant[]{new Variant(i)});
84                 }       
85         }
86         
87
88 }