001package com.hfg.xml.msofficexml.part; 002 003 004import com.hfg.xml.XMLTag; 005import com.hfg.xml.msofficexml.RelationshipType; 006import com.hfg.xml.msofficexml.docx.Docx; 007import com.hfg.xml.msofficexml.docx.wordprocessingml.WmlXML; 008 009//------------------------------------------------------------------------------ 010/** 011 Represents an Office Open XML settings part. 012 013 @author J. Alex Taylor, hairyfatguy.com 014 */ 015//------------------------------------------------------------------------------ 016// com.hfg XML/HTML Coding Library 017// 018// This library is free software; you can redistribute it and/or 019// modify it under the terms of the GNU Lesser General Public 020// License as published by the Free Software Foundation; either 021// version 2.1 of the License, or (at your option) any later version. 022// 023// This library is distributed in the hope that it will be useful, 024// but WITHOUT ANY WARRANTY; without even the implied warranty of 025// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 026// Lesser General Public License for more details. 027// 028// You should have received a copy of the GNU Lesser General Public 029// License along with this library; if not, write to the Free Software 030// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 031// 032// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 033// jataylor@hairyfatguy.com 034//------------------------------------------------------------------------------ 035 036public class SettingsPart extends OfficeXMLPart 037{ 038 //########################################################################### 039 // CONSTRUCTORS 040 //########################################################################### 041 042 //--------------------------------------------------------------------------- 043 public SettingsPart(Docx inDocx) 044 { 045 super(inDocx); 046 047 setFile(WmlXML.SETTINGS_FILE); 048 049 XMLTag rootTag = new XMLTag(WmlXML.SETTINGS); 050 rootTag.addXMLNamespaceDeclaration(WmlXML.WORDPROCESSINGML_NAMESPACE); 051 052 setRootNode(rootTag); 053 054 inDocx.getDocumentPart().getRelationshipPart().addRelationship(RelationshipType.SETTINGS, WmlXML.SETTINGS_FILE); 055 } 056 057 //########################################################################### 058 // PUBLIC METHODS 059 //########################################################################### 060 061 //--------------------------------------------------------------------------- 062 public SettingsPart setHideGrammaticalErrors(boolean inValue) 063 { 064 getOrCreateSubtag(WmlXML.HIDE_GRAMMATICAL_ERRORS).setAttribute(WmlXML.VALUE_ATT, inValue); 065 return this; 066 } 067 068 //--------------------------------------------------------------------------- 069 public SettingsPart setHideSpellingErrors(boolean inValue) 070 { 071 getOrCreateSubtag(WmlXML.HIDE_SPELLING_ERRORS).setAttribute(WmlXML.VALUE_ATT, inValue); 072 return this; 073 } 074 075 //--------------------------------------------------------------------------- 076 public SettingsPart setCleanSpellingProofState() 077 { 078 getOrCreateSubtag(WmlXML.PROOF_STATE).setAttribute(WmlXML.SPELLING_ATT, "clean"); 079 return this; 080 } 081 082 //--------------------------------------------------------------------------- 083 public SettingsPart setDirtySpellingProofState() 084 { 085 getOrCreateSubtag(WmlXML.PROOF_STATE).setAttribute(WmlXML.SPELLING_ATT, "dirty"); 086 return this; 087 } 088 089 //--------------------------------------------------------------------------- 090 public SettingsPart setCleanGrammarProofState() 091 { 092 getOrCreateSubtag(WmlXML.PROOF_STATE).setAttribute(WmlXML.GRAMMAR_ATT, "clean"); 093 return this; 094 } 095 096 //--------------------------------------------------------------------------- 097 public SettingsPart setDirtyGrammarProofState() 098 { 099 getOrCreateSubtag(WmlXML.PROOF_STATE).setAttribute(WmlXML.GRAMMAR_ATT, "dirty"); 100 return this; 101 } 102 103 //--------------------------------------------------------------------------- 104 /** 105 Specifies that hosting applications shall remove all personal information of 106 document authors upon saving a given WordprocessingML document. The definition 107 and extent of personal information is not defined by ECMA-376. 108 */ 109 public SettingsPart setRemovePersonalInfo(boolean inValue) 110 { 111 getOrCreateSubtag(WmlXML.REMOVE_PERSONAL_INFO).setAttribute(WmlXML.VALUE_ATT, inValue); 112 return this; 113 } 114 115 //--------------------------------------------------------------------------- 116 /** 117 Specifies if a document's Thumbnail part should be generated for the contents 118 of the first page of this document when saved by application which support 119 document thumbnail generation. 120 */ 121 public SettingsPart setSavePreviewPicture(boolean inValue) 122 { 123 getOrCreateSubtag(WmlXML.SAVE_PREVIEW_PICT).setAttribute(WmlXML.VALUE_ATT, inValue); 124 return this; 125 } 126 127 //--------------------------------------------------------------------------- 128 /** 129 Specifies that applications shall track revisions made to the WordprocessingML 130 document. Revisions are changes to a WordprocessingML document which are recorded 131 such that they can be viewed independently, accepted or removed, and reverted if 132 needed. When revisions are tracked, the resulting WordprocessingML markup in the 133 Revisions subclause of this document describes the necessary syntax. 134 */ 135 public SettingsPart setTrackRevisions(boolean inValue) 136 { 137 getOrCreateSubtag(WmlXML.TRACK_REVISIONS).setAttribute(WmlXML.VALUE_ATT, inValue); 138 return this; 139 } 140 141}