Write data styles to styles.xml/common-styles

@param util   an util
@param appendable the destination
@throws IOException if an I/O error occurs
480444
public void writeVisibleDataStyles(final XMLUtil util, final Appendable appendable)
            throws IOException {
        final Iterable<DataStyle> dataStyles = this.dataStylesContainer
                .getValues(Dest.STYLES_COMMON_STYLES);
        for (final DataStyle dataStyle : dataStyles) {
            assert !dataStyle.isHidden() : dataStyle.toString() + " - " + dataStyle.getName() +
                    TableCellStyle.DEFAULT_CELL_STYLE.toString();

            dataStyle.appendXMLContent(util, appendable);
        }
    }
209948
private void writeRow(String... columns) throws IOException {
        StringBuilder html = new StringBuilder();
        html.append("<tr>");
        for(String data : columns) {
            html.append("<td>").append(data).append("</td>");
        }
        html.append("</tr>\n");
        writer.write(html.toString());
    }
207520
public <A extends Appendable> A appendTo(A appendable, Map<?, ? extends Collection<?>> map) throws IOException {
		return appendTo(appendable, map.entrySet());
	}
635123
public void appendTo(Appendable app) throws IOException {
        app.append("{properties=[");
        int length = mProperties.length;
        for (int i=0; i<length; i++) {
            if (i > 0) {
                app.append(", ");
            }
            app.append(mDirections[i].toCharacter());
            app.append(mProperties[i].getName());
        }
        app.append(']');
        app.append(", unique=");
        app.append(String.valueOf(isUnique()));
        app.append('}');
    }
1340908
private <T,E extends TypedEdge<T>> void write(
                         Multigraph<T,E> g, File f, Map<T,Color> edgeColors, 
                         boolean useColors, Indexer<String> vertexLabels,
                         boolean useLabels) throws IOException {

        DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = null;
        try {
            docBuilder = dbfac.newDocumentBuilder();
        } catch (ParserConfigurationException pce) {
            throw new IOError(new IOException(pce));
        }
        Document doc = docBuilder.newDocument();

        Element root = doc.createElement("gexf");
        root.setAttribute("xmlns","http://www.gexf.net/1.2draft");
        root.setAttribute("xmlns:viz", "http://www.gexf.net/1.2draft/viz");
        root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
        root.setAttribute("version","1.2");
        root.setAttribute("xsi:schemaLocation","http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd");
        doc.appendChild(root);

        Element graph = doc.createElement("graph");
        graph.setAttribute("defaultedgetype","undirected");
        root.appendChild(graph);

        Element nodes = doc.createElement("nodes");
        graph.appendChild(nodes);
        Element edges = doc.createElement("edges");
        graph.appendChild(edges);

        IntIterator vIter = g.vertices().iterator();
        while (vIter.hasNext()) {
            int vertex = vIter.next();
            Element node = doc.createElement("node");
            node.setAttribute("id", String.valueOf(vertex));
            if (useLabels) 
                node.setAttribute("label", vertexLabels.lookup(vertex));
            else
                node.setAttribute("label", String.valueOf(vertex));
            nodes.appendChild(node);
        }

        ColorGenerator cg = null;
        if (useColors)
            cg = new ColorGenerator();

        int edgeId = 0;
        for (E e : g.edges()) {
            Element edge = doc.createElement("edge");
            edges.appendChild(edge);
            edge.setAttribute("id", "" + (edgeId++));
            edge.setAttribute("source", String.valueOf(e.from()));
            edge.setAttribute("target", String.valueOf(e.to()));
            edge.setAttribute("label", String.valueOf(e.edgeType()));
            if (useColors) {
                Element cEdge = doc.createElement("viz:color");
                edge.appendChild(cEdge);
                Color c = edgeColors.get(e.edgeType());
                if (c == null) {
                    c = cg.next();
                    edgeColors.put(e.edgeType(), c);
                }
                cEdge.setAttribute("r", String.valueOf(c.getRed()));
                cEdge.setAttribute("g", String.valueOf(c.getGreen()));
                cEdge.setAttribute("b", String.valueOf(c.getBlue()));
            }
        }

        // Set up a transformer
        try {
            TransformerFactory transfac = TransformerFactory.newInstance();
            Transformer trans = transfac.newTransformer();
            trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
            trans.setOutputProperty(OutputKeys.INDENT, "yes");
            trans.setOutputProperty(
                "{http://xml.apache.org/xslt}indent-amount", "2");
        
            // Create string from xml tree
            BufferedOutputStream bos = 
                new BufferedOutputStream(new FileOutputStream(f));
            StreamResult result = new StreamResult(bos);
            DOMSource source = new DOMSource(doc);
            trans.transform(source, result);
            bos.close();         
        } catch (TransformerException te) {
            throw new IOError(new IOException(te));
        }
    }
