protected static void exportOutlinerDocument(OutlinerDocument document, FileProtocol protocol) {
		// We need to swap in a new documentSettings object so that the changes don't carry over
		// to the open document, but are conveyed to the export. We'll put the real object back
		// when we're done.
		DocumentSettings oldSettings = document.settings;
		DocumentInfo oldDocInfo = document.getDocumentInfo();
		
		DocumentSettings newSettings = new DocumentSettings(document);
		DocumentInfo newDocInfo = null;
		try {
			newDocInfo = (DocumentInfo) oldDocInfo.clone();
		} catch (CloneNotSupportedException cnse) {
			cnse.printStackTrace();
		}
		
		document.settings = newSettings;
		document.setDocumentInfo(newDocInfo);
		
		// We also need to swap out the tree with a new tree that just contains the current selection
		JoeTree newTree = Outliner.newTree(null);
		JoeTree oldTree = document.tree;
		
		if (document.tree.getComponentFocus() == OutlineLayoutManager.TEXT) {
			Node node = document.tree.getEditingNode();
			
			int cursor = document.tree.getCursorPosition();
			int mark = document.tree.getCursorMarkPosition();
			int startIndex = Math.min(cursor,mark);
			int endIndex = Math.max(cursor,mark);
			
			String text = node.getValue().substring(startIndex, endIndex);
			
			newTree.getRootNode().getFirstChild().setValue(text);
		} else {
			Node root = newTree.getRootNode();
			
			root.removeChild(root.getFirstChild());
			
			for (int i = 0; i < document.tree.getSelectedNodes().size(); i++) {
				Node node = document.tree.getSelectedNodes().get(i).cloneClean();
				node.setDepthRecursively(0);
				newTree.getRootNode().appendChild(node);				
			}
		}
		
		document.tree = newTree;
		
		if (protocol.selectFileToSave(document, FileProtocol.EXPORT)) {
			FileMenu.exportFile(PropertyContainerUtil.getPropertyAsString(document.getDocumentInfo(), DocumentInfo.KEY_PATH), document, protocol);
		}
		
		// Swap it back the settings
		document.settings = oldSettings;
		document.setDocumentInfo(oldDocInfo);
		document.tree = oldTree;
	}