Package org.waveprotocol.wave.model.document.util

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder


        selectionMatcher.getHtmlEnd());

    Point<ContentNode> normalizedStart = normalize(contentSelection.getFirst());
    Point<ContentNode> normalizedEnd = normalize(contentSelection.getSecond());

    final XmlStringBuilder xmlInRange;
    final List<RangedAnnotation<String>> normalizedAnnotations;
    if (useSemanticCopyPaste) {
      String debugString =
          "Start: " + contentSelection.getFirst() + " End: " + contentSelection.getSecond()
              + " docDebug: " + mutableDocument.toDebugString();
View Full Code Here


    N nearestCommonAncestor =
        DocHelper.nearestCommonAncestor(doc, start.getCanonicalNode(), end.getCanonicalNode());

    Range inclusion = new Range(doc.getLocation(start), doc.getLocation(end));

    XmlStringBuilder builder =
      XmlStringBuilder.createEmptyWithCharConstraints(PermittedCharacters.BLIP_TEXT);

    E asElement = doc.asElement(nearestCommonAncestor);
    if (asElement != null) {
      for (N child = doc.getFirstChild(asElement);
           child != null; child = doc.getNextSibling(child)) {
        builder.append(augmentBuilder(child, inclusion));
      }
      if (asElement != doc.getDocumentElement()
          && shouldInclude(inclusion, getNodeRange(asElement))) {
        builder.wrap(doc.getTagName(asElement),
            CollectionUtils.adaptStringMap(doc.getAttributes(asElement)));
      }
    } else {
      T asText = doc.asText(nearestCommonAncestor);
      int tStart = doc.getLocation(asText);
      String substring =
          doc.getData(asText).substring(inclusion.getStart() - tStart, inclusion.getEnd() - tStart);

      builder.appendText(substring);
    }
    return builder;
  }
View Full Code Here

    return builder;
  }

  private XmlStringBuilder augmentBuilder(N node, Range inclusion) {
    Range nodeRange = getNodeRange(node);
    XmlStringBuilder builder = XmlStringBuilder.createEmpty();

    if (!shouldInclude(inclusion, nodeRange)) {
      return builder;
    }

    E asElement = doc.asElement(node);
    if (doc.asElement(node) != null) {
      for (N child = doc.getFirstChild(node); child != null; child = doc.getNextSibling(child)) {
        builder.append(augmentBuilder(child, inclusion));
      }
      builder.wrap(doc.getTagName(asElement),
          CollectionUtils.adaptStringMap(doc.getAttributes(asElement)));
    } else {
      T asText = doc.asText(node);
      int tStart = doc.getLocation(asText);
      String data = doc.getData(asText);
      int start = Math.max(0, inclusion.getStart() - tStart);
      int end = Math.min(data.length(), inclusion.getEnd() - tStart);

      builder.appendText(data.substring(start, end));
    }

    return builder;
  }
View Full Code Here

    int from = -1;
    if (focusedRange != null) {
      from = focusedRange.getFocus();
    }
    if (url != null && !url.isEmpty()) {
      XmlStringBuilder xml = GadgetXmlUtil.constructXml(url, "", user.getAddress());
      CMutableDocument document = editor.getDocument();
      if (document == null) {
        return;
      }
      if (from != -1) {
View Full Code Here

                  } else {
                    // Still no selection.  Oh well, put it at the end.
                    point = doc.locate(doc.size() - 1);
                  }
                }
                XmlStringBuilder content = ImageThumbnail.constructXml(attachmentId, fileName);
                ImageThumbnailWrapper thumbnail = ImageThumbnailWrapper.of(doc.insertXml(point, content));
                thumbnail.setAttachmentId(attachmentId);
              }
            });
View Full Code Here

  public static boolean isNameValuePairElement(ContentNode node) {
    return EditorDocHelper.isNamedElement(node, NAMEVALUEPAIR_TAG);
  }

  public static XmlStringBuilder createXml(String url) {
    XmlStringBuilder builder = XmlStringBuilder.createEmpty();
    builder.wrap(TEMPLATE_TAG, URL_ATTRIBUTE, url);
    return builder;
  }
View Full Code Here

      } else {
        // Still no selection.  Oh well, put it at the end.
        point = doc.locate(doc.size() - 1);
      }
    }
    XmlStringBuilder content = ImageThumbnail.constructXml(null, filename);
    thumbnail = ImageThumbnailWrapper.of(doc.insertXml(point, content));
  }
View Full Code Here

   * @param i The index at which to insert the tag.
   */
  public void addTag(String tagName, int i) {
    E node = getNthTagNode(i);
    El<N> point = Point.<N>inElement(doc.getDocumentElement(), node);
    XmlStringBuilder xml = getXmlFor(tagName);
    doc.insertXml(point, xml);
  }
View Full Code Here

    String content = OperationUtil.getRequiredParameter(operation, ParamsProperty.CONTENT);
    String blipId = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_ID);
    ConversationBlip convBlip = context.getBlip(conversation, blipId);

    // Create builder from xml content.
    XmlStringBuilder markupBuilder = XmlStringBuilder.createFromXmlString(content);

    // Append the new markup to the blip doc.
    Document doc = convBlip.getContent();
    LineContainers.appendLine(doc, markupBuilder);
View Full Code Here

      // While the client libraries force a newline to be sent as the first
      // character we'll remove it here since the new blip we created already
      // contains a newline.
      content = content.substring(1);
    }
    XmlStringBuilder builder = XmlStringBuilder.createText(content);
    LineContainers.appendToLastLine(newBlip.getContent(), builder);
  }
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.util.XmlStringBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.