Skip to content

Commit

Permalink
Add text-transform property
Browse files Browse the repository at this point in the history
  • Loading branch information
bertfrees committed Jun 22, 2015
1 parent 6d14e0f commit 98fbf46
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.daisy.braille.css.BrailleCSSProperty.Page;
import org.daisy.braille.css.BrailleCSSProperty.StringSet;
import org.daisy.braille.css.BrailleCSSProperty.TextIndent;
import org.daisy.braille.css.BrailleCSSProperty.TextTransform;

import cz.vutbr.web.css.CSSFactory;
import cz.vutbr.web.css.CSSProperty;
Expand Down Expand Up @@ -281,6 +282,32 @@ private boolean processTextIndent(Declaration d,
d, properties, values);
}

@SuppressWarnings("unused")
private boolean processTextTransform(Declaration d,
Map<String, CSSProperty> properties, Map<String, Term<?>> values) {

if (d.size() == 1 && genericOneIdent(TextTransform.class, d, properties))
return true;

TermList list = tf.createList();
for (Term<?> t : d.asList()) {
if (t instanceof TermIdent) {
String value = ((TermIdent)t).getValue().toLowerCase();
if (!value.equals("auto"))
list.add(t);
}
else
return false;
}

if (list.isEmpty())
return false;

properties.put("text-transform", TextTransform.list_values);
values.put("text-transform", list);
return true;
}

/****************************************************************
* GENERIC METHODS
****************************************************************/
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/org/daisy/braille/css/BrailleCSSProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,27 @@ public String toString() {
return text;
}
}

public enum TextTransform implements BrailleCSSProperty {
list_values(""), AUTO("auto"), INHERIT("inherit");

private String text;

private TextTransform(String text) {
this.text = text;
}

public boolean inherited() {
return false;
}

public boolean equalsInherit() {
return this == INHERIT;
}

@Override
public String toString() {
return text;
}
}
}
5 changes: 4 additions & 1 deletion src/main/java/org/daisy/braille/css/SupportedBrailleCSS.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.daisy.braille.css.BrailleCSSProperty.Page;
import org.daisy.braille.css.BrailleCSSProperty.StringSet;
import org.daisy.braille.css.BrailleCSSProperty.TextIndent;
import org.daisy.braille.css.BrailleCSSProperty.TextTransform;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -39,7 +40,7 @@ public class SupportedBrailleCSS implements SupportedCSS {

private static Logger log = LoggerFactory.getLogger(SupportedBrailleCSS.class);

private static final int TOTAL_SUPPORTED_DECLARATIONS = 31;
private static final int TOTAL_SUPPORTED_DECLARATIONS = 32;

private static final TermFactory tf = CSSFactory.getTermFactory();

Expand Down Expand Up @@ -217,6 +218,8 @@ private void setSupportedCSS() {
properties.add("string-set");
props.put("content", Content.NONE);
properties.add("content");
props.put("text-transform", TextTransform.AUTO);
properties.add("text-transform");

this.defaultCSSproperties = props;
this.defaultCSSvalues = values;
Expand Down

0 comments on commit 98fbf46

Please sign in to comment.