|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.acesoft.aceoffix.AceoffixCtrl
public class AceoffixCtrl
AceoffixCtrl class is the heart among all Aceoffix classes, which is in charge of online opening, displaying and editing the Office document.
Constructor Summary | |
---|---|
AceoffixCtrl(HttpServletRequest request)
Initializes a new instance of the AceoffixCtrl class. |
Method Summary | |
---|---|
void |
addCustomMenuItem(java.lang.String caption,
java.lang.String jsFunction,
boolean enabled)
Add a menu item to custom menu. |
void |
addCustomToolButton(java.lang.String caption,
java.lang.String jsFunction,
int iconIndex)
Add a button to custom toolbar. |
void |
bind(java.lang.Object SourceObj)
Bind the data source object to the AceoffixCtrl. |
void |
createNewDocument(java.lang.String userName,
DocumentVersion docVersion)
Create a new document and open it for editing online. |
void |
openDocument(java.lang.String documentURL,
OpenModeType openMode,
java.lang.String userName)
Open an Office document online. |
void |
setAllowCopy(boolean allowCopy)
Sets a value that indicates whether allow Copy and Paste in the current document. |
void |
setBorderColor(java.awt.Color borderColor)
Sets the border color of the AceoffixCtrl. |
void |
setBorderStyle(BorderStyleType borderStyle)
Sets the border style of the AceoffixCtrl. |
void |
setCaption(java.lang.String caption)
Sets the caption text for the AceoffixCtrl. |
void |
setCompressDocument(boolean compressDocument)
Sets a value that indicates whether the document will be compressed when AceoffixCtrl saving document. |
void |
setCustomMenuCaption(java.lang.String customMenuCaption)
Sets the caption of custom menu. |
void |
setCustomToolbar(boolean customToolbar)
Sets a value that indicates whether show custom tool bar of the AceoffixCtrl. |
void |
setEncryptDocument(boolean encryptDocument)
Sets a value that indicates whether the document will be encrypted when AceoffixCtrl saving document. |
void |
setFileTitle(java.lang.String fileTitle)
The default file name of the Save As dialog box prompted by AceoffixCtrl. |
void |
setHTTPBasic_Password(java.lang.String hTTPBasic_Password)
The password name used in HTTP Basic Authentication. |
void |
setHTTPBasic_UserName(java.lang.String hTTPBasic_UserName)
The user name used in HTTP Basic Authentication. |
void |
setJsFunction_AfterDocumentClosed(java.lang.String jsFunction_AfterDocumentClosed)
Sets a JavaScript function for AfterDocumentClosed event. |
void |
setJsFunction_AfterDocumentOpened(java.lang.String jsFunction_AfterDocumentOpened)
Sets a JavaScript function for AfterDocumentOpened event. |
void |
setJsFunction_AfterDocumentSaved(java.lang.String jsFunction_AfterDocumentSaved)
Sets a JavaScript function for AfterDocumentSaved event. |
void |
setJsFunction_BeforeDocumentClosed(java.lang.String jsFunction_BeforeDocumentClosed)
Sets a JavaScript function for BeforeDocumentClosed event. |
void |
setJsFunction_BeforeDocumentSaved(java.lang.String jsFunction_BeforeDocumentSaved)
Sets a JavaScript function for BeforeDocumentSaved event. |
void |
setMenubar(boolean menubar)
Sets a value that indicates whether show menubar of the AceoffixCtrl. |
void |
setMenubarColor(java.awt.Color menubarColor)
Sets the back color of the menubar of the AceoffixCtrl. |
void |
setMenubarTextColor(java.awt.Color menubarTextColor)
Sets the back color of the menubar of the AceoffixCtrl. |
void |
setOfficeToolbars(boolean officeToolbars)
Sets a value that indicates whether show toolbars of Microsoft Office. |
void |
setSaveDataPage(java.lang.String saveDataPage)
Sets a value that indicates with which page developers would like to receive and save the data sent by AceoffixCtrl. |
void |
setSaveFileMaxSize(int saveFileMaxSize)
Sets the max size of saving document, in bytes. |
void |
setSaveFilePage(java.lang.String saveFilePage)
Sets a value that indicates with which page developers would like to receive and save the document sent by AceoffixCtrl. |
void |
setServerPage(java.lang.String serverPage)
Sets a value that indicates the URL of Aceoffix server page. |
void |
setTagId(java.lang.String id)
This method is very important. |
void |
setTheme(ThemeType theme)
Sets the theme of the AceoffixCtrl. |
void |
setTimeSpan(int timeSpan)
Sets the time span of concurrency control, in minutes. |
void |
setTitlebar(boolean titlebar)
Sets a value that indicates whether show title bar of the AceoffixCtrl. |
void |
setTitlebarColor(java.awt.Color titlebarColor)
Sets the back color of the titlebar of the AceoffixCtrl. |
void |
setTitlebarTextColor(java.awt.Color titlebarTextColor)
Sets the text color of the titlebar of the AceoffixCtrl. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AceoffixCtrl(HttpServletRequest request)
Method Detail |
---|
public void setTagId(java.lang.String id) throws java.lang.Exception, java.io.IOException
id
- The id is the id of AceoffixCtrl tag.
java.lang.Exception
java.io.IOException
public void setBorderStyle(BorderStyleType borderStyle)
borderStyle
- The default is BorderStyleType.BorderFlat.public void setBorderColor(java.awt.Color borderColor)
borderColor
- The default value is system button shadow color.public void setTheme(ThemeType theme)
theme
- The default value is ThemeType.Office2007.public void setTitlebar(boolean titlebar)
titlebar
- The default value is true.public void setTitlebarColor(java.awt.Color titlebarColor)
titlebarColor
- The default value is active caption color.public void setTitlebarTextColor(java.awt.Color titlebarTextColor)
titlebarTextColor
- The default value is active caption text color.public void setMenubar(boolean menubar)
menubar
- The default value is true.public void setMenubarColor(java.awt.Color menubarColor)
menubarColor
- The default value is system menu back color.public void setMenubarTextColor(java.awt.Color menubarTextColor)
menubarTextColor
- The default value is system window text color.public void setCustomToolbar(boolean customToolbar)
customToolbar
- The default value is true.public void setOfficeToolbars(boolean officeToolbars)
officeToolbars
- The default value is true.public void setCaption(java.lang.String caption)
caption
- The default value is "Aceoffix is a web development platform for Microsoft Office.".public void setAllowCopy(boolean allowCopy)
allowCopy
- The default value is true.public void setFileTitle(java.lang.String fileTitle)
fileTitle
- The default value is "".public void setServerPage(java.lang.String serverPage)
This is the important property of AceoffixCtrl. The Aceoffix server page provides service for the AceoffixCtrl. You must set the ServerPage property before you call the openDocument or createNewDocument method.
The following code example shows how to use the ServerPage property.
aceCtrl1.setServerPage("../aceserver.do"); //Required aceCtrl1.openDocument("doc/test.doc", OpenModeType.docNormalEdit, "Jack"); aceCtrl1.setTagId("AceoffixCtrl1"); //Required
serverPage
- The property has no default value. ServerPage is the URL of Aceoffix server page.
The Aceoffix server page is a very important page provided by Aceoffix.
The URL can be a relative URL or a complete URL which starts with "http". The relative URL can be relative to the URL of current page and it also can be a root relative URL. The root relative URL starting with "/" is relative to the root path of the application.
Note: If the URL is a complete URL, make sure that this URL must link to the current website instead of other websites. It is recommended that you use a relative URL to make the application more portable.
public void setSaveFilePage(java.lang.String saveFilePage)
This is the important property of AceoffixCtrl. If you need to save the document modified by users, you must set a value to SaveFilePage property before you call the openDocument or createNewDocument method. SaveFilePage is the URL of Web page used to receive and save document.
The following code example shows how to use the SaveFilePage property.
aceCtrl1.setServerPage("../aceserver.do"); //Required aceCtrl1.setSaveFilePage("savefile.jsp"); // Set savefile.jsp to receive and save document. aceCtrl1.openDocument("doc/test.doc", OpenModeType.docNormalEdit, "Jack"); aceCtrl1.setTagId("AceoffixCtrl1"); //Required
saveFilePage
- The property has no default value. SaveFilePage is the URL of Web page used to receive and save document.
The URL can be a relative URL or a complete URL which starts with "http". The relative URL can be relative to the URL of current page and it also can be a root relative URL. The root relative URL starting with "/" is relative to the root path of the application.
Note: If the URL is a complete URL, make sure that this URL must link to the current website instead of other websites. It is recommended that you use a relative URL to make the application more portable.
public void setSaveDataPage(java.lang.String saveDataPage)
This is the important property of AceoffixCtrl. If you need to save data inputted by users in the document, you must set a value to SaveDataPage property before you call the OpenDocument method. SaveDataPage is the URL of Web page used to receive and save data from the document.
Before calling openDocument method, you should create WordResponse or ExcelResponse object to specify the DataRegions or Cells, TableRanges which will be submitted and call the bind method.
If the document is Word document, the OpenMode in openDocument must be OpenModeType.docSubmitForm. If the document is Excel document, the OpenMode in openDocument must be OpenModeType.xlsSubmitForm.
After setting SaveDataPage property, you should create the SaveData page to receive and save the data sent by AceoffixCtrl. In SaveData page, you must create WordRequest or ExcelRequest object to get data from the document.
When AceoffixCtrl is saving document, AceoffixCtrl will first submit data extracted from the document to page specified by SaveDataPage and then submit the document file to page specified by SaveFilePage.
If the SaveDataPage property is not assigned, submitting data action will not execute. If the SaveFilePage property is not assigned, submitting file action will not execute. If both SaveDataPage property and SaveFilePage property are not assigned, AceoffixCtrl will report an error when saving document.
The following code example shows how to use the SaveDataPage property.
Word code example:
aceCtrl1.setServerPage("../aceserver.do"); //Required WordResponse wr = new WordResponse(); WordResDataRegion dataRegion = wr.openDataRegion("name"); dataRegion.setNeedSubmit(true); aceCtrl1.setSaveDataPage("savedata.jsp"); aceCtrl1.bind(wr); aceCtrl1.openDocument("doc/test.doc", OpenModeType.docSubmitForm, "Jack"); aceCtrl1.setTagId("AceoffixCtrl1"); //Required
Excel code example:
aceCtrl1.setServerPage("../aceserver.do"); //Required ExcelResponse er = new ExcelResponse(); ExcelResCell cell1 = eres.openSheet("Sheet1").OpenCell("B2"); cell1.setSubmitName("ItemCount"); aceCtrl1.setSaveDataPage("savedata.jsp"); aceCtrl1.bind(er); aceCtrl1.openDocument("doc/test.xls", OpenModeType.xlsSubmitForm, "Jack"); aceCtrl1.setTagId("AceoffixCtrl1"); //Required
saveFilePage
- The property has no default value. SaveDataPage is the URL of Web page used to receive and save data from the document.
The URL can be a relative URL or a complete URL which starts with "http". The relative URL can be relative to the URL of current page and it also can be a root relative URL. The root relative URL starting with "/" is relative to the root path of the application.
Note: If the URL is a complete URL, make sure that this URL must link to the current website instead of other websites. It is recommended that you use a relative URL to make the application more portable.
public void setSaveFileMaxSize(int saveFileMaxSize)
saveFileMaxSize
- The default value is 0 which means that there is no limit to the size of saving document.public void setEncryptDocument(boolean encryptDocument)
If the value is true, AceoffixCtrl will encrypt the document and then save it to the Web server. When AceoffixCtrl open the encrypted document next time, AceoffixCtrl can automatically identify it and open it. Using EncryptDocument property will enhance the security of the documents on the Web server. The encrypted format can not be easily identified by other softwares and users logged on the Web server can not double-click to open the encrypted document. But typically, there is no need to use this property.
encryptDocument
- The default value is false.public void setCompressDocument(boolean compressDocument)
If the value is true, AceoffixCtrl will compress the document and then save it to the Web server. When AceoffixCtrl open the compressed document next time, AceoffixCtrl can automatically identify it and open it. The advantage of using CompressDocument property is reducing the server disk space requirements and reducing the network traffic and speeding up the rate of opening and saving document. The disadvantage of using CompressDocument property is that the compressed format can not be easily identified by other softwares and users logged on the Web server can not double-click to open the compressed document. Typically, there is no need to use this property.
compressDocument
- The default value is false.public void setHTTPBasic_UserName(java.lang.String hTTPBasic_UserName)
public void setHTTPBasic_Password(java.lang.String hTTPBasic_Password)
public void setTimeSpan(int timeSpan)
When many people attempt to modify a document online at the same time, a system of controls must be implemented so that modifications made by one person do not adversely affect those of another person. This is called concurrency control in Aceoffix.
A system of locks prevents users from modifying document in a way that affects other users. After a user opens a document for editing that causes a lock to be applied, other users cannot open this document for editing that would conflict with the lock until the owner releases it. If the value of TimeSpan is greater than 0, the concurrency control will be started to control the current document. The value of TimeSpan means how many minutes a owner can lock the document. When TimeSpan is timeout, Aceoffix will automatically release the lock and the owner can not save the document. If the owner closes the document before the TimeSpan is timeout, Aceoffix also will automatically release the lock. After the lock is released, other user can open the document for editing immediately. During the lock is valid, other users can open the document as read-only.
timeSpan
- The default value is 0 which means that the current document do not use concurrency control.public void setJsFunction_AfterDocumentOpened(java.lang.String jsFunction_AfterDocumentOpened)
This event is triggered at the client-side after the document is opened. If you want to capture this event, You should define a JavaScript function in the HTML code of current page.
public void setJsFunction_AfterDocumentClosed(java.lang.String jsFunction_AfterDocumentClosed)
This event is triggered at the client-side after the document is closed. If you want to capture this event, You should define a JavaScript function in the HTML code of current page.
public void setJsFunction_AfterDocumentSaved(java.lang.String jsFunction_AfterDocumentSaved)
This event is triggered at the client-side after the document is saved. If you want to capture this event, You should define a JavaScript function in the HTML code of current page.
public void setJsFunction_BeforeDocumentClosed(java.lang.String jsFunction_BeforeDocumentClosed)
This event is triggered at the client-side before the document is closed. If you want to capture this event, You should define a JavaScript function in the HTML code of current page.
public void setJsFunction_BeforeDocumentSaved(java.lang.String jsFunction_BeforeDocumentSaved)
This event is triggered at the client-side before the document is saved. If you want to capture this event, You should define a JavaScript function in the HTML code of current page.
public void setCustomMenuCaption(java.lang.String customMenuCaption)
customMenuCaption
- The default value is "Custom Me&nu".public void addCustomMenuItem(java.lang.String caption, java.lang.String jsFunction, boolean enabled)
The following code example shows how to use the addCustomMenuItem method.
aceCtrl1.setCustomMenuCaption("My &Tools"); aceCtrl1.addCustomMenuItem("&Show revisions", "OnCustomMenuClick()", true); aceCtrl1.addCustomMenuItem("&Hide revisions", "OnCustomMenuClick()", true); aceCtrl1.addCustomMenuItem("-", "", true); aceCtrl1.addCustomMenuItem("&Accept all revisions", "DoAcceptAll()", false);
And then, you should define the JavaScript functions in the HTML code of current page.
<script language="javascript" type="text/javascript"> function OnCustomMenuClick(iIndex, sCaption) { var AceoffixCtrl1 = document.getElementById("AceoffixCtrl1"); if (iIndex == 0) AceoffixCtrl1.ShowRevisions = true; if (iIndex == 1) AceoffixCtrl1.ShowRevisions = false; } function DoAcceptAll() { document.getElementById("AceoffixCtrl1").AcceptAllRevisions(); } </script>
caption
- The caption of new menu item. If the caption is "-", means that this menu item is separator.jsFunction
- The name of JavaScript function. The JavaScript function will be called when user click this menu item.enabled
- true: Enable menu item. false: Disable menu item and appear in grey.public void addCustomToolButton(java.lang.String caption, java.lang.String jsFunction, int iconIndex)
The following code example shows how to use the addCustomToolButton method.
aceCtrl1.addCustomToolButton("Save", "SaveDocument()", 1); aceCtrl1.addCustomToolButton("Print", "ShowPrintDlg()", 6); aceCtrl1.addCustomToolButton("-", "", 0); aceCtrl1.addCustomToolButton("Switch Full-screen", "SwitchFullScreen()", 4);
And then, you should define the JavaScript functions in the HTML code of current page.
<script language="javascript" type="text/javascript"> function SaveDocument() { document.getElementById("AceoffixCtrl1").SaveDocument(); } function ShowPrintDlg() { document.getElementById("AceoffixCtrl1").ShowDialog(4); //Print dialog box } function SwitchFullScreen() { document.getElementById("AceoffixCtrl1").FullScreen = !document.getElementById("AceoffixCtrl1").FullScreen; } </script>
caption
- The caption of new button item. If the caption is "-", means that this button item is separator.jsFunction
- The name of JavaScript function. The JavaScript function will be called when user click this button.iconIndex
- The index of button icon. Aceoffix predefines some button icons and you can use one of them. The default value is 0. Possible values as following:
public void bind(java.lang.Object SourceObj) throws java.lang.Exception, java.io.IOException
When accessing data from Word document or Excel workbook, you must create a data source object and call bind method. If you need to call bind method, you must call it before calling openDocument method.
The type of SourceObj parameter should be the same as the type of document opened through openDocument method. For example, if SourceObj is a WordResponse object, the openDocument method should open a Word document.
The following code example shows how to use the bind method.
Word code example:
WordResponse wr = new WordResponse(); WordResDataRegion dataRegion = wr.openDataRegion("name"); dataRegion.setValue("John Scott"); aceCtrl1.bind(wr); //The data source is a WordResponse object.
Excel code example:
ExcelResponse er = new ExcelResponse(); ExcelResSheet sheetOrder = er.OpenSheet("Order"); sheetOrder.OpenCell("B5").Value = "John Scott"; aceCtrl1.bind(er);
SourceObj
- Data source object. Available object types are WordResponse and ExcelResponse.
java.lang.Exception
java.io.IOException
public void openDocument(java.lang.String documentURL, OpenModeType openMode, java.lang.String userName) throws java.lang.Exception, java.io.IOException
This is the important method of AceoffixCtrl. It is used to open an Office document online.
Creating new document on Web server is very different from creating new document on local computer. Creating new document on Web server must consider the compatibility with all the Microsoft Office softwares installed on client computers. In order to keep the compatibility of Office software version, you should choose the lower DocumentVersion when you create a new document by createNewDocument method.
The following code example shows how to open the document and set the document in editable state.
aceCtrl1.setServerPage("../aceserver.do"); //Required aceCtrl1.openDocument("doc/test.doc", OpenModeType.docNormalEdit, "John Scott");
documentURL
- The URL of the document which is going to be opened.
The document can be a file from Web folder and also can be a binary stream outputted by server page. However, the document must be Office document format. Aceoffix supports many document formats, such as *.doc,*.docx,*.xls,*.xlsx,*.ppt,*.pptx,*.xml and *.rtf.
The URL can be a relative URL or a complete URL which starts with "http". The relative URL can be relative to the URL of current page and it also can be a root relative URL. The root relative URL starting with "/" is relative to the root path of the application. Note: If the URL is a complete URL, make sure that this URL must link to the current website instead of other websites. It is recommended that you use a relative URL to make the application more portable.
openMode
- The open mode AceoffixCtrl should use after the document is opened. Make sure that the openMode is consistent with the file type of the document.userName
- The operator of the current document. Typically, userName should be the name of current user who has logged in your web application.
java.lang.Exception
java.io.IOException
public void createNewDocument(java.lang.String userName, DocumentVersion docVersion) throws java.lang.Exception, java.io.IOException
If you want to create a new document and open it for editing online, you need to use createNewDocument method.
Creating new document on Web server is very different from creating new document on local computer. Creating new document on Web server must consider the compatibility with all the Microsoft Office softwares installed on client computers. In order to keep the compatibility of Office software version, you should choose the lower DocumentVersion when you create a new document by createNewDocument method.
The following code example shows how to use the createNewDocument method to create an empty document in Word2003 format.
Word code example:
aceCtrl1.setServerPage("../aceserver.do"); //Required aceCtrl1.setSaveFilePage("savefile.jsp?id=1&op=new"); aceCtrl1.createNewDocument("John Scott", DocumentVersion.Word2003);
userName
- The operator of the current document. Typically, userName should be the name of current user who has logged in your web application.docVersion
- The document type and version.
java.lang.Exception
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |