<%@ Page language="c#" Codebehind="editoffice.aspx.cs" AutoEventWireup="True" Inherits="Webdisk.editoffice" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
  <HEAD>
  <title>编辑Office文件</title>
<% @ Import Namespace="Webdisk" %>
	<link href="<%=xml.GetStyle()%>" rel="stylesheet" type="text/css">
<SCRIPT language=javascript>
function ExitEdit(filepath,str)
{
    Webdisk.editoffice.ExitEdit(filepath,document.getElementById("isedit").value);
}
function unlock() {
    Webdisk.editoffice.UnLock(document.getElementById("hidfile").value);
    document.getElementById("dlock").style.display = 'none';
    document.getElementById("issave").style.display = '';
    TANGER_OCX_OBJ.SetReadOnly(false); setIsNoCopy(false);FormDisabled(false); 
}
</SCRIPT>
</HEAD>
	<body onload='editoffice("25","");' onUnload="ExitEdit(document.all.hidfile.value);">
		<form id="Form1" action="save.aspx" enctype="multipart/form-data" runat="server"><br>
			<TABLE cellSpacing="0" cellPadding="0" width="98%" align="center">
              <TR>
                <TD width="5"><IMG height="5" src="pics/wenbenkuan_01.gif" width="5"></TD>
                <TD width="874" background="pics/wenbenkuan_02.gif"><IMG height="5" src="pics/wenbenkuan_02.gif" width="5"></TD>
                <TD><IMG height="5" src="pics/wenbenkuan_03.gif" width="5"></TD>
              </TR>
              <TR>
                <TD background="pics/wenbenkuan_04.gif">&nbsp;</TD>
                <TD background="pics/wenbenkuan_05.gif" bgColor="#ffffff"><TABLE width="100%">
                    <TR>
                      <TD class="tabletop"><img src="pics/files.gif" width="18" height="18" align="absMiddle"> 编辑<%=type%>文件 &mdash; <%=title %>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:history.go(-1);"><img src="pics/link_back.gif" border="0" align="absMiddle"></a></TD>
                    <TR class="tablebg">
                      <TD><TABLE class="tablebgborder" cellSpacing="1" cellPadding="2" width="100%" align="center"
											border="0">
                          <TR class="tablebg">
                            <TD width="72%" height="22">
                              <p align="center" id="issave" runat=server><a onClick="clearInterval(aaa);saveFileToUrl();" href="#"><img src="pics/edit_save_office.gif" border="0" align="absmiddle"></a></p>
                              <div class="tip" id="dlock" runat="server"><img src="pics/tip.gif" align="absMiddle">&nbsp;当前文件正由<%=lockuser%>                                                                                                             用户于<%=locktime%>             时间编辑中，不能同时编辑，当前显示仅供查看<%=dlockstr%><br></div>
                                    <input id="fileid" name="fileid" type="text" value="<%=fileid %>" disabled="disabled" style="display:none"  />
            <input id="filetitle" name="filetitle" type="text" value="<%=filetitle %>"  style="display:none"/><input id="filename" name="filename" type="text" value="<%=filename2 %>" style="display:none"/>
            <input id="fileother" name="fileother"  type="text" value="<%=fileother %>" style="display:none"/>
            <input class="fileup" id="upattach" type="file" name="attach" style="display:none"/>
    </div>
                
                <div id="officecontrol">
                <!--引用NTKO OFFICE文档控件-->
                <script language="javascript" type="text/javascript" src="officecontrol/ntkoofficecontrol.js"></script>
                <!--控件事件代码开始-->
                <script type="text/javascript" language="JScript" for="TANGER_OCX" event="OnDocumentClosed();">
	                setFileOpenedOrClosed(false);
	                ExitEdit(document.all.hidfile.value);
                </script>
                <script type="text/javascript" for="TANGER_OCX" event="OnDocumentOpened(a1,a2)">
	                TANGER_OCX_OBJ.Activate(true);
					TANGER_OCX_OBJ.ActiveDocument.Saved = true;
					if(2==TANGER_OCX_OBJ.DocType)
	                {
	                    try{
	                        TANGER_OCX_OBJ.ActiveDocument.Application.ActiveWorkbook.Saved=true;
	                    }catch(e)
	                    {
	                        alert("错误：" + err.number + ":" + err.description);
	                    }
	                 }
					 setFileOpenedOrClosed(true);//设置文档状态值
					 
					<%=islock %>
                </script>
                <INPUT id="hidfile" type="hidden" name="hidfile" runat="server"><INPUT name="hidfile" type="hidden" id="isdown" runat="server"><INPUT name="isedit" type="hidden" id="isedit" value="<%=isedit%>"><INPUT name="isadminedit" type="hidden" id="isadminedit" value="<%=isadminedit%>">
                            </TD>
                          </TR>
                      </TABLE></TD>
                    </TR>
                </TABLE></TD>
                <TD width="5" background="pics/wenbenkuan_06.gif"><IMG height="5" src="pics/wenbenkuan_06.gif" width="5"></TD>
              </TR>
              <TR>
                <TD><IMG height="5" src="pics/wenbenkuan_07.gif" width="5"></TD>
                <TD background="pics/wenbenkuan_08.gif"><IMG height="5" src="pics/wenbenkuan_08.gif" width="5"></TD>
                <TD><IMG height="5" src="pics/wenbenkuan_09.gif" width="5"></TD>
              </TR>
            </TABLE>
	</form>
	</body>
</HTML>
<script language="javascript" type="text/javascript" src="js/ntko.js"></script>
<script>
var aaa;
if ((document.getElementById("isedit").value=="1") && (document.getElementById("isadminedit").value=="")) aaa=setInterval("checkout();",30000);
function checkout()
{
    Webdisk.editoffice.checkout(document.all.hidfile.value, IsUsernameExist_callback);
}
function IsUsernameExist_callback(res)
{
	var bRet = res.value;
	if (bRet=="0") 
	{
	    alert("您正在编辑的文档已被解除锁定，请编辑后保存在本地，否则所做修改将会丢失"); 

		clearInterval(aaa);
		document.all.issave.style.display='none';
	}
}
</script>