/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2012 I-maginer This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt ----------------------------------------------------------------------------- */ /******************************************************************************* Plugin Picture Picture Player permettant de lire des media reconnus par Picture Client part Version: 4.0 Author: Bastien BOURINEAU Date: 21/01/2007 Last update: 02/04/2009 *******************************************************************************/ struct PlugPDFView = [ PDFV_instance : PInstance, PDFV_win : ObjWin, PDFV_ax : AX, PDFV_iPosX : I, PDFV_iPosY : I, PDFV_iWidth : I, PDFV_iHeight : I, PDFV_tPercent : [I I I I I I I I], PDFV_tAlign : [I I], PDFV_sPath : S, PDFV_bShow : I ] MkPlugPDFView;; var PDFGUID = "{CA8A9780-280D-11CF-A24D-444553540000}";; //IE //var PDFGUID = "{8856F961-340A-11D0-A96B-00C04FD705A2}";; fun axEvent(A, u, ename, p)= _fooS ename; hd p;; // Retrieving AXfun fun GetAXfun(l, str) = if l == nil then nil else let _AXGetFuncInfo hd l -> [fnc _ _ _] in ( //_fooS fnc; if !strcmp str fnc then hd l else GetAXfun (tl l) str; );; // Retrieving AXinterface fun GetAXinterface(l, str) = if l == nil then nil else ( let _AXGetInterfaceInfo hd l -> [fnc _ _ _] in if !strcmp str fnc then hd l else GetAXinterface (tl l) str; );; fun CallAXFunc(ax, interfname, func, params)= let GetAXinterface (_AXEnumInterfaces ax) interfname -> xinterface in let _AXGetFuncList xinterface -> lfunc in let GetAXfun lfunc func -> xfun in _AXCallFunc xfun params; 0;; fun computePosSize(pdfvstr, vw, vh)= let pdfvstr.PDFV_tPercent -> [px py pw ph xo yo wo ho] in let pdfvstr.PDFV_tAlign -> [ax ay] in let if pw then (ftoi (((itof pdfvstr.PDFV_iWidth) /. 100.0) *. (itof vw))) + wo else pdfvstr.PDFV_iWidth -> pw in let if ph then (ftoi (((itof pdfvstr.PDFV_iHeight) /. 100.0) *. (itof vh))) + ho else pdfvstr.PDFV_iHeight -> ph in let if px then (ftoi (((itof pdfvstr.PDFV_iPosX) /. 100.0) *. (itof vw))) + xo else pdfvstr.PDFV_iPosX -> px in let if (ax == 1) then ((vw / 2) - (pw / 2)) + px else if (ax == 2) then (vw - pw) - px else px -> px in let if py then (ftoi (((itof pdfvstr.PDFV_iPosY) /. 100.0) *. (itof vh))) + yo else pdfvstr.PDFV_iPosY -> py in let if (ay == 1) then ((vh / 2) - (ph / 2)) + py else if (ay == 2) then (vh - ph) - py else py -> py in [px py pw ph];; fun cbAxWinSize(win, pdfvstr, w, h)= let _GETwindowPositionSize pdfvstr.PDFV_win -> [_ _ ww wh] in _AXSetSize pdfvstr.PDFV_ax 0 0 ww wh; 0;; fun cbAxWinDestroy(win, pdfvstr)= set pdfvstr.PDFV_win = nil; set pdfvstr.PDFV_bShow = 0; SendPluginEvent pdfvstr.PDFV_instance "Closed" nil nil; 0;; fun cbShow(inst, from, action, param, reply, pdfvstr)= if (pdfvstr.PDFV_win != nil) then nil else let _GETdesktopSize -> [vw vh] in let computePosSize pdfvstr vw vh -> [px py pw ph] in ( set pdfvstr.PDFV_ax = _AXCreateInstance _channel (_AXstring2GUID PDFGUID); if (pdfvstr.PDFV_ax != nil) then ( set pdfvstr.PDFV_win = _CRwindow _channel c3dXwin px py pw ph WN_NORMAL "Acrobat Reader"; _SIZEwindowEx pdfvstr.PDFV_win pw ph px py; _CBwinSize pdfvstr.PDFV_win @cbAxWinSize pdfvstr; _CBwinDestroy pdfvstr.PDFV_win @cbAxWinDestroy pdfvstr; _AXSetSite pdfvstr.PDFV_win pdfvstr.PDFV_ax; let if (_checkpack pdfvstr.PDFV_sPath) == nil then pdfvstr.PDFV_sPath else _PtoS (_checkpack pdfvstr.PDFV_sPath) -> path in CallAXFunc pdfvstr.PDFV_ax "IAcroAXDocShim" "LoadFile" path::nil; CallAXFunc pdfvstr.PDFV_ax "IAcroAXDocShim" "setView" "Fit"::nil; let _GETwindowPositionSize pdfvstr.PDFV_win -> [_ _ ww wh] in _AXSetSize pdfvstr.PDFV_ax 0 0 ww wh; set pdfvstr.PDFV_bShow = 1; ) else ( _DLGMessageBox _channel c3dXwin (loc "OS3DPDFVIEW_0021") (loc "OS3DPDFVIEW_0001") 0; 0; ); ); 0;; fun cbHide(inst, from, action, param, reply, pdfvstr)= _AXDestroyInstance _fooI pdfvstr.PDFV_ax; _DSwindow pdfvstr.PDFV_win; set pdfvstr.PDFV_ax = nil; set pdfvstr.PDFV_win = nil; set pdfvstr.PDFV_bShow = 0; 0;; fun cbChange(inst, from, action, param, reply, pdfvstr)= let if param == nil then pdfvstr.PDFV_sPath else param -> path in ( set pdfvstr.PDFV_sPath = path; if (pdfvstr.PDFV_ax == nil) then nil else ( let if (_checkpack path) == nil then path else _PtoS (_checkpack path) -> path in CallAXFunc pdfvstr.PDFV_ax "IAcroAXDocShim" "LoadFile" path::nil; // force update if (pdfvstr.PDFV_win) == nil then nil else let _GETwindowPositionSize pdfvstr.PDFV_win -> [_ _ ww wh] in _AXSetSize pdfvstr.PDFV_ax 0 0 ww wh; ); 0; ); 0;; fun cbCallAxfun(inst, from, action, param, reply, func, pdfvstr)= if (pdfvstr.PDFV_ax == nil) then nil else ( CallAXFunc pdfvstr.PDFV_ax "IAcroAXDocShim" func param::nil; //force update if (pdfvstr.PDFV_win) == nil then nil else let _GETwindowPositionSize pdfvstr.PDFV_win -> [_ _ ww wh] in _AXSetSize pdfvstr.PDFV_ax 0 0 ww wh; ); 0;; // Destroy instance fun deleteOb(inst, pdfvstr)= _AXDestroyInstance _fooI pdfvstr.PDFV_ax; _DSwindow pdfvstr.PDFV_win; set pdfvstr.PDFV_ax = nil; set pdfvstr.PDFV_win = nil; 0;; fun cbNewOb(inst)= let (getPluginInstanceParam inst "path") -> path in let atoi (getPluginInstanceParam inst "xpercent") -> xpercent in let if xpercent == nil then 0 else xpercent -> xpercent in let atoi (getPluginInstanceParam inst "xalign") -> xalign in let if xalign == nil then 0 else xalign -> xalign in let atoi (getPluginInstanceParam inst "posx") -> posx in let if posx == nil then 0 else posx -> posx in let atoi (getPluginInstanceParam inst "ypercent") -> ypercent in let if ypercent == nil then 0 else ypercent -> ypercent in let atoi (getPluginInstanceParam inst "yalign") -> yalign in let if yalign == nil then 0 else yalign -> yalign in let atoi (getPluginInstanceParam inst "posy") -> posy in let if posy == nil then 0 else posy -> posy in let atoi (getPluginInstanceParam inst "wpercent") -> wpercent in let if wpercent == nil then 1 else wpercent -> wpercent in let atoi (getPluginInstanceParam inst "width") -> width in let if width == nil then 100 else width -> width in let atoi (getPluginInstanceParam inst "hpercent") -> hpercent in let if hpercent == nil then 1 else hpercent -> hpercent in let atoi (getPluginInstanceParam inst "xoffset") -> xoffset in let if xoffset == nil then 0 else xoffset -> xoffset in let atoi (getPluginInstanceParam inst "yoffset") -> yoffset in let if yoffset == nil then 0 else yoffset -> yoffset in let atoi (getPluginInstanceParam inst "woffset") -> woffset in let if woffset == nil then 0 else woffset -> woffset in let atoi (getPluginInstanceParam inst "hoffset") -> hoffset in let if hoffset == nil then 0 else hoffset -> hoffset in let atoi (getPluginInstanceParam inst "height") -> height in let if height == nil then 100 else height -> height in let atoi (getPluginInstanceParam inst "show") -> show in let if (show == nil) then 1 else show -> show in let MkPlugPDFView [inst nil nil posx posy width height [xpercent ypercent wpercent hpercent xoffset yoffset woffset hoffset] [xalign yalign] path show] -> pdfvstr in ( if pdfvstr.PDFV_bShow then ( cbShow inst nil nil nil nil pdfvstr; 0; ) else ( cbHide inst nil nil nil nil pdfvstr; 0; ); PluginRegisterAction inst "Show" mkfun6 @cbShow pdfvstr; PluginRegisterAction inst "Hide" mkfun6 @cbHide pdfvstr; PluginRegisterAction inst "Change" mkfun6 @cbChange pdfvstr; PluginRegisterAction inst "Next page" mkfun6 mkfun7 @cbCallAxfun pdfvstr "gotoNextPage"; PluginRegisterAction inst "Previous page" mkfun6 mkfun7 @cbCallAxfun pdfvstr "gotoPreviousPage"; PluginRegisterAction inst "Set current page" mkfun6 mkfun7 @cbCallAxfun pdfvstr "setCurrentPage"; PluginRegisterAction inst "Set zoom" mkfun6 mkfun7 @cbCallAxfun pdfvstr "setZoom"; setPluginInstanceCbDel inst mkfun2 @deleteOb pdfvstr; ); 0;; fun IniPlug(file) = PlugRegister @cbNewOb nil; setPluginEditor @dynamicedit; 0;;