266702
public void write(Bean bean, Appendable output) throws IOException {
        JodaBeanUtils.notNull(bean, "bean");
        JodaBeanUtils.notNull(output, "output");
        this.output = new JsonOutput(output, settings.getIndent(), settings.getNewLine());
        writeBean(bean, bean.getClass());
        output.append(settings.getNewLine());
    }
790400
public void appendTo(
      Appendable out,
      DependencyInfo info,
      String content) throws IOException {
    appendTo(out, info, CharSource.wrap(content));
  }
1294152
public void appendTo(Appendable app) throws IOException {
        appendPropTo(app, mPrime.getName(), isOuterJoin(0));
        StorableProperty<?>[] chain = mChain;
        if (chain != null) {
            for (int i=0; i<chain.length; i++) {
                app.append('.');
                appendPropTo(app, chain[i].getName(), isOuterJoin(i + 1));
            }
        }
    }
891358
public void writePreamble(final XMLUtil util, final ZipUTF8Writer writer) throws IOException {
        writer.putNextEntry(new ZipEntry("content.xml"));
        writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        writer.write(
                "<office:document-content xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\" " + "xmlns:style=\"urn:oasis:names:tc:opendocument:xmlns:style:1.0\" " + "xmlns:text=\"urn:oasis:names:tc:opendocument:xmlns:text:1.0\" " + "xmlns:table=\"urn:oasis:names:tc:opendocument:xmlns:table:1.0\" " + "xmlns:draw=\"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0\" " + "xmlns:fo=\"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0\" " + "xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" " + "xmlns:meta=\"urn:oasis:names:tc:opendocument:xmlns:meta:1.0\" " + "xmlns:number=\"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0\" " + "xmlns:presentation=\"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0\" " + "xmlns:svg=\"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0\" " + "xmlns:chart=\"urn:oasis:names:tc:opendocument:xmlns:chart:1.0\" " + "xmlns:dr3d=\"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0\" xmlns:math=\"http://www" + ".w3.org/1998/Math/MathML\" xmlns:form=\"urn:oasis:names:tc:opendocument:xmlns:form:1.0\" " + "xmlns:script=\"urn:oasis:names:tc:opendocument:xmlns:script:1.0\" " + "xmlns:ooo=\"http://openoffice.org/2004/office\" xmlns:ooow=\"http://openoffice" + ".org/2004/writer\" xmlns:oooc=\"http://openoffice.org/2004/calc\" xmlns:dom=\"http://www" + ".w3.org/2001/xml-events\" xmlns:xforms=\"http://www.w3.org/2002/xforms\" " + "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www" + ".w3.org/2001/XMLSchema-instance\" office:version=\"1.1\">");
        writer.write("<office:scripts/>");
        this.stylesContainer.writeFontFaceDecls(util, writer);
        writer.write("<office:automatic-styles>");
        this.stylesContainer.writeHiddenDataStyles(util, writer);
        this.stylesContainer.writeContentAutomaticStyles(util, writer);
        writer.write("</office:automatic-styles>");
        writer.write("<office:body>");
        writer.write("<office:spreadsheet>");
    }
1112057
public void writeHeader(BufferedWriter bufferedWriter, boolean appendLineTermination) throws IOException {
		checkEntityConfig();
		bufferedWriter.write(buildHeaderLine(appendLineTermination));
	}
512290
public void writeTo(Appendable appendable) throws IOException {
        try (JsonOutput json = new Json().newOutput(appendable)) {
            json.beginObject();

            Map<String, Object> first = getOss();
            if (first == null) {
                //noinspection unchecked
                first = (Map<String, Object>) stream().findFirst()
                        .orElse(new ImmutableCapabilities())
                        .asMap();
            }

            // Write the first capability we get as the desired capability.
            json.name(DESIRED_CAPABILITIES);
            json.write(first);

            if (!forceMobileJSONWP) {
                // And write the first capability for gecko13
                json.name(CAPABILITIES);
                json.beginObject();

                // Then write everything into the w3c payload. Because of the way we do this, it's easiest
                // to just populate the "firstMatch" section. The spec says it's fine to omit the
                // "alwaysMatch" field, so we do this.
                json.name(FIRST_MATCH);
                json.beginArray();
                getW3C().forEach(json::write);
                json.endArray();

                json.endObject();  // Close "capabilities" object
            }

            writeMetaData(json);

            json.endObject();
        }
    }
