root/10030_split_mm_into_two_files.patch
@
56:eeb9c6a9510c
| Revision 56:eeb9c6a9510c, 16.3 KB (checked in by Jiang Xin <worldhello.net AT gmail DOT com>, 3 years ago) |
|---|
-
freemind/main/XMLElement.java
diff -r 962e66fc663a freemind/main/XMLElement.java
a b 291 291 */ 292 292 private int parserLineNr; 293 293 294 // OSSXP.COM: some attribute saved in .mmx file, instead of the default .mm file. 295 // three attlist. 0: WhiteList, 1: BlackList, 2:EmList 296 private String special_attlist[]; 294 297 298 private void _addtoAttlist(int list, String att) 299 { 300 if (list >= special_attlist.length || list <0) 301 return; 302 this.special_attlist[list] += att; 303 this.special_attlist[list] += ":"; 304 return; 305 } 306 307 private boolean _isInAttlist(int list, String att) 308 { 309 if ( list >= special_attlist.length || list <0 || special_attlist[list].length()==0 ) { 310 return false; 311 } 312 return this.special_attlist[list].contains(att+':'); 313 } 314 315 public boolean isInWhiteAttlist(String att) 316 { 317 // WHITE list is not NULL 318 if ( this.special_attlist[0].length()!=0 ) { 319 return _isInAttlist(0, att); 320 } 321 // BLACK list is not NULL 322 if ( this.special_attlist[1].length()!=0 ) { 323 return ! _isInAttlist(1, att); 324 } 325 // Default return true; 326 return true; 327 } 328 329 public boolean isInBlackAttlist(String att) 330 { 331 // BLACK list is not NULL 332 if ( this.special_attlist[1].length()!=0 ) { 333 return _isInAttlist(1, att); 334 } 335 // WHITE list is not NULL 336 if ( this.special_attlist[0].length()!=0 ) { 337 return ! _isInAttlist(0, att); 338 } 339 // Default return false; 340 return false; 341 } 342 343 public boolean isInEmAttlist(String att) 344 { 345 return _isInAttlist(2, att); 346 } 347 348 public void addtoWhiteAttlist(String att) 349 { 350 _addtoAttlist(0, att); 351 } 352 353 public void addtoBlackAttlist(String att) 354 { 355 _addtoAttlist(1, att); 356 } 357 358 public void addtoEmAttlist(String att) 359 { 360 _addtoAttlist(2, att); 361 } 362 295 363 /** 296 364 * Creates and initializes a new XML element. 297 365 * Calling the construction is equivalent to: … … 506 574 this.children = new Vector(); 507 575 this.entities = entities; 508 576 this.lineNr = 0; 577 // OSSXP.COM: save some attributes out of .mm file. 578 this.special_attlist = new String[3]; 579 for (int i = 0; i < 3; i++) { 580 special_attlist[i] = ""; 581 } 509 582 Enumeration enumerator = this.entities.keys(); 510 583 while (enumerator.hasMoreElements()) { 511 584 Object key = enumerator.nextElement(); … … 2183 2256 if (! this.attributes.isEmpty()) { 2184 2257 Iterator enumerator = this.attributes.keySet().iterator(); 2185 2258 while (enumerator.hasNext()) { 2186 writer.write(' ');2187 2259 String key = (String) enumerator.next(); 2188 2260 String value = (String) this.attributes.get(key); 2261 2262 // OSSXP.COM: 2263 if ( this.isInBlackAttlist(key) ) 2264 { 2265 continue; 2266 } 2267 2268 writer.write(' '); 2269 2270 if ( this.isInEmAttlist(key) ) 2271 { 2272 writer.write("\n\t"); 2273 } 2274 2189 2275 writer.write(key); 2190 2276 writer.write('='); writer.write('"'); 2191 2277 this.writeEncoded(writer, value); -
freemind/modes/MindMapNode.java
diff -r 962e66fc663a freemind/modes/MindMapNode.java
a b 250 250 * @param saveChildren if true, the save recurses to all of the nodes children. 251 251 */ 252 252 public XMLElement save(Writer writer, MindMapLinkRegistry registry, boolean saveHidden, boolean saveChildren) throws IOException; 253 public XMLElement save(Writer writer, MindMapLinkRegistry registry, boolean saveHidden, boolean saveChildren, int managed_attr) throws IOException; 253 254 254 255 // fc, 10.2.2005: 255 256 /** State icons are icons that are not saved. They indicate that -
freemind/modes/NodeAdapter.java
diff -r 962e66fc663a freemind/modes/NodeAdapter.java
a b 56 56 import freemind.main.FreeMindCommon; 57 57 import freemind.main.FreeMindMain; 58 58 import freemind.main.HtmlTools; 59 import freemind.main.Resources; 59 60 import freemind.main.Tools; 60 61 import freemind.main.XMLElement; 61 62 import freemind.modes.attributes.Attribute; … … 957 958 return controller.getNodeID(this); 958 959 } 959 960 960 public XMLElement save(Writer writer, MindMapLinkRegistry registry, boolean saveInvisible, boolean saveChildren) throws IOException { 961 /** 962 * @param writer 963 * @param registry 964 * @param managed_attr =0|1|2 965 * 0 (default): save to .mm file. (do not save certain attributes, such as node's fold status) 966 * 1 : save to .mmx file. (only save auxiliary attributes, such as node's fold status) 967 * 2 : all-in-one .mm file. the default behavior of vanilla freemind. 968 * @return 969 */ 970 public XMLElement save(Writer writer, MindMapLinkRegistry registry, boolean saveInvisible, boolean saveChildren) throws IOException { 971 return save(writer, registry, saveInvisible, saveChildren, 0); 972 } 973 974 public XMLElement save(Writer writer, MindMapLinkRegistry registry, boolean saveInvisible, boolean saveChildren, int managed_attr) throws IOException { 961 975 // pre save event to save all contents of the node: 962 976 getModeController().firePreSaveEvent(this); 963 977 XMLElement node = new XMLElement(); 964 978 979 // OSSXP.COM: new line before 'TEXT' attribute. 980 node.addtoEmAttlist("TEXT"); 981 // OSSXP.COM: according to the managed_attr parameter, save or not save certain keys of this NODE. 982 switch (managed_attr) 983 { 984 case 0: 985 // Save this node to .mm file without certain attributes. 986 if(Resources.getInstance().getBoolProperty("wh_save_extra_attrs_in_aux_file") && Resources.getInstance().getBoolProperty("wh_separate_attr_created")) node.addtoBlackAttlist("CREATED"); 987 if(Resources.getInstance().getBoolProperty("wh_save_extra_attrs_in_aux_file") && Resources.getInstance().getBoolProperty("wh_separate_attr_modified")) node.addtoBlackAttlist("MODIFIED"); 988 break; 989 case 1: 990 // Save this node to .mmx file. Only save certain attributes. 991 node.addtoWhiteAttlist("ID"); 992 if(Resources.getInstance().getBoolProperty("wh_save_extra_attrs_in_aux_file") && Resources.getInstance().getBoolProperty("wh_separate_attr_folded")) node.addtoWhiteAttlist("FOLDED"); 993 if(Resources.getInstance().getBoolProperty("wh_save_extra_attrs_in_aux_file") && Resources.getInstance().getBoolProperty("wh_separate_attr_created")) node.addtoWhiteAttlist("CREATED"); 994 if(Resources.getInstance().getBoolProperty("wh_save_extra_attrs_in_aux_file") && Resources.getInstance().getBoolProperty("wh_separate_attr_modified")) node.addtoWhiteAttlist("MODIFIED"); 995 break; 996 } 997 965 998 // if (!isNodeClassToBeSaved()) { 966 999 node.setName(XMLElementAdapter.XML_NODE); 967 1000 // } else { … … 970 1003 // } 971 1004 972 1005 /** fc, 12.6.2005: XML must not contain any zero characters. */ 1006 // OSSXP.COM: not save TEXT attributes in .mmx file 1007 if( node.isInWhiteAttlist("TEXT")) 1008 { 973 1009 String text = this.toString().replace('\0', ' '); 974 1010 if(!HtmlTools.isHtmlNode(text)) { 975 1011 node.setAttribute(XMLElementAdapter.XML_NODE_TEXT,text); … … 989 1025 node.addChild(htmlElement); 990 1026 991 1027 } 1028 } 992 1029 // save additional info: 993 1030 if (getAdditionalInfo() != null) { 994 1031 node.setAttribute(XMLElementAdapter.XML_NODE_ENCRYPTED_CONTENT, … … 996 1033 } 997 1034 // ((MindMapEdgeModel)getEdge()).save(doc,node); 998 1035 1036 // OSSXP.COM: not save EDGE in .mmx 1037 if( node.isInWhiteAttlist("EDGE")) 1038 { 999 1039 XMLElement edge = (getEdge()).save(); 1000 1040 if (edge != null) { 1001 1041 node.addChild(edge); } 1042 } 1002 1043 1003 if(getCloud() != null) { 1044 // OSSXP.COM: not save CLOUD in .mmx 1045 if( node.isInWhiteAttlist("CLOUD")) 1046 { 1047 if(getCloud() != null) { 1004 1048 XMLElement cloud = (getCloud()).save(); 1005 1049 node.addChild(cloud); 1006 1050 } 1051 } 1007 1052 1053 // OSSXP.COM: not save ARROWLINK in .mmx 1054 if( node.isInWhiteAttlist("ARROWLINK")) 1055 { 1008 1056 Vector linkVector = registry.getAllLinksFromMe(this); /* Puh... */ 1009 1057 for(int i = 0; i < linkVector.size(); ++i) { 1010 1058 if(linkVector.get(i) instanceof ArrowLinkAdapter) { … … 1012 1060 node.addChild(arrowLinkElement); 1013 1061 } 1014 1062 } 1063 } 1015 1064 1016 if (isFolded()) { 1017 node.setAttribute("FOLDED","true"); } 1018 1065 // OSSXP.COM: set FOLDED status of all nodes in .mm file to "true". Preserve orignal status in .mmx file. 1066 switch (managed_attr) 1067 { 1068 case 0: 1069 // Save this node to .mm file without certain attributes. 1070 if(Resources.getInstance().getBoolProperty("wh_save_extra_attrs_in_aux_file") && Resources.getInstance().getBoolProperty("wh_separate_attr_folded")) 1071 { 1072 if (!isRoot() && !isLeaf()) { 1073 node.setAttribute("FOLDED","true"); 1074 } 1075 break; 1076 } 1077 case 1: 1078 case 2: 1079 default: 1080 if (isFolded()) { 1081 node.setAttribute("FOLDED","true"); 1082 } else { 1083 node.setAttribute("FOLDED","false"); 1084 } 1085 } 1086 1019 1087 // fc, 17.12.2003: Remove the left/right bug. 1020 1088 // VVV save if and only if parent is root. 1021 1089 if (!(isRoot()) && (getParentNode().isRoot())) { … … 1069 1137 .getLastModifiedAt())); 1070 1138 } 1071 1139 //font 1140 // OSSXP.COM: not save FONT in .mmx 1141 if( node.isInWhiteAttlist("FONT")) 1142 { 1072 1143 if (font!=null) { 1073 1144 XMLElement fontElement = new XMLElement(); 1074 1145 fontElement.setName("font"); … … 1084 1155 if (isUnderlined()) { 1085 1156 fontElement.setAttribute("UNDERLINE","true"); } 1086 1157 node.addChild(fontElement); } 1158 } 1159 // OSSXP.COM: not save ICON in .mmx 1160 if( node.isInWhiteAttlist("ICON")) 1161 { 1087 1162 for(int i = 0; i < getIcons().size(); ++i) { 1088 1163 XMLElement iconElement = new XMLElement(); 1089 1164 iconElement.setName("icon"); 1090 1165 iconElement.setAttribute("BUILTIN", ((MindIcon) getIcons().get(i)).getName()); 1091 1166 node.addChild(iconElement); 1092 1167 } 1168 } 1093 1169 1170 // OSSXP.COM: not save HOOK in .mmx 1171 if( node.isInWhiteAttlist("HOOK")) 1172 { 1094 1173 for (Iterator i = getActivatedHooks().iterator(); i.hasNext();) { 1095 1174 XMLElement hookElement = new XMLElement(); 1096 1175 hookElement.setName("hook"); 1097 1176 ((PermanentNodeHook) i.next()).save(hookElement); 1098 1177 node.addChild(hookElement); 1099 1178 } 1179 } 1100 1180 1181 // OSSXP.COM: not save ATTRIBUTE in .mmx 1182 if( node.isInWhiteAttlist("ATTRIBUTE")) 1183 { 1101 1184 attributes.save(node); 1185 } 1102 1186 if (saveChildren && childrenUnfolded().hasNext()) { 1103 1187 node.writeWithoutClosingTag(writer); 1104 1188 //recursive 1105 saveChildren(writer, registry, this, saveInvisible );1189 saveChildren(writer, registry, this, saveInvisible, managed_attr); 1106 1190 node.writeClosingTag(writer); 1107 1191 } else { 1108 1192 node.write(writer); … … 1114 1198 return map.getModeController(); 1115 1199 } 1116 1200 1201 // OSSXP.COM: PARAM managed_attr, controls whether or not save certain attrs (such as nodes's folded status) in .mm files. 1117 1202 private void saveChildren(Writer writer, MindMapLinkRegistry registry, NodeAdapter node, boolean saveHidden) throws IOException { 1203 saveChildren(writer, registry, node, saveHidden, 0); 1204 } 1205 private void saveChildren(Writer writer, MindMapLinkRegistry registry, NodeAdapter node, boolean saveHidden, int managed_attr) throws IOException { 1118 1206 for (ListIterator e = node.childrenUnfolded(); e.hasNext();) { 1119 1207 NodeAdapter child = (NodeAdapter) e.next(); 1120 1208 if(saveHidden || child.isVisible()) 1121 child.save(writer, registry, saveHidden, true );1209 child.save(writer, registry, saveHidden, true, managed_attr); 1122 1210 else 1123 saveChildren(writer, registry, child, saveHidden );1211 saveChildren(writer, registry, child, saveHidden, managed_attr); 1124 1212 } 1125 1213 } 1126 1214 -
freemind/modes/mindmapmode/MindMapMapModel.java
diff -r 962e66fc663a freemind/modes/mindmapmode/MindMapMapModel.java
a b 254 254 } 255 255 // OSSXP.COM: save file using default character set. 256 256 BufferedWriter fileout = new BufferedWriter( new OutputStreamWriter( new FileOutputStream(file), FreeMind.DEFAULT_CHARSET ) ); 257 getXml(fileout); 257 // OSSXP.COM: save tree into .mm file, without some attrs(such as node fold status). 258 getXml(fileout, true, 0); 259 260 if(Resources.getInstance().getBoolProperty("wh_save_extra_attrs_in_aux_file")) 261 { 262 // OSSXP.COM: save variable attrs(such as node fold status) into .mmx file... 263 String ext = Tools.getExtension(file.getName()); 264 String mmxFileName = ""; 265 if(!ext.equals("mm")) 266 { 267 mmxFileName = "." + file.getName()+".mmx"; 268 } 269 else 270 { 271 mmxFileName = "." + Tools.removeExtension(file.getName()) + ".mmx"; 272 } 273 File mmxfile = new File(file.getParent(), mmxFileName); 274 BufferedWriter mmxfileout = new BufferedWriter( new OutputStreamWriter( new FileOutputStream(mmxfile), FreeMind.DEFAULT_CHARSET ) ); 275 getXml(mmxfileout, true, 1); 276 } 258 277 259 278 if(!isInternal) { 260 279 setFile(file); … … 279 298 280 299 /** writes the content of the map to a writer. 281 300 * @throws IOException 301 * @param managed_attr =0|1|2 302 * 0 (default): save to .mm file. (do not save certain attributes, such as node's fold status) 303 * 1 : save to .mmx file. (only save auxiliary attributes, such as node's fold status) 304 * 2 : all-in-one .mm file. the default behavior of vanilla freemind. 282 305 */ 283 private void getXml(Writer fileout, boolean saveInvisible) throws IOException {306 private void getXml(Writer fileout, boolean saveInvisible, int managed_attr) throws IOException { 284 307 // OSSXP.COM: write xml declare. 285 308 fileout.write("<?xml version=\"1.0\" encoding=\"" + FreeMind.DEFAULT_CHARSET + "\"?>\n"); 286 309 fileout.write("<map "); 287 310 fileout.write("version=\""+FreeMind.XML_VERSION+"\""); 288 311 fileout.write(">\n"); 289 fileout.write("<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->\n"); 290 getRegistry().save(fileout); 291 (getRootNode()).save(fileout, this.getLinkRegistry(), saveInvisible, true); 312 // OSSXP.COM: add notice for this hacked version. 313 fileout.write("<!-- This file is saved using a hacked version of FreeMind. visit: http://freemind-mmx.sourceforge.net -->\n"); 314 fileout.write("<!-- Orignal FreeMind, can download from http://freemind.sourceforge.net -->\n"); 315 switch (managed_attr) 316 { 317 case 0: 318 fileout.write("<!-- This .mm file is CVS/SVN friendly, some atts are saved in .mmx file. (from ossxp.com) -->\n"); 319 break; 320 case 1: 321 fileout.write("<!-- This .mmx files store some extra mm file attributes, which should not check in to CVS/SVN ! -->\n"); 322 break; 323 case 2: 324 default: 325 break; 326 } 327 if(managed_attr != 1) { 328 getRegistry().save(fileout); 329 } 330 // OSSXP.COM: managed_attr control whether or not save nodes' fold status into .mm file. 331 (getRootNode()).save(fileout, this.getLinkRegistry(), saveInvisible, true, managed_attr); 292 332 fileout.write("</map>\n"); 293 333 fileout.close(); 294 334 } 295 335 public void getXml(Writer fileout) throws IOException{ 296 getXml(fileout, true );336 getXml(fileout, true, 0); 297 337 } 298 338 299 339 public void getFilteredXml(Writer fileout) throws IOException{ 300 getXml(fileout, false );340 getXml(fileout, false, 0); 301 341 } 302 342 303 343 /**
Note: See TracBrowser
for help on using the browser.
![(please configure the [header_logo] section in trac.ini)](/trac/freemind/chrome/common/trac_banner.png)