Does anybody know, if there is a way to modify Oxygen XML Author 13.2, that it uses for normal text in the Autormode german "typograhic" quotation marks („Word“ instead of "Word") by clicking the key " on the keyboard?
Thx,
Stefan
this.authorAccess.getDocumentController().setDocumentFilter(new AuthorDocumentFilter() {
/**
* @see ro.sync.ecss.extensions.api.AuthorDocumentFilter#insertText(ro.sync.ecss.extensions.api.AuthorDocumentFilterBypass, int, java.lang.String)
*/
@Override
public void insertText(AuthorDocumentFilterBypass filterBypass, int offset, String toInsert) {
if(toInsert.length() == 1 && "\"".equals(toInsert)) {
//User typed a quote but he actually needs a smart quote.
//So we either have to add \u201E (start smart quote)
//Or we add \u201C (end smart quote)
//Depending on whether we already have a start smart quote inserted in the current paragraph.
try {
AuthorNode currentNode = authorAccess.getDocumentController().getNodeAtOffset(offset);
int startofTextInCurrentNode = currentNode.getStartOffset();
if(offset > startofTextInCurrentNode) {
Segment seg = new Segment();
authorAccess.getDocumentController().getChars(startofTextInCurrentNode, offset - startofTextInCurrentNode, seg);
String previosTextInNode = seg.toString();
boolean insertStartQuote = true;
for (int i = previosTextInNode.length() - 1; i >= 0; i--) {
char ch = previosTextInNode.charAt(i);
if('\u201C' == ch) {
//Found end of smart quote, so yes, we should insert a start one
break;
} else if('\u201E' == ch) {
//Found start quote, so we should insert an end one.
insertStartQuote = false;
break;
}
}
if(insertStartQuote) {
toInsert = "\u201E";
} else {
toInsert = "\u201C";
}
}
} catch (BadLocationException e) {
e.printStackTrace();
}
}
System.err.println("INSERT TEXT |" + toInsert + "|");
super.insertText(filterBypass, offset, toInsert);
}
});try {
Segment seg = new Segment();
authorAccess.getDocumentController().getChars(offset-1, 1, seg);
char ch = seg.toString().charAt(0);
boolean insertStartQuote = false;
if (' ' == ch){
insertStartQuote = true;
}
if(insertStartQuote) {
toInsert = "\u201E";
} else {
toInsert = "\u201C";
}
}<p>this is <del>the</del>„an“ exmaple</p>(„text“) also [„text“] also {„text“}Users browsing this forum: No registered users and 0 guests