256653
private void writeSimple(String currentIndent, String tagName, StringBuilder attrs, Class<?> declaredType, Object value) throws IOException {
        Class<?> effectiveType;
        if (declaredType == Object.class) {
            Class<?> realType = value.getClass();
            if (realType != String.class) {
                effectiveType = settings.getConverter().findTypedConverter(realType).getEffectiveType();
                String typeStr = SerTypeMapper.encodeType(effectiveType, settings, basePackage, knownTypes);
                appendAttribute(attrs, TYPE, typeStr);
            } else {
                effectiveType = realType;
            }
        } else if (settings.getConverter().isConvertible(declaredType) == false) {
            effectiveType = settings.getConverter().findTypedConverter(value.getClass()).getEffectiveType();
            String typeStr = SerTypeMapper.encodeType(effectiveType, settings, basePackage, knownTypes);
            appendAttribute(attrs, TYPE, typeStr);
        } else {
            effectiveType = declaredType;
        }
        try {
            String converted = settings.getConverter().convertToString(effectiveType, value);
            if (converted == null) {
                throw new IllegalArgumentException("Unable to write because converter returned a null string: " + value);
            }
            output.append(currentIndent).append('<').append(tagName).append(attrs).append('>');
            appendEncoded(converted);
            output.append('<').append('/').append(tagName).append('>').append(settings.getNewLine());
        } catch (RuntimeException ex) {
            throw new IllegalArgumentException("Unable to convert type " + effectiveType.getName() + " declared as " + declaredType.getName(), ex);
        }
    }
1100670
void writeObjectEnd() throws IOException {
        currentIndent = currentIndent.substring(0, currentIndent.length() - indent.length());
        if (commaState.get(commaDepth)) {
            output.append(newLine);
            output.append(currentIndent);
        }
        output.append('}');
        commaDepth--;
    }
1358452
static void writeCursorTheme(CursorTheme theme, BufferedWriter writer) throws IOException {
        writer.write(XML_START_TAG);
        XMLUtils.writeXmlAttribute(ID, theme.getId(), writer);
        XMLUtils.writeXmlAttribute(NAME, theme.getName(), writer);
        XMLUtils.writeXmlAttribute(TYPE, theme.getType(), writer);

        String description = theme.getDescription();
        if (description != null) {
            XMLUtils.writeXmlAttribute(DESCRIPTION, description, writer);
        }
        writer.write(XMLUtils.CLOSING_BRACE);
        for (CursorAsset asset : theme.getAssets()) {
            CursorAssetFactory.writeCursorAsset(asset, writer);
        }
        writer.write(XML_END_TAG);
        writer.write(XMLUtils.CLOSING_BRACE);
    }
587539
public void appendXMLToTable(final XMLUtil util, final Appendable appendable, final int count)
            throws IOException {
        appendable.append("<table:table-column");
        util.appendEAttribute(appendable, "table:style-name", this.name);
        if (count > 1) util.appendAttribute(appendable, "table:number-columns-repeated", count);
        if (this.defaultCellStyle != null)
            util.appendEAttribute(appendable, "table:default-cell-style-name",
                    this.defaultCellStyle.getName());
        appendable.append("/>");
    }
1200710
File appendSheet(final List<WorksheetContent> worksheetContents) throws IOException {
        final ImmutableSet<String> worksheetNames = FluentIterable.from(worksheetContents)
                .transform(new Function<WorksheetContent, String>() {
                    @Nullable @Override public String apply(@Nullable final WorksheetContent worksheetContent) {
                        return worksheetContent.getSpec().getSheetName();
                    }
                }).toSet();
        if(worksheetNames.size() < worksheetContents.size()) {
            throw new IllegalArgumentException("Sheet names must have distinct names");
        }
        for (final String worksheetName : worksheetNames) {
            if(worksheetName.length() > 30) {
                throw new IllegalArgumentException(
                        String.format("Sheet name cannot exceed 30 characters (invalid name: '%s')",
                                worksheetName));
            }
        }

        final XSSFWorkbook workbook = new XSSFWorkbook();
        final File tempFile =
                File.createTempFile(ExcelConverter.class.getName(), UUID.randomUUID().toString() + XLSX_SUFFIX);
        final FileOutputStream fos = new FileOutputStream(tempFile);

        for (WorksheetContent worksheetContent : worksheetContents) {
            final WorksheetSpec spec = worksheetContent.getSpec();
            appendSheet(workbook, worksheetContent.getDomainObjects(), spec.getFactory(), spec.getSheetName());
        }
        workbook.write(fos);
        fos.close();
        return tempFile;
    }
595583
public void appendLVAttributes(final XMLUtil util,
									  final Appendable appendable) throws IOException {
		this.appendLocaleAttributes(util, appendable);
		this.appendVolatileAttribute(util, appendable);
	}