Quotation marks

Having trouble installing Oxygen? Got a bug to report? Post it all here.
stdu
Posts: 81
Joined: Mon Mar 05, 2012 5:23 pm

Quotation marks

Post by stdu »

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
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Quotation marks

Post by Radu »

Hi Stefan,

We do not have a specific Oxygen option for this but I will register this as an improvement request.

You have the following options:

1) If you have a Java developer, our Author SDK has API which would allow you to implement an extension which would allow you to take control over the characters inserted when the user types:

http://www.oxygenxml.com/oxygen_sdk.htm ... horing_SDK

So if you choose this approach, I will give you more details.

2) As a workaround you can either use the Character Map available in the Edit menu to insert the quotes or you can create code templates.
In the Oxygen Preferences->Editor / Templates / Code Templates page you can define code templates which would insert either a starting double quote or an end double quote.
Then in the Author page when pressing ENTER you would also see (and be able to use) the code templates in the completion proposal window.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
stdu
Posts: 81
Joined: Mon Mar 05, 2012 5:23 pm

Re: Quotation marks

Post by stdu »

Hi Radu,

thanks for your reply. We would choose option 1, beacause we have a java developer, who had already work with the Author SDK to implement special operations for our custom Oxygen framework. Some Details and hints for this way would be very useful.

Thx,
Stefan
stdu
Posts: 81
Joined: Mon Mar 05, 2012 5:23 pm

Re: Quotation marks

Post by stdu »

Hi Radu,

can you give me some details for option 1? That would be very useful for our java developer :wink:

Thx & Greets,
Stefan
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Quotation marks

Post by Radu »

Hi Stefan,

Thanks for reminding me, I somehow overlooked your previous reply.

Here is a small implementation using the existing API:

Code: Select all

    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);
}
});
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
stdu
Posts: 81
Joined: Mon Mar 05, 2012 5:23 pm

Re: Quotation marks

Post by stdu »

Hi Radu,

thanks for your "ready-to-go"-code - this was very helpful! For further implementing or other people who are interested in the issue: we've have changed a bit the code above. Instead of looking for an already existing quote, we are looking if there is a white space before the cursor. If the character before the cursor is a white space an \u201E (start quote) is inserted, if not \u201C (end quote) is inserted. This functions because in german orthography there is always a space before the start quote and never before the end quote. Other programs like LibreOffice etc. function also in this way.

You can achieve this behaviour by replacing the "try"-Part of the code above with the following code:

Code: Select all

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";
}
}
Greets,
Stefan
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Quotation marks

Post by Radu »

Hi Stefan,

It's great that you shared this easier and more robust solution with us, indeed word processors seem to work this way.
We plan to implement this feature ourselves in the near future and it helps.

Probably the only addition would be that if you are exactly at the start of a paragraph (and you have no space before the caret) you would still need to insert a start quote.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
stdu
Posts: 81
Joined: Mon Mar 05, 2012 5:23 pm

Re: Quotation marks

Post by stdu »

Hi Radu,

you're right: after a paragraph starts there would be no space before the start quote. This could happens also by other tags, where the space is in or before these elements, e.g.:

Code: Select all

<p>this is <del>the</del>„an“ exmaple</p>
And my colleage came into the mind a situation in german orthographic, where no space is before the start quote: if the quoted text is in a bracket, e.g.:

Code: Select all

(„text“) also [„text“] also {„text“}
But that's all - I think.

Greets,
Stefan
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Quotation marks

Post by Radu »

Hi Stefan,

We released Oxygen 15.0 a couple of days ago.
In Oxygen 15.0 we added out of the box support to configure the smart quotes behavior.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
ms-badw
Posts: 2
Joined: Wed Oct 01, 2014 6:36 pm

Re: Quotation marks

Post by ms-badw »

Hi Radu,

sorry for the thread ressurection.

But I am also interested in using "german-style" quotation marks. I'm glad to hear, that they are now included as a standard feature in Oxygen.
However, I can't find where to activate/configure them.
Can you tell me where exactly this option is located? I'm using Oxygen 17.1.

Regards,

Maximilian
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Quotation marks

Post by Radu »

Hi Max,

In the Oxygen Preferences->Editor / Edit modes / Author / AutoCorrect page there should be a "Smart Quotes" section.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply