<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
|
<%
|
String path = request.getContextPath();
|
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
|
+ path + "/";
|
%>
|
|
<!DOCTYPE HTML>
|
<html>
|
<head>
|
<base href="<%=basePath%>">
|
<meta name="viewport" charset="width=device-width, initial-scale=1.0">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<title>文件浏览</title>
|
<!--[if !IE]><!-->
|
<link href="static/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css">
|
<!--<![endif]-->
|
<!--[if gt IE 8]>
|
<link href="static/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css">
|
<![endif]-->
|
<link href="static/plugins/jquery-easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css">
|
<link rel="stylesheet" href="static/styles/initialize.css" type="text/css">
|
<link rel="stylesheet" href="static/styles/common.css" type="text/css">
|
<link rel="stylesheet" href="static/plugins/layer/skin/default/layer.css" type="text/css">
|
<link rel="stylesheet" href="static/plugins/jquery.iviewer/jquery.iviewer.css" type="text/css" />
|
|
<script type="text/javascript" src="static/plugins/jquery/jquery.min.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery-easyui/jquery.easyui.min.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
|
<script type="text/javascript" src="static/scripts/easyuiExtend.js"></script>
|
<script type="text/javascript" src="static/scripts/jquery-extend.js"></script>
|
<script type="text/javascript" src="static/plugins/layer/layer.js"></script>
|
<script type="text/javascript" src="static/plugins/slimScroll/jquery.slimscroll.min.js"></script>
|
|
<!-- 图片浏览插件引入 -->
|
<script type="text/javascript" src="static/plugins/jquery.js" ></script>
|
<script type="text/javascript" src="static/plugins/jqueryui.js" ></script>
|
<script type="text/javascript" src="static/plugins/jquery.mousewheel.min.js" ></script>
|
<script type="text/javascript" src="static/plugins/jquery.iviewer/jquery.iviewer.min.js"></script>
|
|
|
<script type="text/javascript" src="static/plugins/spinjs/spin.js"></script>
|
<script type="text/javascript" src="static/plugins/spinjs/jquery.spin.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery.blockUI.js"></script>
|
|
<script type="text/javascript" src="static/wcp/scripts/wcp.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.layer.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.blockUI.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.spin.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.jquery.js"></script>
|
|
<!--[if lt IE 9]>
|
<script type="text/javascript" src="static/plugins/json2.js"></script>
|
<![endif]-->
|
<style type="text/css">
|
.viewer
|
{
|
width: 100%;
|
border: 1px solid black;
|
position: relative;
|
}
|
</style>
|
</head>
|
<body class="pt-tree">
|
<div class="margin-lr">
|
<div class="pt-form">
|
<form id="form1">
|
<div id="div_Office" style="display:none;height: 100%;overflow-y: hidden;">
|
<div>
|
<!-- <input type="button" value="选择头部红头文件" class="btn4" onclick="SelectHead()" id="btn_officetbht" />
|
<input type="button" value="选择尾部红头文件" class="btn4" onclick="SelectLast()" id="btn_officewbht" />
|
<input type="button" value="保存在服务器" class="btn4" onclick="SavetoServer()" id="btn_SavetoServer" />
|
-->
|
<input id="btnSaveFile" type="button" value="保存服务器" class="btn4" style="display:none" onclick="SavetoServer()"/>
|
<span id="masklayer" style=" display:none;font-size:14px; color:red; font-weight:bold;"></span>
|
<div style="display: none">
|
<input id="txt_hongtou2" type="text" value="" />
|
</div>
|
</div>
|
|
<div style="width:100%; height:100%;">
|
<object classid="clsid:7677E74E-5831-4C9E-A2DD-9B1EF9DF2DB4" id="OA1" width="100%" height="98%" codebase="static/plugins/officeviewer.cab#version=8,0,0,651">
|
<param name="Toolbars" value="-1">
|
<param name="LicenseName" value="HZRAETC6706823702">
|
<param name="LicenseCode" value="EDO8-552B-126C-ABEB">
|
<param name="BorderColor" value="15647136">
|
<param name="BorderStyle" value="2">
|
</object>
|
<script language="JavaScript" type="text/javascript" src="static/plugins/NoIEActivate.js"></script>
|
</div>
|
|
</div>
|
</form>
|
</div>
|
|
</div>
|
</body>
|
<script type="text/javascript" src="static/scripts/ResizeScroll.js"></script>
|
|
|
<script>
|
//窗口参数,用于弹窗传递
|
var params = {
|
callBack : null
|
};
|
|
$(function() {
|
if('${isEdit}'=='1')
|
{
|
$('#btnSaveFile').show();
|
}
|
alert('dd');
|
OpenFromServer("http://"+window.location.host+attachViewUrl);
|
}
|
});
|
function closeWindow() {
|
var index = top.layer.getFrameIndex(window.name); //获取窗口索引
|
top.layer.close(index);
|
}
|
</script>
|
<script ID="clientEventHandlersJS" LANGUAGE="javascript">
|
//<!--
|
|
function OpenFromServer(sPath) {
|
CloseDoc();
|
//var sPath= window.prompt("Type the file url:", "http://www.ocxt.com/demo/samples/sample.doc");
|
|
// var sPath = "http://localhost:8161/ViewFile/2015/201507/20150721/rl19303137_淳安公积金网站修改内容.docx";
|
|
// var sPath = "http://localhost:8161/ViewFile/2015/201507/20150721/rl19303137_淳安公积金网站修改内容.docx";
|
// document.all.OA1.Open(sPath, "PowerPoint.Application");
|
|
//document.all.OA1.LoadFile(sPath);
|
// document.all.OA1.Open(sPath, "Word.Application");
|
//document.all.OA1.Open(sPath, "Excel.Application");
|
document.all.OA1.Open(sPath);
|
// if (document.all.OA1.GetCurrentProgID() == "Word.Application") {
|
// document.all.OA1.Open(sPath, "Word.Application");
|
// }
|
// if (document.all.OA1.GetCurrentProgID() == "Excel.Application") {
|
// document.all.OA1.Open(sPath, "Excel.Application");
|
// }
|
// if (document.all.OA1.GetCurrentProgID() == "PowerPoint.Application") {
|
// document.all.OA1.Open(sPath, "PowerPoint.Application");
|
// }
|
|
|
|
//document.all.OA1.Open(sPath, "Word.Application");
|
//document.all.OA1.Open(sPath, "Excel.Application");
|
//document.all.OA1.Open(sPath, "PowerPoint.Application");
|
//document.all.OA1.Open(sPath, "Visio.Application");
|
//document.all.OA1.Open(sPath, "MSProject.Application");
|
}
|
|
function PrintDoc() {
|
if (document.all.OA1.IsOpened()) {
|
document.all.OA1.PrintDialog();
|
}
|
}
|
|
function PrintPreview() {
|
if (document.all.OA1.IsOpened()) {
|
document.all.OA1.PrintPreview();
|
}
|
}
|
|
function ProtectDoc() {
|
|
if (document.all.OA1.GetCurrentProgID() != "PowerPoint.Application") {
|
if (document.all.OA1.IsOpened()) {
|
if (document.all.OA1.GetCurrentProgID() == "Word.Application") {
|
document.all.OA1.ProtectDoc(2); //wdAllowOnlyFormFields
|
|
|
}
|
else if (document.all.OA1.GetCurrentProgID() == "Excel.Application") {
|
document.all.OA1.ProtectDoc(1);
|
}
|
}
|
}
|
else {
|
window.alert("The method doesn't work for the MS PowerPoint!");
|
}
|
}
|
|
function UnProtectDoc() {
|
if (document.all.OA1.GetCurrentProgID() != "PowerPoint.Application") {
|
if (document.all.OA1.IsOpened()) {
|
document.all.OA1.UnProtectDoc();
|
}
|
}
|
else {
|
window.alert("The method doesn't work for the MS PowerPoint!");
|
}
|
}
|
|
function DocIsDirty() {
|
if (document.all.OA1.IsOpened()) {
|
if (document.OA1.IsDirty) {
|
window.alert("The file has been modified!");
|
}
|
else {
|
window.alert("The file hasn't been modified!");
|
}
|
}
|
}
|
|
function ShowHideToolbar() {
|
if (document.all.OA1.IsOpened()) {
|
var x = document.OA1.Toolbars;
|
document.OA1.ShowMenubar(!x);
|
document.OA1.Toolbars = !x;
|
}
|
}
|
|
function DisableHotKey() {
|
if (document.all.OA1.GetCurrentProgID() == "Word.Application") {
|
if (document.all.OA1.IsOpened()) {
|
document.all.OA1.WordDisableSaveHotKey(true);
|
document.all.OA1.WordDisablePrintHotKey(true);
|
document.all.OA1.WordDisableCopyHotKey(true);
|
}
|
}
|
else if (document.all.OA1.GetCurrentProgID() == "Excel.Application") {
|
document.all.OA1.WordDisableSaveHotKey(true);
|
document.all.OA1.WordDisablePrintHotKey(true);
|
document.all.OA1.WordDisableCopyHotKey(true);
|
}
|
else {
|
}
|
}
|
|
function DisableRightClick() {
|
if (document.all.OA1.IsOpened()) {
|
document.all.OA1.DisableViewRightClickMenu(true);
|
}
|
}
|
|
function SaveAs() {
|
if (document.all.OA1.IsOpened()) {
|
document.all.OA1.SaveFileDialog();
|
//You can call the SaveAs method to save silently.
|
}
|
}
|
|
function SavetoServer() {
|
if (document.OA1.IsOpened) {
|
document.OA1.SetAppFocus();
|
document.OA1.HttpInit();
|
//var sFileName = document.OA1.GetDocumentName();
|
// alert(sFileName);
|
sFileName = "${attach.attachViewUrl}";//??
|
// alert(sFileName);
|
document.OA1.HttpAddPostOpenedFile(sFileName); //save as the same file format with the sFileName then upload
|
//document.OA1.HttpAddPostOpenedFile (sFileName, 16); //save as docx file then upload
|
//document.OA1.HttpAddPostOpenedFile (sFileName, 0); //save as doc file then upload
|
//document.OA1.HttpAddPostOpenedFile (sFileName, -4143); //save as xls file then upload
|
//document.OA1.HttpAddPostOpenedFile (sFileName, 51); //save as xlxs file then upload
|
//document.OA1.HttpPost("http://www.ocxt.com/demo/upload_weboffice.php");
|
var url="http://"+window.location.host+"/wcp/management/attach/saveServer";
|
//alert(url);
|
document.OA1.HttpPost(url);
|
//if (document.OA1.GetErrorCode() == 0 || document.OA1.GetErrorCode() == 200) {
|
if (document.OA1.GetErrorCode() == 200) {
|
var sPath = "保存成功! ";
|
window.alert(sPath);
|
}
|
else {
|
window.alert("you need enable the IIS Windows Anonymous Authentication if you have not set the username and password in the HttpPost method. you need set the timeout and largefile size in the web.config file.");
|
}
|
}
|
else {
|
window.alert("Please open a document firstly!");
|
}
|
}
|
|
function CloseDoc() {
|
document.all.OA1.ExitOfficeApp();
|
document.all.OA1.ClearTempFiles();
|
if (document.OA1.IsOpened) {
|
document.all.OA1.ExitOfficeApp();
|
document.all.OA1.ClearTempFiles();
|
}
|
}
|
|
function VBAProgramming() {
|
// alert(0);
|
if (document.OA1.IsOpened) {
|
// alert(1);
|
var objWord = document.OA1.ActiveDocument;
|
// alert(1.5);
|
// document.OA1.GotoItem(101, 0); //move to start.
|
// alert(2);
|
// document.OA1.InsertBreak(6); //insert a line break
|
alert(3);
|
var range = objWord.Range(0, 0);
|
var WTable = objWord.Tables.Add(range, 3, 3);
|
alert(4);
|
WTable.Cell(1, 1).Range.Font.Name = "Times New Roman";
|
WTable.Cell(1, 1).Range.Text = "Automation 1";
|
WTable.Cell(1, 2).Range.Font.Size = 18;
|
WTable.Cell(1, 2).Range.Bold = true;
|
WTable.Cell(1, 2).Range.Font.Italic = true;
|
WTable.Cell(1, 2).Range.Text = "Automation 2";
|
WTable.Cell(2, 1).Range.ParagraphFormat.Alignment = 1; // 0= Left, 1=Center, 2=Right
|
WTable.Cell(2, 1).Range.Font.Name = "Arial";
|
WTable.Cell(2, 1).Range.Font.Size = 12;
|
WTable.Cell(2, 1).Range.Bold = false;
|
WTable.Cell(2, 1).Range.ParagraphFormat.Alignment = 2;
|
WTable.Cell(3, 3).Range.Font.Name = "Times New Roman";
|
WTable.Cell(3, 3).Range.Font.Size = 14;
|
WTable.Cell(3, 3).Range.Bold = true;
|
WTable.Cell(3, 3).Range.Font.Underline = true;
|
WTable.Cell(3, 3).Range.ParagraphFormat.Alignment = 0;
|
WTable.Cell(3, 2).Range.Text = "Automation 3";
|
}
|
}
|
function GetAllRedFile() {
|
|
if (isGetRedFileList == false) {
|
//var urljson = [{ "webpath": "http://localhost:8115/Upload/Hongtou/201408187800.doc" }, { "webpath": "http://localhost:8115/Upload/Hongtou/201408184052.doc" }, { "webpath": "http://localhost:8115/Upload/Hongtou/201408187050.doc"}];
|
|
var urljson = eval(RedFileList);
|
for (var i = 0; i < urljson.length; i++) {
|
var path = document.all.OA1.HttpDownloadFileToTempDir(urljson[i].webpath);
|
RedHeadTempPath.push({ "weburl": urljson[i].webpath, "baseurl": path });
|
}
|
isGetRedFileList = true;
|
}
|
}
|
function InsertRedFile(webpath,position) {
|
// var webpath = "http://localhost:8115/Upload/Hongtou/201408187050.doc";
|
var basepath = "";
|
$.each(RedHeadTempPath, function (i, elem) {
|
if (RedHeadTempPath[i].weburl == webpath) {
|
basepath = RedHeadTempPath[i].baseurl;
|
}
|
});
|
if (basepath != "") {
|
|
var ttt = document.all.OA1.WordInsertFile(basepath, position);
|
if (ttt == false) {
|
|
alert(basepath+" 可以再试试插入一次");
|
}
|
} else {
|
alert("没有获取到相符合的文件,检查红头文件是否存在!");
|
}
|
}
|
|
|
|
function OA1_NotifyCtrlReady() {
|
//document.OA1.ShowRibbonTitlebar (false);
|
//document.OA1.ShowMenubar (false);
|
//document.OA1.Toolbars = false;
|
|
//If you want to open a document when the page loads, you should put the code here.
|
//document.all.OA1.Open("http://www.ocxt.com/demo/samples/sample.doc");
|
document.OA1.LicenseName = "HZRAETC6706823702";
|
document.OA1.LicenseCode = "EDO8-552B-126C-ABEB";
|
}
|
|
function OA1_BeforeDocumentOpened() {
|
document.OA1.DisableFileCommand(1, true); //wdUIDisalbeOfficeButton
|
document.OA1.DisableFileCommand(2, true); //wdUIDisalbeNew
|
document.OA1.DisableFileCommand(4, true); //wdUIDisalbeOpen
|
|
// var viewSign = "";//??
|
// if (document.all.OA1.GetCurrentProgID() == "Word.Application" && viewSign == "0") {
|
//
|
// document.OA1.DisableFileCommand(16, false);
|
// } else {
|
// document.OA1.DisableFileCommand(16, true); //wdUIDisalbeSave
|
// }
|
|
document.OA1.DisableFileCommand(16, true); //wdUIDisalbeSave
|
document.OA1.DisableFileCommand(32, true); //wdUIDisalbeSaveAs
|
document.OA1.DisableFileCommand(512, true); //wdUIDisalbePrint (Ctrl+P) PES,PCT,CON
|
document.OA1.DisableFileCommand(1024, true); //wdUIDisalbePrintQuick
|
document.OA1.DisableFileCommand(2048, true); //wdUIDisalbePrintPreview
|
}
|
|
function OA1_DocumentOpened() {
|
//You can do the office automation here
|
//var objWord = document.OA1.ActiveDocument;
|
//objWord.Content.Text = "You can do the office Automation with the Edraw Viewer Component.";
|
|
|
|
}
|
|
function OA_DocumentBeforePrint() {
|
//window.alert("OA_DocumentBeforePrint");
|
}
|
|
function OA_WindowBeforeRightClick() {
|
//window.alert("OA_WindowBeforeRightClick");
|
}
|
|
function OA_BeforeDocumentSaved() {
|
//window.alert("OA_BeforeDocumentSaved");
|
//document.OA1.DisableStandardCommand(1, true);//cmdTypeSave = 0x00000001, the line code will prevent the save
|
|
// if (document.all.OA1.GetCurrentProgID() == "Word.Application") {
|
// var r = confirm("是否保存到服务器?")
|
// if (r == true) {
|
//
|
// }
|
// else {
|
// document.OA1.DisableStandardCommand(1, true);
|
// }
|
// }
|
}
|
|
</script>
|
<script language="javascript">
|
window.onbeforeunload = function () {
|
document.all.OA1.ExitOfficeApp();
|
}
|
</script>
|
|
<SCRIPT LANGUAGE=javascript FOR=OA1 EVENT=NotifyCtrlReady>
|
<!--
|
OA1_NotifyCtrlReady();
|
//-->
|
</SCRIPT>
|
|
<script language="javascript" for="OA1" event="DocumentOpened()">
|
OA1_DocumentOpened();
|
</script>
|
|
<script language="javascript" for="OA1" event="BeforeDocumentOpened()">
|
OA1_BeforeDocumentOpened();
|
</script>
|
|
<script language="javascript" for="OA1" event="DocumentBeforePrint()">
|
OA_DocumentBeforePrint();
|
</script>
|
|
<script language="javascript" for="OA1" event="BeforeDocumentSaved()">
|
OA_BeforeDocumentSaved();
|
</script>
|
|
<script language="javascript" for="OA1" event="WindowBeforeRightClick()">
|
OA_WindowBeforeRightClick();
|
</script>
|
|
</html>
|