<%@page import="java.net.URLEncoder"%>
<%@page import="com.qmth.qrzk.repository.utils.General"%>
<%@ page language="java"
	import="java.util.*,com.zhuozhengsoft.pageoffice.*"
	pageEncoding="utf-8"%>
<%@ page import="com.qmth.qrzk.repository.*"%>
<%@ page import="java.io.*"%>
<%@ taglib uri="http://java.pageoffice.cn" prefix="po"%>
<%
//******************************卓正PageOffice组件的使用*******************************
		String tempPath = request.getParameter("tempPath");
		String title = request.getParameter("title");
		
		String url = "viewWord.jsp?&tempPath=" + URLEncoder.encode(tempPath, "UTF-8") + "&title=" + title;
		
		PageOfficeCtrl poCtrl=new PageOfficeCtrl(request);
		poCtrl.setMenubar(false);//隐藏菜单栏
		poCtrl.setOfficeToolbars(false);//隐藏Office工具条
		poCtrl.setCustomToolbar(false);//隐藏自定义工具栏
		
		//设置服务器页面
		poCtrl.setServerPage(General.getBasePath(request) + "/poserver.zz");
		//添加自定义按钮
//		poCtrl.addCustomToolButton("保存","Save",1);
//		String userId = request.getParameter("userId");
		//设置保存页面
//		poCtrl.setSaveFilePage(request.getContextPath() + "/attachment/savefile/" + attachmentId + "/" + userId);
		//打开Word文档
		if(!tempPath.startsWith("file://")){
			tempPath = "file://" + tempPath;
		}
		poCtrl.webOpen(tempPath, OpenModeType.docReadOnly,"张佚名");
		poCtrl.setTagId("PageOfficeCtrl1");//此行必需
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	<title><%= title%></title>
	<script type="text/javascript" src="<%=General.getBasePath(request)%>/resources/js/jquery-1.11.1.js"></script>
</head>
<body>
    <script type="text/javascript">
        function Save() {
            document.getElementById("PageOfficeCtrl1").WebSave();
        }
        
        $(function(){
        	if($("#PageOfficeCtrl1").text().indexOf('安装完毕后请重启浏览器浏览本页即可') > 0){
        		$("#PageOfficeCtrl1").text("正在关闭中...");
        		window.setTimeout(function(){window.close();},3000);
				return;
        	}
    		var url = $("#urlDiv").text();
    		if(url.indexOf("PageOffice://") == 0){
    			$('#poFrame').attr('src',url);
    		}
        });
    </script>
    <div id="urlDiv" style="display: none;"><%=PageOfficeLink.openWindow(request, url,"width=1000px;height=630px;")%></div>
    <div style=" width:100%; height:100%;">
        <po:PageOfficeCtrl id="PageOfficeCtrl1">
        </po:PageOfficeCtrl>
    </div>
	<iframe id="poFrame" src="" style="display: none;"></iframe>
</body>
</html>