Quotation marks

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.

Quotation marks

Postby stdu » Mon May 14, 2012 5:30 pm

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
stdu
 
Posts: 31
Joined: Mon Mar 05, 2012 5:23 pm

Re: Quotation marks

Postby Radu » Tue May 15, 2012 10:14 am

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.html#XML_Editor_Authoring_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, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Radu
 
Posts: 2014
Joined: Fri Jul 09, 2004 5:18 pm

Re: Quotation marks

Postby stdu » Tue May 15, 2012 12:03 pm

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: 31
Joined: Mon Mar 05, 2012 5:23 pm

Re: Quotation marks

Postby stdu » Wed Jun 13, 2012 11:12 am

Hi Radu,

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

Thx & Greets,
Stefan
stdu
 
Posts: 31
Joined: Mon Mar 05, 2012 5:23 pm

Re: Quotation marks

Postby Radu » Wed Jun 13, 2012 11:31 am

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, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Radu
 
Posts: 2014
Joined: Fri Jul 09, 2004 5:18 pm

Re: Quotation marks

Postby stdu » Fri Jul 06, 2012 5:21 pm

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
stdu
 
Posts: 31
Joined: Mon Mar 05, 2012 5:23 pm

Re: Quotation marks

Postby Radu » Fri Jul 06, 2012 5:28 pm

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, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Radu
 
Posts: 2014
Joined: Fri Jul 09, 2004 5:18 pm

Re: Quotation marks

Postby stdu » Thu Jul 12, 2012 6:29 pm

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
stdu
 
Posts: 31
Joined: Mon Mar 05, 2012 5:23 pm


Return to Common Problems

Who is online

Users browsing this forum: No registered users and 0 guests