Package org.odftoolkit.odfdom.dom.element

Examples of org.odftoolkit.odfdom.dom.element.OdfStyleBase


    }
  }

  private String getDataDisplayStyleName() {
    String datadisplayStylename = null;
    OdfStyleBase styleElement = getStyleHandler().getStyleElementForRead();
    if (styleElement != null) {
      datadisplayStylename = styleElement.getOdfAttributeValue(OdfName.newName(OdfDocumentNamespace.STYLE,
          "data-style-name"));
    }

    return datadisplayStylename;
  }
View Full Code Here


    FontMetrics fm = txtField.getFontMetrics(txtField.getFont());
    // content width in pixels.
    int widthPixels = fm.stringWidth(content);
    // content height in pixels.
    // int heightPixels = fm.getHeight();
    OdfStyleBase properties = getStyleHandler().getStyleElementForRead();
    double millimeterPadding = 0.0;
    if(properties!=null){
      String padding = properties.getProperty(StyleTableCellPropertiesElement.Padding);
      if(padding!=null){
        millimeterPadding = Length.parseDouble(padding, Unit.MILLIMETER);
      }
    }
    // convert width pixels to mm
View Full Code Here

   * Get the style name of this paragraph
   *
   * @return - the style name
   */
  public String getStyleName() {
    OdfStyleBase style = getStyleHandler().getStyleElementForRead();
    if (style == null) {
      return "";
    }
    if (style instanceof OdfStyle)
      return ((OdfStyle) style).getStyleNameAttribute();
View Full Code Here

   * get a map containing text properties of the specified styleable element.
   * @return  a map of text properties.
   */
  private Map<OdfStyleProperty, String> getTextStyleProperties(OdfStylableElement element) {
    String styleName = element.getStyleName();
    OdfStyleBase styleElement = element.getAutomaticStyles().getStyle(
        styleName, element.getStyleFamily());

    if (styleElement == null) {
      styleElement = element.getDocumentStyle();
    }
    if (styleElement != null) {
      //check if it is the style:defaut-style
      if ((styleElement.getPropertiesElement(OdfStylePropertiesSet.ParagraphProperties) == null) &&
          (styleElement.getPropertiesElement(OdfStylePropertiesSet.TextProperties) == null)) {
        styleElement = ((OdfDocument) ((OdfFileDom) styleElement.getOwnerDocument()).getDocument()).getDocumentStyles().getDefaultStyle(styleElement.getFamily());
      }
      TreeMap<OdfStyleProperty, String> result = new TreeMap<OdfStyleProperty, String>();
      OdfStyleFamily family = OdfStyleFamily.Text;
      if (family != null) {
        for (OdfStyleProperty property : family.getProperties()) {
          if (styleElement.hasProperty(property)) {
            result.put(property, styleElement.getProperty(property));
          }
        }
      }
      return result;
    }
View Full Code Here

   * @return  a map of text properties.
   *
   */
  private Map<OdfStyleProperty, String> getTextStylePropertiesDeep(OdfStylableElement element) {
    String styleName = element.getStyleName();
    OdfStyleBase styleElement = element.getAutomaticStyles().getStyle(
        styleName, element.getStyleFamily());

    if (styleElement == null) {
      styleElement = element.getDocumentStyle();
    }
    TreeMap<OdfStyleProperty, String> result = new TreeMap<OdfStyleProperty, String>();
    while (styleElement != null) {
      //check if it is the style:defaut-style
      if ((styleElement.getPropertiesElement(OdfStylePropertiesSet.ParagraphProperties) == null) &&
          (styleElement.getPropertiesElement(OdfStylePropertiesSet.TextProperties) == null)) {
        styleElement = ((OdfDocument) ((OdfFileDom) styleElement.getOwnerDocument()).getDocument()).getDocumentStyles().getDefaultStyle(styleElement.getFamily());
      }
      OdfStyleFamily family = OdfStyleFamily.Text;
      if (family != null) {
        for (OdfStyleProperty property : family.getProperties()) {
          if (styleElement.hasProperty(property)) {
            result.put(property, styleElement.getProperty(property));
          }
        }
      }
      styleElement = styleElement.getParentStyle();

    }
    return result;
  }
View Full Code Here

   * @since 0.5.5
   */
  public void setVerticalMargin(double spaceTop, double spaceBottom) {
    String tableStyleName = mTableElement.getStyleName();
    OdfOfficeAutomaticStyles automaticStyles = mTableElement.getAutomaticStyles();
    OdfStyleBase tableStyle = automaticStyles.getStyle(tableStyleName, OdfStyleFamily.Table);
    if (tableStyle != null) {
      tableStyle.setProperty(StyleTablePropertiesElement.MarginTop,
          (new DecimalFormat("#0.##").format(spaceTop) + Unit.CENTIMETER.abbr()).replace(",", "."));
      tableStyle.setProperty(StyleTablePropertiesElement.MarginBottom, (new DecimalFormat("#0.##")
          .format(spaceBottom) + Unit.CENTIMETER.abbr()).replace(",", "."));
    }
  }
View Full Code Here

   * @deprecated As of Simple version 0.3, replaced by
   *             <code>getHorizontalAlignmentType()</code>
   */
  @Deprecated
  public String getHorizontalAlignment() {
    OdfStyleBase styleElement = getStyleHandler().getStyleElementForRead();
    if (styleElement != null) {
      OdfStyleProperty property = OdfStyleProperty.get(OdfStylePropertiesSet.ParagraphProperties, OdfName
          .newName(OdfDocumentNamespace.FO, "text-align"));
      return styleElement.getProperty(property);
    }
    return null;
  }
View Full Code Here

    }
    if (FoTextAlignAttribute.Value.RIGHT.toString().equalsIgnoreCase(horizontalAlignment)) {
      horizontalAlignment = FoTextAlignAttribute.Value.END.toString();
    }
    splitRepeatedCells();
    OdfStyleBase styleElement = getStyleHandler().getStyleElementForWrite();
    if (styleElement != null) {
      OdfStyleProperty property = OdfStyleProperty.get(OdfStylePropertiesSet.ParagraphProperties, OdfName
          .newName(OdfDocumentNamespace.FO, "text-align"));
      if (horizontalAlignment != null) {
        styleElement.setProperty(property, horizontalAlignment);
      } else {
        styleElement.removeProperty(property);
      }
    }
  }
View Full Code Here

   * @deprecated As of Simple version 0.3, replaced by
   *             <code>getVerticalAlignmentType()</code>
   */
  @Deprecated
  public String getVerticalAlignment() {
    OdfStyleBase styleElement = getStyleHandler().getStyleElementForRead();
    if (styleElement != null) {
      OdfStyleProperty property = OdfStyleProperty.get(OdfStylePropertiesSet.TableCellProperties, OdfName
          .newName(OdfDocumentNamespace.STYLE, "vertical-align"));
      return styleElement.getProperty(property);
    }
    return null;
  }
View Full Code Here

   *             <code>setVerticalAlignment(SimpleVerticalAlignmentType)</code>
   */
  @Deprecated
  public void setVerticalAlignment(String verticalAlignment) {
    splitRepeatedCells();
    OdfStyleBase styleElement = getStyleHandler().getStyleElementForWrite();
    if (styleElement != null) {
      OdfStyleProperty property = OdfStyleProperty.get(OdfStylePropertiesSet.TableCellProperties, OdfName
          .newName(OdfDocumentNamespace.STYLE, "vertical-align"));
      if (verticalAlignment != null) {
        styleElement.setProperty(property, verticalAlignment);
      } else {
        styleElement.removeProperty(property);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.dom.element.OdfStyleBase

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.